@webqit/oohtml 1.9.16 → 1.9.19

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.
Binary file
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "1.9.16",
17
+ "version": "1.9.19",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -40,7 +40,7 @@
40
40
  "dependencies": {
41
41
  "@webqit/browser-pie": "^0.0.17",
42
42
  "@webqit/observer": "^1.7.5",
43
- "@webqit/subscript": "^2.0.26",
43
+ "@webqit/subscript": "^2.1.4",
44
44
  "@webqit/util": "^0.8.7",
45
45
  "acorn": "^8.7.0"
46
46
  },
@@ -7,4 +7,4 @@ import init from './index.js';
7
7
  /**
8
8
  * @init
9
9
  */
10
- init.call(window);
10
+ init.call( window );
@@ -21,13 +21,13 @@ import { config, scopeQuery,
21
21
  *
22
22
  * @param Object config
23
23
  */
24
- export default function init(_config = null, onDomReady = false) {
24
+ export default function init( _config = {} ) {
25
25
 
26
- const WebQit = domInit.call(this);
27
- if (onDomReady) {
28
- WebQit.DOM.ready(() => {
29
- init.call(this, _config, false);
30
- });
26
+ const WebQit = domInit.call( this );
27
+ if ( _config.onDomReady ) {
28
+ WebQit.DOM.ready( () => {
29
+ init.call( this, { ..._config, onDomReady: false } );
30
+ } );
31
31
  return;
32
32
  }
33
33
 
@@ -44,7 +44,7 @@ export default function init(_config = null, onDomReady = false) {
44
44
  importid: 'name',
45
45
  exportsearch: 'exportsearch',
46
46
  },
47
- }, _config);
47
+ }, _config.params );
48
48
 
49
49
  _defaultNoInherits.push(_meta.get('attr.importid'), _meta.get('attr.moduleref'));
50
50
  const modulerefSelector = '[' + window.CSS.escape(_meta.get('attr.moduleref')) + ']';
@@ -7,4 +7,4 @@ import init from './index.js';
7
7
  /**
8
8
  * @init
9
9
  */
10
- init.call(window);
10
+ init.call( window );
@@ -19,13 +19,13 @@ import { config, scopeQuery } from '../util.js';
19
19
  *
20
20
  * @param Object config
21
21
  */
22
- export default function init(_config = null, onDomReady = false) {
22
+ export default function init( _config = {} ) {
23
23
 
24
- const WebQit = domInit.call(this);
25
- if (onDomReady) {
26
- WebQit.DOM.ready(() => {
27
- init.call(this, _config, false);
28
- });
24
+ const WebQit = domInit.call( this );
25
+ if ( _config.onDomReady ) {
26
+ WebQit.DOM.ready( () => {
27
+ init.call( this, { ..._config, onDomReady: false } );
28
+ } );
29
29
  return;
30
30
  }
31
31
 
@@ -51,7 +51,7 @@ export default function init(_config = null, onDomReady = false) {
51
51
  exports: 'exports',
52
52
  moduleref: 'template',
53
53
  },
54
- }, _config);
54
+ }, _config.params );
55
55
 
56
56
  const templateSelector = 'template' + (_meta.get('element.template') ? '[is="' + _meta.get('element.template') + '"]' : '') + '[' + window.CSS.escape(_meta.get('attr.moduleid')) + ']';
57
57
  var TemplateElementClass = window.HTMLTemplateElement;
package/src/index.js CHANGED
@@ -13,7 +13,7 @@ import Subscript from './subscript/index.js';
13
13
  /**
14
14
  * @init
15
15
  */
16
- export default function init(config = null, onDomReady = false) {
16
+ export default function init(configs = {}) {
17
17
 
18
18
  const WebQit = domInit.call(this);
19
19
  if (WebQit.OOHTML) {
@@ -21,11 +21,11 @@ export default function init(config = null, onDomReady = false) {
21
21
  }
22
22
  WebQit.OOHTML = {};
23
23
  // --------------
24
- HTMLModules.call(this, config, onDomReady);
25
- HTMLImports.call(this, config, onDomReady);
26
- NamespacedHTML.call(this, config, onDomReady);
27
- StateAPI.call(this, config, onDomReady);
28
- Subscript.call(this, config, onDomReady);
24
+ HTMLModules.call(this, (configs.HTMLModules || {}));
25
+ HTMLImports.call(this, (configs.HTMLImports || {}));
26
+ NamespacedHTML.call(this, (configs.NamespacedHTML || {}));
27
+ StateAPI.call(this, (configs.StateAPI || {}));
28
+ Subscript.call(this, (configs.Subscript || {}));
29
29
  // --------------
30
30
  WebQit.Observer = Observer;
31
31
 
@@ -7,4 +7,4 @@ import init from './index.js';
7
7
  /**
8
8
  * @init
9
9
  */
10
- init.call(window);
10
+ init.call( window );
@@ -19,13 +19,13 @@ import { config } from '../util.js';
19
19
  *
20
20
  * @param Object config
21
21
  */
22
- export default function init(_config = null, onDomReady = false) {
22
+ export default function init( _config = {} ) {
23
23
 
24
- const WebQit = domInit.call(this);
25
- if (onDomReady) {
26
- WebQit.DOM.ready(() => {
27
- init.call(this, _config, false);
28
- });
24
+ const WebQit = domInit.call( this );
25
+ if ( _config.onDomReady ) {
26
+ WebQit.DOM.ready( () => {
27
+ init.call( this, { ..._config, onDomReady: false } );
28
+ } );
29
29
  return;
30
30
  }
31
31
 
@@ -43,7 +43,7 @@ export default function init(_config = null, onDomReady = false) {
43
43
  namespace: 'namespace',
44
44
  },
45
45
  eagermode: true,
46
- }, _config);
46
+ }, _config.params );
47
47
 
48
48
  const getNamespaceObject = function(subject) {
49
49
  if (!_internals(subject, 'oohtml').has('namespace')) {
@@ -7,4 +7,4 @@ import init from './index.js';
7
7
  /**
8
8
  * @init
9
9
  */
10
- init.call(window);
10
+ init.call( window );
@@ -19,13 +19,13 @@ import { config } from '../util.js';
19
19
  *
20
20
  * @param Object config
21
21
  */
22
- export default function init(_config = null, onDomReady = false) {
22
+ export default function init( _config = {} ) {
23
23
 
24
- const WebQit = domInit.call(this);
25
- if (onDomReady) {
26
- WebQit.DOM.ready(() => {
27
- init.call(this, _config, false);
28
- });
24
+ const WebQit = domInit.call( this );
25
+ if ( _config.onDomReady ) {
26
+ WebQit.DOM.ready( () => {
27
+ init.call( this, { ..._config, onDomReady: false } );
28
+ } );
29
29
  return;
30
30
  }
31
31
 
@@ -34,7 +34,7 @@ export default function init(_config = null, onDomReady = false) {
34
34
 
35
35
  const _meta = config.call(this, {
36
36
  api: {state: 'state', setState: 'setState', clearState: 'clearState',},
37
- }, _config);
37
+ }, _config.params );
38
38
 
39
39
  const getOrCreateState = function(subject, newStateObject = null) {
40
40
  if (!_internals(subject, 'oohtml').has('state') || newStateObject) {
@@ -21,17 +21,13 @@ export const Element = BaseElement => class extends SubscriptClass( BaseElement
21
21
  return { globalsAutoObserve: [ 'document' ] };
22
22
  }
23
23
 
24
- static get subscriptMethods() {
25
- return [];
26
- }
27
-
28
24
  static expose( element, subscriptFunction ) {
29
- let subscripts = _internals( element, 'oohtml', 'subscripts' );
25
+ let subscriptInstances = _internals( element, 'oohtml', 'subscript', 'instances' );
30
26
  let id = subscriptFunction.name;
31
27
  if ( !id ) {
32
- id = [ ...subscripts.keys() ].filter( k => _isNumeric( k ) ).length;
28
+ id = [ ...subscriptInstances.keys() ].filter( k => _isNumeric( k ) ).length;
33
29
  }
34
- subscripts.set( id, subscriptFunction );
30
+ subscriptInstances.set( id, subscriptFunction );
35
31
  return subscriptFunction;
36
32
  }
37
33
 
@@ -43,7 +39,7 @@ export const Element = BaseElement => class extends SubscriptClass( BaseElement
43
39
 
44
40
  static implementScript( script, element ) {
45
41
  let source = ( script.textContent || '' ).trim();
46
- return this.expose( element, SubscriptFunction.call( element, source ) );
42
+ return this.expose( element, SubscriptFunction.call( element, source, { compilerParams: this.compilerParams, runtimeParams: this.runtimeParams } ) );
47
43
  }
48
44
 
49
45
  /**
@@ -51,9 +47,9 @@ export const Element = BaseElement => class extends SubscriptClass( BaseElement
51
47
  */
52
48
  static doConnectedCallback( instance ) {
53
49
  if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
54
- const subscripts = _internals( instance, 'oohtml', 'subscripts' );
50
+ const subscriptInstances = _internals( instance, 'oohtml', 'subscript', 'instances' );
55
51
  const signals = ( mutations, evt, namespace = [] ) => {
56
- subscripts.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
52
+ subscriptInstances.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
57
53
  };
58
54
  ( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
59
55
  WebQit.Observer.observe( globalThis[ identifier ], mutations => signals( mutations, null, [ identifier ] ), {
@@ -100,8 +96,8 @@ export const Element = BaseElement => class extends SubscriptClass( BaseElement
100
96
  }
101
97
  }
102
98
 
103
- get subscripts() {
104
- return _internals( this, 'oohtml', 'subscripts' );
99
+ get subscript() {
100
+ return _internals( this, 'oohtml', 'subscript', 'instances' );
105
101
  }
106
102
 
107
103
  }
@@ -12,12 +12,12 @@ import { config } from '../util.js';
12
12
  *
13
13
  * @param Object config
14
14
  */
15
- export default function init( _config = null, onDomReady = false ) {
15
+ export default function init( _config = {} ) {
16
16
 
17
17
  const WebQit = domInit.call( this );
18
- if ( onDomReady ) {
18
+ if ( _config.onDomReady ) {
19
19
  WebQit.DOM.ready( () => {
20
- init.call( this, _config, false );
20
+ init.call( this, { ..._config, onDomReady: false } );
21
21
  } );
22
22
  return;
23
23
  }
@@ -27,27 +27,36 @@ export default function init( _config = null, onDomReady = false ) {
27
27
  selectors: { script: 'script[type="subscript"]', },
28
28
  api: { bind: 'bind', unbind: 'unbind', },
29
29
  script: {},
30
- }, _config );
30
+ }, _config.params );
31
31
 
32
- const subscriptElement = Element( class {} );
32
+ const ContextifiableElement = BaseElement => class extends Element( BaseElement ) {
33
+ static get compilerParams() {
34
+ return _config.compilerParams || {};
35
+ }
36
+ static get runtimeParams() {
37
+ return _config.runtimeParams || {};
38
+ }
39
+ };
40
+
41
+ const SubscriptElement = ContextifiableElement();
33
42
  mutations.onPresent( _meta.get('selectors.script'), scriptElement => {
34
43
 
35
44
  let ownerNode = scriptElement.parentNode;
36
45
  if ( !ownerNode ) return;
37
- let embeds = _internals( ownerNode, 'oohtml', 'subscript' ).get( 'embeds' );
38
- if ( !embeds ) {
39
- embeds = new WeakSet;
40
- _internals( ownerNode, 'oohtml', 'subscript' ).set( 'embeds', embeds );
46
+ let scriptTags = _internals( ownerNode, 'oohtml', 'subscript' ).get( 'script-tags' );
47
+ if ( !scriptTags ) {
48
+ scriptTags = new WeakSet;
49
+ _internals( ownerNode, 'oohtml', 'subscript' ).set( 'script-tags', scriptTags );
41
50
  }
42
- if ( embeds.has( scriptElement ) ) return;
51
+ if ( scriptTags.has( scriptElement ) ) return;
43
52
 
44
- subscriptElement.implementScript( scriptElement, ownerNode )();
45
- subscriptElement.doConnectedCallback( ownerNode );
46
- embeds.add( scriptElement );
53
+ SubscriptElement.implementScript( scriptElement, ownerNode )();
54
+ SubscriptElement.doConnectedCallback( ownerNode );
55
+ scriptTags.add( scriptElement );
47
56
 
48
57
  let mo = mutations.onRemoved( ownerNode, () => {
49
- subscriptElement.doDisconnectedCallback( ownerNode );
50
- embeds.delete( scriptElement );
58
+ SubscriptElement.doDisconnectedCallback( ownerNode );
59
+ scriptTags.delete( scriptElement );
51
60
  mo.disconnect();
52
61
  }, { ignoreTransients: true });
53
62
 
@@ -56,6 +65,6 @@ export default function init( _config = null, onDomReady = false ) {
56
65
  if (!WebQit.OOHTML) {
57
66
  WebQit.OOHTML = {};
58
67
  }
59
- WebQit.OOHTML.SubscriptElement = Element;
68
+ WebQit.OOHTML.SubscriptElement = ContextifiableElement;
60
69
 
61
70
  }