@webqit/oohtml 3.1.22 → 4.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/README.md +24 -22
- package/dist/data-binding.js +1 -1
- package/dist/data-binding.js.map +2 -2
- package/dist/main.js +16 -16
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +15 -21
- package/dist/main.lite.js.map +2 -2
- package/dist/scoped-css.js +2 -2
- package/dist/scoped-css.js.map +2 -2
- package/dist/scoped-js.js +1 -1
- package/dist/scoped-js.js.map +2 -2
- package/package.json +2 -2
- package/src/data-binding/index.js +3 -3
- package/src/scoped-css/index.js +3 -3
- package/src/scoped-js/index.js +12 -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": "
|
|
17
|
+
"version": "4.0.0",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"postpublish": "git push && git push --tags"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@webqit/quantum-js": "^4.
|
|
38
|
+
"@webqit/quantum-js": "^4.3.0",
|
|
39
39
|
"@webqit/realdom": "^2.1.23",
|
|
40
40
|
"@webqit/util": "^0.8.11"
|
|
41
41
|
},
|
|
@@ -13,11 +13,11 @@ import { _, _init, _splitOuter } from '../util.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export default function init( $config = {} ) {
|
|
15
15
|
const { config, window } = _init.call( this, 'data-binding', $config, {
|
|
16
|
-
attr: {
|
|
16
|
+
attr: { render: 'render', itemIndex: 'data-key' },
|
|
17
17
|
tokens: { nodeType: 'processing-instruction', tagStart: '?{', tagEnd: '}?', stateStart: '; [=', stateEnd: ']' },
|
|
18
18
|
} );
|
|
19
19
|
( { CONTEXT_API: config.CONTEXT_API, BINDINGS_API: config.BINDINGS_API, HTML_IMPORTS: config.HTML_IMPORTS } = window.webqit.oohtml.configs );
|
|
20
|
-
config.attrSelector = `[${ window.CSS.escape( config.attr.
|
|
20
|
+
config.attrSelector = `[${ window.CSS.escape( config.attr.render ) }]`;
|
|
21
21
|
const discreteBindingsMatch = ( start, end ) => {
|
|
22
22
|
const starting = `starts-with(., "${ start }")`;
|
|
23
23
|
const ending = `substring(., string-length(.) - string-length("${ end }") + 1) = "${ end }"`;
|
|
@@ -144,7 +144,7 @@ function compileDiscreteBindings( config, str ) {
|
|
|
144
144
|
|
|
145
145
|
async function mountInlineBindings( config, ...entries ) {
|
|
146
146
|
for ( const node of entries ) {
|
|
147
|
-
const compiled = compileInlineBindings( config, node.getAttribute( config.attr.
|
|
147
|
+
const compiled = compileInlineBindings( config, node.getAttribute( config.attr.render ) );
|
|
148
148
|
const { scope, bindings } = createDynamicScope.call( this, config, node );
|
|
149
149
|
const signals = [];
|
|
150
150
|
Object.defineProperty( node, '$oohtml_internal_databinding_signals', { value: signals, configurable: true } );
|
package/src/scoped-css/index.js
CHANGED
|
@@ -13,10 +13,10 @@ import { _init, _toHash } from '../util.js';
|
|
|
13
13
|
export default function init({ advanced = {}, ...$config }) {
|
|
14
14
|
const { config, window } = _init.call( this, 'scoped-css', $config, {
|
|
15
15
|
api: { styleSheets: 'styleSheets' },
|
|
16
|
-
style: { retention: 'retain',
|
|
16
|
+
style: { retention: 'retain', mimeTypes: 'text/css', strategy: null },
|
|
17
17
|
} );
|
|
18
|
-
config.styleSelector = (Array.isArray( config.style.
|
|
19
|
-
const qualifier = mm ? `[type
|
|
18
|
+
config.styleSelector = (Array.isArray( config.style.mimeTypes ) ? config.style.mimeTypes : config.style.mimeTypes.split( '|' ) ).concat( '' ).reduce( ( selector, mm ) => {
|
|
19
|
+
const qualifier = mm ? `[type="${ window.CSS.escape( mm ) }"]` : ':not([type])';
|
|
20
20
|
return selector.concat( `style${ qualifier }` );
|
|
21
21
|
}, [] ).join( ',' );
|
|
22
22
|
window.webqit.oohtml.Style = {
|
package/src/scoped-js/index.js
CHANGED
|
@@ -12,13 +12,13 @@ import { _init, _toHash, _fromHash } from '../util.js';
|
|
|
12
12
|
*/
|
|
13
13
|
export default function init({ advanced = {}, ...$config }) {
|
|
14
14
|
const { config, window } = _init.call( this, 'scoped-js', $config, {
|
|
15
|
-
script: { retention: 'retain',
|
|
15
|
+
script: { retention: 'retain', mimeTypes: 'module|text/javascript|application/javascript' },
|
|
16
16
|
api: { scripts: 'scripts' },
|
|
17
17
|
advanced: resolveParams(advanced),
|
|
18
18
|
} );
|
|
19
|
-
config.scriptSelector = ( Array.isArray( config.script.
|
|
20
|
-
const qualifier = mm ? `[type
|
|
21
|
-
return selector.concat( `script${ qualifier }
|
|
19
|
+
config.scriptSelector = ( Array.isArray( config.script.mimeTypes ) ? config.script.mimeTypes : config.script.mimeTypes.split( '|' ) ).concat( '' ).reduce( ( selector, mm ) => {
|
|
20
|
+
const qualifier = mm ? `[type="${ window.CSS.escape( mm ) }"]` : ':not([type])';
|
|
21
|
+
return selector.concat( `script${ qualifier }` );
|
|
22
22
|
}, [] ).join( ',' );
|
|
23
23
|
window.webqit.oohtml.Script = {
|
|
24
24
|
compileCache: [ new Map, new Map, ],
|
|
@@ -88,24 +88,25 @@ async function execute( config, execHash ) {
|
|
|
88
88
|
*/
|
|
89
89
|
function realtime( config ) {
|
|
90
90
|
const window = this, { webqit: { oohtml, realdom, QuantumScript, QuantumAsyncScript, QuantumModule } } = window;
|
|
91
|
-
if ( !window.HTMLScriptElement.supports ) { window.HTMLScriptElement.supports =
|
|
92
|
-
const
|
|
91
|
+
if ( !window.HTMLScriptElement.supports ) { window.HTMLScriptElement.supports = type => [ 'text/javascript', 'application/javascript' ].includes( type ); }
|
|
92
|
+
const handled = new WeakSet;
|
|
93
93
|
realdom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.scriptSelector, record => {
|
|
94
94
|
record.entrants.forEach( script => {
|
|
95
95
|
if ( handled.has( script ) ) return;
|
|
96
|
+
const textContent = ( script._ = script.textContent.trim() ) && script._.startsWith( '/*@oohtml*/if(false){' ) && script._.endsWith( '}/*@oohtml*/' ) ? script._.slice( 21, -12 ) : script.textContent;
|
|
97
|
+
if ( !script.scoped && !script.quantum && !textContent.includes( 'quantum' ) ) return;
|
|
96
98
|
handled.add( script );
|
|
97
99
|
// Do compilation
|
|
98
|
-
const textContent = ( script._ = script.textContent.trim() ) && script._.startsWith( '/*@oohtml*/if(false){' ) && script._.endsWith( '}/*@oohtml*/' ) ? script._.slice( 21, -12 ) : script.textContent;
|
|
99
100
|
const sourceHash = _toHash( textContent );
|
|
100
101
|
const compileCache = oohtml.Script.compileCache[ script.quantum ? 0 : 1 ];
|
|
101
102
|
let compiledScript;
|
|
102
103
|
if ( !( compiledScript = compileCache.get( sourceHash ) ) ) {
|
|
103
104
|
const { parserParams, compilerParams, runtimeParams } = config.advanced;
|
|
104
|
-
compiledScript = new ( script.type === 'module' ? QuantumModule : (QuantumScript || QuantumAsyncScript) )( textContent, {
|
|
105
|
+
compiledScript = new ( script.type === 'module' ? QuantumModule : ( QuantumScript || QuantumAsyncScript ) )( textContent, {
|
|
105
106
|
exportNamespace: `#${ script.id }`,
|
|
106
107
|
fileName: `${ window.document.url?.split( '#' )?.[ 0 ] || '' }#${ script.id }`,
|
|
107
|
-
parserParams,
|
|
108
|
-
compilerParams
|
|
108
|
+
parserParams: { ...parserParams, quantumMode: script.quantum },
|
|
109
|
+
compilerParams,
|
|
109
110
|
runtimeParams,
|
|
110
111
|
} );
|
|
111
112
|
compileCache.set( sourceHash, compiledScript );
|
|
@@ -114,7 +115,7 @@ function realtime( config ) {
|
|
|
114
115
|
const thisContext = script.scoped ? script.parentNode || record.target : ( script.type === 'module' ? undefined : window );
|
|
115
116
|
if ( script.scoped ) { thisContext[ config.api.scripts ].push( script ); }
|
|
116
117
|
const execHash = _toHash( { script, compiledScript, thisContext } );
|
|
117
|
-
const manualHandling = record.type === 'query' || (
|
|
118
|
+
const manualHandling = record.type === 'query' || ( script.type && !window.HTMLScriptElement.supports( script.type ) );
|
|
118
119
|
if ( manualHandling ) { oohtml.Script.execute( execHash ); } else {
|
|
119
120
|
script.textContent = `webqit.oohtml.Script.execute( '${ execHash }' );`;
|
|
120
121
|
}
|