@webqit/oohtml 4.0.0 → 4.0.2
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/README.md +31 -11
- package/dist/data-binding.js +7 -7
- package/dist/data-binding.js.map +2 -2
- package/dist/main.js +19 -19
- package/dist/main.js.map +3 -3
- package/dist/main.lite.js +8 -8
- package/dist/main.lite.js.map +3 -3
- package/dist/scoped-js.js +1 -1
- package/dist/scoped-js.js.map +2 -2
- package/package.json +4 -4
- package/src/data-binding/index.js +1 -1
- package/src/index.js +3 -21
- package/src/{api.global.lite.js → index.lite.js} +1 -1
- package/src/init.js +28 -0
- package/src/scoped-js/index.js +9 -5
- package/src/api.global.js +0 -11
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"wicg-proposal"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://webqit.io/tooling/oohtml",
|
|
17
|
-
"version": "4.0.
|
|
17
|
+
"version": "4.0.2",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"test": "mocha --extension .test.js --exit",
|
|
31
31
|
"test:coverage": "c8 --reporter=text-lcov npm run test | coveralls",
|
|
32
|
-
"build": "esbuild main=src/
|
|
32
|
+
"build": "esbuild main=src/index.js main.lite=src/index.lite.js context-api=src/context-api/targets.browser.js bindings-api=src/bindings-api/targets.browser.js namespaced-html=src/namespaced-html/targets.browser.js html-imports=src/html-imports/targets.browser.js data-binding=src/data-binding/targets.browser.js scoped-css=src/scoped-css/targets.browser.js scoped-js=src/scoped-js/targets.browser.js --bundle --minify --sourcemap --outdir=dist",
|
|
33
33
|
"preversion": "npm test && npm run build && git add -A dist",
|
|
34
34
|
"postversion": "npm publish",
|
|
35
35
|
"postpublish": "git push && git push --tags"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@webqit/quantum-js": "^4.
|
|
38
|
+
"@webqit/quantum-js": "^4.5.2",
|
|
39
39
|
"@webqit/realdom": "^2.1.23",
|
|
40
40
|
"@webqit/util": "^0.8.11"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@webqit/oohtml-ssr": "^2.
|
|
43
|
+
"@webqit/oohtml-ssr": "^2.1.1",
|
|
44
44
|
"chai": "^4.3.4",
|
|
45
45
|
"coveralls": "^3.1.1",
|
|
46
46
|
"esbuild": "^0.14.43",
|
|
@@ -90,7 +90,7 @@ function cleanup( ...entries ) {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
async function mountDiscreteBindings( config, ...entries ) {
|
|
93
|
-
const window = this
|
|
93
|
+
const window = this;
|
|
94
94
|
const patternMatch = str => {
|
|
95
95
|
const tagStart = config.tokens.tagStart.split( '' ).map( x => `\\${ x }` ).join( '' );
|
|
96
96
|
const tagEnd = config.tokens.tagEnd.split( '' ).map( x => `\\${ x }` ).join( '' );
|
package/src/index.js
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* @imports
|
|
4
3
|
*/
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import ScopedJS from './scoped-js/index.js';
|
|
8
|
-
import ContextAPI from './context-api/index.js';
|
|
9
|
-
import BindingsAPI from './bindings-api/index.js';
|
|
10
|
-
import HTMLImports from './html-imports/index.js';
|
|
11
|
-
import DataBinding from './data-binding/index.js';
|
|
4
|
+
import * as QuantumJS from `@webqit/quantum-js`;
|
|
5
|
+
import init from './init.js';
|
|
12
6
|
|
|
13
7
|
/**
|
|
14
8
|
* @init
|
|
15
9
|
*/
|
|
16
|
-
|
|
17
|
-
if ( !this.webqit ) { this.webqit = {}; }
|
|
18
|
-
Object.assign( this.webqit, QuantumJS );
|
|
19
|
-
// --------------
|
|
20
|
-
ContextAPI.call( this, ( configs.CONTEXT_API || {} ) );
|
|
21
|
-
BindingsAPI.call( this, ( configs.BINDINGS_API || {} ) ); // Depends on ContextAPI
|
|
22
|
-
NamespacedHTML.call( this, ( configs.NAMESPACED_HTML || {} ) ); // Depends on ContextAPI
|
|
23
|
-
HTMLImports.call( this, ( configs.HTML_IMPORTS || {} ) ); // Depends on ContextAPI
|
|
24
|
-
DataBinding.call( this, ( configs.DATA_BINDING || {} ) ); // Depends on ContextAPI, BindingsAPI, HTMLImports
|
|
25
|
-
ScopedCSS.call( this, ( configs.SCOPED_CSS || {} ) ); // Depends on NamespacedHTML
|
|
26
|
-
ScopedJS.call( this, ( configs.SCOPED_JS || {} ) );
|
|
27
|
-
// --------------
|
|
28
|
-
}
|
|
10
|
+
init.call( window, QuantumJS );
|
package/src/init.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import NamespacedHTML from './namespaced-html/index.js';
|
|
6
|
+
import ScopedCSS from './scoped-css/index.js';
|
|
7
|
+
import ScopedJS from './scoped-js/index.js';
|
|
8
|
+
import ContextAPI from './context-api/index.js';
|
|
9
|
+
import BindingsAPI from './bindings-api/index.js';
|
|
10
|
+
import HTMLImports from './html-imports/index.js';
|
|
11
|
+
import DataBinding from './data-binding/index.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @init
|
|
15
|
+
*/
|
|
16
|
+
export default function init( QuantumJS, configs = {} ) {
|
|
17
|
+
if ( !this.webqit ) { this.webqit = {}; }
|
|
18
|
+
Object.assign( this.webqit, QuantumJS );
|
|
19
|
+
// --------------
|
|
20
|
+
ContextAPI.call( this, ( configs.CONTEXT_API || {} ) );
|
|
21
|
+
BindingsAPI.call( this, ( configs.BINDINGS_API || {} ) ); // Depends on ContextAPI
|
|
22
|
+
NamespacedHTML.call( this, ( configs.NAMESPACED_HTML || {} ) ); // Depends on ContextAPI
|
|
23
|
+
HTMLImports.call( this, ( configs.HTML_IMPORTS || {} ) ); // Depends on ContextAPI
|
|
24
|
+
DataBinding.call( this, ( configs.DATA_BINDING || {} ) ); // Depends on ContextAPI, BindingsAPI, HTMLImports
|
|
25
|
+
ScopedCSS.call( this, ( configs.SCOPED_CSS || {} ) ); // Depends on NamespacedHTML
|
|
26
|
+
ScopedJS.call( this, ( configs.SCOPED_JS || {} ) );
|
|
27
|
+
// --------------
|
|
28
|
+
}
|
package/src/scoped-js/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @imports
|
|
4
4
|
*/
|
|
5
5
|
import { resolveParams } from '@webqit/quantum-js/params';
|
|
6
|
-
import { _init, _toHash, _fromHash } from '../util.js';
|
|
6
|
+
import { _, _init, _toHash, _fromHash } from '../util.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @init
|
|
@@ -71,9 +71,13 @@ async function execute( config, execHash ) {
|
|
|
71
71
|
script.textContent = await compiledScript.toString();
|
|
72
72
|
}
|
|
73
73
|
// Execute and save state
|
|
74
|
-
const
|
|
74
|
+
const documentRoot = script.getRootNode();
|
|
75
|
+
if ( !_( documentRoot ).has( 'scriptEnv' ) ) {
|
|
76
|
+
_( documentRoot ).set( 'scriptEnv', Object.create( null ) );
|
|
77
|
+
}
|
|
78
|
+
const state = ( await compiledScript.bind( thisContext, _( documentRoot ).get( 'scriptEnv' ) ) ).execute();
|
|
75
79
|
if ( script.quantum ) { Object.defineProperty( script, 'state', { value: state } ); }
|
|
76
|
-
realdom.realtime(
|
|
80
|
+
realdom.realtime( documentRoot ).observe( script, () => {
|
|
77
81
|
if ( script.quantum ) { state.dispose(); }
|
|
78
82
|
if ( script.scoped ) { thisContext[ config.api.scripts ].splice( thisContext[ config.api.scripts ].indexOf( script, 1 ) ); }
|
|
79
83
|
}, { subtree: true, timing: 'sync', generation: 'exits' } );
|
|
@@ -87,7 +91,7 @@ async function execute( config, execHash ) {
|
|
|
87
91
|
* @return Void
|
|
88
92
|
*/
|
|
89
93
|
function realtime( config ) {
|
|
90
|
-
const window = this, { webqit: { oohtml, realdom, QuantumScript,
|
|
94
|
+
const window = this, { webqit: { oohtml, realdom, QuantumScript, AsyncQuantumScript, QuantumModule } } = window;
|
|
91
95
|
if ( !window.HTMLScriptElement.supports ) { window.HTMLScriptElement.supports = type => [ 'text/javascript', 'application/javascript' ].includes( type ); }
|
|
92
96
|
const handled = new WeakSet;
|
|
93
97
|
realdom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.scriptSelector, record => {
|
|
@@ -102,7 +106,7 @@ function realtime( config ) {
|
|
|
102
106
|
let compiledScript;
|
|
103
107
|
if ( !( compiledScript = compileCache.get( sourceHash ) ) ) {
|
|
104
108
|
const { parserParams, compilerParams, runtimeParams } = config.advanced;
|
|
105
|
-
compiledScript = new ( script.type === 'module' ? QuantumModule : ( QuantumScript ||
|
|
109
|
+
compiledScript = new ( script.type === 'module' ? QuantumModule : ( QuantumScript || AsyncQuantumScript ) )( textContent, {
|
|
106
110
|
exportNamespace: `#${ script.id }`,
|
|
107
111
|
fileName: `${ window.document.url?.split( '#' )?.[ 0 ] || '' }#${ script.id }`,
|
|
108
112
|
parserParams: { ...parserParams, quantumMode: script.quantum },
|