@webqit/oohtml 2.1.17 → 2.1.18

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/dist/scoped-js.js CHANGED
@@ -15,7 +15,7 @@ ${m}
15
15
  ${this.rewriteImportStmts(a).join(`
16
16
  `)}
17
17
  ${u}
18
- `));let d,{parserParams:h,compilerParams:g,runtimeParams:y}=this.config.advanced;if(e.contract)h={...h,allowAwaitOutsideFunction:e.type==="module"},y={...y,async:e.type==="module"},d=o(u,{compilerParams:g,parserParams:h,runtimeParams:y}),Object.defineProperty(e,"properties",{configurable:!0,value:o.inspect(d,"properties")});else{let x=e.type==="module"?Object.getPrototypeOf(async function(){}).constructor:Function;d=y?.compileFunction?y.compileFunction(u):new x(u),Object.defineProperty(d,"originalSource",{configurable:!0,value:e.textContent})}c=Object.defineProperty(e.cloneNode(),"function",{value:d}),e.scoped&&Object.defineProperty(c,"scoped",Object.getOwnPropertyDescriptor(e,"scoped")),e.contract&&Object.defineProperty(c,"contract",Object.getOwnPropertyDescriptor(e,"contract")),s.set(f,c)}let l=t.toHash({script:e,compiledScript:c,thisContext:r});e.handling==="manual"?webqit.oohtml.Script.run(l):e.textContent=`webqit.oohtml.Script.run( '${l}' );`}parse(e){let[r,t]=this.tokenize(e,(f,u,c,l,a,m)=>{if(u==="start-enclosure"&&c==="{"&&!l.openAsync?.type&&l.openEnclosures.length===l.openAsync?.scopeId)l.openAsync.type="block";else if(u==="end-enclosure"&&c==="}"&&l.openAsync?.type==="block"&&l.openEnclosures.length===l.openAsync.scopeId)l.openAsync=null;else if(u==="start-quote"&&!l.openEnclosures.length&&["starting","from"].includes(l.openImport))l.openImport="url";else if(u==="end-quote"&&l.openImport==="url")l.openImport="closing";else if(u==="char"){if(l.openImport==="closing"&&(c===";"||![" ",`
18
+ `));let d,{parserParams:h,compilerParams:g,runtimeParams:y}=this.config.advanced;if(e.contract)h={...h,allowAwaitOutsideFunction:e.type==="module"},y={...y,async:e.type==="module"},d=o(u,{compilerParams:g,parserParams:h,runtimeParams:y}),Object.defineProperty(e,"properties",{configurable:!0,value:o.inspect(d,"properties")});else{let x=e.type==="module"?Object.getPrototypeOf(async function(){}).constructor:Function;d=y?.compileFunction?y.compileFunction(u):new x(u)}Object.defineProperty(d,"originalSource",{configurable:!0,value:e.textContent}),c=Object.defineProperty(e.cloneNode(),"function",{value:d}),e.scoped&&Object.defineProperty(c,"scoped",Object.getOwnPropertyDescriptor(e,"scoped")),e.contract&&Object.defineProperty(c,"contract",Object.getOwnPropertyDescriptor(e,"contract")),s.set(f,c)}let l=t.toHash({script:e,compiledScript:c,thisContext:r});e.handling==="manual"?webqit.oohtml.Script.run(l):e.textContent=`webqit.oohtml.Script.run( '${l}' );`}parse(e){let[r,t]=this.tokenize(e,(f,u,c,l,a,m)=>{if(u==="start-enclosure"&&c==="{"&&!l.openAsync?.type&&l.openEnclosures.length===l.openAsync?.scopeId)l.openAsync.type="block";else if(u==="end-enclosure"&&c==="}"&&l.openAsync?.type==="block"&&l.openEnclosures.length===l.openAsync.scopeId)l.openAsync=null;else if(u==="start-quote"&&!l.openEnclosures.length&&["starting","from"].includes(l.openImport))l.openImport="url";else if(u==="end-quote"&&l.openImport==="url")l.openImport="closing";else if(u==="char"){if(l.openImport==="closing"&&(c===";"||![" ",`
19
19
  `].includes(c)||m))return c===";"||m?(f[0]+=c,f.unshift("")):f.unshift(c),l.openImport=null,!1;let p=e.substring(a-1);if(!l.openImport&&/^[\W]?import[ ]*[^\(]/.test(p))return l.openImport="starting",f.unshift(""),6;if(l.openImport==="starting"&&/^[\W]?from /.test(p))return l.openImport="from",4;if(!l.openAsync){if(/^[\W]?async /.test(p))return l.openAsync={scopeId:l.openEnclosures.length},5;if(/^[\W]?await /.test(p))return l.topLevelAwait=!0,5}l.openAsync&&(!l.openAsync.type&&/.?\=\>[ ]*?\{/.test(p)?l.openAsync.type="inline-arrow":l.openAsync.type==="inline-arrow"&&[`
20
20
  `,";"].includes(c)&&l.openEnclosures.length===l.openAsync.scopeId&&(l.openAsync=null))}}),i=[],o="",s;for(let f of r.reverse())(s=f.trim()).startsWith("import ")?i.push(f):s&&(o+=f);return[i,o,t]}rewriteImportStmts(e){let r=[],t=[];return e.forEach((i,o)=>{i=parseImportStmt(i);let[s,f]=i.items.reduce(([u,c],l)=>l.id==="*"?[l.alias,c]:[u,c.concat(l)],[null,[]]);if(s&&r.push(`const ${s} = __$imports$__[${o}];`),f.length){let u=f.map(c=>`${c.id}${c.id!==c.alias?`: ${c.alias}`:""}`).join(", ");r.push(`const { ${u} } = __$imports$__[${o}];`)}t.push(`import("${i.url}")`)}),[`
21
21
  const __$imports$__ = await Promise.all([