@webqit/oohtml 2.1.2 → 2.1.3
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/dist/context-api.js +1 -1
- package/dist/context-api.js.map +3 -3
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/html-modules.js +1 -1
- package/dist/html-modules.js.map +2 -2
- package/dist/main.js +7 -7
- package/dist/main.js.map +2 -2
- package/dist/scoped-js.js +7 -7
- package/dist/scoped-js.js.map +2 -2
- package/package.json +1 -1
- package/src/context-api/index.js +4 -0
- package/src/html-imports/index.js +7 -5
- package/src/html-modules/index.js +9 -7
- package/src/scoped-js/index.js +16 -9
- package/src/scoped-js/targets.browser.js +3 -2
package/package.json
CHANGED
package/src/context-api/index.js
CHANGED
|
@@ -15,6 +15,10 @@ 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
|
+
// -------
|
|
20
|
+
window.wq.HTMLContextManager = HTMLContextManager;
|
|
21
|
+
window.wq.HTMLContext = HTMLContext;
|
|
18
22
|
// -------
|
|
19
23
|
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
20
24
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
78
|
+
HTMLImportElement.instance( importEl )[ '#' ].hydrate(
|
|
77
79
|
node/* the comment node */, slottedElements
|
|
78
80
|
);
|
|
79
81
|
slottedElements.clear();
|
|
@@ -17,6 +17,7 @@ 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 = {}; }
|
|
20
21
|
// -------
|
|
21
22
|
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
22
23
|
template: { attr: { exportid: 'exportid', extends: 'extends', inherits: 'inherits' }, api: { modules: 'modules', exportid: 'exportid' }, },
|
|
@@ -27,9 +28,10 @@ export default function init( $params = {} ) {
|
|
|
27
28
|
params.window = window;
|
|
28
29
|
params.templateSelector = `template[${ window.CSS.escape( params.template.attr.exportid ) }]`;
|
|
29
30
|
params.ownerContextSelector = [ params.context.attr.contextname, params.context.attr.importscontext ].map( a => `[${ window.CSS.escape( a ) }]` ).join( ',' );
|
|
30
|
-
|
|
31
|
+
// -------
|
|
32
|
+
window.wq.HTMLImportsContext = class extends _HTMLImportsContext {
|
|
31
33
|
static get params() { return params; }
|
|
32
|
-
}
|
|
34
|
+
};
|
|
33
35
|
// -------
|
|
34
36
|
exposeModulesObjects.call( this, params );
|
|
35
37
|
realtime.call( this, params );
|
|
@@ -92,15 +94,15 @@ function exposeModulesObjects( params ) {
|
|
|
92
94
|
* @return Void
|
|
93
95
|
*/
|
|
94
96
|
function realtime( params ) {
|
|
95
|
-
const window = this, { dom } = window.wq;
|
|
97
|
+
const window = this, { dom, HTMLImportsContext } = window.wq;
|
|
96
98
|
// ------------
|
|
97
99
|
const attachImportsContext = host => {
|
|
98
|
-
const contextId =
|
|
99
|
-
|
|
100
|
+
const contextId = HTMLImportsContext.createId( host );
|
|
101
|
+
HTMLImportsContext.attachTo( host, contextId );
|
|
100
102
|
};
|
|
101
103
|
const detachImportsContext = ( host, force ) => {
|
|
102
|
-
const contextId =
|
|
103
|
-
|
|
104
|
+
const contextId = HTMLImportsContext.createId( host );
|
|
105
|
+
HTMLImportsContext.detachFrom( host, contextId, cx => {
|
|
104
106
|
return force || host.matches && !host.matches( params.ownerContextSelector ) && !Object.keys( cx.modules ).length;
|
|
105
107
|
} );
|
|
106
108
|
};
|
package/src/scoped-js/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
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,17 @@ 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
|
+
// -------
|
|
19
|
+
window.wq.SubscriptFunction = SubscriptFunction;
|
|
17
20
|
// -------
|
|
18
21
|
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
19
22
|
script: { retention: 'retain', mimeType: '' },
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
config: resolveParams( {
|
|
24
|
+
parserParams: { allowReturnOutsideFunction: false, allowSuperOutsideMethod: false },
|
|
25
|
+
compilerParams: { globalsNoObserve: [ 'alert' ] },
|
|
26
|
+
runtimeParams: { apiVersion: 2 },
|
|
27
|
+
} ),
|
|
23
28
|
} );
|
|
24
29
|
params.scriptSelector = ( Array.isArray( params.script.mimeType ) ? params.script.mimeType : [ params.script.mimeType ] ).reduce( ( selector, mm ) => {
|
|
25
30
|
const qualifier = mm ? `[type=${ window.CSS.escape( mm ) }]` : '';
|
|
@@ -29,7 +34,10 @@ export default function init( $params = {} ) {
|
|
|
29
34
|
realtime.call( this, params );
|
|
30
35
|
}
|
|
31
36
|
|
|
32
|
-
export {
|
|
37
|
+
export {
|
|
38
|
+
SubscriptFunction,
|
|
39
|
+
Observer,
|
|
40
|
+
}
|
|
33
41
|
|
|
34
42
|
/**
|
|
35
43
|
* Performs realtime capture of elements and builds their relationships.
|
|
@@ -136,9 +144,8 @@ export function compile( script, thisContext, params = {} ) {
|
|
|
136
144
|
}
|
|
137
145
|
}
|
|
138
146
|
// Let's obtain a material functions
|
|
139
|
-
let _Function;
|
|
147
|
+
let _Function, { parserParams, compilerParams, runtimeParams } = params.config;
|
|
140
148
|
if ( script.contract ) {
|
|
141
|
-
let { parserParams, compilerParams, runtimeParams } = params;
|
|
142
149
|
parserParams = { ...parserParams, allowAwaitOutsideFunction: script.type === 'module' };
|
|
143
150
|
runtimeParams = { ...runtimeParams, async: script.type === 'module' };
|
|
144
151
|
_Function = SubscriptFunction( source, { compilerParams, parserParams, runtimeParams, } );
|
|
@@ -146,8 +153,8 @@ export function compile( script, thisContext, params = {} ) {
|
|
|
146
153
|
} else {
|
|
147
154
|
const isAsync = script.type === 'module'//meta.topLevelAwait || imports.length;
|
|
148
155
|
const _FunctionConstructor = isAsync ? Object.getPrototypeOf( async function() {} ).constructor : Function;
|
|
149
|
-
_Function =
|
|
150
|
-
?
|
|
156
|
+
_Function = runtimeParams?.compileFunction
|
|
157
|
+
? runtimeParams.compileFunction( source )
|
|
151
158
|
: new _FunctionConstructor( source );
|
|
152
159
|
Object.defineProperty( _Function, 'originalSource', { configurable: true, value: script.textContent } );
|
|
153
160
|
}
|