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