@webqit/oohtml 2.1.44 → 2.1.46

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.44",
17
+ "version": "2.1.46",
18
18
  "license": "MIT",
19
19
  "repository": {
20
20
  "type": "git",
@@ -38,9 +38,9 @@
38
38
  "postpublish": "git push && git push --tags"
39
39
  },
40
40
  "dependencies": {
41
- "@webqit/observer": "^2.1.4",
42
- "@webqit/realdom": "^2.1.11",
43
- "@webqit/subscript": "^2.1.40",
41
+ "@webqit/observer": "^2.1.5",
42
+ "@webqit/realdom": "^2.1.12",
43
+ "@webqit/subscript": "^2.1.41",
44
44
  "@webqit/util": "^0.8.11"
45
45
  },
46
46
  "devDependencies": {
@@ -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 );
@@ -51,29 +51,28 @@ export function execute( compiledScript, thisContext, script ) {
51
51
  // Rerending processes,,,
52
52
  Object.defineProperty( script, 'rerender', { value: ( ...args ) => _await( returnValue, ( [ , rerender ] ) => rerender( ...args ) ) } );
53
53
  _await( script.properties, properties => {
54
+ const _env = { 'this': thisContext };
55
+ const getPaths = ( base, record_s ) => ( Array.isArray( record_s ) ? record_s : [ record_s ] ).map( record => [ ...base, ...( record.path || [ record.key ] ) ] );
54
56
  properties.processes = properties.dependencies.map( path => {
55
- const _env = { 'this': thisContext, 'globalThis': globalThis, 'window': globalThis.window, 'self': globalThis.self };
56
- const getPaths = ( base, record_s ) => ( Array.isArray( record_s ) ? record_s : [ record_s ] ).map( record => [ ...base, ...( record.path || [ record.key ] ) ] );
57
- properties.processes = properties.dependencies.map( path => {
58
- if ( _isTypeObject( _env[ path[ 0 ] ] ) ) {
59
- if ( path.length === 1 ) return;
60
- return Observer.deep( _env[ path[ 0 ] ], path.slice( 1 ), Observer.observe, record_s => {
61
- script.rerender( ...getPaths( [ path[ 0 ] ], record_s ) );
62
- } );
63
- }
64
- return Observer.deep( globalThis, path, Observer.observe, record_s => {
65
- script.rerender( ...getPaths( [], record_s ) );
57
+ if ( _isTypeObject( _env[ path[ 0 ] ] ) ) {
58
+ if ( path.length === 1 ) return;
59
+ return Observer.reduce( _env[ path[ 0 ] ], path.slice( 1 ), Observer.observe, record_s => {
60
+ script.rerender( ...getPaths( [ path[ 0 ] ], record_s ) );
66
61
  } );
62
+ }
63
+ return Observer.reduce( globalThis, path, Observer.observe, record_s => {
64
+ script.rerender( ...getPaths( [], record_s ) );
67
65
  } );
68
66
  } );
69
67
  } );
70
68
  }
71
69
  const window = this, { realdom } = window.webqit;
70
+ if ( !( thisContext instanceof window.Node ) ) return script;
72
71
  realdom.realtime( window.document ).observe( thisContext, () => {
73
72
  if ( script.contract ) {
74
73
  // Rerending processes,,,
75
74
  _await( script.properties, properties => {
76
- properties.processes.forEach( process => process.abort() );
75
+ properties.processes.forEach( process => process?.abort() );
77
76
  } );
78
77
  }
79
78
  thisContext.dispatchEvent( new window.CustomEvent( 'remove' ) );
@@ -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 );