@webqit/oohtml 2.1.2 → 2.1.4

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": "2.1.2",
17
+ "version": "2.1.4",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -15,6 +15,9 @@ import HTMLContext from './HTMLContext.js';
15
15
  */
16
16
  export default function init( $params = { }) {
17
17
  const window = this, dom = wqDom.call( window );
18
+ if ( !window.wq ) { window.wq = {}; }
19
+ window.wq.HTMLContextManager = HTMLContextManager;
20
+ window.wq.HTMLContext = HTMLContext;
18
21
  // -------
19
22
  const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
20
23
  api: { context: 'context', },
@@ -15,6 +15,7 @@ import { _ } from '../util.js';
15
15
  */
16
16
  export default function init( $params = { }) {
17
17
  const window = this, dom = wqDom.call( window );
18
+ if ( !window.wq ) { window.wq = {}; }
18
19
  // -------
19
20
  const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
20
21
  import: { tagName: 'import', attr: { moduleref: 'module' }, },
@@ -22,7 +23,8 @@ export default function init( $params = { }) {
22
23
  isomorphic: true,
23
24
  } );
24
25
  params.slottedElementsSelector = `[${ window.CSS.escape( params.export.attr.exportid ) }]`;
25
- params.HTMLImportElement = _HTMLImportElement.call( this, params );
26
+ // -------
27
+ window.wq.HTMLImportElement = _HTMLImportElement.call( this, params );
26
28
  // -------
27
29
  dom.ready( () => hydration.call( this, params ) );
28
30
  realtime.call( this, params );
@@ -37,13 +39,13 @@ export default function init( $params = { }) {
37
39
  * @return Void
38
40
  */
39
41
  function realtime( params ) {
40
- const window = this, { dom } = window.wq;
42
+ const window = this, { dom, HTMLImportElement } = window.wq;
41
43
  dom.realtime( window.document ).observe( params.import.tagName, record => {
42
44
  record.entrants.forEach( node => handleRealtime( node, true, record ) );
43
45
  record.exits.forEach( node => handleRealtime( node, false, record ) );
44
46
  }, { subtree: true, timing: 'sync' } );
45
47
  function handleRealtime( entry, connectedState, record ) {
46
- const elInstance = params.HTMLImportElement.instance( entry );
48
+ const elInstance = HTMLImportElement.instance( entry );
47
49
  if ( connectedState ) { elInstance[ '#' ].connectedCallback(); }
48
50
  else { elInstance[ '#' ].disconnectedCallback(); }
49
51
  }
@@ -57,7 +59,7 @@ function realtime( params ) {
57
59
  * @return Void
58
60
  */
59
61
  function hydration( params ) {
60
- const window = this;
62
+ const window = this, { HTMLImportElement } = window.wq;
61
63
  function scan( context ) {
62
64
  const slottedElements = new Set;
63
65
  context.childNodes.forEach( node => {
@@ -73,7 +75,7 @@ function hydration( params ) {
73
75
  reviver.innerHTML = nodeValue;
74
76
  const importEl = reviver.firstChild;
75
77
  if ( !importEl.matches( params.import.tagName ) ) return;
76
- params.HTMLImportElement.instance( importEl )[ '#' ].hydrate(
78
+ HTMLImportElement.instance( importEl )[ '#' ].hydrate(
77
79
  node/* the comment node */, slottedElements
78
80
  );
79
81
  slottedElements.clear();
@@ -17,6 +17,10 @@ import { _ } from '../util.js';
17
17
  */
18
18
  export default function init( $params = {} ) {
19
19
  const window = this, dom = wqDom.call( window );
20
+ if ( !window.wq ) { window.wq = {}; }
21
+ window.wq.HTMLImportsContext = class extends _HTMLImportsContext {
22
+ static get params() { return params; }
23
+ };
20
24
  // -------
21
25
  const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
22
26
  template: { attr: { exportid: 'exportid', extends: 'extends', inherits: 'inherits' }, api: { modules: 'modules', exportid: 'exportid' }, },
@@ -27,9 +31,6 @@ export default function init( $params = {} ) {
27
31
  params.window = window;
28
32
  params.templateSelector = `template[${ window.CSS.escape( params.template.attr.exportid ) }]`;
29
33
  params.ownerContextSelector = [ params.context.attr.contextname, params.context.attr.importscontext ].map( a => `[${ window.CSS.escape( a ) }]` ).join( ',' );
30
- params.HTMLImportsContext = class extends _HTMLImportsContext {
31
- static get params() { return params; }
32
- }
33
34
  // -------
34
35
  exposeModulesObjects.call( this, params );
35
36
  realtime.call( this, params );
@@ -92,15 +93,15 @@ function exposeModulesObjects( params ) {
92
93
  * @return Void
93
94
  */
94
95
  function realtime( params ) {
95
- const window = this, { dom } = window.wq;
96
+ const window = this, { dom, HTMLImportsContext } = window.wq;
96
97
  // ------------
97
98
  const attachImportsContext = host => {
98
- const contextId = params.HTMLImportsContext.createId( host );
99
- params.HTMLImportsContext.attachTo( host, contextId );
99
+ const contextId = HTMLImportsContext.createId( host );
100
+ HTMLImportsContext.attachTo( host, contextId );
100
101
  };
101
102
  const detachImportsContext = ( host, force ) => {
102
- const contextId = params.HTMLImportsContext.createId( host );
103
- params.HTMLImportsContext.detachFrom( host, contextId, cx => {
103
+ const contextId = HTMLImportsContext.createId( host );
104
+ HTMLImportsContext.detachFrom( host, contextId, cx => {
104
105
  return force || host.matches && !host.matches( params.ownerContextSelector ) && !Object.keys( cx.modules ).length;
105
106
  } );
106
107
  };
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * @imports
4
4
  */
5
- import { parserParams, compilerParams, runtimeParams } from '@webqit/subscript/src/params.js';
5
+ 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 wqDom from '@webqit/dom';
@@ -14,12 +14,16 @@ import wqDom from '@webqit/dom';
14
14
  */
15
15
  export default function init( $params = {} ) {
16
16
  const window = this, dom = wqDom.call( window );
17
+ if ( !window.wq ) { window.wq = {}; }
18
+ window.wq.SubscriptFunction = SubscriptFunction;
17
19
  // -------
18
20
  const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
19
21
  script: { retention: 'retain', mimeType: '' },
20
- parserParams: { ...parserParams, allowReturnOutsideFunction: false, allowSuperOutsideMethod: false, },
21
- compilerParams: { ...compilerParams, globalsNoObserve: [ ...compilerParams.globalsNoObserve, 'alert' ] },
22
- runtimeParams: { ...runtimeParams, apiVersion: 2, },
22
+ config: resolveParams( {
23
+ parserParams: { allowReturnOutsideFunction: false, allowSuperOutsideMethod: false },
24
+ compilerParams: { globalsNoObserve: [ 'alert' ] },
25
+ runtimeParams: { apiVersion: 2 },
26
+ } ),
23
27
  } );
24
28
  params.scriptSelector = ( Array.isArray( params.script.mimeType ) ? params.script.mimeType : [ params.script.mimeType ] ).reduce( ( selector, mm ) => {
25
29
  const qualifier = mm ? `[type=${ window.CSS.escape( mm ) }]` : '';
@@ -29,7 +33,10 @@ export default function init( $params = {} ) {
29
33
  realtime.call( this, params );
30
34
  }
31
35
 
32
- export { Observer }
36
+ export {
37
+ SubscriptFunction,
38
+ Observer,
39
+ }
33
40
 
34
41
  /**
35
42
  * Performs realtime capture of elements and builds their relationships.
@@ -136,9 +143,8 @@ export function compile( script, thisContext, params = {} ) {
136
143
  }
137
144
  }
138
145
  // Let's obtain a material functions
139
- let _Function;
146
+ let _Function, { parserParams, compilerParams, runtimeParams } = params.config;
140
147
  if ( script.contract ) {
141
- let { parserParams, compilerParams, runtimeParams } = params;
142
148
  parserParams = { ...parserParams, allowAwaitOutsideFunction: script.type === 'module' };
143
149
  runtimeParams = { ...runtimeParams, async: script.type === 'module' };
144
150
  _Function = SubscriptFunction( source, { compilerParams, parserParams, runtimeParams, } );
@@ -146,8 +152,8 @@ export function compile( script, thisContext, params = {} ) {
146
152
  } else {
147
153
  const isAsync = script.type === 'module'//meta.topLevelAwait || imports.length;
148
154
  const _FunctionConstructor = isAsync ? Object.getPrototypeOf( async function() {} ).constructor : Function;
149
- _Function = params.runtimeParams?.compileFunction
150
- ? params.runtimeParams.compileFunction( source )
155
+ _Function = runtimeParams?.compileFunction
156
+ ? runtimeParams.compileFunction( source )
151
157
  : new _FunctionConstructor( source );
152
158
  Object.defineProperty( _Function, 'originalSource', { configurable: true, value: script.textContent } );
153
159
  }
@@ -8,6 +8,7 @@ import init, { Observer } from './index.js';
8
8
  * @init
9
9
  */
10
10
  init.call( window );
11
+
11
12
  // As globals
12
- if ( !window.wq ) { window.wq = {}; }
13
- window.wq.Observer = Observer;
13
+ if ( !self.wq ) { self.wq = {}; }
14
+ self.wq.Observer = Observer;
@@ -8,6 +8,7 @@ import init, { Observer } from './index.js';
8
8
  * @init
9
9
  */
10
10
  init.call( window );
11
+
11
12
  // As globals
12
- if ( !window.wq ) { window.wq = {}; }
13
- window.wq.Observer = Observer;
13
+ if ( !self.wq ) { self.wq = {}; }
14
+ self.wq.Observer = Observer;