@zyrab/domo-ssg 0.7.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyrab/domo-ssg",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "A Static Site Generator (SSG) for Domo-based projects.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -107,31 +107,23 @@ export function generateElementScript(id, events = [], states = {}, refs = []) {
107
107
  }
108
108
  });
109
109
 
110
- const handlerBody = `async function(e) { e.pre\n${indent(logicLines.join("\n"), 1)}\n}`;
110
+ const handlerBody = `async function(e) {\n${indent(logicLines.join("\n"), 1)}\n}`;
111
111
  listeners.push(`document.querySelector('[data-domo-id="${id}"]').addEventListener("${event}", ${handlerBody});`);
112
112
  });
113
113
 
114
- // 2. Process Refs (Now using the exact same smart lookup!)
114
+ // 2. Process Refs - Wrapped in IIFE to allow top-level returns and async
115
115
  const refLogics = refs
116
116
  .map((r) => {
117
117
  const { funcName, resolvedPath, fnSource, body } = resolveDependency(r);
118
118
 
119
- // Track imports/closures just like events
120
119
  if (resolvedPath) {
121
120
  if (!imports.has(resolvedPath)) imports.set(resolvedPath, new Set());
122
121
  imports.get(resolvedPath).add(funcName);
123
- } else if (funcName) {
124
- closureFunctions.push(fnSource);
125
- }
126
-
127
- // Output the Ref logic
128
- if (resolvedPath || funcName) {
129
- // If it's a named/imported function, pass the element to it: myRefFunction(el)
130
122
  return `{\n const el = document.querySelector('[data-domo-id="${id}"]');\n if (el) ${funcName}(el);\n}`;
131
- } else {
132
- // If anonymous, inline the body
133
- return `{\n const el = document.querySelector('[data-domo-id="${id}"]');\n if (el) {\n${indent(body, 4)}\n }\n}`;
134
123
  }
124
+
125
+ // Anonymous Ref Logic wrapped in async IIFE
126
+ return `{\n const el = document.querySelector('[data-domo-id="${id}"]');\n if (el) {\n (async () => {\n${indent(body || fnSource, 6)}\n })();\n }\n}`;
135
127
  })
136
128
  .join("\n");
137
129
 
@@ -205,7 +205,7 @@ async function bundleIslands(metadata, jsDir, tempDir) {
205
205
  // Extract generated paths for injection
206
206
  const allGeneratedPaths = Object.keys(result.metafile.outputs).map((filePath) => {
207
207
  const relativeToDist = filePath.replace(/\\/g, "/").split("/").slice(1).join("/");
208
- let path = `/${relativeToDist}`;
208
+ let path = relativeToDist;
209
209
 
210
210
  // 3. Remove "js/" specifically if it appears immediately after the leading slash
211
211
  // This transforms "/js/main.js" -> "/main.js"
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import { cleanOutputDir, copyStaticFolder, scanRoutes } from "./file-utils.js";
5
5
  import { generateSitemap } from "./sitemap.js";
6
6
  import { buildRoutes } from "./route-traversal.js";
7
7
  import { registry } from "./Registry.js";
8
+ import { join } from "path";
8
9
 
9
10
  async function main() {
10
11
  const config = await loadConfig();
@@ -33,7 +34,6 @@ main().catch((error) => {
33
34
 
34
35
  // import { writeFileSync } from "fs";
35
36
  // import { build } from "esbuild";
36
- // import { join } from "path";
37
37
 
38
38
  // // Your existing plugin to cleanly handle Domo
39
39
  // const rewriteDomoPlugin = {