@webqit/oohtml 1.10.3 → 2.0.0

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 (53) hide show
  1. package/.gitignore +3 -3
  2. package/LICENSE +20 -20
  3. package/README.md +399 -396
  4. package/dist/context-api.js +2 -0
  5. package/dist/context-api.js.map +7 -0
  6. package/dist/html-imports.js +1 -2
  7. package/dist/html-imports.js.map +3 -3
  8. package/dist/html-modules.js +1 -2
  9. package/dist/html-modules.js.map +3 -3
  10. package/dist/main.js +26 -14
  11. package/dist/main.js.map +3 -3
  12. package/dist/namespaced-html.js +1 -2
  13. package/dist/namespaced-html.js.map +3 -3
  14. package/dist/scoped-js.js +27 -0
  15. package/dist/scoped-js.js.map +7 -0
  16. package/dist/state-api.js +1 -2
  17. package/dist/state-api.js.map +3 -3
  18. package/package.json +76 -76
  19. package/src/context-api/HTMLContext.js +158 -0
  20. package/src/context-api/HTMLContextManager.js +77 -0
  21. package/src/context-api/_ContextRequestEvent.js +26 -0
  22. package/src/context-api/index.js +53 -0
  23. package/src/{namespaced-html/browser-entry.js → context-api/targets.browser.js} +9 -9
  24. package/src/html-imports/_HTMLImportElement.js +216 -0
  25. package/src/html-imports/index.js +92 -557
  26. package/src/{browser-entry.js → html-imports/targets.browser.js} +10 -10
  27. package/src/html-modules/HTMLExportsManager.js +191 -0
  28. package/src/html-modules/_HTMLImportsContext.js +114 -0
  29. package/src/html-modules/index.js +133 -384
  30. package/src/{html-imports/browser-entry.js → html-modules/targets.browser.js} +9 -9
  31. package/src/index.js +34 -39
  32. package/src/namespaced-html/index.js +130 -144
  33. package/src/namespaced-html/targets.browser.js +10 -0
  34. package/src/scoped-js/index.js +382 -0
  35. package/src/scoped-js/targets.browser.js +10 -0
  36. package/src/state-api/index.js +55 -142
  37. package/src/state-api/targets.browser.js +10 -0
  38. package/src/{html-modules/browser-entry.js → targets.browser.js} +10 -10
  39. package/src/util.js +20 -180
  40. package/test/imports.test.js +194 -0
  41. package/test/index.js +119 -0
  42. package/test/modules.test.js +198 -0
  43. package/test/namespaced-html.test.js +50 -0
  44. package/test/scoped-js.js +57 -0
  45. package/test/state-api.test.js +34 -0
  46. package/test/test.html +69 -0
  47. package/dist/subscript.js +0 -15
  48. package/dist/subscript.js.map +0 -7
  49. package/src/state-api/browser-entry.js +0 -10
  50. package/src/subscript/Element.js +0 -103
  51. package/src/subscript/browser-entry.js +0 -10
  52. package/src/subscript/index.js +0 -70
  53. package/test/all.test.js +0 -0
@@ -1,10 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import init from './index.js';
6
-
7
- /**
8
- * @init
9
- */
10
- init.call( window );
@@ -1,103 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { SubscriptFunction, SubscriptClass } from '@webqit/subscript';
6
- import { _internals, _isNumeric, _isFunction } from '@webqit/util/js/index.js';
7
-
8
- /**
9
- * ---------------------------
10
- * Subscript Element
11
- * ---------------------------
12
- */
13
-
14
- export const Element = BaseElement => class extends SubscriptClass( BaseElement ) {
15
-
16
- /**
17
- * @subscript Element
18
- */
19
-
20
- static get subscriptParams() {
21
- return { globalsAutoObserve: [ 'document' ] };
22
- }
23
-
24
- static expose( element, subscriptFunction ) {
25
- let subscriptInstances = _internals( element, 'oohtml', 'subscript', 'instances' );
26
- let id = subscriptFunction.name;
27
- if ( !id ) {
28
- id = [ ...subscriptInstances.keys() ].filter( k => _isNumeric( k ) ).length;
29
- }
30
- subscriptInstances.set( id, subscriptFunction );
31
- return subscriptFunction;
32
- }
33
-
34
-
35
- static implementMethod( method, element ) {
36
- let subscriptFunction = super.implementMethod( method, element );
37
- return this.expose( element, subscriptFunction );
38
- }
39
-
40
- static implementScript( script, element ) {
41
- let source = ( script.textContent || '' ).trim();
42
- return this.expose( element, SubscriptFunction.call( element, source, { compilerParams: this.compilerParams, runtimeParams: this.runtimeParams } ) );
43
- }
44
-
45
- /**
46
- * @disconnectedCallback()
47
- */
48
- static doConnectedCallback( instance ) {
49
- if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
50
- const subscriptInstances = _internals( instance, 'oohtml', 'subscript', 'instances' );
51
- const signals = ( mutations, evt, namespace = [] ) => {
52
- subscriptInstances.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
53
- };
54
- ( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
55
- WebQit.Observer.observe( globalThis[ identifier ], mutations => signals( mutations, null, [ identifier ] ), {
56
- subtree: true, diff: true, tags: [ instance, 'subscript-element', identifier ], unique: true
57
- } );
58
- } );
59
- WebQit.Observer.observe( instance, mutations => signals( mutations, null, [ 'this' ] ), {
60
- subtree: true, diff: true, tags: [ instance, 'subscript-element', 'this' ], unique: true
61
- } );
62
- }
63
-
64
- /**
65
- * @disconnectedCallback()
66
- */
67
- static doDisconnectedCallback( instance ) {
68
- if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
69
- ( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
70
- WebQit.Observer.unobserve( globalThis[ identifier ], null, null, {
71
- subtree: true, tags: [ instance, 'subscript-element', identifier ]
72
- } );
73
- } );
74
- WebQit.Observer.unobserve( instance, null, null, {
75
- subtree: true, tags: [ instance, 'subscript-element', 'this' ]
76
- } );
77
- }
78
-
79
- /**
80
- * @connectedCallback()
81
- */
82
- connectedCallback() {
83
- this.constructor.doConnectedCallback( this );
84
- if ( super.connectedCallback ) {
85
- super.connectedCallback();
86
- }
87
- }
88
-
89
- /**
90
- * @disconnectedCallback()
91
- */
92
- disconnectedCallback() {
93
- this.constructor.doDisconnectedCallback( this );
94
- if ( super.disconnectedCallback ) {
95
- super.disconnectedCallback();
96
- }
97
- }
98
-
99
- get subscript() {
100
- return _internals( this, 'oohtml', 'subscript', 'instances' );
101
- }
102
-
103
- }
@@ -1,10 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import init from './index.js';
6
-
7
- /**
8
- * @init
9
- */
10
- init.call( window );
@@ -1,70 +0,0 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { _internals } from '@webqit/util/js/index.js';
6
- import domInit from '@webqit/browser-pie/src/dom/index.js';
7
- import { Element } from './Element.js';
8
- import { config } from '../util.js';
9
-
10
- /**
11
- * @init
12
- *
13
- * @param Object config
14
- */
15
- export default function init( _config = {} ) {
16
-
17
- const WebQit = domInit.call( this );
18
- if ( _config.onDomReady ) {
19
- WebQit.DOM.ready( () => {
20
- init.call( this, { ..._config, onDomReady: false } );
21
- } );
22
- return;
23
- }
24
-
25
- const mutations = WebQit.DOM.mutations;
26
- const _meta = config.call( this, {
27
- selectors: { script: 'script[type="subscript"]', },
28
- api: { bind: 'bind', unbind: 'unbind', },
29
- script: {},
30
- }, _config.params );
31
-
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();
42
- mutations.onPresent( _meta.get('selectors.script'), scriptElement => {
43
-
44
- let ownerNode = scriptElement.parentNode;
45
- if ( !ownerNode ) return;
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 );
50
- }
51
- if ( scriptTags.has( scriptElement ) ) return;
52
-
53
- SubscriptElement.implementScript( scriptElement, ownerNode )();
54
- SubscriptElement.doConnectedCallback( ownerNode );
55
- scriptTags.add( scriptElement );
56
-
57
- let mo = mutations.onRemoved( ownerNode, () => {
58
- SubscriptElement.doDisconnectedCallback( ownerNode );
59
- scriptTags.delete( scriptElement );
60
- mo.disconnect();
61
- }, { ignoreTransients: true });
62
-
63
- } );
64
-
65
- if (!WebQit.OOHTML) {
66
- WebQit.OOHTML = {};
67
- }
68
- WebQit.OOHTML.SubscriptElement = ContextifiableElement;
69
-
70
- }
package/test/all.test.js DELETED
File without changes