@webqit/oohtml 2.1.47 → 2.1.49

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.47",
17
+ "version": "2.1.49",
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/contract": "^2.1.48",
42
41
  "@webqit/observer": "^2.1.5",
43
42
  "@webqit/realdom": "^2.1.12",
43
+ "@webqit/reflex-functions": "^2.1.50",
44
44
  "@webqit/util": "^0.8.11"
45
45
  },
46
46
  "devDependencies": {
47
- "@webqit/oohtml-ssr": "^1.2.13",
47
+ "@webqit/oohtml-ssr": "^1.2.15",
48
48
  "chai": "^4.3.4",
49
49
  "coveralls": "^3.1.1",
50
50
  "esbuild": "^0.14.43",
@@ -54,8 +54,8 @@ export default class Compiler {
54
54
  // Compile scipt
55
55
  compile( script, thisContext ) {
56
56
  const _static = this.constructor;
57
- const { webqit: { oohtml, ContractFunction } } = this.window;
58
- const cache = oohtml.Script.compileCache[ script.contract ? 0 : 1 ];
57
+ const { webqit: { oohtml, ReflexFunction } } = this.window;
58
+ const cache = oohtml.Script.compileCache[ script.reflex ? 0 : 1 ];
59
59
  const sourceHash = _static.toHash( script.textContent );
60
60
  // Script instances are parsed only once
61
61
  let source = script.textContent, compiledScript;
@@ -64,7 +64,7 @@ export default class Compiler {
64
64
  let imports = [], meta = {};
65
65
  let targetKeywords = [];
66
66
  if ( script.type === 'module' ) targetKeywords.push( 'import ' );
67
- if ( script.type === 'module' && !script.contract ) targetKeywords.push( 'await ' );
67
+ if ( script.type === 'module' && !script.reflex ) targetKeywords.push( 'await ' );
68
68
  if ( targetKeywords.length && ( new RegExp( targetKeywords.join( '|' ) ) ).test( source ) ) {
69
69
  [ imports, source, meta ] = this.parse( source );
70
70
  if ( imports.length ) {
@@ -73,11 +73,11 @@ export default class Compiler {
73
73
  }
74
74
  // Let's obtain a material functions
75
75
  let _Function, { parserParams, compilerParams, runtimeParams } = this.config.advanced;
76
- if ( script.contract ) {
76
+ if ( script.reflex ) {
77
77
  parserParams = { ...parserParams, allowAwaitOutsideFunction: script.type === 'module' };
78
78
  runtimeParams = { ...runtimeParams, async: script.type === 'module' };
79
- _Function = ContractFunction( source, { compilerParams, parserParams, runtimeParams, } );
80
- Object.defineProperty( script, 'properties', { configurable: true, value: ContractFunction.inspect( _Function, 'properties' ) } );
79
+ _Function = ReflexFunction( source, { compilerParams, parserParams, runtimeParams, } );
80
+ Object.defineProperty( script, 'properties', { configurable: true, value: ReflexFunction.inspect( _Function ) } );
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;
@@ -89,7 +89,7 @@ export default class Compiler {
89
89
  // Save material function to compile cache
90
90
  compiledScript = Object.defineProperty( script.cloneNode(), 'function', { value: _Function } );
91
91
  script.scoped && Object.defineProperty( compiledScript, 'scoped', Object.getOwnPropertyDescriptor( script, 'scoped') );
92
- script.contract && Object.defineProperty( compiledScript, 'contract', Object.getOwnPropertyDescriptor( script, 'contract') );
92
+ script.reflex && Object.defineProperty( compiledScript, 'reflex', Object.getOwnPropertyDescriptor( script, 'reflex') );
93
93
  cache.set( sourceHash, compiledScript );
94
94
  }
95
95
  const execHash = _static.toHash( { script, compiledScript, thisContext } );
@@ -3,8 +3,8 @@
3
3
  * @imports
4
4
  */
5
5
  import { _isTypeObject } from '@webqit/util/js/index.js';
6
- import { resolveParams } from '@webqit/contract/src/params.js';
7
- import ContractFunction from '@webqit/contract/src/ContractFunctionLite.js';
6
+ import { resolveParams } from '@webqit/reflex-functions/src/params.js';
7
+ import ReflexFunction from '@webqit/reflex-functions/src/ReflexFunctionLite.js';
8
8
  import Observer from '@webqit/observer';
9
9
  import Compiler from './Compiler.js';
10
10
  import { _init } from '../util.js';
@@ -25,16 +25,16 @@ export default function init( { advanced = {}, ...$config } ) {
25
25
  } );
26
26
  config.scriptSelector = ( Array.isArray( config.script.mimeType ) ? config.script.mimeType : [ config.script.mimeType ] ).reduce( ( selector, mm ) => {
27
27
  const qualifier = mm ? `[type=${ window.CSS.escape( mm ) }]` : '';
28
- return selector.concat( `script${ qualifier }[scoped],script${ qualifier }[contract]` );
28
+ return selector.concat( `script${ qualifier }[scoped],script${ qualifier }[reflex]` );
29
29
  }, [] ).join( ',' );
30
30
  window.webqit.oohtml.Script = { compileCache: [ new Map, new Map, ] };
31
- window.webqit.ContractFunction = ContractFunction;
31
+ window.webqit.ReflexFunction = ReflexFunction;
32
32
  window.webqit.Observer = Observer;
33
33
  realtime.call( window, config );
34
34
  }
35
35
 
36
36
  export {
37
- ContractFunction,
37
+ ReflexFunction,
38
38
  Observer,
39
39
  }
40
40
 
@@ -47,9 +47,9 @@ export function execute( compiledScript, thisContext, script ) {
47
47
  };
48
48
  // Execute...
49
49
  const returnValue = compiledScript.function.call( thisContext );
50
- if ( script.contract ) {
50
+ if ( script.reflex ) {
51
51
  // Rerending processes,,,
52
- Object.defineProperty( script, 'rerender', { value: ( ...args ) => _await( returnValue, ( [ , rerender ] ) => rerender( ...args ) ) } );
52
+ Object.defineProperty( script, 'reflect', { value: ( ...args ) => _await( returnValue, ( [ , reflect ] ) => reflect( ...args ) ) } );
53
53
  _await( script.properties, properties => {
54
54
  const _env = { 'this': thisContext };
55
55
  const getPaths = ( base, record_s ) => ( Array.isArray( record_s ) ? record_s : [ record_s ] ).map( record => [ ...base, ...( record.path || [ record.key ] ) ] );
@@ -57,11 +57,11 @@ export function execute( compiledScript, thisContext, script ) {
57
57
  if ( _isTypeObject( _env[ path[ 0 ] ] ) ) {
58
58
  if ( path.length === 1 ) return;
59
59
  return Observer.reduce( _env[ path[ 0 ] ], path.slice( 1 ), Observer.observe, record_s => {
60
- script.rerender( ...getPaths( [ path[ 0 ] ], record_s ) );
60
+ script.reflect( ...getPaths( [ path[ 0 ] ], record_s ) );
61
61
  } );
62
62
  }
63
63
  return Observer.reduce( globalThis, path, Observer.observe, record_s => {
64
- script.rerender( ...getPaths( [], record_s ) );
64
+ script.reflect( ...getPaths( [], record_s ) );
65
65
  } );
66
66
  } );
67
67
  } );
@@ -69,7 +69,7 @@ export function execute( compiledScript, thisContext, script ) {
69
69
  const window = this, { realdom } = window.webqit;
70
70
  if ( !( thisContext instanceof window.Node ) ) return script;
71
71
  realdom.realtime( window.document ).observe( thisContext, () => {
72
- if ( script.contract ) {
72
+ if ( script.reflex ) {
73
73
  // Rerending processes,,,
74
74
  _await( script.properties, properties => {
75
75
  properties.processes.forEach( process => process?.abort() );
@@ -95,8 +95,8 @@ function realtime( config ) {
95
95
  const compiler = new Compiler( window, config, execute ), handled = () => {};
96
96
  realdom.realtime( window.document ).subtree/*instead of observe(); reason: jsdom timing*/( config.scriptSelector, record => {
97
97
  record.entrants.forEach( script => {
98
- if ( 'contract' in script ) return handled( script );
99
- Object.defineProperty( script, 'contract', { value: script.hasAttribute( 'contract' ) } );
98
+ if ( 'reflex' in script ) return handled( script );
99
+ Object.defineProperty( script, 'reflex', { value: script.hasAttribute( 'reflex' ) } );
100
100
  if ( 'scoped' in script ) return handled( script );
101
101
  Object.defineProperty( script, 'scoped', { value: script.hasAttribute( 'scoped' ) } );
102
102
  if ( record.type === 'query' || ( potentialManualTypes.includes( script.type ) && !window.HTMLScriptElement.supports( script.type ) ) ) {
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="contract-compiler-url" content="../contract/dist/compiler.js">
24
+ <meta name="reflex-compiler-url" content="../reflex-functions/dist/compiler.js">
25
25
  <script ssr src="/dist/main.js"></script>
26
26
  ${ head }
27
27
  </head>
@@ -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 Contract compiler
24
+ await delay( 160 ); // Takes time to dynamically load Reflex compiler
25
25
  const styleElement = window.document.querySelector( 'style' );
26
26
 
27
27
  expect( styleElement.textContent.substring( 0, 13 ) ).to.eq( '@scope from (' );
@@ -12,14 +12,14 @@ describe(`Test: Scoped JS`, function() {
12
12
  it(`Should do basic observe`, async function() {
13
13
  const head = '', body = `
14
14
  <h1>Hello World!</h1>
15
- <script scoped contract>
15
+ <script scoped reflex>
16
16
  testRecords.push( this );
17
17
  console.log('-------scoped JS here.');
18
18
  </script>`;
19
19
 
20
20
  const window = createDocument( head, body );
21
21
  window.testRecords = [];
22
- await delay( 160 ); // Takes time to dynamically load Contract compiler
22
+ await delay( 160 ); // Takes time to dynamically load Reflex compiler
23
23
 
24
24
  expect( window.testRecords ).to.have.length( 1 );
25
25
  expect( window.testRecords[ 0 ] ).to.eql( window.document.body );