semajsx 0.1.1 → 0.1.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.
Files changed (103) hide show
  1. package/dist/{computed-BpjqvQu1.mjs → computed-BidG06Lt.mjs} +2 -2
  2. package/dist/{computed-BpjqvQu1.mjs.map → computed-BidG06Lt.mjs.map} +1 -1
  3. package/dist/{document-OGuk9jhK.mjs → document-BOJDaiBc.mjs} +19 -4
  4. package/dist/document-BOJDaiBc.mjs.map +1 -0
  5. package/dist/{document-DFsOtfef.mjs → document-CwHVG_PJ.mjs} +2 -2
  6. package/dist/dom/index.d.mts +68 -3
  7. package/dist/dom/index.d.mts.map +1 -1
  8. package/dist/dom/index.mjs +4 -4
  9. package/dist/dom/jsx-dev-runtime.d.mts +4 -4
  10. package/dist/dom/jsx-dev-runtime.mjs +1 -1
  11. package/dist/dom/jsx-runtime.d.mts +4 -4
  12. package/dist/dom/jsx-runtime.mjs +2 -2
  13. package/dist/{helpers-DrifjCXb.d.mts → helpers-CfRDJgcP.d.mts} +3 -3
  14. package/dist/{helpers-DrifjCXb.d.mts.map → helpers-CfRDJgcP.d.mts.map} +1 -1
  15. package/dist/{index-DS5X3Pvb.d.mts → index-B1pjI-Su.d.mts} +2 -2
  16. package/dist/{index-DS5X3Pvb.d.mts.map → index-B1pjI-Su.d.mts.map} +1 -1
  17. package/dist/index-DC3tthWf.d.mts +81 -0
  18. package/dist/index-DC3tthWf.d.mts.map +1 -0
  19. package/dist/index.d.mts +7 -7
  20. package/dist/index.mjs +5 -5
  21. package/dist/{island-marker-hZdmHMvx.d.mts → island-marker-BJIO07Vj.d.mts} +1 -1
  22. package/dist/island-marker-BJIO07Vj.d.mts.map +1 -0
  23. package/dist/{jsx-CGW4OyqA.d.mts → jsx-fNlLjLou.d.mts} +2 -2
  24. package/dist/{jsx-CGW4OyqA.d.mts.map → jsx-fNlLjLou.d.mts.map} +1 -1
  25. package/dist/{jsx-runtime-DU8DRISG.d.mts → jsx-runtime-BFuFPDzn.d.mts} +3 -3
  26. package/dist/{jsx-runtime-DU8DRISG.d.mts.map → jsx-runtime-BFuFPDzn.d.mts.map} +1 -1
  27. package/dist/jsx-runtime-D9ZNjMJ2.mjs.map +1 -1
  28. package/dist/{jsx-runtime-mBpL8czJ.d.mts → jsx-runtime-DZx2Yv-t.d.mts} +28 -6
  29. package/dist/{jsx-runtime-mBpL8czJ.d.mts.map → jsx-runtime-DZx2Yv-t.d.mts.map} +1 -1
  30. package/dist/lucide-CVtHepGM.mjs +126 -0
  31. package/dist/lucide-CVtHepGM.mjs.map +1 -0
  32. package/dist/{resource-B1IudM8_.d.mts → resource-BQI6AeJ0.d.mts} +23 -3
  33. package/dist/resource-BQI6AeJ0.d.mts.map +1 -0
  34. package/dist/{resource-BjsDAkbG.mjs → resource-DSlXDZZi.mjs} +2 -2
  35. package/dist/{resource-BjsDAkbG.mjs.map → resource-DSlXDZZi.mjs.map} +1 -1
  36. package/dist/signal/index.d.mts +2 -2
  37. package/dist/signal/index.mjs +3 -3
  38. package/dist/{signal-4PgGfydw.mjs → signal-BN8vHXDb.mjs} +1 -1
  39. package/dist/{signal-4PgGfydw.mjs.map → signal-BN8vHXDb.mjs.map} +1 -1
  40. package/dist/{signal-CLsaPA7c.d.mts → signal-BwxUlXKs.d.mts} +1 -1
  41. package/dist/{signal-CLsaPA7c.d.mts.map → signal-BwxUlXKs.d.mts.map} +1 -1
  42. package/dist/{src-CRi0xsNK.mjs → src-BqX3sryB.mjs} +68 -5
  43. package/dist/src-BqX3sryB.mjs.map +1 -0
  44. package/dist/src-DR-EWgVP.mjs +868 -0
  45. package/dist/src-DR-EWgVP.mjs.map +1 -0
  46. package/dist/{src-DEoBG1zB.mjs → src-DUpFNNM_.mjs} +4 -4
  47. package/dist/{src-DEoBG1zB.mjs.map → src-DUpFNNM_.mjs.map} +1 -1
  48. package/dist/{src-BlS3Hc-L.mjs → src-DW3tIczg.mjs} +75 -5
  49. package/dist/src-DW3tIczg.mjs.map +1 -0
  50. package/dist/{src-Jbt_w0hc.mjs → src-Ds9vl42d.mjs} +37 -35
  51. package/dist/src-Ds9vl42d.mjs.map +1 -0
  52. package/dist/{src-iC-NFwTy.mjs → src-DuSN6go_.mjs} +79 -22
  53. package/dist/src-DuSN6go_.mjs.map +1 -0
  54. package/dist/ssg/index.d.mts +4 -182
  55. package/dist/ssg/index.d.mts.map +1 -1
  56. package/dist/ssg/index.mjs +7 -756
  57. package/dist/ssg/index.mjs.map +1 -1
  58. package/dist/ssg/plugins/docs-theme.d.mts +180 -0
  59. package/dist/ssg/plugins/docs-theme.d.mts.map +1 -0
  60. package/dist/ssg/plugins/docs-theme.mjs +2042 -0
  61. package/dist/ssg/plugins/docs-theme.mjs.map +1 -0
  62. package/dist/ssg/plugins/lucide.d.mts +3 -0
  63. package/dist/ssg/plugins/lucide.mjs +7 -0
  64. package/dist/ssr/client.d.mts +3 -3
  65. package/dist/ssr/client.mjs +5 -5
  66. package/dist/ssr/index.d.mts +3 -3
  67. package/dist/ssr/index.d.mts.map +1 -1
  68. package/dist/ssr/index.mjs +6 -5
  69. package/dist/style/index.d.mts +2 -2
  70. package/dist/style/index.d.mts.map +1 -1
  71. package/dist/style/index.mjs +1 -1
  72. package/dist/style/react.d.mts +2 -2
  73. package/dist/style/react.mjs +2 -2
  74. package/dist/style/vue.d.mts +2 -2
  75. package/dist/style/vue.mjs +2 -2
  76. package/dist/terminal/index.d.mts +4 -4
  77. package/dist/terminal/index.mjs +2 -2
  78. package/dist/terminal/jsx-dev-runtime.d.mts +4 -4
  79. package/dist/terminal/jsx-dev-runtime.mjs +1 -1
  80. package/dist/terminal/jsx-runtime.d.mts +4 -4
  81. package/dist/terminal/jsx-runtime.mjs +1 -1
  82. package/dist/{types-DlNR9ZaJ.d.mts → types-BlaUrkq0.d.mts} +2 -2
  83. package/dist/{types-DlNR9ZaJ.d.mts.map → types-BlaUrkq0.d.mts.map} +1 -1
  84. package/dist/types-CGkRxnQB.d.mts +220 -0
  85. package/dist/types-CGkRxnQB.d.mts.map +1 -0
  86. package/dist/{types-Dgj6n-EE.d.mts → types-CZMcXQTW.d.mts} +9 -4
  87. package/dist/types-CZMcXQTW.d.mts.map +1 -0
  88. package/dist/{types-Bjx1Pp14.d.mts → types-D0jRO840.d.mts} +1 -1
  89. package/dist/{types-Bjx1Pp14.d.mts.map → types-D0jRO840.d.mts.map} +1 -1
  90. package/dist/{types-DEi0apQO.d.mts → types-DucvOZQ2.d.mts} +2 -2
  91. package/dist/{types-DEi0apQO.d.mts.map → types-DucvOZQ2.d.mts.map} +1 -1
  92. package/dist/{utils-BrGmTgfG.mjs → utils-DbTAs943.mjs} +1 -1
  93. package/dist/{utils-BrGmTgfG.mjs.map → utils-DbTAs943.mjs.map} +1 -1
  94. package/package.json +30 -2
  95. package/dist/document-OGuk9jhK.mjs.map +0 -1
  96. package/dist/island-marker-hZdmHMvx.d.mts.map +0 -1
  97. package/dist/jsx-runtime-D2B2BK8X.mjs +0 -4
  98. package/dist/resource-B1IudM8_.d.mts.map +0 -1
  99. package/dist/src-BlS3Hc-L.mjs.map +0 -1
  100. package/dist/src-CRi0xsNK.mjs.map +0 -1
  101. package/dist/src-Jbt_w0hc.mjs.map +0 -1
  102. package/dist/src-iC-NFwTy.mjs.map +0 -1
  103. package/dist/types-Dgj6n-EE.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-DuSN6go_.mjs","names":["isPlainObject","logger","viteBuild"],"sources":["../../ssr/src/render.ts","../../ssr/src/lru-cache.ts","../../logger/src/logger.tsx","../../ssr/src/virtual-modules.ts","../../ssr/src/app.ts","../../ssr/src/vite-builder.ts","../../ssr/src/vite-router.ts","../../ssr/src/collector.ts"],"sourcesContent":["import type { JSXNode, VNode } from \"@semajsx/core\";\nimport type {\n IslandMetadata,\n IslandScriptTransformer,\n RenderToStringOptions,\n SSRResult,\n} from \"./shared/types\";\nimport { Fragment } from \"@semajsx/core\";\nimport { getIslandMetadata, isIslandVNode } from \"./client/island\";\nimport { STYLE_MARKER, LINK_MARKER, ASSET_MARKER } from \"./client/resource\";\nimport { isSignal, unwrap } from \"@semajsx/signal\";\nimport { isStyleToken } from \"@semajsx/style\";\n\n/**\n * Render context for collecting islands during traversal\n */\ninterface RenderContext {\n islands: IslandMetadata[];\n islandCounter: number;\n islandBasePath: string;\n // Whether to generate hydration markers (only when transformer is provided)\n enableHydration: boolean;\n // Cache for component render results to avoid duplicate rendering\n renderCache: WeakMap<VNode, string>;\n // Collected CSS file paths\n css: Set<string>;\n // Collected asset file paths\n assets: Set<string>;\n // Root directory for computing component keys\n rootDir: string;\n}\n\n/**\n * Render a VNode tree to an HTML string with island support\n *\n * @param vnode - The VNode tree to render\n * @param options - Rendering options\n * @returns SSR result with HTML and island metadata\n *\n * @example\n * ```tsx\n * // Static HTML only (no client-side scripts)\n * const result = renderToString(<App />)\n * console.log(result.html) // HTML string\n * console.log(result.islands) // Island metadata\n * console.log(result.scripts) // Empty string\n *\n * // With custom hydration scripts\n * const result = renderToString(<App />, {\n * transformIslandScript: (island) => {\n * return `<script type=\"module\" src=\"${island.basePath}/${island.id}.js\"></script>`\n * }\n * })\n * ```\n */\nexport async function renderToString(\n vnode: VNode,\n options: RenderToStringOptions = {},\n): Promise<SSRResult> {\n const { transformIslandScript, rootDir = process.cwd() } = options;\n\n // Fixed path for all static assets under /_semajsx/ namespace\n const islandBasePath = \"/_semajsx/islands\";\n\n // Create render context to collect islands during single traversal\n const context: RenderContext = {\n islands: [],\n islandCounter: 0,\n islandBasePath,\n // Only enable hydration markers when transformer is provided\n enableHydration: !!transformIslandScript,\n renderCache: new WeakMap(),\n css: new Set(),\n assets: new Set(),\n rootDir,\n };\n\n // Render HTML and collect islands in one pass (fixes duplicate rendering)\n const html = await renderVNodeToHTML(vnode, context);\n\n // Generate script tags for islands (only if transformer is provided)\n const scripts = generateIslandScripts(context.islands, islandBasePath, transformIslandScript);\n\n return {\n html,\n islands: context.islands,\n scripts,\n css: Array.from(context.css),\n assets: Array.from(context.assets),\n };\n}\n\n/**\n * Serialize props for island hydration\n */\nfunction serializeProps(props: any): Record<string, any> {\n if (!props || typeof props !== \"object\") {\n return {};\n }\n\n const serialized: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(props)) {\n // Skip children - they will be rendered separately\n if (key === \"children\" || key === \"key\" || key === \"ref\") {\n continue;\n }\n\n // Skip functions (event handlers, callbacks)\n if (typeof value === \"function\") {\n continue;\n }\n\n // Skip symbols\n if (typeof value === \"symbol\") {\n continue;\n }\n\n // Skip undefined\n if (value === undefined) {\n continue;\n }\n\n // Handle signals - serialize their current value\n if (isSignal(value)) {\n serialized[key] = unwrap(value);\n continue;\n }\n\n // Handle null, boolean, number, string\n if (\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\"\n ) {\n serialized[key] = value;\n continue;\n }\n\n // Handle arrays and plain objects\n if (Array.isArray(value) || isPlainObject(value)) {\n try {\n // Test if it's JSON-serializable\n JSON.stringify(value);\n serialized[key] = value;\n } catch (error) {\n console.warn(`Cannot serialize prop \"${key}\":`, error);\n }\n continue;\n }\n\n console.warn(`Skipping non-serializable prop \"${key}\" of type ${typeof value}`);\n }\n\n return serialized;\n}\n\n/**\n * Check if a value is an async iterator\n */\nfunction isAsyncIterator(value: any): value is AsyncIterableIterator<any> {\n return (\n value &&\n typeof value === \"object\" &&\n (typeof value[Symbol.asyncIterator] === \"function\" ||\n (typeof value.next === \"function\" && typeof value.return === \"function\"))\n );\n}\n\n/**\n * Render VNode to HTML string\n */\nasync function renderVNodeToHTML(vnode: VNode | JSXNode, context: RenderContext): Promise<string> {\n // Handle null/undefined\n if (vnode == null) {\n return \"\";\n }\n\n // Handle signals\n if (isSignal(vnode)) {\n return renderVNodeToHTML(unwrap(vnode), context);\n }\n\n // Handle primitives\n if (typeof vnode === \"string\" || typeof vnode === \"number\") {\n return escapeHTML(String(vnode));\n }\n\n if (typeof vnode === \"boolean\") {\n return \"\";\n }\n\n // Handle arrays\n if (Array.isArray(vnode)) {\n const results = await Promise.all(vnode.map((child) => renderVNodeToHTML(child, context)));\n return results.join(\"\");\n }\n\n // Must be a VNode at this point\n if (typeof vnode !== \"object\" || !(\"type\" in vnode)) {\n return \"\";\n }\n\n const vnodeTyped = vnode as VNode;\n\n // Handle text nodes\n if (vnodeTyped.type === \"#text\") {\n return escapeHTML(String(vnodeTyped.props?.nodeValue || \"\"));\n }\n\n // Handle signal nodes - unwrap and render the signal's value\n if (vnodeTyped.type === \"#signal\") {\n const signal = vnodeTyped.props?.signal;\n if (signal && isSignal<VNode>(signal)) {\n const unwrapped = unwrap(signal);\n const rendered = await renderVNodeToHTML(unwrapped, context);\n // If signal renders to empty content, use a comment marker for hydration\n // This ensures the client can find a DOM node to attach the signal subscription to\n return rendered || \"<!--signal-empty-->\";\n }\n return \"<!--signal-empty-->\";\n }\n\n // Handle islands - render content AND mark for hydration\n if (isIslandVNode(vnodeTyped)) {\n return renderIsland(vnodeTyped, context);\n }\n\n // Handle Style resource - collect CSS path, render nothing\n if (vnodeTyped.type === STYLE_MARKER) {\n const href = vnodeTyped.props?.href;\n if (href && typeof href === \"string\") {\n context.css.add(href);\n }\n return \"\";\n }\n\n // Handle Link resource - collect CSS path for stylesheets\n if (vnodeTyped.type === LINK_MARKER) {\n const href = vnodeTyped.props?.href;\n const rel = vnodeTyped.props?.rel;\n if (href && typeof href === \"string\" && rel === \"stylesheet\") {\n context.css.add(href);\n }\n return \"\";\n }\n\n // Handle Asset resource - collect asset path\n if (vnodeTyped.type === ASSET_MARKER) {\n const src = vnodeTyped.props?.src;\n if (src && typeof src === \"string\") {\n context.assets.add(src);\n }\n return \"\";\n }\n\n // Handle native nodes - serialize via outerHTML when available\n if (vnodeTyped.type === \"#native\") {\n const nativeNode = vnodeTyped.props?.__nativeNode;\n if (nativeNode && typeof (nativeNode as { outerHTML?: string }).outerHTML === \"string\") {\n return (nativeNode as { outerHTML: string }).outerHTML;\n }\n return \"\";\n }\n\n // Handle fragments\n if (vnodeTyped.type === Fragment) {\n const results = await Promise.all(\n vnodeTyped.children.map((child: JSXNode) => renderVNodeToHTML(child, context)),\n );\n return results.join(\"\");\n }\n\n // Handle function components\n if (typeof vnodeTyped.type === \"function\") {\n try {\n // Pass children to component as part of props\n const props =\n vnodeTyped.children && vnodeTyped.children.length > 0\n ? { ...vnodeTyped.props, children: vnodeTyped.children }\n : vnodeTyped.props || {};\n\n let result: any = vnodeTyped.type(props);\n\n // Handle async component - await the Promise\n if (result instanceof Promise) {\n result = await result;\n }\n\n // Handle async iterator - take only the first yield\n if (isAsyncIterator(result)) {\n const { value } = await result.next();\n result = value;\n }\n\n // Handle signal return - unwrap the value\n if (isSignal(result)) {\n result = unwrap(result);\n }\n\n return renderVNodeToHTML(result, context);\n } catch (error) {\n console.error(\"Error rendering component:\", error);\n // Return error fallback\n return renderErrorFallback(error, vnodeTyped);\n }\n }\n\n // Handle DOM elements\n if (typeof vnodeTyped.type === \"string\") {\n return renderElement(vnodeTyped, context);\n }\n\n return \"\";\n}\n\n/**\n * Check if a VNode result is a single DOM element (not Fragment, array, or primitive)\n */\nfunction isSingleElement(result: VNode | JSXNode): result is VNode {\n if (result == null || typeof result !== \"object\") {\n return false;\n }\n if (Array.isArray(result)) {\n return false;\n }\n if (!(\"type\" in result)) {\n return false;\n }\n const vnode = result as VNode;\n // Must be a string type (DOM element), not Fragment or function component\n return typeof vnode.type === \"string\";\n}\n\n/**\n * Generate a component key from path for use as identifier\n * Example: \"/home/user/project/src/components/Counter.tsx\" -> \"components/Counter\"\n */\nfunction getComponentKey(componentPath: string, rootDir: string): string {\n // Convert file:// URL to path\n let path = componentPath;\n if (path.startsWith(\"file://\")) {\n path = new URL(path).pathname;\n }\n\n // Make relative to root and remove src/ prefix\n if (path.startsWith(rootDir)) {\n path = path.slice(rootDir.length);\n }\n path = path.replace(/^\\/?(src\\/)?/, \"\");\n\n // Remove extension\n path = path.replace(/\\.\\w+$/, \"\");\n\n // Sanitize for use as attribute value\n path = path.replace(/[^a-zA-Z0-9/_-]/g, \"_\");\n\n return path;\n}\n\n/**\n * Inject island attributes into the first tag of rendered HTML\n */\nfunction injectIslandAttrs(\n html: string,\n islandId: string,\n componentKey: string,\n propsJson: string,\n): string {\n // Find the first > of the opening tag\n const firstTagEnd = html.indexOf(\">\");\n if (firstTagEnd === -1) {\n return html;\n }\n\n const escapedProps = escapeHTML(propsJson);\n const attrs = ` data-island-id=\"${islandId}\" data-island-src=\"${componentKey}\" data-island-props=\"${escapedProps}\"`;\n\n // Handle self-closing tags\n if (html[firstTagEnd - 1] === \"/\") {\n return html.slice(0, firstTagEnd - 1) + attrs + \" />\" + html.slice(firstTagEnd + 1);\n }\n\n return html.slice(0, firstTagEnd) + attrs + html.slice(firstTagEnd);\n}\n\n/**\n * Render an island component\n * - Renders the full HTML content on server (for SEO and no-JS users)\n * - If hydration disabled: renders as plain HTML (no markers)\n * - If hydration enabled: adds markers for client-side hydration\n */\nasync function renderIsland(vnode: VNode, context: RenderContext): Promise<string> {\n const metadata = getIslandMetadata(vnode);\n if (!metadata) {\n return \"\";\n }\n\n // Extract component name for better debugging\n const componentName =\n typeof metadata.component === \"function\" ? metadata.component.name || \"Anonymous\" : \"Unknown\";\n\n // Render the island's content on the server\n let content = \"\";\n let result: any;\n try {\n result = metadata.component(metadata.props || {});\n\n // Handle async component - await the Promise\n if (result instanceof Promise) {\n result = await result;\n }\n\n // Handle async iterator - take only the first yield\n if (isAsyncIterator(result)) {\n const { value } = await result.next();\n result = value;\n }\n\n // Handle signal return - unwrap the value\n if (isSignal(result)) {\n result = unwrap(result);\n }\n\n content = await renderVNodeToHTML(result, context);\n } catch (error) {\n console.error(`[SSR] Error rendering island (${componentName}):`, error);\n return renderErrorFallback(error, vnode);\n }\n\n // If hydration is disabled, just return the plain HTML\n if (!context.enableHydration) {\n return content;\n }\n\n // Generate unique island ID using component name\n const islandId = generateIslandId(componentName, context.islandCounter++);\n\n // Generate component key for grouping islands by component\n const componentKey = getComponentKey(metadata.modulePath, context.rootDir);\n\n // Serialize props for hydration\n const serializedProps = serializeProps(metadata.props);\n\n // Store island metadata\n const islandMetadata: IslandMetadata = {\n id: islandId,\n path: metadata.modulePath,\n props: serializedProps,\n componentName,\n };\n context.islands.push(islandMetadata);\n\n const propsJson = JSON.stringify(serializedProps);\n\n // Single DOM element: inject attrs directly (no wrapper div)\n if (isSingleElement(result)) {\n return injectIslandAttrs(content, islandId, componentKey, propsJson);\n }\n\n // Fragment or other: use comment markers + script tag\n // Use unique end marker to support nested islands\n return `<!--island:${islandId}-->${content}<!--/island:${islandId}--><script type=\"application/json\" data-island=\"${islandId}\" data-island-src=\"${componentKey}\">${propsJson}</script>`;\n}\n\n/**\n * Render a DOM element to HTML\n */\nasync function renderElement(vnode: VNode, context: RenderContext): Promise<string> {\n const tag = vnode.type as string;\n const props = vnode.props || {};\n\n // Handle dangerouslySetInnerHTML\n if (props.dangerouslySetInnerHTML?.__html != null) {\n const attrs = renderAttributes(props);\n return `<${tag}${attrs}>${props.dangerouslySetInnerHTML.__html}</${tag}>`;\n }\n\n // Self-closing tags\n const selfClosing = [\n \"area\",\n \"base\",\n \"br\",\n \"col\",\n \"embed\",\n \"hr\",\n \"img\",\n \"input\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n ];\n\n // Build attributes\n const attrs = renderAttributes(props);\n\n // Self-closing tag\n if (selfClosing.includes(tag)) {\n return `<${tag}${attrs} />`;\n }\n\n // Raw text elements: content must NOT be HTML-escaped\n if (tag === \"style\" || tag === \"script\") {\n const rawChildren = (vnode.children || []).map((child: JSXNode) => extractRawText(child));\n return `<${tag}${attrs}>${rawChildren.join(\"\")}</${tag}>`;\n }\n\n // Regular tag with children\n const childResults = await Promise.all(\n (vnode.children || []).map((child: JSXNode) => renderVNodeToHTML(child, context)),\n );\n const children = childResults.join(\"\");\n\n return `<${tag}${attrs}>${children}</${tag}>`;\n}\n\n/**\n * Extract raw text from a VNode without HTML escaping.\n * Used for <style> and <script> content.\n */\nfunction extractRawText(vnode: JSXNode): string {\n if (vnode == null || typeof vnode === \"boolean\") return \"\";\n if (typeof vnode === \"string\" || typeof vnode === \"number\") return String(vnode);\n if (Array.isArray(vnode)) return vnode.map(extractRawText).join(\"\");\n if (typeof vnode === \"object\" && \"type\" in vnode) {\n const v = vnode as VNode;\n if (v.type === \"#text\") return String(v.props?.nodeValue ?? \"\");\n if (v.type === \"#signal\") {\n const signal = v.props?.signal;\n if (signal && isSignal(signal)) return String(unwrap(signal));\n return \"\";\n }\n // Flatten children\n return (v.children || []).map(extractRawText).join(\"\");\n }\n return \"\";\n}\n\n/**\n * Resolve a class value to a string for SSR output.\n *\n * Handles strings, StyleToken objects, arrays, and falsy values.\n * Unlike the DOM version, this does NOT call inject() since CSS is\n * collected statically (via componentCSS) for SSG/SSR output.\n */\nfunction resolveClass(value: unknown): string {\n if (!value) {\n return \"\";\n }\n\n if (typeof value === \"string\") {\n return value;\n }\n\n if (isStyleToken(value)) {\n return value._ ?? \"\";\n }\n\n if (Array.isArray(value)) {\n return value.map(resolveClass).filter(Boolean).join(\" \");\n }\n\n return String(value);\n}\n\n/**\n * Render element attributes\n */\nfunction renderAttributes(props: Record<string, any>): string {\n const attrs: string[] = [];\n\n for (const [key, value] of Object.entries(props)) {\n // Skip special props\n if (key === \"children\" || key === \"key\" || key === \"ref\" || key === \"dangerouslySetInnerHTML\") {\n continue;\n }\n\n // Skip event handlers\n if (key.startsWith(\"on\")) {\n continue;\n }\n\n // Skip functions\n if (typeof value === \"function\") {\n continue;\n }\n\n // Skip null/undefined\n if (value == null) {\n continue;\n }\n\n // Handle signals\n let attrValue = value;\n if (isSignal(value)) {\n attrValue = unwrap(value);\n }\n\n // Boolean attributes\n if (typeof attrValue === \"boolean\") {\n if (attrValue) {\n attrs.push(key);\n }\n continue;\n }\n\n // Handle JSX -> HTML attribute name mapping\n const attrName =\n key === \"className\"\n ? \"class\"\n : key === \"htmlFor\"\n ? \"for\"\n : key === \"charSet\"\n ? \"charset\"\n : key === \"crossOrigin\"\n ? \"crossorigin\"\n : key === \"httpEquiv\"\n ? \"http-equiv\"\n : key;\n\n // Handle class/className — resolve arrays and StyleToken objects\n if (attrName === \"class\") {\n const resolved = resolveClass(attrValue);\n if (resolved) {\n attrs.push(`class=\"${escapeHTML(resolved)}\"`);\n }\n continue;\n }\n\n // Handle style object\n if (attrName === \"style\" && typeof attrValue === \"object\") {\n const styleStr = Object.entries(attrValue)\n .map(([k, v]) => `${camelToKebab(k)}: ${v}`)\n .join(\"; \");\n attrs.push(`style=\"${escapeHTML(styleStr)}\"`);\n continue;\n }\n\n // Regular attributes\n attrs.push(`${attrName}=\"${escapeHTML(String(attrValue))}\"`);\n }\n\n return attrs.length > 0 ? \" \" + attrs.join(\" \") : \"\";\n}\n\n/**\n * Generate script tags for loading islands\n *\n * If no transformer is provided, returns empty string (static HTML only).\n * If transformer is provided, calls it for each island to generate custom scripts.\n */\nfunction generateIslandScripts(\n islands: IslandMetadata[],\n basePath: string,\n transformer?: IslandScriptTransformer,\n): string {\n // No islands or no transformer = no scripts (static HTML only)\n if (islands.length === 0 || !transformer) {\n return \"\";\n }\n\n const scripts: string[] = [];\n\n for (const island of islands) {\n const script = transformer({\n id: island.id,\n path: island.path,\n props: island.props,\n componentName: island.componentName || \"Unknown\",\n basePath,\n });\n\n if (script) {\n scripts.push(script);\n }\n }\n\n return scripts.join(\"\\n\");\n}\n\n/**\n * Render error fallback\n */\nfunction renderErrorFallback(error: any, vnode?: VNode): string {\n const message = error?.message || String(error);\n const componentName = vnode && typeof vnode.type === \"function\" ? vnode.type.name : \"Unknown\";\n\n return `<div style=\"border: 2px solid red; padding: 10px; margin: 10px; background: #fee;\">\n <strong>Error rendering component: ${escapeHTML(componentName)}</strong>\n <pre>${escapeHTML(message)}</pre>\n </div>`;\n}\n\n/**\n * Generate a unique island ID from component name and counter\n * Examples: \"Counter-0\", \"todo-list-1\", \"my-component-2\"\n */\nfunction generateIslandId(componentName: string, counter: number): string {\n // Convert to kebab-case and sanitize for use as HTML attribute\n const kebabName = camelToKebab(componentName)\n .toLowerCase()\n // Remove leading dash if component name started with uppercase\n .replace(/^-/, \"\")\n // Replace any non-alphanumeric characters (except dash) with dash\n .replace(/[^a-z0-9-]/g, \"-\")\n // Remove consecutive dashes\n .replace(/-+/g, \"-\")\n // Remove trailing dashes\n .replace(/-$/, \"\");\n\n return `${kebabName}-${counter}`;\n}\n\n/**\n * Escape HTML special characters\n */\nfunction escapeHTML(str: string): string {\n return str\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#39;\");\n}\n\n/**\n * Convert camelCase to kebab-case\n */\nfunction camelToKebab(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n}\n\n/**\n * Check if a value is a plain object\n */\nfunction isPlainObject(value: any): boolean {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n","/**\n * Simple LRU (Least Recently Used) Cache\n * Prevents memory leaks by limiting cache size and evicting old entries\n */\n\nexport class LRUCache<K, V> {\n private cache = new Map<K, V>();\n private maxSize: number;\n\n constructor(maxSize: number = 1000) {\n this.maxSize = maxSize;\n }\n\n /**\n * Get a value from the cache\n * Moves the key to the end (marks as recently used)\n */\n get(key: K): V | undefined {\n const value = this.cache.get(key);\n\n if (value !== undefined) {\n // Move to end (most recently used)\n this.cache.delete(key);\n this.cache.set(key, value);\n }\n\n return value;\n }\n\n /**\n * Set a value in the cache\n * Evicts oldest entry if cache is full\n */\n set(key: K, value: V): void {\n // If key exists, delete it first so we can re-add at the end\n if (this.cache.has(key)) {\n this.cache.delete(key);\n }\n\n // Add to end (most recently used)\n this.cache.set(key, value);\n\n // Evict oldest if over capacity\n if (this.cache.size > this.maxSize) {\n // First key is the oldest (least recently used)\n const oldestKey = this.cache.keys().next().value;\n if (oldestKey !== undefined) {\n this.cache.delete(oldestKey);\n }\n }\n }\n\n /**\n * Check if key exists in cache\n */\n has(key: K): boolean {\n return this.cache.has(key);\n }\n\n /**\n * Delete a key from cache\n */\n delete(key: K): boolean {\n return this.cache.delete(key);\n }\n\n /**\n * Clear all entries\n */\n clear(): void {\n this.cache.clear();\n }\n\n /**\n * Get current cache size\n */\n get size(): number {\n return this.cache.size;\n }\n\n /**\n * Get all keys (for debugging)\n */\n keys(): IterableIterator<K> {\n return this.cache.keys();\n }\n\n /**\n * Get all values (for debugging)\n */\n values(): IterableIterator<V> {\n return this.cache.values();\n }\n}\n","/** @jsxImportSource @semajsx/terminal */\n\n/**\n * Logger - A rich terminal logging utility built on SemaJSX terminal\n *\n * Features:\n * - Beautiful visual styling with colors and icons\n * - Structured logging with tables and progress bars\n * - Grouping and indentation\n * - Performance timing\n * - Tag/label support\n * - JSX content support\n */\n\nimport type { VNode } from \"@semajsx/core\";\nimport { print } from \"@semajsx/terminal\";\nimport type {\n GroupOptions,\n LogData,\n LoggerOptions,\n LogLevel,\n LogLevelConfig,\n ProgressOptions,\n TableOptions,\n TimerResult,\n} from \"./types\";\n\n/**\n * Default log level configurations\n */\nconst DEFAULT_LEVEL_CONFIG: Record<LogLevel, LogLevelConfig> = {\n debug: { icon: \"?\", color: \"gray\", bold: false },\n info: { icon: \"i\", color: \"cyan\", bold: false },\n success: { icon: \"+\", color: \"green\", bold: true },\n warn: { icon: \"!\", color: \"yellow\", bold: true },\n error: { icon: \"x\", color: \"red\", bold: true, borderColor: \"red\" },\n};\n\n/**\n * Log level priorities (for filtering)\n */\nconst LEVEL_PRIORITY: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n success: 2,\n warn: 3,\n error: 4,\n};\n\n/**\n * Logger class\n */\nexport class Logger {\n private options: Required<Omit<LoggerOptions, \"levelConfig\" | \"timestampFormat\">> & {\n timestampFormat: () => string;\n levelConfig: Record<LogLevel, LogLevelConfig>;\n };\n private groupDepth = 0;\n private tags: string[] = [];\n private groupStack: Array<{\n title: string;\n color: string;\n bordered: boolean;\n }> = [];\n\n constructor(options: LoggerOptions = {}) {\n this.options = {\n timestamp: options.timestamp ?? true,\n timestampFormat: options.timestampFormat || (() => new Date().toLocaleTimeString()),\n showLevel: options.showLevel ?? true,\n minLevel: options.minLevel || \"debug\",\n prefix: options.prefix || \"\",\n stream: options.stream || process.stdout,\n bordered: options.bordered || false,\n levelConfig: this.mergeLevelConfig(options.levelConfig),\n };\n }\n\n /**\n * Merge custom level config with defaults\n */\n private mergeLevelConfig(\n custom?: Partial<Record<LogLevel, Partial<LogLevelConfig>>>,\n ): Record<LogLevel, LogLevelConfig> {\n if (!custom) return DEFAULT_LEVEL_CONFIG;\n\n const merged = { ...DEFAULT_LEVEL_CONFIG };\n for (const [level, config] of Object.entries(custom)) {\n merged[level as LogLevel] = {\n ...DEFAULT_LEVEL_CONFIG[level as LogLevel],\n ...config,\n };\n }\n return merged;\n }\n\n /**\n * Check if log level should be displayed\n */\n private shouldLog(level: LogLevel): boolean {\n return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[this.options.minLevel];\n }\n\n /**\n * Format log data to string\n */\n private formatData(data: LogData): string {\n if (typeof data === \"string\") {\n return data;\n }\n if (typeof data === \"object\" && \"type\" in data) {\n // It's a VNode, can't stringify\n return \"[JSX Content]\";\n }\n // Format JSON with newline before opening brace\n const json = JSON.stringify(data, null, 2);\n return \"\\n\" + json;\n }\n\n /**\n * Core log method\n */\n private log(level: LogLevel, data: LogData, ...args: LogData[]): void {\n if (!this.shouldLog(level)) return;\n\n const config = this.options.levelConfig[level];\n\n // Build log parts\n const parts: VNode[] = [];\n\n // Timestamp\n if (this.options.timestamp) {\n parts.push(\n <text dim marginRight={1}>\n [{this.options.timestampFormat()}]\n </text>,\n );\n }\n\n // Level with icon\n if (this.options.showLevel) {\n parts.push(\n <text color={config.color} bold={config.bold} marginRight={1}>\n {config.icon} {level.toUpperCase()}\n </text>,\n );\n }\n\n // Prefix\n if (this.options.prefix) {\n parts.push(\n <text marginRight={1} color=\"magenta\" bold>\n [{this.options.prefix}]\n </text>,\n );\n }\n\n // Tags\n if (this.tags.length > 0) {\n parts.push(\n <text marginRight={1} color=\"blue\">\n {this.tags.map((tag) => `#${tag}`).join(\" \")}\n </text>,\n );\n }\n\n // Main content\n if (typeof data === \"object\" && \"type\" in data) {\n // It's JSX - render it directly\n parts.push(data as VNode);\n } else {\n const content = this.formatData(data);\n parts.push(<text>{content}</text>);\n }\n\n // Additional arguments\n if (args.length > 0) {\n for (const arg of args) {\n const formatted = this.formatData(arg);\n parts.push(\n <text marginLeft={1} dim>\n {formatted}\n </text>,\n );\n }\n }\n\n // Render the log\n const logContent = <box flexDirection=\"row\">{parts}</box>;\n\n if (this.options.bordered && config.borderColor) {\n print(\n <box border=\"round\" borderColor={config.borderColor} paddingInline={1}>\n {logContent}\n </box>,\n { stream: this.options.stream },\n );\n } else {\n print(logContent, { stream: this.options.stream });\n }\n }\n\n /**\n * Debug log\n */\n debug(data: LogData, ...args: LogData[]): this {\n this.log(\"debug\", data, ...args);\n return this;\n }\n\n /**\n * Info log\n */\n info(data: LogData, ...args: LogData[]): this {\n this.log(\"info\", data, ...args);\n return this;\n }\n\n /**\n * Success log\n */\n success(data: LogData, ...args: LogData[]): this {\n this.log(\"success\", data, ...args);\n return this;\n }\n\n /**\n * Warning log\n */\n warn(data: LogData, ...args: LogData[]): this {\n this.log(\"warn\", data, ...args);\n return this;\n }\n\n /**\n * Error log\n */\n error(data: LogData, ...args: LogData[]): this {\n this.log(\"error\", data, ...args);\n return this;\n }\n\n /**\n * Start a log group\n */\n group(title: string, options: GroupOptions = {}): this {\n const { bordered = false, borderColor = \"cyan\" } = options;\n\n // Store group info for groupEnd\n this.groupStack.push({ title, color: borderColor, bordered });\n\n if (bordered) {\n // Bordered style - box with title\n print(\n <box border=\"round\" borderColor={borderColor} paddingInline={1}>\n <text bold color={borderColor}>\n {title}\n </text>\n </box>,\n { stream: this.options.stream },\n );\n } else {\n // Default style - title with underline\n print(\n <box flexDirection=\"column\">\n <text bold color={borderColor}>\n {title}\n </text>\n <text color={borderColor} dim>\n {\"─\".repeat(Math.min(title.length, 50))}\n </text>\n </box>,\n { stream: this.options.stream },\n );\n }\n\n this.groupDepth++;\n return this;\n }\n\n /**\n * End a log group\n */\n groupEnd(): this {\n if (this.groupDepth > 0) {\n this.groupDepth--;\n\n // Pop group info and draw closing line (only for non-bordered groups)\n const groupInfo = this.groupStack.pop();\n if (groupInfo && !groupInfo.bordered) {\n print(\n <text color={groupInfo.color} dim>\n {\"─\".repeat(Math.min(groupInfo.title.length, 50))}\n </text>,\n { stream: this.options.stream },\n );\n }\n }\n return this;\n }\n\n /**\n * Add tags to subsequent logs\n */\n withTags(...tags: string[]): Logger {\n const newLogger = new Logger(this.options);\n newLogger.groupDepth = this.groupDepth;\n newLogger.tags = [...this.tags, ...tags];\n newLogger.groupStack = [...this.groupStack];\n return newLogger;\n }\n\n /**\n * Create a child logger with a prefix\n */\n child(prefix: string): Logger {\n return new Logger({\n ...this.options,\n prefix: this.options.prefix ? `${this.options.prefix}:${prefix}` : prefix,\n });\n }\n\n /**\n * Log a table\n */\n table(data: Record<string, unknown>[], options: TableOptions = {}): this {\n const { headers, border = \"single\", borderColor = \"cyan\", headerSeparator = true } = options;\n\n if (data.length === 0) {\n this.info(\"Empty table\");\n return this;\n }\n\n // Get headers from first row if not provided\n const cols = headers || Object.keys(data[0] || {});\n\n const rows: VNode[] = [];\n\n // Header row\n if (headerSeparator) {\n const headerRow = (\n <box flexDirection=\"row\">\n {cols.map((col) => (\n <text bold color={borderColor} width={20}>\n {col}\n </text>\n ))}\n </box>\n );\n rows.push(headerRow);\n\n // Separator\n rows.push(<text dim>{\"-\".repeat(cols.length * 20)}</text>);\n }\n\n // Data rows\n for (const row of data) {\n const dataRow = (\n <box flexDirection=\"row\">\n {cols.map((col) => (\n <text width={20}>{String(row[col] ?? \"\")}</text>\n ))}\n </box>\n );\n rows.push(dataRow);\n }\n\n print(\n <box flexDirection=\"column\" border={border} borderColor={borderColor} paddingInline={1}>\n {rows}\n </box>,\n { stream: this.options.stream },\n );\n\n return this;\n }\n\n /**\n * Show a progress bar\n */\n progress(current: number, total: number, label?: string, options: ProgressOptions = {}): this {\n const {\n width = 40,\n char = \"█\",\n emptyChar = \"░\",\n showPercentage = true,\n color = \"green\",\n } = options;\n\n const percentage = Math.min(100, Math.max(0, (current / total) * 100));\n const filled = Math.floor((percentage / 100) * width);\n const empty = width - filled;\n\n const bar = char.repeat(filled) + emptyChar.repeat(empty);\n\n const content = (\n <box flexDirection=\"row\" alignItems=\"center\">\n {label && (\n <text marginRight={2} bold>\n {label}\n </text>\n )}\n <text color={color}>{bar}</text>\n {showPercentage && (\n <text marginLeft={2} bold color={color}>\n {percentage.toFixed(1)}%\n </text>\n )}\n <text marginLeft={2} dim>\n ({current}/{total})\n </text>\n </box>\n );\n\n print(content, { stream: this.options.stream });\n\n return this;\n }\n\n /**\n * Start a timer\n */\n time(label: string): TimerResult {\n const startTime = Date.now();\n\n return {\n end: (message?: string) => {\n const duration = Date.now() - startTime;\n this.info(\n <box flexDirection=\"row\">\n <text bold color=\"magenta\">\n ⏱ {label}\n </text>\n <text marginLeft={1}>took</text>\n <text marginLeft={1} bold color=\"cyan\">\n {duration}ms\n </text>\n {message && <text marginLeft={1}>- {message}</text>}\n </box>,\n );\n },\n elapsed: () => Date.now() - startTime,\n };\n }\n\n /**\n * Measure execution time of a function\n */\n async measure<T>(label: string, fn: () => T | Promise<T>): Promise<T> {\n const timer = this.time(label);\n try {\n const result = await fn();\n timer.end(\"✓ completed\");\n return result;\n } catch (error) {\n timer.end(\"✗ failed\");\n throw error;\n }\n }\n\n /**\n * Log a separator line\n */\n separator(char = \"─\", color = \"gray\"): this {\n print(<text color={color}>{char.repeat(80)}</text>, {\n stream: this.options.stream,\n });\n return this;\n }\n\n /**\n * Log a blank line\n */\n blank(): this {\n print(<text></text>, { stream: this.options.stream });\n return this;\n }\n\n /**\n * Raw JSX log (for custom content)\n */\n jsx(content: VNode): this {\n print(content, { stream: this.options.stream });\n return this;\n }\n}\n\n/**\n * Create a new logger instance\n */\nexport function createLogger(options: LoggerOptions = {}): Logger {\n return new Logger(options);\n}\n\n/**\n * Default logger instance\n */\nexport const logger: Logger = createLogger();\n","/**\n * Virtual modules plugin for Vite\n *\n * Allows build entries to be virtual (in-memory) instead of on disk.\n */\n\nimport { resolve, dirname } from \"path\";\nimport type { Plugin } from \"vite\";\n\nexport interface VirtualModulesOptions {\n [id: string]: string;\n}\n\n/**\n * Create a Vite plugin for virtual modules\n */\nexport function virtualModules(modules: VirtualModulesOptions): Plugin {\n // Map to store resolved paths (will be built in configResolved)\n const resolvedIds = new Map<string, string>();\n\n // Find module content by trying multiple id variations\n function find(id: string): string | undefined {\n return (\n modules[id] || modules[id.replace(/^\\//, \"\")] || modules[`/${id}`] || resolvedIds.get(id)\n );\n }\n\n let viteRoot = process.cwd();\n\n return {\n name: \"semajsx-virtual-modules\",\n enforce: \"pre\",\n\n configResolved(config) {\n viteRoot = config.root;\n\n // Build resolvedIds with the correct root\n Object.keys(modules).forEach((id) => {\n const resolved = resolve(viteRoot, id);\n resolvedIds.set(resolved, modules[id]!);\n });\n },\n\n resolveId(id, importer) {\n // Direct match or variations\n const content = find(id);\n if (content) {\n // Return resolved absolute path relative to Vite root\n return resolve(viteRoot, id);\n }\n\n // Try resolving relative imports from importer first\n if (importer) {\n const abs = resolve(dirname(importer), id);\n if (resolvedIds.has(abs)) {\n return abs;\n }\n }\n\n // For bare specifiers (not starting with /, ./, or ../),\n // try resolving against viteRoot\n if (!id.startsWith(\"/\") && !id.startsWith(\"./\") && !id.startsWith(\"../\")) {\n const absoluteId = resolve(viteRoot, id);\n if (modules[absoluteId] || resolvedIds.has(absoluteId)) {\n return absoluteId;\n }\n }\n\n return null;\n },\n\n load(id) {\n // First try direct find\n let content = find(id);\n if (content) {\n return content;\n }\n\n // Try finding by the resolved path\n if (resolvedIds.has(id)) {\n return resolvedIds.get(id);\n }\n\n return null;\n },\n };\n}\n","/**\n * App - Main entry point for SemaJSX server applications\n *\n * Provides a unified API for:\n * - Route management\n * - SSR rendering with islands\n * - Development server with Vite\n * - Production builds\n */\n\nimport { createServer, build as viteBuild, mergeConfig } from \"vite\";\nimport type { ViteDevServer, UserConfig as ViteUserConfig } from \"vite\";\nimport { resolve } from \"path\";\nimport { renderToString } from \"./render\";\nimport { renderDocument } from \"./document\";\nimport { LRUCache } from \"./lru-cache\";\nimport { createLogger } from \"@semajsx/logger\";\nimport { virtualModules } from \"./virtual-modules\";\nimport type {\n App,\n AppConfig,\n BuildOptions,\n BuildResult,\n BuildScriptEntry,\n DevOptions,\n IslandMetadata,\n RenderResult,\n RouteContext,\n RouteHandler,\n RouteMeta,\n} from \"./shared/types\";\n\nconst logger = createLogger({ prefix: \"App\" });\n\n/**\n * Internal App implementation\n */\nclass AppImpl implements App {\n readonly config: AppConfig;\n\n private _routes: Map<string, RouteHandler> = new Map();\n private _routeMeta: Map<string, RouteMeta> = new Map();\n private _viteServer: ViteDevServer | null = null;\n private _islandCache: LRUCache<string, IslandMetadata>;\n private _initialized = false;\n\n constructor(config: AppConfig = {}) {\n this.config = {\n root: process.cwd(),\n ...config,\n islands: {\n cache: true,\n cacheSize: 1000,\n ...config.islands,\n },\n };\n\n this._islandCache = new LRUCache(this.config.islands?.cacheSize ?? 1000);\n\n // Register initial routes\n if (config.routes) {\n this.routes(config.routes);\n }\n }\n\n route(path: string, handler: RouteHandler, meta?: RouteMeta): this {\n this._routes.set(path, handler);\n if (meta) {\n this._routeMeta.set(path, meta);\n }\n return this;\n }\n\n routes(routes: Record<string, RouteHandler>): this {\n for (const [path, handler] of Object.entries(routes)) {\n this._routes.set(path, handler);\n }\n return this;\n }\n\n async prepare(): Promise<void> {\n if (this._initialized) return;\n\n logger.info(\"Initializing app with Vite dev server...\");\n\n const baseViteConfig: ViteUserConfig = {\n root: this.config.root,\n server: {\n middlewareMode: true,\n },\n appType: \"custom\",\n optimizeDeps: {\n // Disable optimization for semajsx to use source directly in development\n exclude: [\n \"semajsx\",\n \"@semajsx/core\",\n \"@semajsx/dom\",\n \"@semajsx/signal\",\n \"@semajsx/ssr\",\n \"@semajsx/style\",\n \"@semajsx/ui\",\n ],\n },\n resolve: {\n // Ensure Vite respects package.json \"exports\" field with conditions\n conditions: [\"browser\", \"development\", \"module\", \"import\", \"default\"],\n // Add @ alias for project root\n alias: {\n \"@\": this.config.root || process.cwd(),\n },\n },\n plugins: [this._createVirtualIslandsPlugin()],\n // Exclude problematic native modules from SSR bundling\n ssr: {\n noExternal: [\n \"@semajsx/core\",\n \"@semajsx/dom\",\n \"@semajsx/signal\",\n \"@semajsx/style\",\n \"@semajsx/ui\",\n ],\n external: [\"lightningcss\", \"fsevents\"],\n },\n };\n\n // Merge user Vite config\n const finalConfig = this.config.vite\n ? mergeConfig(baseViteConfig, this.config.vite)\n : baseViteConfig;\n\n this._viteServer = await createServer(finalConfig);\n this._initialized = true;\n\n logger.info(\"App initialized successfully\");\n }\n\n async close(): Promise<void> {\n if (this._viteServer) {\n await this._viteServer.close();\n this._viteServer = null;\n }\n this._initialized = false;\n logger.info(\"App closed\");\n }\n\n async render(path: string): Promise<RenderResult> {\n // Parse path and query string\n const [pathname, queryString] = path.split(\"?\");\n const query: Record<string, string> = {};\n if (queryString) {\n const searchParams = new URLSearchParams(queryString);\n for (const [key, value] of searchParams) {\n query[key] = value;\n }\n }\n\n // Match route\n const { handler, params } = this._matchRoute(pathname || \"/\");\n if (!handler) {\n throw new Error(`No route found for path: ${path}`);\n }\n\n // Execute handler to get VNode\n const context: RouteContext = { params, query };\n const vnode = handler(context);\n\n // Render to string with island detection\n const result = await renderToString(vnode, {\n // Default transformer generates standard script tags\n transformIslandScript: (island) =>\n `<script type=\"module\" src=\"${island.basePath}/${island.id}.js\" async></script>`,\n rootDir: this.config.root,\n });\n\n // Cache islands\n if (this.config.islands?.cache) {\n for (const island of result.islands) {\n this._islandCache.set(island.id, island);\n }\n }\n\n // Render with document template if provided\n if (this.config.document) {\n const documentVNode = this.config.document({\n children: result.html,\n scripts: result.scripts,\n islands: result.islands,\n css: result.css,\n path,\n title: this.config.title,\n meta: this.config.meta,\n });\n\n return {\n ...result,\n document: renderDocument(documentVNode),\n };\n }\n\n return result;\n }\n\n async dev(options: DevOptions = {}): Promise<{ port: number; close: () => Promise<void> }> {\n const { port = 3000, host = \"localhost\", open = false } = options;\n\n await this.prepare();\n\n // Create HTTP server\n const server = Bun.serve({\n port,\n hostname: host,\n fetch: async (req) => this.handleRequest(req),\n });\n\n logger.info(`Development server running at http://${host}:${port}`);\n\n if (open) {\n // Open browser (platform-specific)\n const openCmd =\n process.platform === \"darwin\"\n ? \"open\"\n : process.platform === \"win32\"\n ? \"start\"\n : \"xdg-open\";\n Bun.spawn([openCmd, `http://${host}:${port}`]);\n }\n\n return {\n port,\n close: async () => {\n server.stop();\n await this.close();\n },\n };\n }\n\n async build(options: BuildOptions = {}): Promise<BuildResult> {\n const {\n outDir = \"dist\",\n mode = \"full\",\n minify = true,\n sourcemap = false,\n onIslandBuilt,\n renderHtml: customRenderHtml,\n } = options;\n\n logger.info(`Building for production (mode: ${mode})...`);\n\n const { mkdir } = await import(\"fs/promises\");\n // Ensure rootDir is always absolute\n const rootDir = this.config.root ? resolve(this.config.root) : process.cwd();\n\n // Ensure output directory exists\n await mkdir(outDir, { recursive: true });\n\n const builtIslands: BuildResult[\"islands\"] = [];\n const routes = Array.from(this._routes.keys());\n\n if (mode === \"full\") {\n // Phase 1: Pre-render all routes and collect resources\n const allIslands = new Map<string, IslandMetadata>();\n\n // Virtual modules (use simple file names as keys)\n const modules: Record<string, string> = {};\n const htmlInputs: Record<string, string> = {};\n\n // Render all routes\n for (const [path] of this._routes) {\n try {\n const result = await this.render(path);\n\n // Collect islands by component path (not by instance id)\n for (const island of result.islands) {\n const componentKey = this._getComponentKey(island.path, rootDir);\n if (!allIslands.has(componentKey)) {\n allIslands.set(componentKey, island);\n }\n }\n\n // Generate HTML with resource references\n const htmlFileName = path === \"/\" ? \"index.html\" : `${path.replace(/^\\//, \"\")}.html`;\n\n // CSS paths - use absolute paths that Vite can resolve\n const cssRefs = result.css;\n\n // Island script references - deduplicate by component path\n const seenComponents = new Set<string>();\n const islandScriptEntries: BuildScriptEntry[] = [];\n for (const island of result.islands) {\n const componentKey = this._getComponentKey(island.path, rootDir);\n if (!seenComponents.has(componentKey)) {\n seenComponents.add(componentKey);\n islandScriptEntries.push({ src: `/_semajsx/islands/${componentKey}.ts` });\n }\n }\n\n // Generate HTML\n const routeMeta = this._routeMeta.get(path);\n const pageTitle = routeMeta?.title ?? this.config.title ?? \"Page\";\n\n const html = customRenderHtml\n ? customRenderHtml({\n html: result.html,\n css: cssRefs,\n scripts: islandScriptEntries,\n title: pageTitle,\n path,\n })\n : `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${pageTitle}</title>\n ${cssRefs.map((href) => `<link rel=\"stylesheet\" href=\"${href}\">`).join(\"\\n \")}\n</head>\n<body>\n ${result.html}\n ${islandScriptEntries.map((s) => `<script type=\"module\" src=\"${s.src}\"></script>`).join(\"\\n \")}\n</body>\n</html>`;\n\n // Store virtual HTML with simple file name as key\n modules[htmlFileName] = html;\n htmlInputs[htmlFileName.replace(\".html\", \"\")] = htmlFileName;\n\n logger.debug(`Rendered ${path} -> ${htmlFileName} (virtual)`);\n } catch (error) {\n logger.warn(`Failed to pre-render route ${path}: ${String(error)}`);\n }\n }\n\n // Generate virtual island entry modules (one per component)\n for (const [componentKey, island] of allIslands) {\n let componentPath = island.path;\n if (componentPath.startsWith(\"file://\")) {\n componentPath = new URL(componentPath).pathname;\n }\n const componentName = island.componentName;\n\n const entryCode = `\nimport { hydrateAllIslands } from 'semajsx/ssr/client';\nimport * as ComponentModule from '${componentPath}';\n\nconst Component = ${componentName ? `ComponentModule['${componentName}'] || ComponentModule.${componentName}` : \"ComponentModule.default\"} ||\n Object.values(ComponentModule).find(exp => typeof exp === 'function');\n\nif (Component) {\n hydrateAllIslands('${componentKey}', Component);\n}\n`;\n\n // Store virtual island entry with component key\n modules[`_semajsx/islands/${componentKey}.ts`] = entryCode;\n }\n\n logger.info(\n `Phase 1 complete: ${Object.keys(htmlInputs).length} pages, ${allIslands.size} islands`,\n );\n\n // Phase 2: Vite build with virtual modules\n const userViteConfig = this.config.vite || {};\n const viteConfig: ViteUserConfig = {\n ...userViteConfig,\n root: rootDir,\n base: \"/\",\n // Merge plugins - our virtual modules plugin must be included\n plugins: [virtualModules(modules), ...(userViteConfig.plugins || [])],\n build: {\n ...userViteConfig.build,\n outDir: resolve(outDir),\n emptyOutDir: true,\n minify,\n sourcemap,\n rollupOptions: {\n ...userViteConfig.build?.rollupOptions,\n input: htmlInputs,\n },\n },\n };\n\n // Apply options.vite if provided\n const finalConfig = options.vite ? mergeConfig(viteConfig, options.vite) : viteConfig;\n\n await viteBuild(finalConfig);\n\n logger.info(\"Phase 2 complete: Vite build finished\");\n\n // Record built islands\n for (const [componentKey, island] of allIslands) {\n const webPath = `/_semajsx/islands/${componentKey}.js`;\n\n builtIslands.push({\n id: componentKey,\n path: island.path,\n outputPath: webPath,\n });\n\n if (onIslandBuilt) {\n onIslandBuilt(island);\n }\n }\n }\n\n logger.info(`Build complete. Output: ${outDir}`);\n\n return {\n outDir,\n islands: builtIslands,\n routes,\n };\n }\n\n async handleRequest(request: Request): Promise<Response> {\n const url = new URL(request.url);\n const pathname = url.pathname;\n\n // Handle Vite module requests (/@fs/, /@vite/, /node_modules/, etc.)\n // This includes CSS files which Vite will process\n if (\n pathname.startsWith(\"/@\") ||\n pathname.startsWith(\"/node_modules/\") ||\n pathname.includes(\"@vite\") ||\n pathname.endsWith(\".css\")\n ) {\n const result = await this._handleModuleRequest(pathname);\n if (result) {\n const contentType = pathname.endsWith(\".css\") ? \"text/css\" : \"application/javascript\";\n return new Response(result.code, {\n headers: { \"Content-Type\": contentType },\n });\n }\n }\n\n // Handle island entry points (must be before source file handler)\n if (pathname.startsWith(\"/_semajsx/islands/\")) {\n const match = pathname.match(/\\/_semajsx\\/islands\\/(.+)\\.js/);\n if (match && match[1]) {\n const islandId = match[1];\n try {\n const code = await this.getIslandEntryPoint(islandId);\n return new Response(code, {\n headers: { \"Content-Type\": \"application/javascript\" },\n });\n } catch {\n return new Response(\"Island not found\", { status: 404 });\n }\n }\n }\n\n // Handle source file requests (.ts, .tsx, .js, .jsx)\n if (/\\.(tsx?|jsx?)$/.test(pathname)) {\n const result = await this._handleModuleRequest(pathname);\n if (result) {\n return new Response(result.code, {\n headers: { \"Content-Type\": \"application/javascript\" },\n });\n }\n return new Response(\"Not Found\", { status: 404 });\n }\n\n // Handle page requests\n try {\n const result = await this.render(pathname);\n return new Response(result.document || result.html, {\n headers: { \"Content-Type\": \"text/html; charset=utf-8\" },\n });\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"No route found\")) {\n return new Response(\"Not Found\", { status: 404 });\n }\n logger.error(`Request error: ${String(error)}`);\n return new Response(\"Internal Server Error\", { status: 500 });\n }\n }\n\n getViteServer(): ViteDevServer | null {\n return this._viteServer;\n }\n\n async getIslandEntryPoint(islandId: string): Promise<string> {\n const island = this._islandCache.get(islandId);\n if (!island) {\n throw new Error(`Island not found: ${islandId}`);\n }\n\n // Normalize the component path for Vite\n const componentPath = this._normalizeModulePath(island.path);\n\n // Get component name for import\n const componentName = island.componentName;\n\n // Generate entry point code\n const entryCode = `\nimport { hydrateIsland } from 'semajsx/ssr/client';\nimport { markIslandHydrated } from 'semajsx/ssr/client';\nimport * as ComponentModule from '${componentPath}';\n\n// Get the component (try named export first, then default, then first function)\nconst Component = ${componentName ? `ComponentModule['${componentName}'] || ComponentModule.${componentName} || ` : \"\"}ComponentModule.default ||\n Object.values(ComponentModule).find(exp => typeof exp === 'function');\n\nif (Component) {\n hydrateIsland('${islandId}', Component, markIslandHydrated);\n}\n`;\n\n // Transform through Vite if available\n if (this._viteServer) {\n const result = await this._viteServer.transformRequest(`virtual:island-entry:${islandId}`);\n if (result) {\n return result.code;\n }\n }\n\n return entryCode;\n }\n\n getIsland(islandId: string): IslandMetadata | undefined {\n return this._islandCache.get(islandId);\n }\n\n // Private methods\n\n private _matchRoute(path: string): {\n handler: RouteHandler | undefined;\n params: Record<string, string>;\n } {\n // Exact match first\n const exactHandler = this._routes.get(path);\n if (exactHandler) {\n return { handler: exactHandler, params: {} };\n }\n\n // Dynamic route matching\n for (const [pattern, handler] of this._routes) {\n const params = this._matchDynamicRoute(pattern, path);\n if (params) {\n return { handler, params };\n }\n }\n\n return { handler: undefined, params: {} };\n }\n\n private _matchDynamicRoute(pattern: string, path: string): Record<string, string> | null {\n const patternParts = pattern.split(\"/\").filter(Boolean);\n const pathParts = path.split(\"/\").filter(Boolean);\n\n if (patternParts.length !== pathParts.length) {\n return null;\n }\n\n const params: Record<string, string> = {};\n\n for (let i = 0; i < patternParts.length; i++) {\n const patternPart = patternParts[i]!;\n const pathPart = pathParts[i]!;\n\n if (patternPart.startsWith(\":\")) {\n params[patternPart.slice(1)] = pathPart;\n } else if (patternPart !== pathPart) {\n return null;\n }\n }\n\n return params;\n }\n\n /**\n * Normalize module path (convert file:// URLs to paths Vite can resolve)\n */\n private _normalizeModulePath(path: string): string {\n if (path.startsWith(\"file://\")) {\n // Convert file:// URL to filesystem path\n const fsPath = new URL(path).pathname;\n\n // Make path relative to app root\n const root = this.config.root || process.cwd();\n if (root && fsPath.startsWith(root)) {\n // Path is within root, make it relative\n const relativePath = fsPath.slice(root.length);\n // Ensure it starts with / for Vite to resolve from root\n return relativePath.startsWith(\"/\") ? relativePath : `/${relativePath}`;\n }\n\n // Path is outside root, use @fs protocol\n return `/@fs${fsPath}`;\n }\n return path;\n }\n\n private async _handleModuleRequest(url: string): Promise<{ code: string } | null> {\n if (!this._viteServer) return null;\n\n try {\n const result = await this._viteServer.transformRequest(url);\n if (result) {\n return { code: result.code };\n }\n } catch (error) {\n logger.error(`Failed to transform module ${url}: ${String(error)}`);\n }\n\n return null;\n }\n\n /**\n * Generate a component key from path for use as file name\n * Example: \"/home/user/project/src/components/Counter.tsx\" -> \"components/Counter\"\n */\n private _getComponentKey(componentPath: string, rootDir: string): string {\n // Convert file:// URL to path\n let path = componentPath;\n if (path.startsWith(\"file://\")) {\n path = new URL(path).pathname;\n }\n\n // Make relative to root and remove src/ prefix\n if (path.startsWith(rootDir)) {\n path = path.slice(rootDir.length);\n }\n path = path.replace(/^\\/?(src\\/)?/, \"\");\n\n // Remove extension\n path = path.replace(/\\.\\w+$/, \"\");\n\n // Sanitize for use as file name (replace problematic chars)\n path = path.replace(/[^a-zA-Z0-9/_-]/g, \"_\");\n\n return path;\n }\n\n private _createVirtualIslandsPlugin() {\n const islandCache = this._islandCache;\n const normalizeModulePath = this._normalizeModulePath.bind(this);\n\n return {\n name: \"semajsx-virtual-islands\",\n resolveId(id: string) {\n if (id.startsWith(\"virtual:island-entry:\")) {\n return id;\n }\n return null;\n },\n load(id: string) {\n if (id.startsWith(\"virtual:island-entry:\")) {\n const islandId = id.replace(\"virtual:island-entry:\", \"\");\n const island = islandCache.get(islandId);\n\n if (!island) {\n return null;\n }\n\n const componentPath = normalizeModulePath(island.path);\n const componentName = island.componentName;\n\n return `\nimport { hydrateIsland } from 'semajsx/ssr/client';\nimport { markIslandHydrated } from 'semajsx/ssr/client';\nimport * as ComponentModule from '${componentPath}';\n\n// Get the component (try named export first, then default, then first function)\nconst Component = ${componentName ? `ComponentModule['${componentName}'] || ComponentModule.${componentName}` : \"ComponentModule.default\"} ||\n Object.values(ComponentModule).find(exp => typeof exp === 'function');\n\nif (Component) {\n hydrateIsland('${islandId}', Component, markIslandHydrated);\n}\n`;\n }\n return null;\n },\n };\n }\n}\n\n/**\n * Create a new SemaJSX app\n */\nexport function createApp(config?: AppConfig): App {\n return new AppImpl(config);\n}\n","import type { IslandMetadata } from \"./shared/types\";\nimport { createServer, type ViteDevServer, type PluginOption } from \"vite\";\nimport { logger } from \"@semajsx/logger\";\n\n/**\n * Vite-based island builder\n * Uses Vite dev server for module transformation instead of bundling\n */\nexport class ViteIslandBuilder {\n private vite: ViteDevServer | null = null;\n private entryPoints = new Map<string, string>();\n private options: ViteBuilderOptions;\n\n constructor(options: ViteBuilderOptions = {}) {\n this.options = {\n dev: options.dev ?? true,\n root: options.root ?? process.cwd(),\n };\n }\n\n /**\n * Initialize Vite dev server\n */\n async initialize(): Promise<void> {\n if (this.vite || !this.options.dev) {\n return;\n }\n\n // Build plugins array\n const plugins: PluginOption[] = [\n // Virtual islands plugin\n {\n name: \"semajsx-virtual-islands\",\n resolveId(id: string) {\n if (id.startsWith(\"virtual:island-\")) {\n return \"\\0\" + id;\n }\n },\n load: (id: string) => {\n if (id.startsWith(\"\\0virtual:island-\")) {\n const islandId = id.replace(\"\\0virtual:island-\", \"\").replace(\".js\", \"\");\n return this.entryPoints.get(islandId);\n }\n },\n },\n ];\n\n // Add custom plugins\n if (this.options.plugins) {\n plugins.push(...this.options.plugins);\n }\n\n this.vite = await createServer({\n root: this.options.root,\n server: {\n middlewareMode: true,\n hmr: false, // Disable HMR for simplicity\n },\n appType: \"custom\",\n resolve: {\n // Ensure Vite respects package.json \"exports\" field with conditions\n // \"browser\" condition provides noop island() to avoid loading server code in browser\n // \"development\" condition will resolve to source files (.ts)\n // \"import\" condition will resolve to dist files (.js) when installed as npm package\n conditions: [\"browser\", \"development\", \"module\", \"import\", \"default\"],\n },\n optimizeDeps: {\n // Disable optimization for semajsx to use source directly in development\n exclude: [\"semajsx\", \"@semajsx/dom\", \"@semajsx/signal\"],\n },\n plugins,\n });\n\n logger.success(\"Vite dev server initialized\");\n }\n\n /**\n * Get or generate island entry point code (transformed by Vite)\n */\n async getEntryPoint(island: IslandMetadata): Promise<string> {\n // Generate raw entry point code\n const rawCode = this.generateEntryPoint(island);\n\n // Store raw code for the plugin to access\n this.entryPoints.set(island.id, rawCode);\n\n // If Vite is available, transform the code to resolve bare imports\n if (this.vite) {\n try {\n // Use virtual module ID\n const virtualId = `virtual:island-${island.id}.js`;\n\n // Transform through Vite (which will use our plugin)\n const result = await this.vite.transformRequest(virtualId);\n if (result) {\n return result.code;\n }\n } catch (error) {\n logger.warn(\n `Could not transform entry for ${island.id}:`,\n error as Record<string, unknown>,\n );\n }\n }\n\n // Fallback: return raw code\n return rawCode;\n }\n\n /**\n * Transform a module URL using Vite\n */\n async transformModule(url: string): Promise<{ code: string } | null> {\n if (!this.vite) {\n throw new Error(\"Vite server not initialized\");\n }\n\n try {\n const result = await this.vite.transformRequest(url);\n return result\n ? {\n code: result.code,\n }\n : null;\n } catch (error) {\n logger.error(`Error transforming ${url}:`, error as Record<string, unknown>);\n return null;\n }\n }\n\n /**\n * Generate entry point for island (with imports, no bundling)\n * Uses hydration instead of rendering to preserve server-rendered HTML\n */\n private generateEntryPoint(island: IslandMetadata): string {\n const propsJson = JSON.stringify(island.props);\n const componentName = island.componentName;\n\n // Normalize component path\n const componentPath = this.normalizeModulePath(island.path);\n\n // Generate code that imports dependencies (Vite will resolve them)\n // Use hydrate() instead of render() to preserve server-rendered content\n const displayName = componentName || island.id;\n return `\n// Island hydration entry point: ${displayName}\nimport { hydrate, markIslandHydrated } from 'semajsx/ssr/client';\nimport * as ComponentModule from '${componentPath}';\n\n// Get the component\n// Try to find by name first (most reliable), then fall back to default or first function\nconst Component = ${componentName ? `ComponentModule['${componentName}'] || ComponentModule.${componentName}` : \"ComponentModule.default\"} ||\n Object.values(ComponentModule).find(exp => typeof exp === 'function');\n\nif (!Component) {\n console.error('[${displayName}] No component found in module ${componentPath}');\n} else {\n // Props from server\n const props = ${propsJson};\n\n // Find the placeholder element\n const placeholder = document.querySelector('[data-island-id=\"${island.id}\"]');\n\n if (!placeholder) {\n console.error('[${displayName}] Placeholder not found');\n } else {\n try {\n // Create VNode\n const vnode = Component(props);\n\n // Hydrate (attach interactivity to server-rendered content)\n hydrate(vnode, placeholder);\n\n // Mark island as hydrated for progressive enhancement\n markIslandHydrated('${island.id}');\n\n console.log('[${displayName}] Hydrated successfully');\n } catch (error) {\n console.error('[${displayName}] Hydration error:', error);\n }\n }\n}\n`.trim();\n }\n\n /**\n * Normalize module path (convert file:// URLs to paths relative to Vite root)\n */\n private normalizeModulePath(path: string): string {\n if (path.startsWith(\"file://\")) {\n // Convert file:// URL to filesystem path\n const fsPath = new URL(path).pathname;\n\n // Make path relative to Vite root\n const root = this.options.root || process.cwd();\n if (root && fsPath.startsWith(root)) {\n // Path is within root, make it relative\n const relativePath = fsPath.slice(root.length);\n // Ensure it starts with / for Vite to resolve from root\n return relativePath.startsWith(\"/\") ? relativePath : `/${relativePath}`;\n }\n\n // Path is outside root, use @fs protocol\n return `/@fs${fsPath}`;\n }\n return path;\n }\n\n /**\n * Close Vite server\n */\n async close(): Promise<void> {\n if (this.vite) {\n await this.vite.close();\n this.vite = null;\n }\n }\n\n /**\n * Get Vite dev server instance (for middleware integration)\n */\n getViteServer(): ViteDevServer | null {\n return this.vite;\n }\n}\n\n/**\n * Vite builder options\n */\nexport interface ViteBuilderOptions {\n /** Enable dev mode (uses Vite dev server) */\n dev?: boolean;\n /** Project root directory */\n root?: string;\n /** Additional Vite plugins */\n plugins?: PluginOption[];\n}\n\n/**\n * Create a new Vite island builder\n */\nexport async function createViteIslandBuilder(\n options?: ViteBuilderOptions,\n): Promise<ViteIslandBuilder> {\n const builder = new ViteIslandBuilder(options);\n await builder.initialize();\n return builder;\n}\n","import type {\n RouteContext,\n RouteHandler,\n RouterConfig,\n SSRResult,\n IslandMetadata,\n DocumentTemplate,\n} from \"./shared/types\";\nimport { renderToString } from \"./render\";\nimport { createViteIslandBuilder, type ViteIslandBuilder } from \"./vite-builder\";\nimport type { ViteDevServer } from \"vite\";\nimport { LRUCache } from \"./lru-cache\";\n\n/**\n * Route matcher result\n */\ninterface RouteMatch {\n handler: RouteHandler;\n params: Record<string, string>;\n}\n\n/**\n * Internal router configuration with required base fields\n */\ninterface InternalRouterConfig {\n enableCache: boolean;\n dev: boolean;\n root: string;\n buildOptions: { minify: boolean; sourcemap: boolean };\n document?: DocumentTemplate;\n title?: string;\n meta?: Record<string, any>;\n}\n\n/**\n * Vite-powered SSR Router with island support\n * Uses Vite dev server for module transformation in dev mode\n */\nexport class ViteRouter {\n private routeMap: Map<string, RouteHandler> = new Map();\n private dynamicRoutes: Array<{ pattern: RegExp; handler: RouteHandler }> = [];\n private builder: ViteIslandBuilder | null = null;\n private config: InternalRouterConfig;\n // Use LRU cache to prevent memory leaks from unbounded island storage\n private islandsCache: LRUCache<string, IslandMetadata>;\n private initialized = false;\n\n constructor(config: RouterConfig = {}) {\n this.config = {\n enableCache: config.enableCache ?? true,\n dev: config.dev ?? true,\n root: config.root ?? process.cwd(),\n buildOptions: {\n minify: config.buildOptions?.minify ?? true,\n sourcemap: config.buildOptions?.sourcemap ?? false,\n },\n document: config.document,\n title: config.title,\n meta: config.meta,\n };\n\n // Initialize LRU cache with configurable max size\n // Default: 1000 islands (should be enough for most apps)\n const cacheSize = (config as any).islandCacheSize ?? 1000;\n this.islandsCache = new LRUCache<string, IslandMetadata>(cacheSize);\n }\n\n /**\n * Initialize the router (async because Vite setup is async)\n */\n async initialize(): Promise<void> {\n if (this.initialized) return;\n\n if (this.config.dev) {\n this.builder = await createViteIslandBuilder({\n dev: true,\n root: this.config.root,\n });\n }\n\n this.initialized = true;\n }\n\n /**\n * Register a static route\n */\n route(path: string, handler: RouteHandler): this {\n if (path.includes(\":\")) {\n // Dynamic route\n const pattern = this.pathToRegex(path);\n this.dynamicRoutes.push({ pattern, handler });\n } else {\n // Static route\n this.routeMap.set(path, handler);\n }\n return this;\n }\n\n /**\n * Register multiple routes at once\n */\n routes(routes: Record<string, RouteHandler>): this {\n for (const [path, handler] of Object.entries(routes)) {\n this.route(path, handler);\n }\n return this;\n }\n\n /**\n * Get page content for a given path (lazy rendering)\n */\n async get(path: string): Promise<SSRResult> {\n await this.initialize();\n\n // Parse path and query string\n const [pathname, queryString] = path.split(\"?\");\n const query: Record<string, string> = {};\n if (queryString) {\n const searchParams = new URLSearchParams(queryString);\n for (const [key, value] of searchParams) {\n query[key] = value;\n }\n }\n\n // Find matching route\n const match = this.matchRoute(pathname || \"/\");\n if (!match) {\n throw new Error(`Route not found: ${path}`);\n }\n\n // Call the route handler to get VNode\n const context: RouteContext = { params: match.params, query };\n const vnode = match.handler(context);\n\n // Render to HTML with islands\n const result = await renderToString(vnode, {\n // Default transformer generates standard script tags\n transformIslandScript: (island) =>\n `<script type=\"module\" src=\"${island.basePath}/${island.id}.js\" async></script>`,\n });\n\n // Store islands in LRU cache for later code retrieval\n // Old islands will be automatically evicted when cache is full\n for (const island of result.islands) {\n this.islandsCache.set(island.id, island);\n }\n\n // If document template is provided, render complete HTML document\n if (this.config.document) {\n const { renderDocument } = await import(\"./document\");\n\n const documentVNode = this.config.document({\n // Wrap HTML strings in VNodes with dangerouslySetInnerHTML for raw HTML injection\n children: {\n type: \"template\",\n props: { dangerouslySetInnerHTML: { __html: result.html } },\n children: [],\n },\n scripts: {\n type: \"template\",\n props: { dangerouslySetInnerHTML: { __html: result.scripts } },\n children: [],\n },\n islands: result.islands,\n css: result.css,\n path,\n title: this.config.title,\n meta: this.config.meta,\n });\n\n result.document = renderDocument(documentVNode);\n }\n\n return result;\n }\n\n /**\n * Get island client code\n * In dev mode, returns the entry point (Vite will transform it)\n * In prod mode, would return pre-built bundle\n */\n async getIslandEntryPoint(islandId: string): Promise<string> {\n await this.initialize();\n\n const island = this.islandsCache.get(islandId);\n if (!island) {\n throw new Error(`Island not found: ${islandId}`);\n }\n\n if (!this.builder) {\n throw new Error(\"Vite builder not initialized\");\n }\n\n return this.builder.getEntryPoint(island);\n }\n\n /**\n * Handle module transformation request\n * This is called when browser requests /@fs/... or /node_modules/...\n */\n async handleModuleRequest(url: string): Promise<{ code: string } | null> {\n await this.initialize();\n\n if (!this.builder) {\n throw new Error(\"Vite builder not initialized\");\n }\n\n return this.builder.transformModule(url);\n }\n\n /**\n * Get island metadata by ID\n */\n getIsland(islandId: string): IslandMetadata | undefined {\n return this.islandsCache.get(islandId);\n }\n\n /**\n * Get Vite dev server instance (for middleware integration)\n */\n getViteServer(): ViteDevServer | null {\n return this.builder?.getViteServer() ?? null;\n }\n\n /**\n * Close the router and cleanup resources\n */\n async close(): Promise<void> {\n if (this.builder) {\n await this.builder.close();\n }\n }\n\n /**\n * Match a path to a route handler\n */\n private matchRoute(path: string): RouteMatch | null {\n // Try static routes first\n const staticHandler = this.routeMap.get(path);\n if (staticHandler) {\n return { handler: staticHandler, params: {} };\n }\n\n // Try dynamic routes\n for (const { pattern, handler } of this.dynamicRoutes) {\n const match = path.match(pattern);\n if (match) {\n const params = this.extractParams(pattern, match);\n return { handler, params };\n }\n }\n\n return null;\n }\n\n /**\n * Convert path pattern to regex\n * Example: /blog/:id -> /^\\/blog\\/([^\\/]+)$/\n */\n private pathToRegex(path: string): RegExp {\n const pattern = path.replace(/\\//g, \"\\\\/\").replace(/:([^/]+)/g, \"(?<$1>[^\\\\/]+)\");\n return new RegExp(`^${pattern}$`);\n }\n\n /**\n * Extract params from regex match\n */\n private extractParams(_pattern: RegExp, match: RegExpMatchArray): Record<string, string> {\n return match.groups || {};\n }\n}\n\n/**\n * Create a new Vite-powered router\n */\nexport async function createViteRouter(\n routes?: Record<string, RouteHandler>,\n config?: RouterConfig,\n): Promise<ViteRouter> {\n const router = new ViteRouter(config);\n\n if (routes) {\n router.routes(routes);\n }\n\n // Initialize immediately\n await router.initialize();\n\n return router;\n}\n","import type { VNode } from \"@semajsx/core\";\nimport type { IslandMetadata } from \"./shared/types\";\nimport { isIslandVNode, getIslandMetadata } from \"./client/island\";\nimport { Fragment } from \"@semajsx/core\";\n\n/**\n * Island collector - traverses VNode tree and collects island metadata\n */\nexport class IslandCollector {\n private islands: IslandMetadata[] = [];\n private counter = 0;\n\n /**\n * Collect all islands from a VNode tree\n */\n collect(vnode: VNode): IslandMetadata[] {\n this.islands = [];\n this.counter = 0;\n this.traverse(vnode);\n return this.islands;\n }\n\n /**\n * Traverse VNode tree and collect islands\n */\n private traverse(vnode: VNode | null | undefined): void {\n if (!vnode) return;\n\n // Check if this VNode is an island\n if (isIslandVNode(vnode)) {\n const metadata = getIslandMetadata(vnode);\n if (metadata) {\n this.islands.push({\n id: `island-${this.counter++}`,\n path: metadata.modulePath,\n props: this.serializeProps(metadata.props),\n componentName: typeof vnode.type === \"function\" ? vnode.type.name : undefined,\n });\n }\n // Don't traverse into island children - they will be rendered on client\n return;\n }\n\n // Handle fragments\n if (vnode.type === Fragment) {\n for (const child of vnode.children) {\n this.traverse(child);\n }\n return;\n }\n\n // Handle function components - need to render them first\n if (typeof vnode.type === \"function\") {\n try {\n const result = vnode.type(vnode.props || {});\n // If result is a VNode, traverse it\n if (result && typeof result === \"object\" && \"type\" in result) {\n this.traverse(result as VNode);\n }\n } catch (error) {\n console.warn(\"Error rendering component during collection:\", error);\n }\n return;\n }\n\n // Traverse children\n if (vnode.children && Array.isArray(vnode.children)) {\n for (const child of vnode.children) {\n this.traverse(child);\n }\n }\n }\n\n /**\n * Serialize props for client-side hydration\n * Handles common types and warns about non-serializable values\n */\n private serializeProps(props: any): Record<string, any> {\n if (!props || typeof props !== \"object\") {\n return {};\n }\n\n const serialized: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(props)) {\n // Skip functions (event handlers, callbacks)\n if (typeof value === \"function\") {\n continue;\n }\n\n // Skip symbols\n if (typeof value === \"symbol\") {\n continue;\n }\n\n // Skip undefined\n if (value === undefined) {\n continue;\n }\n\n // Handle null, boolean, number, string\n if (\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\" ||\n typeof value === \"string\"\n ) {\n serialized[key] = value;\n continue;\n }\n\n // Handle arrays and plain objects\n if (Array.isArray(value) || isPlainObject(value)) {\n try {\n // Test if it's JSON-serializable\n JSON.stringify(value);\n serialized[key] = value;\n } catch (error) {\n console.warn(`Cannot serialize prop \"${key}\":`, error);\n }\n continue;\n }\n\n console.warn(`Skipping non-serializable prop \"${key}\" of type ${typeof value}`);\n }\n\n return serialized;\n }\n}\n\n/**\n * Check if a value is a plain object\n */\nfunction isPlainObject(value: any): boolean {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/**\n * Create a new island collector\n */\nexport function createIslandCollector(): IslandCollector {\n return new IslandCollector();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,eAAsB,eACpB,OACA,UAAiC,EAAE,EACf;CACpB,MAAM,EAAE,uBAAuB,UAAU,QAAQ,KAAK,KAAK;CAG3D,MAAM,iBAAiB;CAGvB,MAAM,UAAyB;EAC7B,SAAS,EAAE;EACX,eAAe;EACf;EAEA,iBAAiB,CAAC,CAAC;EACnB,6BAAa,IAAI,SAAS;EAC1B,qBAAK,IAAI,KAAK;EACd,wBAAQ,IAAI,KAAK;EACjB;EACD;CAGD,MAAM,OAAO,MAAM,kBAAkB,OAAO,QAAQ;CAGpD,MAAM,UAAU,sBAAsB,QAAQ,SAAS,gBAAgB,sBAAsB;AAE7F,QAAO;EACL;EACA,SAAS,QAAQ;EACjB;EACA,KAAK,MAAM,KAAK,QAAQ,IAAI;EAC5B,QAAQ,MAAM,KAAK,QAAQ,OAAO;EACnC;;;;;AAMH,SAAS,eAAe,OAAiC;AACvD,KAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO,EAAE;CAGX,MAAM,aAAkC,EAAE;AAE1C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;AAEhD,MAAI,QAAQ,cAAc,QAAQ,SAAS,QAAQ,MACjD;AAIF,MAAI,OAAO,UAAU,WACnB;AAIF,MAAI,OAAO,UAAU,SACnB;AAIF,MAAI,UAAU,OACZ;AAIF,MAAI,SAAS,MAAM,EAAE;AACnB,cAAW,OAAO,OAAO,MAAM;AAC/B;;AAIF,MACE,UAAU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MAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO,EAAE;EAGX,MAAM,aAAkC,EAAE;AAE1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,EAAE;AAEhD,OAAI,OAAO,UAAU,WACnB;AAIF,OAAI,OAAO,UAAU,SACnB;AAIF,OAAI,UAAU,OACZ;AAIF,OACE,UAAU,QACV,OAAO,UAAU,aACjB,OAAO,UAAU,YACjB,OAAO,UAAU,UACjB;AACA,eAAW,OAAO;AAClB;;AAIF,OAAI,MAAM,QAAQ,MAAM,IAAI,cAAc,MAAM,EAAE;AAChD,QAAI;AAEF,UAAK,UAAU,MAAM;AACrB,gBAAW,OAAO;aACX,OAAO;AACd,aAAQ,KAAK,0BAA0B,IAAI,KAAK,MAAM;;AAExD;;AAGF,WAAQ,KAAK,mCAAmC,IAAI,YAAY,OAAO,QAAQ;;AAGjF,SAAO;;;;;;AAOX,SAAS,cAAc,OAAqB;AAC1C,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC,QAAO;CAGT,MAAM,QAAQ,OAAO,eAAe,MAAM;AAC1C,QAAO,UAAU,OAAO,aAAa,UAAU;;;;;AAMjD,SAAgB,wBAAyC;AACvD,QAAO,IAAI,iBAAiB"}
@@ -1,187 +1,8 @@
1
- import { t as Component, u as VNode } from "../types-Dgj6n-EE.mjs";
1
+ import { d as VNode } from "../types-CZMcXQTW.mjs";
2
+ import { S as Watcher, _ as SSGPlugin, a as Collection, b as WatchCallback, c as CollectionSource, d as InferCollections, f as MDXConfig, g as SSGInstance, h as SSGConfig, i as ChangeSet, l as DocumentProps, m as RouteConfig, n as BuildResult, o as CollectionConfig, p as RawHTML, r as BuildState, s as CollectionEntry, t as BuildOptions, u as DocumentTemplate, v as SSGPluginConfig, x as WatchOptions, y as StaticPath } from "../types-CGkRxnQB.mjs";
2
3
  import { PluginOption } from "vite";
3
4
  import { z, z as z$1 } from "zod";
4
5
 
5
- //#region ../ssg/src/types.d.ts
6
- /**
7
- * Infer a registry type from an array of collections
8
- * Maps collection names to their data types
9
- */
10
- type InferCollections<T extends readonly Collection[]> = { [K in T[number] as K["name"]]: K extends Collection<infer D> ? D : unknown };
11
- interface CollectionEntry<T = unknown> {
12
- /** Unique identifier within the collection */
13
- id: string;
14
- /** URL-friendly slug */
15
- slug: string;
16
- /** Validated frontmatter data */
17
- data: T;
18
- /** Raw content body (markdown/mdx) */
19
- body: string;
20
- /** Render the content to JSX */
21
- render: () => Promise<{
22
- Content: () => VNode;
23
- }>;
24
- }
25
- interface ChangeSet<T = unknown> {
26
- /** Cursor for next incremental fetch */
27
- cursor: string;
28
- /** Newly added entries */
29
- added: CollectionEntry<T>[];
30
- /** Updated entries */
31
- updated: CollectionEntry<T>[];
32
- /** Deleted entry IDs */
33
- deleted: string[];
34
- }
35
- type WatchCallback<T = unknown> = (changes: ChangeSet<T>) => void;
36
- interface CollectionSource<T = unknown> {
37
- /** Unique identifier for this source */
38
- id: string;
39
- /** Get all entries from this source */
40
- getEntries(): Promise<CollectionEntry<T>[]>;
41
- /** Get a single entry by ID */
42
- getEntry(id: string): Promise<CollectionEntry<T> | null>;
43
- /** Watch for changes (optional) */
44
- watch?(callback: WatchCallback<T>): () => void;
45
- /** Get incremental changes since cursor (optional) */
46
- getChanges?(since: string): Promise<ChangeSet<T>>;
47
- }
48
- interface CollectionConfig<T extends z$1.ZodType = z$1.ZodType> {
49
- /** Collection name */
50
- name: string;
51
- /** Data source (returns raw entries, validated against schema later) */
52
- source: CollectionSource<unknown>;
53
- /** Zod schema for validation */
54
- schema: T;
55
- }
56
- interface Collection<T = unknown> {
57
- name: string;
58
- source: CollectionSource<unknown>;
59
- schema: z$1.ZodType;
60
- /** Type-only field for inference */
61
- _outputType?: T;
62
- }
63
- interface StaticPath<P = Record<string, string>> {
64
- params: P;
65
- props?: Record<string, unknown>;
66
- }
67
- interface RouteConfig<TRegistry extends Record<string, unknown> = Record<string, unknown>> {
68
- /** Route path pattern (e.g., '/blog/:slug') */
69
- path: string;
70
- /** Component to render */
71
- component: (props: Record<string, unknown>) => VNode;
72
- /** Static props for the route */
73
- props?: Record<string, unknown> | ((ssg: SSGInstance<TRegistry>) => Promise<Record<string, unknown>>);
74
- /** Generate static paths for dynamic routes */
75
- getStaticPaths?: (ssg: SSGInstance<TRegistry>) => Promise<StaticPath[]>;
76
- }
77
- interface MDXConfig {
78
- /** Remark plugins */
79
- remarkPlugins?: unknown[];
80
- /** Rehype plugins */
81
- rehypePlugins?: unknown[];
82
- /** Component mapping for MDX */
83
- components?: Record<string, Component>;
84
- }
85
- /**
86
- * Raw HTML VNode that can be used directly in JSX or converted to string
87
- */
88
- declare class RawHTML {
89
- readonly html: string;
90
- readonly type = "div";
91
- readonly props: {
92
- dangerouslySetInnerHTML: {
93
- __html: string;
94
- };
95
- };
96
- readonly children: never[];
97
- constructor(html: string);
98
- toString(): string;
99
- }
100
- interface DocumentProps {
101
- /** Rendered page content (VNode with toString) */
102
- children: RawHTML;
103
- /** Page title */
104
- title?: string;
105
- /** Base URL path */
106
- base: string;
107
- /** Route path */
108
- path: string;
109
- /** Route props */
110
- props: Record<string, unknown>;
111
- /** Script tags for islands (as RawHTML) */
112
- scripts?: RawHTML;
113
- /** CSS stylesheet paths */
114
- css?: string[];
115
- }
116
- type DocumentTemplate = (props: DocumentProps) => VNode;
117
- interface SSGConfig<TCollections extends readonly Collection[] = Collection[], TRegistry extends Record<string, unknown> = InferCollections<TCollections>> {
118
- /** Output directory for built files */
119
- outDir: string;
120
- /** Root directory for resolving relative paths (defaults to script location) */
121
- rootDir?: string;
122
- /** Base URL path */
123
- base?: string;
124
- /** Collections to include */
125
- collections?: TCollections;
126
- /** Route definitions */
127
- routes?: RouteConfig<TRegistry>[];
128
- /** MDX configuration */
129
- mdx?: MDXConfig;
130
- /** Custom document template */
131
- document?: DocumentTemplate;
132
- }
133
- interface BuildState {
134
- /** Cursor for each collection */
135
- cursors: Record<string, string>;
136
- /** Content hash for each page */
137
- pageHashes: Record<string, string>;
138
- /** Last build timestamp */
139
- timestamp: number;
140
- }
141
- interface BuildResult {
142
- /** New build state for incremental builds */
143
- state: BuildState;
144
- /** Paths that were built */
145
- paths: string[];
146
- /** Build statistics */
147
- stats: {
148
- added: number;
149
- updated: number;
150
- deleted: number;
151
- unchanged: number;
152
- };
153
- }
154
- interface BuildOptions {
155
- /** Enable incremental build */
156
- incremental?: boolean;
157
- /** Previous build state */
158
- state?: BuildState;
159
- /** Only build specific collections */
160
- collections?: string[];
161
- }
162
- interface WatchOptions {
163
- /** Callback when rebuild completes */
164
- onRebuild?: (result: BuildResult) => void;
165
- /** Callback on error */
166
- onError?: (error: Error) => void;
167
- }
168
- interface Watcher {
169
- /** Stop watching */
170
- close(): void;
171
- }
172
- interface SSGInstance<TRegistry extends Record<string, unknown> = Record<string, unknown>> {
173
- /** Get the root directory for resolving paths */
174
- getRootDir(): string;
175
- /** Get all entries from a collection */
176
- getCollection<K extends keyof TRegistry & string>(name: K): Promise<CollectionEntry<TRegistry[K]>[]>;
177
- /** Get a single entry from a collection */
178
- getEntry<K extends keyof TRegistry & string>(name: K, id: string): Promise<CollectionEntry<TRegistry[K]> | null>;
179
- /** Build the static site */
180
- build(options?: BuildOptions): Promise<BuildResult>;
181
- /** Watch for changes and rebuild */
182
- watch(options?: WatchOptions): Watcher;
183
- }
184
- //#endregion
185
6
  //#region ../ssg/src/ssg.d.ts
186
7
  /**
187
8
  * SSG (Static Site Generator) core class
@@ -189,6 +10,7 @@ interface SSGInstance<TRegistry extends Record<string, unknown> = Record<string,
189
10
  */
190
11
  declare class SSG<TRegistry extends Record<string, unknown> = Record<string, unknown>> implements SSGInstance<TRegistry> {
191
12
  private config;
13
+ private plugins;
192
14
  private rootDir;
193
15
  private collections;
194
16
  private entriesCache;
@@ -454,5 +276,5 @@ declare function createWebhookHandler(options: WebhookHandlerOptions): (req: Web
454
276
  */
455
277
  declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
456
278
  //#endregion
457
- export { BaseSource, type BuildOptions, type BuildResult, type BuildState, type ChangeSet, type Collection, type CollectionConfig, type CollectionEntry, type CollectionSource, CustomSource, type CustomSourceOptions, DefaultDocument, type DocumentProps, type DocumentTemplate, FileSource, type FileSourceOptions, type GitCommitSourceOptions, GitSource, type GitSourceOptions, type GitTagSourceOptions, type Heading, type InferCollections, type MDXCompileResult, type MDXConfig, MDXProcessor, RawHTML, RemoteSource, type RemoteSourceOptions, type RouteConfig, SSG, type SSGConfig, type SSGInstance, type StaticPath, type WatchCallback, type WatchOptions, type Watcher, type WebhookConfig, type WebhookHandlerOptions, type WebhookRequest, type WebhookResponse, createMDXProcessor, createSSG, createSource, createWebhookHandler, defineCollection, fileSource, gitSource, remoteSource, verifyWebhookSignature, z };
279
+ export { BaseSource, type BuildOptions, type BuildResult, type BuildState, type ChangeSet, type Collection, type CollectionConfig, type CollectionEntry, type CollectionSource, CustomSource, type CustomSourceOptions, DefaultDocument, type DocumentProps, type DocumentTemplate, FileSource, type FileSourceOptions, type GitCommitSourceOptions, GitSource, type GitSourceOptions, type GitTagSourceOptions, type Heading, type InferCollections, type MDXCompileResult, type MDXConfig, MDXProcessor, RawHTML, RemoteSource, type RemoteSourceOptions, type RouteConfig, SSG, type SSGConfig, type SSGInstance, type SSGPlugin, type SSGPluginConfig, type StaticPath, type WatchCallback, type WatchOptions, type Watcher, type WebhookConfig, type WebhookHandlerOptions, type WebhookRequest, type WebhookResponse, createMDXProcessor, createSSG, createSource, createWebhookHandler, defineCollection, fileSource, gitSource, remoteSource, verifyWebhookSignature, z };
458
280
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../ssg/src/types.ts","../../../ssg/src/ssg.ts","../../../ssg/src/document.tsx","../../../ssg/src/collection/index.ts","../../../ssg/src/sources/base.ts","../../../ssg/src/sources/types.ts","../../../ssg/src/sources/file.ts","../../../ssg/src/sources/git.ts","../../../ssg/src/sources/remote.ts","../../../ssg/src/sources/custom.ts","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AA,GAAQ,WAAA;;;;EAOpB,OAAA,CACE,OAAA,UACA,WAAA,GAAa,MAAA,oBACZ,OAAA,CAAQ,gBAAA;;;;UAkCH,eAAA;;;;UAgCA,eAAA;;;;UAuBA,OAAA;AAAA;;;AX3FV;iBWwGgB,kBAAA,CAAmB,MAAA,GAAS,WAAA,GAAY,YAAA;;;UCzHvC,qBAAA;;EAEf,GAAA,EAAK,WAAA;;EAEL,SAAA,IAAa,UAAA,UAAoB,MAAA,EAAQ,WAAA,YAAuB,OAAA;EZKtD;EYHV,OAAA,IAAW,KAAA,EAAO,KAAA;AAAA;AAAA,UAGH,cAAA;;EAEf,UAAA;;EAEA,IAAA;EZHyC;EYKzC,OAAA,EAAS,MAAA;AAAA;AAAA,UAGM,eAAA;EACf,MAAA;EACA,IAAA;AAAA;;;;iBAMc,oBAAA,CACd,OAAA,EAAS,qBAAA,IACP,GAAA,EAAK,cAAA,KAAmB,OAAA,CAAQ,eAAA;;AZXpC;;iBYwDgB,sBAAA,CACd,OAAA,UACA,SAAA,UACA,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../ssg/src/ssg.ts","../../../ssg/src/document.tsx","../../../ssg/src/collection/index.ts","../../../ssg/src/sources/base.ts","../../../ssg/src/sources/types.ts","../../../ssg/src/sources/file.ts","../../../ssg/src/sources/git.ts","../../../ssg/src/sources/remote.ts","../../../ssg/src/sources/custom.ts","../../../ssg/src/mdx/types.ts","../../../ssg/src/mdx/processor.ts","../../../ssg/src/watcher/webhook.ts"],"mappings":";;;;;;;;;;cA2Ha,GAAA,mBACO,MAAA,oBAA0B,MAAA,8BACjC,WAAA,CAAY,SAAA;EAAA,QACf,MAAA;EAAA,QACA,OAAA;EAAA,QACA,OAAA;EAAA,QACA,WAAA;EAAA,QACA,YAAA;EAAA,QACA,GAAA;EAAA,QACA,UAAA;EAER,WAAA,CAAY,MAAA,EAAQ,SAAA;EA2DpB,UAAA,CAAA;EAIA,aAAA,iBAAoC,SAAA,UAA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