@webqit/oohtml 2.1.45 → 2.1.47

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/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "wicg-proposal"
15
15
  ],
16
16
  "homepage": "https://webqit.io/tooling/oohtml",
17
- "version": "2.1.45",
17
+ "version": "2.1.47",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -38,13 +38,13 @@
38
38
  "postpublish": "git push && git push --tags"
39
39
  },
40
40
  "dependencies": {
41
- "@webqit/observer": "^2.1.4",
41
+ "@webqit/contract": "^2.1.48",
42
+ "@webqit/observer": "^2.1.5",
42
43
  "@webqit/realdom": "^2.1.12",
43
- "@webqit/subscript": "^2.1.41",
44
44
  "@webqit/util": "^0.8.11"
45
45
  },
46
46
  "devDependencies": {
47
- "@webqit/oohtml-ssr": "^1.2.8",
47
+ "@webqit/oohtml-ssr": "^1.2.13",
48
48
  "chai": "^4.3.4",
49
49
  "coveralls": "^3.1.1",
50
50
  "esbuild": "^0.14.43",
@@ -175,7 +175,7 @@ export default class _HTMLExportsManager {
175
175
  const realtimes = [];
176
176
  const parentExportsObj = getModulesObject( this.parent );
177
177
  if ( extendedId ) {
178
- realtimes.push( Observer.deep( parentExportsObj, [ extendedId, this.config.template.api.modules, Infinity ], Observer.get, handleInherited, { live: true } ) );
178
+ realtimes.push( Observer.reduce( parentExportsObj, [ extendedId, this.config.template.api.modules, Infinity ], Observer.get, handleInherited, { live: true } ) );
179
179
  }
180
180
  if ( ( inheritedIds = inheritedIds.split( ' ' ).map( id => id.trim() ).filter( x => x ) ).length ) {
181
181
  realtimes.push( Observer.get( parentExportsObj, inheritedIds, handleInherited, { live: true } ) );
@@ -56,13 +56,13 @@ export default class _HTMLImportsProvider extends HTMLContextProvider {
56
56
  // We'll now fulfill request
57
57
  const options = { live: event.request.live, descripted: true };
58
58
  // Find a way to resolve request against two sources
59
- event.request.controller = Observer.deep( this.localModules, path, Observer.get, ( result, { signal } = {} ) => {
59
+ event.request.controller = Observer.reduce( this.localModules, path, Observer.get, ( result, { signal } = {} ) => {
60
60
  const _result = Array.isArray( result ) ? result : result.value;
61
61
  const _isValidResult = Array.isArray( result ) ? result.length : result.value;
62
62
  if ( !_isValidResult && this.host.isConnected === false ) return; // Subtree is being disposed
63
63
  if ( _isValidResult || !this.contextModules ) return event.respondWith( _result );
64
64
  // This superModules binding is automatically aborted by the injected control.signal; see below
65
- return Observer.deep( this.contextModules, path, Observer.get, result => {
65
+ return Observer.reduce( this.contextModules, path, Observer.get, result => {
66
66
  return event.respondWith( Array.isArray( result ) ? result : result.value );
67
67
  }, { signal, ...options } );
68
68
  }, options );
@@ -54,7 +54,7 @@ export default class Compiler {
54
54
  // Compile scipt
55
55
  compile( script, thisContext ) {
56
56
  const _static = this.constructor;
57
- const { webqit: { oohtml, SubscriptFunction } } = this.window;
57
+ const { webqit: { oohtml, ContractFunction } } = this.window;
58
58
  const cache = oohtml.Script.compileCache[ script.contract ? 0 : 1 ];
59
59
  const sourceHash = _static.toHash( script.textContent );
60
60
  // Script instances are parsed only once
@@ -76,8 +76,8 @@ export default class Compiler {
76
76
  if ( script.contract ) {
77
77
  parserParams = { ...parserParams, allowAwaitOutsideFunction: script.type === 'module' };
78
78
  runtimeParams = { ...runtimeParams, async: script.type === 'module' };
79
- _Function = SubscriptFunction( source, { compilerParams, parserParams, runtimeParams, } );
80
- Object.defineProperty( script, 'properties', { configurable: true, value: SubscriptFunction.inspect( _Function, 'properties' ) } );
79
+ _Function = ContractFunction( source, { compilerParams, parserParams, runtimeParams, } );
80
+ Object.defineProperty( script, 'properties', { configurable: true, value: ContractFunction.inspect( _Function, 'properties' ) } );
81
81
  } else {
82
82
  const isAsync = script.type === 'module'//meta.topLevelAwait || imports.length;
83
83
  const _FunctionConstructor = isAsync ? Object.getPrototypeOf( async function() {} ).constructor : Function;
@@ -3,8 +3,8 @@
3
3
  * @imports
4
4
  */
5
5
  import { _isTypeObject } from '@webqit/util/js/index.js';
6
- import { resolveParams } from '@webqit/subscript/src/params.js';
7
- import SubscriptFunction from '@webqit/subscript/src/SubscriptFunctionLite.js';
6
+ import { resolveParams } from '@webqit/contract/src/params.js';
7
+ import ContractFunction from '@webqit/contract/src/ContractFunctionLite.js';
8
8
  import Observer from '@webqit/observer';
9
9
  import Compiler from './Compiler.js';
10
10
  import { _init } from '../util.js';
@@ -28,13 +28,13 @@ export default function init( { advanced = {}, ...$config } ) {
28
28
  return selector.concat( `script${ qualifier }[scoped],script${ qualifier }[contract]` );
29
29
  }, [] ).join( ',' );
30
30
  window.webqit.oohtml.Script = { compileCache: [ new Map, new Map, ] };
31
- window.webqit.SubscriptFunction = SubscriptFunction;
31
+ window.webqit.ContractFunction = ContractFunction;
32
32
  window.webqit.Observer = Observer;
33
33
  realtime.call( window, config );
34
34
  }
35
35
 
36
36
  export {
37
- SubscriptFunction,
37
+ ContractFunction,
38
38
  Observer,
39
39
  }
40
40
 
@@ -56,11 +56,11 @@ export function execute( compiledScript, thisContext, script ) {
56
56
  properties.processes = properties.dependencies.map( path => {
57
57
  if ( _isTypeObject( _env[ path[ 0 ] ] ) ) {
58
58
  if ( path.length === 1 ) return;
59
- return Observer.deep( _env[ path[ 0 ] ], path.slice( 1 ), Observer.observe, record_s => {
59
+ return Observer.reduce( _env[ path[ 0 ] ], path.slice( 1 ), Observer.observe, record_s => {
60
60
  script.rerender( ...getPaths( [ path[ 0 ] ], record_s ) );
61
61
  } );
62
62
  }
63
- return Observer.deep( globalThis, path, Observer.observe, record_s => {
63
+ return Observer.reduce( globalThis, path, Observer.observe, record_s => {
64
64
  script.rerender( ...getPaths( [], record_s ) );
65
65
  } );
66
66
  } );
package/test/index.js CHANGED
@@ -21,7 +21,7 @@ export function createDocument( head = '', body = '', callback = null, ) {
21
21
  <!DOCTYPE html>
22
22
  <html>
23
23
  <head>
24
- <meta name="subscript-compiler-url" content="../subscript/dist/compiler.js">
24
+ <meta name="contract-compiler-url" content="../contract/dist/compiler.js">
25
25
  <script ssr src="/dist/main.js"></script>
26
26
  ${ head }
27
27
  </head>
@@ -57,14 +57,14 @@ describe(`HTML Modules`, function() {
57
57
  document.import( 'temp0', temp0 => {
58
58
  expect( temp0 ).to.have.property( 'modules' );
59
59
  expect( temp0.modules[ '#' ] ).to.have.length( 2 );
60
- const temp2 = Observer.deep( temp0.modules, getQueryPath( 'temp2' ), Observer.get );
60
+ const temp2 = Observer.reduce( temp0.modules, getQueryPath( 'temp2' ), Observer.get );
61
61
  expect( temp2 ).to.have.property( 'modules' );
62
62
  // -------
63
- const temp1Inherited = Observer.deep( temp0.modules, getQueryPath( 'temp2/temp1' ), Observer.get );
63
+ const temp1Inherited = Observer.reduce( temp0.modules, getQueryPath( 'temp2/temp1' ), Observer.get );
64
64
  expect( temp1Inherited ).to.have.property( 'modules' );
65
65
  // -------
66
66
  const temp3Observed = [];
67
- Observer.deep( temp0.modules, getQueryPath( 'temp2/temp3' ), Observer.observe, record => {
67
+ Observer.reduce( temp0.modules, getQueryPath( 'temp2/temp3' ), Observer.observe, record => {
68
68
  temp3Observed.push( record.value );
69
69
  } );
70
70
  // -------
@@ -75,7 +75,7 @@ describe(`HTML Modules`, function() {
75
75
  expect( temp3Observed ).to.be.an( 'array' ).with.length( 1 );
76
76
  expect( temp3Observed[ 0 ] ).to.have.property( 'modules' );
77
77
  // -------
78
- const temp3Inherited = Observer.deep( temp0.modules, getQueryPath( 'temp2/temp3' ), Observer.get );
78
+ const temp3Inherited = Observer.reduce( temp0.modules, getQueryPath( 'temp2/temp3' ), Observer.get );
79
79
  expect( temp3Inherited ).to.have.property( 'modules' );
80
80
  // -------
81
81
  } );
@@ -117,15 +117,15 @@ describe(`HTML Modules`, function() {
117
117
  expect( temp0 ).to.have.property( 'modules' );
118
118
  await delay( 2100 );
119
119
  // temp1 shouldn't have been automatically loaded still
120
- const hasTemp1 = Observer.deep( temp0.modules, getQueryPath( 'temp1' ), Observer.has );
120
+ const hasTemp1 = Observer.reduce( temp0.modules, getQueryPath( 'temp1' ), Observer.has );
121
121
  expect( hasTemp1 ).to.be.false;
122
122
  // Try access temp1 to trigger loading and await
123
- const _temp1 = await Observer.deep( temp0.modules, getQueryPath( 'temp1' ), Observer.get );
123
+ const _temp1 = await Observer.reduce( temp0.modules, getQueryPath( 'temp1' ), Observer.get );
124
124
  expect( _temp1 ).to.have.property( 'modules' );
125
125
  // -------
126
126
  // Receive updates
127
127
  const temp3Observed = [];
128
- Observer.deep( temp0.modules, getQueryPath( 'temp1/temp2/temp3' ), Observer.observe, ( record, lifecycle ) => {
128
+ Observer.reduce( temp0.modules, getQueryPath( 'temp1/temp2/temp3' ), Observer.observe, ( record, lifecycle ) => {
129
129
  temp3Observed.push( record.value );
130
130
  } );
131
131
  await delay( 2100 );
@@ -21,7 +21,7 @@ describe(`Test: Scoped CSS`, function() {
21
21
  </div>`;
22
22
 
23
23
  const window = createDocument( head, body );
24
- await delay( 160 ); // Takes time to dynamically load Subscript compiler
24
+ await delay( 160 ); // Takes time to dynamically load Contract compiler
25
25
  const styleElement = window.document.querySelector( 'style' );
26
26
 
27
27
  expect( styleElement.textContent.substring( 0, 13 ) ).to.eq( '@scope from (' );
@@ -19,7 +19,7 @@ describe(`Test: Scoped JS`, function() {
19
19
 
20
20
  const window = createDocument( head, body );
21
21
  window.testRecords = [];
22
- await delay( 160 ); // Takes time to dynamically load Subscript compiler
22
+ await delay( 160 ); // Takes time to dynamically load Contract compiler
23
23
 
24
24
  expect( window.testRecords ).to.have.length( 1 );
25
25
  expect( window.testRecords[ 0 ] ).to.eql( window.document.body );