@webqit/oohtml 2.1.9 → 2.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings-api.js +1 -1
- package/dist/bindings-api.js.map +3 -3
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +3 -3
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +3 -3
- package/dist/html-modules.js +1 -1
- package/dist/html-modules.js.map +3 -3
- package/dist/main.js +7 -7
- package/dist/main.js.map +3 -3
- package/dist/namespace-api.js +2 -0
- package/dist/namespace-api.js.map +7 -0
- package/dist/scoped-js.js +7 -7
- package/dist/scoped-js.js.map +3 -3
- package/package.json +6 -6
- package/src/bindings-api/index.js +25 -26
- package/src/context-api/HTMLContext.js +3 -3
- package/src/context-api/index.js +13 -17
- package/src/html-imports/_HTMLImportElement.js +13 -15
- package/src/html-imports/index.js +20 -26
- package/src/html-modules/HTMLExportsManager.js +17 -17
- package/src/html-modules/_HTMLImportsContext.js +6 -6
- package/src/html-modules/index.js +31 -37
- package/src/index.js +8 -10
- package/src/{namespaced-html → namespace-api}/index.js +35 -40
- package/src/scoped-js/Compiler.js +7 -7
- package/src/scoped-js/index.js +19 -24
- package/src/targets.browser.js +2 -2
- package/src/util.js +14 -2
- package/test/index.js +12 -10
- package/dist/namespaced-html.js +0 -2
- package/dist/namespaced-html.js.map +0 -7
- package/dist/state-api.js +0 -2
- package/dist/state-api.js.map +0 -7
- /package/src/{namespaced-html → namespace-api}/targets.browser.js +0 -0
- /package/test/{namespaced-html.test.js → namespace-api.test.js} +0 -0
|
@@ -2,39 +2,33 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
|
-
import wqDom from '@webqit/dom';
|
|
6
5
|
import Observer from '@webqit/observer';
|
|
7
6
|
import _HTMLImportsContext from './_HTMLImportsContext.js';
|
|
8
7
|
import HTMLExportsManager from './HTMLExportsManager.js';
|
|
9
|
-
import { _ } from '../util.js';
|
|
8
|
+
import { _, _init } from '../util.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Initializes HTML Modules.
|
|
13
12
|
*
|
|
14
|
-
* @param Object $
|
|
13
|
+
* @param Object $config
|
|
15
14
|
*
|
|
16
15
|
* @return Void
|
|
17
16
|
*/
|
|
18
|
-
export default function init( $
|
|
19
|
-
const
|
|
20
|
-
if ( !window.wq ) { window.wq = {}; }
|
|
21
|
-
window.wq.Observer = Observer;
|
|
22
|
-
window.wq.HTMLImportsContext = class extends _HTMLImportsContext {
|
|
23
|
-
static get params() { return params; }
|
|
24
|
-
};
|
|
25
|
-
// -------
|
|
26
|
-
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
17
|
+
export default function init( $config = {} ) {
|
|
18
|
+
const { config, window } = _init.call( this, 'html-modules', $config, {
|
|
27
19
|
template: { attr: { exportid: 'exportid', extends: 'extends', inherits: 'inherits' }, api: { modules: 'modules', exportid: 'exportid' }, },
|
|
28
20
|
context: { attr: { importscontext: 'importscontext', contextname: 'contextname' }, api: { modules: 'modules' }, },
|
|
29
21
|
export: { attr: { exportid: 'exportid' }, },
|
|
30
22
|
staticsensitivity: true,
|
|
31
23
|
} );
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
config.templateSelector = `template[${ window.CSS.escape( config.template.attr.exportid ) }]`;
|
|
25
|
+
config.ownerContextSelector = [ config.context.attr.contextname, config.context.attr.importscontext ].map( a => `[${ window.CSS.escape( a ) }]` ).join( ',' );
|
|
26
|
+
window.webqit.HTMLImportsContext = class extends _HTMLImportsContext {
|
|
27
|
+
static get config() { return config; }
|
|
28
|
+
};
|
|
29
|
+
window.webqit.Observer = Observer;
|
|
30
|
+
exposeModulesObjects.call( window, config );
|
|
31
|
+
realtime.call( window, config );
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
export { Observer }
|
|
@@ -64,37 +58,37 @@ export function getModulesObject( node, autoCreate = true ) {
|
|
|
64
58
|
/**
|
|
65
59
|
* Exposes HTML Modules with native APIs.
|
|
66
60
|
*
|
|
67
|
-
* @param Object
|
|
61
|
+
* @param Object config
|
|
68
62
|
*
|
|
69
63
|
* @return Void
|
|
70
64
|
*/
|
|
71
|
-
function exposeModulesObjects(
|
|
65
|
+
function exposeModulesObjects( config ) {
|
|
72
66
|
const window = this;
|
|
73
67
|
// Assertions
|
|
74
|
-
if (
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
68
|
+
if ( config.context.api.modules in window.document ) { throw new Error( `document already has a "${ config.context.api.modules }" property!` ); }
|
|
69
|
+
if ( config.template.api.modules in window.HTMLElement.prototype ) { throw new Error( `The "HTMLElement" class already has a "${ config.template.api.modules }" property!` ); }
|
|
70
|
+
if ( config.template.api.exportid in window.HTMLTemplateElement.prototype ) { throw new Error( `The "HTMLTemplateElement" class already has a "${ config.template.api.exportid }" property!` ); }
|
|
77
71
|
// Definitions
|
|
78
|
-
Object.defineProperty( window.document,
|
|
72
|
+
Object.defineProperty( window.document, config.context.api.modules, { get: function() {
|
|
79
73
|
return getModulesObject( window.document );
|
|
80
74
|
} } );
|
|
81
|
-
Object.defineProperty( window.HTMLElement.prototype,
|
|
75
|
+
Object.defineProperty( window.HTMLElement.prototype, config.template.api.modules, { get: function() {
|
|
82
76
|
return getModulesObject( this );
|
|
83
77
|
} } );
|
|
84
|
-
Object.defineProperty( window.HTMLTemplateElement.prototype,
|
|
85
|
-
return this.
|
|
78
|
+
Object.defineProperty( window.HTMLTemplateElement.prototype, config.template.api.exportid, { get: function() {
|
|
79
|
+
return this.getAttribute( config.template.attr.exportid );
|
|
86
80
|
} } );
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
/**
|
|
90
84
|
* Performs realtime capture of elements and builds their contents graph.
|
|
91
85
|
*
|
|
92
|
-
* @param Object
|
|
86
|
+
* @param Object config
|
|
93
87
|
*
|
|
94
88
|
* @return Void
|
|
95
89
|
*/
|
|
96
|
-
function realtime(
|
|
97
|
-
const window = this, { dom, HTMLImportsContext } = window.
|
|
90
|
+
function realtime( config ) {
|
|
91
|
+
const window = this, { dom, HTMLImportsContext } = window.webqit;
|
|
98
92
|
// ------------
|
|
99
93
|
const attachImportsContext = host => {
|
|
100
94
|
const contextId = HTMLImportsContext.createId( host );
|
|
@@ -103,15 +97,15 @@ function realtime( params ) {
|
|
|
103
97
|
const detachImportsContext = ( host, force ) => {
|
|
104
98
|
const contextId = HTMLImportsContext.createId( host );
|
|
105
99
|
HTMLImportsContext.detachFrom( host, contextId, cx => {
|
|
106
|
-
return force || host.matches && !host.matches(
|
|
100
|
+
return force || host.matches && !host.matches( config.ownerContextSelector ) && !Object.keys( cx.modules ).length;
|
|
107
101
|
} );
|
|
108
102
|
};
|
|
109
103
|
// ------------
|
|
110
|
-
dom.realtime( window.document ).observe( [
|
|
104
|
+
dom.realtime( window.document ).observe( [ config.templateSelector, config.ownerContextSelector ], record => {
|
|
111
105
|
record.entrants.forEach( entry => {
|
|
112
|
-
if ( entry.matches(
|
|
106
|
+
if ( entry.matches( config.templateSelector ) ) {
|
|
113
107
|
Object.defineProperty( entry, 'scoped', { value: entry.hasAttribute( 'scoped' ) } );
|
|
114
|
-
const moduleExport = new HTMLExportsManager( entry,
|
|
108
|
+
const moduleExport = new HTMLExportsManager( window, entry, config );
|
|
115
109
|
moduleExport.ownerContext = entry.scoped ? record.target : window.document;
|
|
116
110
|
const ownerContextModulesObj = getModulesObject( moduleExport.ownerContext );
|
|
117
111
|
if ( moduleExport.exportId ) { Observer.set( ownerContextModulesObj, moduleExport.exportId, entry ); }
|
|
@@ -124,8 +118,8 @@ function realtime( params ) {
|
|
|
124
118
|
}
|
|
125
119
|
} );
|
|
126
120
|
record.exits.forEach( entry => {
|
|
127
|
-
if ( entry.matches(
|
|
128
|
-
const moduleExport = HTMLExportsManager.instance( entry,
|
|
121
|
+
if ( entry.matches( config.templateSelector ) ) {
|
|
122
|
+
const moduleExport = HTMLExportsManager.instance( window, entry, config );
|
|
129
123
|
const ownerContextModulesObj = getModulesObject( moduleExport.ownerContext );
|
|
130
124
|
if ( moduleExport.exportId ) { Observer.deleteProperty( ownerContextModulesObj, moduleExport.exportId ); }
|
|
131
125
|
detachImportsContext( moduleExport.ownerContext );
|
|
@@ -133,5 +127,5 @@ function realtime( params ) {
|
|
|
133
127
|
detachImportsContext( entry, true );
|
|
134
128
|
}
|
|
135
129
|
} );
|
|
136
|
-
}, { subtree: true, timing: 'sync', staticSensitivity:
|
|
130
|
+
}, { subtree: true, timing: 'sync', staticSensitivity: config.staticsensitivity } );
|
|
137
131
|
}
|
package/src/index.js
CHANGED
|
@@ -5,25 +5,23 @@
|
|
|
5
5
|
import Observer from '@webqit/observer';
|
|
6
6
|
import BindingsAPI from './bindings-api/index.js';
|
|
7
7
|
import ContextAPI from './context-api/index.js';
|
|
8
|
+
import NamespaceAPI from './namespace-api/index.js';
|
|
8
9
|
import HTMLModules from './html-modules/index.js';
|
|
9
10
|
import HTMLImports from './html-imports/index.js';
|
|
10
|
-
import NamespacedHTML from './namespaced-html/index.js';
|
|
11
11
|
import ScopedJS from './scoped-js/index.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @init
|
|
15
15
|
*/
|
|
16
16
|
export default function init( configs = {} ) {
|
|
17
|
-
if ( !this.
|
|
18
|
-
if ( this.wq.oohtml ) return;
|
|
19
|
-
this.wq.oohtml = {};
|
|
17
|
+
if ( !this.webqit ) { this.webqit = {}; }
|
|
20
18
|
// --------------
|
|
21
|
-
BindingsAPI.call(this, ( configs.
|
|
22
|
-
ContextAPI.call( this, ( configs.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
ScopedJS.call( this, ( configs.
|
|
19
|
+
BindingsAPI.call(this, ( configs.BINDINGS_API || {} ) );
|
|
20
|
+
ContextAPI.call( this, ( configs.CONTEXT_API || {} ) );
|
|
21
|
+
NamespaceAPI.call(this, ( configs.NAMESPACE_API || {} ) );
|
|
22
|
+
HTMLModules.call( this, ( configs.HTML_MODULES || {} ) );
|
|
23
|
+
HTMLImports.call( this, ( configs.HTML_IMPORTS || {} ) );
|
|
24
|
+
ScopedJS.call( this, ( configs.SCOPED_JS || {} ) );
|
|
27
25
|
// --------------
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -3,30 +3,25 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import Observer from '@webqit/observer';
|
|
6
|
-
import
|
|
7
|
-
import { _ } from '../util.js';
|
|
6
|
+
import { _, _init } from '../util.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @init
|
|
11
10
|
*
|
|
12
|
-
* @param Object $
|
|
11
|
+
* @param Object $config
|
|
13
12
|
*/
|
|
14
|
-
export default function init( $
|
|
15
|
-
|
|
16
|
-
if ( !window.wq ) { window.wq = {}; }
|
|
17
|
-
window.wq.Observer = Observer;
|
|
18
|
-
// -------
|
|
19
|
-
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
13
|
+
export default function init( $config = {} ) {
|
|
14
|
+
const { config, window } = _init.call( this, 'namespace-api', $config, {
|
|
20
15
|
attr: { namespace: 'namespace', id: ':id', },
|
|
21
16
|
api: { namespace: 'namespace', },
|
|
22
17
|
staticsensitivity: true,
|
|
23
18
|
eagermode: true,
|
|
24
19
|
} );
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exposeNamespaceObjects.call(
|
|
29
|
-
realtime.call(
|
|
20
|
+
config.idSelector = `[${ window.CSS.escape( config.attr.id ) }]`;
|
|
21
|
+
config.namespaceSelector = `[${ window.CSS.escape( config.attr.namespace ) }]`;
|
|
22
|
+
window.webqit.Observer = Observer;
|
|
23
|
+
exposeNamespaceObjects.call( window, config );
|
|
24
|
+
realtime.call( window, config );
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
export { Observer }
|
|
@@ -34,21 +29,21 @@ export { Observer }
|
|
|
34
29
|
/**
|
|
35
30
|
* Exposes Namespaced HTML with native APIs.
|
|
36
31
|
*
|
|
37
|
-
* @param Object
|
|
32
|
+
* @param Object config
|
|
38
33
|
*
|
|
39
34
|
* @return Void
|
|
40
35
|
*/
|
|
41
|
-
function exposeNamespaceObjects(
|
|
36
|
+
function exposeNamespaceObjects( config ) {
|
|
42
37
|
const window = this;
|
|
43
38
|
// Assertions
|
|
44
|
-
if (
|
|
45
|
-
if (
|
|
39
|
+
if ( config.api.namespace in window.document ) { throw new Error( `document already has a "${ config.api.namespace }" property!` ); }
|
|
40
|
+
if ( config.api.namespace in window.Element.prototype ) { throw new Error( `The "Element" class already has a "${ config.api.namespace }" property!` ); }
|
|
46
41
|
// Definitions
|
|
47
|
-
Object.defineProperty( window.document,
|
|
48
|
-
return Observer.proxy( getNamespaceObject.call( window, window.document,
|
|
42
|
+
Object.defineProperty( window.document, config.api.namespace, { get: function() {
|
|
43
|
+
return Observer.proxy( getNamespaceObject.call( window, window.document, config ) );
|
|
49
44
|
} });
|
|
50
|
-
Object.defineProperty( window.Element.prototype,
|
|
51
|
-
return Observer.proxy( getNamespaceObject.call( window, this,
|
|
45
|
+
Object.defineProperty( window.Element.prototype, config.api.namespace, { get: function() {
|
|
46
|
+
return Observer.proxy( getNamespaceObject.call( window, this, config ) );
|
|
52
47
|
} } );
|
|
53
48
|
}
|
|
54
49
|
|
|
@@ -59,15 +54,15 @@ function exposeNamespaceObjects( params ) {
|
|
|
59
54
|
*
|
|
60
55
|
* @return Object
|
|
61
56
|
*/
|
|
62
|
-
function getNamespaceObject( node,
|
|
57
|
+
function getNamespaceObject( node, config ) {
|
|
63
58
|
const window = this;
|
|
64
59
|
if ( !_( node ).has( 'namespace' ) ) {
|
|
65
60
|
const namespaceObj = Object.create( null );
|
|
66
61
|
Observer.intercept( namespaceObj, 'get', ( event, receiver, next ) => {
|
|
67
|
-
if ( Observer.has( namespaceObj, event.key ) || !
|
|
68
|
-
const selector = `[${ window.CSS.escape(
|
|
62
|
+
if ( Observer.has( namespaceObj, event.key ) || !config.eagermode ) return next();
|
|
63
|
+
const selector = `[${ window.CSS.escape( config.attr.id ) }="${ event.key }"]`;
|
|
69
64
|
const resultNode = Array.from( node.querySelectorAll( selector ) ).filter( idNode => {
|
|
70
|
-
const ownerRoot = idNode.parentNode.closest(
|
|
65
|
+
const ownerRoot = idNode.parentNode.closest( config.namespaceSelector );
|
|
71
66
|
if ( node === window.document ) {
|
|
72
67
|
// Only IDs without a scope actually belong to the document scope
|
|
73
68
|
return !ownerRoot;
|
|
@@ -85,17 +80,17 @@ function getNamespaceObject( node, params ) {
|
|
|
85
80
|
/**
|
|
86
81
|
* Performs realtime capture of elements and builds their relationships.
|
|
87
82
|
*
|
|
88
|
-
* @param Object
|
|
83
|
+
* @param Object config
|
|
89
84
|
*
|
|
90
85
|
* @return Void
|
|
91
86
|
*/
|
|
92
|
-
function realtime(
|
|
93
|
-
const window = this, { dom } = window.
|
|
87
|
+
function realtime( config ) {
|
|
88
|
+
const window = this, { dom } = window.webqit;
|
|
94
89
|
// ----------------
|
|
95
90
|
const handle = ( target, entry, incoming ) => {
|
|
96
|
-
const identifier = entry.getAttribute(
|
|
97
|
-
const ownerRoot = target.closest(
|
|
98
|
-
const namespaceObj = getNamespaceObject.call( window, ownerRoot,
|
|
91
|
+
const identifier = entry.getAttribute( config.attr.id );
|
|
92
|
+
const ownerRoot = target.closest( config.namespaceSelector ) || _( entry ).get( 'ownerNamespace' ) || window.document;
|
|
93
|
+
const namespaceObj = getNamespaceObject.call( window, ownerRoot, config );
|
|
99
94
|
if ( incoming ) {
|
|
100
95
|
if ( Observer.get( namespaceObj, identifier ) !== entry ) {
|
|
101
96
|
_( entry ).set( 'ownerNamespace', ownerRoot );
|
|
@@ -106,17 +101,17 @@ function realtime( params ) {
|
|
|
106
101
|
Observer.deleteProperty( namespaceObj, identifier );
|
|
107
102
|
}
|
|
108
103
|
};
|
|
109
|
-
dom.realtime( window.document ).observe(
|
|
104
|
+
dom.realtime( window.document ).observe( config.idSelector, record => {
|
|
110
105
|
record.entrants.forEach( entry => handle( record.target, entry, true ) );
|
|
111
106
|
record.exits.forEach( entry => handle( record.target, entry, false ) );
|
|
112
|
-
}, { subtree: true, timing: 'sync', staticSensitivity:
|
|
107
|
+
}, { subtree: true, timing: 'sync', staticSensitivity: config.staticsensitivity } );
|
|
113
108
|
// ----------------
|
|
114
|
-
if (
|
|
115
|
-
dom.realtime( window.document, 'attr' ).observe(
|
|
116
|
-
const ownerRoot = record.target.parentNode?.closest(
|
|
117
|
-
const ownerRootNamespaceObj = getNamespaceObject.call( window, ownerRoot,
|
|
118
|
-
const namespaceObj = getNamespaceObject.call( window, record.target,
|
|
119
|
-
if ( record.target.matches(
|
|
109
|
+
if ( config.staticsensitivity ) {
|
|
110
|
+
dom.realtime( window.document, 'attr' ).observe( config.namespaceSelector, record => {
|
|
111
|
+
const ownerRoot = record.target.parentNode?.closest( config.namespaceSelector ) || _( record.target ).get( 'ownerNamespace' ) || window.document;
|
|
112
|
+
const ownerRootNamespaceObj = getNamespaceObject.call( window, ownerRoot, config );
|
|
113
|
+
const namespaceObj = getNamespaceObject.call( window, record.target, config );
|
|
114
|
+
if ( record.target.matches( config.namespaceSelector ) ) {
|
|
120
115
|
for ( const [ key, entry ] of Object.entries( ownerRootNamespaceObj ) ) {
|
|
121
116
|
if ( !record.target.contains( entry.parentNode ) ) continue;
|
|
122
117
|
Observer.deleteProperty( ownerRootNamespaceObj, key );
|
|
@@ -25,11 +25,11 @@ export default class Compiler {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Set window property
|
|
28
|
-
constructor( window,
|
|
28
|
+
constructor( window, config, executeCallback ) {
|
|
29
29
|
this.window = window;
|
|
30
|
-
this.
|
|
30
|
+
this.config = config;
|
|
31
31
|
// This is a global function
|
|
32
|
-
window.
|
|
32
|
+
window.webqit.oohtml.Script.run = ( execHash ) => {
|
|
33
33
|
const exec = this.constructor.fromHash( execHash );
|
|
34
34
|
if ( !exec ) throw new Error( `Argument must be a valid exec hash.` );
|
|
35
35
|
const { script, compiledScript, thisContext } = exec;
|
|
@@ -37,7 +37,7 @@ export default class Compiler {
|
|
|
37
37
|
if ( !thisContext.scripts ) { Object.defineProperty( thisContext, 'scripts', { value: new Set } ); }
|
|
38
38
|
thisContext.scripts.add( script );
|
|
39
39
|
}
|
|
40
|
-
switch (
|
|
40
|
+
switch ( config.script.retention ) {
|
|
41
41
|
case 'dispose':
|
|
42
42
|
script.remove();
|
|
43
43
|
break;
|
|
@@ -54,7 +54,7 @@ export default class Compiler {
|
|
|
54
54
|
// Compile scipt
|
|
55
55
|
compile( script, thisContext ) {
|
|
56
56
|
const _static = this.constructor;
|
|
57
|
-
const {
|
|
57
|
+
const { webqit: { oohtml, SubscriptFunction } } = this.window;
|
|
58
58
|
const cache = oohtml.Script.compileCache[ script.contract ? 0 : 1 ];
|
|
59
59
|
const sourceHash = _static.toHash( script.textContent );
|
|
60
60
|
// Script instances are parsed only once
|
|
@@ -72,7 +72,7 @@ export default class Compiler {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
// Let's obtain a material functions
|
|
75
|
-
let _Function, { parserParams, compilerParams, runtimeParams } = this.
|
|
75
|
+
let _Function, { parserParams, compilerParams, runtimeParams } = this.config.advanced;
|
|
76
76
|
if ( script.contract ) {
|
|
77
77
|
parserParams = { ...parserParams, allowAwaitOutsideFunction: script.type === 'module' };
|
|
78
78
|
runtimeParams = { ...runtimeParams, async: script.type === 'module' };
|
|
@@ -93,7 +93,7 @@ export default class Compiler {
|
|
|
93
93
|
cache.set( sourceHash, compiledScript );
|
|
94
94
|
}
|
|
95
95
|
const execHash = _static.toHash( { script, compiledScript, thisContext } );
|
|
96
|
-
script.textContent = `
|
|
96
|
+
script.textContent = `webqit.oohtml.Script.run('${ execHash }');`;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// Match import statements
|
package/src/scoped-js/index.js
CHANGED
|
@@ -6,35 +6,30 @@ import { resolveParams } from '@webqit/subscript/src/params.js';
|
|
|
6
6
|
import SubscriptFunction from '@webqit/subscript/src/SubscriptFunctionLite.js';
|
|
7
7
|
import Observer from '@webqit/observer';
|
|
8
8
|
import Compiler from './Compiler.js';
|
|
9
|
-
import
|
|
9
|
+
import { _init } from '../util.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @init
|
|
13
13
|
*
|
|
14
|
-
* @param Object $
|
|
14
|
+
* @param Object $config
|
|
15
15
|
*/
|
|
16
|
-
export default function init(
|
|
17
|
-
|
|
18
|
-
if ( !window.wq ) { window.wq = {}; }
|
|
19
|
-
if ( !window.wq.oohtml ) { window.wq.oohtml = {}; }
|
|
20
|
-
window.wq.oohtml.Script = { compileCache: [ new Map, new Map, ] };
|
|
21
|
-
window.wq.SubscriptFunction = $params.SubscriptFunction/* allow for injection, e.g. from test runner */ || SubscriptFunction;
|
|
22
|
-
window.wq.Observer = Observer;
|
|
23
|
-
// -------
|
|
24
|
-
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
16
|
+
export default function init( { advanced = {}, ...$config } ) {
|
|
17
|
+
const { config, window } = _init.call( this, 'scoped-js', $config, {
|
|
25
18
|
script: { retention: 'retain', mimeType: '' },
|
|
26
|
-
|
|
27
|
-
parserParams: { allowReturnOutsideFunction: false, allowSuperOutsideMethod: false
|
|
28
|
-
compilerParams: { globalsNoObserve: [ 'alert' ]
|
|
29
|
-
runtimeParams: { apiVersion: 2
|
|
19
|
+
advanced: resolveParams( advanced, {
|
|
20
|
+
parserParams: { allowReturnOutsideFunction: false, allowSuperOutsideMethod: false },
|
|
21
|
+
compilerParams: { globalsNoObserve: [ 'alert' ] },
|
|
22
|
+
runtimeParams: { apiVersion: 2 },
|
|
30
23
|
} ),
|
|
31
24
|
} );
|
|
32
|
-
|
|
25
|
+
config.scriptSelector = ( Array.isArray( config.script.mimeType ) ? config.script.mimeType : [ config.script.mimeType ] ).reduce( ( selector, mm ) => {
|
|
33
26
|
const qualifier = mm ? `[type=${ window.CSS.escape( mm ) }]` : '';
|
|
34
27
|
return selector.concat( `script${ qualifier }[scoped],script${ qualifier }[contract]` );
|
|
35
28
|
}, [] ).join( ',' );
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
window.webqit.oohtml.Script = { compileCache: [ new Map, new Map, ] };
|
|
30
|
+
window.webqit.SubscriptFunction = $config.SubscriptFunction/* allow for injection, e.g. from test runner */ || SubscriptFunction;
|
|
31
|
+
window.webqit.Observer = Observer;
|
|
32
|
+
realtime.call( window, config );
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
export {
|
|
@@ -65,7 +60,7 @@ export function execute( compiledScript, thisContext, script ) {
|
|
|
65
60
|
} );
|
|
66
61
|
} );
|
|
67
62
|
}
|
|
68
|
-
const window = this, { dom } = window.
|
|
63
|
+
const window = this, { dom } = window.webqit;
|
|
69
64
|
dom.realtime( window.document ).observe( thisContext, () => {
|
|
70
65
|
if ( script.contract ) {
|
|
71
66
|
// Rerending processes,,,
|
|
@@ -82,14 +77,14 @@ export function execute( compiledScript, thisContext, script ) {
|
|
|
82
77
|
/**
|
|
83
78
|
* Performs realtime capture of elements and builds their relationships.
|
|
84
79
|
*
|
|
85
|
-
* @param Object
|
|
80
|
+
* @param Object config
|
|
86
81
|
*
|
|
87
82
|
* @return Void
|
|
88
83
|
*/
|
|
89
|
-
function realtime(
|
|
90
|
-
const window = this, { dom } = window.
|
|
91
|
-
const compiler = new Compiler( window,
|
|
92
|
-
dom.realtime( window.document ).observe(
|
|
84
|
+
function realtime( config ) {
|
|
85
|
+
const window = this, { dom } = window.webqit;
|
|
86
|
+
const compiler = new Compiler( window, config, execute ), handled = () => {};
|
|
87
|
+
dom.realtime( window.document ).observe( config.scriptSelector, record => {
|
|
93
88
|
record.entrants.forEach( script => {
|
|
94
89
|
if ( 'contract' in script ) return handled( script );
|
|
95
90
|
Object.defineProperty( script, 'contract', { value: script.hasAttribute( 'contract' ) } );
|
package/src/targets.browser.js
CHANGED
package/src/util.js
CHANGED
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
|
+
import webqitDom from '@webqit/dom';
|
|
5
6
|
import { _internals } from '@webqit/util/js/index.js';
|
|
7
|
+
import { _inherit } from '@webqit/util/obj/index.js';
|
|
6
8
|
|
|
7
|
-
export const _ = (
|
|
9
|
+
export const _ = ( ...args ) => _internals( 'oohtml', ...args );
|
|
8
10
|
|
|
9
|
-
export
|
|
11
|
+
export function _init( name, $config, $defaults ) {
|
|
12
|
+
const window = this, dom = webqitDom.call( window );
|
|
13
|
+
window.webqit || ( window.webqit = {} );
|
|
14
|
+
window.webqit.oohtml || ( window.webqit.oohtml = {} );
|
|
15
|
+
window.webqit.oohtml.configs || ( window.webqit.oohtml.configs = {} );
|
|
16
|
+
const config = _inherit( 1, dom.meta( name ).json(), $config, $defaults );
|
|
17
|
+
window.webqit.oohtml.configs[ name.toUpperCase().replace( '-', '_' ) ] = config;
|
|
18
|
+
return { config, dom, window };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function _compare( a, b, depth = 1, objectSizing = false ) {
|
|
10
22
|
if ( depth && typeof a === 'object' && a && typeof b === 'object' && b && ( !objectSizing || Object.keys( a ).length === Object.keys( b ).length ) ) {
|
|
11
23
|
for ( let key in a ) {
|
|
12
24
|
if ( !_compare( a[ key ], b[ key ], depth - 1, objectSizing ) ) return false;
|
package/test/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createContext, compileFunction, runInContext } from 'vm';
|
|
|
7
7
|
import jsdom from 'jsdom';
|
|
8
8
|
import init, { Observer } from '../src/index.js';
|
|
9
9
|
import { SubscriptFunction } from '@webqit/subscript';
|
|
10
|
-
import
|
|
10
|
+
import webqitDom from '@webqit/dom';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* -------
|
|
@@ -16,7 +16,7 @@ import wqDom from '@webqit/dom';
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
export { Observer };
|
|
19
|
-
export const _ = (
|
|
19
|
+
export const _ = ( ...args ) => _internals( 'oohtml', ...args );
|
|
20
20
|
export function delay( duration, callback = undefined ) {
|
|
21
21
|
return new Promise( res => {
|
|
22
22
|
setTimeout( () => res( callback && callback() ), duration );
|
|
@@ -35,7 +35,7 @@ export function createDocument( head = '', body = '', callback = null, ) {
|
|
|
35
35
|
url: 'http://localhost',
|
|
36
36
|
beforeParse( window ) {
|
|
37
37
|
init.call( window );
|
|
38
|
-
if ( callback ) callback( window, window.
|
|
38
|
+
if ( callback ) callback( window, window.webqit.dom );
|
|
39
39
|
}
|
|
40
40
|
} );
|
|
41
41
|
return instance.window;
|
|
@@ -55,16 +55,18 @@ export function createDocumentForScopedJS( head = '', body = '', callback = null
|
|
|
55
55
|
window.testRecords = [];
|
|
56
56
|
createContext( window );
|
|
57
57
|
// Running advanced scripts
|
|
58
|
-
init.call( window, {
|
|
58
|
+
init.call( window, { SCOPED_JS: {
|
|
59
59
|
SubscriptFunction,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
advanced: {
|
|
61
|
+
runtimeParams: {
|
|
62
|
+
compileFunction: ( code, parameters ) => compileFunction( code, parameters, {
|
|
63
|
+
parsingContext: window,
|
|
64
|
+
} ),
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
67
|
} } );
|
|
66
68
|
// Running basic scripts
|
|
67
|
-
const dom =
|
|
69
|
+
const dom = webqitDom.call( window );
|
|
68
70
|
if ( params.runScripts !== 'dangerously' ) {
|
|
69
71
|
dom.realtime( window.document ).observe( 'script', record => {
|
|
70
72
|
record.entrants.forEach( script => {
|
|
@@ -74,7 +76,7 @@ export function createDocumentForScopedJS( head = '', body = '', callback = null
|
|
|
74
76
|
}, { subtree: true } );
|
|
75
77
|
}
|
|
76
78
|
// Sync callback?
|
|
77
|
-
if ( callback ) callback( window, window.
|
|
79
|
+
if ( callback ) callback( window, window.webqit.dom );
|
|
78
80
|
}
|
|
79
81
|
} );
|
|
80
82
|
return instance.window;
|
package/dist/namespaced-html.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(()=>{var Ye=Object.defineProperty;var Re=(r,e)=>{for(var n in e)Ye(r,n,{get:e[n],enumerable:!0})};var Te={};Re(Te,{apply:()=>Ee,batch:()=>gt,construct:()=>Ae,deep:()=>mt,defineProperties:()=>yt,defineProperty:()=>Oe,deleteProperty:()=>ve,get:()=>$,getOwnPropertyDescriptor:()=>xe,getOwnPropertyDescriptors:()=>ht,getPrototypeOf:()=>we,has:()=>fe,intercept:()=>pt,isExtensible:()=>be,observe:()=>dt,ownKeys:()=>se,preventExtensions:()=>Pe,set:()=>Q,setPrototypeOf:()=>Se});function x(r){return!Array.isArray(r)&&typeof r=="object"&&r}function B(r){return typeof r}function E(r,...e){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var n=globalThis.WebQitInternalsRegistry.get(r);if(!n){if(n=new Map,e[0]===!1)return n;globalThis.WebQitInternalsRegistry.set(r,n)}for(var t,i;t=e.shift();)if((i=n)&&!(n=n.get(t))){if(n=new Map,e[0]===!1)return n;i.set(t,n)}return n}function _(r){return Array.isArray(r)}function D(r){return typeof r=="function"}function le(r){return D(r)&&/^class\s?/.test(Function.prototype.toString.call(r))}function J(r){return r===null||r===""}function M(r){return arguments.length&&(r===void 0||typeof r>"u")}function v(r){return Array.isArray(r)||typeof r=="object"&&r||D(r)}function ae(r){return J(r)||M(r)||r===!1||r===0||v(r)&&!Object.keys(r).length}function b(r){return D(r)||r&&{}.toString.call(r)==="[object function]"}function X(r){return r instanceof Number||typeof r=="number"}function T(r){return X(r)||r!==!0&&r!==!1&&r!==null&&r!==""&&!isNaN(r*1)}function ne(r){return r instanceof String||typeof r=="string"&&r!==null}function me(r){return!ne(r)&&!M(r.length)}function ie(r,...e){return e.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r}function de(t,e){e=e||Object.prototype,e=e&&!_(e)?[e]:e;for(var n=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)n.push(t),t=t?Object.getPrototypeOf(t):null;return n}function pe(r,e){var n=[];return de(r,e).forEach(t=>{ie(n,...Object.getOwnPropertyNames(t))}),n}function I(r,e,n=!1,t=!1,i=!1){var o=0,s=r.shift();if((T(s)||s===!0||s===!1)&&(o=s,s=r.shift()),!r.length)throw new Error("_merge() requires two or more array/objects.");return r.forEach((l,f)=>{!v(l)&&!b(l)||(n?pe(l):Object.keys(l)).forEach(u=>{if(!!e(u,s,l,f)){var c=s[u],a=l[u];if((_(c)&&_(a)||x(c)&&x(a))&&(o===!0||o>0))s[u]=_(c)&&_(a)?[]:{},I([T(o)?o-1:o,s[u],c,a],e,n,t,i);else if(_(s)&&_(l))t?s[u]=a:s.push(a);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(l,u)):s[u]=l[u]}catch{}}})}),s}function Y(...r){return I(r,(e,n,t)=>!0,!1,!1,!1)}function A(r,e=!0){return _(r)?r:!e&&x(r)?[r]:r!==!1&&r!==0&&ae(r)?[]:me(r)?Array.prototype.slice.call(r):x(r)?Object.values(r):[r]}var j=class{constructor(e,n){this.registry=e,Object.assign(this,{...n,target:e.target}),this.params.signal&&this.params.signal.addEventListener("abort",()=>this.remove())}remove(){return this.removed=!0,this.registry.removeRegistration(this)}};var Z=class extends j{constructor(){super(...arguments),Object.defineProperty(this,"abortController",{value:new AbortController}),Object.defineProperty(this,"signal",{value:this.abortController.signal})}remove(){this.abortController.abort(),super.remove()}fire(e){let n=e,t=this.filter;if(t!==1/0&&(t=A(t))&&(n=e.filter(i=>t.includes(i.key))),n.length)return this.filter===1/0||Array.isArray(this.filter)?this.handler(n,this):this.handler(n[0],this)}};var L=class{constructor(e){this.target=e,this.entries=[]}addRegistration(e){return this.entries.push(e),e}removeRegistration(e){this.entries=this.entries.filter(n=>n!==e)}static _getInstance(e,n,t=!0,i=this.__namespace){if(!v(n))throw new Error(`Subject must be of type object; "${B(n)}" given!`);let o=this;return i&&globalThis.WebQitObserverNamespaceRegistry.has(e+"-"+i)&&(o=globalThis.WebQitObserverNamespaceRegistry.get(e+"-"+i),e+="-"+i),!E(n,"observerApi").has(e)&&t&&E(n,"observerApi").set(e,new o(n)),E(n,"observerApi").get(e)}static _namespace(e,n,t=null){if(e+="-"+n,arguments.length===2)return globalThis.WebQitObserverNamespaceRegistry.get(e);if(!(t.prototype instanceof this))throw new Error(`The implementation of the namespace ${this.name}.${n} must be a subclass of ${this.name}.`);globalThis.WebQitObserverNamespaceRegistry.set(e,t),t.__namespace=n}};globalThis.WebQitObserverNamespaceRegistry||(globalThis.WebQitObserverNamespaceRegistry=new Map);var F=class extends L{static getInstance(e,n=!0,t=null){return super._getInstance("listeners",...arguments)}static namespace(e,n=null){return super._namespace("listeners",...arguments)}constructor(e){super(e),this.batches=[]}addRegistration(e,n,t){return super.addRegistration(new Z(this,{filter:e,handler:n,params:t}))}emit(e){if(this.batches.length){this.batches[0].events.push(...e);return}this.entries.forEach(n=>n.fire(e))}batch(e){this.batches.unshift({entries:[...this.entries],events:[]}),e();let n=this.batches.shift();!n.events.length||n.entries.forEach(t=>t.fire(n.events))}};var K=class extends j{exec(e,n,t){return this.running||!this.traps[e.type]?n(...Array.prototype.slice.call(arguments,2)):(this.running=!0,this.traps[e.type](e,t,(...i)=>(this.running=!1,n(...i))))}};var q=class extends L{static getInstance(e,n=!0,t=null){return super._getInstance("traps",...arguments)}static namespace(e,n=null){return super._namespace("traps",...arguments)}addRegistration(e){return super.addRegistration(new K(this,e))}emit(e,n=null){let t=this;return function i(o,...s){let l=t.entries[o];return l?l.exec(e,(...f)=>i(o+1,...f),...s):n?n(e,...s):s[0]}(0)}};var C=class{constructor(e,n){if(this.target=e,!n.type)throw new Error("Descriptor type must be given in definition!");Object.assign(this,n)}};var _e={};Re(_e,{accessorize:()=>ut,proxy:()=>at,unaccessorize:()=>lt,unproxy:()=>oe});function ut(r,e,n={}){r=ye(r);let t=E(r,"accessorizedProps");function i(f){let u,c=r;for(;!u&&(c=Object.getPrototypeOf(c));)u=Object.getOwnPropertyDescriptor(c,f);return u?{proto:c,descriptor:u}:{descriptor:{value:void 0}}}function o(f){if(t.has(f))return!0;let u=i(f);u.getValue=function(){return"get"in this.descriptor?this.descriptor.get():this.descriptor.value},u.setValue=function(g){return"set"in this.descriptor?this.descriptor.set(g):this.descriptor.value=g},u.intact=function(){let g=Object.getOwnPropertyDescriptor(r,f);return g.get===h.get&&g.set===h.set&&t.get(f)===this},u.restore=function(){return this.intact()?(this.proto!==r?delete r[f]:Object.defineProperty(r,f,this.descriptor),t.delete(f),!0):!1},t.set(f,u);let{enumerable:c=!0,configurable:a=!0}=u.descriptor,h={enumerable:c,configurable:a};["value","set"].some(g=>g in u.descriptor)&&(h.set=function(g){return Q(this,f,g,n)}),["value","get"].some(g=>g in u.descriptor)&&(h.get=function(){return $(this,f,n)});try{return Object.defineProperty(r,f,h),!0}catch{return t.delete(f),!1}}let l=(Array.isArray(e)?e:e===void 0?Object.keys(r):[e]).map(o);return e===void 0||Array.isArray(e)?l:l[0]}function lt(r,e,n={}){r=ye(r);let t=E(r,"accessorizedProps");function i(l){return t.has(l)?t.get(l).restore():!0}let s=(Array.isArray(e)?e:e===void 0?Object.keys(r):[e]).map(i);return e===void 0||Array.isArray(e)?s:s[0]}function at(r,e={}){r=ye(r);let n=new Proxy(r,{apply:(t,i,o)=>Ee(t,i,o,e),construct:(t,i,o=null)=>Ae(t,i,o,e),defineProperty:(t,i,o)=>Oe(t,i,o,e),deleteProperty:(t,i)=>ve(t,i,e),get:(t,i,o=null)=>{let s=$(t,i,{...e,receiver:o});return e.proxyAutoBinding!==!1&&b(s)&&!le(s)?s.bind(n):s},getOwnPropertyDescriptor:(t,i)=>xe(t,i,e),getPrototypeOf:t=>we(t,e),has:(t,i)=>fe(t,i,e),isExtensible:t=>be(t,e),ownKeys:t=>se(t,e),preventExtensions:t=>Pe(t,e),set:(t,i,o,s=null)=>Q(t,i,o,{...e,receiver:s}),setPrototypeOf:(t,i)=>Se(t,i,e)});return E(n).set(n,r),n}function oe(r){return E(r,!1).get(r)||r}function ye(r){if(!r||!v(r))throw new Error("Target must be of type object!");return oe(r)}function mt(r,e,n,t=o=>o,i={}){return function o(s,l,f){let u=l[f.level];return f.level<l.length-1?f={...f,preflight:!0}:f={...f,preflight:i.preflight},n(s,u,(c,...a)=>{let h=(p={})=>({...f,...p,level:f.level+1}),g=p=>{p instanceof C&&(p.path=[p.key],s instanceof C&&(p.path=s.path.concat(p.key),p.context=s))};if(ce(u)&&Array.isArray(c))return c.forEach(g),f.level===l.length-1||!c.length&&f.midwayResults?t(c,...a):c.map(p=>o(p,l,h(...a)));g(c);let m=v(V(c,!1));return f.level===l.length-1||!m&&f.midwayResults?t(c,...a):m&&o(c,l,h(...a))},f)}(r,e.slice(0),{...i,level:0})}function dt(r,e,n,t={}){if(r=V(r),b(arguments[1])&&([,n,t={}]=arguments,e=1/0),!b(n))throw new Error(`Handler must be a function; "${B(n)}" given!`);let i=De(r,e,n,t);return t.preflight?(t={...t,descripted:!0},delete t.live,$(r,e,i,t)):i()}function pt(r,e,n={}){return r=V(r),x(e)||([,,,n={}]=arguments,e={[arguments[1]]:arguments[2]}),q.getInstance(r,!0,n.namespace).addRegistration({traps:e,params:n})}function xe(r,e,n=i=>i,t={}){return R(r,"getOwnPropertyDescriptor",{key:e},n,t)}function ht(r,e,n=i=>i,t={}){return R(r,"getOwnPropertyDescriptors",{key:e},n,t)}function we(r,e=t=>t,n={}){return R(r,"getPrototypeOf",{},e,n)}function be(r,e=t=>t,n={}){return R(r,"isExtensible",{},e,n)}function se(r,e=t=>t,n={}){return R(r,"ownKeys",{},e,n)}function fe(r,e,n=i=>i,t={}){return R(r,"has",{key:e},n,t)}function $(r,e,n=i=>i,t={}){let i;return r=V(r),x(n)?[t,n]=[n,o=>o]:t.live&&(i=!0),_t(r,e,o=>{let s=[...o];return function l(f,u,c){if(!u.length)return c(f);let a=u.shift();function h(p,d=void 0){let y=S=>(p.value=S,l(f.concat(t.live||t.descripted?p:S),u,c));if(arguments.length>1)return y(d);let w=E(r,"accessorizedProps",!1),O=w&&w.get(p.key);return O&&O.intact()?y(O.getValue()):y(Reflect.get(r,p.key,...t.receiver?[t.receiver]:[]))}let g=new C(r,{type:"get",key:a,value:void 0,related:s}),m=q.getInstance(r,!1,t.namespace);return m?m.emit(g,h):h(g)}([],o.slice(0),l=>{let f=ce(e)?l:l[0];return i?De(r,e,n,t)(f):n(f)})})}function gt(r,e,n={}){return F.getInstance(r,!0,n.namespace).batch(e)}function Q(r,e,n,t=s=>s,i={},o=!1){r=V(r);let s=[[e,n]];x(e)&&([,,t=f=>f,i={},o=!1]=arguments,s=Object.entries(e)),x(t)&&([o,i,t]=[typeof i=="boolean"?i:!1,t,f=>f]);let l=s.map(([f])=>f);return function f(u,c,a){if(!c.length)return a(u);let[h,g]=c.shift();function m(d,y=void 0){let w=G=>(d.status=G,f(u.concat(d),c,a));if(arguments.length>1)return w(d,y);let O=E(r,"accessorizedProps",!1),S=O&&O.get(d.key);return d.type==="defineProperty"?(S&&!S.restore()&&w(!1),Object.defineProperty(r,d.key,d.value),w(!0)):S&&S.intact()?w(S.setValue(d.value)):w(Reflect.set(r,d.key,d.value))}function p(d,y){let w=new C(r,{type:o?"defineProperty":"set",key:h,value:g,isUpdate:d,oldValue:y,related:[...l],detail:i.detail}),O=q.getInstance(r,!1,i.namespace);return O?O.emit(w,m):m(w)}return fe(r,h,d=>!d||i.oldValue!==!0?p(d):$(r,h,y=>p(d,y),i),i)}([],s.slice(0),f=>{let u=F.getInstance(r,!1,i.namespace);return u&&u.emit(f),t(ce(e)?f.map(c=>c.status):f[0].status)})}function Oe(r,e,n,t=o=>o,i={}){return Q(r,e,n,t,i,!0)}function yt(r,e,n=i=>i,t={}){return Q(r,e,n,t,!0)}function ve(r,e,n=i=>i,t={}){r=V(r),x(n)&&([t,n]=[n,s=>s]);let i=A(e),o=[...i];return function s(l,f,u){if(!f.length)return u(l);let c=f.shift();function a(g,m=void 0){let p=w=>(g.status=w,s(l.concat(g),f,u));if(arguments.length>1)return p(g,m);let d=E(r,"accessorizedProps",!1),y=d&&d.get(g.key);return y&&!y.restore()&&p(!1),p(Reflect.deleteProperty(r,g.key))}function h(g){let m=new C(r,{type:"deleteProperty",key:c,oldValue:g,related:[...o],detail:t.detail}),p=q.getInstance(r,!1,t.namespace);return p?p.emit(m,a):a(m)}return t.oldValue===!1?h():$(r,c,h,t)}([],i.slice(0),s=>{let l=F.getInstance(r,!1,t.namespace);return l&&l.emit(s),n(ce(e)?s.map(f=>f.status):s[0].status)})}function Ae(r,e,n=null,t=o=>o,i={}){return R(r,"construct",arguments.length>2?{argumentsList:e,newTarget:n}:{argumentsList:e},t,i)}function Ee(r,e,n,t=o=>o,i={}){return R(r,"apply",{thisArgument:e,argumentsList:n},t,i)}function Se(r,e,n=i=>i,t={}){return R(r,"setPrototypeOf",{proto:e},n,t)}function Pe(r,e=t=>t,n={}){return R(r,"preventExtensions",{},e,n)}function De(r,e,n,t={}){let i;t.signal||(i=new AbortController,t={...t,signal:i.signal});let o=F.getInstance(r,!0,t.namespace);return function s(l,f=null){f?.remove();let c={signal:o.addRegistration(e,s,t).signal};return arguments.length&&n(l,c),i}}function R(r,e,n={},t=o=>o,i={}){r=V(r),x(t)&&([i,t]=[t,f=>f]);function o(f,u){return arguments.length>1?t(u):t(Reflect[e](r,...Object.values(n)))}let s=new C(r,{type:e,...n}),l=q.getInstance(r,!1,i.namespace);return l?l.emit(s,o):o(s)}function ce(r){return r===1/0||Array.isArray(r)}function V(r,e=!0){if((!r||!v(r))&&e)throw new Error(`Object must be of type object or array! "${B(r)}" given.`);return r instanceof C&&(r=r.value),r&&oe(r)}function _t(r,e,n){return e===1/0?se(r,n):n(A(e))}var xt={...Te,..._e},P=xt;function W(r,e,n={},t={}){e=A(e).slice();for(var i=r;!M(i)&&!J(i)&&e.length;){var o=e.shift();if(!(n.get?n.get(i,o):v(i)?o in i:i[o])){t.exists=!1;return}i=n.get?n.get(i,o):i[o]}return t.exists=!0,i}function Ce(r,e,n,t={},i={}){let o=(c,a,h)=>i.set?i.set(c,a,h):(T(e[l])&&_(c)?c.push(h):c[a]=h,!0);e=A(e);for(var s=r,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!v(s)&&!b(s))return!1;var f=W(s,e[l],i);if(!v(f)){if(i.buildTree===!1)return!1;f=b(i.buildTree)?i.buildTree(l):T(e[l+1])?[]:{};var u=o(s,e[l],f);if(!u)return!1}s=f}else return o(s,e[l],n)}var je=r=>class{constructor(n=!0){Object.defineProperty(this,"window",{value:r}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=n,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(n=>{n()||this.readCallbacks.delete(n)}),this.writeCallbacks.forEach(n=>{n()||this.writeCallbacks.delete(n)}),this._run()})}onread(n,t=!1){if(t)return new Promise((i,o)=>{this.async===!1?n(i,o):this.readCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.readCallbacks.add(n)}onwrite(n,t=!1){if(t)return new Promise((i,o)=>{this.async===!1?n(i,o):this.writeCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.writeCallbacks.add(n)}cycle(n,t,i){this.onread(()=>{let o=n(i),s=l=>{l!==void 0&&this.onwrite(()=>{let f=t(l,i),u=c=>{c!==void 0&&this.cycle(n,t,c)};f instanceof Promise?f.then(u):u(f)})};o instanceof Promise?o.then(s):s(o)})}};var z=class{constructor(e,n,t){this.context=e,this.namespace=n,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.wq=this.window.wq,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){return b(e[0])?e=[[],...e]:x(e[0])&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[A(e[0],!1),void 0,e[1]]:e[0]=A(e[0],!1),e}registry(...e){return E(this.window,"dom.realtime",this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,n,t){let{window:i}=this,o=Array.isArray(n)?n:[n],s=new Set;for(let[l,f]of this.registry(e))for(let[u,c]of f){let a=o.filter(h=>u.contains(h.target)?l==="subtree"||h.target===u:!1);if(!!a.length){Array.isArray(n)||(a=a[0]);for(let h of c)s.add([h,a,u])}}for(let[l,f,u]of s)t.call(this,l,f,u)}disconnectables(e,...n){let t={disconnect(){n.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||x(i)&&(i.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var N=class extends z{constructor(e,...n){super(e,"attr",...n)}get(e,n=void 0,t={}){let i=typeof e=="string";[e=[],n=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=We(o,e),l=i?s[0]:s;if(!n)return l;let f=n&&t.lifecycleSignals&&this.createSignalGenerator(),u=f?.generate()||{};if(n(l,u,o),t.live){f&&(t={...t,signalGenerator:f});let c=this.observe(i?e[0]:e,n,{newValue:!0,...t});return this.disconnectables(t.signal,c)}}observe(e,n,t={}){let i=typeof e=="string";if([e=[],n,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(i?e[0]:e,n,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,wq:l}=this;t.eventDetails&&!l.dom.attrInterceptionHooks?.intercepting&&$e.call(s,"intercept",()=>{});let f=new s.MutationObserver(h=>{h=Ve(h).map(g=>ze.call(s,g)),Le.call(s,a,h,o)}),u={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree};e.length&&(u.attributeFilter=e),f.observe(o,u);let c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),a={context:o,filter:e,callback:n,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:f};return this.disconnectables(t.signal,f,c)}observeSync(e,n,t={}){let i=typeof e=="string";[e,n,t={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let l=t.timing==="intercept"?"intercept":"sync",f=t.subtree?"subtree":"children";this.registry(l).size||$e.call(s,l,m=>{this.forEachMatchingContext(l,m,Le)});let u={disconnect(){g.delete(a),g.size||h.delete(o)}},c=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),a={context:o,filter:e,callback:n,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:u},h=this.registry(l,f);h.has(o)||h.set(o,new Set);let g=h.get(o);return g.add(a),this.disconnectables(t.signal,u,c)}};function Ve(r){return r.reduce((e,n,t)=>e[t-1]?.attributeName===n.attributeName?e:e.concat(n),[])}function Le(r,e){let{context:n,filter:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:f}=r;o.atomic&&!s.size&&(e=We(n,t,e)),o.newValue===null&&o.oldValue===null||(e=e.map(a=>{let h;return!o.oldValue&&"oldValue"in a&&({oldValue:h,...a}=a),!o.newValue&&"value"in a?{value:h,...a}=a:o.newValue&&typeof a.value>"u"&&(a={...a,value:a.target.getAttribute(a.name)}),a})),o.atomic&&(e.forEach(a=>s.set(a.name,a)),e=Array.from(s.entries()).map(([,a])=>a));let u=l?e[0]:e,c=f?.generate()||{};i(u,c,n)}function We(r,e,n=[]){let t={event:null,type:"attribute"};return e.length?e.map(o=>n.find(s=>s.name===o)||{target:r,name:o,value:r.getAttribute(o),...t}):Array.from(r.attributes).map(o=>n.find(s=>s.name===o.nodeName)||{target:r,name:o.nodeName,value:o.nodeValue,...t})}function ze({target:r,attributeName:e,value:n,oldValue:t}){let s=(this.wq.dom.attrInterceptionRecords?.get(r)||{})[e]||"mutation";return{target:r,name:e,value:n,oldValue:t,type:"observation",event:s}}function $e(r,e){let n=this,{wq:t,document:i,Element:o}=n;t.dom.attrInterceptionHooks||(t.dom.attrInterceptionHooks=new Map),t.dom.attrInterceptionHooks.has(r)||t.dom.attrInterceptionHooks.set(r,new Set),t.dom.attrInterceptionHooks.get(r).add(e);let s=()=>t.dom.attrInterceptionHooks.get(r).delete(e);if(t.dom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),t.dom.attrInterceptionHooks.intercepting=!0,t.dom.attrInterceptionRecords=new Map;let l=(c,a)=>{t.dom.attrInterceptionRecords.has(c.target)||t.dom.attrInterceptionRecords.set(c.target,{});let h=t.dom.attrInterceptionRecords.get(c.target);clearTimeout(h[c.name]?.timeout),h[c.name]=c.event;let g=setTimeout(()=>{delete h[c.name]},0);Object.defineProperty(c.event,"timeout",{value:g,configurable:!0}),t.dom.attrInterceptionHooks.get("intercept")?.forEach(p=>p([c]));let m=a();return t.dom.attrInterceptionHooks.get("sync")?.forEach(p=>p([c])),m};new n.MutationObserver(c=>{c=Ve(c).map(a=>ze.call(n,a)).filter((a,h)=>!Array.isArray(a.event)),c.length&&(t.dom.attrInterceptionHooks.get("intercept")?.forEach(a=>a(c)),t.dom.attrInterceptionHooks.get("sync")?.forEach(a=>a(c)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(c=>{u[c]=o.prototype[c],o.prototype[c]=function(...a){let h,g=this.getAttribute(a[0]);["setAttribute","toggleAttribute"].includes(c)&&(h=a[1]),c==="toggleAttribute"&&h===void 0&&(h=g===null);let m={target:this,name:a[0],value:h,oldValue:g,type:"interception",event:[this,c]};return l(m,()=>u[c].call(this,...a))}}),s}var U=class extends z{constructor(e,...n){super(e,"tree",...n)}attr(e,n=void 0,t={}){let{context:i,window:o}=this;return new N(i,o).get(...arguments)}query(e,n=void 0,t={}){[e,n=void 0,t={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if((!t.generation||t.generation==="entrants")&&(e.length?e.every(u=>typeof u=="string")&&(e=e.join(","))&&(t.subtree?i.querySelectorAll(e):[...i.children].filter(c=>c.matches(e))).forEach(c=>s(c.parentNode||i).entrants.push(c)):[...i.children].forEach(u=>s(i).entrants.push(u))),!n)return o;let l={disconnected:!1},f=n&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(l.disconnected)break;let c=f?.generate()||{};n(u,c,i)}if(t.live){f&&(t={...t,signalGenerator:f});let u=this.observe(e,n,t);return this.disconnectables(t.signal,l,u)}return this.disconnectables(t.signal,l,f)}children(e,n=void 0,t={}){return[e,n=void 0,t={}]=this.resolveArgs(arguments),this.query(e,n,{...t,subtree:!1})}subtree(e,n=void 0,t={}){return[e,n=void 0,t={}]=this.resolveArgs(arguments),this.query(e,n,{...t,subtree:!0})}observe(e,n,t={}){if([e,n,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,n,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:i,window:o,wq:s,document:l}=this;t.eventDetails&&(s.dom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.dom.domInterceptionRecordsAlwaysOn)&&!s.dom.domInterceptionHooks?.intercepting&&Qe.call(o,"sync",()=>{});let f=new o.MutationObserver(a=>a.forEach(h=>{Be.call(o,c,Ue.call(o,h),i)}));f.observe(i,{childList:!0,subtree:t.subtree});let u=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:i,selectors:e,callback:n,params:t,signalGenerator:u,disconnectable:f};if(t.staticSensitivity){let a=Ge.call(o,c);return this.disconnectables(t.signal,f,u,a)}return this.disconnectables(t.signal,f,u)}observeSync(e,n,t={}){[e,n,t={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let s=t.timing==="intercept"?"intercept":"sync",l=t.subtree?"subtree":"children";this.registry(s).size||Qe.call(o,s,g=>{this.forEachMatchingContext(s,g,Be)});let f={disconnect(){h.delete(c),h.size||a.delete(i)}},u=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:i,selectors:e,callback:n,params:t,signalGenerator:u,disconnectable:f},a=this.registry(s,l);a.has(i)||a.set(i,new Set);let h=a.get(i);if(h.add(c),t.staticSensitivity){let g=Ge.call(o,c);return this.disconnectables(t.signal,f,u,g)}return this.disconnectables(t.signal,f,u)}};function Ge(r){let e=this,{context:n,selectors:t,callback:i,params:o,signalGenerator:s}=r,l=c=>[...c.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(a=>a[1]);if(!(r.$attrs=t.filter(c=>typeof c=="string"&&c.includes("[")).reduce((c,a)=>c.concat(l(a)),[])).length)return;let f=new Set,u=new Set;return f.push=c=>(u.delete(c),f.add(c)),u.push=c=>(f.delete(c),u.add(c)),r.$deliveryCache={entrants:f,exits:u},new N(n,e).observe(r.$attrs,c=>{let a=new Map,h=p=>(a.has(p)||a.set(p,{target:p,entrants:[],exits:[],type:"static",event:null}),a.get(p)),g=new WeakMap,m=p=>(g.has(p)||g.set(p,t.some(d=>p.matches(d))),g.get(p));for(let p of c)["entrants","exits"].forEach(d=>{o.generation&&d!==o.generation||r.$deliveryCache[d].has(p.target)||(d==="entrants"?!m(p.target):m(p.target))||(r.$deliveryCache[d].push(p.target),h(p.target)[d].push(p.target),h(p.target).event=p.event)});for(let[,p]of a){let d=s?.generate()||{};i(p,d,n)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function Be(r,e){let{context:n,selectors:t,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=r,f={...e,entrants:[],exits:[]};if(["entrants","exits"].forEach(c=>{if(!(o.generation&&c!==o.generation)&&(t.length?f[c]=vt(t,e[c],e.event!=="parse"):f[c]=[...e[c]],!!l))for(let a of f[c])l[c].push(a)}),!f.entrants.length&&!f.exits.length)return;let u=s?.generate()||{};i(f,u,n)}function vt(r,e,n){e=Array.isArray(e)?e:[...e];let t=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(n&&(s=i.reduce((l,f)=>[...l,...f.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||n&&i.some(s=>s.contains(o)))return[o]};return e.$$searchCache||(e.$$searchCache=new Map),r.reduce((i,o)=>{let s;return e.$$searchCache.has(o)?s=e.$$searchCache.get(o):(s=t(e,o)||[],x(o)&&e.$$searchCache.set(o,s)),i.concat(s)},[])}function Ue({target:r,addedNodes:e,removedNodes:n}){let t=this,i;return i=A(e).reduce((o,s)=>o||t.wq.dom.domInterceptionRecords?.get(s),null),i=A(n).reduce((o,s)=>o||t.wq.dom.domInterceptionRecords?.get(s),i),i=i||t.document.readyState==="loading"&&"parse"||"mutation",{target:r,entrants:e,exits:n,type:"observation",event:i}}function Qe(r,e){let n=this,{wq:t,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:f,DocumentFragment:u}=n;t.dom.domInterceptionHooks||(t.dom.domInterceptionHooks=new Map),t.dom.domInterceptionHooks.has(r)||t.dom.domInterceptionHooks.set(r,new Set),t.dom.domInterceptionHooks.get(r).add(e);let c=()=>t.dom.domInterceptionHooks.get(r).delete(e);if(t.dom.domInterceptionHooks?.intercepting)return c;console.warn("DOM mutation APIs are now being intercepted."),t.dom.domInterceptionHooks.intercepting=!0,t.dom.domInterceptionRecords=new Map;let a=()=>!0,h=(m,p)=>{a()?m.entrants.concat(m.exits).forEach(y=>{clearTimeout(t.dom.domInterceptionRecords.get(y)?.timeout),t.dom.domInterceptionRecords.set(y,m.event);let w=setTimeout(()=>{t.dom.domInterceptionRecords.delete(y)},0);Object.defineProperty(m.event,"timeout",{value:w,configurable:!0})}):t.dom.domInterceptionRecords.clear(),t.dom.domInterceptionHooks.get("intercept")?.forEach(y=>y(m));let d=p();return t.dom.domInterceptionHooks.get("sync")?.forEach(y=>y(m)),d};if(a()){let m=new n.MutationObserver(p=>p.forEach(d=>{Array.isArray((d=Ue.call(n,d)).event)||(t.dom.domInterceptionHooks.get("intercept")?.forEach(y=>y(d)),t.dom.domInterceptionHooks.get("sync")?.forEach(y=>y(d)))}));m.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!a()&&m.disconnect())}let g=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(m=>{let p=["insertBefore","replaceChild","removeChild","appendChild"].includes(m)?o:s;g[m]=p.prototype[m],g[m]&&(p.prototype[m]=function(...d){let y=()=>g[m].call(this,...d);if(!(this instanceof s||this instanceof u))return y();let w=[],O=[],S=this;["insertBefore"].includes(m)?O=[d[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(m)?(O=[d[1]],["beforebegin","afterend"].includes(d[0])&&(S=this.parentNode)):["setHTML","replaceChildren"].includes(m)?(w=[...this.childNodes],O=m==="replaceChildren"?[...d]:[d[0]]):["replaceWith","remove"].includes(m)?(w=[this],O=m==="replaceWith"?[...d]:[],S=this.parentNode):["replaceChild"].includes(m)?(w=[d[1]],O=[d[0]]):["removeChild"].includes(m)?w=[...d]:(O=[...d],["before","after"].includes(m)&&(S=this.parentNode));let G=m;if(["insertAdjacentHTML","setHTML"].includes(m)){let H=this.nodeName;if(m==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(d[0])){if(!this.parentNode)return g[m].call(this,...d);H=this.parentNode.nodeName}let re=i.createElement(H);g.setHTML.call(re,O[0],m==="setHTML"?d[1]:{}),O=[...re.childNodes],m==="insertAdjacentHTML"?(G="insertAdjacentElement",d[1]=new u,d[1].______isTemp=!0,d[1].append(...re.childNodes)):(G="replaceChildren",d=[...re.childNodes])}return h({target:S,entrants:O,exits:w,type:"interception",event:[this,m]},()=>g[G].call(this,...d))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(m=>{let p=["textContent","nodeValue"].includes(m)?o:["outerText","innerText"].includes(m)?l:s;g[m]=Object.getOwnPropertyDescriptor(p.prototype,m),Object.defineProperty(p.prototype,m,{...g[m],set:function(d){let y=()=>g[m].set.call(this,d);if(!(this instanceof s))return y();let w=[],O=[],S=this;if(["outerHTML","outerText"].includes(m)?(w=[this],S=this.parentNode):w=[...this.childNodes],["outerHTML","innerHTML"].includes(m)){let te=this.nodeName;if(m==="outerHTML"){if(!this.parentNode)return y();te=this.parentNode.nodeName}let H=i.createElement(te==="TEMPLATE"?"div":te);g[m].set.call(H,d),O=this instanceof f?[]:[...H.childNodes],m==="outerHTML"?(d=new u,d.______isTemp=!0,d.append(...H.childNodes),y=()=>g.replaceWith.call(this,d)):this instanceof f?y=()=>this.content.replaceChildren(...H.childNodes):y=()=>g.replaceChildren.call(this,...H.childNodes)}return h({target:S,entrants:O,exits:w,type:"interception",event:[this,m]},y)}})}),["append","prepend","replaceChildren"].forEach(m=>{[i,u.prototype].forEach(p=>{let d=p[m];p[m]=function(...y){if(this.______isTemp)return d.call(this,...y);let w=m==="replaceChildren"?[...this.childNodes]:[];return h({target:this,entrants:y,exits:w,type:"interception",event:[this,m]},()=>d.call(this,...y))}})}),c}function Je(){At.call(this),Et.call(this),St.call(this)}function At(){let r=this;r.CSS||(r.CSS={}),r.CSS.escape||(r.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}function Et(){let r=this;"isConnected"in r.Node.prototype||Object.defineProperty(r.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function St(){let r=this;r.Element.prototype.matches||(r.Element.prototype.matches=r.Element.prototype.matchesSelector||r.Element.prototype.mozMatchesSelector||r.Element.prototype.msMatchesSelector||r.Element.prototype.oMatchesSelector||r.Element.prototype.webkitMatchesSelector||function(e){for(var n=(this.document||this.ownerDocument).querySelectorAll(e),t=n.length;--t>=0&&n.item(t)!==this;);return t>-1})}function Xe(){let r=this;if(r.wq||(r.wq={}),r.wq.dom)return r.wq.dom;r.wq.dom={},Je.call(r);let e=je(r);return r.wq.dom.Reflow=new e,r.wq.dom.DOMRealtime=U,r.wq.dom.AttrRealtime=N,r.wq.dom.realtime=(n,t="tree")=>{if(t==="tree")return new U(n,r);if(t==="attr")return new N(n,r)},r.wq.dom.ready=Pt.bind(r),r.wq.dom.meta=Tt.bind(r),r.wq.dom}function Pt(r){let e=this;e.document.readyState==="complete"?r(e):(e.document.domReadyCallbacks||(e.document.domReadyCallbacks=[],e.document.addEventListener("DOMContentLoaded",()=>{e.document.domReadyCallbacks.splice(0).forEach(n=>n(e))},!1)),e.document.domReadyCallbacks.push(r))}function Tt(r,e=!1){let n=this,t={content:{}};return!(t.el=n.document.querySelector(`meta[name="${r}"]`))&&e&&(t.el=n.document.createElement("meta"),t.el.setAttribute("name",r),n.document.head.append(t.el)),t.el&&(t.content=(t.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return Ce(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:T(s[1])?parseInt(s[1]):s[1]),i},{})),t.get=function(i){return JSON.parse(JSON.stringify(W(this.content,i.split("."))))},t.copy=function(){return JSON.parse(JSON.stringify(this.content))},t.copyWithDefaults=function(...i){return i.length?Y(!0,{},...i.reverse().concat(this.content)):this.copy()},t}var k=(r,...e)=>E(r,"oohtml",...e);function Ie(r={}){let e=this,n=Xe.call(e);e.wq||(e.wq={}),e.wq.Observer=P;let t=n.meta("oohtml").copyWithDefaults(r,{attr:{namespace:"namespace",id:":id"},api:{namespace:"namespace"},staticsensitivity:!0,eagermode:!0});t.idSelector=`[${e.CSS.escape(t.attr.id)}]`,t.namespaceSelector=`[${e.CSS.escape(t.attr.namespace)}]`,Ct.call(this,t),It.call(this,t)}function Ct(r){let e=this;if(r.api.namespace in e.document)throw new Error(`document already has a "${r.api.namespace}" property!`);if(r.api.namespace in e.Element.prototype)throw new Error(`The "Element" class already has a "${r.api.namespace}" property!`);Object.defineProperty(e.document,r.api.namespace,{get:function(){return P.proxy(ee.call(e,e.document,r))}}),Object.defineProperty(e.Element.prototype,r.api.namespace,{get:function(){return P.proxy(ee.call(e,this,r))}})}function ee(r,e){let n=this;if(!k(r).has("namespace")){let t=Object.create(null);P.intercept(t,"get",(i,o,s)=>{if(P.has(t,i.key)||!e.eagermode)return s();let l=`[${n.CSS.escape(e.attr.id)}="${i.key}"]`,f=Array.from(r.querySelectorAll(l)).filter(u=>{let c=u.parentNode.closest(e.namespaceSelector);return r===n.document?!c:c===r})[0];return f&&P.set(t,i.key,f),s()}),k(r).set("namespace",t)}return k(r).get("namespace")}function It(r){let e=this,{dom:n}=e.wq,t=(i,o,s)=>{let l=o.getAttribute(r.attr.id),f=i.closest(r.namespaceSelector)||k(o).get("ownerNamespace")||e.document,u=ee.call(e,f,r);s?P.get(u,l)!==o&&(k(o).set("ownerNamespace",f),P.set(u,l,o)):P.get(u,l)===o&&(k(o).delete("ownerNamespace"),P.deleteProperty(u,l))};n.realtime(e.document).observe(r.idSelector,i=>{i.entrants.forEach(o=>t(i.target,o,!0)),i.exits.forEach(o=>t(i.target,o,!1))},{subtree:!0,timing:"sync",staticSensitivity:r.staticsensitivity}),r.staticsensitivity&&n.realtime(e.document,"attr").observe(r.namespaceSelector,i=>{let o=i.target.parentNode?.closest(r.namespaceSelector)||k(i.target).get("ownerNamespace")||e.document,s=ee.call(e,o,r),l=ee.call(e,i.target,r);if(i.target.matches(r.namespaceSelector))for(let[f,u]of Object.entries(s))!i.target.contains(u.parentNode)||(P.deleteProperty(s,f),P.set(l,f,u));else for(let[f,u]of Object.entries(l))P.deleteProperty(l,f),P.set(s,f,u)},{subtree:!0,timing:"sync"})}Ie.call(window);})();
|
|
2
|
-
//# sourceMappingURL=namespaced-html.js.map
|