@webqit/oohtml 4.3.7 → 4.3.9
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 +2 -2
- package/dist/context-api.js +1 -1
- package/dist/context-api.js.map +2 -2
- package/dist/data-binding.js +1 -1
- package/dist/data-binding.js.map +2 -2
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/main.js +15 -15
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +14 -14
- package/dist/main.lite.js.map +2 -2
- package/dist/namespaced-html.js +1 -1
- package/dist/namespaced-html.js.map +2 -2
- package/dist/scoped-css.js +1 -1
- package/dist/scoped-css.js.map +2 -2
- package/package.json +1 -1
- package/src/context-api/DOMContexts.js +1 -1
- package/src/data-binding/index.js +7 -3
- package/src/html-imports/HTMLImportsContext.js +89 -25
- package/test/modules.test.js +1 -0
package/package.json
CHANGED
|
@@ -44,11 +44,15 @@ function realtime( config ) {
|
|
|
44
44
|
*/
|
|
45
45
|
realdom.realtime( window.document ).query( config.attrSelector, record => {
|
|
46
46
|
cleanup.call( this, ...record.exits );
|
|
47
|
-
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
mountInlineBindings.call( window, config, ...record.entrants );
|
|
49
|
+
}, 0);
|
|
48
50
|
}, { id: 'data-binding:attr', live: true, subtree: 'cross-roots', timing: 'sync', eventDetails: true, staticSensitivity: true } );
|
|
49
51
|
realdom.realtime( window.document ).query( `(${ config.discreteBindingsSelector })`, record => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
cleanup.call( this, ...record.exits );
|
|
54
|
+
mountDiscreteBindings.call( window, config, ...record.entrants );
|
|
55
|
+
}, 0);
|
|
52
56
|
}, { id: 'data-binding:descrete', live: true, subtree: 'cross-roots', timing: 'sync' } );
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -22,9 +22,9 @@ export default class HTMLImportsContext extends DOMContext {
|
|
|
22
22
|
request.detail = detail;
|
|
23
23
|
request.targetContext = Infinity;
|
|
24
24
|
} else if ( detail?.startsWith( '@' ) ) {
|
|
25
|
-
const [ targetContext, ...
|
|
25
|
+
const [ targetContext, ..._detail ] = detail.slice( 1 ).split( /(?<=\w)(?=\/|#)/ ).map( s => s.trim() );
|
|
26
26
|
request.targetContext = targetContext;
|
|
27
|
-
request.detail =
|
|
27
|
+
request.detail = _detail.join( '' );
|
|
28
28
|
} else { request.detail = detail; }
|
|
29
29
|
return request;
|
|
30
30
|
}
|
|
@@ -33,11 +33,14 @@ export default class HTMLImportsContext extends DOMContext {
|
|
|
33
33
|
* @localModules
|
|
34
34
|
*/
|
|
35
35
|
get localModules() { return getDefs( this.host ); }
|
|
36
|
+
get inheritedModules() { return this.#inheritedModules; }
|
|
37
|
+
#inheritedModules = {};
|
|
38
|
+
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
41
|
* @handle()
|
|
39
42
|
*/
|
|
40
|
-
|
|
43
|
+
handle__( event ) {
|
|
41
44
|
const { window: { webqit: { Observer } } } = env;
|
|
42
45
|
// Any existing event.meta.controller? Abort!
|
|
43
46
|
event.meta.controller?.abort();
|
|
@@ -55,27 +58,22 @@ export default class HTMLImportsContext extends DOMContext {
|
|
|
55
58
|
const _result = Array.isArray( result ) ? result : result.value;
|
|
56
59
|
const _isValidLocalResult = Array.isArray( result ) ? result.length : result.value;
|
|
57
60
|
if ( !_isValidLocalResult && this.host.isConnected === false ) return; // Subtree is being disposed
|
|
58
|
-
if ( _isValidLocalResult || !this
|
|
61
|
+
if ( _isValidLocalResult || !this.#inheritedModules ) {
|
|
59
62
|
event._isValidLocalResult = _isValidLocalResult;
|
|
60
63
|
return event.respondWith( _result );
|
|
61
64
|
}
|
|
62
65
|
// This superModules binding is automatically aborted by the injected control.signal; see below
|
|
63
|
-
return Observer.reduce( this
|
|
66
|
+
return Observer.reduce( this.#inheritedModules, path, Observer.get, result => {
|
|
64
67
|
event._currentSource = 'context';
|
|
65
68
|
return event.respondWith( Array.isArray( result ) ? result : result.value );
|
|
66
69
|
}, { ...options, signal } );
|
|
67
70
|
}, { lifecycleSignals: true, ...options } );
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
/**
|
|
71
|
-
* @unsubscribed()
|
|
72
|
-
*/
|
|
73
|
-
unsubscribed( event ) { event.meta.controller?.abort(); }
|
|
74
|
-
|
|
75
73
|
/**
|
|
76
74
|
* @startRealtime()
|
|
77
75
|
*/
|
|
78
|
-
|
|
76
|
+
realtimeSources__( host ) {
|
|
79
77
|
this.host = host;
|
|
80
78
|
// ----------------
|
|
81
79
|
const update = () => {
|
|
@@ -87,35 +85,100 @@ export default class HTMLImportsContext extends DOMContext {
|
|
|
87
85
|
// ----------------
|
|
88
86
|
const $config = this.configs.HTML_IMPORTS;
|
|
89
87
|
if ( !this.host.matches || !$config.attr.importscontext ) return;
|
|
90
|
-
// Any existing this.refdSourceController? Abort!
|
|
91
|
-
this.refdSourceController?.disconnect();
|
|
92
88
|
const realdom = this.host.ownerDocument.defaultView.webqit.realdom;
|
|
93
89
|
let prevRef;
|
|
94
|
-
this.
|
|
90
|
+
this.controller3 = realdom.realtime( this.host ).attr( $config.attr.importscontext, ( record, { signal } ) => {
|
|
95
91
|
if (record.value === prevRef) return;
|
|
96
92
|
prevRef = record.value;
|
|
97
|
-
// No importscontext attr set. But we're still watching
|
|
98
|
-
if ( !record.value ) {
|
|
99
|
-
this.contextModules = undefined;
|
|
100
|
-
return update();
|
|
101
|
-
}
|
|
102
93
|
// This superModules contextrequest is automatically aborted by the injected signal below
|
|
103
|
-
const request = { ...this.constructor.createRequest( record.value
|
|
94
|
+
const request = { ...this.constructor.createRequest( record.value?.trim() ), live: true, signal, diff: true };
|
|
104
95
|
this.host.parentNode[ this.configs.CONTEXT_API.api.contexts ].request( request, response => {
|
|
105
|
-
this
|
|
96
|
+
this.#inheritedModules = !( response && Object.getPrototypeOf( response ) ) ? response : getDefs( response );
|
|
106
97
|
update();
|
|
107
98
|
} );
|
|
108
99
|
}, { live: true, timing: 'sync', lifecycleSignals: true } );
|
|
109
100
|
}
|
|
110
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @handle()
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
handle( event ) {
|
|
107
|
+
const { window: { webqit: { Observer } } } = env;
|
|
108
|
+
// Any existing event.meta.controller? Abort!
|
|
109
|
+
event.meta.controller?.abort();
|
|
110
|
+
// Parse and translate detail
|
|
111
|
+
let path = ( event.detail || '' ).split( /\/|(?<=\w)(?=#)/g ).map( x => x.trim() ).filter( x => x );
|
|
112
|
+
if ( !path.length ) return event.respondWith();
|
|
113
|
+
path = path.join( `/${ this.configs.HTML_IMPORTS.api.defs }/` )?.split( '/' ).map( x => x === '*' ? Infinity : x ) || [];
|
|
114
|
+
// We'll now fulfill request
|
|
115
|
+
const options = { live: event.live, signal: event.signal, descripted: true };
|
|
116
|
+
event.meta.controller = Observer.reduce( this.#modules, path, Observer.get, ( m ) => {
|
|
117
|
+
if ( Array.isArray( m ) ) {
|
|
118
|
+
// Paths with wildcard
|
|
119
|
+
for ( const n of m ) {
|
|
120
|
+
event.respondWith( n );
|
|
121
|
+
}
|
|
122
|
+
} else event.respondWith( m.value );
|
|
123
|
+
}, options );
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @unsubscribed()
|
|
128
|
+
*/
|
|
129
|
+
unsubscribed( event ) { event.meta.controller?.abort(); }
|
|
130
|
+
|
|
111
131
|
/**
|
|
112
132
|
* @initialize()
|
|
113
133
|
*/
|
|
134
|
+
#modules;
|
|
135
|
+
#controller1;
|
|
136
|
+
#controller2;
|
|
114
137
|
initialize( host ) {
|
|
138
|
+
this.host = host;
|
|
139
|
+
const { window: { webqit: { Observer } } } = env;
|
|
140
|
+
// ----------------
|
|
141
|
+
// Observe local
|
|
142
|
+
this.#modules = Object.assign( {}, this.localModules );
|
|
143
|
+
this.#controller1?.abort();
|
|
144
|
+
this.#controller1 = Observer.observe( this.localModules, ( mutations ) => {
|
|
145
|
+
for ( const m of mutations ) {
|
|
146
|
+
if ( m.type === 'delete' ) {
|
|
147
|
+
if ( this.inheritedModules && Observer.has( this.inheritedModules, m.key ) ) {
|
|
148
|
+
Observer.set( this.#modules, m.key, Observer.get( this.inheritedModules, m.key ) );
|
|
149
|
+
} else Observer.deleteProperty( this.#modules, m.key );
|
|
150
|
+
} else Observer.set( this.#modules, m.key, m.value );
|
|
151
|
+
}
|
|
152
|
+
}, { timing: 'sync' } );
|
|
153
|
+
// ----------------
|
|
115
154
|
// If host has importscontext attr, compute that
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
|
|
155
|
+
const $config = this.configs.HTML_IMPORTS;
|
|
156
|
+
if ( this.host.matches && $config.attr.importscontext ) {
|
|
157
|
+
const realdom = this.host.ownerDocument.defaultView.webqit.realdom;
|
|
158
|
+
let prevRef;
|
|
159
|
+
this.#controller2?.disconnect();
|
|
160
|
+
this.#controller2 = realdom.realtime( this.host ).attr( $config.attr.importscontext, ( record, { signal } ) => {
|
|
161
|
+
const moduleRef = ( record.value || '' ).trim();
|
|
162
|
+
if ( moduleRef === prevRef ) return;
|
|
163
|
+
prevRef = moduleRef;
|
|
164
|
+
// This superModules contextrequest is automatically aborted by the injected signal below
|
|
165
|
+
const request = { ...this.constructor.createRequest( moduleRef ? `${moduleRef}/*` : '*' ), live: true, signal, diff: true };
|
|
166
|
+
this.host.parentNode[ this.configs.CONTEXT_API.api.contexts ].request( request, ( m ) => {
|
|
167
|
+
if ( m.type === 'delete' ) {
|
|
168
|
+
Reflect.deleteProperty( this.inheritedModules, m.key );
|
|
169
|
+
if ( !Observer.has( this.localModules, m.key ) ) {
|
|
170
|
+
Observer.deleteProperty( this.#modules, m.key );
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
Reflect.set( this.inheritedModules, m.key, m.value );
|
|
174
|
+
if ( !Observer.has( this.localModules, m.key ) ) {
|
|
175
|
+
Observer.set( this.#modules, m.key, m.value );
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} );
|
|
179
|
+
}, { live: true, timing: 'sync', lifecycleSignals: true } );
|
|
180
|
+
}
|
|
181
|
+
// ----------------
|
|
119
182
|
return super.initialize( host );
|
|
120
183
|
}
|
|
121
184
|
|
|
@@ -124,7 +187,8 @@ export default class HTMLImportsContext extends DOMContext {
|
|
|
124
187
|
*/
|
|
125
188
|
dispose( host ) {
|
|
126
189
|
// Stop listening for sources
|
|
127
|
-
this
|
|
190
|
+
this.#controller1?.abort();
|
|
191
|
+
this.#controller2?.disconnect();
|
|
128
192
|
// Now, stop listening for contextrequest and contextclaim events
|
|
129
193
|
// And relinquish own subscribers to owner context
|
|
130
194
|
return super.dispose( host );
|
package/test/modules.test.js
CHANGED