@webqit/oohtml 2.1.8 → 2.1.10

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.
Files changed (40) hide show
  1. package/dist/bindings-api.js +2 -0
  2. package/dist/bindings-api.js.map +7 -0
  3. package/dist/context-api.js +1 -1
  4. package/dist/context-api.js.map +3 -3
  5. package/dist/html-imports.js +1 -1
  6. package/dist/html-imports.js.map +3 -3
  7. package/dist/html-modules.js +1 -1
  8. package/dist/html-modules.js.map +3 -3
  9. package/dist/main.js +9 -9
  10. package/dist/main.js.map +3 -3
  11. package/dist/namespace-api.js +2 -0
  12. package/dist/namespace-api.js.map +7 -0
  13. package/dist/scoped-js.js +7 -7
  14. package/dist/scoped-js.js.map +3 -3
  15. package/package.json +6 -6
  16. package/src/bindings-api/index.js +84 -0
  17. package/src/context-api/HTMLContext.js +3 -3
  18. package/src/context-api/index.js +13 -17
  19. package/src/html-imports/_HTMLImportElement.js +13 -15
  20. package/src/html-imports/index.js +20 -26
  21. package/src/html-modules/HTMLExportsManager.js +17 -17
  22. package/src/html-modules/_HTMLImportsContext.js +6 -6
  23. package/src/html-modules/index.js +31 -37
  24. package/src/index.js +9 -11
  25. package/src/{namespaced-html → namespace-api}/index.js +35 -40
  26. package/src/scoped-js/Compiler.js +7 -7
  27. package/src/scoped-js/index.js +19 -24
  28. package/src/targets.browser.js +2 -2
  29. package/src/util.js +13 -1
  30. package/test/bindings-api.test.js +42 -0
  31. package/test/index.js +11 -9
  32. package/dist/namespaced-html.js +0 -2
  33. package/dist/namespaced-html.js.map +0 -7
  34. package/dist/state-api.js +0 -2
  35. package/dist/state-api.js.map +0 -7
  36. package/src/state-api/index.js +0 -59
  37. package/test/state-api.test.js +0 -34
  38. /package/src/{namespaced-html → bindings-api}/targets.browser.js +0 -0
  39. /package/src/{state-api → namespace-api}/targets.browser.js +0 -0
  40. /package/test/{namespaced-html.test.js → namespace-api.test.js} +0 -0
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "keywords": [
6
6
  "namespaced-HTML",
7
7
  "html-modules",
8
- "ui-state",
8
+ "ui-bindings",
9
9
  "html-imports",
10
10
  "reflex",
11
11
  "subscript",
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "2.1.8",
17
+ "version": "2.1.10",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -32,15 +32,15 @@
32
32
  "scripts": {
33
33
  "test": "mocha --extension .test.js --exit",
34
34
  "test:coverage": "c8 --reporter=text-lcov npm run test | coveralls",
35
- "build": "esbuild main=src/targets.browser.js html-modules=src/html-modules/targets.browser.js html-imports=src/html-imports/targets.browser.js namespaced-html=src/namespaced-html/targets.browser.js scoped-js=src/scoped-js/targets.browser.js state-api=src/state-api/targets.browser.js context-api=src/context-api/targets.browser.js --bundle --minify --sourcemap --outdir=dist",
35
+ "build": "esbuild main=src/targets.browser.js bindings-api=src/bindings-api/targets.browser.js context-api=src/context-api/targets.browser.js namespace-api=src/namespace-api/targets.browser.js html-modules=src/html-modules/targets.browser.js html-imports=src/html-imports/targets.browser.js scoped-js=src/scoped-js/targets.browser.js --bundle --minify --sourcemap --outdir=dist",
36
36
  "preversion": "npm run test && npm run build && git add -A dist",
37
37
  "postversion": "npm publish",
38
38
  "postpublish": "git push && git push --tags"
39
39
  },
40
40
  "dependencies": {
41
- "@webqit/dom": "^2.0.2",
42
- "@webqit/observer": "^2.0.1",
43
- "@webqit/subscript": "^2.1.36",
41
+ "@webqit/dom": "^2.0.4",
42
+ "@webqit/observer": "^2.0.4",
43
+ "@webqit/subscript": "^2.1.39",
44
44
  "@webqit/util": "^0.8.9"
45
45
  },
46
46
  "devDependencies": {
@@ -0,0 +1,84 @@
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import Observer from '@webqit/observer';
6
+ import { _, _init } from '../util.js';
7
+
8
+ /**
9
+ * @init
10
+ *
11
+ * @param Object $config
12
+ */
13
+ export default function init( $config = {} ) {
14
+ const { config, window } = _init.call( this, 'bindings-api', $config, {
15
+ api: { bind: 'bind', bindings: 'bindings', },
16
+ } );
17
+ window.webqit.Observer = Observer;
18
+ exposeAPIs.call( window, config );
19
+ }
20
+
21
+ export { Observer }
22
+
23
+ /**
24
+ * @Exports
25
+ *
26
+ * The internal bindings object
27
+ * within elements and the document object.
28
+ */
29
+ function getBindingsObject( node ) {
30
+ if ( !_( node ).has( 'bindings' ) ) {
31
+ const bindingsObj = Object.create( null );
32
+ _( node ).set( 'bindings', bindingsObj );
33
+ }
34
+ return _( node ).get( 'bindings' );
35
+ }
36
+
37
+ /**
38
+ * Exposes Bindings with native APIs.
39
+ *
40
+ * @param Object config
41
+ *
42
+ * @return Void
43
+ */
44
+ function exposeAPIs( config ) {
45
+ const window = this;
46
+ // Assertions
47
+ if ( config.api.bind in window.document ) { throw new Error( `document already has a "${ config.api.bind }" property!` ); }
48
+ if ( config.api.bindings in window.document ) { throw new Error( `document already has a "${ config.api.bindings }" property!` ); }
49
+ if ( config.api.bind in window.Element.prototype ) { throw new Error( `The "Element" class already has a "${ config.api.bind }" property!` ); }
50
+ if ( config.api.bindings in window.Element.prototype ) { throw new Error( `The "Element" class already has a "${ config.api.bindings }" property!` ); }
51
+ // Definitions
52
+ Object.defineProperty( window.document, config.api.bind, { value: function( bindings, config = {} ) {
53
+ return applyBindings( window.document, bindings, config );
54
+ } });
55
+ Object.defineProperty( window.document, config.api.bindings, { get: function() {
56
+ return Observer.proxy( getBindingsObject( window.document ) );
57
+ } });
58
+ Object.defineProperty( window.Element.prototype, config.api.bind, { value: function( bindings, config = {} ) {
59
+ return applyBindings( this, bindings, config );
60
+ } });
61
+ Object.defineProperty( window.Element.prototype, config.api.bindings, { get: function() {
62
+ return Observer.proxy( getBindingsObject( this ) );
63
+ } } );
64
+ }
65
+
66
+ /**
67
+ * Exposes Bindings with native APIs.
68
+ *
69
+ * @param document|Element target
70
+ * @param Object bindings
71
+ * @param Object params
72
+ *
73
+ * @return Void
74
+ */
75
+ function applyBindings( target, bindings, { merge, namespace } = {} ) {
76
+ const bindingsObj = getBindingsObject( target );
77
+ const $params = { namespace };
78
+ if ( merge ) return Observer.set( bindingsObj, bindings, $params );;
79
+ const exitingKeys = Observer.ownKeys( bindingsObj, $params ).filter( key => !( key in bindings ) );
80
+ return Observer.batch( bindingsObj, () => {
81
+ if ( exitingKeys.length ) { Observer.deleteProperty( bindingsObj, exitingKeys, $params ); }
82
+ return Observer.set( bindingsObj, bindings, $params );
83
+ }, $params );
84
+ }
@@ -8,9 +8,9 @@ import HTMLContextManager from './HTMLContextManager.js';
8
8
  export default class HTMLContext {
9
9
 
10
10
  /**
11
- * @params
11
+ * @config
12
12
  */
13
- static get params() {
13
+ static get config() {
14
14
  return {};
15
15
  }
16
16
 
@@ -41,7 +41,7 @@ export default class HTMLContext {
41
41
  static createId( host, fields = {} ) {
42
42
  const id = { type: 'HTMLModules', ...fields };
43
43
  if ( id.name ) return id;
44
- if ( host.getAttribute && !( id.name = ( host.getAttribute( this.params.context.attr.contextname ) || '' ).trim() ) ) {
44
+ if ( host.getAttribute && !( id.name = ( host.getAttribute( this.config.context.attr.contextname ) || '' ).trim() ) ) {
45
45
  delete id.name;
46
46
  } else if ( !host.ownerDocument ) {
47
47
  id.name = 'root';
@@ -2,47 +2,43 @@
2
2
  /**
3
3
  * @imports
4
4
  */
5
- import wqDom from '@webqit/dom';
5
+ import { _init } from '../util.js';
6
6
  import HTMLContextManager from './HTMLContextManager.js';
7
7
  import HTMLContext from './HTMLContext.js';
8
8
 
9
9
  /**
10
10
  * Initializes HTML Modules.
11
11
  *
12
- * @param $params Object
12
+ * @param $config Object
13
13
  *
14
14
  * @return Void
15
15
  */
16
- export default function init( $params = { }) {
17
- const window = this, dom = wqDom.call( window );
18
- if ( !window.wq ) { window.wq = {}; }
19
- window.wq.HTMLContextManager = HTMLContextManager;
20
- window.wq.HTMLContext = HTMLContext;
21
- // -------
22
- const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
16
+ export default function init( $config = {} ) {
17
+ const { config, window } = _init.call( this, 'context-api', $config, {
23
18
  api: { context: 'context', },
24
19
  } );
25
- // -------
26
- exposeModulesObjects.call( this, params );
20
+ window.webqit.HTMLContextManager = HTMLContextManager;
21
+ window.webqit.HTMLContext = HTMLContext;
22
+ exposeModulesObjects.call( window, config );
27
23
  }
28
24
 
29
25
  /**
30
26
  * Exposes HTML Modules with native APIs.
31
27
  *
32
- * @param Object params
28
+ * @param Object config
33
29
  *
34
30
  * @return Void
35
31
  */
36
- function exposeModulesObjects( params ) {
32
+ function exposeModulesObjects( config ) {
37
33
  const window = this;
38
34
  // Assertions
39
- if ( params.api.context in window.document ) { throw new Error( `document already has a "${ params.api.context }" property!` ); }
40
- if ( params.api.context in window.HTMLElement.prototype ) { throw new Error( `The "HTMLElement" class already has a "${ params.api.context }" property!` ); }
35
+ if ( config.api.context in window.document ) { throw new Error( `document already has a "${ config.api.context }" property!` ); }
36
+ if ( config.api.context in window.HTMLElement.prototype ) { throw new Error( `The "HTMLElement" class already has a "${ config.api.context }" property!` ); }
41
37
  // Definitions
42
- Object.defineProperty( window.document, params.api.context, { get: function() {
38
+ Object.defineProperty( window.document, config.api.context, { get: function() {
43
39
  return HTMLContextManager.instance( window.document );
44
40
  } } );
45
- Object.defineProperty( window.HTMLElement.prototype, params.api.context, { get: function() {
41
+ Object.defineProperty( window.HTMLElement.prototype, config.api.context, { get: function() {
46
42
  return HTMLContextManager.instance( this );
47
43
  } } );
48
44
  }
@@ -9,16 +9,14 @@ import { _ } from '../util.js';
9
9
  /**
10
10
  * Creates the HTMLImportElement class.
11
11
  *
12
- * @param Object params
12
+ * @param Object config
13
13
  *
14
14
  * @return HTMLImportElement
15
15
  */
16
- export default function( params ) {
17
- const window = this, { dom } = window.wq;
18
- const BaseExportElement = params.import.tagName.includes( '-' )
19
- ? ( params.HTMLImportBaseElement || window.HTMLElement )
20
- : class {};
21
- return class HTMLImportElement extends BaseExportElement {
16
+ export default function( config ) {
17
+ const window = this, { dom } = window.webqit;
18
+ const BaseElement = config.import.tagName.includes( '-' ) ? window.HTMLElement : class {};
19
+ return class HTMLImportElement extends BaseElement {
22
20
 
23
21
  /**
24
22
  * @instance
@@ -28,7 +26,7 @@ export default function( params ) {
28
26
  * @returns
29
27
  */
30
28
  static instance( node ) {
31
- if ( params.import.tagName.includes( '-' ) && ( node instanceof this ) ) return node;
29
+ if ( config.import.tagName.includes( '-' ) && ( node instanceof this ) ) return node;
32
30
  return _( node ).get( 'import::instance' ) || new this( node );;
33
31
  }
34
32
 
@@ -61,7 +59,7 @@ export default function( params ) {
61
59
 
62
60
  priv.hydrate = ( anchorNode, slottedElements ) => {
63
61
  // ----------------
64
- priv.moduleRef = ( this.el.getAttribute( params.import.attr.moduleref ) || '' ).trim();
62
+ priv.moduleRef = ( this.el.getAttribute( config.import.attr.moduleref ) || '' ).trim();
65
63
  priv.setAnchorNode( anchorNode );
66
64
  priv.autoRestore( () => {
67
65
  slottedElements.forEach( slottedElement => {
@@ -73,9 +71,9 @@ export default function( params ) {
73
71
  priv.hydrationImportRequest = new AbortController;
74
72
  priv.importRequest( modules => {
75
73
  if ( priv.originalsRemapped ) { return this.fill( modules ); }
76
- const identifiersMap = [ ...modules ].map( module => ( { el: module, exportId: module.getAttribute( params.export.attr.exportid ) || '#default', tagName: module.tagName, } ) );
74
+ const identifiersMap = [ ...modules ].map( module => ( { el: module, exportId: module.getAttribute( config.export.attr.exportid ) || '#default', tagName: module.tagName, } ) );
77
75
  slottedElements.forEach( slottedElement => {
78
- const tagName = slottedElement.tagName, exportId = slottedElement.getAttribute( params.export.attr.exportid ) || '#default';
76
+ const tagName = slottedElement.tagName, exportId = slottedElement.getAttribute( config.export.attr.exportid ) || '#default';
79
77
  const originalsMatch = identifiersMap.filter( moduleIdentifiers => tagName === moduleIdentifiers.tagName && exportId === moduleIdentifiers.exportId );
80
78
  if ( originalsMatch.length !== 1 ) return;
81
79
  _( slottedElement ).set( 'original@imports', originalsMatch[ 0 ].el );
@@ -112,7 +110,7 @@ export default function( params ) {
112
110
  // Totally initialize this instance?
113
111
  if ( !priv.anchorNode ) { priv.setAnchorNode( this.createAnchorNode() ); }
114
112
  if ( priv.moduleRefRealtime ) return;
115
- priv.moduleRefRealtime = dom.realtime( this.el ).attr( params.import.attr.moduleref, ( record, { signal } ) => {
113
+ priv.moduleRefRealtime = dom.realtime( this.el ).attr( config.import.attr.moduleref, ( record, { signal } ) => {
116
114
  priv.moduleRef = record.value;
117
115
  ;
118
116
  // Below, we ignore first restore from hydration
@@ -138,7 +136,7 @@ export default function( params ) {
138
136
  * @return Element
139
137
  */
140
138
  createAnchorNode() {
141
- if ( !params.isomorphic ) { return window.document.createTextNode( '' ) }
139
+ if ( !config.isomorphic ) { return window.document.createTextNode( '' ) }
142
140
  return window.document.createComment( this.el.outerHTML );
143
141
  }
144
142
 
@@ -174,8 +172,8 @@ export default function( params ) {
174
172
  // Clone each slottable element and give it a reference to its original
175
173
  const slottableElementClone = slottableElement.cloneNode( true );
176
174
  // The folllowing references must be set before adding to DODM
177
- if ( !slottableElementClone.hasAttribute( params.export.attr.exportid ) ) {
178
- slottableElementClone.toggleAttribute( params.export.attr.exportid, true );
175
+ if ( !slottableElementClone.hasAttribute( config.export.attr.exportid ) ) {
176
+ slottableElementClone.toggleAttribute( config.export.attr.exportid, true );
179
177
  }
180
178
  _( slottableElementClone ).set( 'original@imports', slottableElement );
181
179
  _( slottableElementClone ).set( 'slot@imports', this.el );
@@ -2,45 +2,39 @@
2
2
  /**
3
3
  * @imports
4
4
  */
5
- import wqDom from '@webqit/dom';
6
5
  import _HTMLImportElement from './_HTMLImportElement.js';
7
- import { _ } from '../util.js';
6
+ import { _, _init } from '../util.js';
8
7
 
9
8
  /**
10
9
  * Initializes HTML Modules.
11
10
  *
12
- * @param $params Object
11
+ * @param $config Object
13
12
  *
14
13
  * @return Void
15
14
  */
16
- export default function init( $params = { }) {
17
- const window = this, dom = wqDom.call( window );
18
- if ( !window.wq ) { window.wq = {}; }
19
- // -------
20
- const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
15
+ export default function init( $config = {} ) {
16
+ const { config, dom, window } = _init.call( this, 'html-imports', $config, {
21
17
  import: { tagName: 'import', attr: { moduleref: 'module' }, },
22
18
  export: { attr: { exportid: 'exportid' }, },
23
19
  isomorphic: true,
24
20
  } );
25
- params.slottedElementsSelector = `[${ window.CSS.escape( params.export.attr.exportid ) }]`;
26
- // -------
27
- window.wq.HTMLImportElement = _HTMLImportElement.call( this, params );
28
- // -------
29
- dom.ready( () => hydration.call( this, params ) );
30
- realtime.call( this, params );
21
+ config.slottedElementsSelector = `[${ window.CSS.escape( config.export.attr.exportid ) }]`;
22
+ window.webqit.HTMLImportElement = _HTMLImportElement.call( window, config );
23
+ dom.ready( () => hydration.call( window, config ) );
24
+ realtime.call( window, config );
31
25
  }
32
26
 
33
27
  /**
34
28
  * Performs realtime capture of elements and their attributes
35
29
  * and their module query results; then resolves the respective import elements.
36
30
  *
37
- * @param Object params
31
+ * @param Object config
38
32
  *
39
33
  * @return Void
40
34
  */
41
- function realtime( params ) {
42
- const window = this, { dom, HTMLImportElement } = window.wq;
43
- dom.realtime( window.document ).observe( params.import.tagName, record => {
35
+ function realtime( config ) {
36
+ const window = this, { dom, HTMLImportElement } = window.webqit;
37
+ dom.realtime( window.document ).observe( config.import.tagName, record => {
44
38
  record.entrants.forEach( node => handleRealtime( node, true, record ) );
45
39
  record.exits.forEach( node => handleRealtime( node, false, record ) );
46
40
  }, { subtree: true, timing: 'sync' } );
@@ -54,27 +48,27 @@ function realtime( params ) {
54
48
  /**
55
49
  * Performs hydration for server-slotted elements.
56
50
  *
57
- * @param Object params
51
+ * @param Object config
58
52
  *
59
53
  * @return Void
60
54
  */
61
- function hydration( params ) {
62
- const window = this, { HTMLImportElement } = window.wq;
55
+ function hydration( config ) {
56
+ const window = this, { HTMLImportElement } = window.webqit;
63
57
  function scan( context ) {
64
58
  const slottedElements = new Set;
65
59
  context.childNodes.forEach( node => {
66
60
  if ( node.nodeType === 1/** ELEMENT_NODE */ ) {
67
- if ( !node.matches( params.slottedElementsSelector ) ) return;
61
+ if ( !node.matches( config.slottedElementsSelector ) ) return;
68
62
  if ( _( node ).get( 'slot@imports' ) ) return;
69
63
  slottedElements.add( node );
70
64
  } else if ( node.nodeType === 8/** COMMENT_NODE */ ) {
71
65
  const nodeValue = node.nodeValue.trim();
72
- if ( !nodeValue.startsWith( '<' + params.import.tagName ) ) return;
73
- if ( !nodeValue.endsWith( '</' + params.import.tagName + '>' ) ) return;
66
+ if ( !nodeValue.startsWith( '<' + config.import.tagName ) ) return;
67
+ if ( !nodeValue.endsWith( '</' + config.import.tagName + '>' ) ) return;
74
68
  const reviver = window.document.createElement( 'div' );
75
69
  reviver.innerHTML = nodeValue;
76
70
  const importEl = reviver.firstChild;
77
- if ( !importEl.matches( params.import.tagName ) ) return;
71
+ if ( !importEl.matches( config.import.tagName ) ) return;
78
72
  HTMLImportElement.instance( importEl )[ '#' ].hydrate(
79
73
  node/* the comment node */, slottedElements
80
74
  );
@@ -82,7 +76,7 @@ function hydration( params ) {
82
76
  }
83
77
  } );
84
78
  }
85
- Array.from( window.document.querySelectorAll( params.slottedElementsSelector ) ).forEach( slottedElement => {
79
+ Array.from( window.document.querySelectorAll( config.slottedElementsSelector ) ).forEach( slottedElement => {
86
80
  // hydration() might be running AFTER certain <slots> have resolved
87
81
  // and slottedElement might be a just-resolved node
88
82
  if ( _( slottedElement ).get( 'slot@imports' ) ) return;
@@ -11,24 +11,25 @@ export default class HTMLExportsManager {
11
11
  /**
12
12
  * @instance
13
13
  */
14
- static instance( host, params ) {
15
- return _( host ).get( 'exportsmanager::instance' ) || new this( host, params );;
14
+ static instance( window, host, config ) {
15
+ return _( host ).get( 'exportsmanager::instance' ) || new this( window, host, config );
16
16
  }
17
17
 
18
18
  /**
19
19
  * @constructor
20
20
  */
21
- constructor( host, params, parent = null, level = 0 ) {
21
+ constructor( window, host, config = {}, parent = null, level = 0 ) {
22
22
  _( host ).get( `exportsmanager::instance` )?.dispose();
23
23
  _( host ).set( `exportsmanager::instance`, this );
24
24
  this.host = host;
25
- this.params = params;
25
+ this.window = window;
26
+ this.config = config;
26
27
  this.parent = parent;
27
28
  this.level = level;
28
29
  this.modules = getModulesObject( this.host );
29
- this.exportId = ( this.host.getAttribute( this.params.template.attr.exportid ) || '' ).trim();
30
+ this.exportId = ( this.host.getAttribute( this.config.template?.attr.exportid ) || '' ).trim();
30
31
  this.validateExportId( this.exportId );
31
- const dom = params.window.wq.dom;
32
+ const dom = this.window.webqit.dom;
32
33
  // ----------
33
34
  this.realtimeA = dom.realtime( this.host.content ).children( record => {
34
35
  this.export( record.entrants, true );
@@ -71,18 +72,18 @@ export default class HTMLExportsManager {
71
72
  const fragmentsExports = new Map;
72
73
  entries.forEach( entry => {
73
74
  if ( entry.nodeType !== 1 ) return;
74
- const exportId = ( entry.getAttribute( this.params.export.attr.exportid ) || '' ).trim() || '#default';
75
- const isPackage = entry.matches( this.params.templateSelector );
75
+ const exportId = ( entry.getAttribute( this.config.export.attr.exportid ) || '' ).trim() || '#default';
76
+ const isPackage = entry.matches( this.config.templateSelector );
76
77
  if ( exportId.startsWith( '#' ) ) {
77
78
  this.validateExportId( exportId.substring( 1 ) );
78
79
  if ( !fragmentsExports.has( exportId ) ) { fragmentsExports.set( exportId, [] ); }
79
80
  fragmentsExports.get( exportId ).push( entry );
80
81
  } else {
81
82
  if ( isConnected ) {
82
- if ( isPackage ) { new HTMLExportsManager( entry, this.params, this.host, this.level + 1 ); }
83
+ if ( isPackage ) { new HTMLExportsManager( this.window, entry, this.config, this.host, this.level + 1 ); }
83
84
  Observer.set( this.modules, exportId, entry );
84
85
  } else {
85
- if ( isPackage ) { HTMLModulesGraph.instance( entry, this.params ).dispose(); }
86
+ if ( isPackage ) { HTMLExportsManager.instance( this.window, entry ).dispose(); }
86
87
  Observer.deleteProperty( this.modules, exportId );
87
88
  }
88
89
  }
@@ -128,15 +129,14 @@ export default class HTMLExportsManager {
128
129
  * @return Promise
129
130
  */
130
131
  load( src ) {
131
- const window = this.params.window;
132
132
  if ( this.host.content.children.length ) return;
133
133
  // Ongoing request?
134
134
  if ( this.fetchInFlight?.src === src ) return this.fetchInFlight.request;
135
135
  this.fetchInFlight?.controller.abort();
136
136
  // The promise
137
137
  const controller = new AbortController();
138
- const fire = ( type, detail ) => this.host.dispatchEvent( new window.CustomEvent( type, { detail } ) );
139
- const request = window.fetch( src, { signal: controller.signal } ).then( response => {
138
+ const fire = ( type, detail ) => this.host.dispatchEvent( new this.window.CustomEvent( type, { detail } ) );
139
+ const request = this.window.fetch( src, { signal: controller.signal } ).then( response => {
140
140
  return response.ok ? response.text() : Promise.reject( response.statusText );
141
141
  }).then( content => {
142
142
  this.host.innerHTML = content.trim(); // IMPORTANT: .trim()
@@ -159,8 +159,8 @@ export default class HTMLExportsManager {
159
159
  */
160
160
  evalInheritance( ) {
161
161
  if ( !this.parent ) return [];
162
- let extendedId = ( this.host.getAttribute( this.params.template.attr.extends ) || '' ).trim();
163
- let inheritedIds = ( this.host.getAttribute( this.params.template.attr.inherits ) || '' ).trim();
162
+ let extendedId = ( this.host.getAttribute( this.config.template.attr.extends ) || '' ).trim();
163
+ let inheritedIds = ( this.host.getAttribute( this.config.template.attr.inherits ) || '' ).trim();
164
164
  const handleInherited = records => {
165
165
  records.forEach( record => {
166
166
  if ( Observer.get( this.modules, record.key ) !== record.oldValue ) return;
@@ -174,7 +174,7 @@ export default class HTMLExportsManager {
174
174
  const realtimes = [];
175
175
  const parentExportsObj = getModulesObject( this.parent );
176
176
  if ( extendedId ) {
177
- realtimes.push( Observer.deep( parentExportsObj, [ extendedId, this.params.template.api.modules, Infinity ], Observer.get, handleInherited, { live: true } ) );
177
+ realtimes.push( Observer.deep( parentExportsObj, [ extendedId, this.config.template.api.modules, Infinity ], Observer.get, handleInherited, { live: true } ) );
178
178
  }
179
179
  if ( ( inheritedIds = inheritedIds.split( ' ' ).map( id => id.trim() ).filter( x => x ) ).length ) {
180
180
  realtimes.push( Observer.get( parentExportsObj, inheritedIds, handleInherited, { live: true } ) );
@@ -193,7 +193,7 @@ export default class HTMLExportsManager {
193
193
  this.realtimeC.forEach( r => r.abort() );
194
194
  Object.entries( this.modules ).forEach( ( [ key, entry ] ) => {
195
195
  if ( key.startsWith( '#' ) ) return;
196
- HTMLExportsManager.instance( entry ).dispose();
196
+ HTMLExportsManager.instance( this.window, entry ).dispose();
197
197
  } );
198
198
  }
199
199
  }
@@ -39,9 +39,9 @@ export default class _HTMLImportsContext extends HTMLContext {
39
39
 
40
40
  // Parse and translate detail
41
41
  if ( ( event.request.detail || '' ).trim() === '/' ) return event.respondWith( this.modules );
42
- const $params = this.constructor.params;
42
+ const $config = this.constructor.config;
43
43
  let path = ( event.request.detail || '' ).split( /\/|(?<=\w)(?=\W)/g ).map( x => x.trim() ).filter( x => x );
44
- if ( path.length ) { path = path.join( `/${ $params.template.api.modules }/` )?.split( '/' ) || []; }
44
+ if ( path.length ) { path = path.join( `/${ $config.template.api.modules }/` )?.split( '/' ) || []; }
45
45
  // No detail?
46
46
  if ( !path.length ) return event.respondWith();
47
47
 
@@ -70,12 +70,12 @@ export default class _HTMLImportsContext extends HTMLContext {
70
70
  }
71
71
  };
72
72
  // ----------------
73
- const $params = this.constructor.params;
74
- if ( !this.host.matches || !$params.context.attr.importscontext ) return;
73
+ const $config = this.constructor.config;
74
+ if ( !this.host.matches || !$config.context.attr.importscontext ) return;
75
75
  // Any existing this.refdSourceController? Abort!
76
76
  this.refdSourceController?.disconnect();
77
- const dom = this.host.ownerDocument.defaultView.wq.dom;
78
- this.refdSourceController = dom.realtime( this.host ).attr( $params.context.attr.importscontext, ( record, { signal } ) => {
77
+ const dom = this.host.ownerDocument.defaultView.webqit.dom;
78
+ this.refdSourceController = dom.realtime( this.host ).attr( $config.context.attr.importscontext, ( record, { signal } ) => {
79
79
  // No importscontext attr set. But we're still watching
80
80
  if ( !record.value ) {
81
81
  this.altModules = undefined;