Browse Source

minor changes for hl compilation progress

Nicolas Cannasse 1 year ago
parent
commit
5dba7fe490

+ 7 - 8
.vscode/tasks.json

@@ -1,17 +1,16 @@
 {
-    "version": "2.0.0",
     "tasks": [
         {
-            "type": "hxml",
-            "file": "hide.hxml",
-            "label": "Build",
+            "type": "haxe",
+            "args": "active configuration",
+            "problemMatcher": [
+                "haxe-fake"
+            ],
             "group": {
                 "kind": "build",
                 "isDefault": true
             },
-            "presentation": {
-                "reveal": "never"
-            }
+            "label": "Build"
         }
-    ],
+    ]
 }

+ 10 - 2
hide/Config.hx

@@ -118,11 +118,19 @@ class Config {
 		save();
 	}
 
+	static function alert(msg) {
+		#if js
+		js.Browser.window.alert(msg);
+		#else
+		throw msg;
+		#end
+	}
+
 	public static function loadConfig(config : Config, path : String) : Config {
 		try {
 			config.load(path);
 		} catch(err) {
-			js.Browser.window.alert('Couldn\'t load config file ${path}. Reverting to default config.\n${err}.');
+			alert('Couldn\'t load config file ${path}. Reverting to default config.\n${err}.');
 		}
 		return config;
 	}
@@ -135,7 +143,7 @@ class Config {
 			defaults.load(hidePath + "/defaultProps.json");
 		}
 		catch (err) {
-			js.Browser.window.alert('Fatal error : Couldn\'t load ${hidePath}/defaultProps.json. Please check your hide installation.\n$err');
+			alert('Fatal error : Couldn\'t load ${hidePath}/defaultProps.json. Please check your hide installation.\n$err');
 			Sys.exit(-1);
 		}
 

+ 3 - 1
hide/Element.hx

@@ -1,3 +1,5 @@
 package hide;
 
-typedef Element = js.jquery.JQuery;
+typedef Element = #if hl hide.tools.vdom.JQuery #else js.jquery.JQuery #end;
+typedef Event = #if hl hide.tools.vdom.Event #else js.jquery.Event #end;
+typedef HTMLElement = #if hl hide.tools.vdom.Dom #else js.html.Element #end;

+ 5 - 0
hide/Ide.hx

@@ -22,6 +22,7 @@ class Ide {
 	public var isDebugger = false;
 
 	public var gamePad(default,null) : hxd.Pad;
+	public var localStorage(get,never) : js.html.Storage;
 
 	var databaseFile : String;
 	var databaseDiff : String;
@@ -74,6 +75,10 @@ class Ide {
 		wait();
 	}
 
+	function get_localStorage() {
+		return js.Browser.window.localStorage;
+	}
+
 	function initPad() {
 		gamePad = hxd.Pad.createDummy();
 		hxd.Pad.wait((p) -> gamePad = p);

+ 3 - 3
hide/comp/Component.hx

@@ -25,7 +25,7 @@ class Component {
 	function getDisplayState( key : String ) : Dynamic {
 		if( saveDisplayKey == null )
 			return null;
-		var v = js.Browser.window.localStorage.getItem(saveDisplayKey + "/" + key);
+		var v = ide.localStorage.getItem(saveDisplayKey + "/" + key);
 		if( v == null )
 			return null;
 		return haxe.Json.parse(v);
@@ -34,13 +34,13 @@ class Component {
 	function saveDisplayState( key : String, value : Dynamic ) {
 		if( saveDisplayKey == null )
 			return;
-		js.Browser.window.localStorage.setItem(saveDisplayKey + "/" + key, haxe.Json.stringify(value));
+		ide.localStorage.setItem(saveDisplayKey + "/" + key, haxe.Json.stringify(value));
 	}
 
 	function removeDisplayState( key : String ) {
 		if( saveDisplayKey == null )
 			return;
-		js.Browser.window.localStorage.removeItem(saveDisplayKey + "/" + key);
+		ide.localStorage.removeItem(saveDisplayKey + "/" + key);
 	}
 
 }

+ 7 - 7
hide/comp/Modal.hx

@@ -12,21 +12,21 @@ class Modal extends Component {
 		element.on("click dblclick keydown keyup keypressed mousedown mouseup mousewheel",function(e) e.stopPropagation());
 		content = new Element("<div class='content'></div>").appendTo(element);
 
-		var exterior = [element[0], content[0]];
-		element[0].addEventListener("mousedown", function(e) {
+		var exterior = [element.get(), content.get()];
+		element.get(0).addEventListener("mousedown", function(e) {
 			downTarget = e.target;
-		}, true);
-		element[0].addEventListener("mouseup", function(e) {
+		}#if js, true #end);
+		element.get(0).addEventListener("mouseup", function(e) {
 			upTarget = e.target;
-		}, true);
-		element.on("click", function(e : js.jquery.Event) {
+		}#if js, true #end);
+		element.on("click", function(e : Element.Event) {
 			if( exterior.contains(downTarget) && exterior.contains(upTarget) ) {
 				modalClick(e);
 			}
 		});
 	}
 
-	public dynamic function modalClick(e: js.jquery.Event) {
+	public dynamic function modalClick(e: Element.Event) {
 	}
 
 	public function close() {

+ 6 - 4
hide/comp/ScriptEditor.hx

@@ -18,9 +18,9 @@ class ScriptCache {
 
 	public function new(configSign:String) {
 		this.configSign = configSign;
-		var key = js.Browser.window.localStorage.getItem("script_cache_key");
+		var key = hide.Ide.inst.localStorage.getItem("script_cache_key");
 		if( key == configSign ) {
-			var values = js.Browser.window.localStorage.getItem("script_cache_val").split(";");
+			var values = hide.Ide.inst.localStorage.getItem("script_cache_val").split(";");
 			for( v in values )
 				content.set(v,true);
 		}
@@ -38,8 +38,8 @@ class ScriptCache {
 			if( b )
 				all.push(key);
 		}
-		js.Browser.window.localStorage.setItem("script_cache_key", configSign);
-		js.Browser.window.localStorage.setItem("script_cache_val", all.join(";"));
+		hide.Ide.inst.localStorage.setItem("script_cache_key", configSign);
+		hide.Ide.inst.localStorage.setItem("script_cache_val", all.join(";"));
 	}
 
 }
@@ -373,6 +373,7 @@ class ScriptChecker {
 
 }
 
+#if !hl
 class ScriptEditor extends CodeEditor {
 
 	var checker : ScriptChecker;
@@ -456,3 +457,4 @@ class ScriptEditor extends CodeEditor {
 	}
 
 }
+#end

+ 5 - 3
hide/comp/Tabs.hx

@@ -11,7 +11,7 @@ class Tabs extends Component {
 		if( bottomTabs ) element.addClass("tabs-bottom");
 		header = new Element("<div>").addClass("tabs-header").prependTo(element);
 		syncTabs();
-		var t = getTabs()[0];
+		var t = getTabs().get();
 		if( t != null ) currentTab = new Element(t);
 	}
 
@@ -26,17 +26,19 @@ class Tabs extends Component {
 	}
 
 	public function getHeader( tab : Element ) {
-		var index = [for( t in getTabs() ) t].indexOf(tab[0]);
+		var index = [for( t in getTabs() ) t].indexOf(tab.get(0));
 		if( index < 0 ) return null;
 		return header.find('[index=$index]');
 	}
 
+	#if !hl
 	public function allowMask(scene : hide.comp.Scene) {
 		new Element('<a href="#" class="maskToggle"></a>').prependTo(element).click((_) -> {
 			element.toggleClass("masked");
 			@:privateAccess scene.window.checkResize();
 		});
 	}
+	#end
 
 	function set_currentTab( e : Element ) {
 		var index = Std.parseInt(e.attr("index"));
@@ -65,7 +67,7 @@ class Tabs extends Component {
 			var icon = t.attr("icon");
 			var name = t.attr("name");
 			var index = index++;
-			var tab = new Element("<div>").html( (icon != null ? '<div class="ico ico-$icon"></div> ' : '') + (name != null ? name : '') );
+			var tab = new Element("<div>").html( (icon != null ? '<div class="ico ico-$icon"></div> ' : '') + (name != null ? (name:String) : '') );
 			t.attr("index", index);
 			tab.attr("index", index);
 			tab.appendTo(header);

+ 45 - 20
hide/comp/cdb/Cell.hx

@@ -10,7 +10,7 @@ class Cell {
 
 	var ide : hide.Ide;
 
-	public var elementHtml : js.html.Element;
+	public var elementHtml : Element.HTMLElement;
 	var editor : Editor;
 	var currentValue : Dynamic;
 	var watches : Array<String> = new Array<String>();
@@ -21,9 +21,9 @@ class Cell {
 	public var table(get, never) : Table;
 	var blurOff = false;
 	public var inEdit = false;
-	var dropdown : js.html.Element = null;
+	var dropdown : Element.HTMLElement = null;
 
-	public function new( root : js.html.Element, line : Line, column : cdb.Data.Column ) {
+	public function new( root : Element.HTMLElement, line : Line, column : cdb.Data.Column ) {
 		this.elementHtml = root;
 		ide = hide.Ide.inst;
 
@@ -149,7 +149,9 @@ class Cell {
 			var forms : Array<hide.comp.ContextMenu.ContextMenuItem>;
 			var current = editor.formulas.get(this);
 			forms = [for( f in editor.formulas.getList(table.sheet) ) { label : f.name, click : () -> if( f == current ) setF(null) else setF(f), checked : f == current }];
+			#if !hl
 			forms.push({ label : "New...", click : () -> editor.formulas.createNew(this, setF) });
+			#end
 			menu = [
 				{ label : "Formula", menu : forms }
 			];
@@ -185,12 +187,14 @@ class Cell {
 	}
 
 	public function refresh(withSubtable = false) {
+		#if js
 		if (dropdown != null) {
 			if (js.Browser.document.body.contains(dropdown)) {
 				return;
 			}
 			dropdown = null;
 		}
+		#end
 		currentValue = Reflect.field(line.obj, column.name);
 
 		blurOff = true;
@@ -440,13 +444,14 @@ class Cell {
 			html('<div class="color" style="background-color:#${StringTools.hex(v,6)}"></div>');
 		case TFile:
 			var path = ide.getPath(v);
-			var url = ide.getUnCachedUrl(path);
 			var ext = v.split(".").pop().toLowerCase();
 			if (v == "") return html('<span class="error">#MISSING</span>');
 			var innerHtml = StringTools.htmlEscape(v);
 			innerHtml = '<span title=\'$innerHtml\' >' + innerHtml  + '</span>';
 			if (!editor.quickExists(path)) return html('<span class="error">#NOTFOUND : $innerHtml</span>');
 			else if( ext == "png" || ext == "jpg" || ext == "jpeg" || ext == "gif" ) {
+				#if js
+				var url = ide.getUnCachedUrl(path);
 				var dims = imageDims.get(url);
 				var dimsText = dims != null ? dims.width+"x"+dims.height : "";
 				var onload = dims != null ? "" : 'onload="hide.comp.cdb.Cell.onImageLoad(this, \'$url\');"';
@@ -461,6 +466,7 @@ class Cell {
 						<div class="previewContent"><div class="label">$dimsText</div>$img</div>
 					</span>';
 				}
+				#end
 			}
 			return html(innerHtml + ' <input type="submit" value="open" onclick="hide.Ide.inst.openFile(\'$path\')"/>');
 		case TTilePos:
@@ -479,11 +485,13 @@ class Cell {
 		}
 	}
 
+	#if js
 	static function onImageLoad(img : js.html.ImageElement, url) {
 		var dims = {width : img.width, height : img.height};
 		imageDims.set(url, dims);
 		new Element(img).parent().find(".label").text(dims.width+'x'+dims.height);
 	}
+	#end
 
 	static var KWDS = ["for","if","var","this","while","else","do","break","continue","switch","function","return","new","throw","try","catch","case","default"];
 	static var KWD_REG = new EReg([for( k in KWDS ) "(\\b"+k+"\\b)"].join("|"),"g");
@@ -561,6 +569,7 @@ class Cell {
 		var max = width > height ? width : height;
 		var zoom = max <= 32 ? 2 : 64 / max;
 		var inl = isInline ? 'display:inline-block;' : '';
+		#if js
 		var url = ide.getUnCachedUrl(path);
 
 		var px = Std.int(v.size*v.x*zoom);
@@ -577,8 +586,12 @@ class Cell {
 		queueTileLoading();
 		watchFile(path);
 		return {str: html, containsHtml: true};
+		#else
+		return {str : "", containsHtml : false};
+		#end
 	}
 
+	#if !hl
 	static var isTileLoadingQueued = false;
 	static function queueTileLoading() {
 		if (!isTileLoadingQueued) {
@@ -631,6 +644,7 @@ class Cell {
 			elt.parentElement.append(img);
 		}
 	}
+	#end
 
 	public function isTextInput() {
 		return switch( column.type ) {
@@ -709,16 +723,17 @@ class Cell {
 			var i = new Element("<div contenteditable='true' tabindex='1' class='custom-text-edit'>");
 			// replace all spaces with unbreakable spaces (I wanna die)
 			str = spacesToNBSP(str);
-			i[0].innerText = str;
-			var textHeight = i[0].offsetHeight;
+			i.get(0).innerText = str;
+			var textHeight = i.get(0).offsetHeight;
 			var longText = textHeight > 25 || str.indexOf("\n") >= 0;
 
-			elementHtml.appendChild(i[0]);
+			elementHtml.appendChild(i.get(0));
+			#if js
 			i.keypress(function(e) {
 				e.stopPropagation();
 			});
 
-			i[0].addEventListener("paste", function(e) {
+			i.get(0).addEventListener("paste", function(e) {
 				e.preventDefault();
 
 				var event : Dynamic = e;
@@ -726,9 +741,9 @@ class Cell {
 					event = e.originalEvent;
 				}
 				var text = event.clipboardData.getData('text/plain');
-
 				js.Browser.document.execCommand("insertText", false, text);
 			});
+			#end
 			i.dblclick(function(e) e.stopPropagation());
 
 			i.val(str);
@@ -737,7 +752,7 @@ class Cell {
 				this.closeEdit();
 			}
 			i.keydown(function(e) {
-				var t : js.html.HtmlElement = cast e.target;
+				var t : Element.HTMLElement = cast e.target;
 				var textHeight = t.offsetHeight;
 				var longText = textHeight > 25 || t.innerText.indexOf("\n") >= 0;
 				switch( e.keyCode ) {
@@ -763,7 +778,7 @@ class Cell {
 				e.stopPropagation();
 			});
 			i.keyup(function(e) try {
-				var t : js.html.HtmlElement = cast e.target;
+				var t : Element.HTMLElement = cast e.target;
 				var v = editor.base.parseValue(column.type, t.innerText);
 
 				if (column.type == TId && !isUniqueID((v:String), true)) {
@@ -783,11 +798,13 @@ class Cell {
 
 			// Select whole content of contenteditable div
 			{
-				var range =  js.Browser.document.createRange();
-				range.selectNodeContents(i[0]);
+				var range = #if hl ide.createElement("range") #else js.Browser.document.createRange() #end;
+				range.selectNodeContents(i.get(0));
+				#if js
 				var sel = js.Browser.window.getSelection();
 				sel.removeAllRanges();
 				sel.addRange(range);
+				#end
 			}
 
 
@@ -802,7 +819,7 @@ class Cell {
 			if( sdat == null ) return;
 			elementHtml.innerHTML = null;
 			elementHtml.classList.add("edit");
-
+			#if js
 			if (!useSelect2) {
 				var isLocal = sdat.idCol.scope != null;
 				var elts: Array<hide.comp.Dropdown.Choice>;
@@ -916,10 +933,11 @@ class Cell {
 				});
 				s.on("select2:close", function(_) closeEdit());
 			}
+			#end
 		case TEnum(values):
 			elementHtml.innerHTML = null;
 			elementHtml.classList.add("edit");
-
+			#if js
 			if (!useSelect2) {
 				var elts : Array<hide.comp.Dropdown.Choice> = [for( i in 0...values.length ){
 					id : "" + i,
@@ -991,6 +1009,7 @@ class Cell {
 				});
 				s.on("select2:close", function(_) closeEdit());
 			}
+			#end
 		case TColor:
 			var elem = new Element(elementHtml);
 			var preview = elem.find(".color");
@@ -998,6 +1017,7 @@ class Cell {
 				elem.html('<div class="color" style="background-color:#${StringTools.hex(0xFFFFFF,6)}"></div>');
 				preview = elem.find(".color");
 			}
+			#if js
 			var cb = new ColorPicker(false, elem, preview);
 			cb.value = currentValue;
 			cb.onChange = function(drag) {
@@ -1008,6 +1028,7 @@ class Cell {
 				cb.remove();
 				closeEdit();
 			};
+			#end
 		case TFile:
 			ide.chooseFile(["*"], function(file) {
 				setValue(file);
@@ -1040,8 +1061,8 @@ class Cell {
 			}
 			elementHtml.innerHTML = null;
 			var modal = new Element("<div>").addClass("hide-modal");
-			elementHtml.appendChild(modal[0]);
-			elementHtml.appendChild(div[0]);
+			elementHtml.appendChild(modal.get(0));
+			elementHtml.appendChild(div.get(0));
 			modal.click(function(e) {
 				setValue(val);
 				closeEdit();
@@ -1122,6 +1143,7 @@ class Cell {
 				return;
 			}
 
+			#if js
 			var ts = new hide.comp.TileSelector(file,dims,modal.content);
 			ts.allowRectSelect = true;
 			ts.allowSizeSelect = true;
@@ -1138,6 +1160,7 @@ class Cell {
 				refresh();
 				focus();
 			};
+			#end
 		case TLayer(_), TTileLayer:
 			// no edit
 		case TImage:
@@ -1146,6 +1169,7 @@ class Cell {
 	}
 
 	public function open( ?immediate : Bool ) {
+		#if js
 		if( column.type == TString && column.kind == Script ) {
 
 			// prevent opening the script if we are undo/redo-ing as this
@@ -1155,15 +1179,16 @@ class Cell {
 			var str = value == null ? "" : editor.base.valToString(column.type, value);
 			table.toggleList(this, immediate, function() return new ScriptTable(editor, this));
 		} else
+		#end
 			table.toggleList(this, immediate);
 	}
 
 	public function setErrorMessage( msg : String ) {
-		var prevError = elementHtml.querySelector("div.error");
+		var prevError = new Element(elementHtml).find("div.error");
 		if (prevError != null)
 			prevError.remove();
 		if( msg == null ) return;
-		var div = js.Browser.document.createDivElement();
+		var div = #if hl ide.createElement("div") #else js.Browser.document.createDivElement() #end;
 		div.classList.add("error");
 		div.innerText = msg;
 		elementHtml.appendChild(div);
@@ -1253,7 +1278,7 @@ class Cell {
 
 	public function closeEdit() {
 		inEdit = false;
-		var input = elementHtml.querySelector("div[contenteditable]");
+		var input = new Element(elementHtml).find("div[contenteditable]").get(0);
 		var text : String = input?.innerText;
 		if (text != null) {
 			text = nBSPtoSpaces(text);

+ 12 - 3
hide/comp/cdb/Editor.hx

@@ -171,7 +171,7 @@ class Editor extends Component {
 		refresh();
 	}
 
-	function onMouseDown( e : js.jquery.Event ) {
+	function onMouseDown( e : hide.Element.Event ) {
 		switch ( e.which ) {
 		case 4:
 			cursorJump(true);
@@ -183,7 +183,7 @@ class Editor extends Component {
 		return true;
 	}
 
-	function onKey( e : js.jquery.Event ) {
+	function onKey( e : hide.Element.Event ) {
 		if( e.altKey )
 			return false;
 		var isRepeat: Bool = untyped e.originalEvent.repeat;
@@ -327,7 +327,7 @@ class Editor extends Component {
 					}
 
 					if (filtered)
-						lines[idx].classList.add("filtered");
+						lines.get(idx).classList.add("filtered");
 				}
 			}
 			else {
@@ -1060,7 +1060,11 @@ class Editor extends Component {
 		}
 		return id;
 	}
+
 	public function getReferences(id: String, withCodePaths = true, returnAtFirstRef = false, sheet: cdb.Sheet, ?codeFileCache: Array<{path: String, data:String}>, ?prefabFileCache: Array<{path: String, data:String}>) : Array<{str:String, ?goto:Void->Void}> {
+		#if hl
+		return [];
+		#else
 		if( id == null )
 			return [];
 
@@ -1312,6 +1316,7 @@ class Editor extends Component {
 			}
 		}
 		return message;
+		#end
 	}
 
 	public function findUnreferenced(col: cdb.Data.Column, table: Table) {
@@ -1574,10 +1579,12 @@ class Editor extends Component {
 				addSearchInput();
 			if( filters.length <= currentFilters.length ) {
 				var inputs = inputCont.find("input");
+				#if js
 				for( i in 0...inputs.length ) {
 					var input: js.html.InputElement = cast inputs[i];
 					input.value = currentFilters[i].text;
 				}
+				#end
 			}
 		}
 	}
@@ -2268,8 +2275,10 @@ class Editor extends Component {
 	}
 
 	public function focus() {
+		#if js
 		if( element.is(":focus") ) return;
 		(element[0] : Dynamic).focus({ preventScroll : true });
+		#end
 	}
 
 	static public function getSheetProps( s : cdb.Sheet ) {

+ 4 - 0
hide/comp/cdb/Formulas.hx

@@ -280,6 +280,7 @@ class Formulas {
 		return t;
 	}
 
+	#if !hl
 	public function createNew( c : Cell, ?onCreated : Formula -> Void ) {
 		var name = ide.ask("Formula name");
 		if( name == null ) return;
@@ -302,9 +303,11 @@ class Formulas {
 			}
 		});
 	}
+	#end
 
 }
 
+#if !hl
 class FormulasView extends hide.view.Script {
 
 	override function getScriptChecker() {
@@ -411,3 +414,4 @@ class FormulasView extends hide.view.Script {
 
 	static var _ = hide.ui.View.register(FormulasView);
 }
+#end

+ 8 - 8
hide/comp/cdb/Line.hx

@@ -30,17 +30,17 @@ class Line extends Component {
 
 	public function create() {
 		var view = table.view;
-		element[0].classList.remove("hidden");
+		element.get(0).classList.remove("hidden");
 		var id: String = null;
 		for( c in columns ) {
-			var e = js.Browser.document.createTableCellElement();
+			var e = #if hl { throw "TODO"; (null:Element.HTMLElement); } #else js.Browser.document.createTableCellElement() #end;
 			e.classList.add("c");
-			this.element[0].appendChild(e);
+			this.element.get(0).appendChild(e);
 			var cell = new Cell(e, this, c);
 			if( c.type == TId ) {
 				id = cell.value;
 				if( view != null && view.forbid != null && view.forbid.indexOf(cell.value) >= 0 )
-					element[0].classList.add("hidden");
+					element.get(0).classList.add("hidden");
 			}
 		}
 
@@ -48,16 +48,16 @@ class Line extends Component {
 		var countRefs = sheetsToCount.contains(table.sheet.name);
 		if( countRefs && id != null ) {
 			var refCount = table.editor.getReferences(id, false, table.sheet).length;
-			element[0].classList.toggle("has-ref", refCount > 0);
-			element[0].classList.toggle("no-ref", refCount == 0);
-			element[0].classList.add("ref-count-" + refCount);
+			element.get(0).classList.toggle("has-ref", refCount > 0);
+			element.get(0).classList.toggle("no-ref", refCount == 0);
+			element.get(0).classList.add("ref-count-" + refCount);
 		}
 		syncClasses();
 	}
 
 	public function syncClasses() {
 		var obj = obj;
-		element[0].classList.toggle("locIgnored", Reflect.hasField(obj,cdb.Lang.IGNORE_EXPORT_FIELD));
+		element.get(0).classList.toggle("locIgnored", Reflect.hasField(obj,cdb.Lang.IGNORE_EXPORT_FIELD));
 	}
 
 	public function getGroupID() {

+ 21 - 11
hide/comp/cdb/Table.hx

@@ -1,5 +1,5 @@
 package hide.comp.cdb;
-import js.jquery.Helper.*;
+import hide.ui.QueryHelper.*;
 
 enum DisplayMode {
 	Table;
@@ -93,14 +93,17 @@ class Table extends Component {
 
 	function setupTableElement() {
 		cloneTableHead();
+		#if js
 		@:privateAccess {
 			var elt = editor.element.parent();
 			var scrollbarWidth = elt.parent().width() - elt.width();
 			element.width(@:privateAccess editor.cdbTable.contentWidth - scrollbarWidth); // prevent to reflow all cdb-view
 		}
+		#end
 	}
 
 	function cloneTableHead() {
+		#if js
 		var target = element.find('thead').first().find('.head');
 		if (target.length == 0)
 			return;
@@ -116,7 +119,7 @@ class Table extends Component {
 			elt.width(targetElt.width());
 			elt.css("max-width", targetElt.width());
 
-			var txt = elt[0].innerHTML;
+			var txt = elt.get(0).innerHTML;
 			elt.empty();
 			J("<span>" + txt + "</span>").appendTo(elt);
 
@@ -124,9 +127,11 @@ class Table extends Component {
 		}
 
 		J('.cdb').prepend(clone);
+		#end
 	}
 
 	function updateDrag() {
+		#if js
 		var scrollHeight = js.Browser.document.body.scrollHeight;
 		if (ide.mouseY > scrollHeight*0.8) {
 			var scroll = element.get()[0].parentElement.parentElement;
@@ -136,6 +141,7 @@ class Table extends Component {
 			var scroll = element.get()[0].parentElement.parentElement;
 			scroll.scrollTop -= 15 + Std.int((scrollHeight*0.2 - ide.mouseY)/(scrollHeight*0.2)*30);
 		}
+		#end
 	}
 
 	function refreshTable() {
@@ -169,7 +175,8 @@ class Table extends Component {
 				}
 				editor.cursor.clickLine(line, e.shiftKey);
 			});
-			var headEl = head.get()[0];
+			#if js
+			var headEl = head.get(0);
 			headEl.draggable = true;
 			headEl.ondragstart = function(e:js.html.DragEvent) {
 				if (editor.cursor.getCell() != null && editor.cursor.getCell().inEdit) {
@@ -205,6 +212,7 @@ class Table extends Component {
 
 				return false;
 			}
+			#end
 			line;
 		}];
 
@@ -296,10 +304,12 @@ class Table extends Component {
 			element.append(l);
 		}
 
+		#if js
 		if( sheet.parent == null ) {
 			cols.ready(setupTableElement);
 			cols.on("resize", setupTableElement);
 		}
+		#end
 	}
 
 	function makeSeparatorTree( ?root ) {
@@ -343,13 +353,13 @@ class Table extends Component {
 		var t = makeSeparatorTree(sheet.separators[sepIndex]);
 		while( t.parent != null ) {
 			if( isSepHidden(t.index) )
-				new Element(subs[t.index]).find("a.toggle").click();
+				new Element(subs.get(t.index)).find("a.toggle").click();
 			t = t.parent;
 		}
 	}
 
 	function makeSeparator( sindex : Int, colCount : Int ) : Separator {
-		var sep = J("<tr>").addClass("separator").attr("sindex", sindex).append('<td colspan="${colCount+1}"><a href="#" class="toggle"></a><span></span></td>');
+		var sep = J("<tr>").addClass("separator").attr("sindex", sindex).append(J('<td colspan="${colCount+1}"><a href="#" class="toggle"></a><span></span></td>'));
 		var content = sep.find("span");
 		var toggle = sep.find("a");
 		var sepInfo = sheet.separators[sindex];
@@ -421,7 +431,7 @@ class Table extends Component {
 							showRec(s);
 					}
 					if( isSepHidden(t.index) == show )
-						new Element(subs[t.index]).find("a.toggle").click();
+						new Element(subs.get(t.index)).find("a.toggle").click();
 					if( show ) {
 						for( s in t.subs )
 							showRec(s);
@@ -494,9 +504,9 @@ class Table extends Component {
 		sep.dblclick(function(e) {
 			if( !canInsert() ) return;
 			content.empty();
-			J("<input>").appendTo(content).focus().val(title == null ? "" : title).blur(function(_) {
-				title = JTHIS.val();
-				JTHIS.remove();
+			J("<input>").appendTo(content).focus().val(title == null ? "" : title).blur(function(e) {
+				title = e.getThis().val();
+				e.getThis().remove();
 				if( title == "" ) title = null;
 				editor.beginChanges();
 				var sep = sheet.separators[sindex];
@@ -558,7 +568,7 @@ class Table extends Component {
 			var subs = element.find("tr.separator");
 			function toggleRec( t : SepTree ) {
 				var sid = sheet.separators.indexOf(t.sep);
-				subs[sid].style.display = hidden ? "none" : "";
+				subs.get(sid).style.display = hidden ? "none" : "";
 				if( !hidden ) {
 					if( isSepHidden(sid) ) return;
 					for( l in getLines(sid) )
@@ -668,7 +678,7 @@ class Table extends Component {
 			}
 
 			var line = new Line(this, [c], lines.length, l);
-			var cell = new Cell(td[0], line, c);
+			var cell = new Cell(td.get(0), line, c);
 			lines.push(line);
 
 			th.mousedown(function(e) {

+ 16 - 4
hide/tools/FileWatcher.hx

@@ -1,11 +1,15 @@
 package hide.tools;
 
-typedef FileWatchEvent = {path:String,fun:Void->Void,checkDel:Bool,element:js.html.Element,?ignoreCheck:String};
+typedef FileWatchEvent = {path:String,fun:Void->Void,checkDel:Bool,element:Element.HTMLElement,?ignoreCheck:String};
 
 private typedef Watch = {
 	path : String,
 	events : Array<FileWatchEvent>,
+	#if js
 	w : js.node.fs.FSWatcher,
+	#else
+	w : Dynamic,
+	#end
 	wasChanged : Bool,
 	changed : Bool,
 	isDir : Bool,
@@ -57,6 +61,7 @@ class FileWatcher {
 	}
 
 	function getSignature( path : String ) : String {
+		#if js
 		var sign = js.node.Crypto.createHash(js.node.Crypto.CryptoAlgorithm.MD5);
 		try {
 			sign.update(js.node.Fs.readFileSync(ide.getPath(path)));
@@ -64,6 +69,9 @@ class FileWatcher {
 		} catch( e : Dynamic ) {
 			return null;
 		}
+		#else
+		return "";
+		#end
 	}
 
 	public function dispose() {
@@ -80,7 +88,7 @@ class FileWatcher {
 	public function register( path : String, updateFun, ?checkDelete : Bool, ?element : Element ) : FileWatchEvent {
 		path = ide.getPath(path);
 		var w = getWatches(path);
-		var f : FileWatchEvent = { path : path, fun : updateFun, checkDel : checkDelete, element : element == null ? null : element[0] };
+		var f : FileWatchEvent = { path : path, fun : updateFun, checkDel : checkDelete, element : element == null ? null : element.get(0) };
 		w.events.push(f);
 		if( element != null && timer == null ) {
 			timer = new haxe.Timer(1000);
@@ -89,7 +97,7 @@ class FileWatcher {
 		return f;
 	}
 
-	public function registerRaw( path : String, updateFun, ?checkDelete : Bool, ?element : js.html.Element) : FileWatchEvent {
+	public function registerRaw( path : String, updateFun, ?checkDelete : Bool, ?element : Element.HTMLElement) : FileWatchEvent {
 		path = ide.getPath(path);
 		var w = getWatches(path);
 		var f : FileWatchEvent = { path : path, fun : updateFun, checkDel : checkDelete, element: element};
@@ -118,7 +126,7 @@ class FileWatcher {
 	public function unregisterElement( element : Element ) {
 		for( path => w in watches ) {
 			for( e in w.events.copy() )
-				if( e.element == element[0] )
+				if( e.element == element.get(0) )
 					w.events.remove(e);
 			if( w.events.length == 0 ) {
 				watches.remove(path);
@@ -142,11 +150,13 @@ class FileWatcher {
 
 	function isLive( events : Array<FileWatchEvent>, e : FileWatchEvent ) {
 		if( e.element == null ) return true;
+		#if js
 		var elt = e.element;
 		while( elt != null ) {
 			if( elt.nodeName == "BODY" ) return true;
 			elt = elt.parentElement;
 		}
+		#end
 		events.remove(e);
 		return false;
 	}
@@ -168,6 +178,7 @@ class FileWatcher {
 	}
 
 	function initWatch( w : Watch ) {
+		#if js
 		w.w = js.node.Fs.watch(w.path, function(k:String, file:String) {
 			if( w.isDir && k == "change" ) return;
 			if( k == "change" ) w.wasChanged = true;
@@ -176,6 +187,7 @@ class FileWatcher {
 			w.version++;
 			haxe.Timer.delay(onEventChanged.bind(w),100);
 		});
+		#end
 	}
 
 	function getWatches( path : String ) {

+ 6 - 6
hide/ui/Keys.hx

@@ -7,8 +7,8 @@ typedef Entry = {doc: EntryDoc, cb: Void->Void};
 class Keys {
 
 	var keys = new Map<String,Entry>();
-	var parent : js.html.Element;
-	var listeners = new Array<js.jquery.Event -> Bool>();
+	var parent : Element.HTMLElement;
+	var listeners = new Array<Element.Event -> Bool>();
 	var disabledStack : Int = 0;
 
 	public function pushDisable() {
@@ -25,7 +25,7 @@ class Keys {
 
 	public function new( parent : Element ) {
 		if( parent != null ) {
-			this.parent = parent[0];
+			this.parent = parent.get(0);
 			parent.attr("haskeys","true");
 			if( this.parent != null ) Reflect.setField(this.parent,"__keys",this);
 		}
@@ -47,7 +47,7 @@ class Keys {
 		listeners.push(l);
 	}
 
-	public function processEvent( e : js.jquery.Event, config : Config ) {
+	public function processEvent( e : Element.Event, config : Config ) {
 		if (disabledStack > 0)
 			return false;
 		var parts = [];
@@ -79,7 +79,7 @@ class Keys {
 		return false;
 	}
 
-	public function triggerKey( e : js.jquery.Event, key : String, config : Config ) {
+	public function triggerKey( e : Element.Event, key : String, config : Config ) {
 		for( l in listeners )
 			if( l(e) )
 				return true;
@@ -102,7 +102,7 @@ class Keys {
 	}
 
 	public static function get( e : Element ) : Keys {
-		return Reflect.field(e[0], "__keys");
+		return Reflect.field(e.get(0), "__keys");
 	}
 
 	public function sortDocCategories(config: Config) : Map<String, Array<{name: String, shortcut: String}>> {

+ 26 - 9
hide/ui/View.hx

@@ -12,10 +12,12 @@ typedef ViewOptions = { ?position : DisplayPosition, ?width : Int }
 @:keepSub @:allow(hide.Ide)
 class View<T> extends hide.comp.Component {
 
+	#if !hl
 	var container : golden.Container;
 	var containerView : golden.ContentItem;
-	var watches : Array<{ keep : Bool, path : String, callb : Void -> Void }> = [];
 	public var fullScreen(get,set) : Bool;
+	#end
+	var watches : Array<{ keep : Bool, path : String, callb : Void -> Void }> = [];
 	public var keys(get,null) : Keys;
 	public var state(default, null) : T;
 	public var undo(default, null) = new hide.ui.UndoHistory();
@@ -32,7 +34,9 @@ class View<T> extends hide.comp.Component {
 		element = null;
 		this.state = state;
 		ide = Ide.inst;
+		#if !hl
 		@:privateAccess ide.currentFullScreen = null;
+		#end
 	}
 
 	public function watch( filePath : String, onChange : Void -> Void, ?opts : { ?checkDelete : Bool, ?keepOnRebuild : Bool } ) {
@@ -57,7 +61,9 @@ class View<T> extends hide.comp.Component {
 	function get_keys() {
 		if( keys == null ) {
 			keys = new Keys(null);
+			#if js
 			keys.register("view.fullScreen", function() fullScreen = !fullScreen);
+			#end
 		}
 		return keys;
 	}
@@ -91,6 +97,7 @@ class View<T> extends hide.comp.Component {
 		return v == null || v.type != type ? null : v.value;
 	}
 
+	#if !hl
 	function syncTitle() {
 		container.setTitle(getTitle());
 	}
@@ -193,6 +200,13 @@ class View<T> extends hide.comp.Component {
 		element.off();
 		onDisplay();
 	}
+	#end
+
+	#if hl
+	public final function rebuild() {
+		onDisplay();
+	}
+	#end
 
 	function onDisplay() {
 		element.text(viewClass+(state == null ? "" : " "+state));
@@ -201,13 +215,6 @@ class View<T> extends hide.comp.Component {
 	public function onResize() {
 	}
 
-	public function onActivate() {
-	}
-
-	public function isActive() {
-		return container != null && !container.isHidden;
-	}
-
 	public function onDragDrop(items : Array<String>, isDrop : Bool) {
 		return false;
 	}
@@ -216,6 +223,15 @@ class View<T> extends hide.comp.Component {
 		return Type.getClassName(Type.getClass(this)) + (this.state == null ? "" : "("+haxe.Json.stringify(this.state)+")");
 	}
 
+	#if !hl
+
+	public function isActive() {
+		return container != null && !container.isHidden;
+	}
+
+	public function onActivate() {
+	}
+
 	/**
 		Gives focus if part of a tab group
 	**/
@@ -277,6 +293,7 @@ class View<T> extends hide.comp.Component {
 		if( !ide.isCDB ) ide.setFullscreen(v);
 		return v;
 	}
+	#end
 
 	public static var viewClasses = new Map<String,{ name : String, cl : Class<View<Dynamic>>, options : ViewOptions }>();
 	public static function register<T>( cl : Class<View<T>>, ?options : ViewOptions ) {
@@ -291,4 +308,4 @@ class View<T> extends hide.comp.Component {
 		return null;
 	}
 
-}
+}

+ 9 - 1
hide/view/CdbTable.hx

@@ -82,6 +82,7 @@ class CdbTable extends hide.ui.View<{}> {
 				case Script(line):
 					var cell = lastCell;
 					if (cell != null) {
+						#if js
 						//cell.open(false);
 						var scr = Std.downcast(cell.line.subTable, hide.comp.cdb.ScriptTable);
 						if (scr != null) {
@@ -90,6 +91,7 @@ class CdbTable extends hide.ui.View<{}> {
 								haxe.Timer.delay(() ->@:privateAccess scr.script.editor.revealLineInCenter(line+1), 1);
 							}, 1);
 						}
+						#end
 					}
 					colNo = -1;
 					lineNo = -1;
@@ -159,10 +161,12 @@ class CdbTable extends hide.ui.View<{}> {
 				var cell = editor.cursor.getCell();
 				if (cell != null) {
 					cell.open(false);
+					#if js
 					var scr = Std.downcast(cell.line.subTable, hide.comp.cdb.ScriptTable);
 					if (scr != null) {
 						@:privateAccess scr.script.editor.setPosition({column:0, lineNumber: scriptLine});
 					}
+					#end
 				}
 			}
 		}
@@ -202,11 +206,13 @@ class CdbTable extends hide.ui.View<{}> {
 		var sheets = getSheets();
 		if( sheets.length == 0 ) {
 			element.html("No CDB sheet created, <a href='#'>create one</a>");
+			#if js
 			element.find("a").click(function(_) {
 				var sheet = ide.createDBSheet();
 				if( sheet == null ) return;
 				rebuild();
 			});
+			#end
 			return;
 		}
 		element.addClass("cdb-view");
@@ -290,7 +296,7 @@ class CdbTable extends hide.ui.View<{}> {
 			var tab = header.find('[index=$i]');
 			tab.toggleClass("hidden", !show);
 			tab.toggleClass("cat", props.categories != null);
-			tab[0].className = ~/(cat-[^\s]+)/g.replace(tab[0].className, "");
+			tab.get(0).className = ~/(cat-[^\s]+)/g.replace(tab.get(0).className, "");
 			if(props.categories != null)
 				for(c in props.categories)
 					tab.addClass("cat-" + c);
@@ -298,6 +304,7 @@ class CdbTable extends hide.ui.View<{}> {
 		if( doRefresh ) editor.refresh();
 	}
 
+	#if js
 	override public function onDragDrop( items : Array<String>, isDrop : Bool ) {
 		if( items.length == 0 )
 			return false;
@@ -319,6 +326,7 @@ class CdbTable extends hide.ui.View<{}> {
 		}
 		return null;
 	}
+	#end
 
 	override function getTitle() {
 		return "CDB"+ @:privateAccess (ide.databaseDiff != null ? " - "+ide.databaseDiff : "");

+ 1 - 0
hrt/prefab/fx/FX.hx

@@ -4,6 +4,7 @@ import hrt.prefab.Curve;
 import hrt.prefab.Prefab as PrefabElement;
 import hrt.prefab.fx.BaseFX.ObjectAnimation;
 import hrt.prefab.fx.BaseFX.ShaderAnimation;
+import hrt.prefab.fx.Event;
 
 
 @:allow(hrt.prefab.fx.FX)

+ 1 - 0
hrt/prefab/fx/FX2D.hx

@@ -3,6 +3,7 @@ import hrt.prefab.Curve;
 import hrt.prefab.Prefab as PrefabElement;
 import hrt.prefab.fx.BaseFX.ObjectAnimation;
 import hrt.prefab.fx.BaseFX.ShaderAnimation;
+import hrt.prefab.fx.Event;
 
 @:allow(hrt.prefab.fx.FX2D)
 class FX2DAnimation extends h2d.Object {