coralite 0.29.1 → 0.29.2

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/lib/index.js CHANGED
@@ -9392,9 +9392,9 @@ ScriptManager.prototype.use = async function(plugin) {
9392
9392
  ScriptManager.prototype.getHelpersContent = function() {
9393
9393
  let helpers = "";
9394
9394
  for (const key of Object.keys(this.helpers)) {
9395
- helpers += `"${key}": (() => {
9395
+ helpers += `"${key}": (async () => {
9396
9396
  const phase1 = ${this.helpers[key]};
9397
- const phase2 = phase1({});
9397
+ const phase2 = await phase1({});
9398
9398
  return (localContext) => phase2(localContext);
9399
9399
  })(),`;
9400
9400
  }
@@ -9407,9 +9407,9 @@ ScriptManager.prototype.addHelper = async function(name, method) {
9407
9407
  ScriptManager.prototype.getHelpers = function() {
9408
9408
  let helpers = "";
9409
9409
  for (const key of Object.keys(this.helpers)) {
9410
- helpers += `"${key}": (() => {
9410
+ helpers += `"${key}": (async () => {
9411
9411
  const phase1 = ${this.helpers[key]};
9412
- const phase2 = phase1({});
9412
+ const phase2 = await phase1({});
9413
9413
  return (localContext) => phase2(localContext);
9414
9414
  })(),`;
9415
9415
  }
@@ -9450,10 +9450,11 @@ ScriptManager.prototype.compileAllInstances = async function(instances, mode) {
9450
9450
  ${helperParts}
9451
9451
  };
9452
9452
  `);
9453
- entryCodeParts.push(`const getHelpers = (context) => {
9453
+ entryCodeParts.push(`const getHelpers = async (context) => {
9454
9454
  const helpers = {}
9455
9455
  for (const [key, helper] of Object.entries(coraliteComponentScriptHelpers)) {
9456
- helpers[key] = helper(context)
9456
+ const resolvedHelper = await helper
9457
+ helpers[key] = resolvedHelper(context)
9457
9458
  }
9458
9459
  return helpers
9459
9460
  }
@@ -9654,16 +9655,18 @@ class CoraliteElement extends HTMLElement {
9654
9655
  this.values[\`ref_\${refName}\`] = dynamicId;
9655
9656
  }
9656
9657
 
9657
- const helpers = getHelpers(localContext);
9658
- localContext.helpers = helpers;
9659
-
9660
- const imports = coraliteComponentImports[this.componentId] || {};
9661
- localContext.imports = imports;
9658
+ ;(async () => {
9659
+ const helpers = await getHelpers(localContext);
9660
+ localContext.helpers = helpers;
9661
+
9662
+ const imports = coraliteComponentImports[this.componentId] || {};
9663
+ localContext.imports = imports;
9662
9664
 
9663
- const userScript = coraliteComponentFunctions[this.componentId];
9664
- if (userScript) {
9665
- userScript(localContext);
9666
- }
9665
+ const userScript = coraliteComponentFunctions[this.componentId];
9666
+ if (userScript) {
9667
+ userScript(localContext);
9668
+ }
9669
+ })();
9667
9670
 
9668
9671
  this._observer = new MutationObserver((mutations) => {
9669
9672
  let shouldRender = false;
@@ -9724,7 +9727,7 @@ for (const componentId of Object.keys(coraliteComponentTemplates)) {
9724
9727
  entryCodeParts.push("context.imports = imports;\n");
9725
9728
  entryCodeParts.push("const setupValues = await globalSetupValuesPromise;\n");
9726
9729
  entryCodeParts.push("context.values = { ...context.values, ...setupValues };\n");
9727
- entryCodeParts.push("const helpers = getHelpers(context);\n");
9730
+ entryCodeParts.push("const helpers = await getHelpers(context);\n");
9728
9731
  entryCodeParts.push("context.helpers = helpers;\n");
9729
9732
  entryCodeParts.push(`
9730
9733
  // Instance: ${instanceId}
@@ -9893,13 +9896,14 @@ for (const componentId of Object.keys(coraliteComponentTemplates)) {
9893
9896
  for (const key in module.helpers) {
9894
9897
  if (Object.hasOwn(module.helpers, key)) {
9895
9898
  const fn = normalizeFunction(module.helpers[key]);
9896
- contents += ` "${key}": (() => {
9899
+ contents += ` "${key}": (async () => {
9897
9900
  const globalContext = {
9898
9901
  imports: pluginImports,
9899
9902
  config: pluginConfig
9900
9903
  };
9901
9904
  const fn = ${fn};
9902
- return fn(globalContext);
9905
+ const phase2 = await fn(globalContext);
9906
+ return (localContext) => phase2(localContext);
9903
9907
  })(),
9904
9908
  `;
9905
9909
  }