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-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 ) ) ;
} ;
StringTools . replace = function ( s , sub , by ) {
return s . split ( sub ) . join ( by ) ;
} ;
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 ( ) {
2023-06-27 09:43:10 +02:00
Test . test ( [ { fn : "url" , expect : { fn : "equal.xyz" , input : "pos" , out : false } , label : "equal.xyz: should trigger incompatible type)" , data : "http://foo.com?foo=1#pos=1.2,2.2" } , { fn : "url" , expect : { fn : "equal.xyz" , input : "pos" , out : "1.2,2.2,3" } , label : "equal.xyz" , data : "http://foo.com?foo=1#pos=1.2,2.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 : "testParsed" , input : "prio" , out : false } , label : "should trigger incompatible type" , data : "http://foo.com?foo=1#prio=foo" } , { fn : "url" , expect : { fn : "equal.multi" , input : "pos" , out : "c|d|1,2,3" } , label : "b equal.multi" , data : "http://foo.com?foo=1#pos=c|d|1,2,3" } , { 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 : "testBrowserOverride" , input : "q" , out : false } , label : "browser URI cannot override q (defined in asset)" , data : "http://foo.com?foo=1#q=-bar" } , { fn : "url" , expect : { fn : "testBrowserOverride" , input : "scale" , out : false } , label : "scale does not have NAVIGATOR set" , data : "http://foo.com?foo=1#scale=2,2,2" } , { fn : "url" , expect : { fn : "testEmbedOverride" , input : "scale" , out : true } , label : "embedded (src) URI can override scale" , data : "http://foo.com?foo=1#scale=2,2,2" } , { fn : "url" , expect : { fn : "testPredefinedView" , input : "mypredefinedview" , out : true } , label : "test predefined view executed" , data : "http://foo.com?foo=1#mypredefinedview" } , { fn : "url" , expect : { fn : "testPredefinedView" , input : "another" , out : true } , label : "test predefined view executed (multiple)" , data : "http://foo.com?foo=1#mypredefinedview&another" } , { fn : "url" , expect : { fn : "testPredefinedView" , input : "mypredefinedview" , out : true } , label : "test predefined view executed (multiple)" , data : "http://foo.com?foo=1#mypredefinedview&another" } , { fn : "url" , expect : { fn : "testPropertyAssign" , input : "cube.position.x" , out : true } , label : "test data assign" , data : "#cube.position.x=music.position.x" } , { fn : "url" , expect : { fn : "testPropertyAssign" , input : "cube.position.x" , out : true } , label : "test one-way data bind" , data : "#cube.position.x=@music.position.x" } , { fn : "url" , expect : { fn : "testParsed" , input : "_mycustom" , out : true } , label : "test custom property" , data : "http://foo.com?foo=1#mycustom=foo" } ] ) ;
2023-06-22 08:49:24 +02:00
Test . test ( [ { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "bar" ] , out : true } , data : "class:bar" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "bar" ] , out : true } , label : ".bar shorthand" , data : ".bar" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : false } , data : ".bar -.foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : true } , data : ".bar -.foo .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "bar" ] , out : true } , data : ".bar -.bar .bar" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : true } , label : "class:foo" , data : ".foo -.foo .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : true } , label : "class:foo" , data : ".foo -.foo bar:5 .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : true } , label : "class:foo" , data : ".foo -.foo bar:>5 .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : true } , label : "class:foo" , data : ".foo -.foo bar:>5 .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "class" , "foo" ] , out : true } , label : "class:foo" , data : ".foo -.foo .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "id" , "foo" ] , out : false } , label : "!id:foo" , data : ".foo -.foo .foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "id" , "foo" ] , out : true } , label : "id:foo?" , data : "foo -foo foo" } , { fn : "query" , expect : { fn : "testQueryRoot" , input : [ "foo" ] , out : true } , label : "foo should be root-only" , data : "/foo" } , { fn : "query" , expect : { fn : "testQueryRoot" , input : [ "foo" ] , out : false } , label : "foo should recursively selected" , data : "/foo foo" } ] ) ;
Test . test ( [ ] ) ;
2023-06-09 16:40:08 +02:00
Test . test ( [ { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "10" ] , out : true } , data : "price:>=5" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "10" ] , out : false } , data : "price:>=15" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "4" ] , out : false } , data : "price:>=5" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "0" ] , out : false } , data : "price:>=5" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "2" ] , out : true } , data : "price:>=2" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "1" ] , out : false } , label : "price=1" , data : "price:>=5 price:0" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "0" ] , out : true } , label : "price=0" , data : "price:>=5 price:0" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "price" , "6" ] , out : true } , label : "price=6" , data : "price:>=5 price:0" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "tag" , "foo" ] , out : true } , data : "tag:foo" } , { fn : "query" , expect : { fn : "testProperty" , input : [ "tag" , "foo" ] , out : false } , data : "-tag:foo" } , { fn : "query" , expect : { fn : "testPropertyExclude" , input : [ "tag" , "foo" ] , out : true } , label : "testExclude" , data : "-tag:foo" } , { fn : "query" , expect : { fn : "test" , input : [ { price : 5 } ] , out : true } , data : ".foo price:5 -tag:foo" } , { fn : "query" , expect : { fn : "test" , input : [ { tag : "foo" , price : 5 } ] , out : false } , data : ".foo price:5 -tag:foo" } ] ) ;
2023-03-30 19:51:32 +02:00
if ( Test . errors > 1 ) {
2023-06-22 08:49:24 +02:00
console . log ( "src/Test.hx:23:" , "\n-----\n[ ❌] " + Test . errors + " errors :/" ) ;
2023-03-30 19:51:32 +02:00
}
2023-03-09 19:58:08 +01:00
} ;
2023-03-17 16:06:24 +01:00
Test . test = function ( spec ) {
var Query = xrfragment _Query ;
var _g = 0 ;
var _g1 = spec . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var q = null ;
var res = null ;
var valid = false ;
var item = spec [ i ] ;
if ( item . fn == "query" ) {
q = new xrfragment _Query ( item . data ) ;
}
if ( item . fn == "url" ) {
2023-05-04 13:28:12 +02:00
res = xrfragment _URI . parse ( item . data , 0 ) ;
2023-03-17 16:06:24 +01:00
}
2023-03-21 17:57:54 +01:00
if ( item . expect . fn == "test" ) {
2023-03-24 17:10:30 +01:00
valid = item . expect . out == q . test ( item . expect . input [ 0 ] ) ;
}
if ( item . expect . fn == "testProperty" ) {
valid = item . expect . out == q . testProperty ( item . expect . input [ 0 ] , item . expect . input [ 1 ] ) ;
}
if ( item . expect . fn == "testPropertyExclude" ) {
valid = item . expect . out == q . testProperty ( item . expect . input [ 0 ] , item . expect . input [ 1 ] , true ) ;
2023-03-17 16:06:24 +01:00
}
2023-03-30 19:51:32 +02: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" ) {
2023-05-04 13:28:12 +02:00
var item1 = item . expect . out ;
2023-05-05 13:26:17 +02:00
var this1 = xrfragment _URI . parse ( item . data , xrfragment _XRF . NAVIGATOR ) ;
2023-05-04 13:28:12 +02:00
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 ;
2023-08-15 18:27:26 +02:00
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
}
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.multi" ) {
valid = Test . equalMulti ( res , item ) ;
}
2023-06-22 08:49:24 +02:00
if ( item . expect . fn == "testQueryRoot" ) {
valid = item . expect . out == q . get ( ) [ item . expect . input [ 0 ] ] . root ;
}
2023-03-17 16:06:24 +01:00
var ok = valid ? "[ ✔ ] " : "[ ❌] " ;
2023-06-22 08:49:24 +02:00
console . log ( "src/Test.hx:49:" , 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 ) {
2023-03-30 19:51:32 +02:00
Test . errors += 1 ;
2023-03-17 16:06:24 +01:00
}
}
2023-03-09 19:58:08 +01:00
} ;
2023-04-14 15:19:52 +02:00
Test . equalXY = 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 ) ;
} else {
return false ;
}
} ;
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-17 16:06:24 +01:00
Test . equalMulti = function ( res , item ) {
var target = res [ item . expect . input ] ;
var str = "" ;
2023-03-30 19:51:32 +02:00
if ( ! target ) {
return false ;
}
2023-03-17 16:06:24 +01:00
var _g = 0 ;
var _g1 = target . args . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
str = str + "|" + target . args [ i ] . string ;
2023-03-10 18:49:16 +01:00
}
2023-03-17 16:06:24 +01:00
str = HxOverrides . substr ( str , 1 , null ) ;
2023-03-30 19:51:32 +02:00
if ( item . expect . out ) {
return str == item . expect . out ;
} else {
return false ;
}
2023-03-09 19:58:08 +01:00
} ;
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-03-31 12:58:53 +02:00
var xrfragment _Parser = $hx _exports [ "xrfragment" ] [ "Parser" ] = function ( ) { } ;
xrfragment _Parser . _ _name _ _ = true ;
2023-06-27 09:43:10 +02:00
xrfragment _Parser . parse = function ( key , value , store ) {
2023-03-31 12:58:53 +02:00
var Frag _h = Object . create ( null ) ;
2023-08-15 18:27:26 +02:00
Frag _h [ "#" ] = xrfragment _XRF . ASSET | xrfragment _XRF . T _PREDEFINED _VIEW | xrfragment _XRF . PV _EXECUTE ;
2023-04-20 18:49:18 +02:00
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 ;
2023-08-15 18:27:26 +02:00
Frag _h [ "class" ] = xrfragment _XRF . ASSET | xrfragment _XRF . T _STRING ;
Frag _h [ "pos" ] = xrfragment _XRF . PV _OVERRIDE | xrfragment _XRF . ROUNDROBIN | 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 . ROUNDROBIN | xrfragment _XRF . T _VECTOR3 | xrfragment _XRF . METADATA ;
Frag _h [ "rot" ] = xrfragment _XRF . QUERY _OPERATOR | xrfragment _XRF . PV _OVERRIDE | xrfragment _XRF . ROUNDROBIN | xrfragment _XRF . T _VECTOR3 | xrfragment _XRF . METADATA | xrfragment _XRF . NAVIGATOR ;
Frag _h [ "mov" ] = xrfragment _XRF . QUERY _OPERATOR | xrfragment _XRF . PV _OVERRIDE | xrfragment _XRF . ROUNDROBIN | xrfragment _XRF . T _VECTOR3 | xrfragment _XRF . METADATA ;
Frag _h [ "show" ] = xrfragment _XRF . QUERY _OPERATOR | xrfragment _XRF . PV _OVERRIDE | xrfragment _XRF . ROUNDROBIN | 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 . ROUNDROBIN | xrfragment _XRF . T _VECTOR2 | 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 ;
2023-08-24 13:36:41 +02:00
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 ;
2023-04-14 15:19:52 +02:00
Frag _h [ "namespace" ] = xrfragment _XRF . ASSET | xrfragment _XRF . T _STRING ;
2023-04-28 14:27:30 +02:00
Frag _h [ "SPDX" ] = xrfragment _XRF . ASSET | xrfragment _XRF . T _STRING ;
2023-04-14 15:19:52 +02:00
Frag _h [ "unit" ] = xrfragment _XRF . ASSET | xrfragment _XRF . T _STRING ;
Frag _h [ "description" ] = xrfragment _XRF . ASSET | xrfragment _XRF . T _STRING ;
2023-08-15 18:27:26 +02:00
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 ) {
2023-06-09 16:40:08 +02:00
var v = new xrfragment _XRF ( key , xrfragment _XRF . PV _EXECUTE | xrfragment _XRF . NAVIGATOR ) ;
v . validate ( key ) ;
2023-06-27 09:43:10 +02:00
store [ key ] = v ;
2023-04-14 17:37:33 +02:00
return true ;
}
2023-04-20 18:49:18 +02:00
if ( key . split ( "." ) . length > 1 && value . split ( "." ) . length > 1 ) {
2023-06-27 09:43:10 +02:00
store [ key ] = new xrfragment _XRF ( key , xrfragment _XRF . ASSET | xrfragment _XRF . PV _OVERRIDE | xrfragment _XRF . T _STRING | xrfragment _XRF . PROP _BIND ) ;
2023-04-20 18:49:18 +02:00
return true ;
}
2023-06-27 09:43:10 +02:00
var v = new xrfragment _XRF ( key , Frag _h [ key ] ) ;
2023-03-31 12:58:53 +02:00
if ( Object . prototype . hasOwnProperty . call ( Frag _h , key ) ) {
2023-04-14 15:19:52 +02:00
if ( ! v . validate ( value ) ) {
2023-08-24 13:36:41 +02:00
console . log ( "src/xrfragment/Parser.hx:83:" , "⚠ fragment '" + key + "' has incompatible value (" + value + ")" ) ;
2023-03-31 12:58:53 +02:00
return false ;
}
2023-06-27 09:43:10 +02:00
store [ key ] = v ;
2023-05-04 16:26:14 +02:00
if ( xrfragment _Parser . debug ) {
2023-08-24 13:36:41 +02:00
console . log ( "src/xrfragment/Parser.hx:87:" , "✔ " + key + ": " + v . string ) ;
2023-05-04 16:26:14 +02:00
}
2023-06-27 09:43:10 +02:00
} else {
2023-06-27 12:15:04 +02:00
if ( typeof ( value ) == "string" ) {
v . guessType ( v , value ) ;
}
2023-06-27 09:43:10 +02:00
store [ "_" + key ] = v ;
2023-03-31 12:58:53 +02:00
}
return true ;
} ;
2023-03-31 19:13:42 +02:00
var xrfragment _Query = $hx _exports [ "xrfragment" ] [ "Query" ] = function ( str ) {
2023-03-24 17:10:30 +01:00
this . isNumber = new EReg ( "^[0-9\\.]+$" , "" ) ;
this . isClass = new EReg ( "^[-]?class$" , "" ) ;
2023-06-22 08:49:24 +02:00
this . isRoot = new EReg ( "^[-]?/" , "" ) ;
2023-03-21 17:57:54 +01:00
this . isExclude = new EReg ( "^-" , "" ) ;
this . isProp = new EReg ( "^.*:[><=!]?" , "" ) ;
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-03-10 18:49:16 +01:00
xrfragment _Query . _ _name _ _ = true ;
2023-03-09 19:58:08 +01:00
xrfragment _Query . prototype = {
2023-03-31 19:13:42 +02:00
toObject : function ( ) {
return this . q ;
}
, expandAliases : function ( token ) {
2023-03-21 17:57:54 +01:00
var classAlias = new EReg ( "^(-)?\\." , "" ) ;
if ( classAlias . match ( token ) ) {
return StringTools . replace ( token , "." , "class:" ) ;
} else {
return token ;
2023-03-09 19:58:08 +01:00
}
}
2023-04-14 15:19:52 +02:00
, get : function ( ) {
return this . q ;
}
2023-06-27 09:43:10 +02:00
, parse : function ( str ) {
2023-03-09 19:58:08 +01:00
var _gthis = this ;
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-03-24 17:10:30 +01:00
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" ] : [ ] ;
2023-03-21 17:57:54 +01:00
if ( _gthis . isProp . match ( str ) ) {
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
}
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
}
if ( str . indexOf ( "<=" ) != - 1 ) {
2023-03-21 17:57:54 +01:00
oper = "<=" ;
2023-03-09 19:58:08 +01:00
}
2023-03-24 17:10:30 +01:00
if ( _gthis . isExclude . match ( k ) ) {
oper = "!=" ;
k = HxOverrides . substr ( k , 1 , null ) ;
} else {
v = HxOverrides . substr ( v , oper . length , null ) ;
}
if ( oper . length == 0 ) {
oper = "=" ;
2023-03-09 19:58:08 +01:00
}
2023-03-24 17:10:30 +01:00
if ( _gthis . isClass . match ( k ) ) {
filter [ prefix + k ] = oper != "!=" ;
q [ v ] = filter ;
2023-03-09 19:58:08 +01:00
} else {
2023-03-24 17:10:30 +01:00
var rule = { } ;
if ( _gthis . isNumber . match ( v ) ) {
rule [ oper ] = parseFloat ( v ) ;
} else {
rule [ oper ] = v ;
}
filter [ "rules" ] . push ( rule ) ;
q [ k ] = filter ;
2023-03-09 19:58:08 +01:00
}
return ;
2023-03-21 17:57:54 +01:00
} else {
2023-03-24 17:10:30 +01:00
filter [ "id" ] = _gthis . isExclude . match ( str ) ? false : true ;
2023-06-22 08:49:24 +02:00
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 ;
2023-03-09 19:58:08 +01:00
}
} ;
var _g = 0 ;
var _g1 = token . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
2023-03-21 17:57:54 +01:00
process ( this . expandAliases ( 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
}
2023-03-24 17:10:30 +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
}
var _g = 0 ;
2023-03-21 17:57:54 +01:00
var _g1 = Reflect . fields ( this . q ) ;
while ( _g < _g1 . length ) {
var k = _g1 [ _g ] ;
++ _g ;
2023-03-24 17:10:30 +01:00
var filter = Reflect . field ( this . q , k ) ;
if ( filter . rules == null ) {
2023-03-21 17:57:54 +01:00
continue ;
}
2023-03-24 17:10:30 +01:00
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 ;
}
}
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-03-31 14:47:54 +02:00
var xrfragment _URI = $hx _exports [ "xrfragment" ] [ "URI" ] = function ( ) { } ;
xrfragment _URI . _ _name _ _ = true ;
2023-05-04 13:28:12 +02:00
xrfragment _URI . parse = function ( url , filter ) {
var store = { } ;
2023-06-10 14:43:07 +02:00
if ( url == null || url . indexOf ( "#" ) == - 1 ) {
2023-05-04 13:28:12 +02:00
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-05-04 13:28:12 +02:00
var ok = xrfragment _Parser . parse ( key , value , store ) ;
2023-03-10 18:49:16 +01:00
}
2023-05-04 13:28:12 +02:00
if ( filter != null && filter != 0 ) {
2023-04-14 15:19:52 +02:00
var _g = 0 ;
2023-05-04 13:28:12 +02:00
var _g1 = Reflect . fields ( store ) ;
2023-04-14 15:19:52 +02:00
while ( _g < _g1 . length ) {
var key = _g1 [ _g ] ;
++ _g ;
2023-05-04 13:28:12 +02:00
var xrf = store [ key ] ;
if ( ! xrf . is ( filter ) ) {
Reflect . deleteField ( store , key ) ;
2023-04-14 15:19:52 +02:00
}
}
}
2023-05-04 13:28:12 +02:00
return store ;
2023-03-10 18:49:16 +01:00
} ;
2023-04-28 14:27:30 +02:00
var xrfragment _XRF = $hx _exports [ "xrfragment" ] [ "XRF" ] = function ( _fragment , _flags ) {
2023-04-14 15:19:52 +02:00
this . fragment = _fragment ;
this . flags = _flags ;
} ;
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 ) {
return ( this . flags & flag ) != 0 ;
}
, validate : function ( value ) {
this . guessType ( this , value ) ;
if ( value . split ( "|" ) . length > 1 ) {
this . args = [ ] ;
var args = value . split ( "|" ) ;
var _g = 0 ;
var _g1 = args . length ;
while ( _g < _g1 ) {
var i = _g ++ ;
var x = new xrfragment _XRF ( this . fragment , this . flags ) ;
this . guessType ( x , args [ i ] ) ;
this . args . push ( x ) ;
}
}
if ( this . fragment == "q" ) {
this . query = new xrfragment _Query ( value ) . get ( ) ;
}
var ok = true ;
if ( ! ( ( this . args ) instanceof Array ) ) {
if ( this . is ( xrfragment _XRF . T _VECTOR3 ) && ! ( typeof ( this . x ) == "number" && typeof ( this . y ) == "number" && typeof ( this . z ) == "number" ) ) {
ok = false ;
}
if ( this . is ( xrfragment _XRF . T _VECTOR2 ) && ! ( typeof ( this . x ) == "number" && typeof ( this . y ) == "number" ) ) {
ok = false ;
}
var tmp ;
if ( this . is ( xrfragment _XRF . T _INT ) ) {
var v = this . int ;
tmp = ! ( typeof ( v ) == "number" && ( ( v | 0 ) === v ) ) ;
} else {
tmp = false ;
}
if ( tmp ) {
ok = false ;
}
}
return ok ;
}
, guessType : function ( v , str ) {
v . string = str ;
if ( str . split ( "," ) . length > 1 ) {
var xyz = str . split ( "," ) ;
if ( xyz . length > 0 ) {
v . x = parseFloat ( xyz [ 0 ] ) ;
}
if ( xyz . length > 1 ) {
v . y = parseFloat ( xyz [ 1 ] ) ;
}
if ( xyz . length > 2 ) {
v . z = parseFloat ( xyz [ 2 ] ) ;
}
}
if ( xrfragment _XRF . isColor . match ( str ) ) {
v . color = str ;
}
if ( xrfragment _XRF . isFloat . match ( str ) ) {
v . float = parseFloat ( str ) ;
}
if ( xrfragment _XRF . isInt . match ( str ) ) {
v . int = Std . parseInt ( str ) ;
}
}
} ;
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 ;
2023-03-30 19:51:32 +02:00
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 ;
2023-05-05 13:26:17 +02:00
xrfragment _XRF . NAVIGATOR = 32 ;
2023-08-15 18:27:26 +02:00
xrfragment _XRF . METADATA = 64 ;
2023-05-04 13:28:12 +02:00
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 ;
2023-04-14 15:19:52 +02:00
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]+$" , "" ) ;
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-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" ] ;