xrfragment/test/generated/test.js

694 lines
21 KiB
JavaScript
Raw Normal View History

2023-03-09 19:58:08 +01:00
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(""));
};
2023-03-10 18:49:16 +01:00
EReg.__name__ = true;
2023-03-09 19:58:08 +01:00
EReg.prototype = {
2023-03-09 22:32:28 +01:00
match: function(s) {
2023-03-09 19:58:08 +01:00
if(this.r.global) {
this.r.lastIndex = 0;
}
this.r.m = this.r.exec(s);
this.r.s = s;
return this.r.m != null;
}
2023-03-10 18:49:16 +01:00
,split: function(s) {
var d = "#__delim__#";
return s.replace(this.r,d).split(d);
}
2023-03-09 19:58:08 +01:00
};
var HxOverrides = function() { };
2023-03-10 18:49:16 +01:00
HxOverrides.__name__ = true;
2023-03-21 17:57:54 +01:00
HxOverrides.cca = function(s,index) {
var x = s.charCodeAt(index);
if(x != x) {
return undefined;
}
return x;
};
2023-03-09 19:58:08 +01:00
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();
};
2023-03-10 18:49:16 +01:00
Math.__name__ = true;
2023-03-09 19:58:08 +01:00
var Reflect = function() { };
2023-03-10 18:49:16 +01:00
Reflect.__name__ = true;
2023-03-09 19:58:08 +01:00
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;
};
2023-04-14 15:19:52 +02:00
Reflect.deleteField = function(o,field) {
if(!Object.prototype.hasOwnProperty.call(o,field)) {
return false;
}
delete(o[field]);
return true;
};
2023-12-06 12:55:08 +01:00
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;
};
2023-03-09 19:58:08 +01:00
var Std = function() { };
2023-03-10 18:49:16 +01:00
Std.__name__ = true;
Std.string = function(s) {
return js_Boot.__string_rec(s,"");
};
2023-03-09 19:58:08 +01:00
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;
};
2023-03-21 17:57:54 +01:00
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));
};
2023-03-09 19:58:08 +01:00
var Test = function() { };
2023-03-10 18:49:16 +01:00
Test.__name__ = true;
2023-03-09 19:58:08 +01:00
Test.main = function() {
Test.test("t.json",[{ fn : "url", expect : { fn : "equal.x", input : "t", out : "1"}, label : "a equal.x", data : "http://foo.com?foo=1#t=1"},{ fn : "url", expect : { fn : "equal.x", input : "t", out : "-1"}, label : "a equal.x", data : "http://foo.com?foo=1#t=-1"},{ fn : "url", expect : { fn : "equal.x", input : "t", out : "-1.02"}, label : "a equal.x", data : "http://foo.com?foo=1#t=-1.02"},{ fn : "url", expect : { fn : "equal.xy", input : "t", out : "1,2"}, label : "a equal.xy", data : "http://foo.com?foo=1#t=1,2,3"},{ fn : "url", expect : { fn : "equal.xyz", input : "t", out : "1,2,3"}, label : "a equal.xyz", data : "http://foo.com?foo=1#t=1,2,3"},{ fn : "url", expect : { fn : "equal.xyz", input : "t", out : "1,-2,3"}, label : "a equal.xyz", data : "http://foo.com?foo=1#t=1,-2,3"},{ fn : "url", expect : { fn : "equal.xy", input : "t", out : "1,100"}, label : "a equal.xy", data : "http://foo.com?foo=1#t=1,100"},{ fn : "url", expect : { fn : "testBrowserOverride", input : "t", out : true}, label : "browser URI can override t (defined in asset)", data : "http://foo.com?foo=1#t=2,500"},{ fn : "url", expect : { fn : "equal.mediafragment", input : "3", out : "500"}, label : "a equal.mediafragment", data : "http://foo.com?foo=1#t=1,100,400,500*1.2,2.3"},{ fn : "url", expect : { fn : "equal.mediafragmentSpd", input : "1", out : "2.3"}, label : "a equal.mediafragmentSpeed", data : "http://foo.com?foo=1#t=1,100,400,500*1.2,2.3"}]);
if(Test.errors > 1) {
2023-12-06 12:55:08 +01:00
console.log("src/Test.hx:23:","\n-----\n[ ❌] " + Test.errors + " errors :/");
}
2023-03-09 19:58:08 +01:00
};
2023-11-03 21:22:05 +01:00
Test.test = function(topic,spec) {
2023-12-06 12:55:08 +01:00
console.log("src/Test.hx:27:","\n[.] running " + topic);
var Filter = xrfragment_Filter;
2023-03-17 16:06:24 +01:00
var _g = 0;
var _g1 = spec.length;
while(_g < _g1) {
var i = _g++;
2023-12-06 12:55:08 +01:00
var f = null;
2023-03-17 16:06:24 +01:00
var res = null;
var valid = false;
var item = spec[i];
2023-12-06 12:55:08 +01:00
f = new xrfragment_Filter(item.data);
res = xrfragment_URI.parse(item.data,null);
2023-03-21 17:57:54 +01:00
if(item.expect.fn == "test") {
2023-12-06 12:55:08 +01:00
valid = item.expect.out == f.test(item.expect.input[0]);
}
if(item.expect.fn == "testProperty") {
2023-12-06 12:55:08 +01:00
valid = item.expect.out == f.testProperty(item.expect.input[0],item.expect.input[1]);
}
if(item.expect.fn == "testPropertyInt") {
valid = item.expect.out == f.testProperty(item.expect.input[0],item.expect.input[1]);
}
if(item.expect.fn == "testPropertyExclude") {
2023-12-06 12:55:08 +01:00
valid = item.expect.out == f.testProperty(item.expect.input[0],item.expect.input[1],true);
2023-03-17 16:06:24 +01:00
}
if(item.expect.fn == "testParsed") {
valid = item.expect.out == Object.prototype.hasOwnProperty.call(res,item.expect.input);
}
2023-04-14 17:37:33 +02:00
if(item.expect.fn == "testPredefinedView") {
valid = Object.prototype.hasOwnProperty.call(res,item.expect.input) && item.expect.out == res[item.expect.input].is(xrfragment_XRF.PV_EXECUTE);
}
2023-04-20 18:49:18 +02:00
if(item.expect.fn == "testPropertyAssign") {
valid = Object.prototype.hasOwnProperty.call(res,item.expect.input) && item.expect.out == res[item.expect.input].is(xrfragment_XRF.PROP_BIND);
}
if(item.expect.fn == "testBrowserOverride") {
var item1 = item.expect.out;
var this1 = xrfragment_URI.parse(item.data,xrfragment_XRF.NAVIGATOR);
valid = item1 == Object.prototype.hasOwnProperty.call(this1,item.expect.input);
}
if(item.expect.fn == "testEmbedOverride") {
2023-04-20 18:49:18 +02:00
var item2 = item.expect.out;
var this2 = xrfragment_URI.parse(item.data,xrfragment_XRF.METADATA);
2023-04-20 18:49:18 +02:00
valid = item2 == Object.prototype.hasOwnProperty.call(this2,item.expect.input);
}
2023-03-17 16:06:24 +01:00
if(item.expect.fn == "equal.string") {
2023-04-14 15:19:52 +02:00
valid = res[item.expect.input] && item.expect.out == res[item.expect.input].string;
2023-03-17 16:06:24 +01:00
}
2023-11-03 21:22:05 +01:00
if(item.expect.fn == "equal.x") {
valid = Test.equalX(res,item);
}
2023-03-17 16:06:24 +01:00
if(item.expect.fn == "equal.xy") {
2023-04-14 15:19:52 +02:00
valid = Test.equalXY(res,item);
}
if(item.expect.fn == "equal.xyz") {
valid = Test.equalXYZ(res,item);
2023-03-17 16:06:24 +01:00
}
if(item.expect.fn == "equal.mediafragment") {
valid = Test.equalMediaFragment(res,item);
}
if(item.expect.fn == "equal.mediafragmentSpd") {
valid = Test.equalMediaFragmentSpd(res,item);
}
2023-12-06 12:55:08 +01:00
if(item.expect.fn == "testFilterRoot") {
valid = Object.prototype.hasOwnProperty.call(res,item.expect.input[0]) && res[item.expect.input[0]].filter.get().root == item.expect.out;
}
if(item.expect.fn == "testFilterDeep") {
valid = Object.prototype.hasOwnProperty.call(res,item.expect.input[0]) && res[item.expect.input[0]].filter.get().deep == item.expect.out;
}
2023-03-17 16:06:24 +01:00
var ok = valid ? "[ ✔ ] " : "[ ❌] ";
console.log("src/Test.hx:54:",ok + Std.string(item.fn) + ": '" + Std.string(item.data) + "'" + (item.label ? " (" + (item.label ? item.label : item.expect.fn) + ")" : ""));
2023-03-17 16:06:24 +01:00
if(!valid) {
Test.errors += 1;
2023-03-17 16:06:24 +01:00
}
}
2023-03-09 19:58:08 +01:00
};
2023-11-03 21:22:05 +01:00
Test.equalX = function(res,item) {
2023-04-14 15:19:52 +02:00
if(!item.expect.out && !res[item.expect.input]) {
return true;
} else if(res[item.expect.input]) {
2023-11-03 21:22:05 +01:00
return item.expect.out == Std.string(res[item.expect.input].x);
2023-04-14 15:19:52 +02:00
} else {
return false;
}
};
2023-11-03 21:22:05 +01:00
Test.equalXY = function(res,item) {
2023-04-14 15:19:52 +02:00
if(!item.expect.out && !res[item.expect.input]) {
return true;
} else if(res[item.expect.input]) {
2023-11-03 21:22:05 +01:00
return item.expect.out == Std.string(res[item.expect.input].x) + "," + Std.string(res[item.expect.input].y);
2023-04-14 15:19:52 +02:00
} else {
return false;
}
};
2023-11-03 21:22:05 +01:00
Test.equalXYZ = function(res,item) {
if(!item.expect.out && !res[item.expect.input]) {
return true;
} else if(res[item.expect.input]) {
return item.expect.out == Std.string(res[item.expect.input].x) + "," + Std.string(res[item.expect.input].y) + "," + Std.string(res[item.expect.input].z);
} else {
return false;
}
2023-03-09 19:58:08 +01:00
};
Test.equalMediaFragment = function(res,item) {
if(!item.expect.out && !res[item.expect.input]) {
return true;
} else {
return res["t"].floats[Std.parseInt(item.expect.input)] == Std.parseInt(item.expect.out);
}
};
Test.equalMediaFragmentSpd = function(res,item) {
if(!item.expect.out && !res[item.expect.input]) {
return true;
} else {
return res["t"].speed[Std.parseInt(item.expect.input)] == parseFloat(item.expect.out);
}
};
2023-03-09 22:32:28 +01:00
var haxe_iterators_ArrayIterator = function(array) {
this.current = 0;
this.array = array;
2023-03-09 19:58:08 +01:00
};
2023-03-10 18:49:16 +01:00
haxe_iterators_ArrayIterator.__name__ = true;
2023-03-09 22:32:28 +01:00
haxe_iterators_ArrayIterator.prototype = {
hasNext: function() {
return this.current < this.array.length;
2023-03-09 19:58:08 +01:00
}
,next: function() {
return this.array[this.current++];
}
};
2023-03-10 18:49:16 +01:00
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 "<function>";
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);
}
};
2023-12-06 12:55:08 +01:00
var xrfragment_Filter = $hx_exports["xrfragment"]["Filter"] = function(str) {
2023-03-09 19:58:08 +01:00
this.q = { };
2023-03-31 19:13:42 +02:00
this.str = "";
2023-03-09 19:58:08 +01:00
if(str != null) {
this.parse(str);
}
};
2023-12-06 12:55:08 +01:00
xrfragment_Filter.__name__ = true;
xrfragment_Filter.prototype = {
2023-03-31 19:13:42 +02:00
toObject: function() {
2023-12-06 12:55:08 +01:00
return Reflect.copy(this.q);
2023-03-31 19:13:42 +02:00
}
2023-04-14 15:19:52 +02:00
,get: function() {
2023-12-06 12:55:08 +01:00
return Reflect.copy(this.q);
2023-04-14 15:19:52 +02:00
}
,parse: function(str) {
2023-03-09 19:58:08 +01:00
var token = str.split(" ");
var q = { };
2023-03-21 17:57:54 +01:00
var process = function(str,prefix) {
2023-03-09 19:58:08 +01:00
if(prefix == null) {
prefix = "";
}
2023-03-21 17:57:54 +01:00
str = StringTools.trim(str);
2023-12-06 12:55:08 +01:00
var k = str.split("=")[0];
var v = str.split("=")[1];
var filter = { };
if(q[prefix + k]) {
filter = q[prefix + k];
}
2023-12-06 12:55:08 +01:00
if(xrfragment_XRF.isProp.match(str)) {
2023-03-21 17:57:54 +01:00
var oper = "";
2023-03-09 19:58:08 +01:00
if(str.indexOf(">") != -1) {
2023-03-21 17:57:54 +01:00
oper = ">";
2023-03-09 19:58:08 +01:00
}
if(str.indexOf("<") != -1) {
2023-03-21 17:57:54 +01:00
oper = "<";
2023-03-09 19:58:08 +01:00
}
2023-12-06 12:55:08 +01:00
if(xrfragment_XRF.isExclude.match(k)) {
k = HxOverrides.substr(k,1,null);
}
2023-12-06 12:55:08 +01:00
v = HxOverrides.substr(v,oper.length,null);
if(oper.length == 0) {
oper = "=";
2023-03-09 19:58:08 +01:00
}
var rule = { };
2023-12-06 12:55:08 +01:00
if(xrfragment_XRF.isNumber.match(v)) {
rule[oper] = parseFloat(v);
2023-03-09 19:58:08 +01:00
} else {
rule[oper] = v;
2023-03-09 19:58:08 +01:00
}
2023-12-06 12:55:08 +01:00
q["expr"] = rule;
2023-03-09 19:58:08 +01:00
}
2023-12-06 12:55:08 +01:00
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;
2023-03-09 19:58:08 +01:00
};
var _g = 0;
var _g1 = token.length;
while(_g < _g1) {
var i = _g++;
process(token[i]);
2023-03-09 19:58:08 +01:00
}
2023-04-14 15:19:52 +02:00
return this.q = q;
2023-03-09 19:58:08 +01:00
}
,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) {
2023-03-21 17:57:54 +01:00
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];
}
2023-03-09 19:58:08 +01:00
}
2023-12-06 12:55:08 +01:00
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;
}
2023-03-09 19:58:08 +01:00
}
}
2023-03-21 17:57:54 +01:00
return qualify > 0;
2023-03-09 19:58:08 +01:00
}
};
2023-12-06 12:55:08 +01:00
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.METADATA | xrfragment_XRF.NAVIGATOR;
2023-12-06 12:55:08 +01:00
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_MEDIAFRAG | xrfragment_XRF.NAVIGATOR | xrfragment_XRF.METADATA;
2023-12-06 12:55:08 +01:00
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);
v.flags = xrfragment_XRF.set(xrfragment_XRF.T_DYNAMIC,v.flags);
2023-12-06 12:55:08 +01:00
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;
};
2023-03-31 14:47:54 +02:00
var xrfragment_URI = $hx_exports["xrfragment"]["URI"] = function() { };
xrfragment_URI.__name__ = true;
xrfragment_URI.parse = function(url,filter) {
var store = { };
2023-06-10 14:43:07 +02:00
if(url == null || url.indexOf("#") == -1) {
return store;
}
var fragment = url.split("#");
2023-03-10 18:49:16 +01:00
var splitArray = fragment[1].split("&");
var _g = 0;
var _g1 = splitArray.length;
while(_g < _g1) {
var i = _g++;
var splitByEqual = splitArray[i].split("=");
2023-03-31 12:58:53 +02:00
var regexPlus = new EReg("\\+","g");
2023-03-10 18:49:16 +01:00
var key = splitByEqual[0];
2023-04-14 17:37:33 +02:00
var value = "";
2023-03-10 18:49:16 +01:00
if(splitByEqual.length > 1) {
var s = regexPlus.split(splitByEqual[1]).join(" ");
2023-04-14 17:37:33 +02:00
value = decodeURIComponent(s.split("+").join(" "));
2023-03-10 18:49:16 +01:00
}
2023-12-06 12:55:08 +01:00
var ok = xrfragment_Parser.parse(key,value,store,i);
2023-03-10 18:49:16 +01:00
}
if(filter != null && filter != 0) {
2023-04-14 15:19:52 +02:00
var _g = 0;
var _g1 = Reflect.fields(store);
2023-04-14 15:19:52 +02:00
while(_g < _g1.length) {
var key = _g1[_g];
++_g;
var xrf = store[key];
if(!xrf.is(filter)) {
Reflect.deleteField(store,key);
2023-04-14 15:19:52 +02:00
}
}
}
return store;
2023-03-10 18:49:16 +01:00
};
2023-12-06 12:55:08 +01:00
var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags,_index) {
this.speed = [];
this.floats = [];
2023-04-14 15:19:52 +02:00
this.fragment = _fragment;
this.flags = _flags;
2023-12-06 12:55:08 +01:00
this.index = _index;
2023-04-14 15:19:52 +02:00
};
xrfragment_XRF.__name__ = true;
2023-04-28 14:27:30 +02:00
xrfragment_XRF.set = function(flag,flags) {
return flags | flag;
};
xrfragment_XRF.unset = function(flag,flags) {
return flags & ~flag;
};
2023-04-14 15:19:52 +02:00
xrfragment_XRF.prototype = {
is: function(flag) {
2023-11-03 21:22:05 +01:00
var v = this.flags;
if(!(typeof(v) == "number" && ((v | 0) === v))) {
this.flags = 0;
}
2023-04-14 15:19:52 +02:00
return (this.flags & flag) != 0;
}
,validate: function(value) {
this.guessType(this,value);
var ok = true;
2023-11-03 21:22:05 +01:00
if(!this.is(xrfragment_XRF.T_FLOAT) && this.is(xrfragment_XRF.T_VECTOR2) && !(typeof(this.x) == "number" && typeof(this.y) == "number")) {
ok = false;
}
2023-12-06 12:55:08 +01:00
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")) {
2023-11-03 21:22:05 +01:00
ok = false;
2023-04-14 15:19:52 +02:00
}
return ok;
}
,guessType: function(v,str) {
v.string = str;
2023-12-06 12:55:08 +01:00
if(typeof(str) != "string") {
return;
}
if(str.length > 0) {
if(str.split(",").length > 1) {
var xyzn = str.split(",");
if(xyzn.length > 0) {
v.x = parseFloat(xyzn[0]);
2023-12-06 12:55:08 +01:00
}
if(xyzn.length > 1) {
v.y = parseFloat(xyzn[1]);
2023-12-06 12:55:08 +01:00
}
if(xyzn.length > 2) {
v.z = parseFloat(xyzn[2]);
2023-12-06 12:55:08 +01:00
}
var _g = 0;
var _g1 = xyzn.length;
while(_g < _g1) {
var i = _g++;
v.floats.push(parseFloat(xyzn[i]));
2023-12-06 12:55:08 +01:00
}
2023-11-03 21:22:05 +01:00
}
2023-12-06 12:55:08 +01:00
if(xrfragment_XRF.isColor.match(str)) {
v.color = str;
2023-04-14 15:19:52 +02:00
}
2023-12-06 12:55:08 +01:00
if(xrfragment_XRF.isFloat.match(str)) {
v.x = parseFloat(str);
v.float = v.x;
2023-04-14 15:19:52 +02:00
}
2023-12-06 12:55:08 +01:00
if(xrfragment_XRF.isInt.match(str)) {
v.int = Std.parseInt(str);
v.x = v.int;
2023-04-14 15:19:52 +02:00
}
if(xrfragment_XRF.isMediaFrag.match(str)) {
var speed = str.split("*");
v.speed = [];
if(speed.length > 1) {
var values = speed[1].split(",");
var _g = 0;
var _g1 = values.length;
while(_g < _g1) {
var i = _g++;
v.speed.push(parseFloat(values[i]));
}
}
}
2023-12-06 12:55:08 +01:00
v.filter = new xrfragment_Filter(v.fragment + "=" + v.string);
} else {
v.filter = new xrfragment_Filter(v.fragment);
2023-04-14 15:19:52 +02:00
}
}
};
2023-03-09 19:58:08 +01:00
if(typeof(performance) != "undefined" ? typeof(performance.now) == "function" : false) {
HxOverrides.now = performance.now.bind(performance);
}
2023-03-10 18:49:16 +01:00
String.__name__ = true;
Array.__name__ = true;
js_Boot.__toStr = ({ }).toString;
Test.errors = 0;
2023-03-31 12:58:53 +02:00
xrfragment_Parser.error = "";
2023-05-04 16:26:14 +02:00
xrfragment_Parser.debug = false;
2023-04-14 15:19:52 +02:00
xrfragment_XRF.ASSET = 1;
2023-04-20 18:49:18 +02:00
xrfragment_XRF.PROP_BIND = 2;
2023-04-14 17:37:33 +02:00
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_MEDIAFRAG = 2097152;
xrfragment_XRF.T_DYNAMIC = 4194304;
2023-04-14 15:19:52 +02:00
xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","");
2023-11-03 21:22:05 +01:00
xrfragment_XRF.isInt = new EReg("^[-0-9]+$","");
xrfragment_XRF.isFloat = new EReg("^[-0-9]+\\.[0-9]+$","");
2023-04-28 14:27:30 +02:00
xrfragment_XRF.isVector = new EReg("([,]+|\\w)","");
xrfragment_XRF.isUrl = new EReg("(://)?\\..*","");
xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*","");
xrfragment_XRF.isString = new EReg(".*","");
2023-12-06 12:55:08 +01:00
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\\.]+$","");
xrfragment_XRF.isMediaFrag = new EReg("^[0-9\\.,\\*]+$","");
2023-03-09 19:58:08 +01:00
Test.main();
2023-03-09 22:32:28 +01:00
})({});
2023-03-09 19:58:08 +01:00
var xrfragment = $hx_exports["xrfragment"];