@webqit/oohtml 4.3.9 → 4.3.11

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "4.3.9",
17
+ "version": "4.3.11",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@webqit/quantum-js": "^4.5.26",
43
- "@webqit/realdom": "^2.1.32",
43
+ "@webqit/realdom": "^2.1.33",
44
44
  "@webqit/util": "^0.8.11"
45
45
  },
46
46
  "devDependencies": {
@@ -18,15 +18,16 @@ import { _init } from '../util.js';
18
18
  */
19
19
  export default function init( $config = {} ) {
20
20
  const { config, window } = _init.call( this, 'context-api', $config, {
21
+ elements: { roots: 'root,webflo-embedded', },
21
22
  attr: { contextname: 'contextname', },
22
23
  api: { contexts: 'contexts', },
23
24
  } );
24
25
  const waitListMappings = new Map, dispatchEvent = window.EventTarget.prototype.dispatchEvent;
25
26
  Object.defineProperty( window.EventTarget.prototype, 'dispatchEvent', { value: function( ...args ) {
26
- const event = args[0], rootNode = this.getRootNode?.();
27
+ const event = args[0], rootNode = this?.closest?.(config.elements.roots) || this.getRootNode?.();
27
28
  if ( [ 'contextclaim', 'contextrequest' ].includes( event.type ) && rootNode ) {
28
29
  if ( event.meta ) event.meta.target = this;
29
- const temp = event => {
30
+ const temp = (event) => {
30
31
  event.stopImmediatePropagation();
31
32
  // Always set this whether answered or not
32
33
  if ( event.meta ) event.meta.target = event.target;
@@ -36,69 +36,6 @@ export default class HTMLImportsContext extends DOMContext {
36
36
  get inheritedModules() { return this.#inheritedModules; }
37
37
  #inheritedModules = {};
38
38
 
39
-
40
- /**
41
- * @handle()
42
- */
43
- handle__( event ) {
44
- const { window: { webqit: { Observer } } } = env;
45
- // Any existing event.meta.controller? Abort!
46
- event.meta.controller?.abort();
47
-
48
- // Parse and translate detail
49
- if ( ( event.detail || '' ).trim() === '/' ) return event.respondWith( this.localModules );
50
- let path = ( event.detail || '' ).split( /\/|(?<=\w)(?=#)/g ).map( x => x.trim() ).filter( x => x );
51
- if ( !path.length ) return event.respondWith();
52
- path = path.join( `/${ this.configs.HTML_IMPORTS.api.defs }/` )?.split( '/' ) || [];
53
-
54
- // We'll now fulfill request
55
- const options = { live: event.live, signal: event.signal, descripted: true };
56
- // Find a way to resolve request against two sources
57
- event.meta.controller = Observer.reduce( this.localModules, path, Observer.get, ( result, { signal } = {} ) => {
58
- const _result = Array.isArray( result ) ? result : result.value;
59
- const _isValidLocalResult = Array.isArray( result ) ? result.length : result.value;
60
- if ( !_isValidLocalResult && this.host.isConnected === false ) return; // Subtree is being disposed
61
- if ( _isValidLocalResult || !this.#inheritedModules ) {
62
- event._isValidLocalResult = _isValidLocalResult;
63
- return event.respondWith( _result );
64
- }
65
- // This superModules binding is automatically aborted by the injected control.signal; see below
66
- return Observer.reduce( this.#inheritedModules, path, Observer.get, result => {
67
- event._currentSource = 'context';
68
- return event.respondWith( Array.isArray( result ) ? result : result.value );
69
- }, { ...options, signal } );
70
- }, { lifecycleSignals: true, ...options } );
71
- }
72
-
73
- /**
74
- * @startRealtime()
75
- */
76
- realtimeSources__( host ) {
77
- this.host = host;
78
- // ----------------
79
- const update = () => {
80
- for ( const subscriptionEvent of this.subscriptions ) {
81
- if ( subscriptionEvent._isValidLocalResult ) continue;
82
- this.handle( subscriptionEvent );
83
- }
84
- };
85
- // ----------------
86
- const $config = this.configs.HTML_IMPORTS;
87
- if ( !this.host.matches || !$config.attr.importscontext ) return;
88
- const realdom = this.host.ownerDocument.defaultView.webqit.realdom;
89
- let prevRef;
90
- this.controller3 = realdom.realtime( this.host ).attr( $config.attr.importscontext, ( record, { signal } ) => {
91
- if (record.value === prevRef) return;
92
- prevRef = record.value;
93
- // This superModules contextrequest is automatically aborted by the injected signal below
94
- const request = { ...this.constructor.createRequest( record.value?.trim() ), live: true, signal, diff: true };
95
- this.host.parentNode[ this.configs.CONTEXT_API.api.contexts ].request( request, response => {
96
- this.#inheritedModules = !( response && Object.getPrototypeOf( response ) ) ? response : getDefs( response );
97
- update();
98
- } );
99
- }, { live: true, timing: 'sync', lifecycleSignals: true } );
100
- }
101
-
102
39
  /**
103
40
  * @handle()
104
41
  */
@@ -139,7 +76,7 @@ export default class HTMLImportsContext extends DOMContext {
139
76
  const { window: { webqit: { Observer } } } = env;
140
77
  // ----------------
141
78
  // Observe local
142
- this.#modules = Object.assign( {}, this.localModules );
79
+ this.#modules = { ...this.localModules };
143
80
  this.#controller1?.abort();
144
81
  this.#controller1 = Observer.observe( this.localModules, ( mutations ) => {
145
82
  for ( const m of mutations ) {
@@ -157,7 +94,7 @@ export default class HTMLImportsContext extends DOMContext {
157
94
  const realdom = this.host.ownerDocument.defaultView.webqit.realdom;
158
95
  let prevRef;
159
96
  this.#controller2?.disconnect();
160
- this.#controller2 = realdom.realtime( this.host ).attr( $config.attr.importscontext, ( record, { signal } ) => {
97
+ this.#controller2 = realdom.realtime( this.host ).attr( $config.attr.importscontext, ( record, { signal } ) => {
161
98
  const moduleRef = ( record.value || '' ).trim();
162
99
  if ( moduleRef === prevRef ) return;
163
100
  prevRef = moduleRef;
@@ -176,7 +113,7 @@ export default class HTMLImportsContext extends DOMContext {
176
113
  }
177
114
  }
178
115
  } );
179
- }, { live: true, timing: 'sync', lifecycleSignals: true } );
116
+ }, { live: true, timing: 'sync', oldValue: true, lifecycleSignals: true } );
180
117
  }
181
118
  // ----------------
182
119
  return super.initialize( host );