Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multitarget #29

Merged
merged 13 commits into from
Apr 23, 2020
2 changes: 1 addition & 1 deletion .haxerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "4.0.0",
"version": "4.0.5",
"resolveLibs": "scoped"
}
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ os:
# - osx

env:
- HAXE_VERSION=3.4.7
- HAXE_VERSION=latest
# - HAXE_VERSION=nightly
- HAXE_VERSION=nightly

install:
- npm i -g lix
- lix install haxe $HAXE_VERSION
- lix download

script:
- lix run travix js

Expand Down
2 changes: 0 additions & 2 deletions extraParams.hxml

This file was deleted.

8 changes: 3 additions & 5 deletions haxe_libraries/coconut.diffing.hxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
-D coconut.diffing=0.1.0
# @install: lix --silent download "haxelib:/coconut.diffing#0.1.0" into coconut.diffing/0.1.0/haxelib
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.diffing#fa9b0bcb68b20782250e7bb87ede7417bb4e4230" into coconut.diffing/0.1.0/github/fa9b0bcb68b20782250e7bb87ede7417bb4e4230
-lib coconut.ui
-cp ${HAXE_LIBCACHE}/coconut.diffing/0.1.0/haxelib/src
--macro coconut.diffing.macros.Setup.all()
-D hxx_fragment=coconut.diffing.VNode.fragment
-cp ${HAXE_LIBCACHE}/coconut.diffing/0.1.0/github/fa9b0bcb68b20782250e7bb87ede7417bb4e4230/src
-D coconut.diffing=0.1.0
6 changes: 3 additions & 3 deletions haxe_libraries/coconut.ui.hxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-D coconut.ui=0.10.0
# @install: lix --silent download "haxelib:/coconut.ui#0.10.0" into coconut.ui/0.10.0/haxelib
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.ui#b75ff3be15d233973c9697cc14c9386df36c2e33" into coconut.ui/0.10.0/github/b75ff3be15d233973c9697cc14c9386df36c2e33
-lib coconut.data
-lib tink_anon
-lib tink_hxx
-lib tink_lang
-cp ${HAXE_LIBCACHE}/coconut.ui/0.10.0/haxelib/src
-cp ${HAXE_LIBCACHE}/coconut.ui/0.10.0/github/b75ff3be15d233973c9697cc14c9386df36c2e33/src
-D coconut.ui=0.10.0
-D coconut_ui
1 change: 0 additions & 1 deletion haxe_libraries/coconut.vdom.hxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-cp src
-D coconut.vdom
-lib coconut.diffing
extraParams.hxml
-lib tink_hxx
-lib tink_csss
-lib tink_state
Expand Down
6 changes: 3 additions & 3 deletions haxe_libraries/tink_anon.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-D tink_anon=0.4.1
# @install: lix --silent download "haxelib:/tink_anon#0.4.1" into tink_anon/0.4.1/haxelib
# @install: lix --silent download "haxelib:/tink_anon#0.5.0" into tink_anon/0.5.0/haxelib
-lib tink_macro
-cp ${HAXE_LIBCACHE}/tink_anon/0.4.1/haxelib/src
-cp ${HAXE_LIBCACHE}/tink_anon/0.5.0/haxelib/src
-D tink_anon=0.5.0
2 changes: 1 addition & 1 deletion haxe_libraries/tink_chunk.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-D tink_chunk=0.3.1
# @install: lix --silent download "haxelib:/tink_chunk#0.3.1" into tink_chunk/0.3.1/haxelib
-cp ${HAXE_LIBCACHE}/tink_chunk/0.3.1/haxelib/src
-D tink_chunk=0.3.1
6 changes: 3 additions & 3 deletions haxe_libraries/tink_cli.hxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-D tink_cli=0.4.1
# @install: lix --silent download "haxelib:/tink_cli#0.4.1" into tink_cli/0.4.1/haxelib
# @install: lix --silent download "haxelib:/tink_cli#0.5.0" into tink_cli/0.5.0/haxelib
-lib tink_io
-lib tink_macro
-lib tink_stringly
-cp ${HAXE_LIBCACHE}/tink_cli/0.4.1/haxelib/src
-cp ${HAXE_LIBCACHE}/tink_cli/0.5.0/haxelib/src
-D tink_cli=0.5.0
# Make sure docs are generated
-D use-rtti-doc
6 changes: 3 additions & 3 deletions haxe_libraries/tink_core.hxml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-D tink_core=1.24.0
# @install: lix --silent download "haxelib:/tink_core#1.24.0" into tink_core/1.24.0/haxelib
-cp ${HAXE_LIBCACHE}/tink_core/1.24.0/haxelib/src
# @install: lix --silent download "haxelib:/tink_core#1.26.0" into tink_core/1.26.0/haxelib
-cp ${HAXE_LIBCACHE}/tink_core/1.26.0/haxelib/src
-D tink_core=1.26.0
6 changes: 3 additions & 3 deletions haxe_libraries/tink_hxx.hxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-D tink_hxx=0.22.2
# @install: lix --silent download "haxelib:/tink_hxx#0.22.2" into tink_hxx/0.22.2/haxelib
# @install: lix --silent download "haxelib:/tink_hxx#0.23.0" into tink_hxx/0.23.0/haxelib
-lib html-entities
-lib tink_anon
-lib tink_parse
-cp ${HAXE_LIBCACHE}/tink_hxx/0.22.2/haxelib/src
-cp ${HAXE_LIBCACHE}/tink_hxx/0.23.0/haxelib/src
-D tink_hxx=0.23.0
2 changes: 1 addition & 1 deletion haxe_libraries/tink_io.hxml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-D tink_io=0.7.1
# @install: lix --silent download "haxelib:/tink_io#0.7.1" into tink_io/0.7.1/haxelib
-lib tink_chunk
-lib tink_streams
-cp ${HAXE_LIBCACHE}/tink_io/0.7.1/haxelib/src
-D tink_io=0.7.1
6 changes: 3 additions & 3 deletions haxe_libraries/tink_macro.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-D tink_macro=0.18.0
# @install: lix --silent download "haxelib:/tink_macro#0.18.0" into tink_macro/0.18.0/haxelib
# @install: lix --silent download "haxelib:/tink_macro#0.19.0" into tink_macro/0.19.0/haxelib
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_macro/0.18.0/haxelib/src
-cp ${HAXE_LIBCACHE}/tink_macro/0.19.0/haxelib/src
-D tink_macro=0.19.0
6 changes: 3 additions & 3 deletions haxe_libraries/tink_state.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-D tink_state=0.11.0
# @install: lix --silent download "haxelib:/tink_state#0.11.0" into tink_state/0.11.0/haxelib
# @install: lix --silent download "gh://github.com/haxetink/tink_state#2c1770b52411491e8aaba22cb8b85ddad1dc9ccb" into tink_state/0.11.0/github/2c1770b52411491e8aaba22cb8b85ddad1dc9ccb
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_state/0.11.0/haxelib/src
-cp ${HAXE_LIBCACHE}/tink_state/0.11.0/github/2c1770b52411491e8aaba22cb8b85ddad1dc9ccb/src
-D tink_state=0.11.0
2 changes: 1 addition & 1 deletion haxe_libraries/tink_streams.hxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-D tink_streams=0.3.2
# @install: lix --silent download "haxelib:/tink_streams#0.3.2" into tink_streams/0.3.2/haxelib
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_streams/0.3.2/haxelib/src
-D tink_streams=0.3.2
# temp for development, delete this file when pure branch merged
-D pure
2 changes: 1 addition & 1 deletion haxe_libraries/tink_stringly.hxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-D tink_stringly=0.4.0
# @install: lix --silent download "haxelib:/tink_stringly#0.4.0" into tink_stringly/0.4.0/haxelib
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_stringly/0.4.0/haxelib/src
-D tink_stringly=0.4.0
10 changes: 5 additions & 5 deletions haxe_libraries/travix.hxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-D travix=0.13.1
# @install: lix --silent download "haxelib:/travix#0.13.1" into travix/0.13.1/haxelib
# @post-install: cd ${HAXE_LIBCACHE}/travix/0.13.1/haxelib && haxe -cp src --run travix.PostDownload
# @run: haxelib run-dir travix ${HAXE_LIBCACHE}/travix/0.13.1/haxelib
# @install: lix --silent download "haxelib:/travix#0.14.0" into travix/0.14.0/haxelib
# @post-install: cd ${HAXE_LIBCACHE}/travix/0.14.0/haxelib && haxe -cp src --run travix.PostDownload
# @run: haxelib run-dir travix ${HAXE_LIBCACHE}/travix/0.14.0/haxelib
-lib tink_cli
-cp ${HAXE_LIBCACHE}/travix/0.13.1/haxelib/src
-cp ${HAXE_LIBCACHE}/travix/0.14.0/haxelib/src
-D travix=0.14.0
6 changes: 6 additions & 0 deletions src/coconut/Ui.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package coconut;

class Ui {
static public macro function hxx(e)
return coconut.vdom.Renderer.hxx(e);
}
3 changes: 3 additions & 0 deletions src/coconut/ui/Children.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package coconut.ui;

typedef Children = coconut.vdom.Children;
22 changes: 1 addition & 21 deletions src/coconut/ui/RenderResult.hx
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
package coconut.ui;

import coconut.diffing.VNode;
import coconut.diffing.*;
import js.html.*;

@:pure
abstract RenderResult(VNode<Node>) to VNode<Node> from VNode<Node> {

inline function new(n) this = n;

@:from static inline function ofText(s:String):RenderResult
return coconut.vdom.Html.text(s);

@:from static function ofInt(i:Int):RenderResult
return ofText(Std.string(i));

@:from static function ofNode(n:Node):RenderResult
return VNativeInst(n);

@:from static function ofView(v:coconut.ui.View):RenderResult
return VWidgetInst(v);
}
typedef RenderResult = coconut.vdom.RenderResult;
87 changes: 1 addition & 86 deletions src/coconut/ui/Renderer.hx
Original file line number Diff line number Diff line change
@@ -1,88 +1,3 @@
package coconut.ui;

import coconut.diffing.*;
import js.Browser.*;
import js.html.*;

class Renderer {

static var DIFFER = new Differ(new DomBackend());

static public function mount(target:Element, vdom:RenderResult)
DIFFER.render([vdom], target);

static public function getNative(view:View):Null<Node>
return getAllNative(view)[0];// not quite the pinnacle of efficiency, but let's see if anyone complains

static public function getAllNative(view:View):Array<Node>
return switch @:privateAccess view._coco_lastRender {
case null: [];
case r: r.flatten(null);
}

static public inline function updateAll()
tink.state.Observable.updateAll();

}

private class DomCursor implements Cursor<Node> {
var parent:Node;
var cur:Node;
public function new(parent:Node, cur:Node) {
this.parent = parent;
this.cur = cur;
}

public function insert(real:Node) {
var inserted = real.parentNode != parent;
parent.insertBefore(real, cur);
return inserted;
}

public function step():Bool
return switch cur {
case null: false;
case v: (cur = v.nextSibling) != null;
}

public function delete():Bool
return
switch cur {
case null: false;
case v:
cur = v.nextSibling;
parent.removeChild(v);
true;
}

public function current():Node
return cur;
}

private class DomBackend implements Applicator<Node> {

static var PLACEHOLDER:RenderResult = '';

public function new() {}

public function unsetLastRender(target:Node):Rendered<Node> {
var ret = untyped target._coco_;
untyped __js__('delete {0}._coco_', target);
return ret;
}

public function traverseSiblings(first:Node)
return new DomCursor(first.parentNode, first);

public function traverseChildren(parent:Node)
return new DomCursor(parent, parent.firstChild);

public function placeholder(target):RenderResult
return PLACEHOLDER;

public function getLastRender(target:Node):Null<Rendered<Node>>
return untyped target._coco_;

public function setLastRender(target:Node, r:Rendered<Node>)
untyped target._coco_ = r;
}
typedef Renderer = coconut.vdom.Renderer;
3 changes: 3 additions & 0 deletions src/coconut/ui/View.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package coconut.ui;

typedef View = coconut.vdom.View;
3 changes: 0 additions & 3 deletions src/coconut/ui/ViewBase.hx

This file was deleted.

3 changes: 3 additions & 0 deletions src/coconut/vdom/Children.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package coconut.vdom;

typedef Children = coconut.ui.ChildrenOf<RenderResult>;
Loading