@sigx/ssg 0.2.0 → 0.2.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/client.js CHANGED
@@ -1,52 +1,35 @@
1
- import { ssrClientPlugin } from "@sigx/server-renderer/client";
1
+ import { ssrClientPlugin as e } from "@sigx/server-renderer/client";
2
2
  //#region src/client.ts
3
- /**
4
- * Prefetch a route's assets
5
- */
6
- function prefetch(path) {
7
- const link = document.createElement("link");
8
- link.rel = "prefetch";
9
- link.href = path;
10
- document.head.appendChild(link);
3
+ function t(e) {
4
+ let t = document.createElement("link");
5
+ t.rel = "prefetch", t.href = e, document.head.appendChild(t);
11
6
  }
12
- /**
13
- * Setup prefetch on link hover
14
- */
15
- function setupPrefetch(options = {}) {
16
- const { delay = 100 } = options;
17
- const prefetched = /* @__PURE__ */ new Set();
18
- document.addEventListener("mouseover", (event) => {
19
- const anchor = event.target.closest("a");
20
- if (!anchor) return;
21
- const href = anchor.getAttribute("href");
22
- if (!href || href.startsWith("http") || href.startsWith("#")) return;
23
- if (prefetched.has(href)) return;
24
- const timeoutId = setTimeout(() => {
25
- prefetched.add(href);
26
- prefetch(href);
27
- }, delay);
28
- anchor.addEventListener("mouseleave", () => clearTimeout(timeoutId), { once: true });
7
+ function n(e = {}) {
8
+ let { delay: n = 100 } = e, r = /* @__PURE__ */ new Set();
9
+ document.addEventListener("mouseover", (e) => {
10
+ let i = e.target.closest("a");
11
+ if (!i) return;
12
+ let a = i.getAttribute("href");
13
+ if (!a || a.startsWith("http") || a.startsWith("#") || r.has(a)) return;
14
+ let o = setTimeout(() => {
15
+ r.add(a), t(a);
16
+ }, n);
17
+ i.addEventListener("mouseleave", () => clearTimeout(o), { once: !0 });
29
18
  });
30
19
  }
31
- /**
32
- * Check if the page was statically generated
33
- */
34
- function isStaticPage() {
20
+ function r() {
35
21
  return !document.documentElement.hasAttribute("data-ssr");
36
22
  }
37
- /**
38
- * Get initial state embedded in the page
39
- */
40
- function getInitialState() {
41
- const script = document.getElementById("__SSG_STATE__");
42
- if (!script) return null;
23
+ function i() {
24
+ let e = document.getElementById("__SSG_STATE__");
25
+ if (!e) return null;
43
26
  try {
44
- return JSON.parse(script.textContent || "");
27
+ return JSON.parse(e.textContent || "");
45
28
  } catch {
46
29
  return null;
47
30
  }
48
31
  }
49
32
  //#endregion
50
- export { getInitialState, isStaticPage, prefetch, setupPrefetch, ssrClientPlugin };
33
+ export { i as getInitialState, r as isStaticPage, t as prefetch, n as setupPrefetch, e as ssrClientPlugin };
51
34
 
52
35
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\r\n * SSG Client Runtime\r\n *\r\n * Client-side utilities for SSG sites:\r\n * - Hydration plugin\r\n * - Route prefetching\r\n * - Client-side navigation\r\n */\r\n\r\nexport { ssrClientPlugin } from '@sigx/server-renderer/client';\r\n\r\n/**\r\n * Prefetch a route's assets\r\n */\r\nexport function prefetch(path: string): void {\r\n // Create a link element for prefetching\r\n const link = document.createElement('link');\r\n link.rel = 'prefetch';\r\n link.href = path;\r\n document.head.appendChild(link);\r\n}\r\n\r\n/**\r\n * Setup prefetch on link hover\r\n */\r\nexport function setupPrefetch(options: { delay?: number } = {}): void {\r\n const { delay = 100 } = options;\r\n const prefetched = new Set<string>();\r\n\r\n document.addEventListener('mouseover', (event) => {\r\n const target = event.target as HTMLElement;\r\n const anchor = target.closest('a');\r\n\r\n if (!anchor) return;\r\n\r\n const href = anchor.getAttribute('href');\r\n if (!href || href.startsWith('http') || href.startsWith('#')) return;\r\n if (prefetched.has(href)) return;\r\n\r\n // Delay prefetch slightly to avoid unnecessary requests\r\n const timeoutId = setTimeout(() => {\r\n prefetched.add(href);\r\n prefetch(href);\r\n }, delay);\r\n\r\n anchor.addEventListener(\r\n 'mouseleave',\r\n () => clearTimeout(timeoutId),\r\n { once: true }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Check if the page was statically generated\r\n */\r\nexport function isStaticPage(): boolean {\r\n return !document.documentElement.hasAttribute('data-ssr');\r\n}\r\n\r\n/**\r\n * Get initial state embedded in the page\r\n */\r\nexport function getInitialState<T = Record<string, unknown>>(): T | null {\r\n const script = document.getElementById('__SSG_STATE__');\r\n if (!script) return null;\r\n\r\n try {\r\n return JSON.parse(script.textContent || '');\r\n } catch {\r\n return null;\r\n }\r\n}\r\n"],"mappings":";;;;;AAcA,SAAgB,SAAS,MAAoB;CAEzC,MAAM,OAAO,SAAS,cAAc,OAAO;AAC3C,MAAK,MAAM;AACX,MAAK,OAAO;AACZ,UAAS,KAAK,YAAY,KAAK;;;;;AAMnC,SAAgB,cAAc,UAA8B,EAAE,EAAQ;CAClE,MAAM,EAAE,QAAQ,QAAQ;CACxB,MAAM,6BAAa,IAAI,KAAa;AAEpC,UAAS,iBAAiB,cAAc,UAAU;EAE9C,MAAM,SADS,MAAM,OACC,QAAQ,IAAI;AAElC,MAAI,CAAC,OAAQ;EAEb,MAAM,OAAO,OAAO,aAAa,OAAO;AACxC,MAAI,CAAC,QAAQ,KAAK,WAAW,OAAO,IAAI,KAAK,WAAW,IAAI,CAAE;AAC9D,MAAI,WAAW,IAAI,KAAK,CAAE;EAG1B,MAAM,YAAY,iBAAiB;AAC/B,cAAW,IAAI,KAAK;AACpB,YAAS,KAAK;KACf,MAAM;AAET,SAAO,iBACH,oBACM,aAAa,UAAU,EAC7B,EAAE,MAAM,MAAM,CACjB;GACH;;;;;AAMN,SAAgB,eAAwB;AACpC,QAAO,CAAC,SAAS,gBAAgB,aAAa,WAAW;;;;;AAM7D,SAAgB,kBAAyD;CACrE,MAAM,SAAS,SAAS,eAAe,gBAAgB;AACvD,KAAI,CAAC,OAAQ,QAAO;AAEpB,KAAI;AACA,SAAO,KAAK,MAAM,OAAO,eAAe,GAAG;SACvC;AACJ,SAAO"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\r\n * SSG Client Runtime\r\n *\r\n * Client-side utilities for SSG sites:\r\n * - Hydration plugin\r\n * - Route prefetching\r\n * - Client-side navigation\r\n */\r\n\r\nexport { ssrClientPlugin } from '@sigx/server-renderer/client';\r\n\r\n/**\r\n * Prefetch a route's assets\r\n */\r\nexport function prefetch(path: string): void {\r\n // Create a link element for prefetching\r\n const link = document.createElement('link');\r\n link.rel = 'prefetch';\r\n link.href = path;\r\n document.head.appendChild(link);\r\n}\r\n\r\n/**\r\n * Setup prefetch on link hover\r\n */\r\nexport function setupPrefetch(options: { delay?: number } = {}): void {\r\n const { delay = 100 } = options;\r\n const prefetched = new Set<string>();\r\n\r\n document.addEventListener('mouseover', (event) => {\r\n const target = event.target as HTMLElement;\r\n const anchor = target.closest('a');\r\n\r\n if (!anchor) return;\r\n\r\n const href = anchor.getAttribute('href');\r\n if (!href || href.startsWith('http') || href.startsWith('#')) return;\r\n if (prefetched.has(href)) return;\r\n\r\n // Delay prefetch slightly to avoid unnecessary requests\r\n const timeoutId = setTimeout(() => {\r\n prefetched.add(href);\r\n prefetch(href);\r\n }, delay);\r\n\r\n anchor.addEventListener(\r\n 'mouseleave',\r\n () => clearTimeout(timeoutId),\r\n { once: true }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Check if the page was statically generated\r\n */\r\nexport function isStaticPage(): boolean {\r\n return !document.documentElement.hasAttribute('data-ssr');\r\n}\r\n\r\n/**\r\n * Get initial state embedded in the page\r\n */\r\nexport function getInitialState<T = Record<string, unknown>>(): T | null {\r\n const script = document.getElementById('__SSG_STATE__');\r\n if (!script) return null;\r\n\r\n try {\r\n return JSON.parse(script.textContent || '');\r\n } catch {\r\n return null;\r\n }\r\n}\r\n"],"mappings":";;AAcA,SAAgB,EAAS,GAAoB;CAEzC,IAAM,IAAO,SAAS,cAAc,OAAO;AAG3C,CAFA,EAAK,MAAM,YACX,EAAK,OAAO,GACZ,SAAS,KAAK,YAAY,EAAK;;AAMnC,SAAgB,EAAc,IAA8B,EAAE,EAAQ;CAClE,IAAM,EAAE,WAAQ,QAAQ,GAClB,oBAAa,IAAI,KAAa;AAEpC,UAAS,iBAAiB,cAAc,MAAU;EAE9C,IAAM,IADS,EAAM,OACC,QAAQ,IAAI;AAElC,MAAI,CAAC,EAAQ;EAEb,IAAM,IAAO,EAAO,aAAa,OAAO;AAExC,MADI,CAAC,KAAQ,EAAK,WAAW,OAAO,IAAI,EAAK,WAAW,IAAI,IACxD,EAAW,IAAI,EAAK,CAAE;EAG1B,IAAM,IAAY,iBAAiB;AAE/B,GADA,EAAW,IAAI,EAAK,EACpB,EAAS,EAAK;KACf,EAAM;AAET,IAAO,iBACH,oBACM,aAAa,EAAU,EAC7B,EAAE,MAAM,IAAM,CACjB;GACH;;AAMN,SAAgB,IAAwB;AACpC,QAAO,CAAC,SAAS,gBAAgB,aAAa,WAAW;;AAM7D,SAAgB,IAAyD;CACrE,IAAM,IAAS,SAAS,eAAe,gBAAgB;AACvD,KAAI,CAAC,EAAQ,QAAO;AAEpB,KAAI;AACA,SAAO,KAAK,MAAM,EAAO,eAAe,GAAG;SACvC;AACJ,SAAO"}
package/dist/dev.js CHANGED
@@ -1,85 +1,65 @@
1
- import { k as loadConfig } from "./virtual-entries-TuNN2It1.js";
2
- import { t as ssgPlugin } from "./plugin-Bik0HMne.js";
3
- import path from "node:path";
4
- import fsSync from "node:fs";
1
+ import { k as e } from "./virtual-entries-CH-0HuqJ.js";
2
+ import { t } from "./plugin-EIAzPLvE.js";
3
+ import n from "node:path";
4
+ import r from "node:fs";
5
5
  //#region src/dev.ts
6
- /**
7
- * SSG Dev Server
8
- *
9
- * Starts a Vite development server with SSG plugins pre-configured.
10
- * Provides a unified `ssg dev` command for zero-config development.
11
- */
12
- /**
13
- * Start the SSG development server
14
- */
15
- async function dev(options = {}) {
16
- const root = process.cwd();
17
- console.log("\n🚀 @sigx/ssg - Starting development server...\n");
18
- await loadConfig(options.configPath);
19
- const hasViteConfig = fsSync.existsSync(path.join(root, "vite.config.ts")) || fsSync.existsSync(path.join(root, "vite.config.js")) || fsSync.existsSync(path.join(root, "vite.config.mjs"));
20
- const vite = await import("vite");
21
- if (hasViteConfig) {
6
+ async function i(i = {}) {
7
+ let a = process.cwd();
8
+ console.log("\n🚀 @sigx/ssg - Starting development server...\n"), await e(i.configPath);
9
+ let o = r.existsSync(n.join(a, "vite.config.ts")) || r.existsSync(n.join(a, "vite.config.js")) || r.existsSync(n.join(a, "vite.config.mjs")), s = await import("vite");
10
+ if (o) {
22
11
  console.log("📦 Using existing vite.config\n");
23
- const server = await vite.createServer({
24
- root,
12
+ let e = await s.createServer({
13
+ root: a,
25
14
  server: {
26
- port: options.port,
27
- host: options.host,
28
- open: options.open
15
+ port: i.port,
16
+ host: i.host,
17
+ open: i.open
29
18
  }
30
19
  });
31
- await server.listen();
32
- server.printUrls();
20
+ await e.listen(), e.printUrls();
33
21
  } else {
34
22
  console.log("📦 Zero-config mode enabled\n");
35
- let sigxPlugin;
23
+ let e;
36
24
  try {
37
- sigxPlugin = (await import("@sigx/vite")).sigxPlugin;
25
+ e = (await import("@sigx/vite")).sigxPlugin;
38
26
  } catch {
39
- console.warn("⚠️ @sigx/vite not found, JSX transform may not work");
40
- console.warn(" Install with: npm install @sigx/vite\n");
27
+ console.warn("⚠️ @sigx/vite not found, JSX transform may not work"), console.warn(" Install with: npm install @sigx/vite\n");
41
28
  }
42
- const plugins = [];
29
+ let n = [];
43
30
  try {
44
- const tailwind = await import("@tailwindcss/vite");
45
- plugins.push(tailwind.default());
31
+ let e = await import("@tailwindcss/vite");
32
+ n.push(e.default());
46
33
  } catch {}
47
- if (sigxPlugin) plugins.push(sigxPlugin());
48
- plugins.push(...ssgPlugin({ configPath: options.configPath }));
49
- const server = await vite.createServer({
50
- root,
51
- plugins,
34
+ e && n.push(e()), n.push(...t({ configPath: i.configPath }));
35
+ let r = await s.createServer({
36
+ root: a,
37
+ plugins: n,
52
38
  oxc: { jsx: {
53
39
  runtime: "automatic",
54
40
  importSource: "sigx"
55
41
  } },
56
42
  server: {
57
- port: options.port ?? 5173,
58
- host: options.host,
59
- open: options.open
43
+ port: i.port ?? 5173,
44
+ host: i.host,
45
+ open: i.open
60
46
  }
61
47
  });
62
- await server.listen();
63
- server.printUrls();
48
+ await r.listen(), r.printUrls();
64
49
  }
65
50
  }
66
- /**
67
- * Preview the production build
68
- */
69
- async function preview(options = {}) {
70
- const root = process.cwd();
71
- console.log("\n👀 @sigx/ssg - Preview server...\n");
72
- (await (await import("vite")).preview({
73
- root,
51
+ async function a(e = {}) {
52
+ let t = process.cwd();
53
+ console.log("\n👀 @sigx/ssg - Preview server...\n"), (await (await import("vite")).preview({
54
+ root: t,
74
55
  preview: {
75
- port: options.port ?? 4173,
76
- host: options.host,
77
- open: options.open
56
+ port: e.port ?? 4173,
57
+ host: e.host,
58
+ open: e.open
78
59
  }
79
- })).printUrls();
80
- console.log("\n");
60
+ })).printUrls(), console.log("\n");
81
61
  }
82
62
  //#endregion
83
- export { dev, preview };
63
+ export { i as dev, a as preview };
84
64
 
85
65
  //# sourceMappingURL=dev.js.map
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","names":[],"sources":["../src/dev.ts"],"sourcesContent":["/**\r\n * SSG Dev Server\r\n *\r\n * Starts a Vite development server with SSG plugins pre-configured.\r\n * Provides a unified `ssg dev` command for zero-config development.\r\n */\r\n\r\nimport path from 'node:path';\r\nimport fs from 'node:fs';\r\nimport type { SSGConfig } from './types';\r\nimport { loadConfig } from './config';\r\nimport { ssgPlugin } from './vite/plugin';\r\n\r\n/**\r\n * Dev server options\r\n */\r\nexport interface DevOptions {\r\n /**\r\n * Path to ssg.config.ts\r\n */\r\n configPath?: string;\r\n\r\n /**\r\n * Port to run dev server on\r\n * @default 5173\r\n */\r\n port?: number;\r\n\r\n /**\r\n * Host to bind to\r\n * @default 'localhost'\r\n */\r\n host?: string | boolean;\r\n\r\n /**\r\n * Open browser automatically\r\n * @default false\r\n */\r\n open?: boolean;\r\n\r\n /**\r\n * Enable verbose logging\r\n */\r\n verbose?: boolean;\r\n}\r\n\r\n/**\r\n * Start the SSG development server\r\n */\r\nexport async function dev(options: DevOptions = {}): Promise<void> {\r\n const root = process.cwd();\r\n\r\n console.log('\\n🚀 @sigx/ssg - Starting development server...\\n');\r\n\r\n // Load SSG config\r\n const ssgConfig = await loadConfig(options.configPath);\r\n\r\n // Check if user has a vite.config.ts\r\n const hasViteConfig = fs.existsSync(path.join(root, 'vite.config.ts')) ||\r\n fs.existsSync(path.join(root, 'vite.config.js')) ||\r\n fs.existsSync(path.join(root, 'vite.config.mjs'));\r\n\r\n // Import Vite\r\n const vite = await import('vite');\r\n\r\n if (hasViteConfig) {\r\n // User has their own vite.config - use it directly\r\n // They should have ssgPlugin() configured already\r\n console.log('📦 Using existing vite.config\\n');\r\n\r\n const server = await vite.createServer({\r\n root,\r\n server: {\r\n port: options.port,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n await server.listen();\r\n server.printUrls();\r\n } else {\r\n // Zero-config mode - configure everything automatically\r\n console.log('📦 Zero-config mode enabled\\n');\r\n\r\n // Try to import @sigx/vite plugin\r\n let sigxPlugin: ((...args: any[]) => any) | undefined;\r\n try {\r\n const sigxVite = await import('@sigx/vite');\r\n sigxPlugin = sigxVite.sigxPlugin;\r\n } catch {\r\n console.warn('⚠️ @sigx/vite not found, JSX transform may not work');\r\n console.warn(' Install with: npm install @sigx/vite\\n');\r\n }\r\n\r\n // Build plugins array\r\n const plugins: any[] = [];\r\n\r\n // Add Tailwind CSS if available\r\n try {\r\n // @ts-expect-error - Optional dependency\r\n const tailwind = await import('@tailwindcss/vite');\r\n plugins.push(tailwind.default());\r\n } catch {\r\n // Tailwind not installed, skip\r\n }\r\n\r\n // Add SignalX plugin if available\r\n if (sigxPlugin) {\r\n plugins.push(sigxPlugin());\r\n }\r\n\r\n // Add SSG plugin\r\n plugins.push(...ssgPlugin({ configPath: options.configPath }));\r\n\r\n const server = await vite.createServer({\r\n root,\r\n plugins,\r\n // Vite 8 uses oxc instead of esbuild for JSX transforms\r\n oxc: {\r\n jsx: {\r\n runtime: 'automatic',\r\n importSource: 'sigx',\r\n }\r\n },\r\n server: {\r\n port: options.port ?? 5173,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n await server.listen();\r\n server.printUrls();\r\n }\r\n}\r\n\r\n/**\r\n * Preview the production build\r\n */\r\nexport async function preview(options: DevOptions = {}): Promise<void> {\r\n const root = process.cwd();\r\n\r\n console.log('\\n👀 @sigx/ssg - Preview server...\\n');\r\n\r\n const vite = await import('vite');\r\n\r\n const server = await vite.preview({\r\n root,\r\n preview: {\r\n port: options.port ?? 4173,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n server.printUrls();\r\n console.log('\\n');\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;AAiDA,eAAsB,IAAI,UAAsB,EAAE,EAAiB;CAC/D,MAAM,OAAO,QAAQ,KAAK;AAE1B,SAAQ,IAAI,oDAAoD;AAG9C,OAAM,WAAW,QAAQ,WAAW;CAGtD,MAAM,gBAAgB,OAAG,WAAW,KAAK,KAAK,MAAM,iBAAiB,CAAC,IAClE,OAAG,WAAW,KAAK,KAAK,MAAM,iBAAiB,CAAC,IAChD,OAAG,WAAW,KAAK,KAAK,MAAM,kBAAkB,CAAC;CAGrD,MAAM,OAAO,MAAM,OAAO;AAE1B,KAAI,eAAe;AAGf,UAAQ,IAAI,kCAAkC;EAE9C,MAAM,SAAS,MAAM,KAAK,aAAa;GACnC;GACA,QAAQ;IACJ,MAAM,QAAQ;IACd,MAAM,QAAQ;IACd,MAAM,QAAQ;IACjB;GACJ,CAAC;AAEF,QAAM,OAAO,QAAQ;AACrB,SAAO,WAAW;QACf;AAEH,UAAQ,IAAI,gCAAgC;EAG5C,IAAI;AACJ,MAAI;AAEA,iBADiB,MAAM,OAAO,eACR;UAClB;AACJ,WAAQ,KAAK,uDAAuD;AACpE,WAAQ,KAAK,4CAA4C;;EAI7D,MAAM,UAAiB,EAAE;AAGzB,MAAI;GAEA,MAAM,WAAW,MAAM,OAAO;AAC9B,WAAQ,KAAK,SAAS,SAAS,CAAC;UAC5B;AAKR,MAAI,WACA,SAAQ,KAAK,YAAY,CAAC;AAI9B,UAAQ,KAAK,GAAG,UAAU,EAAE,YAAY,QAAQ,YAAY,CAAC,CAAC;EAE9D,MAAM,SAAS,MAAM,KAAK,aAAa;GACnC;GACA;GAEA,KAAK,EACD,KAAK;IACD,SAAS;IACT,cAAc;IACjB,EACJ;GACD,QAAQ;IACJ,MAAM,QAAQ,QAAQ;IACtB,MAAM,QAAQ;IACd,MAAM,QAAQ;IACjB;GACJ,CAAC;AAEF,QAAM,OAAO,QAAQ;AACrB,SAAO,WAAW;;;;;;AAO1B,eAAsB,QAAQ,UAAsB,EAAE,EAAiB;CACnE,MAAM,OAAO,QAAQ,KAAK;AAE1B,SAAQ,IAAI,uCAAuC;AAanD,EATe,OAFF,MAAM,OAAO,SAEA,QAAQ;EAC9B;EACA,SAAS;GACL,MAAM,QAAQ,QAAQ;GACtB,MAAM,QAAQ;GACd,MAAM,QAAQ;GACjB;EACJ,CAAC,EAEK,WAAW;AAClB,SAAQ,IAAI,KAAK"}
1
+ {"version":3,"file":"dev.js","names":[],"sources":["../src/dev.ts"],"sourcesContent":["/**\r\n * SSG Dev Server\r\n *\r\n * Starts a Vite development server with SSG plugins pre-configured.\r\n * Provides a unified `ssg dev` command for zero-config development.\r\n */\r\n\r\nimport path from 'node:path';\r\nimport fs from 'node:fs';\r\nimport type { SSGConfig } from './types';\r\nimport { loadConfig } from './config';\r\nimport { ssgPlugin } from './vite/plugin';\r\n\r\n/**\r\n * Dev server options\r\n */\r\nexport interface DevOptions {\r\n /**\r\n * Path to ssg.config.ts\r\n */\r\n configPath?: string;\r\n\r\n /**\r\n * Port to run dev server on\r\n * @default 5173\r\n */\r\n port?: number;\r\n\r\n /**\r\n * Host to bind to\r\n * @default 'localhost'\r\n */\r\n host?: string | boolean;\r\n\r\n /**\r\n * Open browser automatically\r\n * @default false\r\n */\r\n open?: boolean;\r\n\r\n /**\r\n * Enable verbose logging\r\n */\r\n verbose?: boolean;\r\n}\r\n\r\n/**\r\n * Start the SSG development server\r\n */\r\nexport async function dev(options: DevOptions = {}): Promise<void> {\r\n const root = process.cwd();\r\n\r\n console.log('\\n🚀 @sigx/ssg - Starting development server...\\n');\r\n\r\n // Load SSG config\r\n const ssgConfig = await loadConfig(options.configPath);\r\n\r\n // Check if user has a vite.config.ts\r\n const hasViteConfig = fs.existsSync(path.join(root, 'vite.config.ts')) ||\r\n fs.existsSync(path.join(root, 'vite.config.js')) ||\r\n fs.existsSync(path.join(root, 'vite.config.mjs'));\r\n\r\n // Import Vite\r\n const vite = await import('vite');\r\n\r\n if (hasViteConfig) {\r\n // User has their own vite.config - use it directly\r\n // They should have ssgPlugin() configured already\r\n console.log('📦 Using existing vite.config\\n');\r\n\r\n const server = await vite.createServer({\r\n root,\r\n server: {\r\n port: options.port,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n await server.listen();\r\n server.printUrls();\r\n } else {\r\n // Zero-config mode - configure everything automatically\r\n console.log('📦 Zero-config mode enabled\\n');\r\n\r\n // Try to import @sigx/vite plugin\r\n let sigxPlugin: ((...args: any[]) => any) | undefined;\r\n try {\r\n const sigxVite = await import('@sigx/vite');\r\n sigxPlugin = sigxVite.sigxPlugin;\r\n } catch {\r\n console.warn('⚠️ @sigx/vite not found, JSX transform may not work');\r\n console.warn(' Install with: npm install @sigx/vite\\n');\r\n }\r\n\r\n // Build plugins array\r\n const plugins: any[] = [];\r\n\r\n // Add Tailwind CSS if available\r\n try {\r\n // @ts-expect-error - Optional dependency\r\n const tailwind = await import('@tailwindcss/vite');\r\n plugins.push(tailwind.default());\r\n } catch {\r\n // Tailwind not installed, skip\r\n }\r\n\r\n // Add SignalX plugin if available\r\n if (sigxPlugin) {\r\n plugins.push(sigxPlugin());\r\n }\r\n\r\n // Add SSG plugin\r\n plugins.push(...ssgPlugin({ configPath: options.configPath }));\r\n\r\n const server = await vite.createServer({\r\n root,\r\n plugins,\r\n // Vite 8 uses oxc instead of esbuild for JSX transforms\r\n oxc: {\r\n jsx: {\r\n runtime: 'automatic',\r\n importSource: 'sigx',\r\n }\r\n },\r\n server: {\r\n port: options.port ?? 5173,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n await server.listen();\r\n server.printUrls();\r\n }\r\n}\r\n\r\n/**\r\n * Preview the production build\r\n */\r\nexport async function preview(options: DevOptions = {}): Promise<void> {\r\n const root = process.cwd();\r\n\r\n console.log('\\n👀 @sigx/ssg - Preview server...\\n');\r\n\r\n const vite = await import('vite');\r\n\r\n const server = await vite.preview({\r\n root,\r\n preview: {\r\n port: options.port ?? 4173,\r\n host: options.host,\r\n open: options.open,\r\n },\r\n });\r\n\r\n server.printUrls();\r\n console.log('\\n');\r\n}\r\n"],"mappings":";;;;;AAiDA,eAAsB,EAAI,IAAsB,EAAE,EAAiB;CAC/D,IAAM,IAAO,QAAQ,KAAK;AAKR,CAHlB,QAAQ,IAAI,oDAAoD,EAG9C,MAAM,EAAW,EAAQ,WAAW;CAGtD,IAAM,IAAgB,EAAG,WAAW,EAAK,KAAK,GAAM,iBAAiB,CAAC,IAClE,EAAG,WAAW,EAAK,KAAK,GAAM,iBAAiB,CAAC,IAChD,EAAG,WAAW,EAAK,KAAK,GAAM,kBAAkB,CAAC,EAG/C,IAAO,MAAM,OAAO;AAE1B,KAAI,GAAe;AAGf,UAAQ,IAAI,kCAAkC;EAE9C,IAAM,IAAS,MAAM,EAAK,aAAa;GACnC;GACA,QAAQ;IACJ,MAAM,EAAQ;IACd,MAAM,EAAQ;IACd,MAAM,EAAQ;IACjB;GACJ,CAAC;AAGF,EADA,MAAM,EAAO,QAAQ,EACrB,EAAO,WAAW;QACf;AAEH,UAAQ,IAAI,gCAAgC;EAG5C,IAAI;AACJ,MAAI;AAEA,QADiB,MAAM,OAAO,eACR;UAClB;AAEJ,GADA,QAAQ,KAAK,uDAAuD,EACpE,QAAQ,KAAK,4CAA4C;;EAI7D,IAAM,IAAiB,EAAE;AAGzB,MAAI;GAEA,IAAM,IAAW,MAAM,OAAO;AAC9B,KAAQ,KAAK,EAAS,SAAS,CAAC;UAC5B;AAUR,EALI,KACA,EAAQ,KAAK,GAAY,CAAC,EAI9B,EAAQ,KAAK,GAAG,EAAU,EAAE,YAAY,EAAQ,YAAY,CAAC,CAAC;EAE9D,IAAM,IAAS,MAAM,EAAK,aAAa;GACnC;GACA;GAEA,KAAK,EACD,KAAK;IACD,SAAS;IACT,cAAc;IACjB,EACJ;GACD,QAAQ;IACJ,MAAM,EAAQ,QAAQ;IACtB,MAAM,EAAQ;IACd,MAAM,EAAQ;IACjB;GACJ,CAAC;AAGF,EADA,MAAM,EAAO,QAAQ,EACrB,EAAO,WAAW;;;AAO1B,eAAsB,EAAQ,IAAsB,EAAE,EAAiB;CACnE,IAAM,IAAO,QAAQ,KAAK;AAgB1B,CAdA,QAAQ,IAAI,uCAAuC,GAIpC,OAFF,MAAM,OAAO,SAEA,QAAQ;EAC9B;EACA,SAAS;GACL,MAAM,EAAQ,QAAQ;GACtB,MAAM,EAAQ;GACd,MAAM,EAAQ;GACjB;EACJ,CAAC,EAEK,WAAW,EAClB,QAAQ,IAAI,KAAK"}
package/dist/index.js CHANGED
@@ -1,51 +1,25 @@
1
- import { O as defineSSGConfig } from "./virtual-entries-TuNN2It1.js";
2
- import { a as writeSitemap, i as pagesToSitemapEntries, n as generateRobotsTxt, r as generateSitemap, t as build } from "./build-qmtK32gt.js";
3
- import { dev, preview } from "./dev.js";
4
- import path from "node:path";
1
+ import { O as e } from "./virtual-entries-CH-0HuqJ.js";
2
+ import { a as t, i as n, n as r, r as i, t as a } from "./build-DP9zez3B.js";
3
+ import { dev as o, preview as s } from "./dev.js";
4
+ import c from "node:path";
5
5
  //#region src/errors.ts
6
- /**
7
- * SSG Error Classes and Utilities
8
- *
9
- * Provides structured error messages with file locations and suggestions
10
- * for common issues encountered during development and build.
11
- */
12
- /**
13
- * Base SSG error with enhanced formatting
14
- */
15
- var SSGError = class extends Error {
6
+ var l = class extends Error {
16
7
  code;
17
8
  file;
18
9
  line;
19
10
  suggestion;
20
- constructor(message, options) {
21
- super(message);
22
- this.name = "SSGError";
23
- this.code = options.code;
24
- this.file = options.file;
25
- this.line = options.line;
26
- this.suggestion = options.suggestion;
27
- this.cause = options.cause;
11
+ constructor(e, t) {
12
+ super(e), this.name = "SSGError", this.code = t.code, this.file = t.file, this.line = t.line, this.suggestion = t.suggestion, this.cause = t.cause;
28
13
  }
29
- /**
30
- * Format error for console output with colors
31
- */
32
- format(root) {
33
- const lines = [];
34
- lines.push(`\n❌ ${this.code}: ${this.message}\n`);
35
- if (this.file) {
36
- const displayPath = root ? path.relative(root, this.file) : this.file;
37
- if (this.line) lines.push(` 📁 ${displayPath}:${this.line}`);
38
- else lines.push(` 📁 ${displayPath}`);
14
+ format(e) {
15
+ let t = [];
16
+ if (t.push(`\n❌ ${this.code}: ${this.message}\n`), this.file) {
17
+ let n = e ? c.relative(e, this.file) : this.file;
18
+ this.line ? t.push(` 📁 ${n}:${this.line}`) : t.push(` 📁 ${n}`);
39
19
  }
40
- if (this.suggestion) lines.push(`\n 💡 ${this.suggestion}`);
41
- lines.push("");
42
- return lines.join("\n");
20
+ return this.suggestion && t.push(`\n 💡 ${this.suggestion}`), t.push(""), t.join("\n");
43
21
  }
44
- };
45
- /**
46
- * Error codes for categorization
47
- */
48
- var ErrorCodes = {
22
+ }, u = {
49
23
  CONFIG_NOT_FOUND: "SSG001",
50
24
  CONFIG_INVALID: "SSG002",
51
25
  CONFIG_THEME_NOT_FOUND: "SSG003",
@@ -58,20 +32,10 @@ var ErrorCodes = {
58
32
  MDX_PARSE_ERROR: "SSG400",
59
33
  MDX_FRONTMATTER_ERROR: "SSG401"
60
34
  };
61
- /**
62
- * Format and log an SSG error with full context
63
- */
64
- function handleError(error, root) {
65
- if (error instanceof SSGError) {
66
- console.error(error.format(root));
67
- if (error.cause) console.error(" Caused by:", error.cause);
68
- } else if (error instanceof Error) {
69
- console.error(`\n❌ ${error.name}: ${error.message}\n`);
70
- if (error.stack) console.error(error.stack);
71
- } else console.error("\n❌ Unknown error:", error);
72
- process.exit(1);
35
+ function d(e, t) {
36
+ e instanceof l ? (console.error(e.format(t)), e.cause && console.error(" Caused by:", e.cause)) : e instanceof Error ? (console.error(`\n❌ ${e.name}: ${e.message}\n`), e.stack && console.error(e.stack)) : console.error("\n❌ Unknown error:", e), process.exit(1);
73
37
  }
74
38
  //#endregion
75
- export { ErrorCodes, SSGError, build, defineSSGConfig as defineConfig, defineSSGConfig, dev, generateRobotsTxt, generateSitemap, handleError, pagesToSitemapEntries, preview, writeSitemap };
39
+ export { u as ErrorCodes, l as SSGError, a as build, e as defineConfig, e as defineSSGConfig, o as dev, r as generateRobotsTxt, i as generateSitemap, d as handleError, n as pagesToSitemapEntries, s as preview, t as writeSitemap };
76
40
 
77
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\r\n * SSG Error Classes and Utilities\r\n *\r\n * Provides structured error messages with file locations and suggestions\r\n * for common issues encountered during development and build.\r\n */\r\n\r\nimport path from 'node:path';\r\n\r\n/**\r\n * Base SSG error with enhanced formatting\r\n */\r\nexport class SSGError extends Error {\r\n readonly code: string;\r\n readonly file?: string;\r\n readonly line?: number;\r\n readonly suggestion?: string;\r\n\r\n constructor(\r\n message: string,\r\n options: {\r\n code: string;\r\n file?: string;\r\n line?: number;\r\n suggestion?: string;\r\n cause?: Error;\r\n }\r\n ) {\r\n super(message);\r\n this.name = 'SSGError';\r\n this.code = options.code;\r\n this.file = options.file;\r\n this.line = options.line;\r\n this.suggestion = options.suggestion;\r\n this.cause = options.cause;\r\n }\r\n\r\n /**\r\n * Format error for console output with colors\r\n */\r\n format(root?: string): string {\r\n const lines: string[] = [];\r\n \r\n // Header with error code\r\n lines.push(`\\n❌ ${this.code}: ${this.message}\\n`);\r\n \r\n // File location\r\n if (this.file) {\r\n const displayPath = root ? path.relative(root, this.file) : this.file;\r\n if (this.line) {\r\n lines.push(` 📁 ${displayPath}:${this.line}`);\r\n } else {\r\n lines.push(` 📁 ${displayPath}`);\r\n }\r\n }\r\n \r\n // Suggestion\r\n if (this.suggestion) {\r\n lines.push(`\\n 💡 ${this.suggestion}`);\r\n }\r\n \r\n lines.push('');\r\n return lines.join('\\n');\r\n }\r\n}\r\n\r\n/**\r\n * Error codes for categorization\r\n */\r\nexport const ErrorCodes = {\r\n // Config errors\r\n CONFIG_NOT_FOUND: 'SSG001',\r\n CONFIG_INVALID: 'SSG002',\r\n CONFIG_THEME_NOT_FOUND: 'SSG003',\r\n \r\n // Route/Page errors\r\n PAGE_NOT_FOUND: 'SSG100',\r\n PAGE_INVALID_EXPORT: 'SSG101',\r\n DYNAMIC_ROUTE_NO_PATHS: 'SSG102',\r\n LAYOUT_NOT_FOUND: 'SSG103',\r\n \r\n // Build errors\r\n BUILD_RENDER_FAILED: 'SSG300',\r\n BUILD_VITE_FAILED: 'SSG301',\r\n \r\n // MDX errors\r\n MDX_PARSE_ERROR: 'SSG400',\r\n MDX_FRONTMATTER_ERROR: 'SSG401',\r\n} as const;\r\n\r\n// ============================================================================\r\n// Config Errors\r\n// ============================================================================\r\n\r\nexport function configNotFoundError(searchedPaths: string[]): SSGError {\r\n return new SSGError(\r\n 'No SSG configuration file found',\r\n {\r\n code: ErrorCodes.CONFIG_NOT_FOUND,\r\n suggestion: `Create ssg.config.ts in your project root:\\n\\n` +\r\n ` import { defineSSGConfig } from '@sigx/ssg';\\n` +\r\n ` export default defineSSGConfig({ site: { title: 'My Site' } });`,\r\n }\r\n );\r\n}\r\n\r\nexport function themeNotFoundError(themeName: string): SSGError {\r\n return new SSGError(\r\n `Theme package \"${themeName}\" not found`,\r\n {\r\n code: ErrorCodes.CONFIG_THEME_NOT_FOUND,\r\n suggestion: `Install the theme package:\\n\\n npm install ${themeName}`,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Route/Page Errors\r\n// ============================================================================\r\n\r\nexport function layoutNotFoundError(layoutName: string, pagePath: string, availableLayouts: string[]): SSGError {\r\n const available = availableLayouts.length > 0\r\n ? `Available layouts: ${availableLayouts.join(', ')}`\r\n : 'No layouts found. Create one in src/layouts/';\r\n \r\n return new SSGError(\r\n `Layout \"${layoutName}\" not found`,\r\n {\r\n code: ErrorCodes.LAYOUT_NOT_FOUND,\r\n file: pagePath,\r\n suggestion: `${available}\\n\\n To use a layout, set it in frontmatter:\\n ---\\n layout: default\\n ---`,\r\n }\r\n );\r\n}\r\n\r\nexport function dynamicRouteNoPaths(filePath: string, routePath: string): SSGError {\r\n return new SSGError(\r\n `Dynamic route has no getStaticPaths export`,\r\n {\r\n code: ErrorCodes.DYNAMIC_ROUTE_NO_PATHS,\r\n file: filePath,\r\n suggestion: `Dynamic routes like \"${routePath}\" require a getStaticPaths export:\\n\\n` +\r\n ` export async function getStaticPaths() {\\n` +\r\n ` return [{ params: { slug: 'example' } }];\\n` +\r\n ` }`,\r\n }\r\n );\r\n}\r\n\r\nexport function pageInvalidExport(filePath: string): SSGError {\r\n return new SSGError(\r\n `Page file has no default export`,\r\n {\r\n code: ErrorCodes.PAGE_INVALID_EXPORT,\r\n file: filePath,\r\n suggestion: `Pages must export a default component:\\n\\n` +\r\n ` export default component(() => {\\n` +\r\n ` return () => <div>Page content</div>;\\n` +\r\n ` });`,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Build Errors\r\n// ============================================================================\r\n\r\nexport function buildRenderError(path: string, error: Error): SSGError {\r\n return new SSGError(\r\n `Failed to render page: ${path}`,\r\n {\r\n code: ErrorCodes.BUILD_RENDER_FAILED,\r\n suggestion: `Check the error details below. Common causes:\\n` +\r\n ` - Runtime error in component code\\n` +\r\n ` - Missing dependencies during SSR\\n` +\r\n ` - Browser APIs used during server render`,\r\n cause: error,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// MDX Errors\r\n// ============================================================================\r\n\r\nexport function mdxParseError(file: string, error: Error, line?: number): SSGError {\r\n return new SSGError(\r\n `Failed to parse MDX file`,\r\n {\r\n code: ErrorCodes.MDX_PARSE_ERROR,\r\n file,\r\n line,\r\n suggestion: `Check the MDX syntax. Common issues:\\n` +\r\n ` - Unclosed JSX tags\\n` +\r\n ` - Invalid JavaScript expressions\\n` +\r\n ` - Mixing HTML with JSX incorrectly`,\r\n cause: error,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Error Handler\r\n// ============================================================================\r\n\r\n/**\r\n * Format and log an SSG error with full context\r\n */\r\nexport function handleError(error: unknown, root?: string): never {\r\n if (error instanceof SSGError) {\r\n console.error(error.format(root));\r\n if (error.cause) {\r\n console.error(' Caused by:', error.cause);\r\n }\r\n } else if (error instanceof Error) {\r\n console.error(`\\n❌ ${error.name}: ${error.message}\\n`);\r\n if (error.stack) {\r\n console.error(error.stack);\r\n }\r\n } else {\r\n console.error('\\n❌ Unknown error:', error);\r\n }\r\n \r\n process.exit(1);\r\n}\r\n\r\n/**\r\n * Wrap an async function with error handling\r\n */\r\nexport function withErrorHandling<T>(\r\n fn: () => Promise<T>,\r\n root?: string\r\n): Promise<T> {\r\n return fn().catch((error) => {\r\n handleError(error, root);\r\n });\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;AAYA,IAAa,WAAb,cAA8B,MAAM;CAChC;CACA;CACA;CACA;CAEA,YACI,SACA,SAOF;AACE,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,OAAO,QAAQ;AACpB,OAAK,OAAO,QAAQ;AACpB,OAAK,OAAO,QAAQ;AACpB,OAAK,aAAa,QAAQ;AAC1B,OAAK,QAAQ,QAAQ;;;;;CAMzB,OAAO,MAAuB;EAC1B,MAAM,QAAkB,EAAE;AAG1B,QAAM,KAAK,OAAO,KAAK,KAAK,IAAI,KAAK,QAAQ,IAAI;AAGjD,MAAI,KAAK,MAAM;GACX,MAAM,cAAc,OAAO,KAAK,SAAS,MAAM,KAAK,KAAK,GAAG,KAAK;AACjE,OAAI,KAAK,KACL,OAAM,KAAK,SAAS,YAAY,GAAG,KAAK,OAAO;OAE/C,OAAM,KAAK,SAAS,cAAc;;AAK1C,MAAI,KAAK,WACL,OAAM,KAAK,WAAW,KAAK,aAAa;AAG5C,QAAM,KAAK,GAAG;AACd,SAAO,MAAM,KAAK,KAAK;;;;;;AAO/B,IAAa,aAAa;CAEtB,kBAAkB;CAClB,gBAAgB;CAChB,wBAAwB;CAGxB,gBAAgB;CAChB,qBAAqB;CACrB,wBAAwB;CACxB,kBAAkB;CAGlB,qBAAqB;CACrB,mBAAmB;CAGnB,iBAAiB;CACjB,uBAAuB;CAC1B;;;;AAwHD,SAAgB,YAAY,OAAgB,MAAsB;AAC9D,KAAI,iBAAiB,UAAU;AAC3B,UAAQ,MAAM,MAAM,OAAO,KAAK,CAAC;AACjC,MAAI,MAAM,MACN,SAAQ,MAAM,iBAAiB,MAAM,MAAM;YAExC,iBAAiB,OAAO;AAC/B,UAAQ,MAAM,OAAO,MAAM,KAAK,IAAI,MAAM,QAAQ,IAAI;AACtD,MAAI,MAAM,MACN,SAAQ,MAAM,MAAM,MAAM;OAG9B,SAAQ,MAAM,sBAAsB,MAAM;AAG9C,SAAQ,KAAK,EAAE"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\r\n * SSG Error Classes and Utilities\r\n *\r\n * Provides structured error messages with file locations and suggestions\r\n * for common issues encountered during development and build.\r\n */\r\n\r\nimport path from 'node:path';\r\n\r\n/**\r\n * Base SSG error with enhanced formatting\r\n */\r\nexport class SSGError extends Error {\r\n readonly code: string;\r\n readonly file?: string;\r\n readonly line?: number;\r\n readonly suggestion?: string;\r\n\r\n constructor(\r\n message: string,\r\n options: {\r\n code: string;\r\n file?: string;\r\n line?: number;\r\n suggestion?: string;\r\n cause?: Error;\r\n }\r\n ) {\r\n super(message);\r\n this.name = 'SSGError';\r\n this.code = options.code;\r\n this.file = options.file;\r\n this.line = options.line;\r\n this.suggestion = options.suggestion;\r\n this.cause = options.cause;\r\n }\r\n\r\n /**\r\n * Format error for console output with colors\r\n */\r\n format(root?: string): string {\r\n const lines: string[] = [];\r\n \r\n // Header with error code\r\n lines.push(`\\n❌ ${this.code}: ${this.message}\\n`);\r\n \r\n // File location\r\n if (this.file) {\r\n const displayPath = root ? path.relative(root, this.file) : this.file;\r\n if (this.line) {\r\n lines.push(` 📁 ${displayPath}:${this.line}`);\r\n } else {\r\n lines.push(` 📁 ${displayPath}`);\r\n }\r\n }\r\n \r\n // Suggestion\r\n if (this.suggestion) {\r\n lines.push(`\\n 💡 ${this.suggestion}`);\r\n }\r\n \r\n lines.push('');\r\n return lines.join('\\n');\r\n }\r\n}\r\n\r\n/**\r\n * Error codes for categorization\r\n */\r\nexport const ErrorCodes = {\r\n // Config errors\r\n CONFIG_NOT_FOUND: 'SSG001',\r\n CONFIG_INVALID: 'SSG002',\r\n CONFIG_THEME_NOT_FOUND: 'SSG003',\r\n \r\n // Route/Page errors\r\n PAGE_NOT_FOUND: 'SSG100',\r\n PAGE_INVALID_EXPORT: 'SSG101',\r\n DYNAMIC_ROUTE_NO_PATHS: 'SSG102',\r\n LAYOUT_NOT_FOUND: 'SSG103',\r\n \r\n // Build errors\r\n BUILD_RENDER_FAILED: 'SSG300',\r\n BUILD_VITE_FAILED: 'SSG301',\r\n \r\n // MDX errors\r\n MDX_PARSE_ERROR: 'SSG400',\r\n MDX_FRONTMATTER_ERROR: 'SSG401',\r\n} as const;\r\n\r\n// ============================================================================\r\n// Config Errors\r\n// ============================================================================\r\n\r\nexport function configNotFoundError(searchedPaths: string[]): SSGError {\r\n return new SSGError(\r\n 'No SSG configuration file found',\r\n {\r\n code: ErrorCodes.CONFIG_NOT_FOUND,\r\n suggestion: `Create ssg.config.ts in your project root:\\n\\n` +\r\n ` import { defineSSGConfig } from '@sigx/ssg';\\n` +\r\n ` export default defineSSGConfig({ site: { title: 'My Site' } });`,\r\n }\r\n );\r\n}\r\n\r\nexport function themeNotFoundError(themeName: string): SSGError {\r\n return new SSGError(\r\n `Theme package \"${themeName}\" not found`,\r\n {\r\n code: ErrorCodes.CONFIG_THEME_NOT_FOUND,\r\n suggestion: `Install the theme package:\\n\\n npm install ${themeName}`,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Route/Page Errors\r\n// ============================================================================\r\n\r\nexport function layoutNotFoundError(layoutName: string, pagePath: string, availableLayouts: string[]): SSGError {\r\n const available = availableLayouts.length > 0\r\n ? `Available layouts: ${availableLayouts.join(', ')}`\r\n : 'No layouts found. Create one in src/layouts/';\r\n \r\n return new SSGError(\r\n `Layout \"${layoutName}\" not found`,\r\n {\r\n code: ErrorCodes.LAYOUT_NOT_FOUND,\r\n file: pagePath,\r\n suggestion: `${available}\\n\\n To use a layout, set it in frontmatter:\\n ---\\n layout: default\\n ---`,\r\n }\r\n );\r\n}\r\n\r\nexport function dynamicRouteNoPaths(filePath: string, routePath: string): SSGError {\r\n return new SSGError(\r\n `Dynamic route has no getStaticPaths export`,\r\n {\r\n code: ErrorCodes.DYNAMIC_ROUTE_NO_PATHS,\r\n file: filePath,\r\n suggestion: `Dynamic routes like \"${routePath}\" require a getStaticPaths export:\\n\\n` +\r\n ` export async function getStaticPaths() {\\n` +\r\n ` return [{ params: { slug: 'example' } }];\\n` +\r\n ` }`,\r\n }\r\n );\r\n}\r\n\r\nexport function pageInvalidExport(filePath: string): SSGError {\r\n return new SSGError(\r\n `Page file has no default export`,\r\n {\r\n code: ErrorCodes.PAGE_INVALID_EXPORT,\r\n file: filePath,\r\n suggestion: `Pages must export a default component:\\n\\n` +\r\n ` export default component(() => {\\n` +\r\n ` return () => <div>Page content</div>;\\n` +\r\n ` });`,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Build Errors\r\n// ============================================================================\r\n\r\nexport function buildRenderError(path: string, error: Error): SSGError {\r\n return new SSGError(\r\n `Failed to render page: ${path}`,\r\n {\r\n code: ErrorCodes.BUILD_RENDER_FAILED,\r\n suggestion: `Check the error details below. Common causes:\\n` +\r\n ` - Runtime error in component code\\n` +\r\n ` - Missing dependencies during SSR\\n` +\r\n ` - Browser APIs used during server render`,\r\n cause: error,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// MDX Errors\r\n// ============================================================================\r\n\r\nexport function mdxParseError(file: string, error: Error, line?: number): SSGError {\r\n return new SSGError(\r\n `Failed to parse MDX file`,\r\n {\r\n code: ErrorCodes.MDX_PARSE_ERROR,\r\n file,\r\n line,\r\n suggestion: `Check the MDX syntax. Common issues:\\n` +\r\n ` - Unclosed JSX tags\\n` +\r\n ` - Invalid JavaScript expressions\\n` +\r\n ` - Mixing HTML with JSX incorrectly`,\r\n cause: error,\r\n }\r\n );\r\n}\r\n\r\n// ============================================================================\r\n// Error Handler\r\n// ============================================================================\r\n\r\n/**\r\n * Format and log an SSG error with full context\r\n */\r\nexport function handleError(error: unknown, root?: string): never {\r\n if (error instanceof SSGError) {\r\n console.error(error.format(root));\r\n if (error.cause) {\r\n console.error(' Caused by:', error.cause);\r\n }\r\n } else if (error instanceof Error) {\r\n console.error(`\\n❌ ${error.name}: ${error.message}\\n`);\r\n if (error.stack) {\r\n console.error(error.stack);\r\n }\r\n } else {\r\n console.error('\\n❌ Unknown error:', error);\r\n }\r\n \r\n process.exit(1);\r\n}\r\n\r\n/**\r\n * Wrap an async function with error handling\r\n */\r\nexport function withErrorHandling<T>(\r\n fn: () => Promise<T>,\r\n root?: string\r\n): Promise<T> {\r\n return fn().catch((error) => {\r\n handleError(error, root);\r\n });\r\n}\r\n"],"mappings":";;;;;AAYA,IAAa,IAAb,cAA8B,MAAM;CAChC;CACA;CACA;CACA;CAEA,YACI,GACA,GAOF;AAOE,EANA,MAAM,EAAQ,EACd,KAAK,OAAO,YACZ,KAAK,OAAO,EAAQ,MACpB,KAAK,OAAO,EAAQ,MACpB,KAAK,OAAO,EAAQ,MACpB,KAAK,aAAa,EAAQ,YAC1B,KAAK,QAAQ,EAAQ;;CAMzB,OAAO,GAAuB;EAC1B,IAAM,IAAkB,EAAE;AAM1B,MAHA,EAAM,KAAK,OAAO,KAAK,KAAK,IAAI,KAAK,QAAQ,IAAI,EAG7C,KAAK,MAAM;GACX,IAAM,IAAc,IAAO,EAAK,SAAS,GAAM,KAAK,KAAK,GAAG,KAAK;AACjE,GAAI,KAAK,OACL,EAAM,KAAK,SAAS,EAAY,GAAG,KAAK,OAAO,GAE/C,EAAM,KAAK,SAAS,IAAc;;AAU1C,SALI,KAAK,cACL,EAAM,KAAK,WAAW,KAAK,aAAa,EAG5C,EAAM,KAAK,GAAG,EACP,EAAM,KAAK,KAAK;;GAOlB,IAAa;CAEtB,kBAAkB;CAClB,gBAAgB;CAChB,wBAAwB;CAGxB,gBAAgB;CAChB,qBAAqB;CACrB,wBAAwB;CACxB,kBAAkB;CAGlB,qBAAqB;CACrB,mBAAmB;CAGnB,iBAAiB;CACjB,uBAAuB;CAC1B;AAwHD,SAAgB,EAAY,GAAgB,GAAsB;AAe9D,CAdI,aAAiB,KACjB,QAAQ,MAAM,EAAM,OAAO,EAAK,CAAC,EAC7B,EAAM,SACN,QAAQ,MAAM,iBAAiB,EAAM,MAAM,IAExC,aAAiB,SACxB,QAAQ,MAAM,OAAO,EAAM,KAAK,IAAI,EAAM,QAAQ,IAAI,EAClD,EAAM,SACN,QAAQ,MAAM,EAAM,MAAM,IAG9B,QAAQ,MAAM,sBAAsB,EAAM,EAG9C,QAAQ,KAAK,EAAE"}