@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.
- package/.gitignore +3 -3
- package/LICENSE +20 -20
- package/README.md +399 -396
- package/dist/context-api.js +2 -0
- package/dist/context-api.js.map +7 -0
- package/dist/html-imports.js +1 -2
- package/dist/html-imports.js.map +3 -3
- package/dist/html-modules.js +1 -2
- package/dist/html-modules.js.map +3 -3
- package/dist/main.js +26 -14
- package/dist/main.js.map +3 -3
- package/dist/namespaced-html.js +1 -2
- package/dist/namespaced-html.js.map +3 -3
- package/dist/scoped-js.js +27 -0
- package/dist/scoped-js.js.map +7 -0
- package/dist/state-api.js +1 -2
- package/dist/state-api.js.map +3 -3
- package/package.json +76 -76
- package/src/context-api/HTMLContext.js +158 -0
- package/src/context-api/HTMLContextManager.js +77 -0
- package/src/context-api/_ContextRequestEvent.js +26 -0
- package/src/context-api/index.js +53 -0
- package/src/{namespaced-html/browser-entry.js → context-api/targets.browser.js} +9 -9
- package/src/html-imports/_HTMLImportElement.js +216 -0
- package/src/html-imports/index.js +92 -557
- package/src/{browser-entry.js → html-imports/targets.browser.js} +10 -10
- package/src/html-modules/HTMLExportsManager.js +191 -0
- package/src/html-modules/_HTMLImportsContext.js +114 -0
- package/src/html-modules/index.js +133 -384
- package/src/{html-imports/browser-entry.js → html-modules/targets.browser.js} +9 -9
- package/src/index.js +34 -39
- package/src/namespaced-html/index.js +130 -144
- package/src/namespaced-html/targets.browser.js +10 -0
- package/src/scoped-js/index.js +382 -0
- package/src/scoped-js/targets.browser.js +10 -0
- package/src/state-api/index.js +55 -142
- package/src/state-api/targets.browser.js +10 -0
- package/src/{html-modules/browser-entry.js → targets.browser.js} +10 -10
- package/src/util.js +20 -180
- package/test/imports.test.js +194 -0
- package/test/index.js +119 -0
- package/test/modules.test.js +198 -0
- package/test/namespaced-html.test.js +50 -0
- package/test/scoped-js.js +57 -0
- package/test/state-api.test.js +34 -0
- package/test/test.html +69 -0
- package/dist/subscript.js +0 -15
- package/dist/subscript.js.map +0 -7
- package/src/state-api/browser-entry.js +0 -10
- package/src/subscript/Element.js +0 -103
- package/src/subscript/browser-entry.js +0 -10
- package/src/subscript/index.js +0 -70
- package/test/all.test.js +0 -0
package/src/subscript/Element.js
DELETED
|
@@ -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
|
-
}
|
package/src/subscript/index.js
DELETED
|
@@ -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
|