diff --git a/dist/utils.js b/dist/utils.js
index 326fc74..01b3cec 100644
--- a/dist/utils.js
+++ b/dist/utils.js
@@ -267,7 +267,7 @@ function notify(scope){
if( str.match(/error/g) ) opts.status = "danger"
if( str.match(/warning/g) ) opts.status = "warning"
}
- opts = Object.assign({ message: str , status, timeout:2000 },opts)
+ opts = Object.assign({ message: str , status, timeout:4000 },opts)
SnackBar( opts )
}
}
diff --git a/dist/xrfragment.aframe.js b/dist/xrfragment.aframe.js
index 97fbef3..e0e18ba 100644
--- a/dist/xrfragment.aframe.js
+++ b/dist/xrfragment.aframe.js
@@ -1,3 +1,8 @@
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
(function ($global) { "use strict";
$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
@@ -72,6 +77,20 @@ Reflect.deleteField = function(o,field) {
delete(o[field]);
return true;
};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
@@ -209,83 +228,22 @@ js_Boot.__string_rec = function(o,s) {
return String(o);
}
};
-var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
-xrfragment_Parser.__name__ = true;
-xrfragment_Parser.parse = function(key,value,store) {
- var Frag_h = Object.create(null);
- Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
- Frag_h["prio"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_INT;
- Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
- Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
- Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["q"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["scale"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["mov"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["show"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.METADATA;
- Frag_h["env"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["gravity"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["physics"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["fov"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["clip"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["fog"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["bg"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
- var isPVDynamic = value.length == 0 && key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
- var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
- if(isPVDynamic) {
- var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR);
- v.validate(key);
- store[key] = v;
- return true;
- }
- var v = new xrfragment_XRF(key,Frag_h[key]);
- if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
- if(!v.validate(value)) {
- console.log("src/xrfragment/Parser.hx:80:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
- return false;
- }
- store[key] = v;
- if(xrfragment_Parser.debug) {
- console.log("src/xrfragment/Parser.hx:84:","✔ " + key + ": " + v.string);
- }
- } else {
- if(typeof(value) == "string") {
- v.guessType(v,value);
- }
- v.noXRF = true;
- store[key] = v;
- }
- return true;
-};
-var xrfragment_Query = $hx_exports["xrfragment"]["Query"] = function(str) {
- this.isNumber = new EReg("^[0-9\\.]+$","");
- this.isRoot = new EReg("^[-]?/","");
- this.isExclude = new EReg("^-","");
- this.isProp = new EReg("^.*:[><=!]?","");
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
this.q = { };
this.str = "";
if(str != null) {
this.parse(str);
}
};
-xrfragment_Query.__name__ = true;
-xrfragment_Query.prototype = {
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
toObject: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,get: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,parse: function(str) {
- var _gthis = this;
var token = str.split(" ");
var q = { };
var process = function(str,prefix) {
@@ -293,59 +251,42 @@ xrfragment_Query.prototype = {
prefix = "";
}
str = StringTools.trim(str);
- var k = str.split(":")[0];
- var v = str.split(":")[1];
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
var filter = { };
if(q[prefix + k]) {
filter = q[prefix + k];
}
- filter["rules"] = filter["rules"] != null ? filter["rules"] : [];
- if(_gthis.isProp.match(str)) {
+ if(xrfragment_XRF.isProp.match(str)) {
var oper = "";
- if(str.indexOf("*") != -1) {
- oper = "*";
- }
if(str.indexOf(">") != -1) {
oper = ">";
}
if(str.indexOf("<") != -1) {
oper = "<";
}
- if(str.indexOf(">=") != -1) {
- oper = ">=";
- }
- if(str.indexOf("<=") != -1) {
- oper = "<=";
- }
- if(_gthis.isExclude.match(k)) {
- oper = "!=";
+ if(xrfragment_XRF.isExclude.match(k)) {
k = HxOverrides.substr(k,1,null);
- } else {
- v = HxOverrides.substr(v,oper.length,null);
}
+ v = HxOverrides.substr(v,oper.length,null);
if(oper.length == 0) {
oper = "=";
}
var rule = { };
- if(_gthis.isNumber.match(v)) {
+ if(xrfragment_XRF.isNumber.match(v)) {
rule[oper] = parseFloat(v);
} else {
rule[oper] = v;
}
- filter["rules"].push(rule);
- q[k] = filter;
- return;
- } else {
- filter["id"] = _gthis.isExclude.match(str) ? false : true;
- filter["root"] = _gthis.isRoot.match(str);
- if(_gthis.isExclude.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- if(_gthis.isRoot.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- q[str] = filter;
+ q["expr"] = rule;
}
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
};
var _g = 0;
var _g1 = token.length;
@@ -394,49 +335,75 @@ xrfragment_Query.prototype = {
return v[property];
}
}
- var _g = 0;
- var _g1 = Reflect.fields(this.q);
- while(_g < _g1.length) {
- var k = _g1[_g];
- ++_g;
- var filter = Reflect.field(this.q,k);
- if(filter.rules == null) {
- continue;
- }
- var rules = filter.rules;
- var _g2 = 0;
- while(_g2 < rules.length) {
- var rule = rules[_g2];
- ++_g2;
- if(exclude) {
- if(Reflect.field(rule,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(rule,"!="))) && exclude) {
- ++qualify;
- }
- } else {
- if(Reflect.field(rule,"*") != null && testprop(parseFloat(value) != null)) {
- ++qualify;
- }
- if(Reflect.field(rule,">") != null && testprop(parseFloat(value) > parseFloat(Reflect.field(rule,">")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<") != null && testprop(parseFloat(value) < parseFloat(Reflect.field(rule,"<")))) {
- ++qualify;
- }
- if(Reflect.field(rule,">=") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(rule,">=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<=") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(rule,"<=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"=") != null && (testprop(value == Reflect.field(rule,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(rule,"="))))) {
- ++qualify;
- }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
}
}
}
return qualify > 0;
}
};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
@@ -458,7 +425,7 @@ xrfragment_URI.parse = function(url,filter) {
var s = regexPlus.split(splitByEqual[1]).join(" ");
value = decodeURIComponent(s.split("+").join(" "));
}
- var ok = xrfragment_Parser.parse(key,value,store);
+ var ok = xrfragment_Parser.parse(key,value,store,i);
}
if(filter != null && filter != 0) {
var _g = 0;
@@ -474,9 +441,10 @@ xrfragment_URI.parse = function(url,filter) {
}
return store;
};
-var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) {
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
this.fragment = _fragment;
this.flags = _flags;
+ this.index = _index;
};
xrfragment_XRF.__name__ = true;
xrfragment_XRF.set = function(flag,flags) {
@@ -495,45 +463,50 @@ xrfragment_XRF.prototype = {
}
,validate: function(value) {
this.guessType(this,value);
- if(this.fragment == "q") {
- this.query = new xrfragment_Query(value).get();
- }
var ok = true;
if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
ok = false;
}
- if(!this.is(xrfragment_XRF.T_VECTOR2) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
ok = false;
}
return ok;
}
,guessType: function(v,str) {
v.string = str;
- if(str.split(",").length > 1) {
- var xyzw = str.split(",");
- if(xyzw.length > 0) {
- v.x = parseFloat(xyzw[0]);
- }
- if(xyzw.length > 1) {
- v.y = parseFloat(xyzw[1]);
- }
- if(xyzw.length > 2) {
- v.z = parseFloat(xyzw[2]);
- }
- if(xyzw.length > 3) {
- v.w = parseFloat(xyzw[3]);
- }
+ if(typeof(str) != "string") {
+ return;
}
- if(xrfragment_XRF.isColor.match(str)) {
- v.color = str;
- }
- if(xrfragment_XRF.isFloat.match(str)) {
- v.x = parseFloat(str);
- v.float = v.x;
- }
- if(xrfragment_XRF.isInt.match(str)) {
- v.int = Std.parseInt(str);
- v.x = v.int;
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
}
}
};
@@ -571,6 +544,11 @@ xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
})({});
var xrfragment = $hx_exports["xrfragment"];
// SPDX-License-Identifier: MPL-2.0
@@ -579,7 +557,8 @@ var xrfragment = $hx_exports["xrfragment"];
var xrf = {}
xrf.init = function(opts){
- opts = opts || {}
+ opts = opts || {}
+ xrf.debug = parseInt( ( document.location.hash.match(/debug=([0-9])/) || [0,'0'] )[1] )
xrf.Parser.debug = xrf.debug
xrf.detectCameraRig(opts)
for ( let i in opts ) xrf[i] = opts[i]
@@ -624,7 +603,7 @@ xrf.hasTag = (tag,tags) => String(tags).match( new RegExp(`(^| )${tag}( |$)`,`g`
// map library functions to xrf
for ( let i in xrfragment ) xrf[i] = xrfragment[i]
/*
- * (promise-able) EVENTS
+ * (promise-able) EVENTS (optionally continue after listeners are finished using .then)
*
* example:
*
@@ -649,14 +628,23 @@ xrf.addEventListener = function(eventName, callback, scene) {
// add the callback to the listeners array for this event name
this._listeners[eventName].push(callback);
return () => {
- console.log("size = "+this._listeners[eventName].length)
this._listeners[eventName] = this._listeners[eventName].filter( (c) => c != callback )
- console.log("size = "+this._listeners[eventName].length)
}
};
xrf.emit = function(eventName, data){
if( typeof data != 'object' ) throw 'emit() requires passing objects'
+ if( xrf.debug && ( eventName != "render" || xrf.debug == eventName ) ){
+ let label = String(`xrf.emit('${eventName}')`).padEnd(35," ");
+ label += data.mesh && data.mesh.name ? '#'+data.mesh.name : ''
+ console.groupCollapsed(label)
+ console.info(data)
+ console.groupEnd(label)
+ if( xrf.debug > 1 ) debugger
+ }
+ // forward to THREEjs eventbus if any
+ if( data.scene ) data.scene.dispatchEvent( eventName, data )
+ if( data.mesh ) data.mesh.dispatchEvent( eventName, data )
return xrf.emit.promise(eventName,data)
}
@@ -671,15 +659,21 @@ xrf.emit.normal = function(eventName, data) {
};
xrf.emit.promise = function(e, opts){
- opts.XRF = xrf // always pass root XRF obj
return new Promise( (resolve, reject) => {
opts.promise = () => {
- opts.promise.halted = true
- return { resolve, reject }
+ opts.promises = opts.promises || []
+ opts.promises.push(0)
+ return {
+ resolve: ((index) => () => {
+ opts.promises[index] = 1
+ let succesful = opts.promises.reduce( (a,b) => a+b )
+ if( succesful == opts.promises.length ) resolve(opts)
+ })(opts.promises.length-1),
+ reject: console.error
+ }
}
xrf.emit.normal(e, opts)
- delete opts.XRF
- if( !opts.promise.halted ) resolve()
+ if( !opts.promises ) resolve(opts)
delete opts.promise
})
}
@@ -687,7 +681,8 @@ xrf.emit.promise = function(e, opts){
* http://www.github.com/cburgmer/rasterizeHTML.js
* Copyright (c) 2023 Christoph Burgmer; Licensed MIT */
-!function(o,i){void 0===o&&void 0!==window&&(o=window),"function"==typeof define&&define.amd?define(["url","xmlserializer","sane-domparser-error","inlineresources"],function(e,t,n,r){return o.rasterizeHTML=i(e,t,n,r)}):"object"==typeof module&&module.exports?module.exports=i(require("url"),require("xmlserializer"),require("sane-domparser-error"),require("inlineresources")):o.rasterizeHTML=i(o.url,o.xmlserializer,o.sanedomparsererror,o.inlineresources)}(this,function(e,t,n,r){var o=function(n){"use strict";var o={},t=[];o.joinUrl=function(e,t){return e?n.resolve(e,t):t},o.getConstantUniqueIdFor=function(e){return t.indexOf(e)<0&&t.push(e),t.indexOf(e)},o.clone=function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};return o.parseOptionalParameters=function(e){var t,n,r={canvas:null,options:{}};return null==e[0]||(t=e[0],"object"==typeof(n=t)&&null!==n&&Object.prototype.toString.apply(t).match(/\[object (Canvas|HTMLCanvasElement)\]/i))?(r.canvas=e[0]||null,r.options=o.clone(e[1])):r.options=o.clone(e[0]),r},o}(e),i=function(i){"use strict";function u(e,t,n){var r=e[t];return e[t]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(this,[e,r])},r}var e={};return e.baseUrlRespectingXhr=function(t,o){return function(){var e=new t;return u(e,"open",function(e,t){var n=e.shift(),r=e.shift(),r=i.joinUrl(o,r);return t.apply(this,[n,r].concat(e))}),e}},e.finishNotifyingXhr=function(t){function e(){var e=new t;return u(e,"send",function(e,t){return r+=1,t.apply(this,arguments)}),e.addEventListener("load",function(){o+=1,n()}),e}var n,r=0,o=0,i=!1,c=new Promise(function(e){n=function(){r-o<=0&&i&&e({totalCount:r})}});return e.waitForRequestsToFinish=function(){return i=!0,n(),c},e},e}(o),e=function(i){"use strict";function r(e){return Array.prototype.slice.call(e)}var e={},c={active:!0,hover:!0,focus:!1,target:!1};return e.fakeUserAction=function(e,t,n){var r=e.querySelector(t),o=":"+n,t="rasterizehtml"+n;r&&(c[n]?i.addClassNameRecursively(r,t):i.addClassName(r,t),i.rewriteCssSelectorWith(e,o,"."+t))},e.persistInputValues=function(e){function t(e){return"checkbox"===e.type||"radio"===e.type}var n=e.querySelectorAll("input"),e=e.querySelectorAll("textarea");r(n).filter(t).forEach(function(e){e.checked?e.setAttribute("checked",""):e.removeAttribute("checked")}),r(n).filter(function(e){return!t(e)}).forEach(function(e){e.setAttribute("value",e.value)}),r(e).forEach(function(e){e.textContent=e.value})},e.rewriteTagNameSelectorsToLowerCase=function(e){i.lowercaseCssTypeSelectors(e,i.findHtmlOnlyNodeNames(e))},e}(function(){"use strict";function c(e){return Array.prototype.slice.call(e)}var n={};n.addClassName=function(e,t){e.className+=" "+t},n.addClassNameRecursively=function(e,t){n.addClassName(e,t),e.parentNode!==e.ownerDocument&&n.addClassNameRecursively(e.parentNode,t)};function r(e,t,o){var i="((?:^|[^.#:\\w])|(?=\\W))("+t.join("|")+")(?=\\W|$)";c(e.querySelectorAll("style")).forEach(function(e){var t,n;void 0===e.sheet&&(t=e,n=document.implementation.createHTMLDocument(""),(r=document.createElement("style")).textContent=t.textContent,n.body.appendChild(r),t.sheet=r.sheet);var r=c(e.sheet.cssRules).filter(function(e){return e.selectorText&&new RegExp(i,"i").test(e.selectorText)});r.length&&(r.forEach(function(e){var t,n=e.selectorText.replace(new RegExp(i,"gi"),function(e,t,n){return t+o(n)});n!==e.selectorText&&(t=n,e=(n=e).cssText.replace(/^[^\{]+/,""),u(n,t+" "+e))}),e.textContent=a(e.sheet.cssRules))})}var u=function(e,t){var n=e.parentStyleSheet,e=c(n.cssRules).indexOf(e);n.insertRule(t,e+1),n.deleteRule(e)},a=function(e){return c(e).reduce(function(e,t){return e+t.cssText},"")};return n.rewriteCssSelectorWith=function(e,t,n){r(e,[t],function(){return n})},n.lowercaseCssTypeSelectors=function(e,t){r(e,t,function(e){return e.toLowerCase()})},n.findHtmlOnlyNodeNames=function(e){for(var t,n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r={},o={};t=n.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===n.currentNode.namespaceURI?r[t]=!0:o[t]=!0,n.nextNode(););return Object.keys(r).filter(function(e){return!o[e]})},n}()),i=function(a,f,t,m){"use strict";var e={};e.executeJavascript=function(s,l){return new Promise(function(t){function n(){m.document.getElementsByTagName("body")[0].removeChild(r)}function e(){var e=r.contentDocument;t({document:e,errors:i,cleanUp:n})}var r=function(e,t,n,r){t=e.createElement(t);return t.style.visibility="hidden",t.style.width=n+"px",t.style.height=r+"px",t.style.position="absolute",t.style.top=-1e4-r+"px",t.style.left=-1e4-n+"px",e.getElementsByTagName("body")[0].appendChild(t),t}(m.document,"iframe",l.width,l.height),o=s.outerHTML,i=[],c=l.executeJsTimeout||0,u=r.contentWindow.XMLHttpRequest,a=f.finishNotifyingXhr(u),u=f.baseUrlRespectingXhr(a,l.baseUrl);r.onload=function(){var t;(0<(t=c)?new Promise(function(e){setTimeout(e,t)}):Promise.resolve()).then(a.waitForRequestsToFinish).then(e)},r.contentDocument.open(),r.contentWindow.XMLHttpRequest=u,r.contentWindow.onerror=function(e){i.push({resourceType:"scriptExecution",msg:e})},r.contentDocument.write(""),r.contentDocument.write(o),r.contentDocument.close()})};function s(e,t,n,r,o){var i,c,u,a=Math.max(e.scrollWidth,e.clientWidth),s=Math.max(e.scrollHeight,e.clientHeight),l=t?(i=(l=function(e,t){var n=e.querySelector(t);if(n)return n;if(e.ownerDocument.querySelector(t)===e)return e;throw{message:"Clipping selector not found"}}(e,t).getBoundingClientRect()).top,c=l.left,u=l.width,l.height):(c=i=0,u=a,s);return l={width:u,height:l},r=r,o=o,r={width:Math.max(l.width*o,n),height:Math.max(l.height*o,r)},e=m.getComputedStyle(e.ownerDocument.documentElement).fontSize,{left:c,top:i,width:r.width,height:r.height,viewportWidth:a,viewportHeight:s,rootFontSize:e}}e.calculateDocumentContentSize=function(c,u){return new Promise(function(n,r){var e,t,o=u.zoom||1,i=function(e,t,n){e=Math.floor(e/n),n=Math.floor(t/n);return function(e,t,n){e=e.createElement("iframe");return e.style.width=t+"px",e.style.height=n+"px",e.style.visibility="hidden",e.style.position="absolute",e.style.top=-1e4-n+"px",e.style.left=-1e4-t+"px",e.style.borderWidth=0,e.sandbox="allow-same-origin",e.scrolling="no",e}(m.document,e,n)}(u.width,u.height,o);m.document.getElementsByTagName("body")[0].appendChild(i),i.onload=function(){var e,t=i.contentDocument;try{e=s(function(e,t){e=e.tagName;return t.querySelector(e)}(c,t),u.clip,u.width,u.height,o),n(e)}catch(e){r(e)}finally{m.document.getElementsByTagName("body")[0].removeChild(i)}},i.contentDocument.open(),i.contentDocument.write(""),i.contentDocument.write("html"===(t=(e=c).tagName.toLowerCase())||"body"===t?e.outerHTML:'
'+e.outerHTML+""),i.contentDocument.close()})},e.parseHtmlFragment=function(e){var t=m.document.implementation.createHTMLDocument("");t.documentElement.innerHTML=e;t=t.querySelector("body").firstChild;if(!t)throw"Invalid source";return t};e.parseHTML=function(e){var t=m.document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,function(e,t){var n,r,o,i=/]*)?)>/im.exec(t),t=m.document.implementation.createHTMLDocument("");if(i)for(i="",t.documentElement.innerHTML=i,r=t.querySelector("div"),n=0;n',n=function(){return new Promise(function(t,e){var n;(function(){if(r.Blob)try{return new Blob([""],{type:"text/xml"}),!0}catch(e){}return!1})()&&r.URL?(n=o(a,!0),i(n).then(function(e){return c(n),!e&&i(o(a,!1)).then(function(e){return e})},function(){return!1}).then(function(e){t(!e)},function(){e()})):t(!1)})};return t.renderSvg=function(i){return new Promise(function(e,t){function n(){r&&c(r)}var r,o=new Image;o.onload=function(){o.onload=null,o.onerror=null,n(),e(o)},o.onerror=function(){n(),t()},u(i).then(function(e){r=e,o.src=r},t)})},t}(window);return function(o,i,c){"use strict";var u={};u.drawDocument=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n=o.parseOptionalParameters(t),r=e.documentElement||e;return c.rasterize(r,n.canvas,(e=(t=n).canvas,r=t.options,n=e?e.width:300,e=e?e.height:200,e={width:void 0!==r.width?r.width:n,height:void 0!==r.height?r.height:e},(t=o.clone(t.options)).width=e.width,t.height=e.height,t))};u.drawHTML=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return function(e,t,n){e=i.parseHTML(e);return u.drawDocument(e,t,n)}(e,t.canvas,t.options)};function n(t,n,r){return i.loadDocument(t,r).then(function(e){e=function(e,t,n){var r=document.implementation.createHTMLDocument("");r.replaceChild(e.documentElement,r.documentElement);e=n?o.clone(n):{};return n.baseUrl||(e.baseUrl=t),{document:r,options:e}}(e,t,r);return u.drawDocument(e.document,n,e.options)})}return u.drawURL=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return n(e,t.canvas,t.options)},u}(o,i,function(o,i,c,r,e,u){"use strict";function a(t){return e.renderSvg(t).then(function(e){return{image:e,svg:t}},function(e){throw l(e)})}function s(e,t,n){return r.drawDocumentAsSvg(e,n).then(a).then(function(e){return t&&function(e,t){try{t.getContext("2d").drawImage(e,0,0)}catch(e){throw l(e)}}(e.image,t),e})}var t={},l=function(e){return{message:"Error rendering page",originalError:e}};return t.rasterize=function(e,n,r){var t=o.clone(r);return t.inlineScripts=!0===r.executeJs,u.inlineReferences(e,t).then(function(t){return r.executeJs?i.executeJavascript(e,r).then(function(e){var t=e.document;return c.persistInputValues(t),{document:t,errors:e.errors,cleanUp:e.cleanUp}}).then(function(e){return{element:e.document.documentElement,errors:t.concat(e.errors),cleanUp:e.cleanUp}}):{element:e,errors:t,cleanUp:function(){}}}).then(function(t){return s(t.element,n,r).then(function(e){return t.cleanUp(),{image:e.image,svg:e.svg,errors:t.errors}})})},t}(o,i,e,function(c,r,u){"use strict";function a(t){var e=Object.keys(t);return e.length?" "+e.map(function(e){return e+'="'+t[e]+'"'}).join(" "):""}function o(e,t,n){var r,o,i=u.serializeToString(e);return c.validateXHTML(i),(e=(r=t,o=Math.round(r.viewportWidth),e=Math.round(r.viewportHeight),{x:-r.left,y:-r.top,width:o,height:e})).style=(e.style||"")+"float: left;",e.externalResourcesRequired=!0,'"}var i={};return i.getSvgForDocument=function(e,t,n){return r.rewriteTagNameSelectorsToLowerCase(e),o(e,t,n)},i.drawDocumentAsSvg=function(t,n){return["hover","active","focus","target"].forEach(function(e){n[e]&&r.fakeUserAction(t,n[e],e)}),c.calculateDocumentContentSize(t,n).then(function(e){return i.getSvgForDocument(t,e,n.zoom)})},i}(i,e,t),n,r))});// the XRWG (XR WordGraph)is mentioned in the spec
+!function(o,i){void 0===o&&void 0!==window&&(o=window),"function"==typeof define&&define.amd?define(["url","xmlserializer","sane-domparser-error","inlineresources"],function(e,t,n,r){return o.rasterizeHTML=i(e,t,n,r)}):"object"==typeof module&&module.exports?module.exports=i(require("url"),require("xmlserializer"),require("sane-domparser-error"),require("inlineresources")):o.rasterizeHTML=i(o.url,o.xmlserializer,o.sanedomparsererror,o.inlineresources)}(this,function(e,t,n,r){var o=function(n){"use strict";var o={},t=[];o.joinUrl=function(e,t){return e?n.resolve(e,t):t},o.getConstantUniqueIdFor=function(e){return t.indexOf(e)<0&&t.push(e),t.indexOf(e)},o.clone=function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};return o.parseOptionalParameters=function(e){var t,n,r={canvas:null,options:{}};return null==e[0]||(t=e[0],"object"==typeof(n=t)&&null!==n&&Object.prototype.toString.apply(t).match(/\[object (Canvas|HTMLCanvasElement)\]/i))?(r.canvas=e[0]||null,r.options=o.clone(e[1])):r.options=o.clone(e[0]),r},o}(e),i=function(i){"use strict";function u(e,t,n){var r=e[t];return e[t]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(this,[e,r])},r}var e={};return e.baseUrlRespectingXhr=function(t,o){return function(){var e=new t;return u(e,"open",function(e,t){var n=e.shift(),r=e.shift(),r=i.joinUrl(o,r);return t.apply(this,[n,r].concat(e))}),e}},e.finishNotifyingXhr=function(t){function e(){var e=new t;return u(e,"send",function(e,t){return r+=1,t.apply(this,arguments)}),e.addEventListener("load",function(){o+=1,n()}),e}var n,r=0,o=0,i=!1,c=new Promise(function(e){n=function(){r-o<=0&&i&&e({totalCount:r})}});return e.waitForRequestsToFinish=function(){return i=!0,n(),c},e},e}(o),e=function(i){"use strict";function r(e){return Array.prototype.slice.call(e)}var e={},c={active:!0,hover:!0,focus:!1,target:!1};return e.fakeUserAction=function(e,t,n){var r=e.querySelector(t),o=":"+n,t="rasterizehtml"+n;r&&(c[n]?i.addClassNameRecursively(r,t):i.addClassName(r,t),i.rewriteCssSelectorWith(e,o,"."+t))},e.persistInputValues=function(e){function t(e){return"checkbox"===e.type||"radio"===e.type}var n=e.querySelectorAll("input"),e=e.querySelectorAll("textarea");r(n).filter(t).forEach(function(e){e.checked?e.setAttribute("checked",""):e.removeAttribute("checked")}),r(n).filter(function(e){return!t(e)}).forEach(function(e){e.setAttribute("value",e.value)}),r(e).forEach(function(e){e.textContent=e.value})},e.rewriteTagNameSelectorsToLowerCase=function(e){i.lowercaseCssTypeSelectors(e,i.findHtmlOnlyNodeNames(e))},e}(function(){"use strict";function c(e){return Array.prototype.slice.call(e)}var n={};n.addClassName=function(e,t){e.className+=" "+t},n.addClassNameRecursively=function(e,t){n.addClassName(e,t),e.parentNode!==e.ownerDocument&&n.addClassNameRecursively(e.parentNode,t)};function r(e,t,o){var i="((?:^|[^.#:\\w])|(?=\\W))("+t.join("|")+")(?=\\W|$)";c(e.querySelectorAll("style")).forEach(function(e){var t,n;void 0===e.sheet&&(t=e,n=document.implementation.createHTMLDocument(""),(r=document.createElement("style")).textContent=t.textContent,n.body.appendChild(r),t.sheet=r.sheet);var r=c(e.sheet.cssRules).filter(function(e){return e.selectorText&&new RegExp(i,"i").test(e.selectorText)});r.length&&(r.forEach(function(e){var t,n=e.selectorText.replace(new RegExp(i,"gi"),function(e,t,n){return t+o(n)});n!==e.selectorText&&(t=n,e=(n=e).cssText.replace(/^[^\{]+/,""),u(n,t+" "+e))}),e.textContent=a(e.sheet.cssRules))})}var u=function(e,t){var n=e.parentStyleSheet,e=c(n.cssRules).indexOf(e);n.insertRule(t,e+1),n.deleteRule(e)},a=function(e){return c(e).reduce(function(e,t){return e+t.cssText},"")};return n.rewriteCssSelectorWith=function(e,t,n){r(e,[t],function(){return n})},n.lowercaseCssTypeSelectors=function(e,t){r(e,t,function(e){return e.toLowerCase()})},n.findHtmlOnlyNodeNames=function(e){for(var t,n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r={},o={};t=n.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===n.currentNode.namespaceURI?r[t]=!0:o[t]=!0,n.nextNode(););return Object.keys(r).filter(function(e){return!o[e]})},n}()),i=function(a,f,t,m){"use strict";var e={};e.executeJavascript=function(s,l){return new Promise(function(t){function n(){m.document.getElementsByTagName("body")[0].removeChild(r)}function e(){var e=r.contentDocument;t({document:e,errors:i,cleanUp:n})}var r=function(e,t,n,r){t=e.createElement(t);return t.style.visibility="hidden",t.style.width=n+"px",t.style.height=r+"px",t.style.position="absolute",t.style.top=-1e4-r+"px",t.style.left=-1e4-n+"px",e.getElementsByTagName("body")[0].appendChild(t),t}(m.document,"iframe",l.width,l.height),o=s.outerHTML,i=[],c=l.executeJsTimeout||0,u=r.contentWindow.XMLHttpRequest,a=f.finishNotifyingXhr(u),u=f.baseUrlRespectingXhr(a,l.baseUrl);r.onload=function(){var t;(0<(t=c)?new Promise(function(e){setTimeout(e,t)}):Promise.resolve()).then(a.waitForRequestsToFinish).then(e)},r.contentDocument.open(),r.contentWindow.XMLHttpRequest=u,r.contentWindow.onerror=function(e){i.push({resourceType:"scriptExecution",msg:e})},r.contentDocument.write(""),r.contentDocument.write(o),r.contentDocument.close()})};function s(e,t,n,r,o){var i,c,u,a=Math.max(e.scrollWidth,e.clientWidth),s=Math.max(e.scrollHeight,e.clientHeight),l=t?(i=(l=function(e,t){var n=e.querySelector(t);if(n)return n;if(e.ownerDocument.querySelector(t)===e)return e;throw{message:"Clipping selector not found"}}(e,t).getBoundingClientRect()).top,c=l.left,u=l.width,l.height):(c=i=0,u=a,s);return l={width:u,height:l},r=r,o=o,r={width:Math.max(l.width*o,n),height:Math.max(l.height*o,r)},e=m.getComputedStyle(e.ownerDocument.documentElement).fontSize,{left:c,top:i,width:r.width,height:r.height,viewportWidth:a,viewportHeight:s,rootFontSize:e}}e.calculateDocumentContentSize=function(c,u){return new Promise(function(n,r){var e,t,o=u.zoom||1,i=function(e,t,n){e=Math.floor(e/n),n=Math.floor(t/n);return function(e,t,n){e=e.createElement("iframe");return e.style.width=t+"px",e.style.height=n+"px",e.style.visibility="hidden",e.style.position="absolute",e.style.top=-1e4-n+"px",e.style.left=-1e4-t+"px",e.style.borderWidth=0,e.sandbox="allow-same-origin",e.scrolling="no",e}(m.document,e,n)}(u.width,u.height,o);m.document.getElementsByTagName("body")[0].appendChild(i),i.onload=function(){var e,t=i.contentDocument;try{e=s(function(e,t){e=e.tagName;return t.querySelector(e)}(c,t),u.clip,u.width,u.height,o),n(e)}catch(e){r(e)}finally{m.document.getElementsByTagName("body")[0].removeChild(i)}},i.contentDocument.open(),i.contentDocument.write(""),i.contentDocument.write("html"===(t=(e=c).tagName.toLowerCase())||"body"===t?e.outerHTML:''+e.outerHTML+""),i.contentDocument.close()})},e.parseHtmlFragment=function(e){var t=m.document.implementation.createHTMLDocument("");t.documentElement.innerHTML=e;t=t.querySelector("body").firstChild;if(!t)throw"Invalid source";return t};e.parseHTML=function(e){var t=m.document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,function(e,t){var n,r,o,i=/]*)?)>/im.exec(t),t=m.document.implementation.createHTMLDocument("");if(i)for(i="",t.documentElement.innerHTML=i,r=t.querySelector("div"),n=0;n',n=function(){return new Promise(function(t,e){var n;(function(){if(r.Blob)try{return new Blob([""],{type:"text/xml"}),!0}catch(e){}return!1})()&&r.URL?(n=o(a,!0),i(n).then(function(e){return c(n),!e&&i(o(a,!1)).then(function(e){return e})},function(){return!1}).then(function(e){t(!e)},function(){e()})):t(!1)})};return t.renderSvg=function(i){return new Promise(function(e,t){function n(){r&&c(r)}var r,o=new Image;o.onload=function(){o.onload=null,o.onerror=null,n(),e(o)},o.onerror=function(){n(),t()},u(i).then(function(e){r=e,o.src=r},t)})},t}(window);return function(o,i,c){"use strict";var u={};u.drawDocument=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n=o.parseOptionalParameters(t),r=e.documentElement||e;return c.rasterize(r,n.canvas,(e=(t=n).canvas,r=t.options,n=e?e.width:300,e=e?e.height:200,e={width:void 0!==r.width?r.width:n,height:void 0!==r.height?r.height:e},(t=o.clone(t.options)).width=e.width,t.height=e.height,t))};u.drawHTML=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return function(e,t,n){e=i.parseHTML(e);return u.drawDocument(e,t,n)}(e,t.canvas,t.options)};function n(t,n,r){return i.loadDocument(t,r).then(function(e){e=function(e,t,n){var r=document.implementation.createHTMLDocument("");r.replaceChild(e.documentElement,r.documentElement);e=n?o.clone(n):{};return n.baseUrl||(e.baseUrl=t),{document:r,options:e}}(e,t,r);return u.drawDocument(e.document,n,e.options)})}return u.drawURL=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return n(e,t.canvas,t.options)},u}(o,i,function(o,i,c,r,e,u){"use strict";function a(t){return e.renderSvg(t).then(function(e){return{image:e,svg:t}},function(e){throw l(e)})}function s(e,t,n){return r.drawDocumentAsSvg(e,n).then(a).then(function(e){return t&&function(e,t){try{t.getContext("2d").drawImage(e,0,0)}catch(e){throw l(e)}}(e.image,t),e})}var t={},l=function(e){return{message:"Error rendering page",originalError:e}};return t.rasterize=function(e,n,r){var t=o.clone(r);return t.inlineScripts=!0===r.executeJs,u.inlineReferences(e,t).then(function(t){return r.executeJs?i.executeJavascript(e,r).then(function(e){var t=e.document;return c.persistInputValues(t),{document:t,errors:e.errors,cleanUp:e.cleanUp}}).then(function(e){return{element:e.document.documentElement,errors:t.concat(e.errors),cleanUp:e.cleanUp}}):{element:e,errors:t,cleanUp:function(){}}}).then(function(t){return s(t.element,n,r).then(function(e){return t.cleanUp(),{image:e.image,svg:e.svg,errors:t.errors}})})},t}(o,i,e,function(c,r,u){"use strict";function a(t){var e=Object.keys(t);return e.length?" "+e.map(function(e){return e+'="'+t[e]+'"'}).join(" "):""}function o(e,t,n){var r,o,i=u.serializeToString(e);return c.validateXHTML(i),(e=(r=t,o=Math.round(r.viewportWidth),e=Math.round(r.viewportHeight),{x:-r.left,y:-r.top,width:o,height:e})).style=(e.style||"")+"float: left;",e.externalResourcesRequired=!0,'"}var i={};return i.getSvgForDocument=function(e,t,n){return r.rewriteTagNameSelectorsToLowerCase(e),o(e,t,n)},i.drawDocumentAsSvg=function(t,n){return["hover","active","focus","target"].forEach(function(e){n[e]&&r.fakeUserAction(t,n[e],e)}),c.calculateDocumentContentSize(t,n).then(function(e){return i.getSvgForDocument(t,e,n.zoom)})},i}(i,e,t),n,r))});
+// the XRWG (XR WordGraph)is mentioned in the spec
//
// it collects metadata-keys ('foo' e.g.), names and tags across 3D scene-nodes (.userData.foo e.g.)
@@ -701,18 +696,19 @@ XRWG.cleankey = (word) => String(word).replace(/[^0-9\.a-zA-Z_]/g,'')
XRWG.get = (v,k) => XRWG.find( (x) => x[ k || 'word'] == v )
XRWG.match = (str,types,level) => {
- level = level || 1000
+ if( XRWG.length == 0 ) XRWG.generate(xrf)
+ level = level == undefined ? 1000 : level
types = types || []
let res = XRWG.filter( (n) => {
types.map( (type) => n[type] ? n = false : false )
return n
})
str = str.toLowerCase()
- if( level <10 ) res = res.filter( (n) => n.key == str )
- if( level <20 ) res = res.filter( (n) => n.word == str || n.key == str )
- if( level <30 ) res = res.filter( (n) => n.word.match(str) || n.key == str )
- if( level <40 ) res = res.filter( (n) => n.word.match(str) || n.key == str || String(n.value||'').match(str) )
- if( level <1001 ) res = res.filter( (n) => n.word.match(str) != null || n.key.match(str) != null || String(n.value||'').match(str) != null)
+ if( level <10 ) res = res.filter( (n) => n.key == str )
+ if( level >=10 ) res = res.filter( (n) => n.word == str || n.key == str )
+ if( level >30 ) res = res.filter( (n) => n.word.match(str) || n.key == str )
+ if( level >40 ) res = res.filter( (n) => n.word.match(str) || n.key == str || String(n.value||'').match(str) )
+ if( level >999 ) res = res.filter( (n) => n.word.match(str) != null || n.key.match(str) != null || String(n.value||'').match(str) != null)
return res
}
@@ -731,7 +727,7 @@ XRWG.generate = (opts) => {
node = { word: XRWG.cleankey(key), key, nodes:[spatialNode] }
if( spatialNode.userData[key] ) node.value = spatialNode.userData[key]
node[type] = true
- xrf.emit('XRWG',node)
+ xrf.emit('XRWGnode',node)
XRWG.push( node )
}
}
@@ -753,6 +749,7 @@ XRWG.generate = (opts) => {
// sort by n
XRWG.sort( (a,b) => a.nodes.length - b.nodes.length )
XRWG = XRWG.reverse() // the cleankey/get functions e.g. will persist
+ xrf.emit('XRWG',XRWG)
}
// the hashbus (QueryString eventBus) is mentioned in the spec
//
@@ -782,7 +779,7 @@ pub.mesh = (mesh,model) => { // evaluate embedded fragments (metadata) insid
for( let k in frag ){
let opts = {frag, mesh, model, camera: xrf.camera, scene: model.scene, renderer: xrf.renderer, THREE: xrf.THREE, hashbus: xrf.hashbus }
mesh.userData.XRF = frag // allow fragment impl to access XRF obj already
- xrf.emit('mesh',opts)
+ xrf.emit('frag2mesh',opts)
.then( () => pub.fragment(k,opts) )
}
}
@@ -791,12 +788,14 @@ pub.mesh = (mesh,model) => { // evaluate embedded fragments (metadata) insid
pub.fragment = (k, opts ) => { // evaluate one fragment
let frag = opts.frag[k];
+ if( frag.is( xrf.XRF.PV_EXECUTE ) ) pub.XRWG({...opts,frag})
+
// call native function (xrf/env.js e.g.), or pass it to user decorator
xrf.emit(k,opts)
.then( () => {
let func = xrf.frag[k] || function(){}
- if( xrf[k] ) xrf[k]( func, frag, opts)
- else func( frag, opts)
+ if( typeof xrf[k] == 'function' ) xrf[k]( func, frag, opts)
+ else func( frag, opts)
})
}
@@ -859,9 +858,9 @@ xrf.patchRenderer = function(opts){
renderer.render = ((render) => function(scene,camera){
// update clock
let time = xrf.clock.getDelta()
- // allow entities to do stuff during render (onBeforeRender and onAfterRender don't always fire)
- xrf.emit('render',{scene,camera,time}) // allow fragments to do something at renderframe
+ xrf.emit('render',{scene,camera,time,render}) // allow fragments to do something at renderframe
render(scene,camera)
+ xrf.emit('renderPost',{scene,camera,time,render,renderer}) // allow fragments to do something after renderframe
})(renderer.render.bind(renderer))
}
@@ -909,18 +908,15 @@ xrf.reset = () => {
return true
};
let nodes = []
- xrf.scene.traverse( (n) => n.audio ? n.audio.remove() : false )
- xrf.scene.traverse( (child) => child.isXRF ? nodes.push(child) : false )
+ xrf.scene.traverse( (n) => n.audio && (n.audio.remove()) )
+ xrf.scene.traverse( (child) => child.isXRF && (nodes.push(child)) )
nodes.map( disposeObject ) // leave non-XRF objects intact
- xrf.interactive = xrf.InteractiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
+ xrf.interactive = xrf.interactiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
xrf.add( xrf.interactive )
xrf.layers = 0
xrf.emit('reset',{})
// remove mixers
- xrf.mixers.map( (m) => {
- m.stop()
- delete m
- })
+ xrf.mixers.map( (m) => m.stop())
xrf.mixers = []
}
@@ -937,9 +933,565 @@ xrf.add = (object) => {
object.isXRF = true // mark for easy deletion when replacing scene
xrf.scene.add(object)
}
+
+xrf.hasNoMaterial = (mesh) => {
+ const hasTexture = mesh.material && mesh.material.map
+ const hasMaterialName = mesh.material && mesh.material.name.length > 0
+ return mesh.geometry && !hasMaterialName && !hasTexture
+}
+xrf.navigator = {}
+
+xrf.navigator.to = (url,flags,loader,data) => {
+ if( !url ) throw 'xrf.navigator.to(..) no url given'
+
+ let hashbus = xrf.hashbus
+ xrf.emit('navigate', {url,loader,data})
+
+ return new Promise( (resolve,reject) => {
+ let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
+ if( !file || (!data && xrf.model.file == file) ){ // we're already loaded
+ hashbus.pub( url, xrf.model, flags ) // and eval local URI XR fragments
+ xrf.navigator.updateHash(hash)
+ return resolve(xrf.model)
+ }
+
+ if( xrf.model && xrf.model.scene ) xrf.model.scene.visible = false
+ if( !loader ){
+ const Loader = xrf.loaders[ext]
+ if( !Loader ) throw 'xrfragment: no loader passed to xrfragment for extension .'+ext
+ loader = loader || new Loader().setPath( dir )
+ }
+
+ // force relative path
+ if( dir ) dir = dir[0] == '.' ? dir : `.${dir}`
+ url = url.replace(dir,"")
+ loader = loader || new Loader().setPath( dir )
+ const onLoad = (model) => {
+ xrf.reset() // clear xrf objects from scene
+ model.file = file
+ // only change url when loading *another* file
+ if( xrf.model ) xrf.navigator.pushState( `${dir}${file}`, hash )
+ xrf.model = model
+ // spec: 1. generate the XRWG
+ xrf.XRWG.generate({model,scene:model.scene})
+ // spec: 1. execute the default predefined view '#' (if exist) (https://xrfragment.org/#predefined_view)
+ xrf.frag.defaultPredefinedViews({model,scene:model.scene})
+ // spec: 2. init metadata
+ // spec: predefined view(s) from URL (https://xrfragment.org/#predefined_view)
+ setTimeout( () => { // give external objects some slack
+ let frag = hashbus.pub( url, model) // and eval URI XR fragments
+ hashbus.pub.XRWG({model,scene:model.scene,frag})
+ },2000)
+ xrf.add( model.scene )
+ xrf.navigator.updateHash(hash)
+ xrf.emit('navigateLoaded',{url,model})
+ resolve(model)
+ }
+
+ if( data ) loader.parse(data, "", onLoad )
+ else loader.load(url, onLoad )
+ })
+}
+
+xrf.navigator.init = () => {
+ if( xrf.navigator.init.inited ) return
+
+ window.addEventListener('popstate', function (event){
+ xrf.navigator.to( document.location.search.substr(1) + document.location.hash )
+ })
+
+ window.addEventListener('hashchange', function (e){
+ xrf.emit('hash', {hash: document.location.hash })
+ })
+
+ // this allows selectionlines to be updated according to the camera (renderloop)
+ xrf.focusLine = new xrf.THREE.Group()
+ xrf.focusLine.material = new xrf.THREE.LineDashedMaterial({color:0xFF00FF,linewidth:3, scale: 1, dashSize: 0.2, gapSize: 0.1,opacity:0.3, transparent:true})
+ xrf.focusLine.isXRF = true
+ xrf.focusLine.position.set(0,0,-0.5);
+ xrf.focusLine.points = []
+ xrf.focusLine.lines = []
+ xrf.camera.add(xrf.focusLine)
+
+ xrf.navigator.init.inited = true
+}
+
+xrf.navigator.updateHash = (hash,opts) => {
+ if( hash.replace(/^#/,'') == document.location.hash.substr(1) || hash.match(/\|/) ) return // skip unnecesary pushState triggers
+ console.log(`URL: ${document.location.search.substr(1)}#${hash}`)
+ document.location.hash = hash
+ xrf.emit('hash', {...opts, hash: `#${hash}` })
+}
+
+xrf.navigator.pushState = (file,hash) => {
+ if( file == document.location.search.substr(1) ) return // page is in its default state
+ window.history.pushState({},`${file}#${hash}`, document.location.pathname + `?${file}#${hash}` )
+ xrf.emit('pushState', {file, hash} )
+}
+xrf.addEventListener('env', (opts) => {
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ if( frag.env && !scene.environment ){
+ //let env = scene.getObjectByName(frag.env.string)
+ //if( !env ) env = xrf.scene.getObjectByName(frag.env.string) // repurpose from parent scene
+ //if( !env ) return console.warn("xrf.env "+frag.env.string+" not found")
+ //env.material.map.mapping = THREE.EquirectangularReflectionMapping;
+ //scene.environment = env.material.map
+ //scene.texture = env.material.map
+ // renderer.toneMapping = THREE.ACESFilmicToneMapping;
+ // renderer.toneMappingExposure = 2;
+ console.log(` └ applied image '${frag.env.string}' as environment map`)
+ }
+
+})
+/**
+ *
+ * navigation, portals & mutations
+ *
+ * | fragment | type | scope | example value |
+ * |`href`| string (uri or predefined view) | 🔒 |`#pos=1,1,0`
`#pos=1,1,0&rot=90,0,0`
`#pos=pyramid`
`#pos=lastvisit|pyramid`
`://somefile.gltf#pos=1,1,0`
|
+ *
+ * [[» example implementation|https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/three/xrf/href.js]]
+ * [[» example 3D asset|https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/href.gltf#L192]]
+ * [[» discussion|https://github.com/coderofsalvation/xrfragment/issues/1]]
+ *
+ * [img[xrfragment.jpg]]
+ *
+ *
+ * !!!spec 1.0
+ *
+ * 1. an ''external''- or ''file URI'' fully replaces the current scene and assumes `pos=0,0,0&rot=0,0,0` by default (unless specified)
+ *
+ * 2. navigation should not happen when queries (`q=`) are present in local url: queries will apply (`pos=`, `rot=` e.g.) to the targeted object(s) instead.
+ *
+ * 3. navigation should not happen ''immediately'' when user is more than 2 meter away from the portal/object containing the href (to prevent accidental navigation e.g.)
+ *
+ * 4. URL navigation should always be reflected in the client (in case of javascript: see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/src/3rd/three/navigator.js]] for an example navigator).
+ *
+ * 5. In XR mode, the navigator back/forward-buttons should be always visible (using a wearable e.g., see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/example/aframe/sandbox/index.html#L26-L29]] for an example wearable)
+ *
+ * [img[navigation.png]]
+ *
+ */
+
+xrf.frag.href = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+
+ if( mesh.userData.XRF.href.exec ) return // mesh already initialized
+
+ let click = mesh.userData.XRF.href.exec = (e) => {
+
+ let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
+ xrf
+ .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree
+ .then( () => {
+ const flags = v.string[0] == '#' ? xrf.XRF.PV_OVERRIDE : undefined
+ let toFrag = xrf.URI.parse( v.string, xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.METADATA )
+ // always commit current location (keep a trail of last positions before we navigate)
+ if( !e.nocommit && !document.location.hash.match(lastPos) ) xrf.navigator.to(`#${lastPos}`)
+ xrf.navigator.to(v.string) // let's surf to HREF!
+ })
+ .catch( console.error )
+ }
+
+ let selected = mesh.userData.XRF.href.selected = (state) => () => {
+ if( mesh.selected == state ) return // nothing changed
+ xrf.interactive.objects.map( (o) => {
+ let newState = o.name == mesh.name ? state : false
+ if( o.material ){
+ if( o.material.uniforms ) o.material.uniforms.selected.value = newState
+ //if( o.material.emissive ) o.material.emissive.r = o.material.emissive.g = o.material.emissive.b = newState ? 2.0 : 1.0
+ if( o.material.emissive ){
+ if( !o.material.emissive.original ) o.material.emissive.original = o.material.emissive.clone()
+ o.material.emissive.r = o.material.emissive.g = o.material.emissive.b =
+ newState ? o.material.emissive.original.r + 0.5 : o.material.emissive.original.r
+ }
+ }
+ })
+ // update mouse cursor
+ if( !renderer.domElement.lastCursor )
+ renderer.domElement.lastCursor = renderer.domElement.style.cursor
+ renderer.domElement.style.cursor = state ? 'pointer' : renderer.domElement.lastCursor
+
+ xrf
+ .emit('href',{selected:state,mesh,xrf:v}) // let all listeners agree
+ .then( () => mesh.selected = state )
+ }
+
+ mesh.addEventListener('click', click )
+ mesh.addEventListener('mousemove', selected(true) )
+ mesh.addEventListener('mouseenter', selected(true) )
+ mesh.addEventListener('mouseleave', selected(false) )
+
+ if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
+
+ // lazy add mesh (because we're inside a recursive traverse)
+ setTimeout( (mesh) => {
+ xrf.interactive.add(mesh)
+ xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
+ }, 0, mesh )
+}
+
+/**
+ * > above solutions were abducted from [[this|https://i.imgur.com/E3En0gJ.png]] and [[this|https://i.imgur.com/lpnTz3A.png]] survey result
+ *
+ * !!!Demo
+ *
+ * <$videojs controls="controls" aspectratio="16:9" preload="auto" poster="" fluid="fluid" class="vjs-big-play-centered">
+ *
+ * $videojs>
+ *
+ * > capture of aframe/sandbox
+ */
+xrf.frag.pos = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+
+
+ // spec: indirect coordinate using objectname: https://xrfragment.org/#navigating%203D
+ if( v.x == undefined ){
+ let obj = scene.getObjectByName(v.string)
+ if( !obj ) return
+ let pos = obj.position.clone()
+ obj.getWorldPosition(pos)
+ camera.position.copy(pos)
+ }else{
+ // spec: direct coordinate: https://xrfragment.org/#navigating%203D
+ camera.position.x = v.x
+ camera.position.y = v.y
+ camera.position.z = v.z
+ }
+}
+xrf.frag.rot = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ console.log(" └ setting camera rotation to "+v.string)
+ camera.rotation.set(
+ v.x * Math.PI / 180,
+ v.y * Math.PI / 180,
+ v.z * Math.PI / 180
+ )
+ camera.updateMatrixWorld()
+}
+// *TODO* use webgl instancing
+
+xrf.frag.src = function(v, opts){
+ opts.embedded = v // indicate embedded XR fragment
+ let { mesh, model, camera, scene, renderer, THREE, hashbus, frag} = opts
+
+ let url = v.string
+ let srcFrag = opts.srcFrag = xrfragment.URI.parse(url)
+ opts.isLocal = v.string[0] == '#'
+
+ if( opts.isLocal ){
+ xrf.frag.src.localSRC(url,srcFrag,opts) // local
+ }else xrf.frag.src.externalSRC(url,srcFrag,opts) // external file
+}
+
+xrf.frag.src.addModel = (model,url,frag,opts) => {
+ let {mesh} = opts
+ let scene = model.scene
+ xrf.frag.src.filterScene(scene,{...opts,frag}) // filter scene
+ if( mesh.material ) mesh.material.visible = false // hide placeholder object
+ //enableSourcePortation(scene)
+ if( xrf.frag.src.renderAsPortal(mesh) ){
+ // only add remote objects, because
+ // local scene-objects are already added to scene
+ xrf.portalNonEuclidian({...opts,model,scene:model.scene})
+ if( !opts.isLocal && !mesh.portal.isLens ) xrf.scene.add(scene)
+ return
+ }else{
+ xrf.frag.src.scale( scene, opts, url ) // scale scene
+ mesh.add(scene)
+ }
+ // flag everything isSRC & isXRF
+ mesh.traverse( (n) => { n.isSRC = n.isXRF = n[ opts.isLocal ? 'isSRCLocal' : 'isSRCExternal' ] = true })
+ xrf.emit('parseModel', {...opts, scene, model})
+}
+
+xrf.frag.src.renderAsPortal = (mesh) => {
+ // *TODO* should support better isFlat(mesh) check
+ const isPlane = mesh.geometry && mesh.geometry.attributes.uv && mesh.geometry.attributes.uv.count == 4
+ return xrf.hasNoMaterial(mesh) && isPlane
+}
+
+xrf.frag.src.enableSourcePortation = (src) => {
+ // show sourceportation clickable plane
+ if( srcFrag.href || v.string[0] == '#' ) return
+ let scale = new THREE.Vector3()
+ let size = new THREE.Vector3()
+ mesh.getWorldScale(scale)
+ new THREE.Box3().setFromObject(src).getSize(size)
+ const geo = new THREE.SphereGeometry( Math.max(size.x, size.y, size.z) / scale.x, 10, 10 )
+ const mat = new THREE.MeshBasicMaterial()
+ mat.transparent = true
+ mat.roughness = 0.05
+ mat.metalness = 1
+ mat.opacity = 0
+ const cube = new THREE.Mesh( geo, mat )
+ console.log("todo: sourceportate")
+ return xrf.frag.src
+}
+
+xrf.frag.src.externalSRC = (url,frag,opts) => {
+ fetch(url, { method: 'HEAD' })
+ .then( (res) => {
+ console.log(`loading src ${url}`)
+ let mimetype = res.headers.get('Content-type')
+ if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
+ //if( url.match(/\.(fbx|stl|obj)$/) ) mimetype =
+ opts = { ...opts, frag, mimetype }
+ return xrf.frag.src.type[ mimetype ] ? xrf.frag.src.type[ mimetype ](url,opts) : xrf.frag.src.type.unknown(url,opts)
+ })
+ .then( (model) => {
+ if( model && model.scene ) xrf.frag.src.addModel(model, url, frag, opts )
+ })
+ .finally( () => { })
+ .catch( console.error )
+ return xrf.frag.src
+}
+
+xrf.frag.src.localSRC = (url,frag,opts) => {
+ let {model,scene} = opts
+ let _model = {
+ animations: model.animations,
+ scene: scene.clone()
+ }
+ _model.scenes = [_model.scene]
+ xrf.frag.src.addModel(_model,url,frag, opts) // current file
+}
+
+// scale embedded XR fragments https://xrfragment.org/#scaling%20of%20instanced%20objects
+xrf.frag.src.scale = function(scene, opts, url){
+ let { mesh, model, camera, renderer, THREE} = opts
+
+ // remove invisible objects (hidden by selectors) which might corrupt boundingbox size-detection
+ let cleanScene = scene.clone()
+ if( !cleanScene ) debugger
+ let remove = []
+ const notVisible = (n) => !n.visible || (n.material && !n.material.visible)
+ cleanScene.traverse( (n) => notVisible(n) && n.children.length == 0 && (remove.push(n)) )
+ remove.map( (n) => n.removeFromParent() )
+
+ let restrictTo3DBoundingBox = mesh.geometry
+ if( restrictTo3DBoundingBox ){
+ // spec 3 of https://xrfragment.org/#src
+ // spec 1 of https://xrfragment.org/#scaling%20of%20instanced%20objects
+ // normalize instanced objectsize to boundingbox
+ let sizeFrom = new THREE.Vector3()
+ let sizeTo = new THREE.Vector3()
+ let empty = new THREE.Object3D()
+ new THREE.Box3().setFromObject(mesh).getSize(sizeTo)
+ new THREE.Box3().setFromObject(cleanScene).getSize(sizeFrom)
+ let ratio = sizeFrom.divide(sizeTo)
+ scene.scale.multiplyScalar( 1.0 / Math.max(ratio.x, ratio.y, ratio.z));
+ }else{
+ // spec 4 of https://xrfragment.org/#src
+ // spec 2 of https://xrfragment.org/#scaling%20of%20instanced%20objects
+ scene.scale.multiply( mesh.scale )
+ }
+ scene.isXRF = model.scene.isSRC = true
+}
+
+xrf.frag.src.filterScene = (scene,opts) => {
+ let { mesh, model, camera, renderer, THREE, hashbus, frag} = opts
+
+ xrf.filter.scene({scene,frag,reparent:true})
+
+ scene.traverse( (m) => {
+ if( m.userData && (m.userData.src || m.userData.href) ) return ; // prevent infinite recursion
+ hashbus.pub.mesh(m,{scene,recursive:true}) // cool idea: recursion-depth based distance between face & src
+ })
+ return scene
+}
+
+/*
+ * replace the src-mesh with the contents of the src
+ */
+
+xrf.frag.src.type = {}
+
+/*
+ * mimetype: unknown
+ */
+
+xrf.frag.src.type['unknown'] = function( url, opts ){
+ return new Promise( (resolve,reject) => {
+ reject(`${url} mimetype '${opts.mimetype}' not found or supported (yet)`)
+ })
+}
+xrf.frag.t = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ if( !model.mixer ) return
+ if( !model.animations || model.animations[0] == undefined ) return console.warn('no animation in scene')
+
+ xrf.mixers.map ( (mixer) => {
+
+ mixer.t = v
+
+ // update speed
+ mixer.timeScale = mixer.loop.speed = v.x
+ mixer.loop.speedAbs = Math.abs(v.x)
+
+ if( v.y != undefined || v.z != undefined ) mixer.updateLoop( v )
+
+ // play animations
+ mixer.play( v )
+ })
+}
+
+xrf.frag.t.default = {
+ x:0, // (play from) offset (in seconds)
+ y:0 // optional: (stop at) offset (in seconds)
+}
+
+// setup animation mixer for global scene & src scenes
+xrf.addEventListener('parseModel', (opts) => {
+ let {model} = opts
+ let mixer = model.mixer = new xrf.THREE.AnimationMixer(model.scene)
+ mixer.model = model
+ mixer.loop = {timeStart:0,timeStop:0}
+ mixer.i = xrf.mixers.length
+ mixer.actions = []
+
+ model.animations.map( (anim) => {
+ anim.optimize()
+ console.log("action: "+anim.name)
+ mixer.actions.push( mixer.clipAction( anim, model.scene ) )
+ })
+
+
+ mixer.checkZombies = (animations) => {
+ if( mixer.zombieCheck ) return // fire only once
+ animations.map( (anim) => {
+ // collect zombie animations and warn user
+ let zombies = anim.tracks.map( (t) => {
+ let name = t.name.replace(/\..*/,'')
+ let obj = model.scene.getObjectByName(name)
+ return !model.scene.getObjectByName(name) ? {anim:anim.name,obj:name} : undefined
+ })
+ if( zombies.length > 0 && mixer.i == 0 ){ // only warn for zombies in main scene (because src-scenes might be filtered anyways)
+ zombies
+ .filter( (z) => z ) // filter out undefined
+ .map( (z) => console.warn(`gltf: object '${z.obj}' not found (anim: '${z.anim}'`) )
+ console.warn(`TIP: remove dots in objectnames in blender (which adds dots when duplicating)`)
+ }
+ })
+ mixer.zombieCheck = true
+ }
+
+ mixer.play = (t) => {
+ mixer.isPlaying = t.x != 0
+ mixer.updateLoop(t)
+ xrf.emit( mixer.isPlaying === false ? 'stop' : 'play',{isPlaying: mixer.isPlaying})
+ }
+
+ mixer.stop = () => {
+ mixer.play(false)
+ }
+
+ mixer.updateLoop = (t) => {
+ mixer.loop.timeStart = t.y != undefined ? t.y : mixer.loop.timeStart
+ mixer.loop.timeStop = t.z != undefined ? t.z : mixer.loop.timeStop
+ mixer.actions.map( (action) => {
+ if( mixer.loop.timeStart != undefined ){
+ action.time = mixer.loop.timeStart
+ action.setLoop( THREE.LoopOnce, )
+ action.timeScale = mixer.timeScale
+ action.enabled = true
+ if( t.x != 0 ){
+ action.play()
+ }
+ }
+ })
+ mixer.setTime(mixer.loop.timeStart)
+ mixer.time = Math.abs( mixer.loop.timeStart )
+ mixer.update(0)
+ mixer.checkZombies( model.animations)
+ }
+
+ // update loop when needed
+ if( !mixer.update.patched ){
+ let update = mixer.update
+ mixer.update = function(time){
+ mixer.time = Math.abs(mixer.time)
+ if( time == 0 ) return update.call(this,time)
+
+ // loop jump
+ if( mixer.loop.speed > 0.0 && (mixer.loop.timeStop > 0 && mixer.time > mixer.loop.timeStop) ){
+ setTimeout( (time,anims) => mixer.updateLoop(time), 0, mixer.loop.timeStart ) // prevent recursion
+ }
+ return update.call( this, time )
+ }
+ mixer.update.patched = true
+ }
+
+ // calculate total duration/frame based on longest animation
+ mixer.duration = 0
+ if( model.animations.length ){
+ model.animations.map( (a) => mixer.duration = ( a.duration > mixer.duration ) ? a.duration : mixer.duration )
+ }
+
+ xrf.mixers.push(mixer)
+})
+
+if( document.location.hash.match(/t=/) ){
+ let url = document.location.href
+ let playAfterUserGesture = () => {
+ xrf.hashbus.pub(url) // re-post t fragment on the hashbus again
+ window.removeEventListener('click',playAfterUserGesture)
+ window.removeEventListener('touchstart',playAfterUserGesture)
+ }
+ window.addEventListener('click', playAfterUserGesture )
+ window.addEventListener('touchstart', playAfterUserGesture )
+}
+
+xrf.addEventListener('render', (opts) => {
+ let model = xrf.model
+ let {time} = opts
+ if( !model ) return
+ if( xrf.mixers.length ){
+ xrf.mixers.map( (m) => m.isPlaying && (m.update( time )) )
+
+ // update active camera in case selected by dynamicKey in URI
+ if( xrf.model.camera && model.mixer.isPlaying ){
+
+ let cam = xrf.camera.getCam()
+ // cam.fov = model.cameras[0].fov (why is blender not exporting radians?)
+ cam.far = model.cameras[0].far
+ cam.near = model.cameras[0].near
+
+ let rig = xrf.camera
+ rig.position.copy( model.cameras[0].position )
+ rig.position.y -= rig.offsetY // VR/AR compensate camera rig
+ //rig.rotation.copy( model.cameras[0].rotation )
+
+ rig.updateProjectionMatrix()
+ }
+ }
+})
+
+xrf.addEventListener('dynamicKey', (opts) => {
+ // select active camera if any
+ let {id,match,v} = opts
+ match.map( (w) => {
+ w.nodes.map( (node) => {
+ if( node.isCamera ){
+ console.log("setting camera to "+node.name)
+ xrf.model.camera = node
+ }
+ })
+ })
+})
+xrf.getCollisionMeshes = () => {
+ let meshes = []
+ xrf.scene.traverse( (n) => {
+ if( !n.userData.href && !n.userData.src && xrf.hasNoMaterial(n) ){
+ meshes.push(n)
+ }
+ })
+ return meshes
+}
// wrapper to survive in/outside modules
-xrf.InteractiveGroup = function(THREE,renderer,camera){
+xrf.interactiveGroup = function(THREE,renderer,camera){
let {
Group,
@@ -952,7 +1504,7 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
const _event = { type: '', data: _pointer };
let object = {selected:false}
- class InteractiveGroup extends Group {
+ class interactive extends Group {
constructor( renderer, camera ) {
@@ -1010,9 +1562,9 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
element.addEventListener( 'pointerup', onPointerEvent );
element.addEventListener( 'pointermove', onPointerEvent );
element.addEventListener( 'mousedown', onPointerEvent );
- element.addEventListener( 'mouseup', onPointerEvent );
element.addEventListener( 'mousemove', onPointerEvent );
element.addEventListener( 'click', onPointerEvent );
+ element.addEventListener( 'mouseup', onPointerEvent );
// WebXR Controller Events
// TODO: Dispatch pointerevents too
@@ -1077,582 +1629,121 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
}
- return new InteractiveGroup(renderer,camera)
+ return new interactive(renderer,camera)
}
-xrf.navigator = {}
-
-xrf.navigator.to = (url,flags,loader,data) => {
- if( !url ) throw 'xrf.navigator.to(..) no url given'
-
- let hashbus = xrf.hashbus
-
- return new Promise( (resolve,reject) => {
- let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
- if( !file || (!data && xrf.model.file == file) ){ // we're already loaded
- hashbus.pub( url, xrf.model, flags ) // and eval local URI XR fragments
- xrf.navigator.updateHash(hash)
- return resolve(xrf.model)
- }
-
- if( xrf.model && xrf.model.scene ) xrf.model.scene.visible = false
- if( !loader ){
- const Loader = xrf.loaders[ext]
- if( !Loader ) throw 'xrfragment: no loader passed to xrfragment for extension .'+ext
- loader = loader || new Loader().setPath( dir )
- }
-
- // force relative path
- if( dir ) dir = dir[0] == '.' ? dir : `.${dir}`
- url = url.replace(dir,"")
- loader = loader || new Loader().setPath( dir )
- const onLoad = (model) => {
- xrf.reset() // clear xrf objects from scene
- model.file = file
- // only change url when loading *another* file
- if( xrf.model ) xrf.navigator.pushState( `${dir}${file}`, hash )
- xrf.model = model
- // spec: 1. generate the XRWG
- xrf.XRWG.generate({model,scene:model.scene})
- // spec: 1. execute the default predefined view '#' (if exist) (https://xrfragment.org/#predefined_view)
- xrf.frag.defaultPredefinedViews({model,scene:model.scene})
- // spec: 2. init metadata
- // spec: predefined view(s) from URL (https://xrfragment.org/#predefined_view)
- setTimeout( () => { // give external objects some slack
- let frag = hashbus.pub( url, model) // and eval URI XR fragments
- hashbus.pub.XRWG({model,scene:model.scene,frag})
- console.dir(frag)
- },2000)
- xrf.add( model.scene )
- xrf.navigator.updateHash(hash)
- resolve(model)
- }
-
- if( data ) loader.parse(data, "", onLoad )
- else loader.load(url, onLoad )
- })
-}
-
-xrf.navigator.init = () => {
- if( xrf.navigator.init.inited ) return
-
- window.addEventListener('popstate', function (event){
- xrf.navigator.to( document.location.search.substr(1) + document.location.hash )
- })
-
- window.addEventListener('hashchange', function (e){
- xrf.emit('hash', {hash: document.location.hash })
- })
-
- // this allows selectionlines to be updated according to the camera (renderloop)
- xrf.focusLine = new xrf.THREE.Group()
- xrf.focusLine.material = new xrf.THREE.LineDashedMaterial({color:0xFF00FF,linewidth:3, scale: 1, dashSize: 0.2, gapSize: 0.1,opacity:0.3, transparent:true})
- xrf.focusLine.isXRF = true
- xrf.focusLine.position.set(0,0,-0.5);
- xrf.focusLine.points = []
- xrf.focusLine.lines = []
- xrf.camera.add(xrf.focusLine)
-
- xrf.navigator.init.inited = true
-}
-
-xrf.navigator.updateHash = (hash,opts) => {
- if( hash.replace(/^#/,'') == document.location.hash.substr(1) || hash.match(/\|/) ) return // skip unnecesary pushState triggers
- console.log(`URL: ${document.location.search.substr(1)}#${hash}`)
- document.location.hash = hash
- xrf.emit('hash', {...opts, hash: `#${hash}` })
-}
-
-xrf.navigator.pushState = (file,hash) => {
- if( file == document.location.search.substr(1) ) return // page is in its default state
- window.history.pushState({},`${file}#${hash}`, document.location.pathname + `?${file}#${hash}` )
- xrf.emit('pushState', {file, hash} )
-}
-xrf.addEventListener('env', (opts) => {
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- if( frag.env && !scene.environment ){
- let env = scene.getObjectByName(frag.env.string)
- if( !env ) env = xrf.scene.getObjectByName(frag.env.string) // repurpose from parent scene
- if( !env ) return console.warn("xrf.env "+frag.env.string+" not found")
- env.material.map.mapping = THREE.EquirectangularReflectionMapping;
- scene.environment = env.material.map
- //scene.texture = env.material.map
- renderer.toneMapping = THREE.ACESFilmicToneMapping;
- renderer.toneMappingExposure = 2;
- console.log(` └ applied image '${frag.env.string}' as environment map`)
- }
-
-})
-/**
- *
- * navigation, portals & mutations
- *
- * | fragment | type | scope | example value |
- * |`href`| string (uri or predefined view) | 🔒 |`#pos=1,1,0`
`#pos=1,1,0&rot=90,0,0`
`#pos=pyramid`
`#pos=lastvisit|pyramid`
`://somefile.gltf#pos=1,1,0`
|
- *
- * [[» example implementation|https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/three/xrf/href.js]]
- * [[» example 3D asset|https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/href.gltf#L192]]
- * [[» discussion|https://github.com/coderofsalvation/xrfragment/issues/1]]
- *
- * [img[xrfragment.jpg]]
- *
- *
- * !!!spec 1.0
- *
- * 1. an ''external''- or ''file URI'' fully replaces the current scene and assumes `pos=0,0,0&rot=0,0,0` by default (unless specified)
- *
- * 2. navigation should not happen when queries (`q=`) are present in local url: queries will apply (`pos=`, `rot=` e.g.) to the targeted object(s) instead.
- *
- * 3. navigation should not happen ''immediately'' when user is more than 2 meter away from the portal/object containing the href (to prevent accidental navigation e.g.)
- *
- * 4. URL navigation should always be reflected in the client (in case of javascript: see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/src/3rd/three/navigator.js]] for an example navigator).
- *
- * 5. In XR mode, the navigator back/forward-buttons should be always visible (using a wearable e.g., see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/example/aframe/sandbox/index.html#L26-L29]] for an example wearable)
- *
- * [img[navigation.png]]
- *
+/*
+ * TODO: refactor/fix this (queries are being refactored to filters)
*/
-xrf.frag.href = function(v, opts){
- opts.embedded = v // indicate embedded XR fragment
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
-
- if( mesh.userData.XRF.href.exec ) return // mesh already initialized
-
- if( mesh.material ) mesh.material = mesh.material.clone() // we need this so we can individually highlight meshes
-
- let click = mesh.userData.XRF.href.exec = (e) => {
-
- let isLocal = v.string[0] == '#'
- let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
-
- xrf
- .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree
- .then( () => {
- const flags = v.string[0] == '#' ? xrf.XRF.PV_OVERRIDE : undefined
- let toFrag = xrf.URI.parse( v.string, xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.METADATA )
- // always keep a trail of last positions before we navigate
- if( !document.location.hash.match(lastPos) ) xrf.navigator.to(`#${lastPos}`)
- xrf.navigator.to(v.string) // let's surf to HREF!
- })
- .catch( console.error )
- }
-
- let selected = mesh.userData.XRF.href.selected = (state) => () => {
- if( mesh.selected == state ) return // nothing changed
- xrf.interactive.objects.map( (o) => {
- let newState = o.name == mesh.name ? state : false
- if( o.material ){
- if( o.material.uniforms ) o.material.uniforms.selected.value = newState
- if( o.material.emissive ) o.material.emissive.r = o.material.emissive.g = o.material.emissive.b = newState ? 2.0 : 1.0
- }
- })
- // update mouse cursor
- if( !renderer.domElement.lastCursor )
- renderer.domElement.lastCursor = renderer.domElement.style.cursor
- renderer.domElement.style.cursor = state ? 'pointer' : renderer.domElement.lastCursor
-
- xrf
- .emit('href',{selected:state,mesh,xrf:v}) // let all listeners agree
- .then( () => mesh.selected = state )
- }
-
- mesh.addEventListener('click', click )
- mesh.addEventListener('mousemove', selected(true) )
- mesh.addEventListener('mouseleave', selected(false) )
-
- // lazy add mesh (because we're inside a recursive traverse)
- setTimeout( (mesh) => {
- xrf.interactive.add(mesh)
- xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
- }, 0, mesh )
-}
-
-/**
- * > above solutions were abducted from [[this|https://i.imgur.com/E3En0gJ.png]] and [[this|https://i.imgur.com/lpnTz3A.png]] survey result
- *
- * !!!Demo
- *
- * <$videojs controls="controls" aspectratio="16:9" preload="auto" poster="" fluid="fluid" class="vjs-big-play-centered">
- *
- * $videojs>
- *
- * > capture of aframe/sandbox
- */
-xrf.frag.pos = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- camera.position.x = v.x
- camera.position.y = v.y
- camera.position.z = v.z
-}
-// spec: https://xrfragment.org/#queries
-
-xrf.frag.q = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- console.log(" └ running query ")
- let qobjs = Object.keys(v.query)
-
- // convience function for other fragments (which apply to the query)
- frag.q.getObjects = () => {
- let objs = []
- scene.traverse( (o) => {
- for ( let name in v.query ) {
- let qobj = v.query[name];
- if( qobj.tag && o.userData.tag && xrf.hasTag(name,o.userData.tag) ) objs.push(o)
- else if( qobj.id && o.name == name ) objs.push(o)
- }
- })
- return objs.filter( (o) => o ) // return and filter out empty
- .map( (o) => {
- if( !o.positionOriginal ) o.positionOriginal = o.position.clone()
- return o
- })
- }
- xrf.frag.q.filter(scene,frag) // spec : https://xrfragment.org/#queries
-}
-
-xrf.frag.q.filter = function(scene,frag){
- // spec: https://xrfragment.org/#queries
- let q = frag.q.query
- scene.traverse( (mesh) => {
- for ( let i in q ) {
- let isMeshId = q[i].id != undefined
- let isMeshProperty = q[i].rules != undefined && q[i].rules.length && !isMeshId
- if( q[i].root && mesh.isSRC ) continue; // ignore nested object for root-items (queryseletor '/foo' e.g.)
- if( isMeshId &&
- (i == mesh.name || xrf.hasTag(i,mesh.userData.tag))) mesh.visible = q[i].id
- if( isMeshProperty && mesh.userData[i] ) mesh.visible = (new xrf.Query(frag.q.string)).testProperty(i,mesh.userData[i])
- }
- })
-}
-xrf.frag.rot = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- console.log(" └ setting camera rotation to "+v.string)
- camera.rotation.set(
- v.x * Math.PI / 180,
- v.y * Math.PI / 180,
- v.z * Math.PI / 180
- )
- camera.updateMatrixWorld()
-}
-// *TODO* use webgl instancing
-
-xrf.frag.src = function(v, opts){
-
- opts.embedded = v // indicate embedded XR fragment
- let { mesh, model, camera, scene, renderer, THREE, hashbus, frag} = opts
-
- let src;
- let url = v.string
- let vfrag = xrfragment.URI.parse(url)
- opts.isPlane = mesh.geometry && mesh.geometry.attributes.uv && mesh.geometry.attributes.uv.count == 4
-
- const addModel = (model,url,frag) => {
- let scene = model.scene
- src = xrf.frag.src.filterScene(scene,{...opts,frag})
- xrf.frag.src.scale( src, opts, url )
- xrf.frag.src.eval( src, opts, url )
- // allow 't'-fragment to setup separate animmixer
- xrf.emit('parseModel', {...opts, scene:src, model})
- enableSourcePortation(src)
- mesh.add(src)
- mesh.traverse( (n) => n.isSRC = n.isXRF = true )
- if( mesh.material ) mesh.material.visible = false
- }
-
- const enableSourcePortation = (src) => {
- if( vfrag.href || v.string[0] == '#' ) return
- let scale = new THREE.Vector3()
- let size = new THREE.Vector3()
- mesh.getWorldScale(scale)
- new THREE.Box3().setFromObject(src).getSize(size)
- const geo = new THREE.SphereGeometry( Math.max(size.x, size.y, size.z) / scale.x, 10, 10 )
- const mat = new THREE.MeshBasicMaterial()
- mat.transparent = true
- mat.roughness = 0.05
- mat.metalness = 1
- mat.opacity = 0
- const cube = new THREE.Mesh( geo, mat )
- console.log("todo: sourceportate")
- //mesh.add(cube)
- }
-
- const externalSRC = (url,frag,src) => {
- fetch(url, { method: 'HEAD' })
- .then( (res) => {
- console.log(`loading src ${url}`)
- let mimetype = res.headers.get('Content-type')
- if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
- //if( url.match(/\.(fbx|stl|obj)$/) ) mimetype =
- opts = { ...opts, src, frag, mimetype }
- return xrf.frag.src.type[ mimetype ] ? xrf.frag.src.type[ mimetype ](url,opts) : xrf.frag.src.type.unknown(url,opts)
- })
- .then( (model) => {
- if( model && model.scene ) addModel(model, url, frag )
- })
- .finally( () => { })
- .catch( console.error )
- }
-
- if( url[0] == "#" ){
- let modelClone = {...model, scene: model.scene.clone()}
- modelClone.scenes = [modelClone.scene]
- modelClone.animations = modelClone.animations.map( (a) => a.clone() )
- addModel(modelClone,url,vfrag) // current file
- }else externalSRC(url,vfrag) // external file
-}
-
-xrf.frag.src.eval = function(scene, opts, url){
- let { mesh, model, camera, renderer, THREE, hashbus} = opts
- if( url ){
- //let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
- //let frag = xrfragment.URI.parse(url)
- //// scale URI XR Fragments (queries) inside src-value
- //for( var i in frag ){
- // hashbus.pub.fragment(i, Object.assign(opts,{frag, model:{scene},scene}))
- //}
- //hashbus.pub( '#', {scene} ) // execute the default projection '#' (if exist)
- //hashbus.pub( url, {scene} ) // and eval URI XR fragments
- }
-}
-
-// scale embedded XR fragments https://xrfragment.org/#scaling%20of%20instanced%20objects
-xrf.frag.src.scale = function(scene, opts, url){
- let { mesh, model, camera, renderer, THREE} = opts
-
- let restrictTo3DBoundingBox = mesh.geometry
- if( restrictTo3DBoundingBox ){
- // spec 3 of https://xrfragment.org/#src
- // spec 1 of https://xrfragment.org/#scaling%20of%20instanced%20objects
- // normalize instanced objectsize to boundingbox
- let sizeFrom = new THREE.Vector3()
- let sizeTo = new THREE.Vector3()
-
- let empty = new THREE.Object3D()
-
-// *TODO* exclude invisible objects from boundingbox size-detection
-//
-// THREE.Box3.prototype.expandByObject = (function(expandByObject){
-// return function(object,precise){
-// return expandByObject.call(this, object.visible ? object : empty, precise)
-// }
-// })(THREE.Box3.prototype.expandByObject)
-
- new THREE.Box3().setFromObject(mesh).getSize(sizeTo)
- new THREE.Box3().setFromObject(scene).getSize(sizeFrom)
- let ratio = sizeFrom.divide(sizeTo)
- scene.scale.multiplyScalar( 1.0 / Math.max(ratio.x, ratio.y, ratio.z));
- // let factor = getMax(sizeTo) < getMax(sizeFrom) ? getMax(sizeTo) / getMax(sizeFrom) : getMax(sizeFrom) / getMax(sizeTo)
- // scene.scale.multiplyScalar( factor )
- }else{
- // spec 4 of https://xrfragment.org/#src
- // spec 2 of https://xrfragment.org/#scaling%20of%20instanced%20objects
- scene.scale.multiply( mesh.scale )
- }
- scene.isXRF = model.scene.isSRC = true
-}
-
-xrf.frag.src.filterScene = (scene,opts) => {
- let { mesh, model, camera, renderer, THREE, hashbus, frag} = opts
- let obj, src
- // cherrypicking of object(s)
- if( !frag.q ){
- src = new THREE.Group()
- if( Object.keys(frag).length > 0 ){
- for( var i in frag ){
- if( scene.getObjectByName(i) ){
- src.add( obj = scene.getObjectByName(i).clone(true) )
- }
- hashbus.pub.fragment(i, Object.assign(opts,{frag, model,scene}))
- }
- }
- if( src.children.length == 1 ) obj.position.set(0,0,0);
- }
-
- // filtering of objects using query
- if( frag.q ){
- src = scene
- xrf.frag.q.filter(src,frag)
- }
- src.traverse( (m) => {
- if( m.userData && (m.userData.src || m.userData.href) ) return ; // prevent infinite recursion
- hashbus.pub.mesh(m,{scene,recursive:true}) // cool idea: recursion-depth based distance between face & src
- })
- return src
-}
-
-/*
- * replace the src-mesh with the contents of the src
- */
-
-xrf.frag.src.type = {}
-
-/*
- * mimetype: unknown
- */
-
-xrf.frag.src.type['unknown'] = function( url, opts ){
- return new Promise( (resolve,reject) => {
- reject(`${url} mimetype '${opts.mimetype}' not found or supported (yet)`)
- })
-}
-xrf.frag.t = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- if( !model.mixer ) return
- if( !model.animations || model.animations[0] == undefined ) return console.warn('no animation in scene')
-
- xrf.mixers.map ( (mixer) => {
- mixer.t = v
-
- // update speed
- mixer.timeScale = mixer.loop.speed = v.x
- mixer.loop.speedAbs = Math.abs(v.x)
-
- if( v.y != undefined || v.z != undefined ) mixer.updateLoop( v )
-
- // play animations
- mixer.play( v )
- })
-}
-
-xrf.frag.t.default = {
- x:0, // (play from) offset (in seconds)
- y:0 // optional: (stop at) offset (in seconds)
-}
-
-// setup animation mixer for global scene & src scenes
-xrf.addEventListener('parseModel', (opts) => {
- let {model} = opts
- let mixer = model.mixer = new xrf.THREE.AnimationMixer(model.scene)
- mixer.model = model
- mixer.loop = {}
- mixer.i = xrf.mixers.length
-
- model.animations.map( (anim) => {
- anim.action = mixer.clipAction( anim, model.scene )
- })
-
- mixer.checkZombies = (animations) => {
- if( mixer.zombieCheck ) return // fire only once
- animations.map( (anim) => {
- // collect zombie animations and warn user
- let zombies = anim.tracks.map( (t) => {
- let name = t.name.replace(/\..*/,'')
- return !model.scene.getObjectByName(name) ? {anim:anim.name,obj:t.name} : undefined
- })
- if( zombies.length > 0 ){
- zombies
- .filter( (z) => z ) // filter out undefined
- .map( (z) => console.warn(`gltf: object '${z.obj}' not found (anim: '${z.anim}'`) )
- console.warn(`TIP: remove dots in objectnames in blender (which adds dots when duplicating)`)
- }
- })
- mixer.zombieCheck = true
- }
-
- mixer.play = (t) => {
- mixer.isPlaying = t.x != 0
- mixer.updateLoop(t)
- xrf.emit( mixer.isPlaying === false ? 'stop' : 'play',{isPlaying: mixer.isPlaying})
- }
-
- mixer.stop = () => {
- mixer.play(false)
- }
-
- mixer.updateLoop = (t) => {
- mixer.loop.timeStart = t.y != undefined ? t.y : mixer.loop.timeStart
- mixer.loop.timeStop = t.z != undefined ? t.z : mixer.loop.timeStop
- mixer.model.animations.map( (anim) => {
- if( mixer.loop.timeStart != undefined ){
- //if( anim.action ) delete anim.action
- //anim.action = mixer.clipAction( anim )
- anim.action.time = mixer.loop.timeStart
- anim.action.setLoop( THREE.LoopOnce, )
- anim.action.timeScale = mixer.timeScale
- anim.action.enabled = true
- if( t.x != 0 ) anim.action.play()
- }
- })
- mixer.setTime(mixer.loop.timeStart)
- mixer.time = Math.abs( mixer.loop.timeStart )
- mixer.update(0)
- mixer.checkZombies( model.animations)
- }
-
- // update loop when needed
- if( !mixer.update.patched ){
- let update = mixer.update
- mixer.update = function(time){
- mixer.time = Math.abs(mixer.time)
- if( time == 0 ) return update.call(this,time)
-
- // loop jump
- if( mixer.loop.speed > 0.0 && mixer.time > mixer.loop.timeStop ){
- setTimeout( (time,anims) => mixer.updateLoop(time), 0, mixer.loop.timeStart ) // prevent recursion
- }
- return update.call( this, time )
- }
- mixer.update.patched = true
- }
-
- // calculate total duration/frame based on longest animation
- mixer.duration = 0
- if( model.animations.length ){
- model.animations.map( (a) => mixer.duration = ( a.duration > mixer.duration ) ? a.duration : mixer.duration )
- }
-
- xrf.mixers.push(mixer)
-})
-
-if( document.location.hash.match(/t=/) ){
- let url = document.location.href
- let playAfterUserGesture = () => {
- xrf.hashbus.pub(url) // re-post t fragment on the hashbus again
- window.removeEventListener('click',playAfterUserGesture)
- window.removeEventListener('touchstart',playAfterUserGesture)
- }
- window.addEventListener('click', playAfterUserGesture )
- window.addEventListener('touchstart', playAfterUserGesture )
-}
-
-xrf.addEventListener('render', (opts) => {
- let model = xrf.model
- let {time} = opts
- if( !model ) return
- if( xrf.mixers.length ){
- xrf.mixers.map( (m) => m.isPlaying ? m.update( time ) : false )
-
- // update active camera in case selected by dynamicKey in URI
- if( xrf.model.camera && model.mixer.isPlaying ){
-
- let cam = xrf.camera.getCam()
- // cam.fov = model.cameras[0].fov (why is blender not exporting radians?)
- cam.far = model.cameras[0].far
- cam.near = model.cameras[0].near
-
- let rig = xrf.camera
- rig.position.copy( model.cameras[0].position )
- rig.position.y -= rig.offsetY // VR/AR compensate camera rig
- //rig.rotation.copy( model.cameras[0].rotation )
-
- rig.updateProjectionMatrix()
- }
- }
-})
xrf.addEventListener('dynamicKey', (opts) => {
- // select active camera if any
- let {id,match,v} = opts
- console.dir(opts)
- match.map( (w) => {
- w.nodes.map( (node) => {
- if( node.isCamera ){
- console.log("setting camera to "+node.name)
- xrf.model.camera = node
+ let {scene,id,match,v} = opts
+ if( v.filter ){
+ let frags = {}
+ frags[ v.filter.key ] = v
+ xrf.filter.scene({frag:frags,scene})
+ }
+})
+
+// spec: https://xrfragment.org/#filters
+xrf.filter = function(query, cb){
+ let result = []
+ if( !query ) return result
+ if( query[0] != '#' ) query = '#'+query
+ // *TODO* jquery like utility func
+ return result
+}
+
+xrf.filter.scene = function(opts){
+ let {scene,frag} = opts
+
+ xrf.filter
+ .sort(frag) // get (sorted) filters from XR Fragments
+ .process(frag,scene,opts) // show/hide things
+
+ scene.visible = true // always enable scene
+
+ return scene
+}
+
+xrf.filter.sort = function(frag){
+ // get all filters from XR Fragments
+ frag.filters = Object.values(frag)
+ .filter( (v) => v.filter ? v : null )
+ .sort( (a,b) => a.index > b.index )
+ return xrf.filter
+}
+
+xrf.filter.process = function(frag,scene,opts){
+ const cleanupKey = (k) => k.replace(/[-\*\/]/g,'')
+ let firstFilter = frag.filters.length ? frag.filters[0].filter.get() : false
+ const hasName = (m,name,filter) => m.name == name
+ const hasNameOrTag = (m,name_or_tag,filter) => hasName(m,name_or_tag) ||
+ String(m.userData['tag']).match( new RegExp("(^| )"+name_or_tag) )
+ // utility functions
+ const getOrCloneMaterial = (o) => {
+ if( o.material ){
+ if( o.material.isXRF ) return o.material
+ o.material = o.material.clone()
+ o.material.isXRF = true
+ return o.material
+ }
+ return {}
+ }
+ const setVisible = (n,visible,filter,processed) => {
+ if( processed && processed[n.uuid] ) return
+ getOrCloneMaterial(n).visible = visible
+ if( filter.deep ) n.traverse( (m) => getOrCloneMaterial(m).visible = visible )
+ if( processed ) processed[n.uuid] == true
+ }
+
+ // spec 2: https://xrfragment.org/doc/RFC_XR_Macros.html#embedding-xr-content-using-src
+ // reparent scene based on objectname in case it matches a (non-negating) selector
+ if( opts.reparent && firstFilter && !firstFilter.value && firstFilter.show === true ){
+ let obj
+ frag.target = firstFilter
+ scene.traverse( (n) => hasName(n, firstFilter.key,firstFilter) && (obj = n) )
+ if(obj){
+ while( scene.children.length > 0 ) scene.children[0].removeFromParent()
+ obj.position.set(0,0,0)
+ scene.add( obj )
+ }
+ }
+
+ // then show/hide things based on secondary selectors
+ // we don't use the XRWG (everything) because we process only the given (sub)scene
+ frag.filters.map( (v) => {
+ const filter = v.filter.get()
+ const name_or_tag = cleanupKey(v.fragment)
+ let processed = {}
+ let extembeds = {}
+
+ // hide external objects temporarely
+ scene.traverse( (m) => {
+ if( m.isSRCExternal ){
+ m.traverse( (n) => (extembeds[ n.uuid ] = m) && (n.visible = false) )
}
})
+
+ scene.traverseVisible( (m) => {
+ // filter on value(expression) #foo=>3 e.g. *TODO* do this in XRWG
+ if( filter.value && m.userData[filter.key] ){
+ const visible = v.filter.testProperty(filter.key, m.userData[filter.key], filter.show === false )
+ setVisible(m,visible,filter,processed)
+ return
+ }
+ if( hasNameOrTag(m,name_or_tag,filter ) ){
+ setVisible(m,filter.show,filter)
+ }
+ })
+
+ // show external objects again
+ for ( let i in extembeds ) extembeds[i].visible = true
})
-})
+
+ return xrf.filter
+}
+
xrf.frag.defaultPredefinedViews = (opts) => {
let {scene,model} = opts;
scene.traverse( (n) => {
@@ -1711,12 +1802,10 @@ xrf.addEventListener('dynamicKey', (opts) => {
if( !scene ) return
let remove = []
// erase previous lines
- xrf.focusLine.lines.map( (line) => line.parent.remove(line) )
+ xrf.focusLine.lines.map( (line) => line.parent && (line.parent.remove(line)) )
xrf.focusLine.points = []
xrf.focusLine.lines = []
- //scene.traverse( (n) => n.selection ? remove.push(n) : false )
- //remove.map( (n) => scene.remove(n.selection) )
// drawlines
match.map( (w) => {
w.nodes.map( (mesh) => xrf.drawLineToMesh({ ...opts, mesh}) )
@@ -1725,6 +1814,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
xrf.drawLineToMesh = (opts) => {
let {scene,mesh,frag,id} = opts
+ const THREE = xrf.THREE
let oldSelection
// Selection of Interest if predefined_view matches object name
if( mesh.visible && mesh.material){
@@ -1743,8 +1833,9 @@ xrf.drawLineToMesh = (opts) => {
return center;
}
- xrf.camera.getCam().updateMatrixWorld(true); // always keeps me diving into the docs :]
- xrf.camera.getCam().getWorldPosition(from)
+ let cam = xrf.camera.getCam ? xrf.camera.getCam() : xrf.camera // *FIXME* camerarig/rig are conflicting
+ cam.updateMatrixWorld(true); // always keeps me diving into the docs :]
+ cam.getWorldPosition(from)
from.y = 0.5 // originate from the heart chakra! :p
const points = [from, getCenterPoint(mesh) ]
const geometry = new THREE.BufferGeometry().setFromPoints( points );
@@ -1779,14 +1870,17 @@ xrf.addEventListener('render', (opts) => {
*/
let loadAudio = (mimetype) => function(url,opts){
- let {mesh,src,camera} = opts
+ let {mesh,src,camera,THREE} = opts
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
let frag = xrf.URI.parse( url )
+ return
+
/* WebAudio: setup context via THREEjs */
if( !camera.listener ){
camera.listener = new THREE.AudioListener();
- camera.getCam().add( camera.listener );
+ // *FIXME* camera vs camerarig conflict
+ (camera.getCam ? camera.getCam() : camera).add( camera.listener );
}
let isPositionalAudio = !(mesh.position.x == 0 && mesh.position.y == 0 && mesh.position.z == 0)
@@ -1825,7 +1919,6 @@ let loadAudio = (mimetype) => function(url,opts){
if( t.z > 0 ) sound.setLoopEnd( loopEnd )
if( t.y != undefined ){
- console.dir({loopStart,t})
sound.setLoopStart( loopStart )
sound.offset = loopStart
}
@@ -1851,7 +1944,7 @@ audioMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadAudio(mim
// listen to t XR fragment changes
xrf.addEventListener('t', (opts) => {
let t = opts.frag.t
- xrf.scene.traverse( (n) => n.audio && n.audio.playXRF ? n.audio.playXRF(t) : false )
+ xrf.scene.traverse( (n) => n.audio && n.audio.playXRF && (n.audio.playXRF(t)) )
})
/*
* mimetype: model/gltf+json
@@ -1883,7 +1976,7 @@ xrf.frag.src.type['gltf'] = function( url, opts ){
*/
xrf.frag.src.type['image/png'] = function(url,opts){
- let {mesh} = opts
+ let {mesh,THREE} = opts
let restrictTo3DBoundingBox = mesh.geometry
let renderEquirect = (texture) => {
@@ -1951,7 +2044,7 @@ xrf.frag.src.type['image/png'] = function(url,opts){
}
}
//const geometry = new THREE.BoxGeometry();
- mesh.material = new THREE.MeshBasicMaterial({
+ mesh.material = new xrf.THREE.MeshBasicMaterial({
map: texture,
transparent: url.match(/(png|gif)/) ? true : false,
side: THREE.DoubleSide,
@@ -1979,10 +2072,197 @@ xrf.frag.src.type['image/png'] = function(url,opts){
xrf.frag.src.type['image/gif'] = xrf.frag.src.type['image/png']
xrf.frag.src.type['image/jpeg'] = xrf.frag.src.type['image/png']
+// spec 8: https://xrfragment.org/doc/RFC_XR_Macros.html#embedding-xr-content-using-src
+
+xrf.portalNonEuclidian = function(opts){
+ let { frag, mesh, model, camera, scene, renderer} = opts
+
+ mesh.portal = {
+ pos: mesh.position.clone(),
+ posWorld: new xrf.THREE.Vector3(),
+ posWorldCamera: new xrf.THREE.Vector3(),
+ stencilRef: xrf.portalNonEuclidian.stencilRef,
+ needUpdate: false,
+ stencilObject: false,
+ cameraDirection: new THREE.Vector3(),
+ cameraPosition: new THREE.Vector3(),
+ raycaster: new THREE.Raycaster(),
+ isLocal: opts.isLocal,
+ isLens: false
+ }
+
+ // allow objects to flip between original and stencil position (which puts them behind stencilplane)
+ const addStencilFeature = (n) => {
+ if( n.stencil ) return n // run once
+ n.stencil = ( (pos,scale) => (sRef,newPos, newScale) => {
+ if( !mesh.portal.isLens ){
+ n.position.copy( sRef == 0 ? pos : newPos )
+ if( sRef > 0 ) n.scale.multiply( newScale )
+ else n.scale.copy( scale )
+ n.updateMatrixWorld(true)
+ }
+ xrf.portalNonEuclidian.selectStencil(n, sRef )
+ }
+ )( n.position.clone(), n.scale.clone() )
+ return n
+ }
+
+ this.setupStencilObjects = (scene,opts) => {
+ // collect related objects to render inside stencilplane
+ let stencilObject = scene
+ if( opts.srcFrag.target ){
+ stencilObject = scene.getObjectByName( opts.srcFrag.target.key )
+ // spec: if src-object is child of portal (then portal is lens, and should include all children )
+ mesh.traverse( (n) => n.name == opts.srcFrag.target.key && (stencilObject = n) && (mesh.portal.isLens = true) )
+ }
+
+ if( !stencilObject ) return console.warn(`no objects were found (src:${mesh.userData.src}) for (portal)object name '${mesh.name}'`)
+ mesh.portal.stencilObject = stencilObject
+
+ // spec: if src points to child, act as lens
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
+
+ let stencilObjects = [stencilObject]
+ stencilObjects = stencilObjects
+ .filter( (n) => !n.portal ) // filter out (self)references to portals (prevent recursion)
+ .map(addStencilFeature)
+
+ //// add missing lights to make sure things get lit properly
+ xrf.scene.traverse( (n) => n.isLight &&
+ !stencilObjects.find( (o) => o.uuid == n.uuid ) &&
+ stencilObjects.push(n)
+ )
+
+ // put it into a scene (without .add() because it reparents objects) so we can render it separately
+ mesh.portal.stencilObjects = new xrf.THREE.Scene()
+ mesh.portal.stencilObjects.children = stencilObjects
+
+ xrf.portalNonEuclidian.stencilRef += 1 // each portal has unique stencil id
+ console.log(`enabling portal for object '${mesh.name}' (stencilRef:${mesh.portal.stencilRef})`)
+
+ // clone so it won't be affected by other fragments
+ setTimeout( (mesh) => {
+ if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
+ }, 0, mesh )
+
+
+ // spec: increase height of portal(object) floor so it won't get rendererd under the current floor
+ mesh.portal.posWorld.y +=0.1
+
+ return this
+ }
+
+ // enable the stencil-material of the stencil objects to prevent stackoverflow (portal in portal rendering)
+ const showPortal = (n,show) => {
+ if( n.portal ) n.visible = show
+ return true
+ }
+
+ this.setupListeners = () => {
+
+ mesh.onAfterRender = function(renderer, scene, camera, geometry, material, group ){
+ mesh.portal.needUpdate = true
+ }
+
+ xrf.addEventListener('renderPost', (opts) => {
+ let {scene,camera,time,render,renderer} = opts
+
+ if( mesh.portal && mesh.portal.stencilObjects ){
+ let stencilRef = mesh.portal.stencilRef
+ let newPos = mesh.portal.posWorld
+ let stencilObject = mesh.portal.stencilObject
+ let newScale = mesh.scale
+ let cameraDirection = mesh.portal.cameraDirection
+ let cameraPosition = mesh.portal.cameraPosition
+ let raycaster = mesh.portal.raycaster
+ let cam = xrf.camera.getCam ? xrf.camera.getCam() : camera
+ cam.getWorldPosition(cameraPosition)
+ if( cameraPosition.distanceTo(newPos) > 20.0 ) return // dont render far portals
+ cam.getWorldDirection(cameraDirection)
+
+ // init
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = true
+ mesh.portal.stencilObjects.traverse( (n) => showPortal(n,false) && n.stencil && n.stencil(stencilRef,newPos,newScale) )
+ renderer.autoClear = false
+ renderer.autoClearDepth = false
+ renderer.autoClearColor = false
+ renderer.autoClearStencil = false
+ // render
+ render( mesh.portal.stencilObjects, camera )
+ // de-init
+ renderer.autoClear = true
+ renderer.autoClearDepth = true
+ renderer.autoClearColor = true
+ renderer.autoClearStencil = true
+ mesh.portal.stencilObjects.traverse( (n) => showPortal(n,true) && n.stencil && (n.stencil(0)) )
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
+
+
+ // trigger href upon camera collide
+ if( mesh.userData.XRF.href ){
+ raycaster.far = 0.35
+ raycaster.set(cameraPosition, cameraDirection )
+ intersects = raycaster.intersectObjects([mesh], false)
+ if (intersects.length > 0 && !mesh.portal.teleporting ){
+ mesh.portal.teleporting = true
+ mesh.userData.XRF.href.exec({nocommit:true})
+ setTimeout( () => mesh.portal.teleporting = false, 500) // dont flip back and forth
+ }
+ }
+ }
+ mesh.portal.needUpdate = false
+ })
+ return this
+ }
+
+ // turn mesh into stencilplane
+ xrf
+ .portalNonEuclidian
+ .setMaterial(mesh)
+ .getWorldPosition(mesh.portal.posWorld)
+
+ this
+ .setupListeners()
+ .setupStencilObjects(scene,opts)
+
+}
+
+xrf.portalNonEuclidian.selectStencil = (n, stencilRef, nested) => {
+ if( n.material ){
+ n.material.stencilRef = stencilRef
+ n.material.stencilWrite = stencilRef > 0
+ n.material.stencilFunc = xrf.THREE.EqualStencilFunc;
+ }
+ if( n.children && !nested ) n.traverse( (m) => !m.portal && (xrf.portalNonEuclidian.selectStencil(m,stencilRef,true)) )
+}
+
+xrf.portalNonEuclidian.setMaterial = function(mesh){
+ mesh.material = new xrf.THREE.MeshBasicMaterial({ color: 'orange' });
+ mesh.material.depthWrite = false;
+ mesh.material.colorWrite = false;
+ mesh.material.stencilWrite = true;
+ mesh.material.stencilRef = xrf.portalNonEuclidian.stencilRef;
+ // mesh.renderOrder = 0;//xrf.portalNonEuclidian.stencilRef;
+ mesh.material.stencilFunc = xrf.THREE.AlwaysStencilFunc;
+ mesh.material.stencilZPass = xrf.THREE.ReplaceStencilOp;
+ mesh.material.stencilZFail = xrf.THREE.ReplaceStencilOp;
+ //n.material.depthFunc = stencilRef > 0 ? xrf.THREE.AlwaysDepth : xrf.THREE.LessEqualDepth
+ //mesh.material.depthTest = false;
+ return mesh
+}
+
+xrf.addEventListener('parseModel',(opts) => {
+ const scene = opts.model.scene
+ // scene.traverse( (n) => n.renderOrder = 10 ) // rendering everything *after* the stencil buffers
+})
+
+
+xrf.portalNonEuclidian.stencilRef = 1
let loadVideo = (mimetype) => function(url,opts){
let {mesh,src,camera} = opts
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
+ const THREE = xrf.THREE
let frag = xrf.URI.parse( url )
let video = mesh.video = document.createElement('video')
@@ -1994,9 +2274,17 @@ let loadVideo = (mimetype) => function(url,opts){
let mat = new xrf.THREE.MeshBasicMaterial()
mat.map = texture
mesh.material = mat
+ // set range
+ //video.addEventListener('timeupdate', function timeupdate() {
+ // if (frag.t && video.currentTime < frag.t.y || video.currentTime >= frag.t.z ) {
+ // video.currentTime = frag.t.y
+ // }
+ //},false)
})
+
video.src = url
video.playXRF = (t) => {
+ video.t = t
if( t.x == 0 ) video.pause()
else{
video.playbackRate = Math.abs( t.x ) // html5 video does not support reverseplay :/
@@ -2015,13 +2303,20 @@ videoMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadVideo(mim
// listen to t XR fragment changes
xrf.addEventListener('t', (opts) => {
let t = opts.frag.t
- xrf.scene.traverse( (n) => n.video ? n.video.playXRF(t) : false )
+ xrf.scene.traverse( (n) => n.video && (n.video.playXRF(t)) )
})
window.AFRAME.registerComponent('xrf', {
schema: {
},
init: function () {
if( !AFRAME.XRF ){
+
+ // start with black
+ document.querySelector('[camera]').setAttribute('xrf-fade','')
+ AFRAME.fade = document.querySelector('[camera]').components['xrf-fade']
+
+ if( document.location.host.match(/localhost/) ) document.querySelector('a-scene').setAttribute("stats",'')
+
document.querySelector('a-scene').addEventListener('loaded', () => {
// enable XR fragments
@@ -2031,7 +2326,6 @@ window.AFRAME.registerComponent('xrf', {
camera: aScene.camera,
scene: aScene.object3D,
renderer: aScene.renderer,
- debug: true,
loaders: {
gltf: THREE.GLTFLoader, // which 3D assets (exts) to check for XR fragments?
glb: THREE.GLTFLoader
@@ -2039,17 +2333,52 @@ window.AFRAME.registerComponent('xrf', {
})
if( !XRF.camera ) throw 'xrfragment: no camera detected, please declare ABOVE entities with xrf-attributes'
+ xrf.addEventListener('navigateLoaded', () => {
+ setTimeout( () => AFRAME.fade.out(),500)
+
+ // *TODO* this does not really belong here perhaps
+ let blinkControls = document.querySelector('[blink-controls]')
+ if( blinkControls ){
+ blinkControls = blinkControls.components['blink-controls']
+ blinkControls.defaultCollisionMeshes = xrf.getCollisionMeshes()
+ blinkControls.update()
+ }
+ })
+
+ xrf.addEventListener('href', (opts) => {
+ if( opts.click){
+ let p = opts.promise()
+ let url = opts.xrf.string
+ let isLocal = url.match(/^#/)
+ let hasPos = url.match(/pos=/)
+ if( isLocal && hasPos ){
+ // local teleports only
+ let fastFadeMs = 200
+ AFRAME.fade.in(fastFadeMs)
+ setTimeout( () => {
+ p.resolve()
+ AFRAME.fade.out(fastFadeMs)
+ }, fastFadeMs)
+ }else if( !isLocal ){
+ AFRAME.fade.in()
+ setTimeout( () => {
+ p.resolve()
+ setTimeout( () => AFRAME.fade.out(), 1000 ) // allow one second to load textures e.g.
+ }, AFRAME.fade.data.fadetime )
+ }else p.resolve()
+ }
+ })
+
// in order to set the rotation programmatically
// we need to disable look-controls
- xrf.rot = (xrf,v,opts) => {
- let {frag,renderer} = opts;
- if( frag.q ) return // camera was not targeted for rotation
- let look = document.querySelector('[look-controls]')
- if( look ) look.removeAttribute("look-controls")
- // *TODO* make look-controls compatible, because simply
- // adding the look-controls will revert to the old rotation (cached somehow?)
- //setTimeout( () => look.setAttribute("look-controls",""), 100 )
- }
+ //xrf.rot = (xrf,v,opts) => {
+ // let {frag,renderer} = opts;
+ // //let look = document.querySelector('[look-controls]')
+ // //if( look ) look.removeAttribute("look-controls")
+ // // *TODO* make look-controls compatible, because simply
+ // // adding the look-controls will revert to the old rotation (cached somehow?)
+ // //setTimeout( () => look.setAttribute("look-controls",""), 100 )
+ //}
// convert href's to a-entity's so AFRAME
// raycaster can find & execute it
@@ -2059,16 +2388,17 @@ window.AFRAME.registerComponent('xrf', {
el.setAttribute("xrf-get",mesh.name ) // turn into AFRAME entity
el.setAttribute("class","ray") // expose to raycaster
el.setAttribute("pressable", '') // detect hand-controller click
- // add click
+ // respond to cursor via laser-controls (https://aframe.io/docs/1.4.0/components/laser-controls.html)
el.addEventListener("click", clickHandler )
- //el.addEventListener("pressedstarted", clickHandler )
+ el.addEventListener("mouseenter", mesh.userData.XRF.href.selected(true) )
+ el.addEventListener("mouseleave", mesh.userData.XRF.href.selected(false) )
+ el.addEventListener("pressedstarted", clickHandler )
$('a-scene').appendChild(el)
}
xrf.addEventListener('interactionReady', AFRAME.XRF.clickableMeshToEntity )
// cleanup xrf-get objects when resetting scene
xrf.addEventListener('reset', (opts) => {
- console.log("aframe reset")
let els = [...document.querySelectorAll('[xrf-get]')]
els.map( (el) => document.querySelector('a-scene').removeChild(el) )
})
@@ -2210,6 +2540,33 @@ window.AFRAME.registerComponent('xrf-button', {
});
}
});
+AFRAME.registerComponent('xrf-fade', {
+ schema:{
+ fadetime:{type:"number", default: 1000},
+ color:{type:"color", default:"black"},
+ opacity:{type:"float",default:1.0}
+ },
+ init: function(){
+ let fb = this.fb = document.createElement("a-box")
+ fb.setAttribute("scale", "1 1 1")
+ fb.setAttribute("material", `color: ${this.data.color}; transparent: true; side: back; shader: flat; opacity:1`)
+ this.el.appendChild(fb)
+ },
+ out: function(fadetime){
+ if( fadetime != undefined ) this.data.fadetime = fadetime
+ if( this.data.opacity == 0 ) return
+ this.data.opacity = 0.0
+ this.fb.setAttribute("animation", `property: components.material.material.opacity; dur: ${this.data.fadetime}; from: 1; to: ${this.data.opacity}`)
+ setTimeout( () => this.fb.object3D.visible = false, this.data.fadetime )
+ },
+ "in": function(fadetime){
+ if( fadetime != undefined ) this.data.fadetime = fadetime
+ if( this.data.opacity == 1 ) return
+ this.data.opacity = 1.0
+ this.fb.object3D.visible = true
+ this.fb.setAttribute("animation", `property: components.material.material.opacity; dur: ${this.data.fadetime}; from: 0; to: ${this.data.opacity}`)
+ }
+});
// gaze click on mobile VR
AFRAME.registerComponent('xrf-gaze',{
diff --git a/dist/xrfragment.js b/dist/xrfragment.js
index 71b2cb5..0299943 100644
--- a/dist/xrfragment.js
+++ b/dist/xrfragment.js
@@ -72,6 +72,20 @@ Reflect.deleteField = function(o,field) {
delete(o[field]);
return true;
};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
@@ -209,83 +223,22 @@ js_Boot.__string_rec = function(o,s) {
return String(o);
}
};
-var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
-xrfragment_Parser.__name__ = true;
-xrfragment_Parser.parse = function(key,value,store) {
- var Frag_h = Object.create(null);
- Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
- Frag_h["prio"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_INT;
- Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
- Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
- Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["q"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["scale"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["mov"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["show"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.METADATA;
- Frag_h["env"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["gravity"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["physics"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["fov"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["clip"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["fog"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["bg"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
- var isPVDynamic = value.length == 0 && key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
- var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
- if(isPVDynamic) {
- var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR);
- v.validate(key);
- store[key] = v;
- return true;
- }
- var v = new xrfragment_XRF(key,Frag_h[key]);
- if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
- if(!v.validate(value)) {
- console.log("src/xrfragment/Parser.hx:80:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
- return false;
- }
- store[key] = v;
- if(xrfragment_Parser.debug) {
- console.log("src/xrfragment/Parser.hx:84:","✔ " + key + ": " + v.string);
- }
- } else {
- if(typeof(value) == "string") {
- v.guessType(v,value);
- }
- v.noXRF = true;
- store[key] = v;
- }
- return true;
-};
-var xrfragment_Query = $hx_exports["xrfragment"]["Query"] = function(str) {
- this.isNumber = new EReg("^[0-9\\.]+$","");
- this.isRoot = new EReg("^[-]?/","");
- this.isExclude = new EReg("^-","");
- this.isProp = new EReg("^.*:[><=!]?","");
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
this.q = { };
this.str = "";
if(str != null) {
this.parse(str);
}
};
-xrfragment_Query.__name__ = true;
-xrfragment_Query.prototype = {
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
toObject: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,get: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,parse: function(str) {
- var _gthis = this;
var token = str.split(" ");
var q = { };
var process = function(str,prefix) {
@@ -293,59 +246,42 @@ xrfragment_Query.prototype = {
prefix = "";
}
str = StringTools.trim(str);
- var k = str.split(":")[0];
- var v = str.split(":")[1];
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
var filter = { };
if(q[prefix + k]) {
filter = q[prefix + k];
}
- filter["rules"] = filter["rules"] != null ? filter["rules"] : [];
- if(_gthis.isProp.match(str)) {
+ if(xrfragment_XRF.isProp.match(str)) {
var oper = "";
- if(str.indexOf("*") != -1) {
- oper = "*";
- }
if(str.indexOf(">") != -1) {
oper = ">";
}
if(str.indexOf("<") != -1) {
oper = "<";
}
- if(str.indexOf(">=") != -1) {
- oper = ">=";
- }
- if(str.indexOf("<=") != -1) {
- oper = "<=";
- }
- if(_gthis.isExclude.match(k)) {
- oper = "!=";
+ if(xrfragment_XRF.isExclude.match(k)) {
k = HxOverrides.substr(k,1,null);
- } else {
- v = HxOverrides.substr(v,oper.length,null);
}
+ v = HxOverrides.substr(v,oper.length,null);
if(oper.length == 0) {
oper = "=";
}
var rule = { };
- if(_gthis.isNumber.match(v)) {
+ if(xrfragment_XRF.isNumber.match(v)) {
rule[oper] = parseFloat(v);
} else {
rule[oper] = v;
}
- filter["rules"].push(rule);
- q[k] = filter;
- return;
- } else {
- filter["id"] = _gthis.isExclude.match(str) ? false : true;
- filter["root"] = _gthis.isRoot.match(str);
- if(_gthis.isExclude.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- if(_gthis.isRoot.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- q[str] = filter;
+ q["expr"] = rule;
}
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
};
var _g = 0;
var _g1 = token.length;
@@ -394,49 +330,75 @@ xrfragment_Query.prototype = {
return v[property];
}
}
- var _g = 0;
- var _g1 = Reflect.fields(this.q);
- while(_g < _g1.length) {
- var k = _g1[_g];
- ++_g;
- var filter = Reflect.field(this.q,k);
- if(filter.rules == null) {
- continue;
- }
- var rules = filter.rules;
- var _g2 = 0;
- while(_g2 < rules.length) {
- var rule = rules[_g2];
- ++_g2;
- if(exclude) {
- if(Reflect.field(rule,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(rule,"!="))) && exclude) {
- ++qualify;
- }
- } else {
- if(Reflect.field(rule,"*") != null && testprop(parseFloat(value) != null)) {
- ++qualify;
- }
- if(Reflect.field(rule,">") != null && testprop(parseFloat(value) > parseFloat(Reflect.field(rule,">")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<") != null && testprop(parseFloat(value) < parseFloat(Reflect.field(rule,"<")))) {
- ++qualify;
- }
- if(Reflect.field(rule,">=") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(rule,">=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<=") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(rule,"<=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"=") != null && (testprop(value == Reflect.field(rule,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(rule,"="))))) {
- ++qualify;
- }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
}
}
}
return qualify > 0;
}
};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
@@ -458,7 +420,7 @@ xrfragment_URI.parse = function(url,filter) {
var s = regexPlus.split(splitByEqual[1]).join(" ");
value = decodeURIComponent(s.split("+").join(" "));
}
- var ok = xrfragment_Parser.parse(key,value,store);
+ var ok = xrfragment_Parser.parse(key,value,store,i);
}
if(filter != null && filter != 0) {
var _g = 0;
@@ -474,9 +436,10 @@ xrfragment_URI.parse = function(url,filter) {
}
return store;
};
-var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) {
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
this.fragment = _fragment;
this.flags = _flags;
+ this.index = _index;
};
xrfragment_XRF.__name__ = true;
xrfragment_XRF.set = function(flag,flags) {
@@ -495,45 +458,50 @@ xrfragment_XRF.prototype = {
}
,validate: function(value) {
this.guessType(this,value);
- if(this.fragment == "q") {
- this.query = new xrfragment_Query(value).get();
- }
var ok = true;
if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
ok = false;
}
- if(!this.is(xrfragment_XRF.T_VECTOR2) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
ok = false;
}
return ok;
}
,guessType: function(v,str) {
v.string = str;
- if(str.split(",").length > 1) {
- var xyzw = str.split(",");
- if(xyzw.length > 0) {
- v.x = parseFloat(xyzw[0]);
- }
- if(xyzw.length > 1) {
- v.y = parseFloat(xyzw[1]);
- }
- if(xyzw.length > 2) {
- v.z = parseFloat(xyzw[2]);
- }
- if(xyzw.length > 3) {
- v.w = parseFloat(xyzw[3]);
- }
+ if(typeof(str) != "string") {
+ return;
}
- if(xrfragment_XRF.isColor.match(str)) {
- v.color = str;
- }
- if(xrfragment_XRF.isFloat.match(str)) {
- v.x = parseFloat(str);
- v.float = v.x;
- }
- if(xrfragment_XRF.isInt.match(str)) {
- v.int = Std.parseInt(str);
- v.x = v.int;
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
}
}
};
@@ -571,5 +539,10 @@ xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
})({});
var xrfragment = $hx_exports["xrfragment"];
diff --git a/dist/xrfragment.lua b/dist/xrfragment.lua
index 8f62e4c..8f5bf66 100644
--- a/dist/xrfragment.lua
+++ b/dist/xrfragment.lua
@@ -217,8 +217,8 @@ __lua_Boot = _hx_e()
__lua_UserData = _hx_e()
__lua_Lib = _hx_e()
__lua_Thread = _hx_e()
+__xrfragment_Filter = _hx_e()
__xrfragment_Parser = _hx_e()
-__xrfragment_Query = _hx_e()
__xrfragment_URI = _hx_e()
__xrfragment_XRF = _hx_e()
@@ -710,6 +710,20 @@ Reflect.deleteField = function(o,field)
o.__fields__[field] = nil;
do return true end;
end
+Reflect.copy = function(o)
+ if (o == nil) then
+ do return nil end;
+ end;
+ local o2 = _hx_e();
+ local _g = 0;
+ local _g1 = Reflect.fields(o);
+ while (_g < _g1.length) do
+ local f = _g1[_g];
+ _g = _g + 1;
+ o2[f] = Reflect.field(o, f);
+ end;
+ do return o2 end;
+end
String.new = function(string)
local self = _hx_new(String.prototype)
@@ -1378,220 +1392,28 @@ end
__lua_Thread.new = {}
__lua_Thread.__name__ = true
-__xrfragment_Parser.new = {}
-_hx_exports["xrfragment"]["Parser"] = __xrfragment_Parser
-__xrfragment_Parser.__name__ = true
-__xrfragment_Parser.parse = function(key,value,store)
- local Frag_h = ({});
- local value1 = _hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_PREDEFINED_VIEW),__xrfragment_XRF.PV_EXECUTE);
- if (value1 == nil) then
- Frag_h["#"] = __haxe_ds_StringMap.tnull;
- else
- Frag_h["#"] = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_INT);
- if (value1 == nil) then
- Frag_h.prio = __haxe_ds_StringMap.tnull;
- else
- Frag_h.prio = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_URL);
- if (value1 == nil) then
- Frag_h.src = __haxe_ds_StringMap.tnull;
- else
- Frag_h.src = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_URL),__xrfragment_XRF.T_PREDEFINED_VIEW);
- if (value1 == nil) then
- Frag_h.href = __haxe_ds_StringMap.tnull;
- else
- Frag_h.href = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
- if (value1 == nil) then
- Frag_h.tag = __haxe_ds_StringMap.tnull;
- else
- Frag_h.tag = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.PV_OVERRIDE,__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.T_STRING_OBJ),__xrfragment_XRF.METADATA),__xrfragment_XRF.NAVIGATOR);
- if (value1 == nil) then
- Frag_h.pos = __haxe_ds_StringMap.tnull;
- else
- Frag_h.pos = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.PV_OVERRIDE,__xrfragment_XRF.T_STRING),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.q = __haxe_ds_StringMap.tnull;
- else
- Frag_h.q = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.QUERY_OPERATOR,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.scale = __haxe_ds_StringMap.tnull;
- else
- Frag_h.scale = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.QUERY_OPERATOR,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.METADATA),__xrfragment_XRF.NAVIGATOR);
- if (value1 == nil) then
- Frag_h.rot = __haxe_ds_StringMap.tnull;
- else
- Frag_h.rot = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.QUERY_OPERATOR,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.mov = __haxe_ds_StringMap.tnull;
- else
- Frag_h.mov = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.QUERY_OPERATOR,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_INT),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.show = __haxe_ds_StringMap.tnull;
- else
- Frag_h.show = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_STRING),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.env = __haxe_ds_StringMap.tnull;
- else
- Frag_h.env = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_FLOAT),__xrfragment_XRF.T_VECTOR2),__xrfragment_XRF.T_STRING),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.t = __haxe_ds_StringMap.tnull;
- else
- Frag_h.t = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_FLOAT),__xrfragment_XRF.T_VECTOR2),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.tv = __haxe_ds_StringMap.tnull;
- else
- Frag_h.tv = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.gravity = __haxe_ds_StringMap.tnull;
- else
- Frag_h.gravity = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.physics = __haxe_ds_StringMap.tnull;
- else
- Frag_h.physics = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_INT),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.fov = __haxe_ds_StringMap.tnull;
- else
- Frag_h.fov = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR2),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.clip = __haxe_ds_StringMap.tnull;
- else
- Frag_h.clip = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR2),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.fog = __haxe_ds_StringMap.tnull;
- else
- Frag_h.fog = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
- if (value1 == nil) then
- Frag_h.bg = __haxe_ds_StringMap.tnull;
- else
- Frag_h.bg = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
- if (value1 == nil) then
- Frag_h.namespace = __haxe_ds_StringMap.tnull;
- else
- Frag_h.namespace = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
- if (value1 == nil) then
- Frag_h.SPDX = __haxe_ds_StringMap.tnull;
- else
- Frag_h.SPDX = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
- if (value1 == nil) then
- Frag_h.unit = __haxe_ds_StringMap.tnull;
- else
- Frag_h.unit = value1;
- end;
- local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
- if (value1 == nil) then
- Frag_h.description = __haxe_ds_StringMap.tnull;
- else
- Frag_h.description = value1;
- end;
- local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_URL),__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA),__xrfragment_XRF.PROMPT);
- if (value1 == nil) then
- Frag_h.session = __haxe_ds_StringMap.tnull;
- else
- Frag_h.session = value1;
- end;
- local isPVDynamic = ((__lua_lib_luautf8_Utf8.len(value) == 0) and (__lua_lib_luautf8_Utf8.len(key) > 0)) and (Frag_h[key] == nil);
- local isPVDefault = ((__lua_lib_luautf8_Utf8.len(value) == 0) and (__lua_lib_luautf8_Utf8.len(key) > 0)) and (key == "#");
- if (isPVDynamic) then
- local v = __xrfragment_XRF.new(key, _hx_bit.bor(__xrfragment_XRF.PV_EXECUTE,__xrfragment_XRF.NAVIGATOR));
- v:validate(key);
- store[key] = v;
- do return true end;
- end;
- local ret = Frag_h[key];
- if (ret == __haxe_ds_StringMap.tnull) then
- ret = nil;
- end;
- local v = __xrfragment_XRF.new(key, ret);
- if (Frag_h[key] ~= nil) then
- if (not v:validate(value)) then
- __haxe_Log.trace(Std.string(Std.string(Std.string(Std.string("⚠ fragment '") .. Std.string(key)) .. Std.string("' has incompatible value (")) .. Std.string(value)) .. Std.string(")"), _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="src/xrfragment/Parser.hx",lineNumber=80,className="xrfragment.Parser",methodName="parse"}));
- do return false end;
- end;
- store[key] = v;
- if (__xrfragment_Parser.debug) then
- __haxe_Log.trace(Std.string(Std.string(Std.string("✔ ") .. Std.string(key)) .. Std.string(": ")) .. Std.string(v.string), _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="src/xrfragment/Parser.hx",lineNumber=84,className="xrfragment.Parser",methodName="parse"}));
- end;
- else
- if (__lua_Boot.__instanceof(value, String)) then
- v:guessType(v, value);
- end;
- v.noXRF = true;
- store[key] = v;
- end;
- do return true end;
-end
-
-__xrfragment_Query.new = function(str)
- local self = _hx_new(__xrfragment_Query.prototype)
- __xrfragment_Query.super(self,str)
+__xrfragment_Filter.new = function(str)
+ local self = _hx_new(__xrfragment_Filter.prototype)
+ __xrfragment_Filter.super(self,str)
return self
end
-__xrfragment_Query.super = function(self,str)
- self.isNumber = EReg.new("^[0-9\\.]+$", "");
- self.isRoot = EReg.new("^[-]?/", "");
- self.isExclude = EReg.new("^-", "");
- self.isProp = EReg.new("^.*:[><=!]?", "");
+__xrfragment_Filter.super = function(self,str)
self.q = _hx_e();
self.str = "";
if (str ~= nil) then
self:parse(str);
end;
end
-_hx_exports["xrfragment"]["Query"] = __xrfragment_Query
-__xrfragment_Query.__name__ = true
-__xrfragment_Query.prototype = _hx_e();
-__xrfragment_Query.prototype.toObject = function(self)
- do return self.q end
+_hx_exports["xrfragment"]["Filter"] = __xrfragment_Filter
+__xrfragment_Filter.__name__ = true
+__xrfragment_Filter.prototype = _hx_e();
+__xrfragment_Filter.prototype.toObject = function(self)
+ do return Reflect.copy(self.q) end
end
-__xrfragment_Query.prototype.get = function(self)
- do return self.q end
+__xrfragment_Filter.prototype.get = function(self)
+ do return Reflect.copy(self.q) end
end
-__xrfragment_Query.prototype.parse = function(self,str)
- local _gthis = self;
+__xrfragment_Filter.prototype.parse = function(self,str)
local idx = 1;
local ret = _hx_tab_array({}, 0);
while (idx ~= nil) do
@@ -1625,8 +1447,8 @@ __xrfragment_Query.prototype.parse = function(self,str)
local ret = _hx_tab_array({}, 0);
while (idx ~= nil) do
local newidx = 0;
- if (__lua_lib_luautf8_Utf8.len(":") > 0) then
- newidx = __lua_lib_luautf8_Utf8.find(str, ":", idx, true);
+ if (__lua_lib_luautf8_Utf8.len("=") > 0) then
+ newidx = __lua_lib_luautf8_Utf8.find(str, "=", idx, true);
else
if (idx >= __lua_lib_luautf8_Utf8.len(str)) then
newidx = nil;
@@ -1637,7 +1459,7 @@ __xrfragment_Query.prototype.parse = function(self,str)
if (newidx ~= nil) then
local match = __lua_lib_luautf8_Utf8.sub(str, idx, newidx - 1);
ret:push(match);
- idx = newidx + __lua_lib_luautf8_Utf8.len(":");
+ idx = newidx + __lua_lib_luautf8_Utf8.len("=");
else
ret:push(__lua_lib_luautf8_Utf8.sub(str, idx, __lua_lib_luautf8_Utf8.len(str)));
idx = nil;
@@ -1648,8 +1470,8 @@ __xrfragment_Query.prototype.parse = function(self,str)
local ret = _hx_tab_array({}, 0);
while (idx ~= nil) do
local newidx = 0;
- if (__lua_lib_luautf8_Utf8.len(":") > 0) then
- newidx = __lua_lib_luautf8_Utf8.find(str, ":", idx, true);
+ if (__lua_lib_luautf8_Utf8.len("=") > 0) then
+ newidx = __lua_lib_luautf8_Utf8.find(str, "=", idx, true);
else
if (idx >= __lua_lib_luautf8_Utf8.len(str)) then
newidx = nil;
@@ -1660,7 +1482,7 @@ __xrfragment_Query.prototype.parse = function(self,str)
if (newidx ~= nil) then
local match = __lua_lib_luautf8_Utf8.sub(str, idx, newidx - 1);
ret:push(match);
- idx = newidx + __lua_lib_luautf8_Utf8.len(":");
+ idx = newidx + __lua_lib_luautf8_Utf8.len("=");
else
ret:push(__lua_lib_luautf8_Utf8.sub(str, idx, __lua_lib_luautf8_Utf8.len(str)));
idx = nil;
@@ -1671,15 +1493,7 @@ __xrfragment_Query.prototype.parse = function(self,str)
if (Reflect.field(q, Std.string(prefix) .. Std.string(k))) then
filter = Reflect.field(q, Std.string(prefix) .. Std.string(k));
end;
- local value = (function()
- local _hx_1
- if (Reflect.field(filter, "rules") ~= nil) then
- _hx_1 = Reflect.field(filter, "rules"); else
- _hx_1 = Array.new(); end
- return _hx_1
- end )();
- filter.rules = value;
- if (_gthis.isProp:match(str)) then
+ if (__xrfragment_XRF.isProp:match(str)) then
local oper = "";
local startIndex = nil;
if (startIndex == nil) then
@@ -1687,29 +1501,13 @@ __xrfragment_Query.prototype.parse = function(self,str)
else
startIndex = startIndex + 1;
end;
- local r = __lua_lib_luautf8_Utf8.find(str, "*", startIndex, true);
- if ((function()
- local _hx_2
- if ((r ~= nil) and (r > 0)) then
- _hx_2 = r - 1; else
- _hx_2 = -1; end
- return _hx_2
- end )() ~= -1) then
- oper = "*";
- end;
- local startIndex = nil;
- if (startIndex == nil) then
- startIndex = 1;
- else
- startIndex = startIndex + 1;
- end;
local r = __lua_lib_luautf8_Utf8.find(str, ">", startIndex, true);
if ((function()
- local _hx_3
+ local _hx_1
if ((r ~= nil) and (r > 0)) then
- _hx_3 = r - 1; else
- _hx_3 = -1; end
- return _hx_3
+ _hx_1 = r - 1; else
+ _hx_1 = -1; end
+ return _hx_1
end )() ~= -1) then
oper = ">";
end;
@@ -1721,48 +1519,15 @@ __xrfragment_Query.prototype.parse = function(self,str)
end;
local r = __lua_lib_luautf8_Utf8.find(str, "<", startIndex, true);
if ((function()
- local _hx_4
+ local _hx_2
if ((r ~= nil) and (r > 0)) then
- _hx_4 = r - 1; else
- _hx_4 = -1; end
- return _hx_4
+ _hx_2 = r - 1; else
+ _hx_2 = -1; end
+ return _hx_2
end )() ~= -1) then
oper = "<";
end;
- local startIndex = nil;
- if (startIndex == nil) then
- startIndex = 1;
- else
- startIndex = startIndex + 1;
- end;
- local r = __lua_lib_luautf8_Utf8.find(str, ">=", startIndex, true);
- if ((function()
- local _hx_5
- if ((r ~= nil) and (r > 0)) then
- _hx_5 = r - 1; else
- _hx_5 = -1; end
- return _hx_5
- end )() ~= -1) then
- oper = ">=";
- end;
- local startIndex = nil;
- if (startIndex == nil) then
- startIndex = 1;
- else
- startIndex = startIndex + 1;
- end;
- local r = __lua_lib_luautf8_Utf8.find(str, "<=", startIndex, true);
- if ((function()
- local _hx_6
- if ((r ~= nil) and (r > 0)) then
- _hx_6 = r - 1; else
- _hx_6 = -1; end
- return _hx_6
- end )() ~= -1) then
- oper = "<=";
- end;
- if (_gthis.isExclude:match(k)) then
- oper = "!=";
+ if (__xrfragment_XRF.isExclude:match(k)) then
local pos = 1;
local len = nil;
if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(k)))) then
@@ -1779,86 +1544,75 @@ __xrfragment_Query.prototype.parse = function(self,str)
pos = 0;
end;
k = __lua_lib_luautf8_Utf8.sub(k, pos + 1, pos + len);
- else
- local pos = __lua_lib_luautf8_Utf8.len(oper);
- local len = nil;
- if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(v)))) then
- len = __lua_lib_luautf8_Utf8.len(v);
- else
- if (len < 0) then
- len = __lua_lib_luautf8_Utf8.len(v) + len;
- end;
- end;
- if (pos < 0) then
- pos = __lua_lib_luautf8_Utf8.len(v) + pos;
- end;
- if (pos < 0) then
- pos = 0;
- end;
- v = __lua_lib_luautf8_Utf8.sub(v, pos + 1, pos + len);
end;
+ local pos = __lua_lib_luautf8_Utf8.len(oper);
+ local len = nil;
+ if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(v)))) then
+ len = __lua_lib_luautf8_Utf8.len(v);
+ else
+ if (len < 0) then
+ len = __lua_lib_luautf8_Utf8.len(v) + len;
+ end;
+ end;
+ if (pos < 0) then
+ pos = __lua_lib_luautf8_Utf8.len(v) + pos;
+ end;
+ if (pos < 0) then
+ pos = 0;
+ end;
+ v = __lua_lib_luautf8_Utf8.sub(v, pos + 1, pos + len);
if (__lua_lib_luautf8_Utf8.len(oper) == 0) then
oper = "=";
end;
local rule = _hx_e();
- if (_gthis.isNumber:match(v)) then
+ if (__xrfragment_XRF.isNumber:match(v)) then
local value = Std.parseFloat(v);
rule[oper] = value;
else
rule[oper] = v;
end;
- Reflect.field(filter, "rules"):push(rule);
- q[k] = filter;
- do return end;
- else
- local value = (function()
- local _hx_7
- if (_gthis.isExclude:match(str)) then
- _hx_7 = false; else
- _hx_7 = true; end
- return _hx_7
- end )();
- filter.id = value;
- local value = _gthis.isRoot:match(str);
- filter.root = value;
- if (_gthis.isExclude:match(str)) then
- local pos = 1;
- local len = nil;
- if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(str)))) then
- len = __lua_lib_luautf8_Utf8.len(str);
- else
- if (len < 0) then
- len = __lua_lib_luautf8_Utf8.len(str) + len;
- end;
- end;
- if (pos < 0) then
- pos = __lua_lib_luautf8_Utf8.len(str) + pos;
- end;
- if (pos < 0) then
- pos = 0;
- end;
- str = __lua_lib_luautf8_Utf8.sub(str, pos + 1, pos + len);
- end;
- if (_gthis.isRoot:match(str)) then
- local pos = 1;
- local len = nil;
- if ((len == nil) or (len > (pos + __lua_lib_luautf8_Utf8.len(str)))) then
- len = __lua_lib_luautf8_Utf8.len(str);
- else
- if (len < 0) then
- len = __lua_lib_luautf8_Utf8.len(str) + len;
- end;
- end;
- if (pos < 0) then
- pos = __lua_lib_luautf8_Utf8.len(str) + pos;
- end;
- if (pos < 0) then
- pos = 0;
- end;
- str = __lua_lib_luautf8_Utf8.sub(str, pos + 1, pos + len);
- end;
- q[str] = filter;
+ q.expr = rule;
end;
+ local value;
+ if (__xrfragment_XRF.isDeep:match(str)) then
+ local idx = 1;
+ local ret = _hx_tab_array({}, 0);
+ while (idx ~= nil) do
+ local newidx = 0;
+ if (__lua_lib_luautf8_Utf8.len("*") > 0) then
+ newidx = __lua_lib_luautf8_Utf8.find(k, "*", idx, true);
+ else
+ if (idx >= __lua_lib_luautf8_Utf8.len(k)) then
+ newidx = nil;
+ else
+ newidx = idx + 1;
+ end;
+ end;
+ if (newidx ~= nil) then
+ local match = __lua_lib_luautf8_Utf8.sub(k, idx, newidx - 1);
+ ret:push(match);
+ idx = newidx + __lua_lib_luautf8_Utf8.len("*");
+ else
+ ret:push(__lua_lib_luautf8_Utf8.sub(k, idx, __lua_lib_luautf8_Utf8.len(k)));
+ idx = nil;
+ end;
+ end;
+ value = ret.length - 1;
+ else
+ value = 0;
+ end;
+ q.deep = value;
+ local value = (function()
+ local _hx_3
+ if (__xrfragment_XRF.isExclude:match(str)) then
+ _hx_3 = false; else
+ _hx_3 = true; end
+ return _hx_3
+ end )();
+ q.show = value;
+ local value = __xrfragment_XRF.operators:replace(k, "");
+ q.key = value;
+ q.value = v;
end;
local _g = 0;
local _g1 = token.length;
@@ -1869,7 +1623,7 @@ __xrfragment_Query.prototype.parse = function(self,str)
end;
self.q = q do return self.q end
end
-__xrfragment_Query.prototype.test = function(self,obj)
+__xrfragment_Filter.prototype.test = function(self,obj)
local qualify = false;
local _g = 0;
local _g1 = Reflect.fields(obj);
@@ -1893,7 +1647,7 @@ __xrfragment_Query.prototype.test = function(self,obj)
end;
do return qualify end
end
-__xrfragment_Query.prototype.testProperty = function(self,property,value,exclude)
+__xrfragment_Filter.prototype.testProperty = function(self,property,value,exclude)
local conds = 0;
local fails = 0;
local qualify = 0;
@@ -1914,56 +1668,147 @@ __xrfragment_Query.prototype.testProperty = function(self,property,value,exclude
do return Reflect.field(v, property) end;
end;
end;
- local _g = 0;
- local _g1 = Reflect.fields(self.q);
- local _hx_continue_1 = false;
- while (_g < _g1.length) do repeat
- local k = _g1[_g];
- _g = _g + 1;
- local filter = Reflect.field(self.q, k);
- if (filter.rules == nil) then
- break;
- end;
- local rules = filter.rules;
- local _g = 0;
- while (_g < rules.length) do
- local rule = rules[_g];
- _g = _g + 1;
- if (exclude) then
- if (((Reflect.field(rule, "!=") ~= nil) and testprop(Std.string(value) == Std.string(Reflect.field(rule, "!=")))) and exclude) then
- qualify = qualify + 1;
- end;
- else
- if ((Reflect.field(rule, "*") ~= nil) and testprop(Std.parseFloat(value) ~= nil)) then
- qualify = qualify + 1;
- end;
- if ((Reflect.field(rule, ">") ~= nil) and testprop(Std.parseFloat(value) > Std.parseFloat(Reflect.field(rule, ">")))) then
- qualify = qualify + 1;
- end;
- if ((Reflect.field(rule, "<") ~= nil) and testprop(Std.parseFloat(value) < Std.parseFloat(Reflect.field(rule, "<")))) then
- qualify = qualify + 1;
- end;
- if ((Reflect.field(rule, ">=") ~= nil) and testprop(Std.parseFloat(value) >= Std.parseFloat(Reflect.field(rule, ">=")))) then
- qualify = qualify + 1;
- end;
- if ((Reflect.field(rule, "<=") ~= nil) and testprop(Std.parseFloat(value) <= Std.parseFloat(Reflect.field(rule, "<=")))) then
- qualify = qualify + 1;
- end;
- if ((Reflect.field(rule, "=") ~= nil) and (testprop(value == Reflect.field(rule, "=")) or testprop(Std.parseFloat(value) == Std.parseFloat(Reflect.field(rule, "="))))) then
- qualify = qualify + 1;
- end;
+ if (Reflect.field(self.q, "expr")) then
+ local f = Reflect.field(self.q, "expr");
+ if (not Reflect.field(self.q, "show")) then
+ if (((Reflect.field(f, "!=") ~= nil) and testprop(Std.string(value) == Std.string(Reflect.field(f, "!=")))) and exclude) then
+ qualify = qualify + 1;
+ end;
+ else
+ if ((Reflect.field(f, "*") ~= nil) and testprop(Std.parseFloat(value) ~= nil)) then
+ qualify = qualify + 1;
+ end;
+ if ((Reflect.field(f, ">") ~= nil) and testprop(Std.parseFloat(value) >= Std.parseFloat(Reflect.field(f, ">")))) then
+ qualify = qualify + 1;
+ end;
+ if ((Reflect.field(f, "<") ~= nil) and testprop(Std.parseFloat(value) <= Std.parseFloat(Reflect.field(f, "<")))) then
+ qualify = qualify + 1;
+ end;
+ if ((Reflect.field(f, "=") ~= nil) and (testprop(value == Reflect.field(f, "=")) or testprop(Std.parseFloat(value) == Std.parseFloat(Reflect.field(f, "="))))) then
+ qualify = qualify + 1;
end;
- end;until true
- if _hx_continue_1 then
- _hx_continue_1 = false;
- break;
end;
-
end;
do return qualify > 0 end
end
-__xrfragment_Query.prototype.__class__ = __xrfragment_Query
+__xrfragment_Filter.prototype.__class__ = __xrfragment_Filter
+
+__xrfragment_Parser.new = {}
+_hx_exports["xrfragment"]["Parser"] = __xrfragment_Parser
+__xrfragment_Parser.__name__ = true
+__xrfragment_Parser.parse = function(key,value,store,index)
+ local Frag_h = ({});
+ local value1 = _hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_PREDEFINED_VIEW),__xrfragment_XRF.PV_EXECUTE);
+ if (value1 == nil) then
+ Frag_h["#"] = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h["#"] = value1;
+ end;
+ local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_URL);
+ if (value1 == nil) then
+ Frag_h.src = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.src = value1;
+ end;
+ local value1 = _hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_URL),__xrfragment_XRF.T_PREDEFINED_VIEW);
+ if (value1 == nil) then
+ Frag_h.href = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.href = value1;
+ end;
+ local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
+ if (value1 == nil) then
+ Frag_h.tag = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.tag = value1;
+ end;
+ local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.PV_OVERRIDE,__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.T_STRING),__xrfragment_XRF.T_STRING_OBJ),__xrfragment_XRF.METADATA),__xrfragment_XRF.NAVIGATOR);
+ if (value1 == nil) then
+ Frag_h.pos = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.pos = value1;
+ end;
+ local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.QUERY_OPERATOR,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.METADATA),__xrfragment_XRF.NAVIGATOR);
+ if (value1 == nil) then
+ Frag_h.rot = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.rot = value1;
+ end;
+ local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_FLOAT),__xrfragment_XRF.T_VECTOR2),__xrfragment_XRF.T_STRING),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
+ if (value1 == nil) then
+ Frag_h.t = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.t = value1;
+ end;
+ local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.T_FLOAT),__xrfragment_XRF.T_VECTOR2),__xrfragment_XRF.T_VECTOR3),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA);
+ if (value1 == nil) then
+ Frag_h.tv = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.tv = value1;
+ end;
+ local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
+ if (value1 == nil) then
+ Frag_h.namespace = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.namespace = value1;
+ end;
+ local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
+ if (value1 == nil) then
+ Frag_h.SPDX = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.SPDX = value1;
+ end;
+ local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
+ if (value1 == nil) then
+ Frag_h.unit = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.unit = value1;
+ end;
+ local value1 = _hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_STRING);
+ if (value1 == nil) then
+ Frag_h.description = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.description = value1;
+ end;
+ local value1 = _hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(_hx_bit.bor(__xrfragment_XRF.ASSET,__xrfragment_XRF.T_URL),__xrfragment_XRF.PV_OVERRIDE),__xrfragment_XRF.NAVIGATOR),__xrfragment_XRF.METADATA),__xrfragment_XRF.PROMPT);
+ if (value1 == nil) then
+ Frag_h.session = __haxe_ds_StringMap.tnull;
+ else
+ Frag_h.session = value1;
+ end;
+ local keyStripped = __xrfragment_XRF.operators:replace(key, "");
+ local isPVDynamic = (__lua_lib_luautf8_Utf8.len(key) > 0) and (Frag_h[key] == nil);
+ local isPVDefault = ((__lua_lib_luautf8_Utf8.len(value) == 0) and (__lua_lib_luautf8_Utf8.len(key) > 0)) and (key == "#");
+ if (isPVDynamic) then
+ local v = __xrfragment_XRF.new(key, _hx_bit.bor(__xrfragment_XRF.PV_EXECUTE,__xrfragment_XRF.NAVIGATOR), index);
+ v:validate(value);
+ store[keyStripped] = v;
+ do return true end;
+ end;
+ local ret = Frag_h[key];
+ if (ret == __haxe_ds_StringMap.tnull) then
+ ret = nil;
+ end;
+ local v = __xrfragment_XRF.new(key, ret, index);
+ if (Frag_h[key] ~= nil) then
+ if (not v:validate(value)) then
+ __haxe_Log.trace(Std.string(Std.string(Std.string(Std.string("⚠ fragment '") .. Std.string(key)) .. Std.string("' has incompatible value (")) .. Std.string(value)) .. Std.string(")"), _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="src/xrfragment/Parser.hx",lineNumber=66,className="xrfragment.Parser",methodName="parse"}));
+ do return false end;
+ end;
+ store[keyStripped] = v;
+ if (__xrfragment_Parser.debug) then
+ __haxe_Log.trace(Std.string(Std.string(Std.string("✔ ") .. Std.string(key)) .. Std.string(": ")) .. Std.string(v.string), _hx_o({__fields__={fileName=true,lineNumber=true,className=true,methodName=true},fileName="src/xrfragment/Parser.hx",lineNumber=70,className="xrfragment.Parser",methodName="parse"}));
+ end;
+ else
+ if (__lua_Boot.__instanceof(value, String)) then
+ v:guessType(v, value);
+ end;
+ v.noXRF = true;
+ store[keyStripped] = v;
+ end;
+ do return true end;
+end
__xrfragment_URI.new = {}
_hx_exports["xrfragment"]["URI"] = __xrfragment_URI
@@ -2074,7 +1919,7 @@ __xrfragment_URI.parse = function(url,filter)
if (splitByEqual.length > 1) then
value = StringTools.urlDecode(regexPlus:split(splitByEqual[1]):join(" "));
end;
- local ok = __xrfragment_Parser.parse(key, value, store);
+ local ok = __xrfragment_Parser.parse(key, value, store, i);
end;
if ((filter ~= nil) and (filter ~= 0)) then
local _g = 0;
@@ -2091,14 +1936,15 @@ __xrfragment_URI.parse = function(url,filter)
do return store end;
end
-__xrfragment_XRF.new = function(_fragment,_flags)
+__xrfragment_XRF.new = function(_fragment,_flags,_index)
local self = _hx_new(__xrfragment_XRF.prototype)
- __xrfragment_XRF.super(self,_fragment,_flags)
+ __xrfragment_XRF.super(self,_fragment,_flags,_index)
return self
end
-__xrfragment_XRF.super = function(self,_fragment,_flags)
+__xrfragment_XRF.super = function(self,_fragment,_flags,_index)
self.fragment = _fragment;
self.flags = _flags;
+ self.index = _index;
end
_hx_exports["xrfragment"]["XRF"] = __xrfragment_XRF
__xrfragment_XRF.__name__ = true
@@ -2117,43 +1963,21 @@ __xrfragment_XRF.prototype.is = function(self,flag)
end
__xrfragment_XRF.prototype.validate = function(self,value)
self:guessType(self, value);
- if (self.fragment == "q") then
- self.query = __xrfragment_Query.new(value):get();
- end;
local ok = true;
if ((not self:is(__xrfragment_XRF.T_FLOAT) and self:is(__xrfragment_XRF.T_VECTOR2)) and not (__lua_Boot.__instanceof(self.x, Float) and __lua_Boot.__instanceof(self.y, Float))) then
ok = false;
end;
- if ((not self:is(__xrfragment_XRF.T_VECTOR2) and self:is(__xrfragment_XRF.T_VECTOR3)) and not ((__lua_Boot.__instanceof(self.x, Float) and __lua_Boot.__instanceof(self.y, Float)) and __lua_Boot.__instanceof(self.z, Float))) then
+ if ((not (self:is(__xrfragment_XRF.T_VECTOR2) or self:is(__xrfragment_XRF.T_STRING)) and self:is(__xrfragment_XRF.T_VECTOR3)) and not ((__lua_Boot.__instanceof(self.x, Float) and __lua_Boot.__instanceof(self.y, Float)) and __lua_Boot.__instanceof(self.z, Float))) then
ok = false;
end;
do return ok end
end
__xrfragment_XRF.prototype.guessType = function(self,v,str)
v.string = str;
- local idx = 1;
- local ret = _hx_tab_array({}, 0);
- while (idx ~= nil) do
- local newidx = 0;
- if (__lua_lib_luautf8_Utf8.len(",") > 0) then
- newidx = __lua_lib_luautf8_Utf8.find(str, ",", idx, true);
- else
- if (idx >= __lua_lib_luautf8_Utf8.len(str)) then
- newidx = nil;
- else
- newidx = idx + 1;
- end;
- end;
- if (newidx ~= nil) then
- local match = __lua_lib_luautf8_Utf8.sub(str, idx, newidx - 1);
- ret:push(match);
- idx = newidx + __lua_lib_luautf8_Utf8.len(",");
- else
- ret:push(__lua_lib_luautf8_Utf8.sub(str, idx, __lua_lib_luautf8_Utf8.len(str)));
- idx = nil;
- end;
+ if (not __lua_Boot.__instanceof(str, String)) then
+ do return end;
end;
- if (ret.length > 1) then
+ if (__lua_lib_luautf8_Utf8.len(str) > 0) then
local idx = 1;
local ret = _hx_tab_array({}, 0);
while (idx ~= nil) do
@@ -2176,30 +2000,57 @@ __xrfragment_XRF.prototype.guessType = function(self,v,str)
idx = nil;
end;
end;
- local xyzw = ret;
- if (xyzw.length > 0) then
- v.x = Std.parseFloat(xyzw[0]);
+ if (ret.length > 1) then
+ local idx = 1;
+ local ret = _hx_tab_array({}, 0);
+ while (idx ~= nil) do
+ local newidx = 0;
+ if (__lua_lib_luautf8_Utf8.len(",") > 0) then
+ newidx = __lua_lib_luautf8_Utf8.find(str, ",", idx, true);
+ else
+ if (idx >= __lua_lib_luautf8_Utf8.len(str)) then
+ newidx = nil;
+ else
+ newidx = idx + 1;
+ end;
+ end;
+ if (newidx ~= nil) then
+ local match = __lua_lib_luautf8_Utf8.sub(str, idx, newidx - 1);
+ ret:push(match);
+ idx = newidx + __lua_lib_luautf8_Utf8.len(",");
+ else
+ ret:push(__lua_lib_luautf8_Utf8.sub(str, idx, __lua_lib_luautf8_Utf8.len(str)));
+ idx = nil;
+ end;
+ end;
+ local xyzw = ret;
+ if (xyzw.length > 0) then
+ v.x = Std.parseFloat(xyzw[0]);
+ end;
+ if (xyzw.length > 1) then
+ v.y = Std.parseFloat(xyzw[1]);
+ end;
+ if (xyzw.length > 2) then
+ v.z = Std.parseFloat(xyzw[2]);
+ end;
+ if (xyzw.length > 3) then
+ v.w = Std.parseFloat(xyzw[3]);
+ end;
end;
- if (xyzw.length > 1) then
- v.y = Std.parseFloat(xyzw[1]);
+ if (__xrfragment_XRF.isColor:match(str)) then
+ v.color = str;
end;
- if (xyzw.length > 2) then
- v.z = Std.parseFloat(xyzw[2]);
+ if (__xrfragment_XRF.isFloat:match(str)) then
+ v.x = Std.parseFloat(str);
+ v.float = v.x;
end;
- if (xyzw.length > 3) then
- v.w = Std.parseFloat(xyzw[3]);
+ if (__xrfragment_XRF.isInt:match(str)) then
+ v.int = Std.parseInt(str);
+ v.x = v.int;
end;
- end;
- if (__xrfragment_XRF.isColor:match(str)) then
- v.color = str;
- end;
- if (__xrfragment_XRF.isFloat:match(str)) then
- v.x = Std.parseFloat(str);
- v.float = v.x;
- end;
- if (__xrfragment_XRF.isInt:match(str)) then
- v.int = Std.parseInt(str);
- v.x = v.int;
+ v.filter = __xrfragment_Filter.new(Std.string(Std.string(v.fragment) .. Std.string("=")) .. Std.string(v.string));
+ else
+ v.filter = __xrfragment_Filter.new(v.fragment);
end;
end
@@ -2316,6 +2167,16 @@ local _hx_static_init = function()
__xrfragment_XRF.isString = EReg.new(".*", "");
+ __xrfragment_XRF.operators = EReg.new("(^-|[\\*]+)", "");
+
+ __xrfragment_XRF.isProp = EReg.new("^.*=[><=]?", "");
+
+ __xrfragment_XRF.isExclude = EReg.new("^-", "");
+
+ __xrfragment_XRF.isDeep = EReg.new("\\*", "");
+
+ __xrfragment_XRF.isNumber = EReg.new("^[0-9\\.]+$", "");
+
end
diff --git a/dist/xrfragment.module.js b/dist/xrfragment.module.js
index f60b93c..3ea5aae 100644
--- a/dist/xrfragment.module.js
+++ b/dist/xrfragment.module.js
@@ -1,3 +1,113 @@
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
(function ($global) { "use strict";
$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
@@ -72,6 +182,20 @@ Reflect.deleteField = function(o,field) {
delete(o[field]);
return true;
};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
@@ -209,83 +333,22 @@ js_Boot.__string_rec = function(o,s) {
return String(o);
}
};
-var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
-xrfragment_Parser.__name__ = true;
-xrfragment_Parser.parse = function(key,value,store) {
- var Frag_h = Object.create(null);
- Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
- Frag_h["prio"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_INT;
- Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
- Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
- Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["q"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["scale"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["mov"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["show"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.METADATA;
- Frag_h["env"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["gravity"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["physics"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["fov"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["clip"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["fog"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["bg"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
- var isPVDynamic = value.length == 0 && key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
- var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
- if(isPVDynamic) {
- var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR);
- v.validate(key);
- store[key] = v;
- return true;
- }
- var v = new xrfragment_XRF(key,Frag_h[key]);
- if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
- if(!v.validate(value)) {
- console.log("src/xrfragment/Parser.hx:80:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
- return false;
- }
- store[key] = v;
- if(xrfragment_Parser.debug) {
- console.log("src/xrfragment/Parser.hx:84:","✔ " + key + ": " + v.string);
- }
- } else {
- if(typeof(value) == "string") {
- v.guessType(v,value);
- }
- v.noXRF = true;
- store[key] = v;
- }
- return true;
-};
-var xrfragment_Query = $hx_exports["xrfragment"]["Query"] = function(str) {
- this.isNumber = new EReg("^[0-9\\.]+$","");
- this.isRoot = new EReg("^[-]?/","");
- this.isExclude = new EReg("^-","");
- this.isProp = new EReg("^.*:[><=!]?","");
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
this.q = { };
this.str = "";
if(str != null) {
this.parse(str);
}
};
-xrfragment_Query.__name__ = true;
-xrfragment_Query.prototype = {
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
toObject: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,get: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,parse: function(str) {
- var _gthis = this;
var token = str.split(" ");
var q = { };
var process = function(str,prefix) {
@@ -293,59 +356,42 @@ xrfragment_Query.prototype = {
prefix = "";
}
str = StringTools.trim(str);
- var k = str.split(":")[0];
- var v = str.split(":")[1];
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
var filter = { };
if(q[prefix + k]) {
filter = q[prefix + k];
}
- filter["rules"] = filter["rules"] != null ? filter["rules"] : [];
- if(_gthis.isProp.match(str)) {
+ if(xrfragment_XRF.isProp.match(str)) {
var oper = "";
- if(str.indexOf("*") != -1) {
- oper = "*";
- }
if(str.indexOf(">") != -1) {
oper = ">";
}
if(str.indexOf("<") != -1) {
oper = "<";
}
- if(str.indexOf(">=") != -1) {
- oper = ">=";
- }
- if(str.indexOf("<=") != -1) {
- oper = "<=";
- }
- if(_gthis.isExclude.match(k)) {
- oper = "!=";
+ if(xrfragment_XRF.isExclude.match(k)) {
k = HxOverrides.substr(k,1,null);
- } else {
- v = HxOverrides.substr(v,oper.length,null);
}
+ v = HxOverrides.substr(v,oper.length,null);
if(oper.length == 0) {
oper = "=";
}
var rule = { };
- if(_gthis.isNumber.match(v)) {
+ if(xrfragment_XRF.isNumber.match(v)) {
rule[oper] = parseFloat(v);
} else {
rule[oper] = v;
}
- filter["rules"].push(rule);
- q[k] = filter;
- return;
- } else {
- filter["id"] = _gthis.isExclude.match(str) ? false : true;
- filter["root"] = _gthis.isRoot.match(str);
- if(_gthis.isExclude.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- if(_gthis.isRoot.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- q[str] = filter;
+ q["expr"] = rule;
}
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
};
var _g = 0;
var _g1 = token.length;
@@ -394,49 +440,75 @@ xrfragment_Query.prototype = {
return v[property];
}
}
- var _g = 0;
- var _g1 = Reflect.fields(this.q);
- while(_g < _g1.length) {
- var k = _g1[_g];
- ++_g;
- var filter = Reflect.field(this.q,k);
- if(filter.rules == null) {
- continue;
- }
- var rules = filter.rules;
- var _g2 = 0;
- while(_g2 < rules.length) {
- var rule = rules[_g2];
- ++_g2;
- if(exclude) {
- if(Reflect.field(rule,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(rule,"!="))) && exclude) {
- ++qualify;
- }
- } else {
- if(Reflect.field(rule,"*") != null && testprop(parseFloat(value) != null)) {
- ++qualify;
- }
- if(Reflect.field(rule,">") != null && testprop(parseFloat(value) > parseFloat(Reflect.field(rule,">")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<") != null && testprop(parseFloat(value) < parseFloat(Reflect.field(rule,"<")))) {
- ++qualify;
- }
- if(Reflect.field(rule,">=") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(rule,">=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<=") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(rule,"<=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"=") != null && (testprop(value == Reflect.field(rule,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(rule,"="))))) {
- ++qualify;
- }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
}
}
}
return qualify > 0;
}
};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
@@ -458,7 +530,7 @@ xrfragment_URI.parse = function(url,filter) {
var s = regexPlus.split(splitByEqual[1]).join(" ");
value = decodeURIComponent(s.split("+").join(" "));
}
- var ok = xrfragment_Parser.parse(key,value,store);
+ var ok = xrfragment_Parser.parse(key,value,store,i);
}
if(filter != null && filter != 0) {
var _g = 0;
@@ -474,9 +546,10 @@ xrfragment_URI.parse = function(url,filter) {
}
return store;
};
-var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) {
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
this.fragment = _fragment;
this.flags = _flags;
+ this.index = _index;
};
xrfragment_XRF.__name__ = true;
xrfragment_XRF.set = function(flag,flags) {
@@ -495,45 +568,50 @@ xrfragment_XRF.prototype = {
}
,validate: function(value) {
this.guessType(this,value);
- if(this.fragment == "q") {
- this.query = new xrfragment_Query(value).get();
- }
var ok = true;
if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
ok = false;
}
- if(!this.is(xrfragment_XRF.T_VECTOR2) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
ok = false;
}
return ok;
}
,guessType: function(v,str) {
v.string = str;
- if(str.split(",").length > 1) {
- var xyzw = str.split(",");
- if(xyzw.length > 0) {
- v.x = parseFloat(xyzw[0]);
- }
- if(xyzw.length > 1) {
- v.y = parseFloat(xyzw[1]);
- }
- if(xyzw.length > 2) {
- v.z = parseFloat(xyzw[2]);
- }
- if(xyzw.length > 3) {
- v.w = parseFloat(xyzw[3]);
- }
+ if(typeof(str) != "string") {
+ return;
}
- if(xrfragment_XRF.isColor.match(str)) {
- v.color = str;
- }
- if(xrfragment_XRF.isFloat.match(str)) {
- v.x = parseFloat(str);
- v.float = v.x;
- }
- if(xrfragment_XRF.isInt.match(str)) {
- v.int = Std.parseInt(str);
- v.x = v.int;
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
}
}
};
@@ -571,6 +649,11540 @@ xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
+})({});
+var xrfragment = $hx_exports["xrfragment"];
+export default xrfragment;
+var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
+(function ($global) { "use strict";
+$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
+var EReg = function(r,opt) {
+ this.r = new RegExp(r,opt.split("u").join(""));
+};
+EReg.__name__ = true;
+EReg.prototype = {
+ match: function(s) {
+ if(this.r.global) {
+ this.r.lastIndex = 0;
+ }
+ this.r.m = this.r.exec(s);
+ this.r.s = s;
+ return this.r.m != null;
+ }
+ ,split: function(s) {
+ var d = "#__delim__#";
+ return s.replace(this.r,d).split(d);
+ }
+};
+var HxOverrides = function() { };
+HxOverrides.__name__ = true;
+HxOverrides.cca = function(s,index) {
+ var x = s.charCodeAt(index);
+ if(x != x) {
+ return undefined;
+ }
+ return x;
+};
+HxOverrides.substr = function(s,pos,len) {
+ if(len == null) {
+ len = s.length;
+ } else if(len < 0) {
+ if(pos == 0) {
+ len = s.length + len;
+ } else {
+ return "";
+ }
+ }
+ return s.substr(pos,len);
+};
+HxOverrides.now = function() {
+ return Date.now();
+};
+Math.__name__ = true;
+var Reflect = function() { };
+Reflect.__name__ = true;
+Reflect.field = function(o,field) {
+ try {
+ return o[field];
+ } catch( _g ) {
+ return null;
+ }
+};
+Reflect.fields = function(o) {
+ var a = [];
+ if(o != null) {
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ for( var f in o ) {
+ if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
+ a.push(f);
+ }
+ }
+ }
+ return a;
+};
+Reflect.deleteField = function(o,field) {
+ if(!Object.prototype.hasOwnProperty.call(o,field)) {
+ return false;
+ }
+ delete(o[field]);
+ return true;
+};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
+var Std = function() { };
+Std.__name__ = true;
+Std.string = function(s) {
+ return js_Boot.__string_rec(s,"");
+};
+Std.parseInt = function(x) {
+ if(x != null) {
+ var _g = 0;
+ var _g1 = x.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var c = x.charCodeAt(i);
+ if(c <= 8 || c >= 14 && c != 32 && c != 45) {
+ var nc = x.charCodeAt(i + 1);
+ var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
+ if(isNaN(v)) {
+ return null;
+ } else {
+ return v;
+ }
+ }
+ }
+ }
+ return null;
+};
+var StringTools = function() { };
+StringTools.__name__ = true;
+StringTools.isSpace = function(s,pos) {
+ var c = HxOverrides.cca(s,pos);
+ if(!(c > 8 && c < 14)) {
+ return c == 32;
+ } else {
+ return true;
+ }
+};
+StringTools.ltrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,r)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,r,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.rtrim = function(s) {
+ var l = s.length;
+ var r = 0;
+ while(r < l && StringTools.isSpace(s,l - r - 1)) ++r;
+ if(r > 0) {
+ return HxOverrides.substr(s,0,l - r);
+ } else {
+ return s;
+ }
+};
+StringTools.trim = function(s) {
+ return StringTools.ltrim(StringTools.rtrim(s));
+};
+var haxe_iterators_ArrayIterator = function(array) {
+ this.current = 0;
+ this.array = array;
+};
+haxe_iterators_ArrayIterator.__name__ = true;
+haxe_iterators_ArrayIterator.prototype = {
+ hasNext: function() {
+ return this.current < this.array.length;
+ }
+ ,next: function() {
+ return this.array[this.current++];
+ }
+};
+var js_Boot = function() { };
+js_Boot.__name__ = true;
+js_Boot.__string_rec = function(o,s) {
+ if(o == null) {
+ return "null";
+ }
+ if(s.length >= 5) {
+ return "<...>";
+ }
+ var t = typeof(o);
+ if(t == "function" && (o.__name__ || o.__ename__)) {
+ t = "object";
+ }
+ switch(t) {
+ case "function":
+ return "";
+ case "object":
+ if(((o) instanceof Array)) {
+ var str = "[";
+ s += "\t";
+ var _g = 0;
+ var _g1 = o.length;
+ while(_g < _g1) {
+ var i = _g++;
+ str += (i > 0 ? "," : "") + js_Boot.__string_rec(o[i],s);
+ }
+ str += "]";
+ return str;
+ }
+ var tostr;
+ try {
+ tostr = o.toString;
+ } catch( _g ) {
+ return "???";
+ }
+ if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
+ var s2 = o.toString();
+ if(s2 != "[object Object]") {
+ return s2;
+ }
+ }
+ var str = "{\n";
+ s += "\t";
+ var hasp = o.hasOwnProperty != null;
+ var k = null;
+ for( k in o ) {
+ if(hasp && !o.hasOwnProperty(k)) {
+ continue;
+ }
+ if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
+ continue;
+ }
+ if(str.length != 2) {
+ str += ", \n";
+ }
+ str += s + k + " : " + js_Boot.__string_rec(o[k],s);
+ }
+ s = s.substring(1);
+ str += "\n" + s + "}";
+ return str;
+ case "string":
+ return o;
+ default:
+ return String(o);
+ }
+};
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
+ this.q = { };
+ this.str = "";
+ if(str != null) {
+ this.parse(str);
+ }
+};
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
+ toObject: function() {
+ return Reflect.copy(this.q);
+ }
+ ,get: function() {
+ return Reflect.copy(this.q);
+ }
+ ,parse: function(str) {
+ var token = str.split(" ");
+ var q = { };
+ var process = function(str,prefix) {
+ if(prefix == null) {
+ prefix = "";
+ }
+ str = StringTools.trim(str);
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
+ var filter = { };
+ if(q[prefix + k]) {
+ filter = q[prefix + k];
+ }
+ if(xrfragment_XRF.isProp.match(str)) {
+ var oper = "";
+ if(str.indexOf(">") != -1) {
+ oper = ">";
+ }
+ if(str.indexOf("<") != -1) {
+ oper = "<";
+ }
+ if(xrfragment_XRF.isExclude.match(k)) {
+ k = HxOverrides.substr(k,1,null);
+ }
+ v = HxOverrides.substr(v,oper.length,null);
+ if(oper.length == 0) {
+ oper = "=";
+ }
+ var rule = { };
+ if(xrfragment_XRF.isNumber.match(v)) {
+ rule[oper] = parseFloat(v);
+ } else {
+ rule[oper] = v;
+ }
+ q["expr"] = rule;
+ }
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
+ };
+ var _g = 0;
+ var _g1 = token.length;
+ while(_g < _g1) {
+ var i = _g++;
+ process(token[i]);
+ }
+ return this.q = q;
+ }
+ ,test: function(obj) {
+ var qualify = false;
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v)) {
+ qualify = true;
+ }
+ }
+ var _g = 0;
+ var _g1 = Reflect.fields(obj);
+ while(_g < _g1.length) {
+ var k = _g1[_g];
+ ++_g;
+ var v = Std.string(Reflect.field(obj,k));
+ if(this.testProperty(k,v,true)) {
+ qualify = false;
+ }
+ }
+ return qualify;
+ }
+ ,testProperty: function(property,value,exclude) {
+ var conds = 0;
+ var fails = 0;
+ var qualify = 0;
+ var testprop = function(expr) {
+ conds += 1;
+ fails += expr ? 0 : 1;
+ return expr;
+ };
+ if(this.q[value] != null) {
+ var v = this.q[value];
+ if(v[property] != null) {
+ return v[property];
+ }
+ }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
+ }
+ }
+ }
+ return qualify > 0;
+ }
+};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
+var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
+xrfragment_URI.__name__ = true;
+xrfragment_URI.parse = function(url,filter) {
+ var store = { };
+ if(url == null || url.indexOf("#") == -1) {
+ return store;
+ }
+ var fragment = url.split("#");
+ var splitArray = fragment[1].split("&");
+ var _g = 0;
+ var _g1 = splitArray.length;
+ while(_g < _g1) {
+ var i = _g++;
+ var splitByEqual = splitArray[i].split("=");
+ var regexPlus = new EReg("\\+","g");
+ var key = splitByEqual[0];
+ var value = "";
+ if(splitByEqual.length > 1) {
+ var s = regexPlus.split(splitByEqual[1]).join(" ");
+ value = decodeURIComponent(s.split("+").join(" "));
+ }
+ var ok = xrfragment_Parser.parse(key,value,store,i);
+ }
+ if(filter != null && filter != 0) {
+ var _g = 0;
+ var _g1 = Reflect.fields(store);
+ while(_g < _g1.length) {
+ var key = _g1[_g];
+ ++_g;
+ var xrf = store[key];
+ if(!xrf.is(filter)) {
+ Reflect.deleteField(store,key);
+ }
+ }
+ }
+ return store;
+};
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
+ this.fragment = _fragment;
+ this.flags = _flags;
+ this.index = _index;
+};
+xrfragment_XRF.__name__ = true;
+xrfragment_XRF.set = function(flag,flags) {
+ return flags | flag;
+};
+xrfragment_XRF.unset = function(flag,flags) {
+ return flags & ~flag;
+};
+xrfragment_XRF.prototype = {
+ is: function(flag) {
+ var v = this.flags;
+ if(!(typeof(v) == "number" && ((v | 0) === v))) {
+ this.flags = 0;
+ }
+ return (this.flags & flag) != 0;
+ }
+ ,validate: function(value) {
+ this.guessType(this,value);
+ var ok = true;
+ if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
+ ok = false;
+ }
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ ok = false;
+ }
+ return ok;
+ }
+ ,guessType: function(v,str) {
+ v.string = str;
+ if(typeof(str) != "string") {
+ return;
+ }
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
+ }
+ }
+};
+if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
+ HxOverrides.now = performance.now.bind(performance);
+}
+String.__name__ = true;
+Array.__name__ = true;
+js_Boot.__toStr = ({ }).toString;
+xrfragment_Parser.error = "";
+xrfragment_Parser.debug = false;
+xrfragment_XRF.ASSET = 1;
+xrfragment_XRF.PROP_BIND = 2;
+xrfragment_XRF.QUERY_OPERATOR = 4;
+xrfragment_XRF.PROMPT = 8;
+xrfragment_XRF.ROUNDROBIN = 16;
+xrfragment_XRF.NAVIGATOR = 32;
+xrfragment_XRF.METADATA = 64;
+xrfragment_XRF.PV_OVERRIDE = 128;
+xrfragment_XRF.PV_EXECUTE = 256;
+xrfragment_XRF.T_COLOR = 8192;
+xrfragment_XRF.T_INT = 16384;
+xrfragment_XRF.T_FLOAT = 32768;
+xrfragment_XRF.T_VECTOR2 = 65536;
+xrfragment_XRF.T_VECTOR3 = 131072;
+xrfragment_XRF.T_URL = 262144;
+xrfragment_XRF.T_PREDEFINED_VIEW = 524288;
+xrfragment_XRF.T_STRING = 1048576;
+xrfragment_XRF.T_STRING_OBJ = 2097152;
+xrfragment_XRF.T_STRING_OBJ_PROP = 4194304;
+xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
+xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
+xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
+xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
+xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
+xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
+xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
})({});
var xrfragment = $hx_exports["xrfragment"];
export default xrfragment;
diff --git a/dist/xrfragment.php/lib/Array_hx.php b/dist/xrfragment.php/lib/Array_hx.php
deleted file mode 100644
index 436b010..0000000
--- a/dist/xrfragment.php/lib/Array_hx.php
+++ /dev/null
@@ -1,706 +0,0 @@
-arr = $arr;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:269: characters 3-31
- $a->length = count($arr);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:270: characters 3-11
- return $a;
- }
-
- /**
- * Creates a new Array.
- *
- * @return void
- */
- public function __construct () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:37: characters 9-36
- $this1 = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:37: characters 3-36
- $this->arr = $this1;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:38: characters 3-13
- $this->length = 0;
- }
-
- /**
- * Returns a new Array by appending the elements of `a` to the elements of
- * `this` Array.
- * This operation does not modify `this` Array.
- * If `a` is the empty Array `[]`, a copy of `this` Array is returned.
- * The length of the returned Array is equal to the sum of `this.length`
- * and `a.length`.
- * If `a` is `null`, the result is unspecified.
- *
- * @param mixed[]|Array_hx $a
- *
- * @return mixed[]|Array_hx
- */
- public function concat ($a) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:42: characters 3-46
- return Array_hx::wrap(array_merge($this->arr, $a->arr));
- }
-
- /**
- * Returns whether `this` Array contains `x`.
- * If `x` is found by checking standard equality, the function returns `true`, otherwise
- * the function returns `false`.
- *
- * @param mixed $x
- *
- * @return bool
- */
- public function contains ($x) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:60: characters 3-26
- return $this->indexOf($x) !== -1;
- }
-
- /**
- * Returns a shallow copy of `this` Array.
- * The elements are not copied and retain their identity, so
- * `a[i] == a.copy()[i]` is true for any valid `i`. However,
- * `a == a.copy()` is always false.
- *
- * @return mixed[]|Array_hx
- */
- public function copy () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:46: characters 3-28
- return (clone $this);
- }
-
- /**
- * @return int
- */
- #[\ReturnTypeWillChange]
- public function count () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:257: characters 3-16
- return $this->length;
- }
-
- /**
- * Returns an Array containing those elements of `this` for which `f`
- * returned true.
- * The individual elements are not duplicated and retain their identity.
- * If `f` is null, the result is unspecified.
- *
- * @param \Closure $f
- *
- * @return mixed[]|Array_hx
- */
- public function filter ($f) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:50: characters 3-35
- $result = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:51: characters 15-18
- $data = $this->arr;
- $_g_current = 0;
- $_g_length = count($data);
- $_g_data = $data;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:51: lines 51-55
- while ($_g_current < $_g_length) {
- $item = $_g_data[$_g_current++];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:52: lines 52-54
- if ($f($item)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:53: characters 5-22
- $result[] = $item;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:56: characters 3-22
- return Array_hx::wrap($result);
- }
-
- /**
- * @return \Traversable
- */
- #[\ReturnTypeWillChange]
- public function getIterator () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:250: characters 3-38
- return new \ArrayIterator($this->arr);
- }
-
- /**
- * Returns position of the first occurrence of `x` in `this` Array, searching front to back.
- * If `x` is found by checking standard equality, the function returns its index.
- * If `x` is not found, the function returns -1.
- * If `fromIndex` is specified, it will be used as the starting index to search from,
- * otherwise search starts with zero index. If it is negative, it will be taken as the
- * offset from the end of `this` Array to compute the starting index. If given or computed
- * starting index is less than 0, the whole array will be searched, if it is greater than
- * or equal to the length of `this` Array, the function returns -1.
- *
- * @param mixed $x
- * @param int $fromIndex
- *
- * @return int
- */
- public function indexOf ($x, $fromIndex = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:64: characters 7-69
- $tmp = null;
- if (($fromIndex === null) && !($x instanceof HxClosure)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:64: characters 53-69
- $value = $x;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:64: characters 7-69
- $tmp = !(is_int($value) || is_float($value));
- } else {
- $tmp = false;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:64: lines 64-71
- if ($tmp) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:65: characters 4-50
- $index = array_search($x, $this->arr, true);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:66: lines 66-70
- if ($index === false) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:67: characters 5-14
- return -1;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:69: characters 5-17
- return $index;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:72: lines 72-79
- if ($fromIndex === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:73: characters 4-17
- $fromIndex = 0;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:75: lines 75-76
- if ($fromIndex < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:76: characters 5-24
- $fromIndex += $this->length;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:77: lines 77-78
- if ($fromIndex < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:78: characters 5-18
- $fromIndex = 0;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:80: lines 80-84
- while ($fromIndex < $this->length) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:81: lines 81-82
- if (Boot::equal($this->arr[$fromIndex], $x)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:82: characters 5-21
- return $fromIndex;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:83: characters 4-15
- ++$fromIndex;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:85: characters 3-12
- return -1;
- }
-
- /**
- * Inserts the element `x` at the position `pos`.
- * This operation modifies `this` Array in place.
- * The offset is calculated like so:
- * - If `pos` exceeds `this.length`, the offset is `this.length`.
- * - If `pos` is negative, the offset is calculated from the end of `this`
- * Array, i.e. `this.length + pos`. If this yields a negative value, the
- * offset is 0.
- * - Otherwise, the offset is `pos`.
- * If the resulting offset does not exceed `this.length`, all elements from
- * and including that offset to the end of `this` Array are moved one index
- * ahead.
- *
- * @param int $pos
- * @param mixed $x
- *
- * @return void
- */
- public function insert ($pos, $x) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:89: characters 3-11
- $this->length++;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:90: characters 3-56
- array_splice($this->arr, $pos, 0, [$x]);
- }
-
- /**
- * Returns an iterator of the Array values.
- *
- * @return IteratorsArrayIterator
- */
- public function iterator () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:95: characters 3-48
- return new IteratorsArrayIterator($this);
- }
-
- /**
- * Returns a string representation of `this` Array, with `sep` separating
- * each element.
- * The result of this operation is equal to `Std.string(this[0]) + sep +
- * Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])`
- * If `this` is the empty Array `[]`, the result is the empty String `""`.
- * If `this` has exactly one element, the result is equal to a call to
- * `Std.string(this[0])`.
- * If `sep` is null, the result is unspecified.
- *
- * @param string $sep
- *
- * @return string
- */
- public function join ($sep) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:104: characters 3-98
- return implode($sep, array_map((Boot::class??'null') . "::stringify", $this->arr));
- }
-
- /**
- * @return mixed[]
- */
- #[\ReturnTypeWillChange]
- public function jsonSerialize () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:263: characters 3-13
- return $this->arr;
- }
-
- /**
- * Returns an iterator of the Array indices and values.
- *
- * @return ArrayKeyValueIterator
- */
- public function keyValueIterator () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:100: characters 3-41
- return new ArrayKeyValueIterator($this);
- }
-
- /**
- * Returns position of the last occurrence of `x` in `this` Array, searching back to front.
- * If `x` is found by checking standard equality, the function returns its index.
- * If `x` is not found, the function returns -1.
- * If `fromIndex` is specified, it will be used as the starting index to search from,
- * otherwise search starts with the last element index. If it is negative, it will be
- * taken as the offset from the end of `this` Array to compute the starting index. If
- * given or computed starting index is greater than or equal to the length of `this` Array,
- * the whole array will be searched, if it is less than 0, the function returns -1.
- *
- * @param mixed $x
- * @param int $fromIndex
- *
- * @return int
- */
- public function lastIndexOf ($x, $fromIndex = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:108: lines 108-109
- if (($fromIndex === null) || ($fromIndex >= $this->length)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:109: characters 4-26
- $fromIndex = $this->length - 1;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:110: lines 110-111
- if ($fromIndex < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:111: characters 4-23
- $fromIndex += $this->length;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:112: lines 112-116
- while ($fromIndex >= 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:113: lines 113-114
- if (Boot::equal($this->arr[$fromIndex], $x)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:114: characters 5-21
- return $fromIndex;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:115: characters 4-15
- --$fromIndex;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:117: characters 3-12
- return -1;
- }
-
- /**
- * Creates a new Array by applying function `f` to all elements of `this`.
- * The order of elements is preserved.
- * If `f` is null, the result is unspecified.
- *
- * @param \Closure $f
- *
- * @return mixed[]|Array_hx
- */
- public function map ($f) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:121: characters 3-35
- $result = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:122: characters 15-18
- $data = $this->arr;
- $_g_current = 0;
- $_g_length = count($data);
- $_g_data = $data;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:122: lines 122-124
- while ($_g_current < $_g_length) {
- $item = $_g_data[$_g_current++];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:123: characters 4-24
- $result[] = $f($item);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:125: characters 3-22
- return Array_hx::wrap($result);
- }
-
- /**
- * @param int $offset
- *
- * @return bool
- */
- #[\ReturnTypeWillChange]
- public function offsetExists ($offset) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:212: characters 3-25
- return $offset < $this->length;
- }
-
- /**
- * @param int $offset
- *
- * @return mixed
- */
- #[\ReturnTypeWillChange]
- public function &offsetGet ($offset) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:218: lines 218-222
- try {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:219: characters 4-22
- return $this->arr[$offset];
- } catch(\Throwable $_g) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:221: characters 4-15
- return null;
- }
- }
-
- /**
- * @param int $offset
- * @param mixed $value
- *
- * @return void
- */
- #[\ReturnTypeWillChange]
- public function offsetSet ($offset, $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:228: lines 228-233
- if ($this->length <= $offset) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:229: characters 13-19
- $_g = $this->length;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:229: characters 22-32
- $_g1 = $offset + 1;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:229: lines 229-231
- while ($_g < $_g1) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:229: characters 13-32
- $i = $_g++;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:230: characters 5-18
- $this->arr[$i] = null;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:232: characters 4-23
- $this->length = $offset + 1;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:234: characters 3-22
- $this->arr[$offset] = $value;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:235: characters 3-35
- return $value;
- }
-
- /**
- * @param int $offset
- *
- * @return void
- */
- #[\ReturnTypeWillChange]
- public function offsetUnset ($offset) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:241: lines 241-244
- if (($offset >= 0) && ($offset < $this->length)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:242: characters 4-39
- array_splice($this->arr, $offset, 1);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:243: characters 4-12
- --$this->length;
- }
- }
-
- /**
- * Removes the last element of `this` Array and returns it.
- * This operation modifies `this` Array in place.
- * If `this` has at least one element, `this.length` will decrease by 1.
- * If `this` is the empty Array `[]`, null is returned and the length
- * remains 0.
- *
- * @return mixed
- */
- public function pop () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:129: lines 129-130
- if ($this->length > 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:130: characters 4-12
- $this->length--;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:131: characters 3-31
- return array_pop($this->arr);
- }
-
- /**
- * Adds the element `x` at the end of `this` Array and returns the new
- * length of `this` Array.
- * This operation modifies `this` Array in place.
- * `this.length` increases by 1.
- *
- * @param mixed $x
- *
- * @return int
- */
- public function push ($x) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:135: characters 3-20
- $this->arr[$this->length++] = $x;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:136: characters 3-16
- return $this->length;
- }
-
- /**
- * Removes the first occurrence of `x` in `this` Array.
- * This operation modifies `this` Array in place.
- * If `x` is found by checking standard equality, it is removed from `this`
- * Array and all following elements are reindexed accordingly. The function
- * then returns true.
- * If `x` is not found, `this` Array is not changed and the function
- * returns false.
- *
- * @param mixed $x
- *
- * @return bool
- */
- public function remove ($x) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:140: characters 3-22
- $result = false;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:141: characters 16-20
- $_g = 0;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:141: characters 20-26
- $_g1 = $this->length;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:141: lines 141-148
- while ($_g < $_g1) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:141: characters 16-26
- $index = $_g++;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:142: lines 142-147
- if (Boot::equal($this->arr[$index], $x)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:143: characters 5-39
- array_splice($this->arr, $index, 1);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:144: characters 5-13
- $this->length--;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:145: characters 5-18
- $result = true;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:146: characters 5-10
- break;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:149: characters 3-16
- return $result;
- }
-
- /**
- * Set the length of the Array.
- * If `len` is shorter than the array's current size, the last
- * `length - len` elements will be removed. If `len` is longer, the Array
- * will be extended, with new elements set to a target-specific default
- * value:
- * - always null on dynamic targets
- * - 0, 0.0 or false for Int, Float and Bool respectively on static targets
- * - null for other types on static targets
- *
- * @param int $len
- *
- * @return void
- */
- public function resize ($len) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:201: lines 201-205
- if ($this->length < $len) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:202: characters 4-42
- $this->arr = array_pad($this->arr, $len, null);
- } else if ($this->length > $len) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:204: characters 4-47
- array_splice($this->arr, $len, $this->length - $len);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:206: characters 3-15
- $this->length = $len;
- }
-
- /**
- * Reverse the order of elements of `this` Array.
- * This operation modifies `this` Array in place.
- * If `this.length < 2`, `this` remains unchanged.
- *
- * @return void
- */
- public function reverse () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:153: characters 3-34
- $this->arr = array_reverse($this->arr);
- }
-
- /**
- * Removes the first element of `this` Array and returns it.
- * This operation modifies `this` Array in place.
- * If `this` has at least one element, `this`.length and the index of each
- * remaining element is decreased by 1.
- * If `this` is the empty Array `[]`, `null` is returned and the length
- * remains 0.
- *
- * @return mixed
- */
- public function shift () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:157: lines 157-158
- if ($this->length > 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:158: characters 4-12
- $this->length--;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:159: characters 3-33
- return array_shift($this->arr);
- }
-
- /**
- * Creates a shallow copy of the range of `this` Array, starting at and
- * including `pos`, up to but not including `end`.
- * This operation does not modify `this` Array.
- * The elements are not copied and retain their identity.
- * If `end` is omitted or exceeds `this.length`, it defaults to the end of
- * `this` Array.
- * If `pos` or `end` are negative, their offsets are calculated from the
- * end of `this` Array by `this.length + pos` and `this.length + end`
- * respectively. If this yields a negative value, 0 is used instead.
- * If `pos` exceeds `this.length` or if `end` is less than or equals
- * `pos`, the result is `[]`.
- *
- * @param int $pos
- * @param int $end
- *
- * @return mixed[]|Array_hx
- */
- public function slice ($pos, $end = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:163: lines 163-164
- if ($pos < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:164: characters 4-17
- $pos += $this->length;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:165: lines 165-166
- if ($pos < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:166: characters 4-11
- $pos = 0;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:167: lines 167-177
- if ($end === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:168: characters 4-45
- return Array_hx::wrap(array_slice($this->arr, $pos));
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:170: lines 170-171
- if ($end < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:171: characters 5-18
- $end += $this->length;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:172: lines 172-176
- if ($end <= $pos) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:173: characters 5-14
- return new Array_hx();
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:175: characters 5-57
- return Array_hx::wrap(array_slice($this->arr, $pos, $end - $pos));
- }
- }
- }
-
- /**
- * Sorts `this` Array according to the comparison function `f`, where
- * `f(x,y)` returns 0 if x == y, a positive Int if x > y and a
- * negative Int if x < y.
- * This operation modifies `this` Array in place.
- * The sort operation is not guaranteed to be stable, which means that the
- * order of equal elements may not be retained. For a stable Array sorting
- * algorithm, `haxe.ds.ArraySort.sort()` can be used instead.
- * If `f` is null, the result is unspecified.
- *
- * @param \Closure $f
- *
- * @return void
- */
- public function sort ($f) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:181: characters 3-15
- usort($this->arr, $f);
- }
-
- /**
- * Removes `len` elements from `this` Array, starting at and including
- * `pos`, an returns them.
- * This operation modifies `this` Array in place.
- * If `len` is < 0 or `pos` exceeds `this`.length, an empty Array [] is
- * returned and `this` Array is unchanged.
- * If `pos` is negative, its value is calculated from the end of `this`
- * Array by `this.length + pos`. If this yields a negative value, 0 is
- * used instead.
- * If the sum of the resulting values for `len` and `pos` exceed
- * `this.length`, this operation will affect the elements from `pos` to the
- * end of `this` Array.
- * The length of the returned Array is equal to the new length of `this`
- * Array subtracted from the original length of `this` Array. In other
- * words, each element of the original `this` Array either remains in
- * `this` Array or becomes an element of the returned Array.
- *
- * @param int $pos
- * @param int $len
- *
- * @return mixed[]|Array_hx
- */
- public function splice ($pos, $len) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:185: lines 185-186
- if ($len < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:186: characters 4-13
- return new Array_hx();
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:187: characters 3-57
- $result = Array_hx::wrap(array_splice($this->arr, $pos, $len));
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:188: characters 3-26
- $this->length -= $result->length;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:189: characters 3-16
- return $result;
- }
-
- /**
- * Returns a string representation of `this` Array.
- * The result will include the individual elements' String representations
- * separated by comma. The enclosing [ ] may be missing on some platforms,
- * use `Std.string()` to get a String representation that is consistent
- * across platforms.
- *
- * @return string
- */
- public function toString () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:197: characters 10-54
- $arr = $this->arr;
- $strings = [];
- foreach ($arr as $key => $value) {
- $strings[$key] = Boot::stringify($value, 9);
- }
- return "[" . (implode(",", $strings)??'null') . "]";
- }
-
- /**
- * Adds the element `x` at the start of `this` Array.
- * This operation modifies `this` Array in place.
- * `this.length` and the index of each Array element increases by 1.
- *
- * @param mixed $x
- *
- * @return void
- */
- public function unshift ($x) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Array.hx:193: characters 3-40
- $this->length = array_unshift($this->arr, $x);
- }
-
- public function __toString() {
- return $this->toString();
- }
-}
-
-Boot::registerClass(Array_hx::class, 'Array');
diff --git a/dist/xrfragment.php/lib/EReg.php b/dist/xrfragment.php/lib/EReg.php
deleted file mode 100644
index 79953b0..0000000
--- a/dist/xrfragment.php/lib/EReg.php
+++ /dev/null
@@ -1,147 +0,0 @@
-
- */
-final class EReg {
- /**
- * @var bool
- */
- public $global;
- /**
- * @var string
- */
- public $last;
- /**
- * @var array[]
- */
- public $matches;
- /**
- * @var string
- */
- public $options;
- /**
- * @var string
- */
- public $pattern;
- /**
- * @var string
- */
- public $re;
-
- /**
- * Creates a new regular expression with pattern `r` and modifiers `opt`.
- * This is equivalent to the shorthand syntax `~/r/opt`
- * If `r` or `opt` are null, the result is unspecified.
- *
- * @param string $r
- * @param string $opt
- *
- * @return void
- */
- public function __construct ($r, $opt) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:37: characters 3-19
- $this->pattern = $r;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:38: characters 3-45
- $this->options = str_replace("g", "", $opt);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:39: characters 3-26
- $this->global = $this->options !== $opt;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:40: characters 3-49
- $this->options = str_replace("u", "", $this->options);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:41: characters 3-68
- $this->re = "\"" . (str_replace("\"", "\\\"", $r)??'null') . "\"" . ($this->options??'null');
- }
-
- /**
- * @return void
- */
- public function handlePregError () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:63: characters 3-36
- $e = preg_last_error();
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:64: lines 64-72
- if ($e === PREG_INTERNAL_ERROR) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:65: characters 4-9
- throw HaxeException::thrown("EReg: internal PCRE error");
- } else if ($e === PREG_BACKTRACK_LIMIT_ERROR) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:67: characters 4-9
- throw HaxeException::thrown("EReg: backtrack limit");
- } else if ($e === PREG_RECURSION_LIMIT_ERROR) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:69: characters 4-9
- throw HaxeException::thrown("EReg: recursion limit");
- } else if ($e === PREG_JIT_STACKLIMIT_ERROR) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:71: characters 4-9
- throw HaxeException::thrown("failed due to limited JIT stack space");
- }
- }
-
- /**
- * Tells if `this` regular expression matches String `s`.
- * This method modifies the internal state.
- * If `s` is `null`, the result is unspecified.
- *
- * @param string $s
- *
- * @return bool
- */
- public function match ($s) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:45: characters 10-29
- $p = preg_match(($this->re . "u"), $s, $this->matches, PREG_OFFSET_CAPTURE, 0);
- if ($p === false) {
- $this->handlePregError();
- $p = preg_match($this->re, $s, $this->matches, PREG_OFFSET_CAPTURE);
- }
- if ($p > 0) {
- $this->last = $s;
- } else {
- $this->last = null;
- }
- return $p > 0;
- }
-
- /**
- * Splits String `s` at all substrings `this` EReg matches.
- * If a match is found at the start of `s`, the result contains a leading
- * empty String "" entry.
- * If a match is found at the end of `s`, the result contains a trailing
- * empty String "" entry.
- * If two matching substrings appear next to each other, the result
- * contains the empty String `""` between them.
- * By default, this method splits `s` into two parts at the first matched
- * substring. If the global g modifier is in place, `s` is split at each
- * matched substring.
- * If `s` is null, the result is unspecified.
- *
- * @param string $s
- *
- * @return string[]|\Array_hx
- */
- public function split ($s) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:128: characters 3-96
- $parts = preg_split(($this->re . "u"), $s, ($this->global ? -1 : 2));
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:129: lines 129-132
- if ($parts === false) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:130: characters 4-21
- $this->handlePregError();
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:131: characters 4-55
- $parts = preg_split($this->re, $s, ($this->global ? -1 : 2));
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/EReg.hx:133: characters 3-48
- return \Array_hx::wrap($parts);
- }
-}
-
-Boot::registerClass(EReg::class, 'EReg');
diff --git a/dist/xrfragment.php/lib/Reflect.php b/dist/xrfragment.php/lib/Reflect.php
deleted file mode 100644
index 4fb99d3..0000000
--- a/dist/xrfragment.php/lib/Reflect.php
+++ /dev/null
@@ -1,179 +0,0 @@
-{$field});
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:160: characters 4-15
- return true;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:162: characters 4-16
- return false;
- }
- }
-
- /**
- * Returns the value of the field named `field` on object `o`.
- * If `o` is not an object or has no field named `field`, the result is
- * null.
- * If the field is defined as a property, its accessors are ignored. Refer
- * to `Reflect.getProperty` for a function supporting property accessors.
- * If `field` is null, the result is unspecified.
- *
- * @param mixed $o
- * @param string $field
- *
- * @return mixed
- */
- public static function field ($o, $field) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:50: lines 50-52
- if (is_string($o)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:51: characters 24-45
- $tmp = Boot::dynamicString($o);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:51: characters 4-53
- return $tmp->{$field};
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:53: lines 53-54
- if (!is_object($o)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:54: characters 4-15
- return null;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:56: lines 56-58
- if (($field === "") && (PHP_VERSION_ID < 70100)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:57: characters 4-56
- return (((array)($o))[$field] ?? null);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:60: lines 60-62
- if (property_exists($o, $field)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:61: characters 4-33
- return $o->{$field};
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:63: lines 63-65
- if (method_exists($o, $field)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:64: characters 4-44
- return Boot::getInstanceClosure($o, $field);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:67: lines 67-78
- if (($o instanceof HxClass)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:68: characters 4-54
- $phpClassName = $o->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:69: lines 69-71
- if (defined("" . ($phpClassName??'null') . "::" . ($field??'null'))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:70: characters 5-52
- return constant("" . ($phpClassName??'null') . "::" . ($field??'null'));
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:72: lines 72-74
- if (property_exists($phpClassName, $field)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:73: characters 5-34
- return $o->{$field};
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:75: lines 75-77
- if (method_exists($phpClassName, $field)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:76: characters 5-54
- return Boot::getStaticClosure($phpClassName, $field);
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:80: characters 3-14
- return null;
- }
-
- /**
- * Returns the fields of structure `o`.
- * This method is only guaranteed to work on anonymous structures. Refer to
- * `Type.getInstanceFields` for a function supporting class instances.
- * If `o` is null, the result is unspecified.
- *
- * @param mixed $o
- *
- * @return string[]|\Array_hx
- */
- public static function fields ($o) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:117: lines 117-119
- if (is_object($o)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:118: characters 4-77
- return \Array_hx::wrap(array_keys(get_object_vars($o)));
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:120: characters 3-12
- return new \Array_hx();
- }
-
- /**
- * Tells if structure `o` has a field named `field`.
- * This is only guaranteed to work for anonymous structures. Refer to
- * `Type.getInstanceFields` for a function supporting class instances.
- * If `o` or `field` are null, the result is unspecified.
- *
- * @param mixed $o
- * @param string $field
- *
- * @return bool
- */
- public static function hasField ($o, $field) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:34: lines 34-35
- if (!is_object($o)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:35: characters 4-16
- return false;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:36: lines 36-37
- if (property_exists($o, $field)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:37: characters 4-15
- return true;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:39: lines 39-44
- if (($o instanceof HxClass)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:40: characters 4-54
- $phpClassName = $o->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:41: lines 41-43
- if (!(property_exists($phpClassName, $field) || method_exists($phpClassName, $field))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:43: characters 8-47
- return defined("" . ($phpClassName??'null') . "::" . ($field??'null'));
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:41: lines 41-43
- return true;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:46: characters 3-15
- return false;
- }
-
- /**
- * Sets the field named `field` of object `o` to value `value`.
- * If `o` has no field named `field`, this function is only guaranteed to
- * work for anonymous structures.
- * If `o` or `field` are null, the result is unspecified.
- *
- * @param mixed $o
- * @param string $field
- * @param mixed $value
- *
- * @return void
- */
- public static function setField ($o, $field, $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Reflect.hx:84: characters 3-35
- $o->{$field} = $value;
- }
-}
-
-Boot::registerClass(Reflect::class, 'Reflect');
diff --git a/dist/xrfragment.php/lib/Std.php b/dist/xrfragment.php/lib/Std.php
deleted file mode 100644
index 191c23a..0000000
--- a/dist/xrfragment.php/lib/Std.php
+++ /dev/null
@@ -1,125 +0,0 @@
-= 48) && ($charCode <= 57)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:87: characters 4-14
- return 0.0;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:89: characters 4-20
- return NAN;
- }
- }
-
- /**
- * Converts a `String` to an `Int`.
- * Leading whitespaces are ignored.
- * If `x` starts with 0x or 0X, hexadecimal notation is recognized where the following digits may
- * contain 0-9 and A-F.
- * Otherwise `x` is read as decimal number with 0-9 being allowed characters. `x` may also start with
- * a - to denote a negative value.
- * In decimal mode, parsing continues until an invalid character is detected, in which case the
- * result up to that point is returned. For hexadecimal notation, the effect of invalid characters
- * is unspecified.
- * Leading 0s that are not part of the 0x/0X hexadecimal notation are ignored, which means octal
- * notation is not supported.
- * If `x` is null, the result is unspecified.
- * If `x` cannot be parsed as integer, the result is `null`.
- *
- * @param string $x
- *
- * @return int
- */
- public static function parseInt ($x) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:55: lines 55-70
- if (is_numeric($x)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:56: characters 4-31
- return intval($x, 10);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:58: characters 4-23
- $x = ltrim($x);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:59: characters 4-54
- $firstCharIndex = (mb_substr($x, 0, 1) === "-" ? 1 : 0);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:60: characters 4-53
- $firstCharCode = HxString::charCodeAt($x, $firstCharIndex);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:61: lines 61-63
- if (!(($firstCharCode !== null) && ($firstCharCode >= 48) && ($firstCharCode <= 57))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:62: characters 5-16
- return null;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:64: characters 21-49
- $index = $firstCharIndex + 1;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:64: characters 4-50
- $secondChar = ($index < 0 ? "" : mb_substr($x, $index, 1));
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:65: lines 65-69
- if (($secondChar === "x") || ($secondChar === "X")) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:66: characters 5-31
- return intval($x, 0);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:68: characters 5-32
- return intval($x, 10);
- }
- }
- }
-
- /**
- * Converts any value to a String.
- * If `s` is of `String`, `Int`, `Float` or `Bool`, its value is returned.
- * If `s` is an instance of a class and that class or one of its parent classes has
- * a `toString` method, that method is called. If no such method is present, the result
- * is unspecified.
- * If `s` is an enum constructor without argument, the constructor's name is returned. If
- * arguments exists, the constructor's name followed by the String representations of
- * the arguments is returned.
- * If `s` is a structure, the field names along with their values are returned. The field order
- * and the operator separating field names and values are unspecified.
- * If s is null, "null" is returned.
- *
- * @param mixed $s
- *
- * @return string
- */
- public static function string ($s) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/Std.hx:47: characters 3-27
- return Boot::stringify($s);
- }
-}
-
-Boot::registerClass(Std::class, 'Std');
diff --git a/dist/xrfragment.php/lib/StringTools.php b/dist/xrfragment.php/lib/StringTools.php
deleted file mode 100644
index 120361d..0000000
--- a/dist/xrfragment.php/lib/StringTools.php
+++ /dev/null
@@ -1,40 +0,0 @@
- = null;
- * a.push(1); // generates target-specific null-pointer exception
- * } catch(e:haxe.Exception) {
- * throw e; // rethrows native exception instead of haxe.Exception
- * }
- * ```
- */
-class Exception extends \Exception {
- /**
- * @var \Throwable
- */
- public $__nativeException;
- /**
- * @var Exception
- */
- public $__previousException;
- /**
- * @var int
- */
- public $__skipStack;
-
- /**
- * @param mixed $value
- *
- * @return mixed
- */
- public static function thrown ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:30: lines 30-38
- if (($value instanceof Exception)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:31: characters 4-35
- return $value->get_native();
- } else if (($value instanceof \Throwable)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:33: characters 4-16
- return $value;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:35: characters 4-38
- $e = new ValueException($value);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:36: characters 4-21
- $e->__skipStack = 1;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:37: characters 4-12
- return $e;
- }
- }
-
- /**
- * Create a new Exception instance.
- * The `previous` argument could be used for exception chaining.
- * The `native` argument is for internal usage only.
- * There is no need to provide `native` argument manually and no need to keep it
- * upon extending `haxe.Exception` unless you know what you're doing.
- *
- * @param string $message
- * @param Exception $previous
- * @param mixed $native
- *
- * @return void
- */
- public function __construct ($message, $previous = null, $native = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:16: characters 39-40
- $this->__skipStack = 0;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:42: characters 3-30
- parent::__construct($message, 0, $previous);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:43: characters 3-38
- $this->__previousException = $previous;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:44: lines 44-48
- if (($native !== null) && ($native instanceof \Throwable)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:45: characters 4-30
- $this->__nativeException = $native;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:47: characters 4-33
- $this->__nativeException = $this;
- }
- }
-
- /**
- * @return mixed
- */
- final public function get_native () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/_std/haxe/Exception.hx:72: characters 3-27
- return $this->__nativeException;
- }
-}
-
-Boot::registerClass(Exception::class, 'haxe.Exception');
-Boot::registerGetters('haxe\\Exception', [
- 'native' => true
-]);
diff --git a/dist/xrfragment.php/lib/haxe/Log.php b/dist/xrfragment.php/lib/haxe/Log.php
deleted file mode 100644
index fbf9017..0000000
--- a/dist/xrfragment.php/lib/haxe/Log.php
+++ /dev/null
@@ -1,88 +0,0 @@
-fileName??'null') . ":" . ($infos->lineNumber??'null');
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:38: lines 38-40
- if ($infos->customParams !== null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:39: lines 39-40
- $_g = 0;
- $_g1 = $infos->customParams;
- while ($_g < $_g1->length) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:39: characters 9-10
- $v = ($_g1->arr[$_g] ?? null);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:39: lines 39-40
- ++$_g;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:40: characters 5-32
- $str = ($str??'null') . ", " . \Std::string($v);
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:41: characters 3-27
- return ($pstr??'null') . ": " . ($str??'null');
- }
-
- /**
- * @internal
- * @access private
- */
- static public function __hx__init ()
- {
- static $called = false;
- if ($called) return;
- $called = true;
-
-
- self::$trace = function ($v, $infos = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:63: characters 3-36
- $str = Log::formatOutput($v, $infos);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/Log.hx:70: characters 3-19
- echo(\Std::string($str) . \PHP_EOL);
- };
- }
-}
-
-Boot::registerClass(Log::class, 'haxe.Log');
-Log::__hx__init();
diff --git a/dist/xrfragment.php/lib/haxe/ValueException.php b/dist/xrfragment.php/lib/haxe/ValueException.php
deleted file mode 100644
index 1aec3dc..0000000
--- a/dist/xrfragment.php/lib/haxe/ValueException.php
+++ /dev/null
@@ -1,44 +0,0 @@
-value = $value;
- }
-}
-
-Boot::registerClass(ValueException::class, 'haxe.ValueException');
diff --git a/dist/xrfragment.php/lib/haxe/iterators/ArrayIterator.php b/dist/xrfragment.php/lib/haxe/iterators/ArrayIterator.php
deleted file mode 100644
index 271c2a1..0000000
--- a/dist/xrfragment.php/lib/haxe/iterators/ArrayIterator.php
+++ /dev/null
@@ -1,57 +0,0 @@
-` is passed to `Iterable`
- */
-class ArrayIterator {
- /**
- * @var mixed[]|\Array_hx
- */
- public $array;
- /**
- * @var int
- */
- public $current;
-
- /**
- * Create a new `ArrayIterator`.
- *
- * @param mixed[]|\Array_hx $array
- *
- * @return void
- */
- public function __construct ($array) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/iterators/ArrayIterator.hx:30: characters 20-21
- $this->current = 0;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/iterators/ArrayIterator.hx:37: characters 3-21
- $this->array = $array;
- }
-
- /**
- * See `Iterator.hasNext`
- *
- * @return bool
- */
- public function hasNext () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/iterators/ArrayIterator.hx:45: characters 3-32
- return $this->current < $this->array->length;
- }
-
- /**
- * See `Iterator.next`
- *
- * @return mixed
- */
- public function next () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/haxe/iterators/ArrayIterator.hx:53: characters 3-26
- return ($this->array->arr[$this->current++] ?? null);
- }
-}
-
-Boot::registerClass(ArrayIterator::class, 'haxe.iterators.ArrayIterator');
diff --git a/dist/xrfragment.php/lib/haxe/iterators/ArrayKeyValueIterator.php b/dist/xrfragment.php/lib/haxe/iterators/ArrayKeyValueIterator.php
deleted file mode 100644
index 5cfa71b..0000000
--- a/dist/xrfragment.php/lib/haxe/iterators/ArrayKeyValueIterator.php
+++ /dev/null
@@ -1,26 +0,0 @@
-array = $array;
- }
-}
-
-Boot::registerClass(ArrayKeyValueIterator::class, 'haxe.iterators.ArrayKeyValueIterator');
diff --git a/dist/xrfragment.php/lib/php/Boot.php b/dist/xrfragment.php/lib/php/Boot.php
deleted file mode 100644
index bd62529..0000000
--- a/dist/xrfragment.php/lib/php/Boot.php
+++ /dev/null
@@ -1,1190 +0,0 @@
-PHP compatibility utilities.
- * You should not use this class directly.
- */
-class Boot {
- const PHP_PREFIX = "";
-
- /**
- * @var array
- * List of Haxe classes registered by their PHP class names
- */
- static protected $aliases;
- /**
- * @var array
- * Cache of HxClass instances
- */
- static protected $classes;
- /**
- * @var array
- * List of getters (for Reflect)
- */
- static protected $getters;
- /**
- * @var array
- * Metadata storage
- */
- static protected $meta;
- /**
- * @var array
- * List of setters (for Reflect)
- */
- static protected $setters;
- /**
- * @var array
- * Cache for closures created of static methods
- */
- static protected $staticClosures;
-
- /**
- * Concat `left` and `right` if both are strings or string and null.
- * Otherwise return sum of `left` and `right`.
- *
- * @param mixed $left
- * @param mixed $right
- *
- * @return mixed
- */
- public static function addOrConcat ($left, $right) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:452: lines 452-454
- if (\is_string($left) || \is_string($right)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:453: characters 4-45
- return ($left??'null') . ($right??'null');
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:455: characters 3-33
- return ($left + $right);
- }
-
- /**
- * Unsafe cast to HxClass
- *
- * @param Class $cls
- *
- * @return HxClass
- */
- public static function castClass ($cls) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:301: characters 3-18
- return $cls;
- }
-
- /**
- * Unsafe cast to HxClosure
- *
- * @param mixed $value
- *
- * @return HxClosure
- */
- public static function castClosure ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:294: characters 3-15
- return $value;
- }
-
- /**
- * Unsafe cast to HxEnum
- *
- * @param mixed $enm
- *
- * @return HxEnum
- */
- public static function castEnumValue ($enm) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:308: characters 3-18
- return $enm;
- }
-
- /**
- * Creates Haxe-compatible closure.
- * @param type `this` for instance methods; full php class name for static methods
- * @param func Method name
- *
- * @param mixed $target
- * @param string $func
- *
- * @return HxClosure
- */
- public static function closure ($target, $func) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:634: characters 10-96
- if (\is_string($target)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:634: characters 31-61
- return Boot::getStaticClosure($target, $func);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:634: characters 64-96
- return Boot::getInstanceClosure($target, $func);
- }
- }
-
- /**
- * Returns `Class` for `HxClosure`
- *
- * @return HxClass
- */
- public static function closureHxClass () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:315: characters 3-24
- return Boot::getClass(HxClosure::class);
- }
-
- /**
- * Create Haxe-compatible anonymous structure of `data` associative array
- *
- * @param array $data
- *
- * @return mixed
- */
- public static function createAnon ($data) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:563: characters 3-24
- $o = new HxAnon();
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:564: characters 3-86
- foreach ($data as $key => $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:564: characters 53-85
- $o->{$key} = $value;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:565: characters 3-11
- return $o;
- }
-
- /**
- * Helper method to avoid "Cannot use temporary expression in write context" error for expressions like this:
- * ```haxe
- * (new MyClass()).fieldName = 'value';
- * ```
- *
- * @param mixed $value
- *
- * @return mixed
- */
- public static function deref ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:556: characters 3-15
- return $value;
- }
-
- /**
- * @param float $value
- *
- * @return float
- */
- public static function divByZero ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:654: characters 10-71
- if (Boot::equal($value, 0)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:654: characters 23-32
- return \NAN;
- } else if ($value < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:654: characters 48-58
- return -\INF;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:654: characters 61-70
- return \INF;
- }
- }
-
- /**
- * Get `field` of a dynamic `value` in a safe manner (avoid exceptions on trying to get a method)
- *
- * @param mixed $value
- * @param string $field
- *
- * @return mixed
- */
- public static function dynamicField ($value, $field) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:579: lines 579-581
- if (\method_exists($value, $field)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:580: characters 11-32
- if (\is_string($value)) {
- return Boot::getStaticClosure($value, $field);
- } else {
- return Boot::getInstanceClosure($value, $field);
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:582: lines 582-584
- if (\is_string($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:583: characters 4-51
- $value = new HxDynamicStr($value);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:585: characters 3-36
- return $value->{$field};
- }
-
- /**
- * @param string $str
- *
- * @return HxDynamicStr
- */
- public static function dynamicString ($str) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:589: characters 3-47
- return new HxDynamicStr($str);
- }
-
- /**
- * Make sure specified class is loaded
- *
- * @param string $phpClassName
- *
- * @return bool
- */
- public static function ensureLoaded ($phpClassName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:572: characters 10-84
- if (!\class_exists($phpClassName)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:572: characters 47-84
- return \interface_exists($phpClassName);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:572: characters 10-84
- return true;
- }
- }
-
- /**
- * Check if specified values are equal
- *
- * @param mixed $left
- * @param mixed $right
- *
- * @return bool
- */
- public static function equal ($left, $right) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:438: lines 438-440
- if ((\is_int($left) || \is_float($left)) && (\is_int($right) || \is_float($right))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:439: characters 4-36
- return ($left == $right);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:441: lines 441-443
- if (($left instanceof HxClosure) && ($right instanceof HxClosure)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:442: characters 4-43
- return $left->equals($right);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:444: characters 3-41
- return ($left === $right);
- }
-
- /**
- * Get Class instance for PHP fully qualified class name (E.g. '\some\pack\MyClass')
- * It's always the same instance for the same `phpClassName`
- *
- * @param string $phpClassName
- *
- * @return HxClass
- */
- public static function getClass ($phpClassName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:185: lines 185-187
- if (\mb_substr($phpClassName, 0, 1) === "\\") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:186: characters 19-41
- $phpClassName = \mb_substr($phpClassName, 1, null);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:188: lines 188-190
- if (!isset(Boot::$classes[$phpClassName])) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:189: characters 4-53
- $val = new HxClass($phpClassName);
- Boot::$classes[$phpClassName] = $val;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:192: characters 3-31
- return Boot::$classes[$phpClassName];
- }
-
- /**
- * Returns either Haxe class name for specified `phpClassName` or (if no such Haxe class registered) `phpClassName`.
- *
- * @param string $phpClassName
- *
- * @return string
- */
- public static function getClassName ($phpClassName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:220: characters 3-40
- $hxClass = Boot::getClass($phpClassName);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:221: characters 3-35
- $name = Boot::getHaxeName($hxClass);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:222: characters 10-54
- if ($name === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:222: characters 26-46
- return $hxClass->phpClassName;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:222: characters 49-53
- return $name;
- }
- }
-
- /**
- * Returns original Haxe fully qualified class name for this type (if exists)
- *
- * @param HxClass $hxClass
- *
- * @return string
- */
- public static function getHaxeName ($hxClass) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:229: characters 11-31
- $__hx__switch = ($hxClass->phpClassName);
- if ($__hx__switch === "Bool") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:235: characters 5-18
- return "Bool";
- } else if ($__hx__switch === "Class") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:239: characters 5-19
- return "Class";
- } else if ($__hx__switch === "Dynamic") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:243: characters 5-21
- return "Dynamic";
- } else if ($__hx__switch === "Enum") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:241: characters 5-18
- return "Enum";
- } else if ($__hx__switch === "Float") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:237: characters 5-19
- return "Float";
- } else if ($__hx__switch === "Int") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:231: characters 5-17
- return "Int";
- } else if ($__hx__switch === "String") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:233: characters 5-20
- return "String";
- } else {
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:250: lines 250-256
- if (isset(Boot::$aliases[$hxClass->phpClassName])) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:251: characters 4-40
- return Boot::$aliases[$hxClass->phpClassName];
- } else if (\class_exists($hxClass->phpClassName) && isset(Boot::$aliases[$hxClass->phpClassName])) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:253: characters 4-40
- return Boot::$aliases[$hxClass->phpClassName];
- } else if (\interface_exists($hxClass->phpClassName) && isset(Boot::$aliases[$hxClass->phpClassName])) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:255: characters 4-40
- return Boot::$aliases[$hxClass->phpClassName];
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:258: characters 3-14
- return null;
- }
-
- /**
- * Returns Class
- *
- * @return HxClass
- */
- public static function getHxAnon () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:199: characters 3-21
- return Boot::getClass(HxAnon::class);
- }
-
- /**
- * Returns Class
- *
- * @return HxClass
- */
- public static function getHxClass () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:213: characters 3-22
- return Boot::getClass(HxClass::class);
- }
-
- /**
- * Creates Haxe-compatible closure of an instance method.
- * @param obj - any object
- *
- * @param object $obj
- * @param string $methodName
- *
- * @return HxClosure
- */
- public static function getInstanceClosure ($obj, $methodName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:597: characters 3-73
- $result = ($obj->__hx_closureCache[$methodName] ?? null);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:598: lines 598-600
- if ($result !== null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:599: characters 4-17
- return $result;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:601: lines 601-603
- if (!\method_exists($obj, $methodName) && !isset($obj->{$methodName})) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:602: characters 4-15
- return null;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:604: characters 3-42
- $result = new HxClosure($obj, $methodName);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:605: lines 605-607
- if (!\property_exists($obj, "__hx_closureCache")) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:606: characters 28-50
- $this1 = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:606: characters 4-50
- $obj->__hx_closureCache = $this1;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:608: characters 3-45
- $obj->__hx_closureCache[$methodName] = $result;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:609: characters 3-16
- return $result;
- }
-
- /**
- * Retrieve metadata for specified class
- *
- * @param string $phpClassName
- *
- * @return mixed
- */
- public static function getMeta ($phpClassName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:151: characters 3-46
- if (!(\class_exists($phpClassName) || \interface_exists($phpClassName))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:151: characters 35-46
- return null;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:152: characters 10-70
- if (isset(Boot::$meta[$phpClassName])) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:152: characters 45-63
- return Boot::$meta[$phpClassName];
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:152: characters 66-70
- return null;
- }
- }
-
- /**
- * Find corresponding PHP class name.
- * Returns `null` if specified class does not exist.
- *
- * @param string $haxeName
- *
- * @return string
- */
- public static function getPhpName ($haxeName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:266: characters 3-28
- $prefix = Boot::getPrefix();
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:267: characters 3-63
- $phpParts = (\strlen($prefix) === 0 ? new \Array_hx() : \Array_hx::wrap([$prefix]));
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:269: characters 3-39
- $haxeParts = HxString::split($haxeName, ".");
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:270: lines 270-275
- $_g = 0;
- while ($_g < $haxeParts->length) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:270: characters 8-12
- $part = ($haxeParts->arr[$_g] ?? null);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:270: lines 270-275
- ++$_g;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:271: lines 271-273
- if (Boot::isPhpKeyword($part)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:272: characters 5-18
- $part = ($part??'null') . "_hx";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:274: characters 4-23
- $phpParts->arr[$phpParts->length++] = $part;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:277: characters 3-29
- return $phpParts->join("\\");
- }
-
- /**
- * Returns root namespace based on a value of `-D php-prefix=value` compiler flag.
- * Returns empty string if no `-D php-prefix=value` provided.
- *
- * @return string
- */
- public static function getPrefix () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:89: characters 3-41
- return self::PHP_PREFIX;
- }
-
- /**
- * Returns a list of phpName=>haxeName for currently loaded haxe-generated classes.
- *
- * @return array
- */
- public static function getRegisteredAliases () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:177: characters 3-17
- return Boot::$aliases;
- }
-
- /**
- * Returns a list of currently loaded haxe-generated classes.
- *
- * @return Class[]|\Array_hx
- */
- public static function getRegisteredClasses () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:166: characters 3-19
- $result = new \Array_hx();
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:167: lines 167-169
- $collection = Boot::$aliases;
- foreach ($collection as $key => $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:168: characters 4-39
- $x = Boot::getClass($key);
- $result->arr[$result->length++] = $x;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:170: characters 3-16
- return $result;
- }
-
- /**
- * Creates Haxe-compatible closure of a static method.
- *
- * @param string $phpClassName
- * @param string $methodName
- *
- * @return HxClosure
- */
- public static function getStaticClosure ($phpClassName, $methodName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:616: characters 3-80
- $result = (Boot::$staticClosures[$phpClassName][$methodName] ?? null);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:617: lines 617-619
- if ($result !== null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:618: characters 4-17
- return $result;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:620: characters 3-51
- $result = new HxClosure($phpClassName, $methodName);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:621: lines 621-623
- if (!\array_key_exists($phpClassName, Boot::$staticClosures)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:622: characters 35-57
- $this1 = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:622: characters 4-57
- Boot::$staticClosures[$phpClassName] = $this1;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:624: characters 3-52
- Boot::$staticClosures[$phpClassName][$methodName] = $result;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:625: characters 3-16
- return $result;
- }
-
- /**
- * Check if specified property has getter
- *
- * @param string $phpClassName
- * @param string $property
- *
- * @return bool
- */
- public static function hasGetter ($phpClassName, $property) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:110: lines 110-111
- if (!(\class_exists($phpClassName) || \interface_exists($phpClassName))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:111: characters 4-16
- return false;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:113: characters 3-19
- $has = false;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:114: characters 3-72
- $phpClassName1 = $phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:115: lines 115-118
- while (true) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:116: characters 4-55
- $has = isset(Boot::$getters[$phpClassName1][$property]);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:117: characters 4-56
- $phpClassName1 = \get_parent_class($phpClassName1);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:115: lines 115-118
- if (!(!$has && ($phpClassName1 !== false) && \class_exists($phpClassName1))) {
- break;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:120: characters 3-13
- return $has;
- }
-
- /**
- * Check if specified property has setter
- *
- * @param string $phpClassName
- * @param string $property
- *
- * @return bool
- */
- public static function hasSetter ($phpClassName, $property) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:127: lines 127-128
- if (!(\class_exists($phpClassName) || \interface_exists($phpClassName))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:128: characters 4-16
- return false;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:130: characters 3-19
- $has = false;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:131: characters 3-72
- $phpClassName1 = $phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:132: lines 132-135
- while (true) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:133: characters 4-55
- $has = isset(Boot::$setters[$phpClassName1][$property]);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:134: characters 4-56
- $phpClassName1 = \get_parent_class($phpClassName1);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:132: lines 132-135
- if (!(!$has && ($phpClassName1 !== false) && \class_exists($phpClassName1))) {
- break;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:137: characters 3-13
- return $has;
- }
-
- /**
- * @param mixed $value
- * @param HxClass $type
- *
- * @return bool
- */
- public static function is ($value, $type) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:460: characters 3-31
- return Boot::isOfType($value, $type);
- }
-
- /**
- * Check if provided value is an anonymous object
- *
- * @param mixed $v
- *
- * @return bool
- */
- public static function isAnon ($v) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:206: characters 3-33
- return ($v instanceof HxAnon);
- }
-
- /**
- * Check if `value` is a `Class`
- *
- * @param mixed $value
- *
- * @return bool
- */
- public static function isClass ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:512: characters 3-38
- return ($value instanceof HxClass);
- }
-
- /**
- * Check if `value` is an enum constructor instance
- *
- * @param mixed $value
- *
- * @return bool
- */
- public static function isEnumValue ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:519: characters 3-37
- return ($value instanceof HxEnum);
- }
-
- /**
- * Check if `value` is a function
- *
- * @param mixed $value
- *
- * @return bool
- */
- public static function isFunction ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:526: characters 10-72
- if (!($value instanceof \Closure)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:526: characters 42-72
- return ($value instanceof HxClosure);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:526: characters 10-72
- return true;
- }
- }
-
- /**
- * Check if `value` is an instance of `HxClosure`
- *
- * @param mixed $value
- *
- * @return bool
- */
- public static function isHxClosure ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:533: characters 3-40
- return ($value instanceof HxClosure);
- }
-
- /**
- * @param mixed $value
- *
- * @return bool
- */
- public static function isNumber ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:431: characters 10-44
- if (!\is_int($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:431: characters 28-44
- return \is_float($value);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:431: characters 10-44
- return true;
- }
- }
-
- /**
- * `Std.isOfType()` implementation
- *
- * @param mixed $value
- * @param HxClass $type
- *
- * @return bool
- */
- public static function isOfType ($value, $type) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:467: lines 467-468
- if ($type === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:468: characters 4-16
- return false;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:470: characters 3-35
- $phpType = $type->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:478: lines 478-504
- if ($phpType === "Bool") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:487: characters 5-27
- return \is_bool($value);
- } else if ($phpType === "Dynamic") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:480: characters 5-25
- return $value !== null;
- } else if ($phpType === "Class" || $phpType === "Enum") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:493: lines 493-498
- if (($value instanceof HxClass)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:494: characters 6-62
- $valuePhpClass = $value->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:495: characters 6-62
- $enumPhpClass = Boot::getClass(HxEnum::class)->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:496: characters 6-74
- $isEnumType = \is_subclass_of($valuePhpClass, $enumPhpClass);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:497: characters 13-59
- if ($phpType === "Enum") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:497: characters 34-44
- return $isEnumType;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:497: characters 47-58
- return !$isEnumType;
- }
- }
- } else if ($phpType === "Float") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:485: characters 12-46
- if (!\is_float($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:485: characters 32-46
- return \is_int($value);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:485: characters 12-46
- return true;
- }
- } else if ($phpType === "Int") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:482: lines 482-483
- if (\is_int($value) || (\is_float($value) && ((int)($value) == $value) && !\is_nan($value))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:483: characters 9-40
- return \abs($value) <= 2147483648;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:482: lines 482-483
- return false;
- }
- } else if ($phpType === "String") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:489: characters 5-29
- return \is_string($value);
- } else if ($phpType === "php\\NativeArray" || $phpType === "php\\_NativeArray\\NativeArray_Impl_") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:491: characters 5-28
- return \is_array($value);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:500: lines 500-503
- if (\is_object($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:501: characters 6-42
- $type1 = $type;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:502: characters 6-43
- return ($value instanceof $type1->phpClassName);
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:505: characters 3-15
- return false;
- }
-
- /**
- * Check if the value of `str` is a reserved keyword in PHP
- * @see https://www.php.net/manual/en/reserved.keywords.php
- *
- * @param string $str
- *
- * @return bool
- */
- public static function isPhpKeyword ($str) {
- switch(strtolower($str)) {
- case '__halt_compiler': case 'abstract': case 'and': case 'array': case 'as': case 'break':
- case 'callable': case 'case': case 'catch': case 'class': case 'clone': case 'const': case 'continue':
- case 'declare': case 'default': case 'die': case 'do': case 'echo': case 'else': case 'elseif':
- case 'empty': case 'enddeclare': case 'endfor': case 'endforeach': case 'endif': case 'endswitch': case 'endwhile':
- case 'eval': case 'exit': case 'extends': case 'final': case 'finally': case 'for': case 'foreach':
- case 'function': case 'global': case 'goto': case 'if': case 'implements': case 'include': case 'include_once':
- case 'instanceof': case 'insteadof': case 'interface': case 'isset': case 'list': case 'namespace': case 'new':
- case 'or': case 'print': case 'private': case 'protected': case 'public': case 'require': case 'require_once':
- case 'return': case 'static': case 'switch': case 'throw': case 'trait': case 'try': case 'unset':
- case 'use': case 'var': case 'while': case 'xor': case 'yield': case '__class__': case '__dir__':
- case '__file__': case '__function__': case '__line__': case '__method__': case '__trait__': case '__namespace__': case 'int':
- case 'float': case 'bool': case 'string': case 'true': case 'false': case 'null': case 'parent':
- case 'void': case 'iterable': case 'object': case 'fn':
- return true;
- default:
- return false;
- }
- }
-
- /**
- * Associate PHP class name with Haxe class name
- *
- * @param string $phpClassName
- * @param string $haxeClassName
- *
- * @return void
- */
- public static function registerClass ($phpClassName, $haxeClassName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:159: characters 3-40
- Boot::$aliases[$phpClassName] = $haxeClassName;
- }
-
- /**
- * Register list of getters to be able to call getters using reflection
- *
- * @param string $phpClassName
- * @param array $list
- *
- * @return void
- */
- public static function registerGetters ($phpClassName, $list) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:96: characters 3-31
- Boot::$getters[$phpClassName] = $list;
- }
-
- /**
- * Save metadata for specified class
- *
- * @param string $phpClassName
- * @param mixed $data
- *
- * @return void
- */
- public static function registerMeta ($phpClassName, $data) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:144: characters 3-28
- Boot::$meta[$phpClassName] = $data;
- }
-
- /**
- * Register list of setters to be able to call getters using reflection
- *
- * @param string $phpClassName
- * @param array $list
- *
- * @return void
- */
- public static function registerSetters ($phpClassName, $list) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:103: characters 3-31
- Boot::$setters[$phpClassName] = $list;
- }
-
- /**
- * Performs `left >>> right` operation
- *
- * @param int $left
- * @param int $right
- *
- * @return int
- */
- public static function shiftRightUnsigned ($left, $right) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:540: lines 540-546
- if ($right === 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:541: characters 4-15
- return $left;
- } else if ($left >= 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:543: characters 4-82
- return ($left >> $right) & ~((1 << (8 * \PHP_INT_SIZE - 1)) >> ($right - 1));
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:545: characters 4-56
- return ($left >> $right) & (2147483647 >> ($right - 1));
- }
- }
-
- /**
- * Returns string representation of `value`
- *
- * @param mixed $value
- * @param int $maxRecursion
- *
- * @return string
- */
- public static function stringify ($value, $maxRecursion = 10) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:357: lines 357-420
- if ($maxRecursion === null) {
- $maxRecursion = 10;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:358: lines 358-360
- if ($maxRecursion <= 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:359: characters 4-18
- return "<...>";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:361: lines 361-363
- if ($value === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:362: characters 4-17
- return "null";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:364: lines 364-366
- if (\is_string($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:365: characters 4-16
- return $value;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:367: lines 367-369
- if (\is_int($value) || \is_float($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:368: characters 4-31
- return (string)($value);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:370: lines 370-372
- if (\is_bool($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:371: characters 11-35
- if ($value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:371: characters 20-24
- return "true";
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:371: characters 29-34
- return "false";
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:373: lines 373-379
- if (\is_array($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:374: characters 4-37
- $strings = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:375: lines 375-377
- $collection = $value;
- foreach ($collection as $key => $value1) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:376: characters 5-82
- $strings[] = (((string)($key)??'null') . " => " . (Boot::stringify($value1, $maxRecursion - 1)??'null'));
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:378: characters 4-52
- return "[" . (\implode(", ", $strings)??'null') . "]";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:380: lines 380-418
- if (\is_object($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:381: lines 381-383
- if (($value instanceof \Array_hx)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:382: characters 5-75
- return Boot::stringifyNativeIndexedArray(Boot::dynamicField($value, 'arr'), $maxRecursion - 1);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:384: lines 384-392
- if (($value instanceof HxEnum)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:385: characters 5-26
- $e = $value;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:386: characters 5-24
- $result = $e->tag;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:387: lines 387-390
- if (\count($e->params) > 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:388: characters 6-109
- $strings = \array_map(function ($item) use (&$maxRecursion) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:388: characters 52-97
- return Boot::stringify($item, $maxRecursion - 1);
- }, $e->params);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:389: characters 6-56
- $result = ($result??'null') . "(" . (\implode(",", $strings)??'null') . ")";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:391: characters 5-18
- return $result;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:393: lines 393-395
- if (\method_exists($value, "toString")) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:394: characters 5-28
- return HxDynamicStr::wrap($value)->toString();
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:396: lines 396-398
- if (\method_exists($value, "__toString")) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:397: characters 5-30
- return $value->__toString();
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:399: lines 399-409
- if (($value instanceof \StdClass)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:400: lines 400-402
- if (isset($value->toString) && \is_callable(Boot::dynamicField($value, 'toString'))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:401: characters 6-29
- return HxDynamicStr::wrap($value)->toString();
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:403: characters 18-50
- $this1 = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:403: characters 5-51
- $result = $this1;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:404: characters 5-46
- $data = \get_object_vars($value);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:405: characters 17-34
- $data1 = \array_keys($data);
- $_g_current = 0;
- $_g_length = \count($data1);
- $_g_data = $data1;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:405: lines 405-407
- while ($_g_current < $_g_length) {
- $key = $_g_data[$_g_current++];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:406: characters 6-75
- \array_push($result, "" . ($key??'null') . " : " . (Boot::stringify($data[$key], $maxRecursion - 1)??'null'));
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:408: characters 5-54
- return "{ " . (\implode(", ", $result)??'null') . " }";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:410: lines 410-412
- if (($value instanceof \Closure) || ($value instanceof HxClosure)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:411: characters 5-24
- return "";
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:413: lines 413-417
- if (($value instanceof HxClass)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:414: characters 5-74
- return "[class " . (Boot::getClassName($value->phpClassName)??'null') . "]";
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:416: characters 5-68
- return "[object " . (Boot::getClassName(\get_class($value))??'null') . "]";
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:419: characters 3-8
- throw Exception::thrown("Unable to stringify value");
- }
-
- /**
- * @param mixed[] $arr
- * @param int $maxRecursion
- *
- * @return string
- */
- public static function stringifyNativeIndexedArray ($arr, $maxRecursion = 10) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:422: lines 422-428
- if ($maxRecursion === null) {
- $maxRecursion = 10;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:423: characters 3-36
- $strings = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:424: lines 424-426
- foreach ($arr as $key => $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:425: characters 4-60
- $strings[$key] = Boot::stringify($value, $maxRecursion - 1);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:427: characters 3-50
- return "[" . (\implode(",", $strings)??'null') . "]";
- }
-
- /**
- * Implementation for `cast(value, Class)`
- * @throws haxe.ValueError if `value` cannot be casted to this type
- *
- * @param HxClass $hxClass
- * @param mixed $value
- *
- * @return mixed
- */
- public static function typedCast ($hxClass, $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:323: lines 323-324
- if ($value === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:324: characters 4-15
- return null;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:325: characters 11-31
- $__hx__switch = ($hxClass->phpClassName);
- if ($__hx__switch === "Bool") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:335: lines 335-337
- if (\is_bool($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:336: characters 6-18
- return $value;
- }
- } else if ($__hx__switch === "Float") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:331: lines 331-333
- if (\is_int($value) || \is_float($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:332: characters 6-29
- return \floatval($value);
- }
- } else if ($__hx__switch === "Int") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:327: lines 327-329
- if (\is_int($value) || \is_float($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:328: characters 6-33
- return \intval($value);
- }
- } else if ($__hx__switch === "String") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:339: lines 339-341
- if (\is_string($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:340: characters 6-18
- return $value;
- }
- } else if ($__hx__switch === "array") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:343: lines 343-345
- if (\is_array($value)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:344: characters 6-18
- return $value;
- }
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:347: lines 347-349
- if (\is_object($value) && Boot::isOfType($value, $hxClass)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:348: characters 6-18
- return $value;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:351: characters 3-8
- throw Exception::thrown("Cannot cast " . \Std::string($value) . " to " . (Boot::getClassName($hxClass->phpClassName)??'null'));
- }
-
- /**
- * Get UTF-8 code of the first character in `s` without any checks
- *
- * @param mixed $s
- *
- * @return int
- */
- public static function unsafeOrd ($s) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:641: characters 3-31
- $code = \ord($s[0]);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:642: lines 642-650
- if ($code < 192) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:643: characters 4-15
- return $code;
- } else if ($code < 224) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:645: characters 4-57
- return (($code - 192) << 6) + \ord($s[1]) - 128;
- } else if ($code < 240) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:647: characters 4-93
- return (($code - 224) << 12) + ((\ord($s[1]) - 128) << 6) + \ord($s[2]) - 128;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:649: characters 4-129
- return (($code - 240) << 18) + ((\ord($s[1]) - 128) << 12) + ((\ord($s[2]) - 128) << 6) + \ord($s[3]) - 128;
- }
- }
-
- /**
- * @internal
- * @access private
- */
- static public function __hx__init ()
- {
- static $called = false;
- if ($called) return;
- $called = true;
-
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:60: characters 3-39
- \mb_internal_encoding("UTF-8");
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:61: lines 61-81
- if (!\defined("HAXE_CUSTOM_ERROR_HANDLER") || !\HAXE_CUSTOM_ERROR_HANDLER) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:62: characters 4-82
- $previousLevel = \error_reporting(\E_ALL & ~\E_DEPRECATED);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:63: lines 63-75
- $previousHandler = \set_error_handler(function ($errno, $errstr, $errfile, $errline) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:64: lines 64-66
- if ((\error_reporting() & $errno) === 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:65: characters 6-18
- return false;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:71: lines 71-73
- if (($errno === \E_WARNING) && ($errstr === "Division by zero")) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:72: characters 6-17
- return true;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:74: characters 5-10
- throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
- });
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:77: lines 77-80
- if ($previousHandler !== null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:78: characters 5-42
- \error_reporting($previousLevel);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:79: characters 5-46
- \set_error_handler($previousHandler);
- }
- }
-
- $this1 = [];
- self::$aliases = $this1;
- $this1 = [];
- self::$classes = $this1;
- $this1 = [];
- self::$getters = $this1;
- $this1 = [];
- self::$setters = $this1;
- $this1 = [];
- self::$meta = $this1;
- $this1 = [];
- self::$staticClosures = $this1;
- }
-}
-
-require_once __DIR__.'/_polyfills.php';
-Boot::__hx__init();
-Boot::registerClass(Boot::class, 'php.Boot');
diff --git a/dist/xrfragment.php/lib/php/_Boot/HxAnon.php b/dist/xrfragment.php/lib/php/_Boot/HxAnon.php
deleted file mode 100644
index fccec81..0000000
--- a/dist/xrfragment.php/lib/php/_Boot/HxAnon.php
+++ /dev/null
@@ -1,43 +0,0 @@
-$name)(...$args);
- }
-
- /**
- * @param string $name
- *
- * @return mixed
- */
- public function __get ($name) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:953: characters 3-14
- return null;
- }
-}
-
-Boot::registerClass(HxAnon::class, 'php._Boot.HxAnon');
diff --git a/dist/xrfragment.php/lib/php/_Boot/HxClass.php b/dist/xrfragment.php/lib/php/_Boot/HxClass.php
deleted file mode 100644
index 755f527..0000000
--- a/dist/xrfragment.php/lib/php/_Boot/HxClass.php
+++ /dev/null
@@ -1,95 +0,0 @@
- implementation for Haxe->PHP internals.
- */
-class HxClass {
- /**
- * @var string
- */
- public $phpClassName;
-
- /**
- * @param string $phpClassName
- *
- * @return void
- */
- public function __construct ($phpClassName) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:667: characters 3-35
- $this->phpClassName = $phpClassName;
- }
-
- /**
- * Magic method to call static methods of this class, when `HxClass` instance is in a `Dynamic` variable.
- *
- * @param string $method
- * @param array $args
- *
- * @return mixed
- */
- public function __call ($method, $args) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:675: characters 3-111
- $callback = ((($this->phpClassName === "String" ? HxString::class : $this->phpClassName))??'null') . "::" . ($method??'null');
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:676: characters 3-53
- return \call_user_func_array($callback, $args);
- }
-
- /**
- * Magic method to get static vars of this class, when `HxClass` instance is in a `Dynamic` variable.
- *
- * @param string $property
- *
- * @return mixed
- */
- public function __get ($property) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:684: lines 684-692
- if (\defined("" . ($this->phpClassName??'null') . "::" . ($property??'null'))) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:685: characters 4-54
- return \constant("" . ($this->phpClassName??'null') . "::" . ($property??'null'));
- } else if (Boot::hasGetter($this->phpClassName, $property)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:687: characters 29-41
- $tmp = $this->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:687: characters 4-59
- return $tmp::{"get_" . ($property??'null')}();
- } else if (\method_exists($this->phpClassName, $property)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:689: characters 4-56
- return Boot::getStaticClosure($this->phpClassName, $property);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:691: characters 33-45
- $tmp = $this->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:691: characters 4-56
- return $tmp::${$property};
- }
- }
-
- /**
- * Magic method to set static vars of this class, when `HxClass` instance is in a `Dynamic` variable.
- *
- * @param string $property
- * @param mixed $value
- *
- * @return void
- */
- public function __set ($property, $value) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:700: lines 700-704
- if (Boot::hasSetter($this->phpClassName, $property)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:701: characters 22-34
- $tmp = $this->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:701: characters 4-59
- $tmp::{"set_" . ($property??'null')}($value);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:703: characters 26-38
- $tmp = $this->phpClassName;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:703: characters 4-56
- $tmp::${$property} = $value;
- }
- }
-}
-
-Boot::registerClass(HxClass::class, 'php._Boot.HxClass');
diff --git a/dist/xrfragment.php/lib/php/_Boot/HxClosure.php b/dist/xrfragment.php/lib/php/_Boot/HxClosure.php
deleted file mode 100644
index c5fba4d..0000000
--- a/dist/xrfragment.php/lib/php/_Boot/HxClosure.php
+++ /dev/null
@@ -1,114 +0,0 @@
-target = $target;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:979: characters 3-19
- $this->func = $func;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:981: lines 981-983
- if (\is_null($target)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:982: characters 4-9
- throw Exception::thrown("Unable to create closure on `null`");
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:984: characters 3-104
- $this->callable = (($target instanceof HxAnon) ? $target->{$func} : [$target, $func]);
- }
-
- /**
- * @see http://php.net/manual/en/language.oop5.magic.php#object.invoke
- *
- * @return mixed
- */
- public function __invoke () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:992: characters 3-71
- return \call_user_func_array($this->callable, \func_get_args());
- }
-
- /**
- * Invoke this closure with `newThis` instead of `this`
- *
- * @param mixed $newThis
- * @param array $args
- *
- * @return mixed
- */
- public function callWith ($newThis, $args) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1019: characters 3-65
- return \call_user_func_array($this->getCallback($newThis), $args);
- }
-
- /**
- * Check if this is the same closure
- *
- * @param HxClosure $closure
- *
- * @return bool
- */
- public function equals ($closure) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1012: characters 10-60
- if (Boot::equal($this->target, $closure->target)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1012: characters 39-59
- return $this->func === $closure->func;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1012: characters 10-60
- return false;
- }
- }
-
- /**
- * Generates callable value for PHP
- *
- * @param mixed $eThis
- *
- * @return mixed[]
- */
- public function getCallback ($eThis = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:999: lines 999-1001
- if ($eThis === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1000: characters 4-18
- $eThis = $this->target;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1002: lines 1002-1004
- if (($eThis instanceof HxAnon)) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1003: characters 4-36
- return $eThis->{$this->func};
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:1005: characters 3-39
- return [$eThis, $this->func];
- }
-}
-
-Boot::registerClass(HxClosure::class, 'php._Boot.HxClosure');
diff --git a/dist/xrfragment.php/lib/php/_Boot/HxDynamicStr.php b/dist/xrfragment.php/lib/php/_Boot/HxDynamicStr.php
deleted file mode 100644
index 523b003..0000000
--- a/dist/xrfragment.php/lib/php/_Boot/HxDynamicStr.php
+++ /dev/null
@@ -1,160 +0,0 @@
-target);
- return \call_user_func_array((HxDynamicStr::$hxString??'null') . "::" . ($method??'null'), $args);
- }
-
- /**
- * @param string $field
- *
- * @return mixed
- */
- public function __get ($field) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:902: lines 902-908
- if ($field === "length") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:904: characters 5-36
- return mb_strlen($this->target);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:906: characters 5-17
- $this->func = $field;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:907: characters 5-16
- return $this;
- }
- }
-
- /**
- * @see http://php.net/manual/en/language.oop5.magic.php#object.invoke
- *
- * @return mixed
- */
- public function __invoke () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:921: characters 10-54
- $str = $this->target;
- $method = $this->func;
- $args = \func_get_args();
- \array_unshift($args, $str);
- return \call_user_func_array((HxDynamicStr::$hxString??'null') . "::" . ($method??'null'), $args);
- }
-
- /**
- * Invoke this closure with `newThis` instead of `this`
- *
- * @param mixed $newThis
- * @param array $args
- *
- * @return mixed
- */
- public function callWith ($newThis, $args) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:938: lines 938-940
- if ($newThis === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:939: characters 4-20
- $newThis = $this->target;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:941: characters 10-37
- $method = $this->func;
- \array_unshift($args, $newThis);
- return \call_user_func_array((HxDynamicStr::$hxString??'null') . "::" . ($method??'null'), $args);
- }
-
- /**
- * Generates callable value for PHP
- *
- * @param mixed $eThis
- *
- * @return mixed[]
- */
- public function getCallback ($eThis = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:928: lines 928-930
- if ($eThis === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:929: characters 4-51
- return [$this, $this->func];
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:931: characters 3-69
- return [new HxDynamicStr($eThis), $this->func];
- }
-
- /**
- * @internal
- * @access private
- */
- static public function __hx__init ()
- {
- static $called = false;
- if ($called) return;
- $called = true;
-
-
- self::$hxString = Boot::getClass(HxString::class)->phpClassName;
- }
-}
-
-Boot::registerClass(HxDynamicStr::class, 'php._Boot.HxDynamicStr');
-HxDynamicStr::__hx__init();
diff --git a/dist/xrfragment.php/lib/php/_Boot/HxEnum.php b/dist/xrfragment.php/lib/php/_Boot/HxEnum.php
deleted file mode 100644
index 63934ff..0000000
--- a/dist/xrfragment.php/lib/php/_Boot/HxEnum.php
+++ /dev/null
@@ -1,73 +0,0 @@
-tag = $tag;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:722: characters 3-21
- $this->index = $index;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:723: characters 12-63
- $tmp = null;
- if ($arguments === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:723: characters 33-50
- $this1 = [];
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:723: characters 12-63
- $tmp = $this1;
- } else {
- $tmp = $arguments;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:723: characters 3-63
- $this->params = $tmp;
- }
-
- /**
- * PHP magic method to get string representation of this `Class`
- *
- * @return string
- */
- public function __toString () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:738: characters 3-30
- return Boot::stringify($this);
- }
-
- /**
- * Get string representation of this `Class`
- *
- * @return string
- */
- public function toString () {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:730: characters 3-22
- return $this->__toString();
- }
-}
-
-Boot::registerClass(HxEnum::class, 'php._Boot.HxEnum');
diff --git a/dist/xrfragment.php/lib/php/_Boot/HxString.php b/dist/xrfragment.php/lib/php/_Boot/HxString.php
deleted file mode 100644
index dd7d038..0000000
--- a/dist/xrfragment.php/lib/php/_Boot/HxString.php
+++ /dev/null
@@ -1,294 +0,0 @@
-= $length) && ($search !== "")) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:785: characters 5-14
- return -1;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:788: lines 788-793
- $index = null;
- if ($search === "") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:789: characters 4-28
- $length = mb_strlen($str);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:788: lines 788-793
- $index = ($startIndex > $length ? $length : $startIndex);
- } else {
- $index = \mb_strpos($str, $search, $startIndex);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:794: characters 10-39
- if ($index === false) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:794: characters 28-30
- return -1;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:794: characters 33-38
- return $index;
- }
- }
-
- /**
- * @param string $str
- * @param string $search
- * @param int $startIndex
- *
- * @return int
- */
- public static function lastIndexOf ($str, $search, $startIndex = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:798: characters 3-26
- $start = $startIndex;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:799: lines 799-811
- if ($start === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:800: characters 4-13
- $start = 0;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:802: characters 4-28
- $length = mb_strlen($str);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:803: lines 803-810
- if ($start >= 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:804: characters 5-27
- $start -= $length;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:805: lines 805-807
- if ($start > 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:806: characters 6-15
- $start = 0;
- }
- } else if ($start < -$length) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:809: characters 5-20
- $start = -$length;
- }
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:812: lines 812-817
- $index = null;
- if ($search === "") {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:813: characters 4-28
- $length = mb_strlen($str);
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:812: lines 812-817
- $index = (($startIndex === null) || ($startIndex > $length) ? $length : $startIndex);
- } else {
- $index = \mb_strrpos($str, $search, $start);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:818: lines 818-822
- if ($index === false) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:819: characters 4-13
- return -1;
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:821: characters 4-16
- return $index;
- }
- }
-
- /**
- * @param string $str
- * @param string $delimiter
- *
- * @return string[]|\Array_hx
- */
- public static function split ($str, $delimiter) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:826: lines 826-831
- $arr = null;
- if ($delimiter === "") {
- $arr = \preg_split("//u", $str, -1, \PREG_SPLIT_NO_EMPTY);
- } else {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:829: characters 4-49
- $delimiter = \preg_quote($delimiter, "/");
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:826: lines 826-831
- $arr = \preg_split("/" . ($delimiter??'null') . "/", $str);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:832: characters 3-41
- return \Array_hx::wrap($arr);
- }
-
- /**
- * @param string $str
- * @param int $pos
- * @param int $len
- *
- * @return string
- */
- public static function substr ($str, $pos, $len = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:836: characters 3-41
- return \mb_substr($str, $pos, $len);
- }
-
- /**
- * @param string $str
- * @param int $startIndex
- * @param int $endIndex
- *
- * @return string
- */
- public static function substring ($str, $startIndex, $endIndex = null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:840: lines 840-845
- if ($endIndex === null) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:841: lines 841-843
- if ($startIndex < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:842: characters 5-19
- $startIndex = 0;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:844: characters 4-44
- return \mb_substr($str, $startIndex);
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:846: lines 846-848
- if ($endIndex < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:847: characters 4-16
- $endIndex = 0;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:849: lines 849-851
- if ($startIndex < 0) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:850: characters 4-18
- $startIndex = 0;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:852: lines 852-856
- if ($startIndex > $endIndex) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:853: characters 4-23
- $tmp = $endIndex;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:854: characters 4-25
- $endIndex = $startIndex;
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:855: characters 4-20
- $startIndex = $tmp;
- }
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:857: characters 3-66
- return \mb_substr($str, $startIndex, $endIndex - $startIndex);
- }
-
- /**
- * @param string $str
- *
- * @return string
- */
- public static function toLowerCase ($str) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:755: characters 3-35
- return \mb_strtolower($str);
- }
-
- /**
- * @param string $str
- *
- * @return string
- */
- public static function toString ($str) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:861: characters 3-13
- return $str;
- }
-
- /**
- * @param string $str
- *
- * @return string
- */
- public static function toUpperCase ($str) {
- #/nix/store/ljakxdz94hcvn9b4k9y292dn5lhh20iy-haxe-4.2.5/lib/haxe/std/php/Boot.hx:751: characters 3-35
- return \mb_strtoupper($str);
- }
-}
-
-Boot::registerClass(HxString::class, 'php._Boot.HxString');
diff --git a/dist/xrfragment.php/lib/php/_polyfills.php b/dist/xrfragment.php/lib/php/_polyfills.php
deleted file mode 100644
index 714a7dd..0000000
--- a/dist/xrfragment.php/lib/php/_polyfills.php
+++ /dev/null
@@ -1,63 +0,0 @@
- $code %= 0x200000) {
- $s = chr($code);
- } elseif (0x800 > $code) {
- $s = chr(0xC0 | $code >> 6) . chr(0x80 | $code & 0x3F);
- } elseif (0x10000 > $code) {
- $s = chr(0xE0 | $code >> 12) . chr(0x80 | $code >> 6 & 0x3F) . chr(0x80 | $code & 0x3F);
- } else {
- $s = chr(0xF0 | $code >> 18) . chr(0x80 | $code >> 12 & 0x3F) . chr(0x80 | $code >> 6 & 0x3F) . chr(0x80 | $code & 0x3F);
- }
- return $s;
- }
- }
-
- /**
- * @see http://php.net/manual/en/function.mb-ord.php
- */
- if(!function_exists('mb_ord')) {
- function mb_ord($s, $encoding = null) {
- if($encoding && $encoding !== 'UTF-8') {
- throw new Exception("$encoding is not supported in mb_ord() polyfill.");
- }
- $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
- if (0xF0 <= $code) {
- return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
- }
- if (0xE0 <= $code) {
- return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
- }
- if (0xC0 <= $code) {
- return (($code - 0xC0) << 6) + $s[2] - 0x80;
- }
- return $code;
- }
- }
-
- /**
- * @see http://php.net/manual/en/function.mb-scrub.php
- */
- if(!function_exists('mb_scrub')) {
- function mb_scrub($s, $encoding = null) {
- $encoding = null === $encoding ? mb_internal_encoding() : $encoding;
- return mb_convert_encoding($s, $encoding, $encoding);
- }
- }
-
-}
\ No newline at end of file
diff --git a/dist/xrfragment.php/lib/xrfragment/Parser.php b/dist/xrfragment.php/lib/xrfragment/Parser.php
deleted file mode 100644
index a157d56..0000000
--- a/dist/xrfragment.php/lib/xrfragment/Parser.php
+++ /dev/null
@@ -1,139 +0,0 @@
- 0) && !\array_key_exists($key, $Frag_data)) {
- #src/xrfragment/Parser.hx:68: characters 5-64
- $v = new XRF($key, XRF::$PV_EXECUTE | XRF::$NAVIGATOR);
- #src/xrfragment/Parser.hx:69: characters 9-24
- $v->validate($key);
- #src/xrfragment/Parser.hx:70: characters 5-23
- \Reflect::setField($store, $key, $v);
- #src/xrfragment/Parser.hx:71: characters 5-16
- return true;
- }
- #src/xrfragment/Parser.hx:73: lines 73-76
- if ((HxString::split($key, ".")->length > 1) && (HxString::split($value, ".")->length > 1)) {
- #src/xrfragment/Parser.hx:74: characters 5-95
- $value1 = new XRF($key, XRF::$ASSET | XRF::$PV_OVERRIDE | XRF::$T_STRING | XRF::$PROP_BIND);
- \Reflect::setField($store, $key, $value1);
- #src/xrfragment/Parser.hx:75: characters 5-16
- return true;
- }
- #src/xrfragment/Parser.hx:79: characters 7-47
- $v = new XRF($key, ($Frag_data[$key] ?? null));
- #src/xrfragment/Parser.hx:80: lines 80-90
- if (\array_key_exists($key, $Frag_data)) {
- #src/xrfragment/Parser.hx:81: lines 81-84
- if (!$v->validate($value)) {
- #src/xrfragment/Parser.hx:82: characters 11-16
- (Log::$trace)("⚠ fragment '" . ($key??'null') . "' has incompatible value (" . ($value??'null') . ")", new _HxAnon_Parser0("src/xrfragment/Parser.hx", 82, "xrfragment.Parser", "parse"));
- #src/xrfragment/Parser.hx:83: characters 11-23
- return false;
- }
- #src/xrfragment/Parser.hx:85: characters 9-27
- \Reflect::setField($store, $key, $v);
- #src/xrfragment/Parser.hx:86: characters 9-50
- if (Parser::$debug) {
- #src/xrfragment/Parser.hx:86: characters 21-26
- (Log::$trace)("✔ " . ($key??'null') . ": " . ($v->string??'null'), new _HxAnon_Parser0("src/xrfragment/Parser.hx", 86, "xrfragment.Parser", "parse"));
- }
- } else {
- #src/xrfragment/Parser.hx:88: characters 9-63
- if (is_string($value)) {
- #src/xrfragment/Parser.hx:88: characters 43-63
- $v->guessType($v, $value);
- }
- #src/xrfragment/Parser.hx:89: characters 9-29
- \Reflect::setField($store, "_" . ($key??'null'), $v);
- }
- #src/xrfragment/Parser.hx:92: characters 7-18
- return true;
- }
-}
-
-class _HxAnon_Parser0 extends HxAnon {
- function __construct($fileName, $lineNumber, $className, $methodName) {
- $this->fileName = $fileName;
- $this->lineNumber = $lineNumber;
- $this->className = $className;
- $this->methodName = $methodName;
- }
-}
-
-Boot::registerClass(Parser::class, 'xrfragment.Parser');
diff --git a/dist/xrfragment.php/lib/xrfragment/Query.php b/dist/xrfragment.php/lib/xrfragment/Query.php
deleted file mode 100644
index 36bd925..0000000
--- a/dist/xrfragment.php/lib/xrfragment/Query.php
+++ /dev/null
@@ -1,393 +0,0 @@
- version 1.0.0 [![Actions Status](https://github.com/coderofsalvation/xrfragment/workflows/test/badge.svg)](https://github.com/coderofsalvation/xrfragment/actions) generated by `make doc` @ $(date +"%Y-%m-%dT%H:%M:%S%z")
- *
- * In case your programming language has no parser ([check here](https://github.com/coderofsalvation/xrfragment/tree/main/dist)) you can [crosscompile it](https://github.com/coderofsalvation/xrfragment/blob/main/build.hxml), or roll your own `Query.parse(str)` using the spec:
- */
- public $str;
-
- /**
- * @param string $str
- *
- * @return void
- */
- public function __construct ($str) {
- #src/xrfragment/Query.hx:59: characters 36-49
- $this->isNumber = new \EReg("^[0-9\\.]+\$", "");
- #src/xrfragment/Query.hx:58: characters 36-50
- $this->isClass = new \EReg("^[-]?class\$", "");
- #src/xrfragment/Query.hx:57: characters 36-46
- $this->isRoot = new \EReg("^[-]?/", "");
- #src/xrfragment/Query.hx:56: characters 36-41
- $this->isExclude = new \EReg("^-", "");
- #src/xrfragment/Query.hx:55: characters 36-50
- $this->isProp = new \EReg("^.*:[><=!]?", "");
- #src/xrfragment/Query.hx:54: characters 47-49
- $this->q = new HxAnon();
- #src/xrfragment/Query.hx:53: characters 28-30
- $this->str = "";
- #src/xrfragment/Query.hx:62: characters 5-39
- if ($str !== null) {
- #src/xrfragment/Query.hx:62: characters 24-39
- $this->parse($str);
- }
- }
-
- /**
- * @param string $token
- *
- * @return string
- */
- public function expandAliases ($token) {
- #src/xrfragment/Query.hx:71: characters 5-33
- $classAlias = new \EReg("^(-)?\\.", "");
- #src/xrfragment/Query.hx:72: characters 12-85
- if ($classAlias->match($token)) {
- #src/xrfragment/Query.hx:72: characters 38-77
- return \StringTools::replace($token, ".", "class:");
- } else {
- #src/xrfragment/Query.hx:72: characters 80-85
- return $token;
- }
- }
-
- /**
- * @return mixed
- */
- public function get () {
- #src/xrfragment/Query.hx:76: characters 5-18
- return $this->q;
- }
-
- /**
- * @param string $str
- *
- * @return mixed
- */
- public function parse ($str) {
- #src/xrfragment/Query.hx:79: lines 79-126
- $_gthis = $this;
- #src/xrfragment/Query.hx:81: characters 5-32
- $token = HxString::split($str, " ");
- #src/xrfragment/Query.hx:82: characters 5-44
- $q = new HxAnon();
- #src/xrfragment/Query.hx:84: lines 84-123
- $process = function ($str, $prefix = "") use (&$_gthis, &$q) {
- if ($prefix === null) {
- $prefix = "";
- }
- #src/xrfragment/Query.hx:85: characters 7-34
- $str = \trim($str);
- #src/xrfragment/Query.hx:86: characters 7-40
- $k = (HxString::split($str, ":")->arr[0] ?? null);
- #src/xrfragment/Query.hx:87: characters 7-40
- $v = (HxString::split($str, ":")->arr[1] ?? null);
- #src/xrfragment/Query.hx:89: characters 7-51
- $filter = new HxAnon();
- #src/xrfragment/Query.hx:90: characters 7-53
- if (\Reflect::field($q, ($prefix??'null') . ($k??'null'))) {
- #src/xrfragment/Query.hx:90: characters 29-53
- $filter = \Reflect::field($q, ($prefix??'null') . ($k??'null'));
- }
- #src/xrfragment/Query.hx:91: characters 7-89
- $value = (\Reflect::field($filter, "rules") !== null ? \Reflect::field($filter, "rules") : new \Array_hx());
- \Reflect::setField($filter, "rules", $value);
- #src/xrfragment/Query.hx:93: lines 93-122
- if ($_gthis->isProp->match($str)) {
- #src/xrfragment/Query.hx:94: characters 9-30
- $oper = "";
- #src/xrfragment/Query.hx:95: characters 9-49
- if (HxString::indexOf($str, "*") !== -1) {
- #src/xrfragment/Query.hx:95: characters 39-49
- $oper = "*";
- }
- #src/xrfragment/Query.hx:96: characters 9-49
- if (HxString::indexOf($str, ">") !== -1) {
- #src/xrfragment/Query.hx:96: characters 39-49
- $oper = ">";
- }
- #src/xrfragment/Query.hx:97: characters 9-49
- if (HxString::indexOf($str, "<") !== -1) {
- #src/xrfragment/Query.hx:97: characters 39-49
- $oper = "<";
- }
- #src/xrfragment/Query.hx:98: characters 9-50
- if (HxString::indexOf($str, ">=") !== -1) {
- #src/xrfragment/Query.hx:98: characters 39-50
- $oper = ">=";
- }
- #src/xrfragment/Query.hx:99: characters 9-50
- if (HxString::indexOf($str, "<=") !== -1) {
- #src/xrfragment/Query.hx:99: characters 39-50
- $oper = "<=";
- }
- #src/xrfragment/Query.hx:100: lines 100-103
- if ($_gthis->isExclude->match($k)) {
- #src/xrfragment/Query.hx:101: characters 11-22
- $oper = "!=";
- #src/xrfragment/Query.hx:102: characters 15-26
- $k = \mb_substr($k, 1, null);
- } else {
- #src/xrfragment/Query.hx:103: characters 19-40
- $v = \mb_substr($v, mb_strlen($oper), null);
- }
- #src/xrfragment/Query.hx:104: characters 9-42
- if (mb_strlen($oper) === 0) {
- #src/xrfragment/Query.hx:104: characters 32-42
- $oper = "=";
- }
- #src/xrfragment/Query.hx:105: lines 105-114
- if ($_gthis->isClass->match($k)) {
- #src/xrfragment/Query.hx:106: characters 11-45
- $value = $oper !== "!=";
- \Reflect::setField($filter, ($prefix??'null') . ($k??'null'), $value);
- #src/xrfragment/Query.hx:107: characters 11-26
- \Reflect::setField($q, $v, $filter);
- } else {
- #src/xrfragment/Query.hx:109: characters 11-53
- $rule = new HxAnon();
- #src/xrfragment/Query.hx:110: lines 110-111
- if ($_gthis->isNumber->match($v)) {
- #src/xrfragment/Query.hx:110: characters 35-67
- $value = \Std::parseFloat($v);
- \Reflect::setField($rule, $oper, $value);
- } else {
- #src/xrfragment/Query.hx:111: characters 16-30
- \Reflect::setField($rule, $oper, $v);
- }
- #src/xrfragment/Query.hx:112: characters 11-39
- \Reflect::field($filter, "rules")->push($rule);
- #src/xrfragment/Query.hx:113: characters 11-29
- \Reflect::setField($q, $k, $filter);
- }
- #src/xrfragment/Query.hx:115: characters 9-15
- return;
- } else {
- #src/xrfragment/Query.hx:117: characters 9-62
- $value = ($_gthis->isExclude->match($str) ? false : true);
- \Reflect::setField($filter, "id", $value);
- #src/xrfragment/Query.hx:118: characters 9-63
- $value = $_gthis->isRoot->match($str);
- \Reflect::setField($filter, "root", $value);
- #src/xrfragment/Query.hx:119: characters 9-55
- if ($_gthis->isExclude->match($str)) {
- #src/xrfragment/Query.hx:119: characters 42-55
- $str = \mb_substr($str, 1, null);
- }
- #src/xrfragment/Query.hx:120: characters 9-55
- if ($_gthis->isRoot->match($str)) {
- #src/xrfragment/Query.hx:120: characters 42-55
- $str = \mb_substr($str, 1, null);
- }
- #src/xrfragment/Query.hx:121: characters 9-29
- \Reflect::setField($q, $str, $filter);
- }
- };
- #src/xrfragment/Query.hx:124: characters 15-19
- $_g = 0;
- #src/xrfragment/Query.hx:124: characters 19-31
- $_g1 = $token->length;
- #src/xrfragment/Query.hx:124: characters 5-68
- while ($_g < $_g1) {
- #src/xrfragment/Query.hx:124: characters 15-31
- $i = $_g++;
- #src/xrfragment/Query.hx:124: characters 34-68
- $process($this->expandAliases(($token->arr[$i] ?? null)));
- }
- #src/xrfragment/Query.hx:125: characters 5-22
- return $this->q = $q;
- }
-
- /**
- * @param mixed $obj
- *
- * @return bool
- */
- public function test ($obj = null) {
- #src/xrfragment/Query.hx:130: characters 5-30
- $qualify = false;
- #src/xrfragment/Query.hx:132: lines 132-135
- $_g = 0;
- $_g1 = \Reflect::fields($obj);
- while ($_g < $_g1->length) {
- #src/xrfragment/Query.hx:132: characters 11-12
- $k = ($_g1->arr[$_g] ?? null);
- #src/xrfragment/Query.hx:132: lines 132-135
- ++$_g;
- #src/xrfragment/Query.hx:133: characters 7-57
- $v = \Std::string(\Reflect::field($obj, $k));
- #src/xrfragment/Query.hx:134: characters 7-47
- if ($this->testProperty($k, $v)) {
- #src/xrfragment/Query.hx:134: characters 33-47
- $qualify = true;
- }
- }
- #src/xrfragment/Query.hx:136: lines 136-139
- $_g = 0;
- $_g1 = \Reflect::fields($obj);
- while ($_g < $_g1->length) {
- #src/xrfragment/Query.hx:136: characters 11-12
- $k = ($_g1->arr[$_g] ?? null);
- #src/xrfragment/Query.hx:136: lines 136-139
- ++$_g;
- #src/xrfragment/Query.hx:137: characters 7-57
- $v = \Std::string(\Reflect::field($obj, $k));
- #src/xrfragment/Query.hx:138: characters 7-54
- if ($this->testProperty($k, $v, true)) {
- #src/xrfragment/Query.hx:138: characters 39-54
- $qualify = false;
- }
- }
- #src/xrfragment/Query.hx:140: characters 5-19
- return $qualify;
- }
-
- /**
- * @param string $property
- * @param string $value
- * @param bool $exclude
- *
- * @return bool
- */
- public function testProperty ($property, $value, $exclude = null) {
- #src/xrfragment/Query.hx:145: characters 5-23
- $conds = 0;
- #src/xrfragment/Query.hx:146: characters 5-23
- $fails = 0;
- #src/xrfragment/Query.hx:147: characters 5-26
- $qualify = 0;
- #src/xrfragment/Query.hx:149: lines 149-153
- $testprop = function ($expr) use (&$conds, &$fails) {
- #src/xrfragment/Query.hx:150: characters 7-15
- $conds += 1;
- #src/xrfragment/Query.hx:151: characters 7-27
- $fails += ($expr ? 0 : 1);
- #src/xrfragment/Query.hx:152: characters 7-18
- return $expr;
- };
- #src/xrfragment/Query.hx:156: lines 156-159
- if (\Reflect::field($this->q, $value) !== null) {
- #src/xrfragment/Query.hx:157: characters 7-52
- $v = \Reflect::field($this->q, $value);
- #src/xrfragment/Query.hx:158: characters 7-59
- if (\Reflect::field($v, $property) !== null) {
- #src/xrfragment/Query.hx:158: characters 37-59
- return \Reflect::field($v, $property);
- }
- }
- #src/xrfragment/Query.hx:162: lines 162-183
- $_g = 0;
- $_g1 = \Reflect::fields($this->q);
- while ($_g < $_g1->length) {
- #src/xrfragment/Query.hx:162: characters 11-12
- $k = ($_g1->arr[$_g] ?? null);
- #src/xrfragment/Query.hx:162: lines 162-183
- ++$_g;
- #src/xrfragment/Query.hx:163: characters 7-47
- $filter = \Reflect::field($this->q, $k);
- #src/xrfragment/Query.hx:164: characters 7-43
- if (Boot::dynamicField($filter, 'rules') === null) {
- #src/xrfragment/Query.hx:164: characters 35-43
- continue;
- }
- #src/xrfragment/Query.hx:165: characters 7-47
- $rules = Boot::dynamicField($filter, 'rules');
- #src/xrfragment/Query.hx:167: lines 167-182
- $_g2 = 0;
- while ($_g2 < $rules->length) {
- #src/xrfragment/Query.hx:167: characters 12-16
- $rule = ($rules->arr[$_g2] ?? null);
- #src/xrfragment/Query.hx:167: lines 167-182
- ++$_g2;
- #src/xrfragment/Query.hx:169: lines 169-181
- if ($exclude) {
- #src/xrfragment/Query.hx:170: characters 11-145
- if ((\Reflect::field($rule, "!=") !== null) && $testprop(\Std::string($value) === \Std::string(\Reflect::field($rule, "!="))) && $exclude) {
- #src/xrfragment/Query.hx:170: characters 133-145
- ++$qualify;
- }
- } else {
- #src/xrfragment/Query.hx:172: characters 11-141
- if ((\Reflect::field($rule, "*") !== null) && $testprop(\Std::parseFloat($value) !== null)) {
- #src/xrfragment/Query.hx:172: characters 129-141
- ++$qualify;
- }
- #src/xrfragment/Query.hx:173: characters 11-143
- if ((\Reflect::field($rule, ">") !== null) && $testprop(\Std::parseFloat($value) > \Std::parseFloat(\Reflect::field($rule, ">")))) {
- #src/xrfragment/Query.hx:173: characters 131-143
- ++$qualify;
- }
- #src/xrfragment/Query.hx:174: characters 11-143
- if ((\Reflect::field($rule, "<") !== null) && $testprop(\Std::parseFloat($value) < \Std::parseFloat(\Reflect::field($rule, "<")))) {
- #src/xrfragment/Query.hx:174: characters 131-143
- ++$qualify;
- }
- #src/xrfragment/Query.hx:175: characters 11-143
- if ((\Reflect::field($rule, ">=") !== null) && $testprop(\Std::parseFloat($value) >= \Std::parseFloat(\Reflect::field($rule, ">=")))) {
- #src/xrfragment/Query.hx:175: characters 131-143
- ++$qualify;
- }
- #src/xrfragment/Query.hx:176: characters 11-143
- if ((\Reflect::field($rule, "<=") !== null) && $testprop(\Std::parseFloat($value) <= \Std::parseFloat(\Reflect::field($rule, "<=")))) {
- #src/xrfragment/Query.hx:176: characters 131-143
- ++$qualify;
- }
- #src/xrfragment/Query.hx:177: lines 177-180
- if ((\Reflect::field($rule, "=") !== null) && ($testprop($value === \Reflect::field($rule, "=")) || $testprop(Boot::equal(\Std::parseFloat($value), \Std::parseFloat(\Reflect::field($rule, "=")))))) {
- #src/xrfragment/Query.hx:180: characters 14-26
- ++$qualify;
- }
- }
- }
- }
- #src/xrfragment/Query.hx:184: characters 5-23
- return $qualify > 0;
- }
-
- /**
- * @return mixed
- */
- public function toObject () {
- #src/xrfragment/Query.hx:66: characters 5-18
- return $this->q;
- }
-}
-
-Boot::registerClass(Query::class, 'xrfragment.Query');
diff --git a/dist/xrfragment.php/lib/xrfragment/URI.php b/dist/xrfragment.php/lib/xrfragment/URI.php
deleted file mode 100644
index 05d46b1..0000000
--- a/dist/xrfragment.php/lib/xrfragment/URI.php
+++ /dev/null
@@ -1,101 +0,0 @@
- version 1.0.0 [![Actions Status](https://github.com/coderofsalvation/xrfragment/workflows/test/badge.svg)](https://github.com/coderofsalvation/xrfragment/actions) generated by `make doc` @ $(date +"%Y-%m-%dT%H:%M:%S%z")
- *
- * ### XR Fragment URI Grammar
- *
- * ```
- * reserved = gen-delims / sub-delims
- * gen-delims = "#" / "&"
- * sub-delims = "," / "="
- * ```
- *
- * > Example: `://foo.com/my3d.asset#pos=1,0,0&prio=-5&t=0,100|100,200`
- *
- * | Explanation | |
- * |-|-|
- * | `pos=1,2,3` | vector/coordinate argument e.g. |
- * | `pos=1,2,3&rot=0,90,0&q=.foo` | combinators |
- *
- * In case your programming language has no parser ([check here](https://github.com/coderofsalvation/xrfragment/tree/main/dist)) you can [crosscompile it](https://github.com/coderofsalvation/xrfragment/blob/main/build.hxml), or roll your own `Parser.parse(k,v,store)` using the spec:
- *
- */
-class URI {
- /**
- * @param string $url
- * @param int $filter
- *
- * @return mixed
- */
- public static function parse ($url, $filter) {
- #src/xrfragment/URI.hx:37: characters 7-50
- $store = new HxAnon();
- #src/xrfragment/URI.hx:38: characters 7-63
- if (($url === null) || (HxString::indexOf($url, "#") === -1)) {
- #src/xrfragment/URI.hx:38: characters 51-63
- return $store;
- }
- #src/xrfragment/URI.hx:39: characters 7-54
- $fragment = HxString::split($url, "#");
- #src/xrfragment/URI.hx:40: characters 7-62
- $splitArray = HxString::split(($fragment->arr[1] ?? null), "&");
- #src/xrfragment/URI.hx:41: characters 19-23
- $_g = 0;
- #src/xrfragment/URI.hx:41: characters 23-40
- $_g1 = $splitArray->length;
- #src/xrfragment/URI.hx:41: lines 41-51
- while ($_g < $_g1) {
- #src/xrfragment/URI.hx:41: characters 19-40
- $i = $_g++;
- #src/xrfragment/URI.hx:43: characters 9-53
- $splitByEqual = HxString::split(($splitArray->arr[$i] ?? null), "=");
- #src/xrfragment/URI.hx:44: characters 9-33
- $regexPlus = new \EReg("\\+", "g");
- #src/xrfragment/URI.hx:45: characters 9-42
- $key = ($splitByEqual->arr[0] ?? null);
- #src/xrfragment/URI.hx:46: characters 5-27
- $value = "";
- #src/xrfragment/URI.hx:47: lines 47-49
- if ($splitByEqual->length > 1) {
- #src/xrfragment/URI.hx:48: characters 19-84
- $value = \urldecode($regexPlus->split(($splitByEqual->arr[1] ?? null))->join(" "));
- }
- #src/xrfragment/URI.hx:50: characters 5-49
- $ok = Parser::parse($key, $value, $store);
- }
- #src/xrfragment/URI.hx:52: lines 52-59
- if (($filter !== null) && ($filter !== 0)) {
- #src/xrfragment/URI.hx:53: lines 53-58
- $_g = 0;
- $_g1 = \Reflect::fields($store);
- while ($_g < $_g1->length) {
- #src/xrfragment/URI.hx:53: characters 14-17
- $key = ($_g1->arr[$_g] ?? null);
- #src/xrfragment/URI.hx:53: lines 53-58
- ++$_g;
- #src/xrfragment/URI.hx:54: characters 13-42
- $xrf = \Reflect::field($store, $key);
- #src/xrfragment/URI.hx:55: lines 55-57
- if (!$xrf->is($filter)) {
- #src/xrfragment/URI.hx:56: characters 8-25
- \Reflect::deleteField($store, $key);
- }
- }
- }
- #src/xrfragment/URI.hx:60: characters 7-19
- return $store;
- }
-}
-
-Boot::registerClass(URI::class, 'xrfragment.URI');
diff --git a/dist/xrfragment.php/lib/xrfragment/XRF.php b/dist/xrfragment.php/lib/xrfragment/XRF.php
deleted file mode 100644
index 46a1c2b..0000000
--- a/dist/xrfragment.php/lib/xrfragment/XRF.php
+++ /dev/null
@@ -1,334 +0,0 @@
-fragment = $_fragment;
- #src/xrfragment/XRF.hx:62: characters 5-22
- $this->flags = $_flags;
- }
-
- /**
- * @param XRF $v
- * @param string $str
- *
- * @return void
- */
- public function guessType ($v, $str) {
- #src/xrfragment/XRF.hx:103: characters 5-19
- $v->string = $str;
- #src/xrfragment/XRF.hx:104: lines 104-109
- if (HxString::split($str, ",")->length > 1) {
- #src/xrfragment/XRF.hx:105: characters 7-46
- $xyz = HxString::split($str, ",");
- #src/xrfragment/XRF.hx:106: characters 7-56
- if ($xyz->length > 0) {
- #src/xrfragment/XRF.hx:106: characters 28-56
- $v->x = \Std::parseFloat(($xyz->arr[0] ?? null));
- }
- #src/xrfragment/XRF.hx:107: characters 7-56
- if ($xyz->length > 1) {
- #src/xrfragment/XRF.hx:107: characters 28-56
- $v->y = \Std::parseFloat(($xyz->arr[1] ?? null));
- }
- #src/xrfragment/XRF.hx:108: characters 7-56
- if ($xyz->length > 2) {
- #src/xrfragment/XRF.hx:108: characters 28-56
- $v->z = \Std::parseFloat(($xyz->arr[2] ?? null));
- }
- }
- #src/xrfragment/XRF.hx:111: characters 5-43
- if (XRF::$isColor->match($str)) {
- #src/xrfragment/XRF.hx:111: characters 30-43
- $v->color = $str;
- }
- #src/xrfragment/XRF.hx:112: characters 5-59
- if (XRF::$isFloat->match($str)) {
- #src/xrfragment/XRF.hx:112: characters 30-59
- $v->float = \Std::parseFloat($str);
- }
- #src/xrfragment/XRF.hx:113: characters 5-57
- if (XRF::$isInt->match($str)) {
- #src/xrfragment/XRF.hx:113: characters 30-57
- $v->int = \Std::parseInt($str);
- }
- }
-
- /**
- * @param int $flag
- *
- * @return bool
- */
- public function is ($flag) {
- #src/xrfragment/XRF.hx:66: characters 5-31
- return ($this->flags & $flag) !== 0;
- }
-
- /**
- * @param string $value
- *
- * @return bool
- */
- public function validate ($value) {
- #src/xrfragment/XRF.hx:78: characters 5-27
- $this->guessType($this, $value);
- #src/xrfragment/XRF.hx:80: lines 80-88
- if (HxString::split($value, "|")->length > 1) {
- #src/xrfragment/XRF.hx:81: characters 7-35
- $this->args = new \Array_hx();
- #src/xrfragment/XRF.hx:82: characters 7-49
- $args = HxString::split($value, "|");
- #src/xrfragment/XRF.hx:83: characters 17-21
- $_g = 0;
- #src/xrfragment/XRF.hx:83: characters 21-32
- $_g1 = $args->length;
- #src/xrfragment/XRF.hx:83: lines 83-87
- while ($_g < $_g1) {
- #src/xrfragment/XRF.hx:83: characters 17-32
- $i = $_g++;
- #src/xrfragment/XRF.hx:84: characters 9-45
- $x = new XRF($this->fragment, $this->flags);
- #src/xrfragment/XRF.hx:85: characters 9-30
- $this->guessType($x, ($args->arr[$i] ?? null));
- #src/xrfragment/XRF.hx:86: characters 9-28
- $_this = $this->args;
- $_this->arr[$_this->length++] = $x;
- }
- }
- #src/xrfragment/XRF.hx:90: characters 5-59
- if ($this->fragment === "q") {
- #src/xrfragment/XRF.hx:90: characters 27-59
- $this->query = (new Query($value))->get();
- }
- #src/xrfragment/XRF.hx:92: characters 5-24
- $ok = true;
- #src/xrfragment/XRF.hx:93: lines 93-97
- if (!($this->args instanceof \Array_hx)) {
- #src/xrfragment/XRF.hx:94: characters 7-115
- if ($this->is(XRF::$T_VECTOR3) && !((is_float($this->x) || is_int($this->x)) && (is_float($this->y) || is_int($this->y)) && (is_float($this->z) || is_int($this->z)))) {
- #src/xrfragment/XRF.hx:94: characters 105-115
- $ok = false;
- }
- #src/xrfragment/XRF.hx:95: characters 7-115
- if ($this->is(XRF::$T_VECTOR2) && !((is_float($this->x) || is_int($this->x)) && (is_float($this->y) || is_int($this->y)))) {
- #src/xrfragment/XRF.hx:95: characters 105-115
- $ok = false;
- }
- #src/xrfragment/XRF.hx:96: characters 7-63
- if ($this->is(XRF::$T_INT) && !Boot::isOfType($this->int, Boot::getClass('Int'))) {
- #src/xrfragment/XRF.hx:96: characters 53-63
- $ok = false;
- }
- }
- #src/xrfragment/XRF.hx:98: characters 5-14
- return $ok;
- }
-
- /**
- * @internal
- * @access private
- */
- static public function __hx__init ()
- {
- static $called = false;
- if ($called) return;
- $called = true;
-
-
- self::$isColor = new \EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\$", "");
- self::$isInt = new \EReg("^[0-9]+\$", "");
- self::$isFloat = new \EReg("^[0-9]+\\.[0-9]+\$", "");
- self::$isVector = new \EReg("([,]+|\\w)", "");
- self::$isUrl = new \EReg("(://)?\\..*", "");
- self::$isUrlOrPretypedView = new \EReg("(^#|://)?\\..*", "");
- self::$isString = new \EReg(".*", "");
- }
-}
-
-Boot::registerClass(XRF::class, 'xrfragment.XRF');
-XRF::__hx__init();
diff --git a/dist/xrfragment.py b/dist/xrfragment.py
index 6bbc652..e7c7098 100644
--- a/dist/xrfragment.py
+++ b/dist/xrfragment.py
@@ -63,7 +63,7 @@ class EReg:
_hx_class_name = "EReg"
__slots__ = ("pattern", "matchObj", "_hx_global")
_hx_fields = ["pattern", "matchObj", "global"]
- _hx_methods = ["split"]
+ _hx_methods = ["split", "replace"]
def __init__(self,r,opt):
self.matchObj = None
@@ -107,12 +107,35 @@ class EReg:
else:
return [HxString.substring(s,0,self.matchObj.start()), HxString.substr(s,self.matchObj.end(),None)]
+ def replace(self,s,by):
+ _this = by.split("$$")
+ by = "_hx_#repl#__".join([python_Boot.toString1(x1,'') for x1 in _this])
+ def _hx_local_0(x):
+ res = by
+ g = x.groups()
+ _g = 0
+ _g1 = len(g)
+ while (_g < _g1):
+ i = _g
+ _g = (_g + 1)
+ gs = g[i]
+ if (gs is None):
+ continue
+ delimiter = ("$" + HxOverrides.stringOrNull(str((i + 1))))
+ _this = (list(res) if ((delimiter == "")) else res.split(delimiter))
+ res = gs.join([python_Boot.toString1(x1,'') for x1 in _this])
+ _this = res.split("_hx_#repl#__")
+ res = "$".join([python_Boot.toString1(x1,'') for x1 in _this])
+ return res
+ replace = _hx_local_0
+ return python_lib_Re.sub(self.pattern,replace,s,(0 if (self._hx_global) else 1))
+
class Reflect:
_hx_class_name = "Reflect"
__slots__ = ()
- _hx_statics = ["field", "deleteField"]
+ _hx_statics = ["field", "deleteField", "copy"]
@staticmethod
def field(o,field):
@@ -129,6 +152,20 @@ class Reflect:
o.__delattr__(field)
return True
+ @staticmethod
+ def copy(o):
+ if (o is None):
+ return None
+ o2 = _hx_AnonObject({})
+ _g = 0
+ _g1 = python_Boot.fields(o)
+ while (_g < len(_g1)):
+ f = (_g1[_g] if _g >= 0 and _g < len(_g1) else None)
+ _g = (_g + 1)
+ value = Reflect.field(o,f)
+ setattr(o2,(("_hx_" + f) if ((f in python_Boot.keywords)) else (("_hx_" + f) if (((((len(f) > 2) and ((ord(f[0]) == 95))) and ((ord(f[1]) == 95))) and ((ord(f[(len(f) - 1)]) != 95)))) else f)),value)
+ return o2
+
class Std:
_hx_class_name = "Std"
@@ -984,7 +1021,11 @@ class python_HaxeIterator:
class python_internal_ArrayImpl:
_hx_class_name = "python.internal.ArrayImpl"
__slots__ = ()
- _hx_statics = ["concat", "copy", "iterator", "keyValueIterator", "indexOf", "lastIndexOf", "join", "toString", "pop", "push", "unshift", "remove", "contains", "shift", "slice", "sort", "splice", "map", "filter", "insert", "reverse", "_get"]
+ _hx_statics = ["get_length", "concat", "copy", "iterator", "keyValueIterator", "indexOf", "lastIndexOf", "join", "toString", "pop", "push", "unshift", "remove", "contains", "shift", "slice", "sort", "splice", "map", "filter", "insert", "reverse", "_get"]
+
+ @staticmethod
+ def get_length(x):
+ return len(x)
@staticmethod
def concat(a1,a2):
@@ -1120,7 +1161,7 @@ class python_internal_ArrayImpl:
class HxOverrides:
_hx_class_name = "HxOverrides"
__slots__ = ()
- _hx_statics = ["eq", "stringOrNull", "push", "arrayGet"]
+ _hx_statics = ["eq", "stringOrNull", "length", "arrayGet"]
@staticmethod
def eq(a,b):
@@ -1136,12 +1177,12 @@ class HxOverrides:
return s
@staticmethod
- def push(x,e):
- if isinstance(x,list):
- _this = x
- _this.append(e)
- return len(_this)
- return x.push(e)
+ def length(x):
+ if isinstance(x,str):
+ return len(x)
+ elif isinstance(x,list):
+ return len(x)
+ return x.length
@staticmethod
def arrayGet(a,i):
@@ -1173,7 +1214,7 @@ class python_internal_MethodClosure:
class HxString:
_hx_class_name = "HxString"
__slots__ = ()
- _hx_statics = ["split", "charCodeAt", "charAt", "lastIndexOf", "toUpperCase", "toLowerCase", "indexOf", "indexOfImpl", "toString", "substring", "substr"]
+ _hx_statics = ["split", "charCodeAt", "charAt", "lastIndexOf", "toUpperCase", "toLowerCase", "indexOf", "indexOfImpl", "toString", "get_length", "substring", "substr"]
@staticmethod
def split(s,d):
@@ -1252,6 +1293,10 @@ class HxString:
def toString(s):
return s
+ @staticmethod
+ def get_length(s):
+ return len(s)
+
@staticmethod
def substring(s,startIndex,endIndex = None):
if (startIndex < 0):
@@ -1280,156 +1325,73 @@ class HxString:
return s[startIndex:(startIndex + _hx_len)]
-class xrfragment_Parser:
- _hx_class_name = "xrfragment.Parser"
- __slots__ = ()
- _hx_statics = ["error", "debug", "parse"]
-
- @staticmethod
- def parse(key,value,store):
- Frag = haxe_ds_StringMap()
- Frag.h["#"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW) | xrfragment_XRF.PV_EXECUTE)
- Frag.h["prio"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_INT)
- Frag.h["src"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_URL)
- Frag.h["href"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.T_URL) | xrfragment_XRF.T_PREDEFINED_VIEW)
- Frag.h["tag"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
- Frag.h["pos"] = ((((xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.T_STRING_OBJ) | xrfragment_XRF.METADATA) | xrfragment_XRF.NAVIGATOR)
- Frag.h["q"] = ((xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING) | xrfragment_XRF.METADATA)
- Frag.h["scale"] = (((xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.METADATA)
- Frag.h["rot"] = ((((xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.METADATA) | xrfragment_XRF.NAVIGATOR)
- Frag.h["mov"] = (((xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.METADATA)
- Frag.h["show"] = (((xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_INT) | xrfragment_XRF.METADATA)
- Frag.h["env"] = (((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_STRING) | xrfragment_XRF.METADATA)
- Frag.h["t"] = ((((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_FLOAT) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.T_STRING) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
- Frag.h["tv"] = ((((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_FLOAT) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
- Frag.h["gravity"] = (((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.METADATA)
- Frag.h["physics"] = (((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.METADATA)
- Frag.h["fov"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_INT) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
- Frag.h["clip"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
- Frag.h["fog"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
- Frag.h["bg"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
- Frag.h["namespace"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
- Frag.h["SPDX"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
- Frag.h["unit"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
- Frag.h["description"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
- Frag.h["session"] = (((((xrfragment_XRF.ASSET | xrfragment_XRF.T_URL) | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA) | xrfragment_XRF.PROMPT)
- isPVDynamic = (((len(value) == 0) and ((len(key) > 0))) and (not (key in Frag.h)))
- isPVDefault = (((len(value) == 0) and ((len(key) > 0))) and ((key == "#")))
- if isPVDynamic:
- v = xrfragment_XRF(key,(xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR))
- v.validate(key)
- setattr(store,(("_hx_" + key) if ((key in python_Boot.keywords)) else (("_hx_" + key) if (((((len(key) > 2) and ((ord(key[0]) == 95))) and ((ord(key[1]) == 95))) and ((ord(key[(len(key) - 1)]) != 95)))) else key)),v)
- return True
- v = xrfragment_XRF(key,Frag.h.get(key,None))
- if (key in Frag.h):
- if (not v.validate(value)):
- print(str((((("⚠ fragment '" + ("null" if key is None else key)) + "' has incompatible value (") + ("null" if value is None else value)) + ")")))
- return False
- setattr(store,(("_hx_" + key) if ((key in python_Boot.keywords)) else (("_hx_" + key) if (((((len(key) > 2) and ((ord(key[0]) == 95))) and ((ord(key[1]) == 95))) and ((ord(key[(len(key) - 1)]) != 95)))) else key)),v)
- if xrfragment_Parser.debug:
- print(str(((("✔ " + ("null" if key is None else key)) + ": ") + HxOverrides.stringOrNull(v.string))))
- else:
- if Std.isOfType(value,str):
- v.guessType(v,value)
- v.noXRF = True
- setattr(store,(("_hx_" + key) if ((key in python_Boot.keywords)) else (("_hx_" + key) if (((((len(key) > 2) and ((ord(key[0]) == 95))) and ((ord(key[1]) == 95))) and ((ord(key[(len(key) - 1)]) != 95)))) else key)),v)
- return True
-
-
-class xrfragment_Query:
- _hx_class_name = "xrfragment.Query"
- __slots__ = ("str", "q", "isProp", "isExclude", "isRoot", "isNumber")
- _hx_fields = ["str", "q", "isProp", "isExclude", "isRoot", "isNumber"]
+class xrfragment_Filter:
+ _hx_class_name = "xrfragment.Filter"
+ __slots__ = ("str", "q")
+ _hx_fields = ["str", "q"]
_hx_methods = ["toObject", "get", "parse", "test", "testProperty"]
def __init__(self,_hx_str):
- self.isNumber = EReg("^[0-9\\.]+$","")
- self.isRoot = EReg("^[-]?/","")
- self.isExclude = EReg("^-","")
- self.isProp = EReg("^.*:[><=!]?","")
self.q = _hx_AnonObject({})
self.str = ""
if (_hx_str is not None):
self.parse(_hx_str)
def toObject(self):
- return self.q
+ return Reflect.copy(self.q)
def get(self):
- return self.q
+ return Reflect.copy(self.q)
def parse(self,_hx_str):
- _gthis = self
token = _hx_str.split(" ")
q = _hx_AnonObject({})
def _hx_local_0(_hx_str,prefix = None):
if (prefix is None):
prefix = ""
_hx_str = StringTools.trim(_hx_str)
- k = HxOverrides.arrayGet(_hx_str.split(":"), 0)
- v = HxOverrides.arrayGet(_hx_str.split(":"), 1)
+ k = HxOverrides.arrayGet(_hx_str.split("="), 0)
+ v = HxOverrides.arrayGet(_hx_str.split("="), 1)
_hx_filter = _hx_AnonObject({})
if Reflect.field(q,(("null" if prefix is None else prefix) + ("null" if k is None else k))):
_hx_filter = Reflect.field(q,(("null" if prefix is None else prefix) + ("null" if k is None else k)))
- value = (Reflect.field(_hx_filter,"rules") if ((Reflect.field(_hx_filter,"rules") is not None)) else list())
- setattr(_hx_filter,(("_hx_" + "rules") if (("rules" in python_Boot.keywords)) else (("_hx_" + "rules") if (((((len("rules") > 2) and ((ord("rules"[0]) == 95))) and ((ord("rules"[1]) == 95))) and ((ord("rules"[(len("rules") - 1)]) != 95)))) else "rules")),value)
- _this = _gthis.isProp
+ _this = xrfragment_XRF.isProp
_this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
if (_this.matchObj is not None):
oper = ""
startIndex = None
- if (((_hx_str.find("*") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"*",startIndex))) != -1):
- oper = "*"
- startIndex = None
if (((_hx_str.find(">") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,">",startIndex))) != -1):
oper = ">"
startIndex = None
if (((_hx_str.find("<") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"<",startIndex))) != -1):
oper = "<"
- startIndex = None
- if (((_hx_str.find(">=") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,">=",startIndex))) != -1):
- oper = ">="
- startIndex = None
- if (((_hx_str.find("<=") if ((startIndex is None)) else HxString.indexOfImpl(_hx_str,"<=",startIndex))) != -1):
- oper = "<="
- _this = _gthis.isExclude
+ _this = xrfragment_XRF.isExclude
_this.matchObj = python_lib_Re.search(_this.pattern,k)
if (_this.matchObj is not None):
- oper = "!="
k = HxString.substr(k,1,None)
- else:
- v = HxString.substr(v,len(oper),None)
+ v = HxString.substr(v,len(oper),None)
if (len(oper) == 0):
oper = "="
rule = _hx_AnonObject({})
- _this = _gthis.isNumber
+ _this = xrfragment_XRF.isNumber
_this.matchObj = python_lib_Re.search(_this.pattern,v)
if (_this.matchObj is not None):
value = Std.parseFloat(v)
setattr(rule,(("_hx_" + oper) if ((oper in python_Boot.keywords)) else (("_hx_" + oper) if (((((len(oper) > 2) and ((ord(oper[0]) == 95))) and ((ord(oper[1]) == 95))) and ((ord(oper[(len(oper) - 1)]) != 95)))) else oper)),value)
else:
setattr(rule,(("_hx_" + oper) if ((oper in python_Boot.keywords)) else (("_hx_" + oper) if (((((len(oper) > 2) and ((ord(oper[0]) == 95))) and ((ord(oper[1]) == 95))) and ((ord(oper[(len(oper) - 1)]) != 95)))) else oper)),v)
- Reflect.field(Reflect.field(_hx_filter,"rules"),"push")(rule)
- setattr(q,(("_hx_" + k) if ((k in python_Boot.keywords)) else (("_hx_" + k) if (((((len(k) > 2) and ((ord(k[0]) == 95))) and ((ord(k[1]) == 95))) and ((ord(k[(len(k) - 1)]) != 95)))) else k)),_hx_filter)
- return
- else:
- _this = _gthis.isExclude
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- value = (False if ((_this.matchObj is not None)) else True)
- setattr(_hx_filter,(("_hx_" + "id") if (("id" in python_Boot.keywords)) else (("_hx_" + "id") if (((((len("id") > 2) and ((ord("id"[0]) == 95))) and ((ord("id"[1]) == 95))) and ((ord("id"[(len("id") - 1)]) != 95)))) else "id")),value)
- _this = _gthis.isRoot
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- value = (_this.matchObj is not None)
- setattr(_hx_filter,(("_hx_" + "root") if (("root" in python_Boot.keywords)) else (("_hx_" + "root") if (((((len("root") > 2) and ((ord("root"[0]) == 95))) and ((ord("root"[1]) == 95))) and ((ord("root"[(len("root") - 1)]) != 95)))) else "root")),value)
- _this = _gthis.isExclude
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- if (_this.matchObj is not None):
- _hx_str = HxString.substr(_hx_str,1,None)
- _this = _gthis.isRoot
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- if (_this.matchObj is not None):
- _hx_str = HxString.substr(_hx_str,1,None)
- setattr(q,(("_hx_" + _hx_str) if ((_hx_str in python_Boot.keywords)) else (("_hx_" + _hx_str) if (((((len(_hx_str) > 2) and ((ord(_hx_str[0]) == 95))) and ((ord(_hx_str[1]) == 95))) and ((ord(_hx_str[(len(_hx_str) - 1)]) != 95)))) else _hx_str)),_hx_filter)
+ setattr(q,(("_hx_" + "expr") if (("expr" in python_Boot.keywords)) else (("_hx_" + "expr") if (((((len("expr") > 2) and ((ord("expr"[0]) == 95))) and ((ord("expr"[1]) == 95))) and ((ord("expr"[(len("expr") - 1)]) != 95)))) else "expr")),rule)
+ _this = xrfragment_XRF.isDeep
+ _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
+ value = ((Reflect.field(k.split("*"),"length") - 1) if ((_this.matchObj is not None)) else 0)
+ setattr(q,(("_hx_" + "deep") if (("deep" in python_Boot.keywords)) else (("_hx_" + "deep") if (((((len("deep") > 2) and ((ord("deep"[0]) == 95))) and ((ord("deep"[1]) == 95))) and ((ord("deep"[(len("deep") - 1)]) != 95)))) else "deep")),value)
+ _this = xrfragment_XRF.isExclude
+ _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
+ value = (False if ((_this.matchObj is not None)) else True)
+ setattr(q,(("_hx_" + "show") if (("show" in python_Boot.keywords)) else (("_hx_" + "show") if (((((len("show") > 2) and ((ord("show"[0]) == 95))) and ((ord("show"[1]) == 95))) and ((ord("show"[(len("show") - 1)]) != 95)))) else "show")),value)
+ value = xrfragment_XRF.operators.replace(k,"")
+ setattr(q,(("_hx_" + "key") if (("key" in python_Boot.keywords)) else (("_hx_" + "key") if (((((len("key") > 2) and ((ord("key"[0]) == 95))) and ((ord("key"[1]) == 95))) and ((ord("key"[(len("key") - 1)]) != 95)))) else "key")),value)
+ setattr(q,(("_hx_" + "value") if (("value" in python_Boot.keywords)) else (("_hx_" + "value") if (((((len("value") > 2) and ((ord("value"[0]) == 95))) and ((ord("value"[1]) == 95))) and ((ord("value"[(len("value") - 1)]) != 95)))) else "value")),v)
process = _hx_local_0
_g = 0
_g1 = len(token)
@@ -1479,39 +1441,69 @@ class xrfragment_Query:
v = Reflect.field(self.q,value)
if (Reflect.field(v,property) is not None):
return Reflect.field(v,property)
- _g = 0
- _g1 = python_Boot.fields(self.q)
- while (_g < len(_g1)):
- k = (_g1[_g] if _g >= 0 and _g < len(_g1) else None)
- _g = (_g + 1)
- _hx_filter = Reflect.field(self.q,k)
- if (Reflect.field(_hx_filter,"rules") is None):
- continue
- rules = Reflect.field(_hx_filter,"rules")
- _g2 = 0
- while (_g2 < len(rules)):
- rule = (rules[_g2] if _g2 >= 0 and _g2 < len(rules) else None)
- _g2 = (_g2 + 1)
- if exclude:
- if (((Reflect.field(rule,"!=") is not None) and testprop((Std.string(value) == Std.string(Reflect.field(rule,"!="))))) and exclude):
- qualify = (qualify + 1)
- else:
- if ((Reflect.field(rule,"*") is not None) and testprop((Std.parseFloat(value) is not None))):
- qualify = (qualify + 1)
- if ((Reflect.field(rule,">") is not None) and testprop((Std.parseFloat(value) > Std.parseFloat(Reflect.field(rule,">"))))):
- qualify = (qualify + 1)
- if ((Reflect.field(rule,"<") is not None) and testprop((Std.parseFloat(value) < Std.parseFloat(Reflect.field(rule,"<"))))):
- qualify = (qualify + 1)
- if ((Reflect.field(rule,">=") is not None) and testprop((Std.parseFloat(value) >= Std.parseFloat(Reflect.field(rule,">="))))):
- qualify = (qualify + 1)
- if ((Reflect.field(rule,"<=") is not None) and testprop((Std.parseFloat(value) <= Std.parseFloat(Reflect.field(rule,"<="))))):
- qualify = (qualify + 1)
- if ((Reflect.field(rule,"=") is not None) and ((testprop((value == Reflect.field(rule,"="))) or testprop((Std.parseFloat(value) == Std.parseFloat(Reflect.field(rule,"="))))))):
- qualify = (qualify + 1)
+ if Reflect.field(self.q,"expr"):
+ f = Reflect.field(self.q,"expr")
+ if (not Reflect.field(self.q,"show")):
+ if (((Reflect.field(f,"!=") is not None) and testprop((Std.string(value) == Std.string(Reflect.field(f,"!="))))) and exclude):
+ qualify = (qualify + 1)
+ else:
+ if ((Reflect.field(f,"*") is not None) and testprop((Std.parseFloat(value) is not None))):
+ qualify = (qualify + 1)
+ if ((Reflect.field(f,">") is not None) and testprop((Std.parseFloat(value) >= Std.parseFloat(Reflect.field(f,">"))))):
+ qualify = (qualify + 1)
+ if ((Reflect.field(f,"<") is not None) and testprop((Std.parseFloat(value) <= Std.parseFloat(Reflect.field(f,"<"))))):
+ qualify = (qualify + 1)
+ if ((Reflect.field(f,"=") is not None) and ((testprop((value == Reflect.field(f,"="))) or testprop((Std.parseFloat(value) == Std.parseFloat(Reflect.field(f,"="))))))):
+ qualify = (qualify + 1)
return (qualify > 0)
+class xrfragment_Parser:
+ _hx_class_name = "xrfragment.Parser"
+ __slots__ = ()
+ _hx_statics = ["error", "debug", "parse"]
+
+ @staticmethod
+ def parse(key,value,store,index = None):
+ Frag = haxe_ds_StringMap()
+ Frag.h["#"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW) | xrfragment_XRF.PV_EXECUTE)
+ Frag.h["src"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_URL)
+ Frag.h["href"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.T_URL) | xrfragment_XRF.T_PREDEFINED_VIEW)
+ Frag.h["tag"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
+ Frag.h["pos"] = (((((xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.T_STRING) | xrfragment_XRF.T_STRING_OBJ) | xrfragment_XRF.METADATA) | xrfragment_XRF.NAVIGATOR)
+ Frag.h["rot"] = ((((xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.METADATA) | xrfragment_XRF.NAVIGATOR)
+ Frag.h["t"] = ((((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_FLOAT) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.T_STRING) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
+ Frag.h["tv"] = ((((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_FLOAT) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.T_VECTOR3) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA)
+ Frag.h["namespace"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
+ Frag.h["SPDX"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
+ Frag.h["unit"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
+ Frag.h["description"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING)
+ Frag.h["session"] = (((((xrfragment_XRF.ASSET | xrfragment_XRF.T_URL) | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.NAVIGATOR) | xrfragment_XRF.METADATA) | xrfragment_XRF.PROMPT)
+ keyStripped = xrfragment_XRF.operators.replace(key,"")
+ isPVDynamic = ((len(key) > 0) and (not (key in Frag.h)))
+ isPVDefault = (((len(value) == 0) and ((len(key) > 0))) and ((key == "#")))
+ if isPVDynamic:
+ v = xrfragment_XRF(key,(xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR),index)
+ v.validate(value)
+ setattr(store,(("_hx_" + keyStripped) if ((keyStripped in python_Boot.keywords)) else (("_hx_" + keyStripped) if (((((len(keyStripped) > 2) and ((ord(keyStripped[0]) == 95))) and ((ord(keyStripped[1]) == 95))) and ((ord(keyStripped[(len(keyStripped) - 1)]) != 95)))) else keyStripped)),v)
+ return True
+ v = xrfragment_XRF(key,Frag.h.get(key,None),index)
+ if (key in Frag.h):
+ if (not v.validate(value)):
+ print(str((((("⚠ fragment '" + ("null" if key is None else key)) + "' has incompatible value (") + ("null" if value is None else value)) + ")")))
+ return False
+ setattr(store,(("_hx_" + keyStripped) if ((keyStripped in python_Boot.keywords)) else (("_hx_" + keyStripped) if (((((len(keyStripped) > 2) and ((ord(keyStripped[0]) == 95))) and ((ord(keyStripped[1]) == 95))) and ((ord(keyStripped[(len(keyStripped) - 1)]) != 95)))) else keyStripped)),v)
+ if xrfragment_Parser.debug:
+ print(str(((("✔ " + ("null" if key is None else key)) + ": ") + HxOverrides.stringOrNull(v.string))))
+ else:
+ if Std.isOfType(value,str):
+ v.guessType(v,value)
+ v.noXRF = True
+ setattr(store,(("_hx_" + keyStripped) if ((keyStripped in python_Boot.keywords)) else (("_hx_" + keyStripped) if (((((len(keyStripped) > 2) and ((ord(keyStripped[0]) == 95))) and ((ord(keyStripped[1]) == 95))) and ((ord(keyStripped[(len(keyStripped) - 1)]) != 95)))) else keyStripped)),v)
+ return True
+
+
class xrfragment_URI:
_hx_class_name = "xrfragment.URI"
__slots__ = ()
@@ -1544,7 +1536,7 @@ class xrfragment_URI:
if (len(splitByEqual) > 1):
_this1 = regexPlus.split((splitByEqual[1] if 1 < len(splitByEqual) else None))
value = python_lib_urllib_Parse.unquote(" ".join([python_Boot.toString1(x1,'') for x1 in _this1]))
- ok = xrfragment_Parser.parse(key,value,store)
+ ok = xrfragment_Parser.parse(key,value,store,i)
if ((_hx_filter is not None) and ((_hx_filter != 0))):
_g = 0
_g1 = python_Boot.fields(store)
@@ -1559,14 +1551,14 @@ class xrfragment_URI:
class xrfragment_XRF:
_hx_class_name = "xrfragment.XRF"
- __slots__ = ("fragment", "flags", "x", "y", "z", "w", "color", "string", "int", "float", "query", "noXRF")
- _hx_fields = ["fragment", "flags", "x", "y", "z", "w", "color", "string", "int", "float", "query", "noXRF"]
+ __slots__ = ("fragment", "flags", "index", "x", "y", "z", "w", "color", "string", "int", "float", "filter", "noXRF")
+ _hx_fields = ["fragment", "flags", "index", "x", "y", "z", "w", "color", "string", "int", "float", "filter", "noXRF"]
_hx_methods = ["is", "validate", "guessType"]
- _hx_statics = ["ASSET", "PROP_BIND", "QUERY_OPERATOR", "PROMPT", "ROUNDROBIN", "NAVIGATOR", "METADATA", "PV_OVERRIDE", "PV_EXECUTE", "T_COLOR", "T_INT", "T_FLOAT", "T_VECTOR2", "T_VECTOR3", "T_URL", "T_PREDEFINED_VIEW", "T_STRING", "T_STRING_OBJ", "T_STRING_OBJ_PROP", "isColor", "isInt", "isFloat", "isVector", "isUrl", "isUrlOrPretypedView", "isString", "set", "unset"]
+ _hx_statics = ["ASSET", "PROP_BIND", "QUERY_OPERATOR", "PROMPT", "ROUNDROBIN", "NAVIGATOR", "METADATA", "PV_OVERRIDE", "PV_EXECUTE", "T_COLOR", "T_INT", "T_FLOAT", "T_VECTOR2", "T_VECTOR3", "T_URL", "T_PREDEFINED_VIEW", "T_STRING", "T_STRING_OBJ", "T_STRING_OBJ_PROP", "isColor", "isInt", "isFloat", "isVector", "isUrl", "isUrlOrPretypedView", "isString", "operators", "isProp", "isExclude", "isDeep", "isNumber", "set", "unset"]
- def __init__(self,_fragment,_flags):
+ def __init__(self,_fragment,_flags,_index = None):
self.noXRF = None
- self.query = None
+ self.filter = None
self.float = None
self.int = None
self.string = None
@@ -1577,6 +1569,7 @@ class xrfragment_XRF:
self.x = None
self.fragment = _fragment
self.flags = _flags
+ self.index = _index
def _hx_is(self,flag):
if (not Std.isOfType(self.flags,Int)):
@@ -1585,41 +1578,45 @@ class xrfragment_XRF:
def validate(self,value):
self.guessType(self,value)
- if (self.fragment == "q"):
- self.query = xrfragment_Query(value).get()
ok = True
if (((not self._hx_is(xrfragment_XRF.T_FLOAT)) and self._hx_is(xrfragment_XRF.T_VECTOR2)) and (not ((Std.isOfType(self.x,Float) and Std.isOfType(self.y,Float))))):
ok = False
- if (((not self._hx_is(xrfragment_XRF.T_VECTOR2)) and self._hx_is(xrfragment_XRF.T_VECTOR3)) and (not (((Std.isOfType(self.x,Float) and Std.isOfType(self.y,Float)) and Std.isOfType(self.z,Float))))):
+ if (((not ((self._hx_is(xrfragment_XRF.T_VECTOR2) or self._hx_is(xrfragment_XRF.T_STRING)))) and self._hx_is(xrfragment_XRF.T_VECTOR3)) and (not (((Std.isOfType(self.x,Float) and Std.isOfType(self.y,Float)) and Std.isOfType(self.z,Float))))):
ok = False
return ok
def guessType(self,v,_hx_str):
v.string = _hx_str
- if (len(_hx_str.split(",")) > 1):
- xyzw = _hx_str.split(",")
- if (len(xyzw) > 0):
- v.x = Std.parseFloat((xyzw[0] if 0 < len(xyzw) else None))
- if (len(xyzw) > 1):
- v.y = Std.parseFloat((xyzw[1] if 1 < len(xyzw) else None))
- if (len(xyzw) > 2):
- v.z = Std.parseFloat((xyzw[2] if 2 < len(xyzw) else None))
- if (len(xyzw) > 3):
- v.w = Std.parseFloat((xyzw[3] if 3 < len(xyzw) else None))
- _this = xrfragment_XRF.isColor
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- if (_this.matchObj is not None):
- v.color = _hx_str
- _this = xrfragment_XRF.isFloat
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- if (_this.matchObj is not None):
- v.x = Std.parseFloat(_hx_str)
- v.float = v.x
- _this = xrfragment_XRF.isInt
- _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
- if (_this.matchObj is not None):
- v.int = Std.parseInt(_hx_str)
- v.x = v.int
+ if (not Std.isOfType(_hx_str,str)):
+ return
+ if (len(_hx_str) > 0):
+ if (len(_hx_str.split(",")) > 1):
+ xyzw = _hx_str.split(",")
+ if (len(xyzw) > 0):
+ v.x = Std.parseFloat((xyzw[0] if 0 < len(xyzw) else None))
+ if (len(xyzw) > 1):
+ v.y = Std.parseFloat((xyzw[1] if 1 < len(xyzw) else None))
+ if (len(xyzw) > 2):
+ v.z = Std.parseFloat((xyzw[2] if 2 < len(xyzw) else None))
+ if (len(xyzw) > 3):
+ v.w = Std.parseFloat((xyzw[3] if 3 < len(xyzw) else None))
+ _this = xrfragment_XRF.isColor
+ _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
+ if (_this.matchObj is not None):
+ v.color = _hx_str
+ _this = xrfragment_XRF.isFloat
+ _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
+ if (_this.matchObj is not None):
+ v.x = Std.parseFloat(_hx_str)
+ v.float = v.x
+ _this = xrfragment_XRF.isInt
+ _this.matchObj = python_lib_Re.search(_this.pattern,_hx_str)
+ if (_this.matchObj is not None):
+ v.int = Std.parseInt(_hx_str)
+ v.x = v.int
+ v.filter = xrfragment_Filter(((HxOverrides.stringOrNull(v.fragment) + "=") + HxOverrides.stringOrNull(v.string)))
+ else:
+ v.filter = xrfragment_Filter(v.fragment)
@staticmethod
def set(flag,flags):
@@ -1664,4 +1661,9 @@ xrfragment_XRF.isFloat = EReg("^[-0-9]+\\.[0-9]+$","")
xrfragment_XRF.isVector = EReg("([,]+|\\w)","")
xrfragment_XRF.isUrl = EReg("(://)?\\..*","")
xrfragment_XRF.isUrlOrPretypedView = EReg("(^#|://)?\\..*","")
-xrfragment_XRF.isString = EReg(".*","")
\ No newline at end of file
+xrfragment_XRF.isString = EReg(".*","")
+xrfragment_XRF.operators = EReg("(^-|[\\*]+)","")
+xrfragment_XRF.isProp = EReg("^.*=[><=]?","")
+xrfragment_XRF.isExclude = EReg("^-","")
+xrfragment_XRF.isDeep = EReg("\\*","")
+xrfragment_XRF.isNumber = EReg("^[0-9\\.]+$","")
\ No newline at end of file
diff --git a/dist/xrfragment.three.js b/dist/xrfragment.three.js
index 859985c..7bb3b74 100644
--- a/dist/xrfragment.three.js
+++ b/dist/xrfragment.three.js
@@ -1,3 +1,8 @@
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
(function ($global) { "use strict";
$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
@@ -72,6 +77,20 @@ Reflect.deleteField = function(o,field) {
delete(o[field]);
return true;
};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
@@ -209,83 +228,22 @@ js_Boot.__string_rec = function(o,s) {
return String(o);
}
};
-var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
-xrfragment_Parser.__name__ = true;
-xrfragment_Parser.parse = function(key,value,store) {
- var Frag_h = Object.create(null);
- Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
- Frag_h["prio"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_INT;
- Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
- Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
- Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["q"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["scale"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["mov"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["show"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.METADATA;
- Frag_h["env"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["gravity"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["physics"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["fov"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["clip"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["fog"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["bg"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
- var isPVDynamic = value.length == 0 && key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
- var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
- if(isPVDynamic) {
- var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR);
- v.validate(key);
- store[key] = v;
- return true;
- }
- var v = new xrfragment_XRF(key,Frag_h[key]);
- if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
- if(!v.validate(value)) {
- console.log("src/xrfragment/Parser.hx:80:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
- return false;
- }
- store[key] = v;
- if(xrfragment_Parser.debug) {
- console.log("src/xrfragment/Parser.hx:84:","✔ " + key + ": " + v.string);
- }
- } else {
- if(typeof(value) == "string") {
- v.guessType(v,value);
- }
- v.noXRF = true;
- store[key] = v;
- }
- return true;
-};
-var xrfragment_Query = $hx_exports["xrfragment"]["Query"] = function(str) {
- this.isNumber = new EReg("^[0-9\\.]+$","");
- this.isRoot = new EReg("^[-]?/","");
- this.isExclude = new EReg("^-","");
- this.isProp = new EReg("^.*:[><=!]?","");
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
this.q = { };
this.str = "";
if(str != null) {
this.parse(str);
}
};
-xrfragment_Query.__name__ = true;
-xrfragment_Query.prototype = {
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
toObject: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,get: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,parse: function(str) {
- var _gthis = this;
var token = str.split(" ");
var q = { };
var process = function(str,prefix) {
@@ -293,59 +251,42 @@ xrfragment_Query.prototype = {
prefix = "";
}
str = StringTools.trim(str);
- var k = str.split(":")[0];
- var v = str.split(":")[1];
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
var filter = { };
if(q[prefix + k]) {
filter = q[prefix + k];
}
- filter["rules"] = filter["rules"] != null ? filter["rules"] : [];
- if(_gthis.isProp.match(str)) {
+ if(xrfragment_XRF.isProp.match(str)) {
var oper = "";
- if(str.indexOf("*") != -1) {
- oper = "*";
- }
if(str.indexOf(">") != -1) {
oper = ">";
}
if(str.indexOf("<") != -1) {
oper = "<";
}
- if(str.indexOf(">=") != -1) {
- oper = ">=";
- }
- if(str.indexOf("<=") != -1) {
- oper = "<=";
- }
- if(_gthis.isExclude.match(k)) {
- oper = "!=";
+ if(xrfragment_XRF.isExclude.match(k)) {
k = HxOverrides.substr(k,1,null);
- } else {
- v = HxOverrides.substr(v,oper.length,null);
}
+ v = HxOverrides.substr(v,oper.length,null);
if(oper.length == 0) {
oper = "=";
}
var rule = { };
- if(_gthis.isNumber.match(v)) {
+ if(xrfragment_XRF.isNumber.match(v)) {
rule[oper] = parseFloat(v);
} else {
rule[oper] = v;
}
- filter["rules"].push(rule);
- q[k] = filter;
- return;
- } else {
- filter["id"] = _gthis.isExclude.match(str) ? false : true;
- filter["root"] = _gthis.isRoot.match(str);
- if(_gthis.isExclude.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- if(_gthis.isRoot.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- q[str] = filter;
+ q["expr"] = rule;
}
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
};
var _g = 0;
var _g1 = token.length;
@@ -394,49 +335,75 @@ xrfragment_Query.prototype = {
return v[property];
}
}
- var _g = 0;
- var _g1 = Reflect.fields(this.q);
- while(_g < _g1.length) {
- var k = _g1[_g];
- ++_g;
- var filter = Reflect.field(this.q,k);
- if(filter.rules == null) {
- continue;
- }
- var rules = filter.rules;
- var _g2 = 0;
- while(_g2 < rules.length) {
- var rule = rules[_g2];
- ++_g2;
- if(exclude) {
- if(Reflect.field(rule,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(rule,"!="))) && exclude) {
- ++qualify;
- }
- } else {
- if(Reflect.field(rule,"*") != null && testprop(parseFloat(value) != null)) {
- ++qualify;
- }
- if(Reflect.field(rule,">") != null && testprop(parseFloat(value) > parseFloat(Reflect.field(rule,">")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<") != null && testprop(parseFloat(value) < parseFloat(Reflect.field(rule,"<")))) {
- ++qualify;
- }
- if(Reflect.field(rule,">=") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(rule,">=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<=") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(rule,"<=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"=") != null && (testprop(value == Reflect.field(rule,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(rule,"="))))) {
- ++qualify;
- }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
}
}
}
return qualify > 0;
}
};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
@@ -458,7 +425,7 @@ xrfragment_URI.parse = function(url,filter) {
var s = regexPlus.split(splitByEqual[1]).join(" ");
value = decodeURIComponent(s.split("+").join(" "));
}
- var ok = xrfragment_Parser.parse(key,value,store);
+ var ok = xrfragment_Parser.parse(key,value,store,i);
}
if(filter != null && filter != 0) {
var _g = 0;
@@ -474,9 +441,10 @@ xrfragment_URI.parse = function(url,filter) {
}
return store;
};
-var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) {
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
this.fragment = _fragment;
this.flags = _flags;
+ this.index = _index;
};
xrfragment_XRF.__name__ = true;
xrfragment_XRF.set = function(flag,flags) {
@@ -495,45 +463,50 @@ xrfragment_XRF.prototype = {
}
,validate: function(value) {
this.guessType(this,value);
- if(this.fragment == "q") {
- this.query = new xrfragment_Query(value).get();
- }
var ok = true;
if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
ok = false;
}
- if(!this.is(xrfragment_XRF.T_VECTOR2) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
ok = false;
}
return ok;
}
,guessType: function(v,str) {
v.string = str;
- if(str.split(",").length > 1) {
- var xyzw = str.split(",");
- if(xyzw.length > 0) {
- v.x = parseFloat(xyzw[0]);
- }
- if(xyzw.length > 1) {
- v.y = parseFloat(xyzw[1]);
- }
- if(xyzw.length > 2) {
- v.z = parseFloat(xyzw[2]);
- }
- if(xyzw.length > 3) {
- v.w = parseFloat(xyzw[3]);
- }
+ if(typeof(str) != "string") {
+ return;
}
- if(xrfragment_XRF.isColor.match(str)) {
- v.color = str;
- }
- if(xrfragment_XRF.isFloat.match(str)) {
- v.x = parseFloat(str);
- v.float = v.x;
- }
- if(xrfragment_XRF.isInt.match(str)) {
- v.int = Std.parseInt(str);
- v.x = v.int;
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
}
}
};
@@ -571,6 +544,11 @@ xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
})({});
var xrfragment = $hx_exports["xrfragment"];
// SPDX-License-Identifier: MPL-2.0
@@ -579,7 +557,8 @@ var xrfragment = $hx_exports["xrfragment"];
var xrf = {}
xrf.init = function(opts){
- opts = opts || {}
+ opts = opts || {}
+ xrf.debug = parseInt( ( document.location.hash.match(/debug=([0-9])/) || [0,'0'] )[1] )
xrf.Parser.debug = xrf.debug
xrf.detectCameraRig(opts)
for ( let i in opts ) xrf[i] = opts[i]
@@ -624,7 +603,7 @@ xrf.hasTag = (tag,tags) => String(tags).match( new RegExp(`(^| )${tag}( |$)`,`g`
// map library functions to xrf
for ( let i in xrfragment ) xrf[i] = xrfragment[i]
/*
- * (promise-able) EVENTS
+ * (promise-able) EVENTS (optionally continue after listeners are finished using .then)
*
* example:
*
@@ -649,14 +628,23 @@ xrf.addEventListener = function(eventName, callback, scene) {
// add the callback to the listeners array for this event name
this._listeners[eventName].push(callback);
return () => {
- console.log("size = "+this._listeners[eventName].length)
this._listeners[eventName] = this._listeners[eventName].filter( (c) => c != callback )
- console.log("size = "+this._listeners[eventName].length)
}
};
xrf.emit = function(eventName, data){
if( typeof data != 'object' ) throw 'emit() requires passing objects'
+ if( xrf.debug && ( eventName != "render" || xrf.debug == eventName ) ){
+ let label = String(`xrf.emit('${eventName}')`).padEnd(35," ");
+ label += data.mesh && data.mesh.name ? '#'+data.mesh.name : ''
+ console.groupCollapsed(label)
+ console.info(data)
+ console.groupEnd(label)
+ if( xrf.debug > 1 ) debugger
+ }
+ // forward to THREEjs eventbus if any
+ if( data.scene ) data.scene.dispatchEvent( eventName, data )
+ if( data.mesh ) data.mesh.dispatchEvent( eventName, data )
return xrf.emit.promise(eventName,data)
}
@@ -671,15 +659,21 @@ xrf.emit.normal = function(eventName, data) {
};
xrf.emit.promise = function(e, opts){
- opts.XRF = xrf // always pass root XRF obj
return new Promise( (resolve, reject) => {
opts.promise = () => {
- opts.promise.halted = true
- return { resolve, reject }
+ opts.promises = opts.promises || []
+ opts.promises.push(0)
+ return {
+ resolve: ((index) => () => {
+ opts.promises[index] = 1
+ let succesful = opts.promises.reduce( (a,b) => a+b )
+ if( succesful == opts.promises.length ) resolve(opts)
+ })(opts.promises.length-1),
+ reject: console.error
+ }
}
xrf.emit.normal(e, opts)
- delete opts.XRF
- if( !opts.promise.halted ) resolve()
+ if( !opts.promises ) resolve(opts)
delete opts.promise
})
}
@@ -687,7 +681,8 @@ xrf.emit.promise = function(e, opts){
* http://www.github.com/cburgmer/rasterizeHTML.js
* Copyright (c) 2023 Christoph Burgmer; Licensed MIT */
-!function(o,i){void 0===o&&void 0!==window&&(o=window),"function"==typeof define&&define.amd?define(["url","xmlserializer","sane-domparser-error","inlineresources"],function(e,t,n,r){return o.rasterizeHTML=i(e,t,n,r)}):"object"==typeof module&&module.exports?module.exports=i(require("url"),require("xmlserializer"),require("sane-domparser-error"),require("inlineresources")):o.rasterizeHTML=i(o.url,o.xmlserializer,o.sanedomparsererror,o.inlineresources)}(this,function(e,t,n,r){var o=function(n){"use strict";var o={},t=[];o.joinUrl=function(e,t){return e?n.resolve(e,t):t},o.getConstantUniqueIdFor=function(e){return t.indexOf(e)<0&&t.push(e),t.indexOf(e)},o.clone=function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};return o.parseOptionalParameters=function(e){var t,n,r={canvas:null,options:{}};return null==e[0]||(t=e[0],"object"==typeof(n=t)&&null!==n&&Object.prototype.toString.apply(t).match(/\[object (Canvas|HTMLCanvasElement)\]/i))?(r.canvas=e[0]||null,r.options=o.clone(e[1])):r.options=o.clone(e[0]),r},o}(e),i=function(i){"use strict";function u(e,t,n){var r=e[t];return e[t]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(this,[e,r])},r}var e={};return e.baseUrlRespectingXhr=function(t,o){return function(){var e=new t;return u(e,"open",function(e,t){var n=e.shift(),r=e.shift(),r=i.joinUrl(o,r);return t.apply(this,[n,r].concat(e))}),e}},e.finishNotifyingXhr=function(t){function e(){var e=new t;return u(e,"send",function(e,t){return r+=1,t.apply(this,arguments)}),e.addEventListener("load",function(){o+=1,n()}),e}var n,r=0,o=0,i=!1,c=new Promise(function(e){n=function(){r-o<=0&&i&&e({totalCount:r})}});return e.waitForRequestsToFinish=function(){return i=!0,n(),c},e},e}(o),e=function(i){"use strict";function r(e){return Array.prototype.slice.call(e)}var e={},c={active:!0,hover:!0,focus:!1,target:!1};return e.fakeUserAction=function(e,t,n){var r=e.querySelector(t),o=":"+n,t="rasterizehtml"+n;r&&(c[n]?i.addClassNameRecursively(r,t):i.addClassName(r,t),i.rewriteCssSelectorWith(e,o,"."+t))},e.persistInputValues=function(e){function t(e){return"checkbox"===e.type||"radio"===e.type}var n=e.querySelectorAll("input"),e=e.querySelectorAll("textarea");r(n).filter(t).forEach(function(e){e.checked?e.setAttribute("checked",""):e.removeAttribute("checked")}),r(n).filter(function(e){return!t(e)}).forEach(function(e){e.setAttribute("value",e.value)}),r(e).forEach(function(e){e.textContent=e.value})},e.rewriteTagNameSelectorsToLowerCase=function(e){i.lowercaseCssTypeSelectors(e,i.findHtmlOnlyNodeNames(e))},e}(function(){"use strict";function c(e){return Array.prototype.slice.call(e)}var n={};n.addClassName=function(e,t){e.className+=" "+t},n.addClassNameRecursively=function(e,t){n.addClassName(e,t),e.parentNode!==e.ownerDocument&&n.addClassNameRecursively(e.parentNode,t)};function r(e,t,o){var i="((?:^|[^.#:\\w])|(?=\\W))("+t.join("|")+")(?=\\W|$)";c(e.querySelectorAll("style")).forEach(function(e){var t,n;void 0===e.sheet&&(t=e,n=document.implementation.createHTMLDocument(""),(r=document.createElement("style")).textContent=t.textContent,n.body.appendChild(r),t.sheet=r.sheet);var r=c(e.sheet.cssRules).filter(function(e){return e.selectorText&&new RegExp(i,"i").test(e.selectorText)});r.length&&(r.forEach(function(e){var t,n=e.selectorText.replace(new RegExp(i,"gi"),function(e,t,n){return t+o(n)});n!==e.selectorText&&(t=n,e=(n=e).cssText.replace(/^[^\{]+/,""),u(n,t+" "+e))}),e.textContent=a(e.sheet.cssRules))})}var u=function(e,t){var n=e.parentStyleSheet,e=c(n.cssRules).indexOf(e);n.insertRule(t,e+1),n.deleteRule(e)},a=function(e){return c(e).reduce(function(e,t){return e+t.cssText},"")};return n.rewriteCssSelectorWith=function(e,t,n){r(e,[t],function(){return n})},n.lowercaseCssTypeSelectors=function(e,t){r(e,t,function(e){return e.toLowerCase()})},n.findHtmlOnlyNodeNames=function(e){for(var t,n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r={},o={};t=n.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===n.currentNode.namespaceURI?r[t]=!0:o[t]=!0,n.nextNode(););return Object.keys(r).filter(function(e){return!o[e]})},n}()),i=function(a,f,t,m){"use strict";var e={};e.executeJavascript=function(s,l){return new Promise(function(t){function n(){m.document.getElementsByTagName("body")[0].removeChild(r)}function e(){var e=r.contentDocument;t({document:e,errors:i,cleanUp:n})}var r=function(e,t,n,r){t=e.createElement(t);return t.style.visibility="hidden",t.style.width=n+"px",t.style.height=r+"px",t.style.position="absolute",t.style.top=-1e4-r+"px",t.style.left=-1e4-n+"px",e.getElementsByTagName("body")[0].appendChild(t),t}(m.document,"iframe",l.width,l.height),o=s.outerHTML,i=[],c=l.executeJsTimeout||0,u=r.contentWindow.XMLHttpRequest,a=f.finishNotifyingXhr(u),u=f.baseUrlRespectingXhr(a,l.baseUrl);r.onload=function(){var t;(0<(t=c)?new Promise(function(e){setTimeout(e,t)}):Promise.resolve()).then(a.waitForRequestsToFinish).then(e)},r.contentDocument.open(),r.contentWindow.XMLHttpRequest=u,r.contentWindow.onerror=function(e){i.push({resourceType:"scriptExecution",msg:e})},r.contentDocument.write(""),r.contentDocument.write(o),r.contentDocument.close()})};function s(e,t,n,r,o){var i,c,u,a=Math.max(e.scrollWidth,e.clientWidth),s=Math.max(e.scrollHeight,e.clientHeight),l=t?(i=(l=function(e,t){var n=e.querySelector(t);if(n)return n;if(e.ownerDocument.querySelector(t)===e)return e;throw{message:"Clipping selector not found"}}(e,t).getBoundingClientRect()).top,c=l.left,u=l.width,l.height):(c=i=0,u=a,s);return l={width:u,height:l},r=r,o=o,r={width:Math.max(l.width*o,n),height:Math.max(l.height*o,r)},e=m.getComputedStyle(e.ownerDocument.documentElement).fontSize,{left:c,top:i,width:r.width,height:r.height,viewportWidth:a,viewportHeight:s,rootFontSize:e}}e.calculateDocumentContentSize=function(c,u){return new Promise(function(n,r){var e,t,o=u.zoom||1,i=function(e,t,n){e=Math.floor(e/n),n=Math.floor(t/n);return function(e,t,n){e=e.createElement("iframe");return e.style.width=t+"px",e.style.height=n+"px",e.style.visibility="hidden",e.style.position="absolute",e.style.top=-1e4-n+"px",e.style.left=-1e4-t+"px",e.style.borderWidth=0,e.sandbox="allow-same-origin",e.scrolling="no",e}(m.document,e,n)}(u.width,u.height,o);m.document.getElementsByTagName("body")[0].appendChild(i),i.onload=function(){var e,t=i.contentDocument;try{e=s(function(e,t){e=e.tagName;return t.querySelector(e)}(c,t),u.clip,u.width,u.height,o),n(e)}catch(e){r(e)}finally{m.document.getElementsByTagName("body")[0].removeChild(i)}},i.contentDocument.open(),i.contentDocument.write(""),i.contentDocument.write("html"===(t=(e=c).tagName.toLowerCase())||"body"===t?e.outerHTML:''+e.outerHTML+""),i.contentDocument.close()})},e.parseHtmlFragment=function(e){var t=m.document.implementation.createHTMLDocument("");t.documentElement.innerHTML=e;t=t.querySelector("body").firstChild;if(!t)throw"Invalid source";return t};e.parseHTML=function(e){var t=m.document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,function(e,t){var n,r,o,i=/]*)?)>/im.exec(t),t=m.document.implementation.createHTMLDocument("");if(i)for(i="",t.documentElement.innerHTML=i,r=t.querySelector("div"),n=0;n',n=function(){return new Promise(function(t,e){var n;(function(){if(r.Blob)try{return new Blob([""],{type:"text/xml"}),!0}catch(e){}return!1})()&&r.URL?(n=o(a,!0),i(n).then(function(e){return c(n),!e&&i(o(a,!1)).then(function(e){return e})},function(){return!1}).then(function(e){t(!e)},function(){e()})):t(!1)})};return t.renderSvg=function(i){return new Promise(function(e,t){function n(){r&&c(r)}var r,o=new Image;o.onload=function(){o.onload=null,o.onerror=null,n(),e(o)},o.onerror=function(){n(),t()},u(i).then(function(e){r=e,o.src=r},t)})},t}(window);return function(o,i,c){"use strict";var u={};u.drawDocument=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n=o.parseOptionalParameters(t),r=e.documentElement||e;return c.rasterize(r,n.canvas,(e=(t=n).canvas,r=t.options,n=e?e.width:300,e=e?e.height:200,e={width:void 0!==r.width?r.width:n,height:void 0!==r.height?r.height:e},(t=o.clone(t.options)).width=e.width,t.height=e.height,t))};u.drawHTML=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return function(e,t,n){e=i.parseHTML(e);return u.drawDocument(e,t,n)}(e,t.canvas,t.options)};function n(t,n,r){return i.loadDocument(t,r).then(function(e){e=function(e,t,n){var r=document.implementation.createHTMLDocument("");r.replaceChild(e.documentElement,r.documentElement);e=n?o.clone(n):{};return n.baseUrl||(e.baseUrl=t),{document:r,options:e}}(e,t,r);return u.drawDocument(e.document,n,e.options)})}return u.drawURL=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return n(e,t.canvas,t.options)},u}(o,i,function(o,i,c,r,e,u){"use strict";function a(t){return e.renderSvg(t).then(function(e){return{image:e,svg:t}},function(e){throw l(e)})}function s(e,t,n){return r.drawDocumentAsSvg(e,n).then(a).then(function(e){return t&&function(e,t){try{t.getContext("2d").drawImage(e,0,0)}catch(e){throw l(e)}}(e.image,t),e})}var t={},l=function(e){return{message:"Error rendering page",originalError:e}};return t.rasterize=function(e,n,r){var t=o.clone(r);return t.inlineScripts=!0===r.executeJs,u.inlineReferences(e,t).then(function(t){return r.executeJs?i.executeJavascript(e,r).then(function(e){var t=e.document;return c.persistInputValues(t),{document:t,errors:e.errors,cleanUp:e.cleanUp}}).then(function(e){return{element:e.document.documentElement,errors:t.concat(e.errors),cleanUp:e.cleanUp}}):{element:e,errors:t,cleanUp:function(){}}}).then(function(t){return s(t.element,n,r).then(function(e){return t.cleanUp(),{image:e.image,svg:e.svg,errors:t.errors}})})},t}(o,i,e,function(c,r,u){"use strict";function a(t){var e=Object.keys(t);return e.length?" "+e.map(function(e){return e+'="'+t[e]+'"'}).join(" "):""}function o(e,t,n){var r,o,i=u.serializeToString(e);return c.validateXHTML(i),(e=(r=t,o=Math.round(r.viewportWidth),e=Math.round(r.viewportHeight),{x:-r.left,y:-r.top,width:o,height:e})).style=(e.style||"")+"float: left;",e.externalResourcesRequired=!0,'"}var i={};return i.getSvgForDocument=function(e,t,n){return r.rewriteTagNameSelectorsToLowerCase(e),o(e,t,n)},i.drawDocumentAsSvg=function(t,n){return["hover","active","focus","target"].forEach(function(e){n[e]&&r.fakeUserAction(t,n[e],e)}),c.calculateDocumentContentSize(t,n).then(function(e){return i.getSvgForDocument(t,e,n.zoom)})},i}(i,e,t),n,r))});// the XRWG (XR WordGraph)is mentioned in the spec
+!function(o,i){void 0===o&&void 0!==window&&(o=window),"function"==typeof define&&define.amd?define(["url","xmlserializer","sane-domparser-error","inlineresources"],function(e,t,n,r){return o.rasterizeHTML=i(e,t,n,r)}):"object"==typeof module&&module.exports?module.exports=i(require("url"),require("xmlserializer"),require("sane-domparser-error"),require("inlineresources")):o.rasterizeHTML=i(o.url,o.xmlserializer,o.sanedomparsererror,o.inlineresources)}(this,function(e,t,n,r){var o=function(n){"use strict";var o={},t=[];o.joinUrl=function(e,t){return e?n.resolve(e,t):t},o.getConstantUniqueIdFor=function(e){return t.indexOf(e)<0&&t.push(e),t.indexOf(e)},o.clone=function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};return o.parseOptionalParameters=function(e){var t,n,r={canvas:null,options:{}};return null==e[0]||(t=e[0],"object"==typeof(n=t)&&null!==n&&Object.prototype.toString.apply(t).match(/\[object (Canvas|HTMLCanvasElement)\]/i))?(r.canvas=e[0]||null,r.options=o.clone(e[1])):r.options=o.clone(e[0]),r},o}(e),i=function(i){"use strict";function u(e,t,n){var r=e[t];return e[t]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(this,[e,r])},r}var e={};return e.baseUrlRespectingXhr=function(t,o){return function(){var e=new t;return u(e,"open",function(e,t){var n=e.shift(),r=e.shift(),r=i.joinUrl(o,r);return t.apply(this,[n,r].concat(e))}),e}},e.finishNotifyingXhr=function(t){function e(){var e=new t;return u(e,"send",function(e,t){return r+=1,t.apply(this,arguments)}),e.addEventListener("load",function(){o+=1,n()}),e}var n,r=0,o=0,i=!1,c=new Promise(function(e){n=function(){r-o<=0&&i&&e({totalCount:r})}});return e.waitForRequestsToFinish=function(){return i=!0,n(),c},e},e}(o),e=function(i){"use strict";function r(e){return Array.prototype.slice.call(e)}var e={},c={active:!0,hover:!0,focus:!1,target:!1};return e.fakeUserAction=function(e,t,n){var r=e.querySelector(t),o=":"+n,t="rasterizehtml"+n;r&&(c[n]?i.addClassNameRecursively(r,t):i.addClassName(r,t),i.rewriteCssSelectorWith(e,o,"."+t))},e.persistInputValues=function(e){function t(e){return"checkbox"===e.type||"radio"===e.type}var n=e.querySelectorAll("input"),e=e.querySelectorAll("textarea");r(n).filter(t).forEach(function(e){e.checked?e.setAttribute("checked",""):e.removeAttribute("checked")}),r(n).filter(function(e){return!t(e)}).forEach(function(e){e.setAttribute("value",e.value)}),r(e).forEach(function(e){e.textContent=e.value})},e.rewriteTagNameSelectorsToLowerCase=function(e){i.lowercaseCssTypeSelectors(e,i.findHtmlOnlyNodeNames(e))},e}(function(){"use strict";function c(e){return Array.prototype.slice.call(e)}var n={};n.addClassName=function(e,t){e.className+=" "+t},n.addClassNameRecursively=function(e,t){n.addClassName(e,t),e.parentNode!==e.ownerDocument&&n.addClassNameRecursively(e.parentNode,t)};function r(e,t,o){var i="((?:^|[^.#:\\w])|(?=\\W))("+t.join("|")+")(?=\\W|$)";c(e.querySelectorAll("style")).forEach(function(e){var t,n;void 0===e.sheet&&(t=e,n=document.implementation.createHTMLDocument(""),(r=document.createElement("style")).textContent=t.textContent,n.body.appendChild(r),t.sheet=r.sheet);var r=c(e.sheet.cssRules).filter(function(e){return e.selectorText&&new RegExp(i,"i").test(e.selectorText)});r.length&&(r.forEach(function(e){var t,n=e.selectorText.replace(new RegExp(i,"gi"),function(e,t,n){return t+o(n)});n!==e.selectorText&&(t=n,e=(n=e).cssText.replace(/^[^\{]+/,""),u(n,t+" "+e))}),e.textContent=a(e.sheet.cssRules))})}var u=function(e,t){var n=e.parentStyleSheet,e=c(n.cssRules).indexOf(e);n.insertRule(t,e+1),n.deleteRule(e)},a=function(e){return c(e).reduce(function(e,t){return e+t.cssText},"")};return n.rewriteCssSelectorWith=function(e,t,n){r(e,[t],function(){return n})},n.lowercaseCssTypeSelectors=function(e,t){r(e,t,function(e){return e.toLowerCase()})},n.findHtmlOnlyNodeNames=function(e){for(var t,n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r={},o={};t=n.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===n.currentNode.namespaceURI?r[t]=!0:o[t]=!0,n.nextNode(););return Object.keys(r).filter(function(e){return!o[e]})},n}()),i=function(a,f,t,m){"use strict";var e={};e.executeJavascript=function(s,l){return new Promise(function(t){function n(){m.document.getElementsByTagName("body")[0].removeChild(r)}function e(){var e=r.contentDocument;t({document:e,errors:i,cleanUp:n})}var r=function(e,t,n,r){t=e.createElement(t);return t.style.visibility="hidden",t.style.width=n+"px",t.style.height=r+"px",t.style.position="absolute",t.style.top=-1e4-r+"px",t.style.left=-1e4-n+"px",e.getElementsByTagName("body")[0].appendChild(t),t}(m.document,"iframe",l.width,l.height),o=s.outerHTML,i=[],c=l.executeJsTimeout||0,u=r.contentWindow.XMLHttpRequest,a=f.finishNotifyingXhr(u),u=f.baseUrlRespectingXhr(a,l.baseUrl);r.onload=function(){var t;(0<(t=c)?new Promise(function(e){setTimeout(e,t)}):Promise.resolve()).then(a.waitForRequestsToFinish).then(e)},r.contentDocument.open(),r.contentWindow.XMLHttpRequest=u,r.contentWindow.onerror=function(e){i.push({resourceType:"scriptExecution",msg:e})},r.contentDocument.write(""),r.contentDocument.write(o),r.contentDocument.close()})};function s(e,t,n,r,o){var i,c,u,a=Math.max(e.scrollWidth,e.clientWidth),s=Math.max(e.scrollHeight,e.clientHeight),l=t?(i=(l=function(e,t){var n=e.querySelector(t);if(n)return n;if(e.ownerDocument.querySelector(t)===e)return e;throw{message:"Clipping selector not found"}}(e,t).getBoundingClientRect()).top,c=l.left,u=l.width,l.height):(c=i=0,u=a,s);return l={width:u,height:l},r=r,o=o,r={width:Math.max(l.width*o,n),height:Math.max(l.height*o,r)},e=m.getComputedStyle(e.ownerDocument.documentElement).fontSize,{left:c,top:i,width:r.width,height:r.height,viewportWidth:a,viewportHeight:s,rootFontSize:e}}e.calculateDocumentContentSize=function(c,u){return new Promise(function(n,r){var e,t,o=u.zoom||1,i=function(e,t,n){e=Math.floor(e/n),n=Math.floor(t/n);return function(e,t,n){e=e.createElement("iframe");return e.style.width=t+"px",e.style.height=n+"px",e.style.visibility="hidden",e.style.position="absolute",e.style.top=-1e4-n+"px",e.style.left=-1e4-t+"px",e.style.borderWidth=0,e.sandbox="allow-same-origin",e.scrolling="no",e}(m.document,e,n)}(u.width,u.height,o);m.document.getElementsByTagName("body")[0].appendChild(i),i.onload=function(){var e,t=i.contentDocument;try{e=s(function(e,t){e=e.tagName;return t.querySelector(e)}(c,t),u.clip,u.width,u.height,o),n(e)}catch(e){r(e)}finally{m.document.getElementsByTagName("body")[0].removeChild(i)}},i.contentDocument.open(),i.contentDocument.write(""),i.contentDocument.write("html"===(t=(e=c).tagName.toLowerCase())||"body"===t?e.outerHTML:''+e.outerHTML+""),i.contentDocument.close()})},e.parseHtmlFragment=function(e){var t=m.document.implementation.createHTMLDocument("");t.documentElement.innerHTML=e;t=t.querySelector("body").firstChild;if(!t)throw"Invalid source";return t};e.parseHTML=function(e){var t=m.document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,function(e,t){var n,r,o,i=/]*)?)>/im.exec(t),t=m.document.implementation.createHTMLDocument("");if(i)for(i="",t.documentElement.innerHTML=i,r=t.querySelector("div"),n=0;n',n=function(){return new Promise(function(t,e){var n;(function(){if(r.Blob)try{return new Blob([""],{type:"text/xml"}),!0}catch(e){}return!1})()&&r.URL?(n=o(a,!0),i(n).then(function(e){return c(n),!e&&i(o(a,!1)).then(function(e){return e})},function(){return!1}).then(function(e){t(!e)},function(){e()})):t(!1)})};return t.renderSvg=function(i){return new Promise(function(e,t){function n(){r&&c(r)}var r,o=new Image;o.onload=function(){o.onload=null,o.onerror=null,n(),e(o)},o.onerror=function(){n(),t()},u(i).then(function(e){r=e,o.src=r},t)})},t}(window);return function(o,i,c){"use strict";var u={};u.drawDocument=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n=o.parseOptionalParameters(t),r=e.documentElement||e;return c.rasterize(r,n.canvas,(e=(t=n).canvas,r=t.options,n=e?e.width:300,e=e?e.height:200,e={width:void 0!==r.width?r.width:n,height:void 0!==r.height?r.height:e},(t=o.clone(t.options)).width=e.width,t.height=e.height,t))};u.drawHTML=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return function(e,t,n){e=i.parseHTML(e);return u.drawDocument(e,t,n)}(e,t.canvas,t.options)};function n(t,n,r){return i.loadDocument(t,r).then(function(e){e=function(e,t,n){var r=document.implementation.createHTMLDocument("");r.replaceChild(e.documentElement,r.documentElement);e=n?o.clone(n):{};return n.baseUrl||(e.baseUrl=t),{document:r,options:e}}(e,t,r);return u.drawDocument(e.document,n,e.options)})}return u.drawURL=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return n(e,t.canvas,t.options)},u}(o,i,function(o,i,c,r,e,u){"use strict";function a(t){return e.renderSvg(t).then(function(e){return{image:e,svg:t}},function(e){throw l(e)})}function s(e,t,n){return r.drawDocumentAsSvg(e,n).then(a).then(function(e){return t&&function(e,t){try{t.getContext("2d").drawImage(e,0,0)}catch(e){throw l(e)}}(e.image,t),e})}var t={},l=function(e){return{message:"Error rendering page",originalError:e}};return t.rasterize=function(e,n,r){var t=o.clone(r);return t.inlineScripts=!0===r.executeJs,u.inlineReferences(e,t).then(function(t){return r.executeJs?i.executeJavascript(e,r).then(function(e){var t=e.document;return c.persistInputValues(t),{document:t,errors:e.errors,cleanUp:e.cleanUp}}).then(function(e){return{element:e.document.documentElement,errors:t.concat(e.errors),cleanUp:e.cleanUp}}):{element:e,errors:t,cleanUp:function(){}}}).then(function(t){return s(t.element,n,r).then(function(e){return t.cleanUp(),{image:e.image,svg:e.svg,errors:t.errors}})})},t}(o,i,e,function(c,r,u){"use strict";function a(t){var e=Object.keys(t);return e.length?" "+e.map(function(e){return e+'="'+t[e]+'"'}).join(" "):""}function o(e,t,n){var r,o,i=u.serializeToString(e);return c.validateXHTML(i),(e=(r=t,o=Math.round(r.viewportWidth),e=Math.round(r.viewportHeight),{x:-r.left,y:-r.top,width:o,height:e})).style=(e.style||"")+"float: left;",e.externalResourcesRequired=!0,'"}var i={};return i.getSvgForDocument=function(e,t,n){return r.rewriteTagNameSelectorsToLowerCase(e),o(e,t,n)},i.drawDocumentAsSvg=function(t,n){return["hover","active","focus","target"].forEach(function(e){n[e]&&r.fakeUserAction(t,n[e],e)}),c.calculateDocumentContentSize(t,n).then(function(e){return i.getSvgForDocument(t,e,n.zoom)})},i}(i,e,t),n,r))});
+// the XRWG (XR WordGraph)is mentioned in the spec
//
// it collects metadata-keys ('foo' e.g.), names and tags across 3D scene-nodes (.userData.foo e.g.)
@@ -701,18 +696,19 @@ XRWG.cleankey = (word) => String(word).replace(/[^0-9\.a-zA-Z_]/g,'')
XRWG.get = (v,k) => XRWG.find( (x) => x[ k || 'word'] == v )
XRWG.match = (str,types,level) => {
- level = level || 1000
+ if( XRWG.length == 0 ) XRWG.generate(xrf)
+ level = level == undefined ? 1000 : level
types = types || []
let res = XRWG.filter( (n) => {
types.map( (type) => n[type] ? n = false : false )
return n
})
str = str.toLowerCase()
- if( level <10 ) res = res.filter( (n) => n.key == str )
- if( level <20 ) res = res.filter( (n) => n.word == str || n.key == str )
- if( level <30 ) res = res.filter( (n) => n.word.match(str) || n.key == str )
- if( level <40 ) res = res.filter( (n) => n.word.match(str) || n.key == str || String(n.value||'').match(str) )
- if( level <1001 ) res = res.filter( (n) => n.word.match(str) != null || n.key.match(str) != null || String(n.value||'').match(str) != null)
+ if( level <10 ) res = res.filter( (n) => n.key == str )
+ if( level >=10 ) res = res.filter( (n) => n.word == str || n.key == str )
+ if( level >30 ) res = res.filter( (n) => n.word.match(str) || n.key == str )
+ if( level >40 ) res = res.filter( (n) => n.word.match(str) || n.key == str || String(n.value||'').match(str) )
+ if( level >999 ) res = res.filter( (n) => n.word.match(str) != null || n.key.match(str) != null || String(n.value||'').match(str) != null)
return res
}
@@ -731,7 +727,7 @@ XRWG.generate = (opts) => {
node = { word: XRWG.cleankey(key), key, nodes:[spatialNode] }
if( spatialNode.userData[key] ) node.value = spatialNode.userData[key]
node[type] = true
- xrf.emit('XRWG',node)
+ xrf.emit('XRWGnode',node)
XRWG.push( node )
}
}
@@ -753,6 +749,7 @@ XRWG.generate = (opts) => {
// sort by n
XRWG.sort( (a,b) => a.nodes.length - b.nodes.length )
XRWG = XRWG.reverse() // the cleankey/get functions e.g. will persist
+ xrf.emit('XRWG',XRWG)
}
// the hashbus (QueryString eventBus) is mentioned in the spec
//
@@ -782,7 +779,7 @@ pub.mesh = (mesh,model) => { // evaluate embedded fragments (metadata) insid
for( let k in frag ){
let opts = {frag, mesh, model, camera: xrf.camera, scene: model.scene, renderer: xrf.renderer, THREE: xrf.THREE, hashbus: xrf.hashbus }
mesh.userData.XRF = frag // allow fragment impl to access XRF obj already
- xrf.emit('mesh',opts)
+ xrf.emit('frag2mesh',opts)
.then( () => pub.fragment(k,opts) )
}
}
@@ -791,12 +788,14 @@ pub.mesh = (mesh,model) => { // evaluate embedded fragments (metadata) insid
pub.fragment = (k, opts ) => { // evaluate one fragment
let frag = opts.frag[k];
+ if( frag.is( xrf.XRF.PV_EXECUTE ) ) pub.XRWG({...opts,frag})
+
// call native function (xrf/env.js e.g.), or pass it to user decorator
xrf.emit(k,opts)
.then( () => {
let func = xrf.frag[k] || function(){}
- if( xrf[k] ) xrf[k]( func, frag, opts)
- else func( frag, opts)
+ if( typeof xrf[k] == 'function' ) xrf[k]( func, frag, opts)
+ else func( frag, opts)
})
}
@@ -859,9 +858,9 @@ xrf.patchRenderer = function(opts){
renderer.render = ((render) => function(scene,camera){
// update clock
let time = xrf.clock.getDelta()
- // allow entities to do stuff during render (onBeforeRender and onAfterRender don't always fire)
- xrf.emit('render',{scene,camera,time}) // allow fragments to do something at renderframe
+ xrf.emit('render',{scene,camera,time,render}) // allow fragments to do something at renderframe
render(scene,camera)
+ xrf.emit('renderPost',{scene,camera,time,render,renderer}) // allow fragments to do something after renderframe
})(renderer.render.bind(renderer))
}
@@ -909,18 +908,15 @@ xrf.reset = () => {
return true
};
let nodes = []
- xrf.scene.traverse( (n) => n.audio ? n.audio.remove() : false )
- xrf.scene.traverse( (child) => child.isXRF ? nodes.push(child) : false )
+ xrf.scene.traverse( (n) => n.audio && (n.audio.remove()) )
+ xrf.scene.traverse( (child) => child.isXRF && (nodes.push(child)) )
nodes.map( disposeObject ) // leave non-XRF objects intact
- xrf.interactive = xrf.InteractiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
+ xrf.interactive = xrf.interactiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
xrf.add( xrf.interactive )
xrf.layers = 0
xrf.emit('reset',{})
// remove mixers
- xrf.mixers.map( (m) => {
- m.stop()
- delete m
- })
+ xrf.mixers.map( (m) => m.stop())
xrf.mixers = []
}
@@ -937,9 +933,565 @@ xrf.add = (object) => {
object.isXRF = true // mark for easy deletion when replacing scene
xrf.scene.add(object)
}
+
+xrf.hasNoMaterial = (mesh) => {
+ const hasTexture = mesh.material && mesh.material.map
+ const hasMaterialName = mesh.material && mesh.material.name.length > 0
+ return mesh.geometry && !hasMaterialName && !hasTexture
+}
+xrf.navigator = {}
+
+xrf.navigator.to = (url,flags,loader,data) => {
+ if( !url ) throw 'xrf.navigator.to(..) no url given'
+
+ let hashbus = xrf.hashbus
+ xrf.emit('navigate', {url,loader,data})
+
+ return new Promise( (resolve,reject) => {
+ let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
+ if( !file || (!data && xrf.model.file == file) ){ // we're already loaded
+ hashbus.pub( url, xrf.model, flags ) // and eval local URI XR fragments
+ xrf.navigator.updateHash(hash)
+ return resolve(xrf.model)
+ }
+
+ if( xrf.model && xrf.model.scene ) xrf.model.scene.visible = false
+ if( !loader ){
+ const Loader = xrf.loaders[ext]
+ if( !Loader ) throw 'xrfragment: no loader passed to xrfragment for extension .'+ext
+ loader = loader || new Loader().setPath( dir )
+ }
+
+ // force relative path
+ if( dir ) dir = dir[0] == '.' ? dir : `.${dir}`
+ url = url.replace(dir,"")
+ loader = loader || new Loader().setPath( dir )
+ const onLoad = (model) => {
+ xrf.reset() // clear xrf objects from scene
+ model.file = file
+ // only change url when loading *another* file
+ if( xrf.model ) xrf.navigator.pushState( `${dir}${file}`, hash )
+ xrf.model = model
+ // spec: 1. generate the XRWG
+ xrf.XRWG.generate({model,scene:model.scene})
+ // spec: 1. execute the default predefined view '#' (if exist) (https://xrfragment.org/#predefined_view)
+ xrf.frag.defaultPredefinedViews({model,scene:model.scene})
+ // spec: 2. init metadata
+ // spec: predefined view(s) from URL (https://xrfragment.org/#predefined_view)
+ setTimeout( () => { // give external objects some slack
+ let frag = hashbus.pub( url, model) // and eval URI XR fragments
+ hashbus.pub.XRWG({model,scene:model.scene,frag})
+ },2000)
+ xrf.add( model.scene )
+ xrf.navigator.updateHash(hash)
+ xrf.emit('navigateLoaded',{url,model})
+ resolve(model)
+ }
+
+ if( data ) loader.parse(data, "", onLoad )
+ else loader.load(url, onLoad )
+ })
+}
+
+xrf.navigator.init = () => {
+ if( xrf.navigator.init.inited ) return
+
+ window.addEventListener('popstate', function (event){
+ xrf.navigator.to( document.location.search.substr(1) + document.location.hash )
+ })
+
+ window.addEventListener('hashchange', function (e){
+ xrf.emit('hash', {hash: document.location.hash })
+ })
+
+ // this allows selectionlines to be updated according to the camera (renderloop)
+ xrf.focusLine = new xrf.THREE.Group()
+ xrf.focusLine.material = new xrf.THREE.LineDashedMaterial({color:0xFF00FF,linewidth:3, scale: 1, dashSize: 0.2, gapSize: 0.1,opacity:0.3, transparent:true})
+ xrf.focusLine.isXRF = true
+ xrf.focusLine.position.set(0,0,-0.5);
+ xrf.focusLine.points = []
+ xrf.focusLine.lines = []
+ xrf.camera.add(xrf.focusLine)
+
+ xrf.navigator.init.inited = true
+}
+
+xrf.navigator.updateHash = (hash,opts) => {
+ if( hash.replace(/^#/,'') == document.location.hash.substr(1) || hash.match(/\|/) ) return // skip unnecesary pushState triggers
+ console.log(`URL: ${document.location.search.substr(1)}#${hash}`)
+ document.location.hash = hash
+ xrf.emit('hash', {...opts, hash: `#${hash}` })
+}
+
+xrf.navigator.pushState = (file,hash) => {
+ if( file == document.location.search.substr(1) ) return // page is in its default state
+ window.history.pushState({},`${file}#${hash}`, document.location.pathname + `?${file}#${hash}` )
+ xrf.emit('pushState', {file, hash} )
+}
+xrf.addEventListener('env', (opts) => {
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ if( frag.env && !scene.environment ){
+ //let env = scene.getObjectByName(frag.env.string)
+ //if( !env ) env = xrf.scene.getObjectByName(frag.env.string) // repurpose from parent scene
+ //if( !env ) return console.warn("xrf.env "+frag.env.string+" not found")
+ //env.material.map.mapping = THREE.EquirectangularReflectionMapping;
+ //scene.environment = env.material.map
+ //scene.texture = env.material.map
+ // renderer.toneMapping = THREE.ACESFilmicToneMapping;
+ // renderer.toneMappingExposure = 2;
+ console.log(` └ applied image '${frag.env.string}' as environment map`)
+ }
+
+})
+/**
+ *
+ * navigation, portals & mutations
+ *
+ * | fragment | type | scope | example value |
+ * |`href`| string (uri or predefined view) | 🔒 |`#pos=1,1,0`
`#pos=1,1,0&rot=90,0,0`
`#pos=pyramid`
`#pos=lastvisit|pyramid`
`://somefile.gltf#pos=1,1,0`
|
+ *
+ * [[» example implementation|https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/three/xrf/href.js]]
+ * [[» example 3D asset|https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/href.gltf#L192]]
+ * [[» discussion|https://github.com/coderofsalvation/xrfragment/issues/1]]
+ *
+ * [img[xrfragment.jpg]]
+ *
+ *
+ * !!!spec 1.0
+ *
+ * 1. an ''external''- or ''file URI'' fully replaces the current scene and assumes `pos=0,0,0&rot=0,0,0` by default (unless specified)
+ *
+ * 2. navigation should not happen when queries (`q=`) are present in local url: queries will apply (`pos=`, `rot=` e.g.) to the targeted object(s) instead.
+ *
+ * 3. navigation should not happen ''immediately'' when user is more than 2 meter away from the portal/object containing the href (to prevent accidental navigation e.g.)
+ *
+ * 4. URL navigation should always be reflected in the client (in case of javascript: see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/src/3rd/three/navigator.js]] for an example navigator).
+ *
+ * 5. In XR mode, the navigator back/forward-buttons should be always visible (using a wearable e.g., see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/example/aframe/sandbox/index.html#L26-L29]] for an example wearable)
+ *
+ * [img[navigation.png]]
+ *
+ */
+
+xrf.frag.href = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+
+ if( mesh.userData.XRF.href.exec ) return // mesh already initialized
+
+ let click = mesh.userData.XRF.href.exec = (e) => {
+
+ let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
+ xrf
+ .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree
+ .then( () => {
+ const flags = v.string[0] == '#' ? xrf.XRF.PV_OVERRIDE : undefined
+ let toFrag = xrf.URI.parse( v.string, xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.METADATA )
+ // always commit current location (keep a trail of last positions before we navigate)
+ if( !e.nocommit && !document.location.hash.match(lastPos) ) xrf.navigator.to(`#${lastPos}`)
+ xrf.navigator.to(v.string) // let's surf to HREF!
+ })
+ .catch( console.error )
+ }
+
+ let selected = mesh.userData.XRF.href.selected = (state) => () => {
+ if( mesh.selected == state ) return // nothing changed
+ xrf.interactive.objects.map( (o) => {
+ let newState = o.name == mesh.name ? state : false
+ if( o.material ){
+ if( o.material.uniforms ) o.material.uniforms.selected.value = newState
+ //if( o.material.emissive ) o.material.emissive.r = o.material.emissive.g = o.material.emissive.b = newState ? 2.0 : 1.0
+ if( o.material.emissive ){
+ if( !o.material.emissive.original ) o.material.emissive.original = o.material.emissive.clone()
+ o.material.emissive.r = o.material.emissive.g = o.material.emissive.b =
+ newState ? o.material.emissive.original.r + 0.5 : o.material.emissive.original.r
+ }
+ }
+ })
+ // update mouse cursor
+ if( !renderer.domElement.lastCursor )
+ renderer.domElement.lastCursor = renderer.domElement.style.cursor
+ renderer.domElement.style.cursor = state ? 'pointer' : renderer.domElement.lastCursor
+
+ xrf
+ .emit('href',{selected:state,mesh,xrf:v}) // let all listeners agree
+ .then( () => mesh.selected = state )
+ }
+
+ mesh.addEventListener('click', click )
+ mesh.addEventListener('mousemove', selected(true) )
+ mesh.addEventListener('mouseenter', selected(true) )
+ mesh.addEventListener('mouseleave', selected(false) )
+
+ if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
+
+ // lazy add mesh (because we're inside a recursive traverse)
+ setTimeout( (mesh) => {
+ xrf.interactive.add(mesh)
+ xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
+ }, 0, mesh )
+}
+
+/**
+ * > above solutions were abducted from [[this|https://i.imgur.com/E3En0gJ.png]] and [[this|https://i.imgur.com/lpnTz3A.png]] survey result
+ *
+ * !!!Demo
+ *
+ * <$videojs controls="controls" aspectratio="16:9" preload="auto" poster="" fluid="fluid" class="vjs-big-play-centered">
+ *
+ * $videojs>
+ *
+ * > capture of aframe/sandbox
+ */
+xrf.frag.pos = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+
+
+ // spec: indirect coordinate using objectname: https://xrfragment.org/#navigating%203D
+ if( v.x == undefined ){
+ let obj = scene.getObjectByName(v.string)
+ if( !obj ) return
+ let pos = obj.position.clone()
+ obj.getWorldPosition(pos)
+ camera.position.copy(pos)
+ }else{
+ // spec: direct coordinate: https://xrfragment.org/#navigating%203D
+ camera.position.x = v.x
+ camera.position.y = v.y
+ camera.position.z = v.z
+ }
+}
+xrf.frag.rot = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ console.log(" └ setting camera rotation to "+v.string)
+ camera.rotation.set(
+ v.x * Math.PI / 180,
+ v.y * Math.PI / 180,
+ v.z * Math.PI / 180
+ )
+ camera.updateMatrixWorld()
+}
+// *TODO* use webgl instancing
+
+xrf.frag.src = function(v, opts){
+ opts.embedded = v // indicate embedded XR fragment
+ let { mesh, model, camera, scene, renderer, THREE, hashbus, frag} = opts
+
+ let url = v.string
+ let srcFrag = opts.srcFrag = xrfragment.URI.parse(url)
+ opts.isLocal = v.string[0] == '#'
+
+ if( opts.isLocal ){
+ xrf.frag.src.localSRC(url,srcFrag,opts) // local
+ }else xrf.frag.src.externalSRC(url,srcFrag,opts) // external file
+}
+
+xrf.frag.src.addModel = (model,url,frag,opts) => {
+ let {mesh} = opts
+ let scene = model.scene
+ xrf.frag.src.filterScene(scene,{...opts,frag}) // filter scene
+ if( mesh.material ) mesh.material.visible = false // hide placeholder object
+ //enableSourcePortation(scene)
+ if( xrf.frag.src.renderAsPortal(mesh) ){
+ // only add remote objects, because
+ // local scene-objects are already added to scene
+ xrf.portalNonEuclidian({...opts,model,scene:model.scene})
+ if( !opts.isLocal && !mesh.portal.isLens ) xrf.scene.add(scene)
+ return
+ }else{
+ xrf.frag.src.scale( scene, opts, url ) // scale scene
+ mesh.add(scene)
+ }
+ // flag everything isSRC & isXRF
+ mesh.traverse( (n) => { n.isSRC = n.isXRF = n[ opts.isLocal ? 'isSRCLocal' : 'isSRCExternal' ] = true })
+ xrf.emit('parseModel', {...opts, scene, model})
+}
+
+xrf.frag.src.renderAsPortal = (mesh) => {
+ // *TODO* should support better isFlat(mesh) check
+ const isPlane = mesh.geometry && mesh.geometry.attributes.uv && mesh.geometry.attributes.uv.count == 4
+ return xrf.hasNoMaterial(mesh) && isPlane
+}
+
+xrf.frag.src.enableSourcePortation = (src) => {
+ // show sourceportation clickable plane
+ if( srcFrag.href || v.string[0] == '#' ) return
+ let scale = new THREE.Vector3()
+ let size = new THREE.Vector3()
+ mesh.getWorldScale(scale)
+ new THREE.Box3().setFromObject(src).getSize(size)
+ const geo = new THREE.SphereGeometry( Math.max(size.x, size.y, size.z) / scale.x, 10, 10 )
+ const mat = new THREE.MeshBasicMaterial()
+ mat.transparent = true
+ mat.roughness = 0.05
+ mat.metalness = 1
+ mat.opacity = 0
+ const cube = new THREE.Mesh( geo, mat )
+ console.log("todo: sourceportate")
+ return xrf.frag.src
+}
+
+xrf.frag.src.externalSRC = (url,frag,opts) => {
+ fetch(url, { method: 'HEAD' })
+ .then( (res) => {
+ console.log(`loading src ${url}`)
+ let mimetype = res.headers.get('Content-type')
+ if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
+ //if( url.match(/\.(fbx|stl|obj)$/) ) mimetype =
+ opts = { ...opts, frag, mimetype }
+ return xrf.frag.src.type[ mimetype ] ? xrf.frag.src.type[ mimetype ](url,opts) : xrf.frag.src.type.unknown(url,opts)
+ })
+ .then( (model) => {
+ if( model && model.scene ) xrf.frag.src.addModel(model, url, frag, opts )
+ })
+ .finally( () => { })
+ .catch( console.error )
+ return xrf.frag.src
+}
+
+xrf.frag.src.localSRC = (url,frag,opts) => {
+ let {model,scene} = opts
+ let _model = {
+ animations: model.animations,
+ scene: scene.clone()
+ }
+ _model.scenes = [_model.scene]
+ xrf.frag.src.addModel(_model,url,frag, opts) // current file
+}
+
+// scale embedded XR fragments https://xrfragment.org/#scaling%20of%20instanced%20objects
+xrf.frag.src.scale = function(scene, opts, url){
+ let { mesh, model, camera, renderer, THREE} = opts
+
+ // remove invisible objects (hidden by selectors) which might corrupt boundingbox size-detection
+ let cleanScene = scene.clone()
+ if( !cleanScene ) debugger
+ let remove = []
+ const notVisible = (n) => !n.visible || (n.material && !n.material.visible)
+ cleanScene.traverse( (n) => notVisible(n) && n.children.length == 0 && (remove.push(n)) )
+ remove.map( (n) => n.removeFromParent() )
+
+ let restrictTo3DBoundingBox = mesh.geometry
+ if( restrictTo3DBoundingBox ){
+ // spec 3 of https://xrfragment.org/#src
+ // spec 1 of https://xrfragment.org/#scaling%20of%20instanced%20objects
+ // normalize instanced objectsize to boundingbox
+ let sizeFrom = new THREE.Vector3()
+ let sizeTo = new THREE.Vector3()
+ let empty = new THREE.Object3D()
+ new THREE.Box3().setFromObject(mesh).getSize(sizeTo)
+ new THREE.Box3().setFromObject(cleanScene).getSize(sizeFrom)
+ let ratio = sizeFrom.divide(sizeTo)
+ scene.scale.multiplyScalar( 1.0 / Math.max(ratio.x, ratio.y, ratio.z));
+ }else{
+ // spec 4 of https://xrfragment.org/#src
+ // spec 2 of https://xrfragment.org/#scaling%20of%20instanced%20objects
+ scene.scale.multiply( mesh.scale )
+ }
+ scene.isXRF = model.scene.isSRC = true
+}
+
+xrf.frag.src.filterScene = (scene,opts) => {
+ let { mesh, model, camera, renderer, THREE, hashbus, frag} = opts
+
+ xrf.filter.scene({scene,frag,reparent:true})
+
+ scene.traverse( (m) => {
+ if( m.userData && (m.userData.src || m.userData.href) ) return ; // prevent infinite recursion
+ hashbus.pub.mesh(m,{scene,recursive:true}) // cool idea: recursion-depth based distance between face & src
+ })
+ return scene
+}
+
+/*
+ * replace the src-mesh with the contents of the src
+ */
+
+xrf.frag.src.type = {}
+
+/*
+ * mimetype: unknown
+ */
+
+xrf.frag.src.type['unknown'] = function( url, opts ){
+ return new Promise( (resolve,reject) => {
+ reject(`${url} mimetype '${opts.mimetype}' not found or supported (yet)`)
+ })
+}
+xrf.frag.t = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ if( !model.mixer ) return
+ if( !model.animations || model.animations[0] == undefined ) return console.warn('no animation in scene')
+
+ xrf.mixers.map ( (mixer) => {
+
+ mixer.t = v
+
+ // update speed
+ mixer.timeScale = mixer.loop.speed = v.x
+ mixer.loop.speedAbs = Math.abs(v.x)
+
+ if( v.y != undefined || v.z != undefined ) mixer.updateLoop( v )
+
+ // play animations
+ mixer.play( v )
+ })
+}
+
+xrf.frag.t.default = {
+ x:0, // (play from) offset (in seconds)
+ y:0 // optional: (stop at) offset (in seconds)
+}
+
+// setup animation mixer for global scene & src scenes
+xrf.addEventListener('parseModel', (opts) => {
+ let {model} = opts
+ let mixer = model.mixer = new xrf.THREE.AnimationMixer(model.scene)
+ mixer.model = model
+ mixer.loop = {timeStart:0,timeStop:0}
+ mixer.i = xrf.mixers.length
+ mixer.actions = []
+
+ model.animations.map( (anim) => {
+ anim.optimize()
+ console.log("action: "+anim.name)
+ mixer.actions.push( mixer.clipAction( anim, model.scene ) )
+ })
+
+
+ mixer.checkZombies = (animations) => {
+ if( mixer.zombieCheck ) return // fire only once
+ animations.map( (anim) => {
+ // collect zombie animations and warn user
+ let zombies = anim.tracks.map( (t) => {
+ let name = t.name.replace(/\..*/,'')
+ let obj = model.scene.getObjectByName(name)
+ return !model.scene.getObjectByName(name) ? {anim:anim.name,obj:name} : undefined
+ })
+ if( zombies.length > 0 && mixer.i == 0 ){ // only warn for zombies in main scene (because src-scenes might be filtered anyways)
+ zombies
+ .filter( (z) => z ) // filter out undefined
+ .map( (z) => console.warn(`gltf: object '${z.obj}' not found (anim: '${z.anim}'`) )
+ console.warn(`TIP: remove dots in objectnames in blender (which adds dots when duplicating)`)
+ }
+ })
+ mixer.zombieCheck = true
+ }
+
+ mixer.play = (t) => {
+ mixer.isPlaying = t.x != 0
+ mixer.updateLoop(t)
+ xrf.emit( mixer.isPlaying === false ? 'stop' : 'play',{isPlaying: mixer.isPlaying})
+ }
+
+ mixer.stop = () => {
+ mixer.play(false)
+ }
+
+ mixer.updateLoop = (t) => {
+ mixer.loop.timeStart = t.y != undefined ? t.y : mixer.loop.timeStart
+ mixer.loop.timeStop = t.z != undefined ? t.z : mixer.loop.timeStop
+ mixer.actions.map( (action) => {
+ if( mixer.loop.timeStart != undefined ){
+ action.time = mixer.loop.timeStart
+ action.setLoop( THREE.LoopOnce, )
+ action.timeScale = mixer.timeScale
+ action.enabled = true
+ if( t.x != 0 ){
+ action.play()
+ }
+ }
+ })
+ mixer.setTime(mixer.loop.timeStart)
+ mixer.time = Math.abs( mixer.loop.timeStart )
+ mixer.update(0)
+ mixer.checkZombies( model.animations)
+ }
+
+ // update loop when needed
+ if( !mixer.update.patched ){
+ let update = mixer.update
+ mixer.update = function(time){
+ mixer.time = Math.abs(mixer.time)
+ if( time == 0 ) return update.call(this,time)
+
+ // loop jump
+ if( mixer.loop.speed > 0.0 && (mixer.loop.timeStop > 0 && mixer.time > mixer.loop.timeStop) ){
+ setTimeout( (time,anims) => mixer.updateLoop(time), 0, mixer.loop.timeStart ) // prevent recursion
+ }
+ return update.call( this, time )
+ }
+ mixer.update.patched = true
+ }
+
+ // calculate total duration/frame based on longest animation
+ mixer.duration = 0
+ if( model.animations.length ){
+ model.animations.map( (a) => mixer.duration = ( a.duration > mixer.duration ) ? a.duration : mixer.duration )
+ }
+
+ xrf.mixers.push(mixer)
+})
+
+if( document.location.hash.match(/t=/) ){
+ let url = document.location.href
+ let playAfterUserGesture = () => {
+ xrf.hashbus.pub(url) // re-post t fragment on the hashbus again
+ window.removeEventListener('click',playAfterUserGesture)
+ window.removeEventListener('touchstart',playAfterUserGesture)
+ }
+ window.addEventListener('click', playAfterUserGesture )
+ window.addEventListener('touchstart', playAfterUserGesture )
+}
+
+xrf.addEventListener('render', (opts) => {
+ let model = xrf.model
+ let {time} = opts
+ if( !model ) return
+ if( xrf.mixers.length ){
+ xrf.mixers.map( (m) => m.isPlaying && (m.update( time )) )
+
+ // update active camera in case selected by dynamicKey in URI
+ if( xrf.model.camera && model.mixer.isPlaying ){
+
+ let cam = xrf.camera.getCam()
+ // cam.fov = model.cameras[0].fov (why is blender not exporting radians?)
+ cam.far = model.cameras[0].far
+ cam.near = model.cameras[0].near
+
+ let rig = xrf.camera
+ rig.position.copy( model.cameras[0].position )
+ rig.position.y -= rig.offsetY // VR/AR compensate camera rig
+ //rig.rotation.copy( model.cameras[0].rotation )
+
+ rig.updateProjectionMatrix()
+ }
+ }
+})
+
+xrf.addEventListener('dynamicKey', (opts) => {
+ // select active camera if any
+ let {id,match,v} = opts
+ match.map( (w) => {
+ w.nodes.map( (node) => {
+ if( node.isCamera ){
+ console.log("setting camera to "+node.name)
+ xrf.model.camera = node
+ }
+ })
+ })
+})
+xrf.getCollisionMeshes = () => {
+ let meshes = []
+ xrf.scene.traverse( (n) => {
+ if( !n.userData.href && !n.userData.src && xrf.hasNoMaterial(n) ){
+ meshes.push(n)
+ }
+ })
+ return meshes
+}
// wrapper to survive in/outside modules
-xrf.InteractiveGroup = function(THREE,renderer,camera){
+xrf.interactiveGroup = function(THREE,renderer,camera){
let {
Group,
@@ -952,7 +1504,7 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
const _event = { type: '', data: _pointer };
let object = {selected:false}
- class InteractiveGroup extends Group {
+ class interactive extends Group {
constructor( renderer, camera ) {
@@ -1010,9 +1562,9 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
element.addEventListener( 'pointerup', onPointerEvent );
element.addEventListener( 'pointermove', onPointerEvent );
element.addEventListener( 'mousedown', onPointerEvent );
- element.addEventListener( 'mouseup', onPointerEvent );
element.addEventListener( 'mousemove', onPointerEvent );
element.addEventListener( 'click', onPointerEvent );
+ element.addEventListener( 'mouseup', onPointerEvent );
// WebXR Controller Events
// TODO: Dispatch pointerevents too
@@ -1077,582 +1629,121 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
}
- return new InteractiveGroup(renderer,camera)
+ return new interactive(renderer,camera)
}
-xrf.navigator = {}
-
-xrf.navigator.to = (url,flags,loader,data) => {
- if( !url ) throw 'xrf.navigator.to(..) no url given'
-
- let hashbus = xrf.hashbus
-
- return new Promise( (resolve,reject) => {
- let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
- if( !file || (!data && xrf.model.file == file) ){ // we're already loaded
- hashbus.pub( url, xrf.model, flags ) // and eval local URI XR fragments
- xrf.navigator.updateHash(hash)
- return resolve(xrf.model)
- }
-
- if( xrf.model && xrf.model.scene ) xrf.model.scene.visible = false
- if( !loader ){
- const Loader = xrf.loaders[ext]
- if( !Loader ) throw 'xrfragment: no loader passed to xrfragment for extension .'+ext
- loader = loader || new Loader().setPath( dir )
- }
-
- // force relative path
- if( dir ) dir = dir[0] == '.' ? dir : `.${dir}`
- url = url.replace(dir,"")
- loader = loader || new Loader().setPath( dir )
- const onLoad = (model) => {
- xrf.reset() // clear xrf objects from scene
- model.file = file
- // only change url when loading *another* file
- if( xrf.model ) xrf.navigator.pushState( `${dir}${file}`, hash )
- xrf.model = model
- // spec: 1. generate the XRWG
- xrf.XRWG.generate({model,scene:model.scene})
- // spec: 1. execute the default predefined view '#' (if exist) (https://xrfragment.org/#predefined_view)
- xrf.frag.defaultPredefinedViews({model,scene:model.scene})
- // spec: 2. init metadata
- // spec: predefined view(s) from URL (https://xrfragment.org/#predefined_view)
- setTimeout( () => { // give external objects some slack
- let frag = hashbus.pub( url, model) // and eval URI XR fragments
- hashbus.pub.XRWG({model,scene:model.scene,frag})
- console.dir(frag)
- },2000)
- xrf.add( model.scene )
- xrf.navigator.updateHash(hash)
- resolve(model)
- }
-
- if( data ) loader.parse(data, "", onLoad )
- else loader.load(url, onLoad )
- })
-}
-
-xrf.navigator.init = () => {
- if( xrf.navigator.init.inited ) return
-
- window.addEventListener('popstate', function (event){
- xrf.navigator.to( document.location.search.substr(1) + document.location.hash )
- })
-
- window.addEventListener('hashchange', function (e){
- xrf.emit('hash', {hash: document.location.hash })
- })
-
- // this allows selectionlines to be updated according to the camera (renderloop)
- xrf.focusLine = new xrf.THREE.Group()
- xrf.focusLine.material = new xrf.THREE.LineDashedMaterial({color:0xFF00FF,linewidth:3, scale: 1, dashSize: 0.2, gapSize: 0.1,opacity:0.3, transparent:true})
- xrf.focusLine.isXRF = true
- xrf.focusLine.position.set(0,0,-0.5);
- xrf.focusLine.points = []
- xrf.focusLine.lines = []
- xrf.camera.add(xrf.focusLine)
-
- xrf.navigator.init.inited = true
-}
-
-xrf.navigator.updateHash = (hash,opts) => {
- if( hash.replace(/^#/,'') == document.location.hash.substr(1) || hash.match(/\|/) ) return // skip unnecesary pushState triggers
- console.log(`URL: ${document.location.search.substr(1)}#${hash}`)
- document.location.hash = hash
- xrf.emit('hash', {...opts, hash: `#${hash}` })
-}
-
-xrf.navigator.pushState = (file,hash) => {
- if( file == document.location.search.substr(1) ) return // page is in its default state
- window.history.pushState({},`${file}#${hash}`, document.location.pathname + `?${file}#${hash}` )
- xrf.emit('pushState', {file, hash} )
-}
-xrf.addEventListener('env', (opts) => {
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- if( frag.env && !scene.environment ){
- let env = scene.getObjectByName(frag.env.string)
- if( !env ) env = xrf.scene.getObjectByName(frag.env.string) // repurpose from parent scene
- if( !env ) return console.warn("xrf.env "+frag.env.string+" not found")
- env.material.map.mapping = THREE.EquirectangularReflectionMapping;
- scene.environment = env.material.map
- //scene.texture = env.material.map
- renderer.toneMapping = THREE.ACESFilmicToneMapping;
- renderer.toneMappingExposure = 2;
- console.log(` └ applied image '${frag.env.string}' as environment map`)
- }
-
-})
-/**
- *
- * navigation, portals & mutations
- *
- * | fragment | type | scope | example value |
- * |`href`| string (uri or predefined view) | 🔒 |`#pos=1,1,0`
`#pos=1,1,0&rot=90,0,0`
`#pos=pyramid`
`#pos=lastvisit|pyramid`
`://somefile.gltf#pos=1,1,0`
|
- *
- * [[» example implementation|https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/three/xrf/href.js]]
- * [[» example 3D asset|https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/href.gltf#L192]]
- * [[» discussion|https://github.com/coderofsalvation/xrfragment/issues/1]]
- *
- * [img[xrfragment.jpg]]
- *
- *
- * !!!spec 1.0
- *
- * 1. an ''external''- or ''file URI'' fully replaces the current scene and assumes `pos=0,0,0&rot=0,0,0` by default (unless specified)
- *
- * 2. navigation should not happen when queries (`q=`) are present in local url: queries will apply (`pos=`, `rot=` e.g.) to the targeted object(s) instead.
- *
- * 3. navigation should not happen ''immediately'' when user is more than 2 meter away from the portal/object containing the href (to prevent accidental navigation e.g.)
- *
- * 4. URL navigation should always be reflected in the client (in case of javascript: see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/src/3rd/three/navigator.js]] for an example navigator).
- *
- * 5. In XR mode, the navigator back/forward-buttons should be always visible (using a wearable e.g., see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/example/aframe/sandbox/index.html#L26-L29]] for an example wearable)
- *
- * [img[navigation.png]]
- *
+/*
+ * TODO: refactor/fix this (queries are being refactored to filters)
*/
-xrf.frag.href = function(v, opts){
- opts.embedded = v // indicate embedded XR fragment
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
-
- if( mesh.userData.XRF.href.exec ) return // mesh already initialized
-
- if( mesh.material ) mesh.material = mesh.material.clone() // we need this so we can individually highlight meshes
-
- let click = mesh.userData.XRF.href.exec = (e) => {
-
- let isLocal = v.string[0] == '#'
- let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
-
- xrf
- .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree
- .then( () => {
- const flags = v.string[0] == '#' ? xrf.XRF.PV_OVERRIDE : undefined
- let toFrag = xrf.URI.parse( v.string, xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.METADATA )
- // always keep a trail of last positions before we navigate
- if( !document.location.hash.match(lastPos) ) xrf.navigator.to(`#${lastPos}`)
- xrf.navigator.to(v.string) // let's surf to HREF!
- })
- .catch( console.error )
- }
-
- let selected = mesh.userData.XRF.href.selected = (state) => () => {
- if( mesh.selected == state ) return // nothing changed
- xrf.interactive.objects.map( (o) => {
- let newState = o.name == mesh.name ? state : false
- if( o.material ){
- if( o.material.uniforms ) o.material.uniforms.selected.value = newState
- if( o.material.emissive ) o.material.emissive.r = o.material.emissive.g = o.material.emissive.b = newState ? 2.0 : 1.0
- }
- })
- // update mouse cursor
- if( !renderer.domElement.lastCursor )
- renderer.domElement.lastCursor = renderer.domElement.style.cursor
- renderer.domElement.style.cursor = state ? 'pointer' : renderer.domElement.lastCursor
-
- xrf
- .emit('href',{selected:state,mesh,xrf:v}) // let all listeners agree
- .then( () => mesh.selected = state )
- }
-
- mesh.addEventListener('click', click )
- mesh.addEventListener('mousemove', selected(true) )
- mesh.addEventListener('mouseleave', selected(false) )
-
- // lazy add mesh (because we're inside a recursive traverse)
- setTimeout( (mesh) => {
- xrf.interactive.add(mesh)
- xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
- }, 0, mesh )
-}
-
-/**
- * > above solutions were abducted from [[this|https://i.imgur.com/E3En0gJ.png]] and [[this|https://i.imgur.com/lpnTz3A.png]] survey result
- *
- * !!!Demo
- *
- * <$videojs controls="controls" aspectratio="16:9" preload="auto" poster="" fluid="fluid" class="vjs-big-play-centered">
- *
- * $videojs>
- *
- * > capture of aframe/sandbox
- */
-xrf.frag.pos = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- camera.position.x = v.x
- camera.position.y = v.y
- camera.position.z = v.z
-}
-// spec: https://xrfragment.org/#queries
-
-xrf.frag.q = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- console.log(" └ running query ")
- let qobjs = Object.keys(v.query)
-
- // convience function for other fragments (which apply to the query)
- frag.q.getObjects = () => {
- let objs = []
- scene.traverse( (o) => {
- for ( let name in v.query ) {
- let qobj = v.query[name];
- if( qobj.tag && o.userData.tag && xrf.hasTag(name,o.userData.tag) ) objs.push(o)
- else if( qobj.id && o.name == name ) objs.push(o)
- }
- })
- return objs.filter( (o) => o ) // return and filter out empty
- .map( (o) => {
- if( !o.positionOriginal ) o.positionOriginal = o.position.clone()
- return o
- })
- }
- xrf.frag.q.filter(scene,frag) // spec : https://xrfragment.org/#queries
-}
-
-xrf.frag.q.filter = function(scene,frag){
- // spec: https://xrfragment.org/#queries
- let q = frag.q.query
- scene.traverse( (mesh) => {
- for ( let i in q ) {
- let isMeshId = q[i].id != undefined
- let isMeshProperty = q[i].rules != undefined && q[i].rules.length && !isMeshId
- if( q[i].root && mesh.isSRC ) continue; // ignore nested object for root-items (queryseletor '/foo' e.g.)
- if( isMeshId &&
- (i == mesh.name || xrf.hasTag(i,mesh.userData.tag))) mesh.visible = q[i].id
- if( isMeshProperty && mesh.userData[i] ) mesh.visible = (new xrf.Query(frag.q.string)).testProperty(i,mesh.userData[i])
- }
- })
-}
-xrf.frag.rot = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- console.log(" └ setting camera rotation to "+v.string)
- camera.rotation.set(
- v.x * Math.PI / 180,
- v.y * Math.PI / 180,
- v.z * Math.PI / 180
- )
- camera.updateMatrixWorld()
-}
-// *TODO* use webgl instancing
-
-xrf.frag.src = function(v, opts){
-
- opts.embedded = v // indicate embedded XR fragment
- let { mesh, model, camera, scene, renderer, THREE, hashbus, frag} = opts
-
- let src;
- let url = v.string
- let vfrag = xrfragment.URI.parse(url)
- opts.isPlane = mesh.geometry && mesh.geometry.attributes.uv && mesh.geometry.attributes.uv.count == 4
-
- const addModel = (model,url,frag) => {
- let scene = model.scene
- src = xrf.frag.src.filterScene(scene,{...opts,frag})
- xrf.frag.src.scale( src, opts, url )
- xrf.frag.src.eval( src, opts, url )
- // allow 't'-fragment to setup separate animmixer
- xrf.emit('parseModel', {...opts, scene:src, model})
- enableSourcePortation(src)
- mesh.add(src)
- mesh.traverse( (n) => n.isSRC = n.isXRF = true )
- if( mesh.material ) mesh.material.visible = false
- }
-
- const enableSourcePortation = (src) => {
- if( vfrag.href || v.string[0] == '#' ) return
- let scale = new THREE.Vector3()
- let size = new THREE.Vector3()
- mesh.getWorldScale(scale)
- new THREE.Box3().setFromObject(src).getSize(size)
- const geo = new THREE.SphereGeometry( Math.max(size.x, size.y, size.z) / scale.x, 10, 10 )
- const mat = new THREE.MeshBasicMaterial()
- mat.transparent = true
- mat.roughness = 0.05
- mat.metalness = 1
- mat.opacity = 0
- const cube = new THREE.Mesh( geo, mat )
- console.log("todo: sourceportate")
- //mesh.add(cube)
- }
-
- const externalSRC = (url,frag,src) => {
- fetch(url, { method: 'HEAD' })
- .then( (res) => {
- console.log(`loading src ${url}`)
- let mimetype = res.headers.get('Content-type')
- if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
- //if( url.match(/\.(fbx|stl|obj)$/) ) mimetype =
- opts = { ...opts, src, frag, mimetype }
- return xrf.frag.src.type[ mimetype ] ? xrf.frag.src.type[ mimetype ](url,opts) : xrf.frag.src.type.unknown(url,opts)
- })
- .then( (model) => {
- if( model && model.scene ) addModel(model, url, frag )
- })
- .finally( () => { })
- .catch( console.error )
- }
-
- if( url[0] == "#" ){
- let modelClone = {...model, scene: model.scene.clone()}
- modelClone.scenes = [modelClone.scene]
- modelClone.animations = modelClone.animations.map( (a) => a.clone() )
- addModel(modelClone,url,vfrag) // current file
- }else externalSRC(url,vfrag) // external file
-}
-
-xrf.frag.src.eval = function(scene, opts, url){
- let { mesh, model, camera, renderer, THREE, hashbus} = opts
- if( url ){
- //let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
- //let frag = xrfragment.URI.parse(url)
- //// scale URI XR Fragments (queries) inside src-value
- //for( var i in frag ){
- // hashbus.pub.fragment(i, Object.assign(opts,{frag, model:{scene},scene}))
- //}
- //hashbus.pub( '#', {scene} ) // execute the default projection '#' (if exist)
- //hashbus.pub( url, {scene} ) // and eval URI XR fragments
- }
-}
-
-// scale embedded XR fragments https://xrfragment.org/#scaling%20of%20instanced%20objects
-xrf.frag.src.scale = function(scene, opts, url){
- let { mesh, model, camera, renderer, THREE} = opts
-
- let restrictTo3DBoundingBox = mesh.geometry
- if( restrictTo3DBoundingBox ){
- // spec 3 of https://xrfragment.org/#src
- // spec 1 of https://xrfragment.org/#scaling%20of%20instanced%20objects
- // normalize instanced objectsize to boundingbox
- let sizeFrom = new THREE.Vector3()
- let sizeTo = new THREE.Vector3()
-
- let empty = new THREE.Object3D()
-
-// *TODO* exclude invisible objects from boundingbox size-detection
-//
-// THREE.Box3.prototype.expandByObject = (function(expandByObject){
-// return function(object,precise){
-// return expandByObject.call(this, object.visible ? object : empty, precise)
-// }
-// })(THREE.Box3.prototype.expandByObject)
-
- new THREE.Box3().setFromObject(mesh).getSize(sizeTo)
- new THREE.Box3().setFromObject(scene).getSize(sizeFrom)
- let ratio = sizeFrom.divide(sizeTo)
- scene.scale.multiplyScalar( 1.0 / Math.max(ratio.x, ratio.y, ratio.z));
- // let factor = getMax(sizeTo) < getMax(sizeFrom) ? getMax(sizeTo) / getMax(sizeFrom) : getMax(sizeFrom) / getMax(sizeTo)
- // scene.scale.multiplyScalar( factor )
- }else{
- // spec 4 of https://xrfragment.org/#src
- // spec 2 of https://xrfragment.org/#scaling%20of%20instanced%20objects
- scene.scale.multiply( mesh.scale )
- }
- scene.isXRF = model.scene.isSRC = true
-}
-
-xrf.frag.src.filterScene = (scene,opts) => {
- let { mesh, model, camera, renderer, THREE, hashbus, frag} = opts
- let obj, src
- // cherrypicking of object(s)
- if( !frag.q ){
- src = new THREE.Group()
- if( Object.keys(frag).length > 0 ){
- for( var i in frag ){
- if( scene.getObjectByName(i) ){
- src.add( obj = scene.getObjectByName(i).clone(true) )
- }
- hashbus.pub.fragment(i, Object.assign(opts,{frag, model,scene}))
- }
- }
- if( src.children.length == 1 ) obj.position.set(0,0,0);
- }
-
- // filtering of objects using query
- if( frag.q ){
- src = scene
- xrf.frag.q.filter(src,frag)
- }
- src.traverse( (m) => {
- if( m.userData && (m.userData.src || m.userData.href) ) return ; // prevent infinite recursion
- hashbus.pub.mesh(m,{scene,recursive:true}) // cool idea: recursion-depth based distance between face & src
- })
- return src
-}
-
-/*
- * replace the src-mesh with the contents of the src
- */
-
-xrf.frag.src.type = {}
-
-/*
- * mimetype: unknown
- */
-
-xrf.frag.src.type['unknown'] = function( url, opts ){
- return new Promise( (resolve,reject) => {
- reject(`${url} mimetype '${opts.mimetype}' not found or supported (yet)`)
- })
-}
-xrf.frag.t = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- if( !model.mixer ) return
- if( !model.animations || model.animations[0] == undefined ) return console.warn('no animation in scene')
-
- xrf.mixers.map ( (mixer) => {
- mixer.t = v
-
- // update speed
- mixer.timeScale = mixer.loop.speed = v.x
- mixer.loop.speedAbs = Math.abs(v.x)
-
- if( v.y != undefined || v.z != undefined ) mixer.updateLoop( v )
-
- // play animations
- mixer.play( v )
- })
-}
-
-xrf.frag.t.default = {
- x:0, // (play from) offset (in seconds)
- y:0 // optional: (stop at) offset (in seconds)
-}
-
-// setup animation mixer for global scene & src scenes
-xrf.addEventListener('parseModel', (opts) => {
- let {model} = opts
- let mixer = model.mixer = new xrf.THREE.AnimationMixer(model.scene)
- mixer.model = model
- mixer.loop = {}
- mixer.i = xrf.mixers.length
-
- model.animations.map( (anim) => {
- anim.action = mixer.clipAction( anim, model.scene )
- })
-
- mixer.checkZombies = (animations) => {
- if( mixer.zombieCheck ) return // fire only once
- animations.map( (anim) => {
- // collect zombie animations and warn user
- let zombies = anim.tracks.map( (t) => {
- let name = t.name.replace(/\..*/,'')
- return !model.scene.getObjectByName(name) ? {anim:anim.name,obj:t.name} : undefined
- })
- if( zombies.length > 0 ){
- zombies
- .filter( (z) => z ) // filter out undefined
- .map( (z) => console.warn(`gltf: object '${z.obj}' not found (anim: '${z.anim}'`) )
- console.warn(`TIP: remove dots in objectnames in blender (which adds dots when duplicating)`)
- }
- })
- mixer.zombieCheck = true
- }
-
- mixer.play = (t) => {
- mixer.isPlaying = t.x != 0
- mixer.updateLoop(t)
- xrf.emit( mixer.isPlaying === false ? 'stop' : 'play',{isPlaying: mixer.isPlaying})
- }
-
- mixer.stop = () => {
- mixer.play(false)
- }
-
- mixer.updateLoop = (t) => {
- mixer.loop.timeStart = t.y != undefined ? t.y : mixer.loop.timeStart
- mixer.loop.timeStop = t.z != undefined ? t.z : mixer.loop.timeStop
- mixer.model.animations.map( (anim) => {
- if( mixer.loop.timeStart != undefined ){
- //if( anim.action ) delete anim.action
- //anim.action = mixer.clipAction( anim )
- anim.action.time = mixer.loop.timeStart
- anim.action.setLoop( THREE.LoopOnce, )
- anim.action.timeScale = mixer.timeScale
- anim.action.enabled = true
- if( t.x != 0 ) anim.action.play()
- }
- })
- mixer.setTime(mixer.loop.timeStart)
- mixer.time = Math.abs( mixer.loop.timeStart )
- mixer.update(0)
- mixer.checkZombies( model.animations)
- }
-
- // update loop when needed
- if( !mixer.update.patched ){
- let update = mixer.update
- mixer.update = function(time){
- mixer.time = Math.abs(mixer.time)
- if( time == 0 ) return update.call(this,time)
-
- // loop jump
- if( mixer.loop.speed > 0.0 && mixer.time > mixer.loop.timeStop ){
- setTimeout( (time,anims) => mixer.updateLoop(time), 0, mixer.loop.timeStart ) // prevent recursion
- }
- return update.call( this, time )
- }
- mixer.update.patched = true
- }
-
- // calculate total duration/frame based on longest animation
- mixer.duration = 0
- if( model.animations.length ){
- model.animations.map( (a) => mixer.duration = ( a.duration > mixer.duration ) ? a.duration : mixer.duration )
- }
-
- xrf.mixers.push(mixer)
-})
-
-if( document.location.hash.match(/t=/) ){
- let url = document.location.href
- let playAfterUserGesture = () => {
- xrf.hashbus.pub(url) // re-post t fragment on the hashbus again
- window.removeEventListener('click',playAfterUserGesture)
- window.removeEventListener('touchstart',playAfterUserGesture)
- }
- window.addEventListener('click', playAfterUserGesture )
- window.addEventListener('touchstart', playAfterUserGesture )
-}
-
-xrf.addEventListener('render', (opts) => {
- let model = xrf.model
- let {time} = opts
- if( !model ) return
- if( xrf.mixers.length ){
- xrf.mixers.map( (m) => m.isPlaying ? m.update( time ) : false )
-
- // update active camera in case selected by dynamicKey in URI
- if( xrf.model.camera && model.mixer.isPlaying ){
-
- let cam = xrf.camera.getCam()
- // cam.fov = model.cameras[0].fov (why is blender not exporting radians?)
- cam.far = model.cameras[0].far
- cam.near = model.cameras[0].near
-
- let rig = xrf.camera
- rig.position.copy( model.cameras[0].position )
- rig.position.y -= rig.offsetY // VR/AR compensate camera rig
- //rig.rotation.copy( model.cameras[0].rotation )
-
- rig.updateProjectionMatrix()
- }
- }
-})
xrf.addEventListener('dynamicKey', (opts) => {
- // select active camera if any
- let {id,match,v} = opts
- console.dir(opts)
- match.map( (w) => {
- w.nodes.map( (node) => {
- if( node.isCamera ){
- console.log("setting camera to "+node.name)
- xrf.model.camera = node
+ let {scene,id,match,v} = opts
+ if( v.filter ){
+ let frags = {}
+ frags[ v.filter.key ] = v
+ xrf.filter.scene({frag:frags,scene})
+ }
+})
+
+// spec: https://xrfragment.org/#filters
+xrf.filter = function(query, cb){
+ let result = []
+ if( !query ) return result
+ if( query[0] != '#' ) query = '#'+query
+ // *TODO* jquery like utility func
+ return result
+}
+
+xrf.filter.scene = function(opts){
+ let {scene,frag} = opts
+
+ xrf.filter
+ .sort(frag) // get (sorted) filters from XR Fragments
+ .process(frag,scene,opts) // show/hide things
+
+ scene.visible = true // always enable scene
+
+ return scene
+}
+
+xrf.filter.sort = function(frag){
+ // get all filters from XR Fragments
+ frag.filters = Object.values(frag)
+ .filter( (v) => v.filter ? v : null )
+ .sort( (a,b) => a.index > b.index )
+ return xrf.filter
+}
+
+xrf.filter.process = function(frag,scene,opts){
+ const cleanupKey = (k) => k.replace(/[-\*\/]/g,'')
+ let firstFilter = frag.filters.length ? frag.filters[0].filter.get() : false
+ const hasName = (m,name,filter) => m.name == name
+ const hasNameOrTag = (m,name_or_tag,filter) => hasName(m,name_or_tag) ||
+ String(m.userData['tag']).match( new RegExp("(^| )"+name_or_tag) )
+ // utility functions
+ const getOrCloneMaterial = (o) => {
+ if( o.material ){
+ if( o.material.isXRF ) return o.material
+ o.material = o.material.clone()
+ o.material.isXRF = true
+ return o.material
+ }
+ return {}
+ }
+ const setVisible = (n,visible,filter,processed) => {
+ if( processed && processed[n.uuid] ) return
+ getOrCloneMaterial(n).visible = visible
+ if( filter.deep ) n.traverse( (m) => getOrCloneMaterial(m).visible = visible )
+ if( processed ) processed[n.uuid] == true
+ }
+
+ // spec 2: https://xrfragment.org/doc/RFC_XR_Macros.html#embedding-xr-content-using-src
+ // reparent scene based on objectname in case it matches a (non-negating) selector
+ if( opts.reparent && firstFilter && !firstFilter.value && firstFilter.show === true ){
+ let obj
+ frag.target = firstFilter
+ scene.traverse( (n) => hasName(n, firstFilter.key,firstFilter) && (obj = n) )
+ if(obj){
+ while( scene.children.length > 0 ) scene.children[0].removeFromParent()
+ obj.position.set(0,0,0)
+ scene.add( obj )
+ }
+ }
+
+ // then show/hide things based on secondary selectors
+ // we don't use the XRWG (everything) because we process only the given (sub)scene
+ frag.filters.map( (v) => {
+ const filter = v.filter.get()
+ const name_or_tag = cleanupKey(v.fragment)
+ let processed = {}
+ let extembeds = {}
+
+ // hide external objects temporarely
+ scene.traverse( (m) => {
+ if( m.isSRCExternal ){
+ m.traverse( (n) => (extembeds[ n.uuid ] = m) && (n.visible = false) )
}
})
+
+ scene.traverseVisible( (m) => {
+ // filter on value(expression) #foo=>3 e.g. *TODO* do this in XRWG
+ if( filter.value && m.userData[filter.key] ){
+ const visible = v.filter.testProperty(filter.key, m.userData[filter.key], filter.show === false )
+ setVisible(m,visible,filter,processed)
+ return
+ }
+ if( hasNameOrTag(m,name_or_tag,filter ) ){
+ setVisible(m,filter.show,filter)
+ }
+ })
+
+ // show external objects again
+ for ( let i in extembeds ) extembeds[i].visible = true
})
-})
+
+ return xrf.filter
+}
+
xrf.frag.defaultPredefinedViews = (opts) => {
let {scene,model} = opts;
scene.traverse( (n) => {
@@ -1711,12 +1802,10 @@ xrf.addEventListener('dynamicKey', (opts) => {
if( !scene ) return
let remove = []
// erase previous lines
- xrf.focusLine.lines.map( (line) => line.parent.remove(line) )
+ xrf.focusLine.lines.map( (line) => line.parent && (line.parent.remove(line)) )
xrf.focusLine.points = []
xrf.focusLine.lines = []
- //scene.traverse( (n) => n.selection ? remove.push(n) : false )
- //remove.map( (n) => scene.remove(n.selection) )
// drawlines
match.map( (w) => {
w.nodes.map( (mesh) => xrf.drawLineToMesh({ ...opts, mesh}) )
@@ -1725,6 +1814,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
xrf.drawLineToMesh = (opts) => {
let {scene,mesh,frag,id} = opts
+ const THREE = xrf.THREE
let oldSelection
// Selection of Interest if predefined_view matches object name
if( mesh.visible && mesh.material){
@@ -1743,8 +1833,9 @@ xrf.drawLineToMesh = (opts) => {
return center;
}
- xrf.camera.getCam().updateMatrixWorld(true); // always keeps me diving into the docs :]
- xrf.camera.getCam().getWorldPosition(from)
+ let cam = xrf.camera.getCam ? xrf.camera.getCam() : xrf.camera // *FIXME* camerarig/rig are conflicting
+ cam.updateMatrixWorld(true); // always keeps me diving into the docs :]
+ cam.getWorldPosition(from)
from.y = 0.5 // originate from the heart chakra! :p
const points = [from, getCenterPoint(mesh) ]
const geometry = new THREE.BufferGeometry().setFromPoints( points );
@@ -1779,14 +1870,17 @@ xrf.addEventListener('render', (opts) => {
*/
let loadAudio = (mimetype) => function(url,opts){
- let {mesh,src,camera} = opts
+ let {mesh,src,camera,THREE} = opts
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
let frag = xrf.URI.parse( url )
+ return
+
/* WebAudio: setup context via THREEjs */
if( !camera.listener ){
camera.listener = new THREE.AudioListener();
- camera.getCam().add( camera.listener );
+ // *FIXME* camera vs camerarig conflict
+ (camera.getCam ? camera.getCam() : camera).add( camera.listener );
}
let isPositionalAudio = !(mesh.position.x == 0 && mesh.position.y == 0 && mesh.position.z == 0)
@@ -1825,7 +1919,6 @@ let loadAudio = (mimetype) => function(url,opts){
if( t.z > 0 ) sound.setLoopEnd( loopEnd )
if( t.y != undefined ){
- console.dir({loopStart,t})
sound.setLoopStart( loopStart )
sound.offset = loopStart
}
@@ -1851,7 +1944,7 @@ audioMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadAudio(mim
// listen to t XR fragment changes
xrf.addEventListener('t', (opts) => {
let t = opts.frag.t
- xrf.scene.traverse( (n) => n.audio && n.audio.playXRF ? n.audio.playXRF(t) : false )
+ xrf.scene.traverse( (n) => n.audio && n.audio.playXRF && (n.audio.playXRF(t)) )
})
/*
* mimetype: model/gltf+json
@@ -1883,7 +1976,7 @@ xrf.frag.src.type['gltf'] = function( url, opts ){
*/
xrf.frag.src.type['image/png'] = function(url,opts){
- let {mesh} = opts
+ let {mesh,THREE} = opts
let restrictTo3DBoundingBox = mesh.geometry
let renderEquirect = (texture) => {
@@ -1951,7 +2044,7 @@ xrf.frag.src.type['image/png'] = function(url,opts){
}
}
//const geometry = new THREE.BoxGeometry();
- mesh.material = new THREE.MeshBasicMaterial({
+ mesh.material = new xrf.THREE.MeshBasicMaterial({
map: texture,
transparent: url.match(/(png|gif)/) ? true : false,
side: THREE.DoubleSide,
@@ -1979,10 +2072,197 @@ xrf.frag.src.type['image/png'] = function(url,opts){
xrf.frag.src.type['image/gif'] = xrf.frag.src.type['image/png']
xrf.frag.src.type['image/jpeg'] = xrf.frag.src.type['image/png']
+// spec 8: https://xrfragment.org/doc/RFC_XR_Macros.html#embedding-xr-content-using-src
+
+xrf.portalNonEuclidian = function(opts){
+ let { frag, mesh, model, camera, scene, renderer} = opts
+
+ mesh.portal = {
+ pos: mesh.position.clone(),
+ posWorld: new xrf.THREE.Vector3(),
+ posWorldCamera: new xrf.THREE.Vector3(),
+ stencilRef: xrf.portalNonEuclidian.stencilRef,
+ needUpdate: false,
+ stencilObject: false,
+ cameraDirection: new THREE.Vector3(),
+ cameraPosition: new THREE.Vector3(),
+ raycaster: new THREE.Raycaster(),
+ isLocal: opts.isLocal,
+ isLens: false
+ }
+
+ // allow objects to flip between original and stencil position (which puts them behind stencilplane)
+ const addStencilFeature = (n) => {
+ if( n.stencil ) return n // run once
+ n.stencil = ( (pos,scale) => (sRef,newPos, newScale) => {
+ if( !mesh.portal.isLens ){
+ n.position.copy( sRef == 0 ? pos : newPos )
+ if( sRef > 0 ) n.scale.multiply( newScale )
+ else n.scale.copy( scale )
+ n.updateMatrixWorld(true)
+ }
+ xrf.portalNonEuclidian.selectStencil(n, sRef )
+ }
+ )( n.position.clone(), n.scale.clone() )
+ return n
+ }
+
+ this.setupStencilObjects = (scene,opts) => {
+ // collect related objects to render inside stencilplane
+ let stencilObject = scene
+ if( opts.srcFrag.target ){
+ stencilObject = scene.getObjectByName( opts.srcFrag.target.key )
+ // spec: if src-object is child of portal (then portal is lens, and should include all children )
+ mesh.traverse( (n) => n.name == opts.srcFrag.target.key && (stencilObject = n) && (mesh.portal.isLens = true) )
+ }
+
+ if( !stencilObject ) return console.warn(`no objects were found (src:${mesh.userData.src}) for (portal)object name '${mesh.name}'`)
+ mesh.portal.stencilObject = stencilObject
+
+ // spec: if src points to child, act as lens
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
+
+ let stencilObjects = [stencilObject]
+ stencilObjects = stencilObjects
+ .filter( (n) => !n.portal ) // filter out (self)references to portals (prevent recursion)
+ .map(addStencilFeature)
+
+ //// add missing lights to make sure things get lit properly
+ xrf.scene.traverse( (n) => n.isLight &&
+ !stencilObjects.find( (o) => o.uuid == n.uuid ) &&
+ stencilObjects.push(n)
+ )
+
+ // put it into a scene (without .add() because it reparents objects) so we can render it separately
+ mesh.portal.stencilObjects = new xrf.THREE.Scene()
+ mesh.portal.stencilObjects.children = stencilObjects
+
+ xrf.portalNonEuclidian.stencilRef += 1 // each portal has unique stencil id
+ console.log(`enabling portal for object '${mesh.name}' (stencilRef:${mesh.portal.stencilRef})`)
+
+ // clone so it won't be affected by other fragments
+ setTimeout( (mesh) => {
+ if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
+ }, 0, mesh )
+
+
+ // spec: increase height of portal(object) floor so it won't get rendererd under the current floor
+ mesh.portal.posWorld.y +=0.1
+
+ return this
+ }
+
+ // enable the stencil-material of the stencil objects to prevent stackoverflow (portal in portal rendering)
+ const showPortal = (n,show) => {
+ if( n.portal ) n.visible = show
+ return true
+ }
+
+ this.setupListeners = () => {
+
+ mesh.onAfterRender = function(renderer, scene, camera, geometry, material, group ){
+ mesh.portal.needUpdate = true
+ }
+
+ xrf.addEventListener('renderPost', (opts) => {
+ let {scene,camera,time,render,renderer} = opts
+
+ if( mesh.portal && mesh.portal.stencilObjects ){
+ let stencilRef = mesh.portal.stencilRef
+ let newPos = mesh.portal.posWorld
+ let stencilObject = mesh.portal.stencilObject
+ let newScale = mesh.scale
+ let cameraDirection = mesh.portal.cameraDirection
+ let cameraPosition = mesh.portal.cameraPosition
+ let raycaster = mesh.portal.raycaster
+ let cam = xrf.camera.getCam ? xrf.camera.getCam() : camera
+ cam.getWorldPosition(cameraPosition)
+ if( cameraPosition.distanceTo(newPos) > 20.0 ) return // dont render far portals
+ cam.getWorldDirection(cameraDirection)
+
+ // init
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = true
+ mesh.portal.stencilObjects.traverse( (n) => showPortal(n,false) && n.stencil && n.stencil(stencilRef,newPos,newScale) )
+ renderer.autoClear = false
+ renderer.autoClearDepth = false
+ renderer.autoClearColor = false
+ renderer.autoClearStencil = false
+ // render
+ render( mesh.portal.stencilObjects, camera )
+ // de-init
+ renderer.autoClear = true
+ renderer.autoClearDepth = true
+ renderer.autoClearColor = true
+ renderer.autoClearStencil = true
+ mesh.portal.stencilObjects.traverse( (n) => showPortal(n,true) && n.stencil && (n.stencil(0)) )
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
+
+
+ // trigger href upon camera collide
+ if( mesh.userData.XRF.href ){
+ raycaster.far = 0.35
+ raycaster.set(cameraPosition, cameraDirection )
+ intersects = raycaster.intersectObjects([mesh], false)
+ if (intersects.length > 0 && !mesh.portal.teleporting ){
+ mesh.portal.teleporting = true
+ mesh.userData.XRF.href.exec({nocommit:true})
+ setTimeout( () => mesh.portal.teleporting = false, 500) // dont flip back and forth
+ }
+ }
+ }
+ mesh.portal.needUpdate = false
+ })
+ return this
+ }
+
+ // turn mesh into stencilplane
+ xrf
+ .portalNonEuclidian
+ .setMaterial(mesh)
+ .getWorldPosition(mesh.portal.posWorld)
+
+ this
+ .setupListeners()
+ .setupStencilObjects(scene,opts)
+
+}
+
+xrf.portalNonEuclidian.selectStencil = (n, stencilRef, nested) => {
+ if( n.material ){
+ n.material.stencilRef = stencilRef
+ n.material.stencilWrite = stencilRef > 0
+ n.material.stencilFunc = xrf.THREE.EqualStencilFunc;
+ }
+ if( n.children && !nested ) n.traverse( (m) => !m.portal && (xrf.portalNonEuclidian.selectStencil(m,stencilRef,true)) )
+}
+
+xrf.portalNonEuclidian.setMaterial = function(mesh){
+ mesh.material = new xrf.THREE.MeshBasicMaterial({ color: 'orange' });
+ mesh.material.depthWrite = false;
+ mesh.material.colorWrite = false;
+ mesh.material.stencilWrite = true;
+ mesh.material.stencilRef = xrf.portalNonEuclidian.stencilRef;
+ // mesh.renderOrder = 0;//xrf.portalNonEuclidian.stencilRef;
+ mesh.material.stencilFunc = xrf.THREE.AlwaysStencilFunc;
+ mesh.material.stencilZPass = xrf.THREE.ReplaceStencilOp;
+ mesh.material.stencilZFail = xrf.THREE.ReplaceStencilOp;
+ //n.material.depthFunc = stencilRef > 0 ? xrf.THREE.AlwaysDepth : xrf.THREE.LessEqualDepth
+ //mesh.material.depthTest = false;
+ return mesh
+}
+
+xrf.addEventListener('parseModel',(opts) => {
+ const scene = opts.model.scene
+ // scene.traverse( (n) => n.renderOrder = 10 ) // rendering everything *after* the stencil buffers
+})
+
+
+xrf.portalNonEuclidian.stencilRef = 1
let loadVideo = (mimetype) => function(url,opts){
let {mesh,src,camera} = opts
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
+ const THREE = xrf.THREE
let frag = xrf.URI.parse( url )
let video = mesh.video = document.createElement('video')
@@ -1994,9 +2274,17 @@ let loadVideo = (mimetype) => function(url,opts){
let mat = new xrf.THREE.MeshBasicMaterial()
mat.map = texture
mesh.material = mat
+ // set range
+ //video.addEventListener('timeupdate', function timeupdate() {
+ // if (frag.t && video.currentTime < frag.t.y || video.currentTime >= frag.t.z ) {
+ // video.currentTime = frag.t.y
+ // }
+ //},false)
})
+
video.src = url
video.playXRF = (t) => {
+ video.t = t
if( t.x == 0 ) video.pause()
else{
video.playbackRate = Math.abs( t.x ) // html5 video does not support reverseplay :/
@@ -2015,5 +2303,5 @@ videoMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadVideo(mim
// listen to t XR fragment changes
xrf.addEventListener('t', (opts) => {
let t = opts.frag.t
- xrf.scene.traverse( (n) => n.video ? n.video.playXRF(t) : false )
+ xrf.scene.traverse( (n) => n.video && (n.video.playXRF(t)) )
})
diff --git a/dist/xrfragment.three.module.js b/dist/xrfragment.three.module.js
index 2b45528..88f5698 100644
--- a/dist/xrfragment.three.module.js
+++ b/dist/xrfragment.three.module.js
@@ -1,3 +1,8 @@
+/*
+ * generated at $(date)
+ * https://xrfragment.org
+ * SPDX-License-Identifier: MPL-2.0
+ */
var $hx_exports = typeof exports != "undefined" ? exports : typeof window != "undefined" ? window : typeof self != "undefined" ? self : this;
(function ($global) { "use strict";
$hx_exports["xrfragment"] = $hx_exports["xrfragment"] || {};
@@ -72,6 +77,20 @@ Reflect.deleteField = function(o,field) {
delete(o[field]);
return true;
};
+Reflect.copy = function(o) {
+ if(o == null) {
+ return null;
+ }
+ var o2 = { };
+ var _g = 0;
+ var _g1 = Reflect.fields(o);
+ while(_g < _g1.length) {
+ var f = _g1[_g];
+ ++_g;
+ o2[f] = Reflect.field(o,f);
+ }
+ return o2;
+};
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
@@ -209,83 +228,22 @@ js_Boot.__string_rec = function(o,s) {
return String(o);
}
};
-var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
-xrfragment_Parser.__name__ = true;
-xrfragment_Parser.parse = function(key,value,store) {
- var Frag_h = Object.create(null);
- Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
- Frag_h["prio"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_INT;
- Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
- Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
- Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["q"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["scale"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
- Frag_h["mov"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["show"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.METADATA;
- Frag_h["env"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.METADATA;
- Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["gravity"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["physics"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA;
- Frag_h["fov"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["clip"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["fog"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["bg"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
- Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
- Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
- var isPVDynamic = value.length == 0 && key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
- var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
- if(isPVDynamic) {
- var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR);
- v.validate(key);
- store[key] = v;
- return true;
- }
- var v = new xrfragment_XRF(key,Frag_h[key]);
- if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
- if(!v.validate(value)) {
- console.log("src/xrfragment/Parser.hx:80:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
- return false;
- }
- store[key] = v;
- if(xrfragment_Parser.debug) {
- console.log("src/xrfragment/Parser.hx:84:","✔ " + key + ": " + v.string);
- }
- } else {
- if(typeof(value) == "string") {
- v.guessType(v,value);
- }
- v.noXRF = true;
- store[key] = v;
- }
- return true;
-};
-var xrfragment_Query = $hx_exports["xrfragment"]["Query"] = function(str) {
- this.isNumber = new EReg("^[0-9\\.]+$","");
- this.isRoot = new EReg("^[-]?/","");
- this.isExclude = new EReg("^-","");
- this.isProp = new EReg("^.*:[><=!]?","");
+var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
this.q = { };
this.str = "";
if(str != null) {
this.parse(str);
}
};
-xrfragment_Query.__name__ = true;
-xrfragment_Query.prototype = {
+xrfragment_Filter.__name__ = true;
+xrfragment_Filter.prototype = {
toObject: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,get: function() {
- return this.q;
+ return Reflect.copy(this.q);
}
,parse: function(str) {
- var _gthis = this;
var token = str.split(" ");
var q = { };
var process = function(str,prefix) {
@@ -293,59 +251,42 @@ xrfragment_Query.prototype = {
prefix = "";
}
str = StringTools.trim(str);
- var k = str.split(":")[0];
- var v = str.split(":")[1];
+ var k = str.split("=")[0];
+ var v = str.split("=")[1];
var filter = { };
if(q[prefix + k]) {
filter = q[prefix + k];
}
- filter["rules"] = filter["rules"] != null ? filter["rules"] : [];
- if(_gthis.isProp.match(str)) {
+ if(xrfragment_XRF.isProp.match(str)) {
var oper = "";
- if(str.indexOf("*") != -1) {
- oper = "*";
- }
if(str.indexOf(">") != -1) {
oper = ">";
}
if(str.indexOf("<") != -1) {
oper = "<";
}
- if(str.indexOf(">=") != -1) {
- oper = ">=";
- }
- if(str.indexOf("<=") != -1) {
- oper = "<=";
- }
- if(_gthis.isExclude.match(k)) {
- oper = "!=";
+ if(xrfragment_XRF.isExclude.match(k)) {
k = HxOverrides.substr(k,1,null);
- } else {
- v = HxOverrides.substr(v,oper.length,null);
}
+ v = HxOverrides.substr(v,oper.length,null);
if(oper.length == 0) {
oper = "=";
}
var rule = { };
- if(_gthis.isNumber.match(v)) {
+ if(xrfragment_XRF.isNumber.match(v)) {
rule[oper] = parseFloat(v);
} else {
rule[oper] = v;
}
- filter["rules"].push(rule);
- q[k] = filter;
- return;
- } else {
- filter["id"] = _gthis.isExclude.match(str) ? false : true;
- filter["root"] = _gthis.isRoot.match(str);
- if(_gthis.isExclude.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- if(_gthis.isRoot.match(str)) {
- str = HxOverrides.substr(str,1,null);
- }
- q[str] = filter;
+ q["expr"] = rule;
}
+ var value = xrfragment_XRF.isDeep.match(str) ? k.split("*").length - 1 : 0;
+ q["deep"] = value;
+ var value = xrfragment_XRF.isExclude.match(str) ? false : true;
+ q["show"] = value;
+ var value = k.replace(xrfragment_XRF.operators.r,"");
+ q["key"] = value;
+ q["value"] = v;
};
var _g = 0;
var _g1 = token.length;
@@ -394,49 +335,75 @@ xrfragment_Query.prototype = {
return v[property];
}
}
- var _g = 0;
- var _g1 = Reflect.fields(this.q);
- while(_g < _g1.length) {
- var k = _g1[_g];
- ++_g;
- var filter = Reflect.field(this.q,k);
- if(filter.rules == null) {
- continue;
- }
- var rules = filter.rules;
- var _g2 = 0;
- while(_g2 < rules.length) {
- var rule = rules[_g2];
- ++_g2;
- if(exclude) {
- if(Reflect.field(rule,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(rule,"!="))) && exclude) {
- ++qualify;
- }
- } else {
- if(Reflect.field(rule,"*") != null && testprop(parseFloat(value) != null)) {
- ++qualify;
- }
- if(Reflect.field(rule,">") != null && testprop(parseFloat(value) > parseFloat(Reflect.field(rule,">")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<") != null && testprop(parseFloat(value) < parseFloat(Reflect.field(rule,"<")))) {
- ++qualify;
- }
- if(Reflect.field(rule,">=") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(rule,">=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"<=") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(rule,"<=")))) {
- ++qualify;
- }
- if(Reflect.field(rule,"=") != null && (testprop(value == Reflect.field(rule,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(rule,"="))))) {
- ++qualify;
- }
+ if(Reflect.field(this.q,"expr")) {
+ var f = Reflect.field(this.q,"expr");
+ if(!Reflect.field(this.q,"show")) {
+ if(Reflect.field(f,"!=") != null && testprop((value == null ? "null" : "" + value) == Std.string(Reflect.field(f,"!="))) && exclude) {
+ ++qualify;
+ }
+ } else {
+ if(Reflect.field(f,"*") != null && testprop(parseFloat(value) != null)) {
+ ++qualify;
+ }
+ if(Reflect.field(f,">") != null && testprop(parseFloat(value) >= parseFloat(Reflect.field(f,">")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"<") != null && testprop(parseFloat(value) <= parseFloat(Reflect.field(f,"<")))) {
+ ++qualify;
+ }
+ if(Reflect.field(f,"=") != null && (testprop(value == Reflect.field(f,"=")) || testprop(parseFloat(value) == parseFloat(Reflect.field(f,"="))))) {
+ ++qualify;
}
}
}
return qualify > 0;
}
};
+var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
+xrfragment_Parser.__name__ = true;
+xrfragment_Parser.parse = function(key,value,store,index) {
+ var Frag_h = Object.create(null);
+ Frag_h["#"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_PREDEFINED_VIEW | xrfragment_XRF.PV_EXECUTE;
+ Frag_h["src"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL;
+ Frag_h["href"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.T_PREDEFINED_VIEW;
+ Frag_h["tag"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["pos"] = xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.T_STRING | xrfragment_XRF.T_STRING_OBJ | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["rot"] = xrfragment_XRF.QUERY_OPERATOR | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.METADATA | xrfragment_XRF.NAVIGATOR;
+ Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_STRING | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["tv"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_FLOAT | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.T_VECTOR3 | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
+ Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING;
+ Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA | xrfragment_XRF.PROMPT;
+ var keyStripped = key.replace(xrfragment_XRF.operators.r,"");
+ var isPVDynamic = key.length > 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key);
+ var isPVDefault = value.length == 0 && key.length > 0 && key == "#";
+ if(isPVDynamic) {
+ var v = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.NAVIGATOR,index);
+ v.validate(value);
+ store[keyStripped] = v;
+ return true;
+ }
+ var v = new xrfragment_XRF(key,Frag_h[key],index);
+ if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
+ if(!v.validate(value)) {
+ console.log("src/xrfragment/Parser.hx:66:","⚠ fragment '" + key + "' has incompatible value (" + value + ")");
+ return false;
+ }
+ store[keyStripped] = v;
+ if(xrfragment_Parser.debug) {
+ console.log("src/xrfragment/Parser.hx:70:","✔ " + key + ": " + v.string);
+ }
+ } else {
+ if(typeof(value) == "string") {
+ v.guessType(v,value);
+ }
+ v.noXRF = true;
+ store[keyStripped] = v;
+ }
+ return true;
+};
var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
@@ -458,7 +425,7 @@ xrfragment_URI.parse = function(url,filter) {
var s = regexPlus.split(splitByEqual[1]).join(" ");
value = decodeURIComponent(s.split("+").join(" "));
}
- var ok = xrfragment_Parser.parse(key,value,store);
+ var ok = xrfragment_Parser.parse(key,value,store,i);
}
if(filter != null && filter != 0) {
var _g = 0;
@@ -474,9 +441,10 @@ xrfragment_URI.parse = function(url,filter) {
}
return store;
};
-var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) {
+var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
this.fragment = _fragment;
this.flags = _flags;
+ this.index = _index;
};
xrfragment_XRF.__name__ = true;
xrfragment_XRF.set = function(flag,flags) {
@@ -495,45 +463,50 @@ xrfragment_XRF.prototype = {
}
,validate: function(value) {
this.guessType(this,value);
- if(this.fragment == "q") {
- this.query = new xrfragment_Query(value).get();
- }
var ok = true;
if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
ok = false;
}
- if(!this.is(xrfragment_XRF.T_VECTOR2) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
+ if(!(this.is(xrfragment_XRF.T_VECTOR2) || this.is(xrfragment_XRF.T_STRING)) && this.is(xrfragment_XRF.T_VECTOR3) && !(typeof(this.x) == "number" && typeof(this.y) == "number" && typeof(this.z) == "number")) {
ok = false;
}
return ok;
}
,guessType: function(v,str) {
v.string = str;
- if(str.split(",").length > 1) {
- var xyzw = str.split(",");
- if(xyzw.length > 0) {
- v.x = parseFloat(xyzw[0]);
- }
- if(xyzw.length > 1) {
- v.y = parseFloat(xyzw[1]);
- }
- if(xyzw.length > 2) {
- v.z = parseFloat(xyzw[2]);
- }
- if(xyzw.length > 3) {
- v.w = parseFloat(xyzw[3]);
- }
+ if(typeof(str) != "string") {
+ return;
}
- if(xrfragment_XRF.isColor.match(str)) {
- v.color = str;
- }
- if(xrfragment_XRF.isFloat.match(str)) {
- v.x = parseFloat(str);
- v.float = v.x;
- }
- if(xrfragment_XRF.isInt.match(str)) {
- v.int = Std.parseInt(str);
- v.x = v.int;
+ if(str.length > 0) {
+ if(str.split(",").length > 1) {
+ var xyzw = str.split(",");
+ if(xyzw.length > 0) {
+ v.x = parseFloat(xyzw[0]);
+ }
+ if(xyzw.length > 1) {
+ v.y = parseFloat(xyzw[1]);
+ }
+ if(xyzw.length > 2) {
+ v.z = parseFloat(xyzw[2]);
+ }
+ if(xyzw.length > 3) {
+ v.w = parseFloat(xyzw[3]);
+ }
+ }
+ if(xrfragment_XRF.isColor.match(str)) {
+ v.color = str;
+ }
+ if(xrfragment_XRF.isFloat.match(str)) {
+ v.x = parseFloat(str);
+ v.float = v.x;
+ }
+ if(xrfragment_XRF.isInt.match(str)) {
+ v.int = Std.parseInt(str);
+ v.x = v.int;
+ }
+ v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
+ } else {
+ v.filter = new xrfragment_Filter(v.fragment);
}
}
};
@@ -571,6 +544,11 @@ xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
xrfragment_XRF.isString = new EReg(".*","");
+xrfragment_XRF.operators = new EReg("(^-|[\\*]+)","");
+xrfragment_XRF.isProp = new EReg("^.*=[><=]?","");
+xrfragment_XRF.isExclude = new EReg("^-","");
+xrfragment_XRF.isDeep = new EReg("\\*","");
+xrfragment_XRF.isNumber = new EReg("^[0-9\\.]+$","");
})({});
var xrfragment = $hx_exports["xrfragment"];
// SPDX-License-Identifier: MPL-2.0
@@ -579,7 +557,8 @@ var xrfragment = $hx_exports["xrfragment"];
var xrf = {}
xrf.init = function(opts){
- opts = opts || {}
+ opts = opts || {}
+ xrf.debug = parseInt( ( document.location.hash.match(/debug=([0-9])/) || [0,'0'] )[1] )
xrf.Parser.debug = xrf.debug
xrf.detectCameraRig(opts)
for ( let i in opts ) xrf[i] = opts[i]
@@ -624,7 +603,7 @@ xrf.hasTag = (tag,tags) => String(tags).match( new RegExp(`(^| )${tag}( |$)`,`g`
// map library functions to xrf
for ( let i in xrfragment ) xrf[i] = xrfragment[i]
/*
- * (promise-able) EVENTS
+ * (promise-able) EVENTS (optionally continue after listeners are finished using .then)
*
* example:
*
@@ -649,14 +628,23 @@ xrf.addEventListener = function(eventName, callback, scene) {
// add the callback to the listeners array for this event name
this._listeners[eventName].push(callback);
return () => {
- console.log("size = "+this._listeners[eventName].length)
this._listeners[eventName] = this._listeners[eventName].filter( (c) => c != callback )
- console.log("size = "+this._listeners[eventName].length)
}
};
xrf.emit = function(eventName, data){
if( typeof data != 'object' ) throw 'emit() requires passing objects'
+ if( xrf.debug && ( eventName != "render" || xrf.debug == eventName ) ){
+ let label = String(`xrf.emit('${eventName}')`).padEnd(35," ");
+ label += data.mesh && data.mesh.name ? '#'+data.mesh.name : ''
+ console.groupCollapsed(label)
+ console.info(data)
+ console.groupEnd(label)
+ if( xrf.debug > 1 ) debugger
+ }
+ // forward to THREEjs eventbus if any
+ if( data.scene ) data.scene.dispatchEvent( eventName, data )
+ if( data.mesh ) data.mesh.dispatchEvent( eventName, data )
return xrf.emit.promise(eventName,data)
}
@@ -671,15 +659,21 @@ xrf.emit.normal = function(eventName, data) {
};
xrf.emit.promise = function(e, opts){
- opts.XRF = xrf // always pass root XRF obj
return new Promise( (resolve, reject) => {
opts.promise = () => {
- opts.promise.halted = true
- return { resolve, reject }
+ opts.promises = opts.promises || []
+ opts.promises.push(0)
+ return {
+ resolve: ((index) => () => {
+ opts.promises[index] = 1
+ let succesful = opts.promises.reduce( (a,b) => a+b )
+ if( succesful == opts.promises.length ) resolve(opts)
+ })(opts.promises.length-1),
+ reject: console.error
+ }
}
xrf.emit.normal(e, opts)
- delete opts.XRF
- if( !opts.promise.halted ) resolve()
+ if( !opts.promises ) resolve(opts)
delete opts.promise
})
}
@@ -687,7 +681,8 @@ xrf.emit.promise = function(e, opts){
* http://www.github.com/cburgmer/rasterizeHTML.js
* Copyright (c) 2023 Christoph Burgmer; Licensed MIT */
-!function(o,i){void 0===o&&void 0!==window&&(o=window),"function"==typeof define&&define.amd?define(["url","xmlserializer","sane-domparser-error","inlineresources"],function(e,t,n,r){return o.rasterizeHTML=i(e,t,n,r)}):"object"==typeof module&&module.exports?module.exports=i(require("url"),require("xmlserializer"),require("sane-domparser-error"),require("inlineresources")):o.rasterizeHTML=i(o.url,o.xmlserializer,o.sanedomparsererror,o.inlineresources)}(this,function(e,t,n,r){var o=function(n){"use strict";var o={},t=[];o.joinUrl=function(e,t){return e?n.resolve(e,t):t},o.getConstantUniqueIdFor=function(e){return t.indexOf(e)<0&&t.push(e),t.indexOf(e)},o.clone=function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};return o.parseOptionalParameters=function(e){var t,n,r={canvas:null,options:{}};return null==e[0]||(t=e[0],"object"==typeof(n=t)&&null!==n&&Object.prototype.toString.apply(t).match(/\[object (Canvas|HTMLCanvasElement)\]/i))?(r.canvas=e[0]||null,r.options=o.clone(e[1])):r.options=o.clone(e[0]),r},o}(e),i=function(i){"use strict";function u(e,t,n){var r=e[t];return e[t]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(this,[e,r])},r}var e={};return e.baseUrlRespectingXhr=function(t,o){return function(){var e=new t;return u(e,"open",function(e,t){var n=e.shift(),r=e.shift(),r=i.joinUrl(o,r);return t.apply(this,[n,r].concat(e))}),e}},e.finishNotifyingXhr=function(t){function e(){var e=new t;return u(e,"send",function(e,t){return r+=1,t.apply(this,arguments)}),e.addEventListener("load",function(){o+=1,n()}),e}var n,r=0,o=0,i=!1,c=new Promise(function(e){n=function(){r-o<=0&&i&&e({totalCount:r})}});return e.waitForRequestsToFinish=function(){return i=!0,n(),c},e},e}(o),e=function(i){"use strict";function r(e){return Array.prototype.slice.call(e)}var e={},c={active:!0,hover:!0,focus:!1,target:!1};return e.fakeUserAction=function(e,t,n){var r=e.querySelector(t),o=":"+n,t="rasterizehtml"+n;r&&(c[n]?i.addClassNameRecursively(r,t):i.addClassName(r,t),i.rewriteCssSelectorWith(e,o,"."+t))},e.persistInputValues=function(e){function t(e){return"checkbox"===e.type||"radio"===e.type}var n=e.querySelectorAll("input"),e=e.querySelectorAll("textarea");r(n).filter(t).forEach(function(e){e.checked?e.setAttribute("checked",""):e.removeAttribute("checked")}),r(n).filter(function(e){return!t(e)}).forEach(function(e){e.setAttribute("value",e.value)}),r(e).forEach(function(e){e.textContent=e.value})},e.rewriteTagNameSelectorsToLowerCase=function(e){i.lowercaseCssTypeSelectors(e,i.findHtmlOnlyNodeNames(e))},e}(function(){"use strict";function c(e){return Array.prototype.slice.call(e)}var n={};n.addClassName=function(e,t){e.className+=" "+t},n.addClassNameRecursively=function(e,t){n.addClassName(e,t),e.parentNode!==e.ownerDocument&&n.addClassNameRecursively(e.parentNode,t)};function r(e,t,o){var i="((?:^|[^.#:\\w])|(?=\\W))("+t.join("|")+")(?=\\W|$)";c(e.querySelectorAll("style")).forEach(function(e){var t,n;void 0===e.sheet&&(t=e,n=document.implementation.createHTMLDocument(""),(r=document.createElement("style")).textContent=t.textContent,n.body.appendChild(r),t.sheet=r.sheet);var r=c(e.sheet.cssRules).filter(function(e){return e.selectorText&&new RegExp(i,"i").test(e.selectorText)});r.length&&(r.forEach(function(e){var t,n=e.selectorText.replace(new RegExp(i,"gi"),function(e,t,n){return t+o(n)});n!==e.selectorText&&(t=n,e=(n=e).cssText.replace(/^[^\{]+/,""),u(n,t+" "+e))}),e.textContent=a(e.sheet.cssRules))})}var u=function(e,t){var n=e.parentStyleSheet,e=c(n.cssRules).indexOf(e);n.insertRule(t,e+1),n.deleteRule(e)},a=function(e){return c(e).reduce(function(e,t){return e+t.cssText},"")};return n.rewriteCssSelectorWith=function(e,t,n){r(e,[t],function(){return n})},n.lowercaseCssTypeSelectors=function(e,t){r(e,t,function(e){return e.toLowerCase()})},n.findHtmlOnlyNodeNames=function(e){for(var t,n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r={},o={};t=n.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===n.currentNode.namespaceURI?r[t]=!0:o[t]=!0,n.nextNode(););return Object.keys(r).filter(function(e){return!o[e]})},n}()),i=function(a,f,t,m){"use strict";var e={};e.executeJavascript=function(s,l){return new Promise(function(t){function n(){m.document.getElementsByTagName("body")[0].removeChild(r)}function e(){var e=r.contentDocument;t({document:e,errors:i,cleanUp:n})}var r=function(e,t,n,r){t=e.createElement(t);return t.style.visibility="hidden",t.style.width=n+"px",t.style.height=r+"px",t.style.position="absolute",t.style.top=-1e4-r+"px",t.style.left=-1e4-n+"px",e.getElementsByTagName("body")[0].appendChild(t),t}(m.document,"iframe",l.width,l.height),o=s.outerHTML,i=[],c=l.executeJsTimeout||0,u=r.contentWindow.XMLHttpRequest,a=f.finishNotifyingXhr(u),u=f.baseUrlRespectingXhr(a,l.baseUrl);r.onload=function(){var t;(0<(t=c)?new Promise(function(e){setTimeout(e,t)}):Promise.resolve()).then(a.waitForRequestsToFinish).then(e)},r.contentDocument.open(),r.contentWindow.XMLHttpRequest=u,r.contentWindow.onerror=function(e){i.push({resourceType:"scriptExecution",msg:e})},r.contentDocument.write(""),r.contentDocument.write(o),r.contentDocument.close()})};function s(e,t,n,r,o){var i,c,u,a=Math.max(e.scrollWidth,e.clientWidth),s=Math.max(e.scrollHeight,e.clientHeight),l=t?(i=(l=function(e,t){var n=e.querySelector(t);if(n)return n;if(e.ownerDocument.querySelector(t)===e)return e;throw{message:"Clipping selector not found"}}(e,t).getBoundingClientRect()).top,c=l.left,u=l.width,l.height):(c=i=0,u=a,s);return l={width:u,height:l},r=r,o=o,r={width:Math.max(l.width*o,n),height:Math.max(l.height*o,r)},e=m.getComputedStyle(e.ownerDocument.documentElement).fontSize,{left:c,top:i,width:r.width,height:r.height,viewportWidth:a,viewportHeight:s,rootFontSize:e}}e.calculateDocumentContentSize=function(c,u){return new Promise(function(n,r){var e,t,o=u.zoom||1,i=function(e,t,n){e=Math.floor(e/n),n=Math.floor(t/n);return function(e,t,n){e=e.createElement("iframe");return e.style.width=t+"px",e.style.height=n+"px",e.style.visibility="hidden",e.style.position="absolute",e.style.top=-1e4-n+"px",e.style.left=-1e4-t+"px",e.style.borderWidth=0,e.sandbox="allow-same-origin",e.scrolling="no",e}(m.document,e,n)}(u.width,u.height,o);m.document.getElementsByTagName("body")[0].appendChild(i),i.onload=function(){var e,t=i.contentDocument;try{e=s(function(e,t){e=e.tagName;return t.querySelector(e)}(c,t),u.clip,u.width,u.height,o),n(e)}catch(e){r(e)}finally{m.document.getElementsByTagName("body")[0].removeChild(i)}},i.contentDocument.open(),i.contentDocument.write(""),i.contentDocument.write("html"===(t=(e=c).tagName.toLowerCase())||"body"===t?e.outerHTML:''+e.outerHTML+""),i.contentDocument.close()})},e.parseHtmlFragment=function(e){var t=m.document.implementation.createHTMLDocument("");t.documentElement.innerHTML=e;t=t.querySelector("body").firstChild;if(!t)throw"Invalid source";return t};e.parseHTML=function(e){var t=m.document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,function(e,t){var n,r,o,i=/]*)?)>/im.exec(t),t=m.document.implementation.createHTMLDocument("");if(i)for(i="",t.documentElement.innerHTML=i,r=t.querySelector("div"),n=0;n',n=function(){return new Promise(function(t,e){var n;(function(){if(r.Blob)try{return new Blob([""],{type:"text/xml"}),!0}catch(e){}return!1})()&&r.URL?(n=o(a,!0),i(n).then(function(e){return c(n),!e&&i(o(a,!1)).then(function(e){return e})},function(){return!1}).then(function(e){t(!e)},function(){e()})):t(!1)})};return t.renderSvg=function(i){return new Promise(function(e,t){function n(){r&&c(r)}var r,o=new Image;o.onload=function(){o.onload=null,o.onerror=null,n(),e(o)},o.onerror=function(){n(),t()},u(i).then(function(e){r=e,o.src=r},t)})},t}(window);return function(o,i,c){"use strict";var u={};u.drawDocument=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n=o.parseOptionalParameters(t),r=e.documentElement||e;return c.rasterize(r,n.canvas,(e=(t=n).canvas,r=t.options,n=e?e.width:300,e=e?e.height:200,e={width:void 0!==r.width?r.width:n,height:void 0!==r.height?r.height:e},(t=o.clone(t.options)).width=e.width,t.height=e.height,t))};u.drawHTML=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return function(e,t,n){e=i.parseHTML(e);return u.drawDocument(e,t,n)}(e,t.canvas,t.options)};function n(t,n,r){return i.loadDocument(t,r).then(function(e){e=function(e,t,n){var r=document.implementation.createHTMLDocument("");r.replaceChild(e.documentElement,r.documentElement);e=n?o.clone(n):{};return n.baseUrl||(e.baseUrl=t),{document:r,options:e}}(e,t,r);return u.drawDocument(e.document,n,e.options)})}return u.drawURL=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return n(e,t.canvas,t.options)},u}(o,i,function(o,i,c,r,e,u){"use strict";function a(t){return e.renderSvg(t).then(function(e){return{image:e,svg:t}},function(e){throw l(e)})}function s(e,t,n){return r.drawDocumentAsSvg(e,n).then(a).then(function(e){return t&&function(e,t){try{t.getContext("2d").drawImage(e,0,0)}catch(e){throw l(e)}}(e.image,t),e})}var t={},l=function(e){return{message:"Error rendering page",originalError:e}};return t.rasterize=function(e,n,r){var t=o.clone(r);return t.inlineScripts=!0===r.executeJs,u.inlineReferences(e,t).then(function(t){return r.executeJs?i.executeJavascript(e,r).then(function(e){var t=e.document;return c.persistInputValues(t),{document:t,errors:e.errors,cleanUp:e.cleanUp}}).then(function(e){return{element:e.document.documentElement,errors:t.concat(e.errors),cleanUp:e.cleanUp}}):{element:e,errors:t,cleanUp:function(){}}}).then(function(t){return s(t.element,n,r).then(function(e){return t.cleanUp(),{image:e.image,svg:e.svg,errors:t.errors}})})},t}(o,i,e,function(c,r,u){"use strict";function a(t){var e=Object.keys(t);return e.length?" "+e.map(function(e){return e+'="'+t[e]+'"'}).join(" "):""}function o(e,t,n){var r,o,i=u.serializeToString(e);return c.validateXHTML(i),(e=(r=t,o=Math.round(r.viewportWidth),e=Math.round(r.viewportHeight),{x:-r.left,y:-r.top,width:o,height:e})).style=(e.style||"")+"float: left;",e.externalResourcesRequired=!0,'"}var i={};return i.getSvgForDocument=function(e,t,n){return r.rewriteTagNameSelectorsToLowerCase(e),o(e,t,n)},i.drawDocumentAsSvg=function(t,n){return["hover","active","focus","target"].forEach(function(e){n[e]&&r.fakeUserAction(t,n[e],e)}),c.calculateDocumentContentSize(t,n).then(function(e){return i.getSvgForDocument(t,e,n.zoom)})},i}(i,e,t),n,r))});// the XRWG (XR WordGraph)is mentioned in the spec
+!function(o,i){void 0===o&&void 0!==window&&(o=window),"function"==typeof define&&define.amd?define(["url","xmlserializer","sane-domparser-error","inlineresources"],function(e,t,n,r){return o.rasterizeHTML=i(e,t,n,r)}):"object"==typeof module&&module.exports?module.exports=i(require("url"),require("xmlserializer"),require("sane-domparser-error"),require("inlineresources")):o.rasterizeHTML=i(o.url,o.xmlserializer,o.sanedomparsererror,o.inlineresources)}(this,function(e,t,n,r){var o=function(n){"use strict";var o={},t=[];o.joinUrl=function(e,t){return e?n.resolve(e,t):t},o.getConstantUniqueIdFor=function(e){return t.indexOf(e)<0&&t.push(e),t.indexOf(e)},o.clone=function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n};return o.parseOptionalParameters=function(e){var t,n,r={canvas:null,options:{}};return null==e[0]||(t=e[0],"object"==typeof(n=t)&&null!==n&&Object.prototype.toString.apply(t).match(/\[object (Canvas|HTMLCanvasElement)\]/i))?(r.canvas=e[0]||null,r.options=o.clone(e[1])):r.options=o.clone(e[0]),r},o}(e),i=function(i){"use strict";function u(e,t,n){var r=e[t];return e[t]=function(){var e=Array.prototype.slice.call(arguments);return n.apply(this,[e,r])},r}var e={};return e.baseUrlRespectingXhr=function(t,o){return function(){var e=new t;return u(e,"open",function(e,t){var n=e.shift(),r=e.shift(),r=i.joinUrl(o,r);return t.apply(this,[n,r].concat(e))}),e}},e.finishNotifyingXhr=function(t){function e(){var e=new t;return u(e,"send",function(e,t){return r+=1,t.apply(this,arguments)}),e.addEventListener("load",function(){o+=1,n()}),e}var n,r=0,o=0,i=!1,c=new Promise(function(e){n=function(){r-o<=0&&i&&e({totalCount:r})}});return e.waitForRequestsToFinish=function(){return i=!0,n(),c},e},e}(o),e=function(i){"use strict";function r(e){return Array.prototype.slice.call(e)}var e={},c={active:!0,hover:!0,focus:!1,target:!1};return e.fakeUserAction=function(e,t,n){var r=e.querySelector(t),o=":"+n,t="rasterizehtml"+n;r&&(c[n]?i.addClassNameRecursively(r,t):i.addClassName(r,t),i.rewriteCssSelectorWith(e,o,"."+t))},e.persistInputValues=function(e){function t(e){return"checkbox"===e.type||"radio"===e.type}var n=e.querySelectorAll("input"),e=e.querySelectorAll("textarea");r(n).filter(t).forEach(function(e){e.checked?e.setAttribute("checked",""):e.removeAttribute("checked")}),r(n).filter(function(e){return!t(e)}).forEach(function(e){e.setAttribute("value",e.value)}),r(e).forEach(function(e){e.textContent=e.value})},e.rewriteTagNameSelectorsToLowerCase=function(e){i.lowercaseCssTypeSelectors(e,i.findHtmlOnlyNodeNames(e))},e}(function(){"use strict";function c(e){return Array.prototype.slice.call(e)}var n={};n.addClassName=function(e,t){e.className+=" "+t},n.addClassNameRecursively=function(e,t){n.addClassName(e,t),e.parentNode!==e.ownerDocument&&n.addClassNameRecursively(e.parentNode,t)};function r(e,t,o){var i="((?:^|[^.#:\\w])|(?=\\W))("+t.join("|")+")(?=\\W|$)";c(e.querySelectorAll("style")).forEach(function(e){var t,n;void 0===e.sheet&&(t=e,n=document.implementation.createHTMLDocument(""),(r=document.createElement("style")).textContent=t.textContent,n.body.appendChild(r),t.sheet=r.sheet);var r=c(e.sheet.cssRules).filter(function(e){return e.selectorText&&new RegExp(i,"i").test(e.selectorText)});r.length&&(r.forEach(function(e){var t,n=e.selectorText.replace(new RegExp(i,"gi"),function(e,t,n){return t+o(n)});n!==e.selectorText&&(t=n,e=(n=e).cssText.replace(/^[^\{]+/,""),u(n,t+" "+e))}),e.textContent=a(e.sheet.cssRules))})}var u=function(e,t){var n=e.parentStyleSheet,e=c(n.cssRules).indexOf(e);n.insertRule(t,e+1),n.deleteRule(e)},a=function(e){return c(e).reduce(function(e,t){return e+t.cssText},"")};return n.rewriteCssSelectorWith=function(e,t,n){r(e,[t],function(){return n})},n.lowercaseCssTypeSelectors=function(e,t){r(e,t,function(e){return e.toLowerCase()})},n.findHtmlOnlyNodeNames=function(e){for(var t,n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),r={},o={};t=n.currentNode.tagName.toLowerCase(),"http://www.w3.org/1999/xhtml"===n.currentNode.namespaceURI?r[t]=!0:o[t]=!0,n.nextNode(););return Object.keys(r).filter(function(e){return!o[e]})},n}()),i=function(a,f,t,m){"use strict";var e={};e.executeJavascript=function(s,l){return new Promise(function(t){function n(){m.document.getElementsByTagName("body")[0].removeChild(r)}function e(){var e=r.contentDocument;t({document:e,errors:i,cleanUp:n})}var r=function(e,t,n,r){t=e.createElement(t);return t.style.visibility="hidden",t.style.width=n+"px",t.style.height=r+"px",t.style.position="absolute",t.style.top=-1e4-r+"px",t.style.left=-1e4-n+"px",e.getElementsByTagName("body")[0].appendChild(t),t}(m.document,"iframe",l.width,l.height),o=s.outerHTML,i=[],c=l.executeJsTimeout||0,u=r.contentWindow.XMLHttpRequest,a=f.finishNotifyingXhr(u),u=f.baseUrlRespectingXhr(a,l.baseUrl);r.onload=function(){var t;(0<(t=c)?new Promise(function(e){setTimeout(e,t)}):Promise.resolve()).then(a.waitForRequestsToFinish).then(e)},r.contentDocument.open(),r.contentWindow.XMLHttpRequest=u,r.contentWindow.onerror=function(e){i.push({resourceType:"scriptExecution",msg:e})},r.contentDocument.write(""),r.contentDocument.write(o),r.contentDocument.close()})};function s(e,t,n,r,o){var i,c,u,a=Math.max(e.scrollWidth,e.clientWidth),s=Math.max(e.scrollHeight,e.clientHeight),l=t?(i=(l=function(e,t){var n=e.querySelector(t);if(n)return n;if(e.ownerDocument.querySelector(t)===e)return e;throw{message:"Clipping selector not found"}}(e,t).getBoundingClientRect()).top,c=l.left,u=l.width,l.height):(c=i=0,u=a,s);return l={width:u,height:l},r=r,o=o,r={width:Math.max(l.width*o,n),height:Math.max(l.height*o,r)},e=m.getComputedStyle(e.ownerDocument.documentElement).fontSize,{left:c,top:i,width:r.width,height:r.height,viewportWidth:a,viewportHeight:s,rootFontSize:e}}e.calculateDocumentContentSize=function(c,u){return new Promise(function(n,r){var e,t,o=u.zoom||1,i=function(e,t,n){e=Math.floor(e/n),n=Math.floor(t/n);return function(e,t,n){e=e.createElement("iframe");return e.style.width=t+"px",e.style.height=n+"px",e.style.visibility="hidden",e.style.position="absolute",e.style.top=-1e4-n+"px",e.style.left=-1e4-t+"px",e.style.borderWidth=0,e.sandbox="allow-same-origin",e.scrolling="no",e}(m.document,e,n)}(u.width,u.height,o);m.document.getElementsByTagName("body")[0].appendChild(i),i.onload=function(){var e,t=i.contentDocument;try{e=s(function(e,t){e=e.tagName;return t.querySelector(e)}(c,t),u.clip,u.width,u.height,o),n(e)}catch(e){r(e)}finally{m.document.getElementsByTagName("body")[0].removeChild(i)}},i.contentDocument.open(),i.contentDocument.write(""),i.contentDocument.write("html"===(t=(e=c).tagName.toLowerCase())||"body"===t?e.outerHTML:''+e.outerHTML+""),i.contentDocument.close()})},e.parseHtmlFragment=function(e){var t=m.document.implementation.createHTMLDocument("");t.documentElement.innerHTML=e;t=t.querySelector("body").firstChild;if(!t)throw"Invalid source";return t};e.parseHTML=function(e){var t=m.document.implementation.createHTMLDocument("");return t.documentElement.innerHTML=e,function(e,t){var n,r,o,i=/]*)?)>/im.exec(t),t=m.document.implementation.createHTMLDocument("");if(i)for(i="",t.documentElement.innerHTML=i,r=t.querySelector("div"),n=0;n',n=function(){return new Promise(function(t,e){var n;(function(){if(r.Blob)try{return new Blob([""],{type:"text/xml"}),!0}catch(e){}return!1})()&&r.URL?(n=o(a,!0),i(n).then(function(e){return c(n),!e&&i(o(a,!1)).then(function(e){return e})},function(){return!1}).then(function(e){t(!e)},function(){e()})):t(!1)})};return t.renderSvg=function(i){return new Promise(function(e,t){function n(){r&&c(r)}var r,o=new Image;o.onload=function(){o.onload=null,o.onerror=null,n(),e(o)},o.onerror=function(){n(),t()},u(i).then(function(e){r=e,o.src=r},t)})},t}(window);return function(o,i,c){"use strict";var u={};u.drawDocument=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),n=o.parseOptionalParameters(t),r=e.documentElement||e;return c.rasterize(r,n.canvas,(e=(t=n).canvas,r=t.options,n=e?e.width:300,e=e?e.height:200,e={width:void 0!==r.width?r.width:n,height:void 0!==r.height?r.height:e},(t=o.clone(t.options)).width=e.width,t.height=e.height,t))};u.drawHTML=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return function(e,t,n){e=i.parseHTML(e);return u.drawDocument(e,t,n)}(e,t.canvas,t.options)};function n(t,n,r){return i.loadDocument(t,r).then(function(e){e=function(e,t,n){var r=document.implementation.createHTMLDocument("");r.replaceChild(e.documentElement,r.documentElement);e=n?o.clone(n):{};return n.baseUrl||(e.baseUrl=t),{document:r,options:e}}(e,t,r);return u.drawDocument(e.document,n,e.options)})}return u.drawURL=function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1),t=o.parseOptionalParameters(t);return n(e,t.canvas,t.options)},u}(o,i,function(o,i,c,r,e,u){"use strict";function a(t){return e.renderSvg(t).then(function(e){return{image:e,svg:t}},function(e){throw l(e)})}function s(e,t,n){return r.drawDocumentAsSvg(e,n).then(a).then(function(e){return t&&function(e,t){try{t.getContext("2d").drawImage(e,0,0)}catch(e){throw l(e)}}(e.image,t),e})}var t={},l=function(e){return{message:"Error rendering page",originalError:e}};return t.rasterize=function(e,n,r){var t=o.clone(r);return t.inlineScripts=!0===r.executeJs,u.inlineReferences(e,t).then(function(t){return r.executeJs?i.executeJavascript(e,r).then(function(e){var t=e.document;return c.persistInputValues(t),{document:t,errors:e.errors,cleanUp:e.cleanUp}}).then(function(e){return{element:e.document.documentElement,errors:t.concat(e.errors),cleanUp:e.cleanUp}}):{element:e,errors:t,cleanUp:function(){}}}).then(function(t){return s(t.element,n,r).then(function(e){return t.cleanUp(),{image:e.image,svg:e.svg,errors:t.errors}})})},t}(o,i,e,function(c,r,u){"use strict";function a(t){var e=Object.keys(t);return e.length?" "+e.map(function(e){return e+'="'+t[e]+'"'}).join(" "):""}function o(e,t,n){var r,o,i=u.serializeToString(e);return c.validateXHTML(i),(e=(r=t,o=Math.round(r.viewportWidth),e=Math.round(r.viewportHeight),{x:-r.left,y:-r.top,width:o,height:e})).style=(e.style||"")+"float: left;",e.externalResourcesRequired=!0,'"}var i={};return i.getSvgForDocument=function(e,t,n){return r.rewriteTagNameSelectorsToLowerCase(e),o(e,t,n)},i.drawDocumentAsSvg=function(t,n){return["hover","active","focus","target"].forEach(function(e){n[e]&&r.fakeUserAction(t,n[e],e)}),c.calculateDocumentContentSize(t,n).then(function(e){return i.getSvgForDocument(t,e,n.zoom)})},i}(i,e,t),n,r))});
+// the XRWG (XR WordGraph)is mentioned in the spec
//
// it collects metadata-keys ('foo' e.g.), names and tags across 3D scene-nodes (.userData.foo e.g.)
@@ -701,18 +696,19 @@ XRWG.cleankey = (word) => String(word).replace(/[^0-9\.a-zA-Z_]/g,'')
XRWG.get = (v,k) => XRWG.find( (x) => x[ k || 'word'] == v )
XRWG.match = (str,types,level) => {
- level = level || 1000
+ if( XRWG.length == 0 ) XRWG.generate(xrf)
+ level = level == undefined ? 1000 : level
types = types || []
let res = XRWG.filter( (n) => {
types.map( (type) => n[type] ? n = false : false )
return n
})
str = str.toLowerCase()
- if( level <10 ) res = res.filter( (n) => n.key == str )
- if( level <20 ) res = res.filter( (n) => n.word == str || n.key == str )
- if( level <30 ) res = res.filter( (n) => n.word.match(str) || n.key == str )
- if( level <40 ) res = res.filter( (n) => n.word.match(str) || n.key == str || String(n.value||'').match(str) )
- if( level <1001 ) res = res.filter( (n) => n.word.match(str) != null || n.key.match(str) != null || String(n.value||'').match(str) != null)
+ if( level <10 ) res = res.filter( (n) => n.key == str )
+ if( level >=10 ) res = res.filter( (n) => n.word == str || n.key == str )
+ if( level >30 ) res = res.filter( (n) => n.word.match(str) || n.key == str )
+ if( level >40 ) res = res.filter( (n) => n.word.match(str) || n.key == str || String(n.value||'').match(str) )
+ if( level >999 ) res = res.filter( (n) => n.word.match(str) != null || n.key.match(str) != null || String(n.value||'').match(str) != null)
return res
}
@@ -731,7 +727,7 @@ XRWG.generate = (opts) => {
node = { word: XRWG.cleankey(key), key, nodes:[spatialNode] }
if( spatialNode.userData[key] ) node.value = spatialNode.userData[key]
node[type] = true
- xrf.emit('XRWG',node)
+ xrf.emit('XRWGnode',node)
XRWG.push( node )
}
}
@@ -753,6 +749,7 @@ XRWG.generate = (opts) => {
// sort by n
XRWG.sort( (a,b) => a.nodes.length - b.nodes.length )
XRWG = XRWG.reverse() // the cleankey/get functions e.g. will persist
+ xrf.emit('XRWG',XRWG)
}
// the hashbus (QueryString eventBus) is mentioned in the spec
//
@@ -782,7 +779,7 @@ pub.mesh = (mesh,model) => { // evaluate embedded fragments (metadata) insid
for( let k in frag ){
let opts = {frag, mesh, model, camera: xrf.camera, scene: model.scene, renderer: xrf.renderer, THREE: xrf.THREE, hashbus: xrf.hashbus }
mesh.userData.XRF = frag // allow fragment impl to access XRF obj already
- xrf.emit('mesh',opts)
+ xrf.emit('frag2mesh',opts)
.then( () => pub.fragment(k,opts) )
}
}
@@ -791,12 +788,14 @@ pub.mesh = (mesh,model) => { // evaluate embedded fragments (metadata) insid
pub.fragment = (k, opts ) => { // evaluate one fragment
let frag = opts.frag[k];
+ if( frag.is( xrf.XRF.PV_EXECUTE ) ) pub.XRWG({...opts,frag})
+
// call native function (xrf/env.js e.g.), or pass it to user decorator
xrf.emit(k,opts)
.then( () => {
let func = xrf.frag[k] || function(){}
- if( xrf[k] ) xrf[k]( func, frag, opts)
- else func( frag, opts)
+ if( typeof xrf[k] == 'function' ) xrf[k]( func, frag, opts)
+ else func( frag, opts)
})
}
@@ -859,9 +858,9 @@ xrf.patchRenderer = function(opts){
renderer.render = ((render) => function(scene,camera){
// update clock
let time = xrf.clock.getDelta()
- // allow entities to do stuff during render (onBeforeRender and onAfterRender don't always fire)
- xrf.emit('render',{scene,camera,time}) // allow fragments to do something at renderframe
+ xrf.emit('render',{scene,camera,time,render}) // allow fragments to do something at renderframe
render(scene,camera)
+ xrf.emit('renderPost',{scene,camera,time,render,renderer}) // allow fragments to do something after renderframe
})(renderer.render.bind(renderer))
}
@@ -909,18 +908,15 @@ xrf.reset = () => {
return true
};
let nodes = []
- xrf.scene.traverse( (n) => n.audio ? n.audio.remove() : false )
- xrf.scene.traverse( (child) => child.isXRF ? nodes.push(child) : false )
+ xrf.scene.traverse( (n) => n.audio && (n.audio.remove()) )
+ xrf.scene.traverse( (child) => child.isXRF && (nodes.push(child)) )
nodes.map( disposeObject ) // leave non-XRF objects intact
- xrf.interactive = xrf.InteractiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
+ xrf.interactive = xrf.interactiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
xrf.add( xrf.interactive )
xrf.layers = 0
xrf.emit('reset',{})
// remove mixers
- xrf.mixers.map( (m) => {
- m.stop()
- delete m
- })
+ xrf.mixers.map( (m) => m.stop())
xrf.mixers = []
}
@@ -937,9 +933,565 @@ xrf.add = (object) => {
object.isXRF = true // mark for easy deletion when replacing scene
xrf.scene.add(object)
}
+
+xrf.hasNoMaterial = (mesh) => {
+ const hasTexture = mesh.material && mesh.material.map
+ const hasMaterialName = mesh.material && mesh.material.name.length > 0
+ return mesh.geometry && !hasMaterialName && !hasTexture
+}
+xrf.navigator = {}
+
+xrf.navigator.to = (url,flags,loader,data) => {
+ if( !url ) throw 'xrf.navigator.to(..) no url given'
+
+ let hashbus = xrf.hashbus
+ xrf.emit('navigate', {url,loader,data})
+
+ return new Promise( (resolve,reject) => {
+ let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
+ if( !file || (!data && xrf.model.file == file) ){ // we're already loaded
+ hashbus.pub( url, xrf.model, flags ) // and eval local URI XR fragments
+ xrf.navigator.updateHash(hash)
+ return resolve(xrf.model)
+ }
+
+ if( xrf.model && xrf.model.scene ) xrf.model.scene.visible = false
+ if( !loader ){
+ const Loader = xrf.loaders[ext]
+ if( !Loader ) throw 'xrfragment: no loader passed to xrfragment for extension .'+ext
+ loader = loader || new Loader().setPath( dir )
+ }
+
+ // force relative path
+ if( dir ) dir = dir[0] == '.' ? dir : `.${dir}`
+ url = url.replace(dir,"")
+ loader = loader || new Loader().setPath( dir )
+ const onLoad = (model) => {
+ xrf.reset() // clear xrf objects from scene
+ model.file = file
+ // only change url when loading *another* file
+ if( xrf.model ) xrf.navigator.pushState( `${dir}${file}`, hash )
+ xrf.model = model
+ // spec: 1. generate the XRWG
+ xrf.XRWG.generate({model,scene:model.scene})
+ // spec: 1. execute the default predefined view '#' (if exist) (https://xrfragment.org/#predefined_view)
+ xrf.frag.defaultPredefinedViews({model,scene:model.scene})
+ // spec: 2. init metadata
+ // spec: predefined view(s) from URL (https://xrfragment.org/#predefined_view)
+ setTimeout( () => { // give external objects some slack
+ let frag = hashbus.pub( url, model) // and eval URI XR fragments
+ hashbus.pub.XRWG({model,scene:model.scene,frag})
+ },2000)
+ xrf.add( model.scene )
+ xrf.navigator.updateHash(hash)
+ xrf.emit('navigateLoaded',{url,model})
+ resolve(model)
+ }
+
+ if( data ) loader.parse(data, "", onLoad )
+ else loader.load(url, onLoad )
+ })
+}
+
+xrf.navigator.init = () => {
+ if( xrf.navigator.init.inited ) return
+
+ window.addEventListener('popstate', function (event){
+ xrf.navigator.to( document.location.search.substr(1) + document.location.hash )
+ })
+
+ window.addEventListener('hashchange', function (e){
+ xrf.emit('hash', {hash: document.location.hash })
+ })
+
+ // this allows selectionlines to be updated according to the camera (renderloop)
+ xrf.focusLine = new xrf.THREE.Group()
+ xrf.focusLine.material = new xrf.THREE.LineDashedMaterial({color:0xFF00FF,linewidth:3, scale: 1, dashSize: 0.2, gapSize: 0.1,opacity:0.3, transparent:true})
+ xrf.focusLine.isXRF = true
+ xrf.focusLine.position.set(0,0,-0.5);
+ xrf.focusLine.points = []
+ xrf.focusLine.lines = []
+ xrf.camera.add(xrf.focusLine)
+
+ xrf.navigator.init.inited = true
+}
+
+xrf.navigator.updateHash = (hash,opts) => {
+ if( hash.replace(/^#/,'') == document.location.hash.substr(1) || hash.match(/\|/) ) return // skip unnecesary pushState triggers
+ console.log(`URL: ${document.location.search.substr(1)}#${hash}`)
+ document.location.hash = hash
+ xrf.emit('hash', {...opts, hash: `#${hash}` })
+}
+
+xrf.navigator.pushState = (file,hash) => {
+ if( file == document.location.search.substr(1) ) return // page is in its default state
+ window.history.pushState({},`${file}#${hash}`, document.location.pathname + `?${file}#${hash}` )
+ xrf.emit('pushState', {file, hash} )
+}
+xrf.addEventListener('env', (opts) => {
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ if( frag.env && !scene.environment ){
+ //let env = scene.getObjectByName(frag.env.string)
+ //if( !env ) env = xrf.scene.getObjectByName(frag.env.string) // repurpose from parent scene
+ //if( !env ) return console.warn("xrf.env "+frag.env.string+" not found")
+ //env.material.map.mapping = THREE.EquirectangularReflectionMapping;
+ //scene.environment = env.material.map
+ //scene.texture = env.material.map
+ // renderer.toneMapping = THREE.ACESFilmicToneMapping;
+ // renderer.toneMappingExposure = 2;
+ console.log(` └ applied image '${frag.env.string}' as environment map`)
+ }
+
+})
+/**
+ *
+ * navigation, portals & mutations
+ *
+ * | fragment | type | scope | example value |
+ * |`href`| string (uri or predefined view) | 🔒 |`#pos=1,1,0`
`#pos=1,1,0&rot=90,0,0`
`#pos=pyramid`
`#pos=lastvisit|pyramid`
`://somefile.gltf#pos=1,1,0`
|
+ *
+ * [[» example implementation|https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/three/xrf/href.js]]
+ * [[» example 3D asset|https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/href.gltf#L192]]
+ * [[» discussion|https://github.com/coderofsalvation/xrfragment/issues/1]]
+ *
+ * [img[xrfragment.jpg]]
+ *
+ *
+ * !!!spec 1.0
+ *
+ * 1. an ''external''- or ''file URI'' fully replaces the current scene and assumes `pos=0,0,0&rot=0,0,0` by default (unless specified)
+ *
+ * 2. navigation should not happen when queries (`q=`) are present in local url: queries will apply (`pos=`, `rot=` e.g.) to the targeted object(s) instead.
+ *
+ * 3. navigation should not happen ''immediately'' when user is more than 2 meter away from the portal/object containing the href (to prevent accidental navigation e.g.)
+ *
+ * 4. URL navigation should always be reflected in the client (in case of javascript: see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/src/3rd/three/navigator.js]] for an example navigator).
+ *
+ * 5. In XR mode, the navigator back/forward-buttons should be always visible (using a wearable e.g., see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/example/aframe/sandbox/index.html#L26-L29]] for an example wearable)
+ *
+ * [img[navigation.png]]
+ *
+ */
+
+xrf.frag.href = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+
+ if( mesh.userData.XRF.href.exec ) return // mesh already initialized
+
+ let click = mesh.userData.XRF.href.exec = (e) => {
+
+ let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
+ xrf
+ .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree
+ .then( () => {
+ const flags = v.string[0] == '#' ? xrf.XRF.PV_OVERRIDE : undefined
+ let toFrag = xrf.URI.parse( v.string, xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.METADATA )
+ // always commit current location (keep a trail of last positions before we navigate)
+ if( !e.nocommit && !document.location.hash.match(lastPos) ) xrf.navigator.to(`#${lastPos}`)
+ xrf.navigator.to(v.string) // let's surf to HREF!
+ })
+ .catch( console.error )
+ }
+
+ let selected = mesh.userData.XRF.href.selected = (state) => () => {
+ if( mesh.selected == state ) return // nothing changed
+ xrf.interactive.objects.map( (o) => {
+ let newState = o.name == mesh.name ? state : false
+ if( o.material ){
+ if( o.material.uniforms ) o.material.uniforms.selected.value = newState
+ //if( o.material.emissive ) o.material.emissive.r = o.material.emissive.g = o.material.emissive.b = newState ? 2.0 : 1.0
+ if( o.material.emissive ){
+ if( !o.material.emissive.original ) o.material.emissive.original = o.material.emissive.clone()
+ o.material.emissive.r = o.material.emissive.g = o.material.emissive.b =
+ newState ? o.material.emissive.original.r + 0.5 : o.material.emissive.original.r
+ }
+ }
+ })
+ // update mouse cursor
+ if( !renderer.domElement.lastCursor )
+ renderer.domElement.lastCursor = renderer.domElement.style.cursor
+ renderer.domElement.style.cursor = state ? 'pointer' : renderer.domElement.lastCursor
+
+ xrf
+ .emit('href',{selected:state,mesh,xrf:v}) // let all listeners agree
+ .then( () => mesh.selected = state )
+ }
+
+ mesh.addEventListener('click', click )
+ mesh.addEventListener('mousemove', selected(true) )
+ mesh.addEventListener('mouseenter', selected(true) )
+ mesh.addEventListener('mouseleave', selected(false) )
+
+ if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
+
+ // lazy add mesh (because we're inside a recursive traverse)
+ setTimeout( (mesh) => {
+ xrf.interactive.add(mesh)
+ xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
+ }, 0, mesh )
+}
+
+/**
+ * > above solutions were abducted from [[this|https://i.imgur.com/E3En0gJ.png]] and [[this|https://i.imgur.com/lpnTz3A.png]] survey result
+ *
+ * !!!Demo
+ *
+ * <$videojs controls="controls" aspectratio="16:9" preload="auto" poster="" fluid="fluid" class="vjs-big-play-centered">
+ *
+ * $videojs>
+ *
+ * > capture of aframe/sandbox
+ */
+xrf.frag.pos = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+
+
+ // spec: indirect coordinate using objectname: https://xrfragment.org/#navigating%203D
+ if( v.x == undefined ){
+ let obj = scene.getObjectByName(v.string)
+ if( !obj ) return
+ let pos = obj.position.clone()
+ obj.getWorldPosition(pos)
+ camera.position.copy(pos)
+ }else{
+ // spec: direct coordinate: https://xrfragment.org/#navigating%203D
+ camera.position.x = v.x
+ camera.position.y = v.y
+ camera.position.z = v.z
+ }
+}
+xrf.frag.rot = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ console.log(" └ setting camera rotation to "+v.string)
+ camera.rotation.set(
+ v.x * Math.PI / 180,
+ v.y * Math.PI / 180,
+ v.z * Math.PI / 180
+ )
+ camera.updateMatrixWorld()
+}
+// *TODO* use webgl instancing
+
+xrf.frag.src = function(v, opts){
+ opts.embedded = v // indicate embedded XR fragment
+ let { mesh, model, camera, scene, renderer, THREE, hashbus, frag} = opts
+
+ let url = v.string
+ let srcFrag = opts.srcFrag = xrfragment.URI.parse(url)
+ opts.isLocal = v.string[0] == '#'
+
+ if( opts.isLocal ){
+ xrf.frag.src.localSRC(url,srcFrag,opts) // local
+ }else xrf.frag.src.externalSRC(url,srcFrag,opts) // external file
+}
+
+xrf.frag.src.addModel = (model,url,frag,opts) => {
+ let {mesh} = opts
+ let scene = model.scene
+ xrf.frag.src.filterScene(scene,{...opts,frag}) // filter scene
+ if( mesh.material ) mesh.material.visible = false // hide placeholder object
+ //enableSourcePortation(scene)
+ if( xrf.frag.src.renderAsPortal(mesh) ){
+ // only add remote objects, because
+ // local scene-objects are already added to scene
+ xrf.portalNonEuclidian({...opts,model,scene:model.scene})
+ if( !opts.isLocal && !mesh.portal.isLens ) xrf.scene.add(scene)
+ return
+ }else{
+ xrf.frag.src.scale( scene, opts, url ) // scale scene
+ mesh.add(scene)
+ }
+ // flag everything isSRC & isXRF
+ mesh.traverse( (n) => { n.isSRC = n.isXRF = n[ opts.isLocal ? 'isSRCLocal' : 'isSRCExternal' ] = true })
+ xrf.emit('parseModel', {...opts, scene, model})
+}
+
+xrf.frag.src.renderAsPortal = (mesh) => {
+ // *TODO* should support better isFlat(mesh) check
+ const isPlane = mesh.geometry && mesh.geometry.attributes.uv && mesh.geometry.attributes.uv.count == 4
+ return xrf.hasNoMaterial(mesh) && isPlane
+}
+
+xrf.frag.src.enableSourcePortation = (src) => {
+ // show sourceportation clickable plane
+ if( srcFrag.href || v.string[0] == '#' ) return
+ let scale = new THREE.Vector3()
+ let size = new THREE.Vector3()
+ mesh.getWorldScale(scale)
+ new THREE.Box3().setFromObject(src).getSize(size)
+ const geo = new THREE.SphereGeometry( Math.max(size.x, size.y, size.z) / scale.x, 10, 10 )
+ const mat = new THREE.MeshBasicMaterial()
+ mat.transparent = true
+ mat.roughness = 0.05
+ mat.metalness = 1
+ mat.opacity = 0
+ const cube = new THREE.Mesh( geo, mat )
+ console.log("todo: sourceportate")
+ return xrf.frag.src
+}
+
+xrf.frag.src.externalSRC = (url,frag,opts) => {
+ fetch(url, { method: 'HEAD' })
+ .then( (res) => {
+ console.log(`loading src ${url}`)
+ let mimetype = res.headers.get('Content-type')
+ if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
+ //if( url.match(/\.(fbx|stl|obj)$/) ) mimetype =
+ opts = { ...opts, frag, mimetype }
+ return xrf.frag.src.type[ mimetype ] ? xrf.frag.src.type[ mimetype ](url,opts) : xrf.frag.src.type.unknown(url,opts)
+ })
+ .then( (model) => {
+ if( model && model.scene ) xrf.frag.src.addModel(model, url, frag, opts )
+ })
+ .finally( () => { })
+ .catch( console.error )
+ return xrf.frag.src
+}
+
+xrf.frag.src.localSRC = (url,frag,opts) => {
+ let {model,scene} = opts
+ let _model = {
+ animations: model.animations,
+ scene: scene.clone()
+ }
+ _model.scenes = [_model.scene]
+ xrf.frag.src.addModel(_model,url,frag, opts) // current file
+}
+
+// scale embedded XR fragments https://xrfragment.org/#scaling%20of%20instanced%20objects
+xrf.frag.src.scale = function(scene, opts, url){
+ let { mesh, model, camera, renderer, THREE} = opts
+
+ // remove invisible objects (hidden by selectors) which might corrupt boundingbox size-detection
+ let cleanScene = scene.clone()
+ if( !cleanScene ) debugger
+ let remove = []
+ const notVisible = (n) => !n.visible || (n.material && !n.material.visible)
+ cleanScene.traverse( (n) => notVisible(n) && n.children.length == 0 && (remove.push(n)) )
+ remove.map( (n) => n.removeFromParent() )
+
+ let restrictTo3DBoundingBox = mesh.geometry
+ if( restrictTo3DBoundingBox ){
+ // spec 3 of https://xrfragment.org/#src
+ // spec 1 of https://xrfragment.org/#scaling%20of%20instanced%20objects
+ // normalize instanced objectsize to boundingbox
+ let sizeFrom = new THREE.Vector3()
+ let sizeTo = new THREE.Vector3()
+ let empty = new THREE.Object3D()
+ new THREE.Box3().setFromObject(mesh).getSize(sizeTo)
+ new THREE.Box3().setFromObject(cleanScene).getSize(sizeFrom)
+ let ratio = sizeFrom.divide(sizeTo)
+ scene.scale.multiplyScalar( 1.0 / Math.max(ratio.x, ratio.y, ratio.z));
+ }else{
+ // spec 4 of https://xrfragment.org/#src
+ // spec 2 of https://xrfragment.org/#scaling%20of%20instanced%20objects
+ scene.scale.multiply( mesh.scale )
+ }
+ scene.isXRF = model.scene.isSRC = true
+}
+
+xrf.frag.src.filterScene = (scene,opts) => {
+ let { mesh, model, camera, renderer, THREE, hashbus, frag} = opts
+
+ xrf.filter.scene({scene,frag,reparent:true})
+
+ scene.traverse( (m) => {
+ if( m.userData && (m.userData.src || m.userData.href) ) return ; // prevent infinite recursion
+ hashbus.pub.mesh(m,{scene,recursive:true}) // cool idea: recursion-depth based distance between face & src
+ })
+ return scene
+}
+
+/*
+ * replace the src-mesh with the contents of the src
+ */
+
+xrf.frag.src.type = {}
+
+/*
+ * mimetype: unknown
+ */
+
+xrf.frag.src.type['unknown'] = function( url, opts ){
+ return new Promise( (resolve,reject) => {
+ reject(`${url} mimetype '${opts.mimetype}' not found or supported (yet)`)
+ })
+}
+xrf.frag.t = function(v, opts){
+ let { frag, mesh, model, camera, scene, renderer, THREE} = opts
+ if( !model.mixer ) return
+ if( !model.animations || model.animations[0] == undefined ) return console.warn('no animation in scene')
+
+ xrf.mixers.map ( (mixer) => {
+
+ mixer.t = v
+
+ // update speed
+ mixer.timeScale = mixer.loop.speed = v.x
+ mixer.loop.speedAbs = Math.abs(v.x)
+
+ if( v.y != undefined || v.z != undefined ) mixer.updateLoop( v )
+
+ // play animations
+ mixer.play( v )
+ })
+}
+
+xrf.frag.t.default = {
+ x:0, // (play from) offset (in seconds)
+ y:0 // optional: (stop at) offset (in seconds)
+}
+
+// setup animation mixer for global scene & src scenes
+xrf.addEventListener('parseModel', (opts) => {
+ let {model} = opts
+ let mixer = model.mixer = new xrf.THREE.AnimationMixer(model.scene)
+ mixer.model = model
+ mixer.loop = {timeStart:0,timeStop:0}
+ mixer.i = xrf.mixers.length
+ mixer.actions = []
+
+ model.animations.map( (anim) => {
+ anim.optimize()
+ console.log("action: "+anim.name)
+ mixer.actions.push( mixer.clipAction( anim, model.scene ) )
+ })
+
+
+ mixer.checkZombies = (animations) => {
+ if( mixer.zombieCheck ) return // fire only once
+ animations.map( (anim) => {
+ // collect zombie animations and warn user
+ let zombies = anim.tracks.map( (t) => {
+ let name = t.name.replace(/\..*/,'')
+ let obj = model.scene.getObjectByName(name)
+ return !model.scene.getObjectByName(name) ? {anim:anim.name,obj:name} : undefined
+ })
+ if( zombies.length > 0 && mixer.i == 0 ){ // only warn for zombies in main scene (because src-scenes might be filtered anyways)
+ zombies
+ .filter( (z) => z ) // filter out undefined
+ .map( (z) => console.warn(`gltf: object '${z.obj}' not found (anim: '${z.anim}'`) )
+ console.warn(`TIP: remove dots in objectnames in blender (which adds dots when duplicating)`)
+ }
+ })
+ mixer.zombieCheck = true
+ }
+
+ mixer.play = (t) => {
+ mixer.isPlaying = t.x != 0
+ mixer.updateLoop(t)
+ xrf.emit( mixer.isPlaying === false ? 'stop' : 'play',{isPlaying: mixer.isPlaying})
+ }
+
+ mixer.stop = () => {
+ mixer.play(false)
+ }
+
+ mixer.updateLoop = (t) => {
+ mixer.loop.timeStart = t.y != undefined ? t.y : mixer.loop.timeStart
+ mixer.loop.timeStop = t.z != undefined ? t.z : mixer.loop.timeStop
+ mixer.actions.map( (action) => {
+ if( mixer.loop.timeStart != undefined ){
+ action.time = mixer.loop.timeStart
+ action.setLoop( THREE.LoopOnce, )
+ action.timeScale = mixer.timeScale
+ action.enabled = true
+ if( t.x != 0 ){
+ action.play()
+ }
+ }
+ })
+ mixer.setTime(mixer.loop.timeStart)
+ mixer.time = Math.abs( mixer.loop.timeStart )
+ mixer.update(0)
+ mixer.checkZombies( model.animations)
+ }
+
+ // update loop when needed
+ if( !mixer.update.patched ){
+ let update = mixer.update
+ mixer.update = function(time){
+ mixer.time = Math.abs(mixer.time)
+ if( time == 0 ) return update.call(this,time)
+
+ // loop jump
+ if( mixer.loop.speed > 0.0 && (mixer.loop.timeStop > 0 && mixer.time > mixer.loop.timeStop) ){
+ setTimeout( (time,anims) => mixer.updateLoop(time), 0, mixer.loop.timeStart ) // prevent recursion
+ }
+ return update.call( this, time )
+ }
+ mixer.update.patched = true
+ }
+
+ // calculate total duration/frame based on longest animation
+ mixer.duration = 0
+ if( model.animations.length ){
+ model.animations.map( (a) => mixer.duration = ( a.duration > mixer.duration ) ? a.duration : mixer.duration )
+ }
+
+ xrf.mixers.push(mixer)
+})
+
+if( document.location.hash.match(/t=/) ){
+ let url = document.location.href
+ let playAfterUserGesture = () => {
+ xrf.hashbus.pub(url) // re-post t fragment on the hashbus again
+ window.removeEventListener('click',playAfterUserGesture)
+ window.removeEventListener('touchstart',playAfterUserGesture)
+ }
+ window.addEventListener('click', playAfterUserGesture )
+ window.addEventListener('touchstart', playAfterUserGesture )
+}
+
+xrf.addEventListener('render', (opts) => {
+ let model = xrf.model
+ let {time} = opts
+ if( !model ) return
+ if( xrf.mixers.length ){
+ xrf.mixers.map( (m) => m.isPlaying && (m.update( time )) )
+
+ // update active camera in case selected by dynamicKey in URI
+ if( xrf.model.camera && model.mixer.isPlaying ){
+
+ let cam = xrf.camera.getCam()
+ // cam.fov = model.cameras[0].fov (why is blender not exporting radians?)
+ cam.far = model.cameras[0].far
+ cam.near = model.cameras[0].near
+
+ let rig = xrf.camera
+ rig.position.copy( model.cameras[0].position )
+ rig.position.y -= rig.offsetY // VR/AR compensate camera rig
+ //rig.rotation.copy( model.cameras[0].rotation )
+
+ rig.updateProjectionMatrix()
+ }
+ }
+})
+
+xrf.addEventListener('dynamicKey', (opts) => {
+ // select active camera if any
+ let {id,match,v} = opts
+ match.map( (w) => {
+ w.nodes.map( (node) => {
+ if( node.isCamera ){
+ console.log("setting camera to "+node.name)
+ xrf.model.camera = node
+ }
+ })
+ })
+})
+xrf.getCollisionMeshes = () => {
+ let meshes = []
+ xrf.scene.traverse( (n) => {
+ if( !n.userData.href && !n.userData.src && xrf.hasNoMaterial(n) ){
+ meshes.push(n)
+ }
+ })
+ return meshes
+}
// wrapper to survive in/outside modules
-xrf.InteractiveGroup = function(THREE,renderer,camera){
+xrf.interactiveGroup = function(THREE,renderer,camera){
let {
Group,
@@ -952,7 +1504,7 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
const _event = { type: '', data: _pointer };
let object = {selected:false}
- class InteractiveGroup extends Group {
+ class interactive extends Group {
constructor( renderer, camera ) {
@@ -1010,9 +1562,9 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
element.addEventListener( 'pointerup', onPointerEvent );
element.addEventListener( 'pointermove', onPointerEvent );
element.addEventListener( 'mousedown', onPointerEvent );
- element.addEventListener( 'mouseup', onPointerEvent );
element.addEventListener( 'mousemove', onPointerEvent );
element.addEventListener( 'click', onPointerEvent );
+ element.addEventListener( 'mouseup', onPointerEvent );
// WebXR Controller Events
// TODO: Dispatch pointerevents too
@@ -1077,582 +1629,121 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
}
- return new InteractiveGroup(renderer,camera)
+ return new interactive(renderer,camera)
}
-xrf.navigator = {}
-
-xrf.navigator.to = (url,flags,loader,data) => {
- if( !url ) throw 'xrf.navigator.to(..) no url given'
-
- let hashbus = xrf.hashbus
-
- return new Promise( (resolve,reject) => {
- let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
- if( !file || (!data && xrf.model.file == file) ){ // we're already loaded
- hashbus.pub( url, xrf.model, flags ) // and eval local URI XR fragments
- xrf.navigator.updateHash(hash)
- return resolve(xrf.model)
- }
-
- if( xrf.model && xrf.model.scene ) xrf.model.scene.visible = false
- if( !loader ){
- const Loader = xrf.loaders[ext]
- if( !Loader ) throw 'xrfragment: no loader passed to xrfragment for extension .'+ext
- loader = loader || new Loader().setPath( dir )
- }
-
- // force relative path
- if( dir ) dir = dir[0] == '.' ? dir : `.${dir}`
- url = url.replace(dir,"")
- loader = loader || new Loader().setPath( dir )
- const onLoad = (model) => {
- xrf.reset() // clear xrf objects from scene
- model.file = file
- // only change url when loading *another* file
- if( xrf.model ) xrf.navigator.pushState( `${dir}${file}`, hash )
- xrf.model = model
- // spec: 1. generate the XRWG
- xrf.XRWG.generate({model,scene:model.scene})
- // spec: 1. execute the default predefined view '#' (if exist) (https://xrfragment.org/#predefined_view)
- xrf.frag.defaultPredefinedViews({model,scene:model.scene})
- // spec: 2. init metadata
- // spec: predefined view(s) from URL (https://xrfragment.org/#predefined_view)
- setTimeout( () => { // give external objects some slack
- let frag = hashbus.pub( url, model) // and eval URI XR fragments
- hashbus.pub.XRWG({model,scene:model.scene,frag})
- console.dir(frag)
- },2000)
- xrf.add( model.scene )
- xrf.navigator.updateHash(hash)
- resolve(model)
- }
-
- if( data ) loader.parse(data, "", onLoad )
- else loader.load(url, onLoad )
- })
-}
-
-xrf.navigator.init = () => {
- if( xrf.navigator.init.inited ) return
-
- window.addEventListener('popstate', function (event){
- xrf.navigator.to( document.location.search.substr(1) + document.location.hash )
- })
-
- window.addEventListener('hashchange', function (e){
- xrf.emit('hash', {hash: document.location.hash })
- })
-
- // this allows selectionlines to be updated according to the camera (renderloop)
- xrf.focusLine = new xrf.THREE.Group()
- xrf.focusLine.material = new xrf.THREE.LineDashedMaterial({color:0xFF00FF,linewidth:3, scale: 1, dashSize: 0.2, gapSize: 0.1,opacity:0.3, transparent:true})
- xrf.focusLine.isXRF = true
- xrf.focusLine.position.set(0,0,-0.5);
- xrf.focusLine.points = []
- xrf.focusLine.lines = []
- xrf.camera.add(xrf.focusLine)
-
- xrf.navigator.init.inited = true
-}
-
-xrf.navigator.updateHash = (hash,opts) => {
- if( hash.replace(/^#/,'') == document.location.hash.substr(1) || hash.match(/\|/) ) return // skip unnecesary pushState triggers
- console.log(`URL: ${document.location.search.substr(1)}#${hash}`)
- document.location.hash = hash
- xrf.emit('hash', {...opts, hash: `#${hash}` })
-}
-
-xrf.navigator.pushState = (file,hash) => {
- if( file == document.location.search.substr(1) ) return // page is in its default state
- window.history.pushState({},`${file}#${hash}`, document.location.pathname + `?${file}#${hash}` )
- xrf.emit('pushState', {file, hash} )
-}
-xrf.addEventListener('env', (opts) => {
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- if( frag.env && !scene.environment ){
- let env = scene.getObjectByName(frag.env.string)
- if( !env ) env = xrf.scene.getObjectByName(frag.env.string) // repurpose from parent scene
- if( !env ) return console.warn("xrf.env "+frag.env.string+" not found")
- env.material.map.mapping = THREE.EquirectangularReflectionMapping;
- scene.environment = env.material.map
- //scene.texture = env.material.map
- renderer.toneMapping = THREE.ACESFilmicToneMapping;
- renderer.toneMappingExposure = 2;
- console.log(` └ applied image '${frag.env.string}' as environment map`)
- }
-
-})
-/**
- *
- * navigation, portals & mutations
- *
- * | fragment | type | scope | example value |
- * |`href`| string (uri or predefined view) | 🔒 |`#pos=1,1,0`
`#pos=1,1,0&rot=90,0,0`
`#pos=pyramid`
`#pos=lastvisit|pyramid`
`://somefile.gltf#pos=1,1,0`
|
- *
- * [[» example implementation|https://github.com/coderofsalvation/xrfragment/blob/main/src/3rd/three/xrf/href.js]]
- * [[» example 3D asset|https://github.com/coderofsalvation/xrfragment/blob/main/example/assets/href.gltf#L192]]
- * [[» discussion|https://github.com/coderofsalvation/xrfragment/issues/1]]
- *
- * [img[xrfragment.jpg]]
- *
- *
- * !!!spec 1.0
- *
- * 1. an ''external''- or ''file URI'' fully replaces the current scene and assumes `pos=0,0,0&rot=0,0,0` by default (unless specified)
- *
- * 2. navigation should not happen when queries (`q=`) are present in local url: queries will apply (`pos=`, `rot=` e.g.) to the targeted object(s) instead.
- *
- * 3. navigation should not happen ''immediately'' when user is more than 2 meter away from the portal/object containing the href (to prevent accidental navigation e.g.)
- *
- * 4. URL navigation should always be reflected in the client (in case of javascript: see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/src/3rd/three/navigator.js]] for an example navigator).
- *
- * 5. In XR mode, the navigator back/forward-buttons should be always visible (using a wearable e.g., see [[here|https://github.com/coderofsalvation/xrfragment/blob/dev/example/aframe/sandbox/index.html#L26-L29]] for an example wearable)
- *
- * [img[navigation.png]]
- *
+/*
+ * TODO: refactor/fix this (queries are being refactored to filters)
*/
-xrf.frag.href = function(v, opts){
- opts.embedded = v // indicate embedded XR fragment
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
-
- if( mesh.userData.XRF.href.exec ) return // mesh already initialized
-
- if( mesh.material ) mesh.material = mesh.material.clone() // we need this so we can individually highlight meshes
-
- let click = mesh.userData.XRF.href.exec = (e) => {
-
- let isLocal = v.string[0] == '#'
- let lastPos = `pos=${camera.position.x.toFixed(2)},${camera.position.y.toFixed(2)},${camera.position.z.toFixed(2)}`
-
- xrf
- .emit('href',{click:true,mesh,xrf:v}) // let all listeners agree
- .then( () => {
- const flags = v.string[0] == '#' ? xrf.XRF.PV_OVERRIDE : undefined
- let toFrag = xrf.URI.parse( v.string, xrf.XRF.NAVIGATOR | xrf.XRF.PV_OVERRIDE | xrf.XRF.METADATA )
- // always keep a trail of last positions before we navigate
- if( !document.location.hash.match(lastPos) ) xrf.navigator.to(`#${lastPos}`)
- xrf.navigator.to(v.string) // let's surf to HREF!
- })
- .catch( console.error )
- }
-
- let selected = mesh.userData.XRF.href.selected = (state) => () => {
- if( mesh.selected == state ) return // nothing changed
- xrf.interactive.objects.map( (o) => {
- let newState = o.name == mesh.name ? state : false
- if( o.material ){
- if( o.material.uniforms ) o.material.uniforms.selected.value = newState
- if( o.material.emissive ) o.material.emissive.r = o.material.emissive.g = o.material.emissive.b = newState ? 2.0 : 1.0
- }
- })
- // update mouse cursor
- if( !renderer.domElement.lastCursor )
- renderer.domElement.lastCursor = renderer.domElement.style.cursor
- renderer.domElement.style.cursor = state ? 'pointer' : renderer.domElement.lastCursor
-
- xrf
- .emit('href',{selected:state,mesh,xrf:v}) // let all listeners agree
- .then( () => mesh.selected = state )
- }
-
- mesh.addEventListener('click', click )
- mesh.addEventListener('mousemove', selected(true) )
- mesh.addEventListener('mouseleave', selected(false) )
-
- // lazy add mesh (because we're inside a recursive traverse)
- setTimeout( (mesh) => {
- xrf.interactive.add(mesh)
- xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
- }, 0, mesh )
-}
-
-/**
- * > above solutions were abducted from [[this|https://i.imgur.com/E3En0gJ.png]] and [[this|https://i.imgur.com/lpnTz3A.png]] survey result
- *
- * !!!Demo
- *
- * <$videojs controls="controls" aspectratio="16:9" preload="auto" poster="" fluid="fluid" class="vjs-big-play-centered">
- *
- * $videojs>
- *
- * > capture of aframe/sandbox
- */
-xrf.frag.pos = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- camera.position.x = v.x
- camera.position.y = v.y
- camera.position.z = v.z
-}
-// spec: https://xrfragment.org/#queries
-
-xrf.frag.q = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- console.log(" └ running query ")
- let qobjs = Object.keys(v.query)
-
- // convience function for other fragments (which apply to the query)
- frag.q.getObjects = () => {
- let objs = []
- scene.traverse( (o) => {
- for ( let name in v.query ) {
- let qobj = v.query[name];
- if( qobj.tag && o.userData.tag && xrf.hasTag(name,o.userData.tag) ) objs.push(o)
- else if( qobj.id && o.name == name ) objs.push(o)
- }
- })
- return objs.filter( (o) => o ) // return and filter out empty
- .map( (o) => {
- if( !o.positionOriginal ) o.positionOriginal = o.position.clone()
- return o
- })
- }
- xrf.frag.q.filter(scene,frag) // spec : https://xrfragment.org/#queries
-}
-
-xrf.frag.q.filter = function(scene,frag){
- // spec: https://xrfragment.org/#queries
- let q = frag.q.query
- scene.traverse( (mesh) => {
- for ( let i in q ) {
- let isMeshId = q[i].id != undefined
- let isMeshProperty = q[i].rules != undefined && q[i].rules.length && !isMeshId
- if( q[i].root && mesh.isSRC ) continue; // ignore nested object for root-items (queryseletor '/foo' e.g.)
- if( isMeshId &&
- (i == mesh.name || xrf.hasTag(i,mesh.userData.tag))) mesh.visible = q[i].id
- if( isMeshProperty && mesh.userData[i] ) mesh.visible = (new xrf.Query(frag.q.string)).testProperty(i,mesh.userData[i])
- }
- })
-}
-xrf.frag.rot = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- console.log(" └ setting camera rotation to "+v.string)
- camera.rotation.set(
- v.x * Math.PI / 180,
- v.y * Math.PI / 180,
- v.z * Math.PI / 180
- )
- camera.updateMatrixWorld()
-}
-// *TODO* use webgl instancing
-
-xrf.frag.src = function(v, opts){
-
- opts.embedded = v // indicate embedded XR fragment
- let { mesh, model, camera, scene, renderer, THREE, hashbus, frag} = opts
-
- let src;
- let url = v.string
- let vfrag = xrfragment.URI.parse(url)
- opts.isPlane = mesh.geometry && mesh.geometry.attributes.uv && mesh.geometry.attributes.uv.count == 4
-
- const addModel = (model,url,frag) => {
- let scene = model.scene
- src = xrf.frag.src.filterScene(scene,{...opts,frag})
- xrf.frag.src.scale( src, opts, url )
- xrf.frag.src.eval( src, opts, url )
- // allow 't'-fragment to setup separate animmixer
- xrf.emit('parseModel', {...opts, scene:src, model})
- enableSourcePortation(src)
- mesh.add(src)
- mesh.traverse( (n) => n.isSRC = n.isXRF = true )
- if( mesh.material ) mesh.material.visible = false
- }
-
- const enableSourcePortation = (src) => {
- if( vfrag.href || v.string[0] == '#' ) return
- let scale = new THREE.Vector3()
- let size = new THREE.Vector3()
- mesh.getWorldScale(scale)
- new THREE.Box3().setFromObject(src).getSize(size)
- const geo = new THREE.SphereGeometry( Math.max(size.x, size.y, size.z) / scale.x, 10, 10 )
- const mat = new THREE.MeshBasicMaterial()
- mat.transparent = true
- mat.roughness = 0.05
- mat.metalness = 1
- mat.opacity = 0
- const cube = new THREE.Mesh( geo, mat )
- console.log("todo: sourceportate")
- //mesh.add(cube)
- }
-
- const externalSRC = (url,frag,src) => {
- fetch(url, { method: 'HEAD' })
- .then( (res) => {
- console.log(`loading src ${url}`)
- let mimetype = res.headers.get('Content-type')
- if( url.replace(/#.*/,'').match(/\.(gltf|glb)$/) ) mimetype = 'gltf'
- //if( url.match(/\.(fbx|stl|obj)$/) ) mimetype =
- opts = { ...opts, src, frag, mimetype }
- return xrf.frag.src.type[ mimetype ] ? xrf.frag.src.type[ mimetype ](url,opts) : xrf.frag.src.type.unknown(url,opts)
- })
- .then( (model) => {
- if( model && model.scene ) addModel(model, url, frag )
- })
- .finally( () => { })
- .catch( console.error )
- }
-
- if( url[0] == "#" ){
- let modelClone = {...model, scene: model.scene.clone()}
- modelClone.scenes = [modelClone.scene]
- modelClone.animations = modelClone.animations.map( (a) => a.clone() )
- addModel(modelClone,url,vfrag) // current file
- }else externalSRC(url,vfrag) // external file
-}
-
-xrf.frag.src.eval = function(scene, opts, url){
- let { mesh, model, camera, renderer, THREE, hashbus} = opts
- if( url ){
- //let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
- //let frag = xrfragment.URI.parse(url)
- //// scale URI XR Fragments (queries) inside src-value
- //for( var i in frag ){
- // hashbus.pub.fragment(i, Object.assign(opts,{frag, model:{scene},scene}))
- //}
- //hashbus.pub( '#', {scene} ) // execute the default projection '#' (if exist)
- //hashbus.pub( url, {scene} ) // and eval URI XR fragments
- }
-}
-
-// scale embedded XR fragments https://xrfragment.org/#scaling%20of%20instanced%20objects
-xrf.frag.src.scale = function(scene, opts, url){
- let { mesh, model, camera, renderer, THREE} = opts
-
- let restrictTo3DBoundingBox = mesh.geometry
- if( restrictTo3DBoundingBox ){
- // spec 3 of https://xrfragment.org/#src
- // spec 1 of https://xrfragment.org/#scaling%20of%20instanced%20objects
- // normalize instanced objectsize to boundingbox
- let sizeFrom = new THREE.Vector3()
- let sizeTo = new THREE.Vector3()
-
- let empty = new THREE.Object3D()
-
-// *TODO* exclude invisible objects from boundingbox size-detection
-//
-// THREE.Box3.prototype.expandByObject = (function(expandByObject){
-// return function(object,precise){
-// return expandByObject.call(this, object.visible ? object : empty, precise)
-// }
-// })(THREE.Box3.prototype.expandByObject)
-
- new THREE.Box3().setFromObject(mesh).getSize(sizeTo)
- new THREE.Box3().setFromObject(scene).getSize(sizeFrom)
- let ratio = sizeFrom.divide(sizeTo)
- scene.scale.multiplyScalar( 1.0 / Math.max(ratio.x, ratio.y, ratio.z));
- // let factor = getMax(sizeTo) < getMax(sizeFrom) ? getMax(sizeTo) / getMax(sizeFrom) : getMax(sizeFrom) / getMax(sizeTo)
- // scene.scale.multiplyScalar( factor )
- }else{
- // spec 4 of https://xrfragment.org/#src
- // spec 2 of https://xrfragment.org/#scaling%20of%20instanced%20objects
- scene.scale.multiply( mesh.scale )
- }
- scene.isXRF = model.scene.isSRC = true
-}
-
-xrf.frag.src.filterScene = (scene,opts) => {
- let { mesh, model, camera, renderer, THREE, hashbus, frag} = opts
- let obj, src
- // cherrypicking of object(s)
- if( !frag.q ){
- src = new THREE.Group()
- if( Object.keys(frag).length > 0 ){
- for( var i in frag ){
- if( scene.getObjectByName(i) ){
- src.add( obj = scene.getObjectByName(i).clone(true) )
- }
- hashbus.pub.fragment(i, Object.assign(opts,{frag, model,scene}))
- }
- }
- if( src.children.length == 1 ) obj.position.set(0,0,0);
- }
-
- // filtering of objects using query
- if( frag.q ){
- src = scene
- xrf.frag.q.filter(src,frag)
- }
- src.traverse( (m) => {
- if( m.userData && (m.userData.src || m.userData.href) ) return ; // prevent infinite recursion
- hashbus.pub.mesh(m,{scene,recursive:true}) // cool idea: recursion-depth based distance between face & src
- })
- return src
-}
-
-/*
- * replace the src-mesh with the contents of the src
- */
-
-xrf.frag.src.type = {}
-
-/*
- * mimetype: unknown
- */
-
-xrf.frag.src.type['unknown'] = function( url, opts ){
- return new Promise( (resolve,reject) => {
- reject(`${url} mimetype '${opts.mimetype}' not found or supported (yet)`)
- })
-}
-xrf.frag.t = function(v, opts){
- let { frag, mesh, model, camera, scene, renderer, THREE} = opts
- if( !model.mixer ) return
- if( !model.animations || model.animations[0] == undefined ) return console.warn('no animation in scene')
-
- xrf.mixers.map ( (mixer) => {
- mixer.t = v
-
- // update speed
- mixer.timeScale = mixer.loop.speed = v.x
- mixer.loop.speedAbs = Math.abs(v.x)
-
- if( v.y != undefined || v.z != undefined ) mixer.updateLoop( v )
-
- // play animations
- mixer.play( v )
- })
-}
-
-xrf.frag.t.default = {
- x:0, // (play from) offset (in seconds)
- y:0 // optional: (stop at) offset (in seconds)
-}
-
-// setup animation mixer for global scene & src scenes
-xrf.addEventListener('parseModel', (opts) => {
- let {model} = opts
- let mixer = model.mixer = new xrf.THREE.AnimationMixer(model.scene)
- mixer.model = model
- mixer.loop = {}
- mixer.i = xrf.mixers.length
-
- model.animations.map( (anim) => {
- anim.action = mixer.clipAction( anim, model.scene )
- })
-
- mixer.checkZombies = (animations) => {
- if( mixer.zombieCheck ) return // fire only once
- animations.map( (anim) => {
- // collect zombie animations and warn user
- let zombies = anim.tracks.map( (t) => {
- let name = t.name.replace(/\..*/,'')
- return !model.scene.getObjectByName(name) ? {anim:anim.name,obj:t.name} : undefined
- })
- if( zombies.length > 0 ){
- zombies
- .filter( (z) => z ) // filter out undefined
- .map( (z) => console.warn(`gltf: object '${z.obj}' not found (anim: '${z.anim}'`) )
- console.warn(`TIP: remove dots in objectnames in blender (which adds dots when duplicating)`)
- }
- })
- mixer.zombieCheck = true
- }
-
- mixer.play = (t) => {
- mixer.isPlaying = t.x != 0
- mixer.updateLoop(t)
- xrf.emit( mixer.isPlaying === false ? 'stop' : 'play',{isPlaying: mixer.isPlaying})
- }
-
- mixer.stop = () => {
- mixer.play(false)
- }
-
- mixer.updateLoop = (t) => {
- mixer.loop.timeStart = t.y != undefined ? t.y : mixer.loop.timeStart
- mixer.loop.timeStop = t.z != undefined ? t.z : mixer.loop.timeStop
- mixer.model.animations.map( (anim) => {
- if( mixer.loop.timeStart != undefined ){
- //if( anim.action ) delete anim.action
- //anim.action = mixer.clipAction( anim )
- anim.action.time = mixer.loop.timeStart
- anim.action.setLoop( THREE.LoopOnce, )
- anim.action.timeScale = mixer.timeScale
- anim.action.enabled = true
- if( t.x != 0 ) anim.action.play()
- }
- })
- mixer.setTime(mixer.loop.timeStart)
- mixer.time = Math.abs( mixer.loop.timeStart )
- mixer.update(0)
- mixer.checkZombies( model.animations)
- }
-
- // update loop when needed
- if( !mixer.update.patched ){
- let update = mixer.update
- mixer.update = function(time){
- mixer.time = Math.abs(mixer.time)
- if( time == 0 ) return update.call(this,time)
-
- // loop jump
- if( mixer.loop.speed > 0.0 && mixer.time > mixer.loop.timeStop ){
- setTimeout( (time,anims) => mixer.updateLoop(time), 0, mixer.loop.timeStart ) // prevent recursion
- }
- return update.call( this, time )
- }
- mixer.update.patched = true
- }
-
- // calculate total duration/frame based on longest animation
- mixer.duration = 0
- if( model.animations.length ){
- model.animations.map( (a) => mixer.duration = ( a.duration > mixer.duration ) ? a.duration : mixer.duration )
- }
-
- xrf.mixers.push(mixer)
-})
-
-if( document.location.hash.match(/t=/) ){
- let url = document.location.href
- let playAfterUserGesture = () => {
- xrf.hashbus.pub(url) // re-post t fragment on the hashbus again
- window.removeEventListener('click',playAfterUserGesture)
- window.removeEventListener('touchstart',playAfterUserGesture)
- }
- window.addEventListener('click', playAfterUserGesture )
- window.addEventListener('touchstart', playAfterUserGesture )
-}
-
-xrf.addEventListener('render', (opts) => {
- let model = xrf.model
- let {time} = opts
- if( !model ) return
- if( xrf.mixers.length ){
- xrf.mixers.map( (m) => m.isPlaying ? m.update( time ) : false )
-
- // update active camera in case selected by dynamicKey in URI
- if( xrf.model.camera && model.mixer.isPlaying ){
-
- let cam = xrf.camera.getCam()
- // cam.fov = model.cameras[0].fov (why is blender not exporting radians?)
- cam.far = model.cameras[0].far
- cam.near = model.cameras[0].near
-
- let rig = xrf.camera
- rig.position.copy( model.cameras[0].position )
- rig.position.y -= rig.offsetY // VR/AR compensate camera rig
- //rig.rotation.copy( model.cameras[0].rotation )
-
- rig.updateProjectionMatrix()
- }
- }
-})
xrf.addEventListener('dynamicKey', (opts) => {
- // select active camera if any
- let {id,match,v} = opts
- console.dir(opts)
- match.map( (w) => {
- w.nodes.map( (node) => {
- if( node.isCamera ){
- console.log("setting camera to "+node.name)
- xrf.model.camera = node
+ let {scene,id,match,v} = opts
+ if( v.filter ){
+ let frags = {}
+ frags[ v.filter.key ] = v
+ xrf.filter.scene({frag:frags,scene})
+ }
+})
+
+// spec: https://xrfragment.org/#filters
+xrf.filter = function(query, cb){
+ let result = []
+ if( !query ) return result
+ if( query[0] != '#' ) query = '#'+query
+ // *TODO* jquery like utility func
+ return result
+}
+
+xrf.filter.scene = function(opts){
+ let {scene,frag} = opts
+
+ xrf.filter
+ .sort(frag) // get (sorted) filters from XR Fragments
+ .process(frag,scene,opts) // show/hide things
+
+ scene.visible = true // always enable scene
+
+ return scene
+}
+
+xrf.filter.sort = function(frag){
+ // get all filters from XR Fragments
+ frag.filters = Object.values(frag)
+ .filter( (v) => v.filter ? v : null )
+ .sort( (a,b) => a.index > b.index )
+ return xrf.filter
+}
+
+xrf.filter.process = function(frag,scene,opts){
+ const cleanupKey = (k) => k.replace(/[-\*\/]/g,'')
+ let firstFilter = frag.filters.length ? frag.filters[0].filter.get() : false
+ const hasName = (m,name,filter) => m.name == name
+ const hasNameOrTag = (m,name_or_tag,filter) => hasName(m,name_or_tag) ||
+ String(m.userData['tag']).match( new RegExp("(^| )"+name_or_tag) )
+ // utility functions
+ const getOrCloneMaterial = (o) => {
+ if( o.material ){
+ if( o.material.isXRF ) return o.material
+ o.material = o.material.clone()
+ o.material.isXRF = true
+ return o.material
+ }
+ return {}
+ }
+ const setVisible = (n,visible,filter,processed) => {
+ if( processed && processed[n.uuid] ) return
+ getOrCloneMaterial(n).visible = visible
+ if( filter.deep ) n.traverse( (m) => getOrCloneMaterial(m).visible = visible )
+ if( processed ) processed[n.uuid] == true
+ }
+
+ // spec 2: https://xrfragment.org/doc/RFC_XR_Macros.html#embedding-xr-content-using-src
+ // reparent scene based on objectname in case it matches a (non-negating) selector
+ if( opts.reparent && firstFilter && !firstFilter.value && firstFilter.show === true ){
+ let obj
+ frag.target = firstFilter
+ scene.traverse( (n) => hasName(n, firstFilter.key,firstFilter) && (obj = n) )
+ if(obj){
+ while( scene.children.length > 0 ) scene.children[0].removeFromParent()
+ obj.position.set(0,0,0)
+ scene.add( obj )
+ }
+ }
+
+ // then show/hide things based on secondary selectors
+ // we don't use the XRWG (everything) because we process only the given (sub)scene
+ frag.filters.map( (v) => {
+ const filter = v.filter.get()
+ const name_or_tag = cleanupKey(v.fragment)
+ let processed = {}
+ let extembeds = {}
+
+ // hide external objects temporarely
+ scene.traverse( (m) => {
+ if( m.isSRCExternal ){
+ m.traverse( (n) => (extembeds[ n.uuid ] = m) && (n.visible = false) )
}
})
+
+ scene.traverseVisible( (m) => {
+ // filter on value(expression) #foo=>3 e.g. *TODO* do this in XRWG
+ if( filter.value && m.userData[filter.key] ){
+ const visible = v.filter.testProperty(filter.key, m.userData[filter.key], filter.show === false )
+ setVisible(m,visible,filter,processed)
+ return
+ }
+ if( hasNameOrTag(m,name_or_tag,filter ) ){
+ setVisible(m,filter.show,filter)
+ }
+ })
+
+ // show external objects again
+ for ( let i in extembeds ) extembeds[i].visible = true
})
-})
+
+ return xrf.filter
+}
+
xrf.frag.defaultPredefinedViews = (opts) => {
let {scene,model} = opts;
scene.traverse( (n) => {
@@ -1711,12 +1802,10 @@ xrf.addEventListener('dynamicKey', (opts) => {
if( !scene ) return
let remove = []
// erase previous lines
- xrf.focusLine.lines.map( (line) => line.parent.remove(line) )
+ xrf.focusLine.lines.map( (line) => line.parent && (line.parent.remove(line)) )
xrf.focusLine.points = []
xrf.focusLine.lines = []
- //scene.traverse( (n) => n.selection ? remove.push(n) : false )
- //remove.map( (n) => scene.remove(n.selection) )
// drawlines
match.map( (w) => {
w.nodes.map( (mesh) => xrf.drawLineToMesh({ ...opts, mesh}) )
@@ -1725,6 +1814,7 @@ xrf.addEventListener('dynamicKey', (opts) => {
xrf.drawLineToMesh = (opts) => {
let {scene,mesh,frag,id} = opts
+ const THREE = xrf.THREE
let oldSelection
// Selection of Interest if predefined_view matches object name
if( mesh.visible && mesh.material){
@@ -1743,8 +1833,9 @@ xrf.drawLineToMesh = (opts) => {
return center;
}
- xrf.camera.getCam().updateMatrixWorld(true); // always keeps me diving into the docs :]
- xrf.camera.getCam().getWorldPosition(from)
+ let cam = xrf.camera.getCam ? xrf.camera.getCam() : xrf.camera // *FIXME* camerarig/rig are conflicting
+ cam.updateMatrixWorld(true); // always keeps me diving into the docs :]
+ cam.getWorldPosition(from)
from.y = 0.5 // originate from the heart chakra! :p
const points = [from, getCenterPoint(mesh) ]
const geometry = new THREE.BufferGeometry().setFromPoints( points );
@@ -1779,14 +1870,17 @@ xrf.addEventListener('render', (opts) => {
*/
let loadAudio = (mimetype) => function(url,opts){
- let {mesh,src,camera} = opts
+ let {mesh,src,camera,THREE} = opts
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
let frag = xrf.URI.parse( url )
+ return
+
/* WebAudio: setup context via THREEjs */
if( !camera.listener ){
camera.listener = new THREE.AudioListener();
- camera.getCam().add( camera.listener );
+ // *FIXME* camera vs camerarig conflict
+ (camera.getCam ? camera.getCam() : camera).add( camera.listener );
}
let isPositionalAudio = !(mesh.position.x == 0 && mesh.position.y == 0 && mesh.position.z == 0)
@@ -1825,7 +1919,6 @@ let loadAudio = (mimetype) => function(url,opts){
if( t.z > 0 ) sound.setLoopEnd( loopEnd )
if( t.y != undefined ){
- console.dir({loopStart,t})
sound.setLoopStart( loopStart )
sound.offset = loopStart
}
@@ -1851,7 +1944,7 @@ audioMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadAudio(mim
// listen to t XR fragment changes
xrf.addEventListener('t', (opts) => {
let t = opts.frag.t
- xrf.scene.traverse( (n) => n.audio && n.audio.playXRF ? n.audio.playXRF(t) : false )
+ xrf.scene.traverse( (n) => n.audio && n.audio.playXRF && (n.audio.playXRF(t)) )
})
/*
* mimetype: model/gltf+json
@@ -1883,7 +1976,7 @@ xrf.frag.src.type['gltf'] = function( url, opts ){
*/
xrf.frag.src.type['image/png'] = function(url,opts){
- let {mesh} = opts
+ let {mesh,THREE} = opts
let restrictTo3DBoundingBox = mesh.geometry
let renderEquirect = (texture) => {
@@ -1951,7 +2044,7 @@ xrf.frag.src.type['image/png'] = function(url,opts){
}
}
//const geometry = new THREE.BoxGeometry();
- mesh.material = new THREE.MeshBasicMaterial({
+ mesh.material = new xrf.THREE.MeshBasicMaterial({
map: texture,
transparent: url.match(/(png|gif)/) ? true : false,
side: THREE.DoubleSide,
@@ -1979,10 +2072,197 @@ xrf.frag.src.type['image/png'] = function(url,opts){
xrf.frag.src.type['image/gif'] = xrf.frag.src.type['image/png']
xrf.frag.src.type['image/jpeg'] = xrf.frag.src.type['image/png']
+// spec 8: https://xrfragment.org/doc/RFC_XR_Macros.html#embedding-xr-content-using-src
+
+xrf.portalNonEuclidian = function(opts){
+ let { frag, mesh, model, camera, scene, renderer} = opts
+
+ mesh.portal = {
+ pos: mesh.position.clone(),
+ posWorld: new xrf.THREE.Vector3(),
+ posWorldCamera: new xrf.THREE.Vector3(),
+ stencilRef: xrf.portalNonEuclidian.stencilRef,
+ needUpdate: false,
+ stencilObject: false,
+ cameraDirection: new THREE.Vector3(),
+ cameraPosition: new THREE.Vector3(),
+ raycaster: new THREE.Raycaster(),
+ isLocal: opts.isLocal,
+ isLens: false
+ }
+
+ // allow objects to flip between original and stencil position (which puts them behind stencilplane)
+ const addStencilFeature = (n) => {
+ if( n.stencil ) return n // run once
+ n.stencil = ( (pos,scale) => (sRef,newPos, newScale) => {
+ if( !mesh.portal.isLens ){
+ n.position.copy( sRef == 0 ? pos : newPos )
+ if( sRef > 0 ) n.scale.multiply( newScale )
+ else n.scale.copy( scale )
+ n.updateMatrixWorld(true)
+ }
+ xrf.portalNonEuclidian.selectStencil(n, sRef )
+ }
+ )( n.position.clone(), n.scale.clone() )
+ return n
+ }
+
+ this.setupStencilObjects = (scene,opts) => {
+ // collect related objects to render inside stencilplane
+ let stencilObject = scene
+ if( opts.srcFrag.target ){
+ stencilObject = scene.getObjectByName( opts.srcFrag.target.key )
+ // spec: if src-object is child of portal (then portal is lens, and should include all children )
+ mesh.traverse( (n) => n.name == opts.srcFrag.target.key && (stencilObject = n) && (mesh.portal.isLens = true) )
+ }
+
+ if( !stencilObject ) return console.warn(`no objects were found (src:${mesh.userData.src}) for (portal)object name '${mesh.name}'`)
+ mesh.portal.stencilObject = stencilObject
+
+ // spec: if src points to child, act as lens
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
+
+ let stencilObjects = [stencilObject]
+ stencilObjects = stencilObjects
+ .filter( (n) => !n.portal ) // filter out (self)references to portals (prevent recursion)
+ .map(addStencilFeature)
+
+ //// add missing lights to make sure things get lit properly
+ xrf.scene.traverse( (n) => n.isLight &&
+ !stencilObjects.find( (o) => o.uuid == n.uuid ) &&
+ stencilObjects.push(n)
+ )
+
+ // put it into a scene (without .add() because it reparents objects) so we can render it separately
+ mesh.portal.stencilObjects = new xrf.THREE.Scene()
+ mesh.portal.stencilObjects.children = stencilObjects
+
+ xrf.portalNonEuclidian.stencilRef += 1 // each portal has unique stencil id
+ console.log(`enabling portal for object '${mesh.name}' (stencilRef:${mesh.portal.stencilRef})`)
+
+ // clone so it won't be affected by other fragments
+ setTimeout( (mesh) => {
+ if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
+ }, 0, mesh )
+
+
+ // spec: increase height of portal(object) floor so it won't get rendererd under the current floor
+ mesh.portal.posWorld.y +=0.1
+
+ return this
+ }
+
+ // enable the stencil-material of the stencil objects to prevent stackoverflow (portal in portal rendering)
+ const showPortal = (n,show) => {
+ if( n.portal ) n.visible = show
+ return true
+ }
+
+ this.setupListeners = () => {
+
+ mesh.onAfterRender = function(renderer, scene, camera, geometry, material, group ){
+ mesh.portal.needUpdate = true
+ }
+
+ xrf.addEventListener('renderPost', (opts) => {
+ let {scene,camera,time,render,renderer} = opts
+
+ if( mesh.portal && mesh.portal.stencilObjects ){
+ let stencilRef = mesh.portal.stencilRef
+ let newPos = mesh.portal.posWorld
+ let stencilObject = mesh.portal.stencilObject
+ let newScale = mesh.scale
+ let cameraDirection = mesh.portal.cameraDirection
+ let cameraPosition = mesh.portal.cameraPosition
+ let raycaster = mesh.portal.raycaster
+ let cam = xrf.camera.getCam ? xrf.camera.getCam() : camera
+ cam.getWorldPosition(cameraPosition)
+ if( cameraPosition.distanceTo(newPos) > 20.0 ) return // dont render far portals
+ cam.getWorldDirection(cameraDirection)
+
+ // init
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = true
+ mesh.portal.stencilObjects.traverse( (n) => showPortal(n,false) && n.stencil && n.stencil(stencilRef,newPos,newScale) )
+ renderer.autoClear = false
+ renderer.autoClearDepth = false
+ renderer.autoClearColor = false
+ renderer.autoClearStencil = false
+ // render
+ render( mesh.portal.stencilObjects, camera )
+ // de-init
+ renderer.autoClear = true
+ renderer.autoClearDepth = true
+ renderer.autoClearColor = true
+ renderer.autoClearStencil = true
+ mesh.portal.stencilObjects.traverse( (n) => showPortal(n,true) && n.stencil && (n.stencil(0)) )
+ if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
+
+
+ // trigger href upon camera collide
+ if( mesh.userData.XRF.href ){
+ raycaster.far = 0.35
+ raycaster.set(cameraPosition, cameraDirection )
+ intersects = raycaster.intersectObjects([mesh], false)
+ if (intersects.length > 0 && !mesh.portal.teleporting ){
+ mesh.portal.teleporting = true
+ mesh.userData.XRF.href.exec({nocommit:true})
+ setTimeout( () => mesh.portal.teleporting = false, 500) // dont flip back and forth
+ }
+ }
+ }
+ mesh.portal.needUpdate = false
+ })
+ return this
+ }
+
+ // turn mesh into stencilplane
+ xrf
+ .portalNonEuclidian
+ .setMaterial(mesh)
+ .getWorldPosition(mesh.portal.posWorld)
+
+ this
+ .setupListeners()
+ .setupStencilObjects(scene,opts)
+
+}
+
+xrf.portalNonEuclidian.selectStencil = (n, stencilRef, nested) => {
+ if( n.material ){
+ n.material.stencilRef = stencilRef
+ n.material.stencilWrite = stencilRef > 0
+ n.material.stencilFunc = xrf.THREE.EqualStencilFunc;
+ }
+ if( n.children && !nested ) n.traverse( (m) => !m.portal && (xrf.portalNonEuclidian.selectStencil(m,stencilRef,true)) )
+}
+
+xrf.portalNonEuclidian.setMaterial = function(mesh){
+ mesh.material = new xrf.THREE.MeshBasicMaterial({ color: 'orange' });
+ mesh.material.depthWrite = false;
+ mesh.material.colorWrite = false;
+ mesh.material.stencilWrite = true;
+ mesh.material.stencilRef = xrf.portalNonEuclidian.stencilRef;
+ // mesh.renderOrder = 0;//xrf.portalNonEuclidian.stencilRef;
+ mesh.material.stencilFunc = xrf.THREE.AlwaysStencilFunc;
+ mesh.material.stencilZPass = xrf.THREE.ReplaceStencilOp;
+ mesh.material.stencilZFail = xrf.THREE.ReplaceStencilOp;
+ //n.material.depthFunc = stencilRef > 0 ? xrf.THREE.AlwaysDepth : xrf.THREE.LessEqualDepth
+ //mesh.material.depthTest = false;
+ return mesh
+}
+
+xrf.addEventListener('parseModel',(opts) => {
+ const scene = opts.model.scene
+ // scene.traverse( (n) => n.renderOrder = 10 ) // rendering everything *after* the stencil buffers
+})
+
+
+xrf.portalNonEuclidian.stencilRef = 1
let loadVideo = (mimetype) => function(url,opts){
let {mesh,src,camera} = opts
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
+ const THREE = xrf.THREE
let frag = xrf.URI.parse( url )
let video = mesh.video = document.createElement('video')
@@ -1994,9 +2274,17 @@ let loadVideo = (mimetype) => function(url,opts){
let mat = new xrf.THREE.MeshBasicMaterial()
mat.map = texture
mesh.material = mat
+ // set range
+ //video.addEventListener('timeupdate', function timeupdate() {
+ // if (frag.t && video.currentTime < frag.t.y || video.currentTime >= frag.t.z ) {
+ // video.currentTime = frag.t.y
+ // }
+ //},false)
})
+
video.src = url
video.playXRF = (t) => {
+ video.t = t
if( t.x == 0 ) video.pause()
else{
video.playbackRate = Math.abs( t.x ) // html5 video does not support reverseplay :/
@@ -2015,6 +2303,6 @@ videoMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadVideo(mim
// listen to t XR fragment changes
xrf.addEventListener('t', (opts) => {
let t = opts.frag.t
- xrf.scene.traverse( (n) => n.video ? n.video.playXRF(t) : false )
+ xrf.scene.traverse( (n) => n.video && (n.video.playXRF(t)) )
})
export default xrf;
diff --git a/src/3rd/js/three/xrf/src/non-euclidian.js b/src/3rd/js/three/xrf/src/non-euclidian.js
index d574d39..550f07a 100644
--- a/src/3rd/js/three/xrf/src/non-euclidian.js
+++ b/src/3rd/js/three/xrf/src/non-euclidian.js
@@ -41,6 +41,7 @@ xrf.portalNonEuclidian = function(opts){
// spec: if src-object is child of portal (then portal is lens, and should include all children )
mesh.traverse( (n) => n.name == opts.srcFrag.target.key && (stencilObject = n) && (mesh.portal.isLens = true) )
}
+
if( !stencilObject ) return console.warn(`no objects were found (src:${mesh.userData.src}) for (portal)object name '${mesh.name}'`)
mesh.portal.stencilObject = stencilObject
@@ -86,6 +87,12 @@ xrf.portalNonEuclidian = function(opts){
this.setupListeners = () => {
mesh.onAfterRender = function(renderer, scene, camera, geometry, material, group ){
+ mesh.portal.needUpdate = true
+ }
+
+ xrf.addEventListener('renderPost', (opts) => {
+ let {scene,camera,time,render,renderer} = opts
+
if( mesh.portal && mesh.portal.stencilObjects ){
let stencilRef = mesh.portal.stencilRef
let newPos = mesh.portal.posWorld
@@ -103,9 +110,16 @@ xrf.portalNonEuclidian = function(opts){
if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = true
mesh.portal.stencilObjects.traverse( (n) => showPortal(n,false) && n.stencil && n.stencil(stencilRef,newPos,newScale) )
renderer.autoClear = false
+ renderer.autoClearDepth = false
+ renderer.autoClearColor = false
+ renderer.autoClearStencil = false
// render
- renderer.render( mesh.portal.stencilObjects, camera )
+ render( mesh.portal.stencilObjects, camera )
// de-init
+ renderer.autoClear = true
+ renderer.autoClearDepth = true
+ renderer.autoClearColor = true
+ renderer.autoClearStencil = true
mesh.portal.stencilObjects.traverse( (n) => showPortal(n,true) && n.stencil && (n.stencil(0)) )
if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = false
@@ -122,7 +136,8 @@ xrf.portalNonEuclidian = function(opts){
}
}
}
- }
+ mesh.portal.needUpdate = false
+ })
return this
}
@@ -153,7 +168,7 @@ xrf.portalNonEuclidian.setMaterial = function(mesh){
mesh.material.colorWrite = false;
mesh.material.stencilWrite = true;
mesh.material.stencilRef = xrf.portalNonEuclidian.stencilRef;
- mesh.renderOrder = 10;//xrf.portalNonEuclidian.stencilRef;
+ // mesh.renderOrder = 0;//xrf.portalNonEuclidian.stencilRef;
mesh.material.stencilFunc = xrf.THREE.AlwaysStencilFunc;
mesh.material.stencilZPass = xrf.THREE.ReplaceStencilOp;
mesh.material.stencilZFail = xrf.THREE.ReplaceStencilOp;
@@ -164,7 +179,7 @@ xrf.portalNonEuclidian.setMaterial = function(mesh){
xrf.addEventListener('parseModel',(opts) => {
const scene = opts.model.scene
- scene.traverse( (n) => n.renderOrder = 0 ) // rendering everything *after* the stencil buffers
+ // scene.traverse( (n) => n.renderOrder = 10 ) // rendering everything *after* the stencil buffers
})