semajsx 0.9.0 → 0.10.0

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.
@@ -85,6 +85,26 @@ declare namespace JSX {
85
85
  */
86
86
  box: BoxAttributes;
87
87
  /**
88
+ * Row component — shorthand for `<box flexDirection="row">`
89
+ *
90
+ * @example
91
+ * <row>
92
+ * <text color="green">✓ </text>
93
+ * <text>Task name</text>
94
+ * </row>
95
+ */
96
+ row: BoxAttributes;
97
+ /**
98
+ * Column component — shorthand for `<box flexDirection="column">`
99
+ *
100
+ * @example
101
+ * <column>
102
+ * <text>Line 1</text>
103
+ * <text>Line 2</text>
104
+ * </column>
105
+ */
106
+ column: BoxAttributes;
107
+ /**
88
108
  * Text component for displaying styled text
89
109
  *
90
110
  * Supports text styling:
@@ -109,4 +129,4 @@ declare namespace JSX {
109
129
  }
110
130
  //#endregion
111
131
  export { TextAttributes as i, JSX as n, TerminalAttributes as r, BoxAttributes as t };
112
- //# sourceMappingURL=jsx-runtime-tdaY-P9K.d.mts.map
132
+ //# sourceMappingURL=jsx-runtime-Cjjlh1kA.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime-tdaY-P9K.d.mts","names":[],"sources":["../../terminal/src/jsx-runtime.ts"],"mappings":";;;;;;;UAeU,sBAAA,SAA+B,aAAA;EAEvC,GAAA;EACA,QAAA,GAAW,OAAA;AAAA;;;;AAsBb;KAfY,kBAAA,GAAqB,WAAA,CAAY,sBAAA;;;;AA8B7C;;;;;AAKA;;;;;KApBY,aAAA,GAAgB,kBAAA;;;;;;;;;;;;;;KAehB,cAAA,GAAiB,kBAAA;;;;kBAKZ,GAAA;EAAA,KACH,OAAA,GAAU,KAAA;EAAA,KAEV,WAAA,SACF,iBAAA,KACJ,KAAA,UAAe,OAAA,MACf,KAAA,OAAY,GAAA,EAAK,YAAA,KAAiB,OAAA;EAAA,UAEvB,wBAAA;IACf,QAAA;EAAA;EAAA,UAGe,mBAAA;IACf,GAAA;EAAA;EAAA,UAGe,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6Bf,GAAA,EAAK,aAAA;;;;;;;;;;;;;;;;;;;;;IAsBL,IAAA,EAAM,cAAA;EAAA;AAAA"}
1
+ {"version":3,"file":"jsx-runtime-Cjjlh1kA.d.mts","names":[],"sources":["../../terminal/src/jsx-runtime.ts"],"mappings":";;;;;;;UAeU,sBAAA,SAA+B,aAAA;EAEvC,GAAA;EACA,QAAA,GAAW,OAAA;AAAA;;;;AAsBb;KAfY,kBAAA,GAAqB,WAAA,CAAY,sBAAA;;;;AA8B7C;;;;;AAKA;;;;;KApBY,aAAA,GAAgB,kBAAA;;;;;;;;;;;;;;KAehB,cAAA,GAAiB,kBAAA;;;;kBAKZ,GAAA;EAAA,KACH,OAAA,GAAU,KAAA;EAAA,KAEV,WAAA,SACF,iBAAA,KACJ,KAAA,UAAe,OAAA,MACf,KAAA,OAAY,GAAA,EAAK,YAAA,KAAiB,OAAA;EAAA,UAEvB,wBAAA;IACf,QAAA;EAAA;EAAA,UAGe,mBAAA;IACf,GAAA;EAAA;EAAA,UAGe,iBAAA;IAmDf;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAtBA,GAAA,EAAK,aAAA;;;;;;;;;;IAWL,GAAA,EAAK,aAAA;;;;;;;;;;IAWL,MAAA,EAAQ,aAAA;;;;;;;;;;;;;;;;;;;;;IAsBR,IAAA,EAAM,cAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime-kv_6vBiR.mjs","names":[],"sources":["../../terminal/src/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX automatic runtime for Terminal (production)\n * Use with: @jsxImportSource @semajsx/terminal\n */\n\nimport { Fragment } from \"@semajsx/core\";\nimport type { ComponentAPI, JSXNode, VNode, WithSignals } from \"@semajsx/core\";\nimport type { TerminalStyle } from \"./types\";\n\nexport { jsx, jsxs } from \"@semajsx/core\";\nexport { Fragment };\n\n/**\n * Base terminal element attributes (without Signal support)\n */\ninterface BaseTerminalAttributes extends TerminalStyle {\n // Special props\n key?: string | number;\n children?: JSXNode;\n}\n\n/**\n * Terminal element attributes with Signal support\n * All style properties can accept Signal values\n */\nexport type TerminalAttributes = WithSignals<BaseTerminalAttributes>;\n\n/**\n * Box element attributes\n * Used for layout containers with flexbox support\n *\n * All properties support both plain values and Signals:\n * - flexDirection, justifyContent, alignItems\n * - flexGrow, flexShrink, flexBasis\n * - width, height, minWidth, minHeight, maxWidth, maxHeight\n * - margin, marginLeft, marginRight, marginTop, marginBottom\n * - padding, paddingLeft, paddingRight, paddingTop, paddingBottom\n * - border, borderColor\n * - backgroundColor\n */\nexport type BoxAttributes = TerminalAttributes;\n\n/**\n * Text element attributes\n * Used for displaying styled text content\n *\n * All properties support both plain values and Signals:\n * - color: Text color\n * - bold: Bold text\n * - italic: Italic text\n * - underline: Underlined text\n * - strikethrough: Strikethrough text\n * - dim: Dimmed text\n * - Layout props: flexGrow, flexShrink, flexBasis, margin, etc.\n */\nexport type TextAttributes = TerminalAttributes;\n\n/**\n * JSX namespace for Terminal elements\n */\nexport namespace JSX {\n export type Element = VNode;\n\n export type ElementType =\n | keyof IntrinsicElements\n | ((props: any) => JSXNode)\n | ((props: any, ctx: ComponentAPI) => JSXNode);\n\n export interface ElementChildrenAttribute {\n children: {};\n }\n\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n\n export interface IntrinsicElements {\n /**\n * Box component for layout and containers\n *\n * Supports flexbox layout with Yoga:\n * - flexDirection: 'row' | 'column' | 'row-reverse' | 'column-reverse'\n * - justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around'\n * - alignItems: 'flex-start' | 'center' | 'flex-end' | 'stretch'\n *\n * Supports sizing:\n * - width, height: number | string (e.g., '50%')\n * - minWidth, minHeight, maxWidth, maxHeight: number\n *\n * Supports spacing:\n * - margin, marginLeft, marginRight, marginTop, marginBottom: number\n * - padding, paddingLeft, paddingRight, paddingTop, paddingBottom: number\n *\n * Supports borders:\n * - border: 'single' | 'double' | 'round' | 'bold' | 'none'\n * - borderColor: string (color name or hex)\n *\n * Supports background:\n * - backgroundColor: string (color name or hex)\n *\n * @example\n * <box border=\"round\" padding={1} borderColor=\"green\">\n * <text>Content</text>\n * </box>\n */\n box: BoxAttributes;\n\n /**\n * Text component for displaying styled text\n *\n * Supports text styling:\n * - color: string (color name or hex)\n * - bold: boolean\n * - italic: boolean\n * - underline: boolean\n * - strikethrough: boolean\n * - dim: boolean\n *\n * Supports layout from parent box:\n * - flexGrow, flexShrink, flexBasis\n * - margin, marginLeft, marginRight, marginTop, marginBottom\n *\n * @example\n * <text color=\"green\" bold>\n * Success message\n * </text>\n */\n text: TextAttributes;\n }\n}\n"],"mappings":""}
1
+ {"version":3,"file":"jsx-runtime-kv_6vBiR.mjs","names":[],"sources":["../../terminal/src/jsx-runtime.ts"],"sourcesContent":["/**\n * JSX automatic runtime for Terminal (production)\n * Use with: @jsxImportSource @semajsx/terminal\n */\n\nimport { Fragment } from \"@semajsx/core\";\nimport type { ComponentAPI, JSXNode, VNode, WithSignals } from \"@semajsx/core\";\nimport type { TerminalStyle } from \"./types\";\n\nexport { jsx, jsxs } from \"@semajsx/core\";\nexport { Fragment };\n\n/**\n * Base terminal element attributes (without Signal support)\n */\ninterface BaseTerminalAttributes extends TerminalStyle {\n // Special props\n key?: string | number;\n children?: JSXNode;\n}\n\n/**\n * Terminal element attributes with Signal support\n * All style properties can accept Signal values\n */\nexport type TerminalAttributes = WithSignals<BaseTerminalAttributes>;\n\n/**\n * Box element attributes\n * Used for layout containers with flexbox support\n *\n * All properties support both plain values and Signals:\n * - flexDirection, justifyContent, alignItems\n * - flexGrow, flexShrink, flexBasis\n * - width, height, minWidth, minHeight, maxWidth, maxHeight\n * - margin, marginLeft, marginRight, marginTop, marginBottom\n * - padding, paddingLeft, paddingRight, paddingTop, paddingBottom\n * - border, borderColor\n * - backgroundColor\n */\nexport type BoxAttributes = TerminalAttributes;\n\n/**\n * Text element attributes\n * Used for displaying styled text content\n *\n * All properties support both plain values and Signals:\n * - color: Text color\n * - bold: Bold text\n * - italic: Italic text\n * - underline: Underlined text\n * - strikethrough: Strikethrough text\n * - dim: Dimmed text\n * - Layout props: flexGrow, flexShrink, flexBasis, margin, etc.\n */\nexport type TextAttributes = TerminalAttributes;\n\n/**\n * JSX namespace for Terminal elements\n */\nexport namespace JSX {\n export type Element = VNode;\n\n export type ElementType =\n | keyof IntrinsicElements\n | ((props: any) => JSXNode)\n | ((props: any, ctx: ComponentAPI) => JSXNode);\n\n export interface ElementChildrenAttribute {\n children: {};\n }\n\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n\n export interface IntrinsicElements {\n /**\n * Box component for layout and containers\n *\n * Supports flexbox layout with Yoga:\n * - flexDirection: 'row' | 'column' | 'row-reverse' | 'column-reverse'\n * - justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around'\n * - alignItems: 'flex-start' | 'center' | 'flex-end' | 'stretch'\n *\n * Supports sizing:\n * - width, height: number | string (e.g., '50%')\n * - minWidth, minHeight, maxWidth, maxHeight: number\n *\n * Supports spacing:\n * - margin, marginLeft, marginRight, marginTop, marginBottom: number\n * - padding, paddingLeft, paddingRight, paddingTop, paddingBottom: number\n *\n * Supports borders:\n * - border: 'single' | 'double' | 'round' | 'bold' | 'none'\n * - borderColor: string (color name or hex)\n *\n * Supports background:\n * - backgroundColor: string (color name or hex)\n *\n * @example\n * <box border=\"round\" padding={1} borderColor=\"green\">\n * <text>Content</text>\n * </box>\n */\n box: BoxAttributes;\n\n /**\n * Row component — shorthand for `<box flexDirection=\"row\">`\n *\n * @example\n * <row>\n * <text color=\"green\">✓ </text>\n * <text>Task name</text>\n * </row>\n */\n row: BoxAttributes;\n\n /**\n * Column component — shorthand for `<box flexDirection=\"column\">`\n *\n * @example\n * <column>\n * <text>Line 1</text>\n * <text>Line 2</text>\n * </column>\n */\n column: BoxAttributes;\n\n /**\n * Text component for displaying styled text\n *\n * Supports text styling:\n * - color: string (color name or hex)\n * - bold: boolean\n * - italic: boolean\n * - underline: boolean\n * - strikethrough: boolean\n * - dim: boolean\n *\n * Supports layout from parent box:\n * - flexGrow, flexShrink, flexBasis\n * - margin, marginLeft, marginRight, marginTop, marginBottom\n *\n * @example\n * <text color=\"green\" bold>\n * Success message\n * </text>\n */\n text: TextAttributes;\n }\n}\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { a as jsxs, i as jsx } from "./src--YS4EvMz.mjs";
2
- import { s as createApp } from "./src-Mucdq4zw.mjs";
2
+ import { s as createApp } from "./src-CmmFUCQS.mjs";
3
3
  import { n as renderDocument } from "./document-Cfdhi7vG.mjs";
4
4
  import { dirname, join, relative, resolve } from "path";
5
5
  import { mkdir, readFile, rm, watch, writeFile } from "fs/promises";
@@ -849,4 +849,4 @@ function createSource(options) {
849
849
 
850
850
  //#endregion
851
851
  export { DefaultDocument as _, remoteSource as a, FileSource as c, defineCollection as d, SSG as f, RawHTML as g, createMDXProcessor as h, RemoteSource as i, fileSource as l, MDXProcessor as m, CustomSource as n, GitSource as o, createSSG as p, createSource as r, gitSource as s, z$1 as t, BaseSource as u };
852
- //# sourceMappingURL=src-BTG08Qnh.mjs.map
852
+ //# sourceMappingURL=src-BNQE-0cR.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"src-BTG08Qnh.mjs","names":["fsWatch"],"sources":["../../ssg/src/document.tsx","../../ssg/src/types.ts","../../ssg/src/mdx/processor.ts","../../ssg/src/mdx/vite-plugin.ts","../../ssg/src/ssg.ts","../../ssg/src/collection/index.ts","../../ssg/src/sources/base.ts","../../ssg/src/sources/file.ts","../../ssg/src/sources/git.ts","../../ssg/src/sources/remote.ts","../../ssg/src/sources/custom.ts"],"sourcesContent":["/** @jsxImportSource @semajsx/dom */\n\nimport type { DocumentTemplate } from \"./types\";\n\n/**\n * Default HTML document template for SSG\n */\nexport const DefaultDocument: DocumentTemplate = ({\n children,\n title = \"SSG Page\",\n scripts,\n css,\n styles,\n}) => (\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>{title}</title>\n {css?.map((href) => (\n <link rel=\"stylesheet\" href={href} />\n ))}\n {styles && styles.length > 0 && <style>{styles.join(\"\\n\")}</style>}\n </head>\n <body>\n {children}\n {scripts}\n </body>\n </html>\n);\n","import type { Component, VNode } from \"@semajsx/core\";\nimport type { z } from \"zod\";\n\n// =============================================================================\n// Collection Registry (for type inference)\n// =============================================================================\n\n/**\n * Infer a registry type from an array of collections\n * Maps collection names to their data types\n */\nexport type InferCollections<T extends readonly Collection[]> = {\n [K in T[number] as K[\"name\"]]: K extends Collection<infer D> ? D : unknown;\n};\n\n// =============================================================================\n// Collection Entry\n// =============================================================================\n\nexport interface CollectionEntry<T = unknown> {\n /** Unique identifier within the collection */\n id: string;\n /** URL-friendly slug */\n slug: string;\n /** Validated frontmatter data */\n data: T;\n /** Raw content body (markdown/mdx) */\n body: string;\n /** Render the content to JSX */\n render: () => Promise<{ Content: () => VNode }>;\n}\n\n// =============================================================================\n// Collection Source\n// =============================================================================\n\nexport interface ChangeSet<T = unknown> {\n /** Cursor for next incremental fetch */\n cursor: string;\n /** Newly added entries */\n added: CollectionEntry<T>[];\n /** Updated entries */\n updated: CollectionEntry<T>[];\n /** Deleted entry IDs */\n deleted: string[];\n}\n\nexport type WatchCallback<T = unknown> = (changes: ChangeSet<T>) => void;\n\nexport interface CollectionSource<T = unknown> {\n /** Unique identifier for this source */\n id: string;\n\n /** Get all entries from this source */\n getEntries(): Promise<CollectionEntry<T>[]>;\n\n /** Get a single entry by ID */\n getEntry(id: string): Promise<CollectionEntry<T> | null>;\n\n /** Watch for changes (optional) */\n watch?(callback: WatchCallback<T>): () => void;\n\n /** Get incremental changes since cursor (optional) */\n getChanges?(since: string): Promise<ChangeSet<T>>;\n}\n\n// =============================================================================\n// Collection Definition\n// =============================================================================\n\nexport interface CollectionConfig<T extends z.ZodType = z.ZodType> {\n /** Collection name */\n name: string;\n /** Data source (returns raw entries, validated against schema later) */\n source: CollectionSource<unknown>;\n /** Zod schema for validation */\n schema: T;\n}\n\nexport interface Collection<T = unknown> {\n name: string;\n source: CollectionSource<unknown>;\n schema: z.ZodType;\n /** Type-only field for inference */\n _outputType?: T;\n}\n\n// =============================================================================\n// Route Configuration\n// =============================================================================\n\nexport interface StaticPath<P = Record<string, string>> {\n params: P;\n props?: Record<string, unknown>;\n}\n\nexport interface RouteConfig<TRegistry extends Record<string, unknown> = Record<string, unknown>> {\n /** Route path pattern (e.g., '/blog/:slug') */\n path: string;\n /** Component to render. Props are provided dynamically by the route config. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Route props are dynamic, typed via `props`/`getStaticPaths`\n component: (props: any) => VNode;\n /** Static props for the route */\n props?:\n | Record<string, unknown>\n | ((ssg: SSGInstance<TRegistry>) => Promise<Record<string, unknown>>);\n /** Generate static paths for dynamic routes */\n getStaticPaths?: (ssg: SSGInstance<TRegistry>) => Promise<StaticPath[]>;\n}\n\n// =============================================================================\n// MDX Configuration\n// =============================================================================\n\nexport interface MDXConfig {\n /** Remark plugins */\n remarkPlugins?: unknown[];\n /** Rehype plugins */\n rehypePlugins?: unknown[];\n /** Component mapping for MDX */\n components?: Record<string, Component>;\n}\n\n// =============================================================================\n// Document Template\n// =============================================================================\n\n/**\n * Raw HTML VNode that can be used directly in JSX or converted to string\n */\nexport class RawHTML {\n public readonly type = \"div\";\n public readonly props: { dangerouslySetInnerHTML: { __html: string } };\n public readonly children: never[] = [];\n\n constructor(public readonly html: string) {\n this.props = { dangerouslySetInnerHTML: { __html: html } };\n }\n\n toString(): string {\n return this.html;\n }\n}\n\nexport interface DocumentProps {\n /** Rendered page content (VNode with toString) */\n children: RawHTML;\n /** Page title */\n title?: string;\n /** Base URL path */\n base: string;\n /** Route path */\n path: string;\n /** Route props */\n props: Record<string, unknown>;\n /** Script tags for islands (as RawHTML) */\n scripts?: RawHTML;\n /** CSS stylesheet paths */\n css?: string[];\n /** Inline CSS collected from StyleTokens */\n styles?: string[];\n}\n\nexport type DocumentTemplate = (props: DocumentProps) => VNode;\n\n// =============================================================================\n// Plugin System\n// =============================================================================\n\n/**\n * Partial SSG config that a plugin's config() hook can return.\n * Each field has a defined merge strategy:\n * - mdx: merge (concat arrays, merge component objects)\n * - document: override (last writer wins)\n * - routes: concat\n * - collections: concat\n */\nexport interface SSGPluginConfig {\n mdx?: Partial<MDXConfig>;\n document?: DocumentTemplate;\n routes?: RouteConfig[];\n collections?: readonly Collection[];\n}\n\nexport interface SSGPlugin {\n /** Plugin name for identification and debugging */\n name: string;\n\n /** Plugin ordering: 'pre' runs before normal plugins, 'post' runs after */\n enforce?: \"pre\" | \"post\";\n\n /**\n * Modify SSG config before it is resolved.\n * Return partial config to merge.\n * Called in plugin order: enforce:'pre' → normal → enforce:'post' → user config.\n */\n config?(config: SSGConfig): SSGPluginConfig | void;\n\n /** Called after config is fully resolved. Read-only inspection. */\n configResolved?(config: SSGConfig): void;\n\n /** Called before build starts */\n buildStart?(): void | Promise<void>;\n\n /** Called after build completes. Receives the SSG instance for post-build operations. */\n buildEnd?(result: BuildResult, ssg: SSGInstance): void | Promise<void>;\n}\n\n// =============================================================================\n// SSG Configuration\n// =============================================================================\n\nexport interface SSGConfig<\n TCollections extends readonly Collection[] = Collection[],\n TRegistry extends Record<string, unknown> = InferCollections<TCollections>,\n> {\n /** Output directory for built files */\n outDir: string;\n /** Root directory for resolving relative paths (defaults to script location) */\n rootDir?: string;\n /** Base URL path */\n base?: string;\n /** Collections to include */\n collections?: TCollections;\n /** Route definitions */\n routes?: RouteConfig<TRegistry>[];\n /** Plugins that contribute remark/rehype plugins and components.\n * Plugin factories may return arrays (Vite-style); nested arrays are flattened. */\n plugins?: (SSGPlugin | SSGPlugin[])[];\n /** MDX configuration (merged after plugins, takes precedence) */\n mdx?: MDXConfig;\n /** Custom document template */\n document?: DocumentTemplate;\n}\n\n// =============================================================================\n// Build State & Result\n// =============================================================================\n\nexport interface BuildState {\n /** Cursor for each collection */\n cursors: Record<string, string>;\n /** Content hash for each page */\n pageHashes: Record<string, string>;\n /** Last build timestamp */\n timestamp: number;\n}\n\nexport interface BuildResult {\n /** New build state for incremental builds */\n state: BuildState;\n /** Paths that were built */\n paths: string[];\n /** Build statistics */\n stats: {\n added: number;\n updated: number;\n deleted: number;\n unchanged: number;\n };\n}\n\nexport interface BuildOptions {\n /** Enable incremental build */\n incremental?: boolean;\n /** Previous build state */\n state?: BuildState;\n /** Only build specific collections */\n collections?: string[];\n}\n\n// =============================================================================\n// Watcher\n// =============================================================================\n\nexport interface WatchOptions {\n /** Callback when rebuild completes */\n onRebuild?: (result: BuildResult) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n}\n\nexport interface Watcher {\n /** Stop watching */\n close(): void;\n}\n\n// =============================================================================\n// SSG Instance\n// =============================================================================\n\nexport interface SSGInstance<TRegistry extends Record<string, unknown> = Record<string, unknown>> {\n /** Get the root directory for resolving paths */\n getRootDir(): string;\n\n /** Get all entries from a collection */\n getCollection<K extends keyof TRegistry & string>(\n name: K,\n ): Promise<CollectionEntry<TRegistry[K]>[]>;\n\n /** Get a single entry from a collection */\n getEntry<K extends keyof TRegistry & string>(\n name: K,\n id: string,\n ): Promise<CollectionEntry<TRegistry[K]> | null>;\n\n /** Build the static site */\n build(options?: BuildOptions): Promise<BuildResult>;\n\n /** Watch for changes and rebuild */\n watch(options?: WatchOptions): Watcher;\n}\n","import { compile } from \"@mdx-js/mdx\";\nimport type { Pluggable } from \"unified\";\nimport type { VNode } from \"@semajsx/core\";\nimport type { MDXConfig, MDXCompileResult, Heading } from \"./types\";\n\n/**\n * MDX Processor for compiling MDX content to JSX components\n */\nexport class MDXProcessor {\n private config: MDXConfig;\n\n constructor(config: MDXConfig = {}) {\n this.config = config;\n }\n\n /**\n * Compile MDX content to a JSX component\n */\n async compile(\n content: string,\n frontmatter: Record<string, unknown> = {},\n ): Promise<MDXCompileResult> {\n // Extract headings for table of contents\n const headings = this.extractHeadings(content);\n\n // Compile MDX to JavaScript\n const compiled = await compile(content, {\n outputFormat: \"function-body\",\n development: false,\n remarkPlugins: (this.config.remarkPlugins ?? []) as Pluggable[],\n rehypePlugins: (this.config.rehypePlugins ?? []) as Pluggable[],\n // Use SemaJSX runtime\n jsxImportSource: \"semajsx/dom\",\n });\n\n // Dynamic import of JSX runtime\n const jsxRuntime = await import(\"semajsx/dom/jsx-runtime\");\n\n // Create the Content component\n const Content = this.createComponent(\n String(compiled),\n this.config.components ?? {},\n jsxRuntime,\n );\n\n return {\n Content,\n frontmatter,\n headings,\n };\n }\n\n /**\n * Create a component from compiled MDX code\n */\n private createComponent(\n code: string,\n components: Record<string, (props: Record<string, unknown>) => VNode>,\n jsxRuntime: unknown,\n ): (props?: Record<string, unknown>) => VNode {\n // Import JSX runtime\n // This will be resolved at runtime\n return (props: Record<string, unknown> = {}) => {\n try {\n // Create a function from the MDX compiled code\n // MDX compiled code expects jsx runtime in arguments[0]\n // By using new Function() with no parameters, we can pass\n // the runtime via call() and it becomes arguments[0]\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n const fn = new Function(code + \"\\nreturn MDXContent;\");\n\n // Call with jsxRuntime as arguments[0]\n // MDX returns an object with default export\n const result = fn.call(null, jsxRuntime) as {\n default: (props: Record<string, unknown>) => VNode;\n };\n return result.default({ ...props, components });\n } catch (e) {\n // Fallback for when runtime is not available\n throw new Error(`MDX rendering failed: ${(e as Error).message}`);\n }\n };\n }\n\n /**\n * Extract headings from markdown content\n */\n private extractHeadings(content: string): Heading[] {\n const headings: Heading[] = [];\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n\n let match;\n while ((match = headingRegex.exec(content)) !== null) {\n const hashes = match[1];\n const rawText = match[2];\n if (!hashes || !rawText) continue;\n\n const depth = hashes.length;\n const text = rawText.trim();\n const slug = this.slugify(text);\n\n headings.push({ depth, text, slug });\n }\n\n return headings;\n }\n\n /**\n * Convert text to URL-friendly slug\n */\n private slugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\")\n .replace(/-+/g, \"-\")\n .trim();\n }\n}\n\n/**\n * Create an MDX processor instance\n */\nexport function createMDXProcessor(config?: MDXConfig): MDXProcessor {\n return new MDXProcessor(config);\n}\n","import { compile } from \"@mdx-js/mdx\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport type { Pluggable } from \"unified\";\n\n/**\n * MDX plugin options\n */\nexport interface MDXPluginOptions {\n /** Remark plugins */\n remarkPlugins?: unknown[];\n /** Rehype plugins */\n rehypePlugins?: unknown[];\n}\n\n/**\n * Vite plugin for MDX support\n * Transforms .mdx files to JSX modules\n */\nexport function viteMDXPlugin(options: MDXPluginOptions = {}): PluginOption {\n const plugin: Plugin = {\n name: \"semajsx-mdx\",\n\n async transform(code: string, id: string) {\n // Only transform .mdx files\n if (!id.endsWith(\".mdx\")) {\n return null;\n }\n\n try {\n // Compile MDX to JavaScript (not JSX)\n const compiled = await compile(code, {\n jsxImportSource: \"semajsx/dom\",\n outputFormat: \"program\",\n development: false,\n remarkPlugins: (options.remarkPlugins ?? []) as Pluggable[],\n rehypePlugins: (options.rehypePlugins ?? []) as Pluggable[],\n });\n\n return {\n code: String(compiled),\n map: null,\n };\n } catch (error) {\n const err = error as Error;\n throw new Error(`MDX compilation failed for ${id}: ${err.message}`);\n }\n },\n };\n\n return plugin;\n}\n","import { mkdir, writeFile, rm } from \"fs/promises\";\nimport { join, dirname, resolve } from \"path\";\nimport { createApp, renderDocument } from \"@semajsx/ssr\";\nimport type { App, RouteContext } from \"@semajsx/ssr\";\nimport { DefaultDocument } from \"./document\";\nimport type { VNode } from \"@semajsx/core\";\nimport {\n RawHTML,\n type SSGConfig,\n type SSGPlugin,\n type SSGInstance,\n type MDXConfig,\n type RouteConfig,\n type DocumentTemplate,\n type Collection,\n type CollectionEntry,\n type BuildOptions,\n type BuildResult,\n type BuildState,\n type WatchOptions,\n type Watcher,\n type DocumentProps,\n type InferCollections,\n} from \"./types\";\nimport { viteMDXPlugin } from \"./mdx\";\n\n/**\n * Sort plugins by enforce order: 'pre' → normal → 'post'\n */\nfunction sortPlugins(plugins: SSGPlugin[]): SSGPlugin[] {\n const pre: SSGPlugin[] = [];\n const normal: SSGPlugin[] = [];\n const post: SSGPlugin[] = [];\n\n for (const plugin of plugins) {\n if (plugin.enforce === \"pre\") pre.push(plugin);\n else if (plugin.enforce === \"post\") post.push(plugin);\n else normal.push(plugin);\n }\n\n return [...pre, ...normal, ...post];\n}\n\n/**\n * Merge a partial MDX config into an existing one.\n */\nfunction mergeMdxConfig(base: MDXConfig, partial: Partial<MDXConfig>): MDXConfig {\n return {\n remarkPlugins: [...(base.remarkPlugins ?? []), ...(partial.remarkPlugins ?? [])],\n rehypePlugins: [...(base.rehypePlugins ?? []), ...(partial.rehypePlugins ?? [])],\n components: { ...base.components, ...partial.components },\n };\n}\n\n/**\n * Resolved config produced by running all plugin config hooks.\n */\ninterface ResolvedPluginConfig {\n mdx: MDXConfig;\n document?: DocumentTemplate;\n routes: RouteConfig[];\n collections: Collection[];\n}\n\n/**\n * Result of plugin resolution: merged config + flat list of all plugins.\n */\ninterface PluginResolutionResult {\n config: ResolvedPluginConfig;\n allPlugins: SSGPlugin[];\n}\n\n/**\n * Run config hooks on all plugins, then merge with user config.\n *\n * Plugin arrays are flattened Vite-style: plugin factories may return\n * `SSGPlugin | SSGPlugin[]`, and the top-level array is `.flat()`-ed\n * before sorting and processing.\n *\n * Merge strategies:\n * - mdx: merge (concat arrays, merge component objects)\n * - document: override (last writer wins, user config last)\n * - routes: concat (plugin routes first, then user routes)\n * - collections: concat (plugin collections first, then user collections)\n */\nfunction resolvePlugins(\n plugins: (SSGPlugin | SSGPlugin[])[],\n config: SSGConfig,\n): PluginResolutionResult {\n // Vite-style: flatten nested arrays from plugin factories\n const flat = plugins.flat();\n const sorted = sortPlugins(flat);\n\n let mdx: MDXConfig = { remarkPlugins: [], rehypePlugins: [], components: {} };\n let document: DocumentTemplate | undefined;\n const routes: RouteConfig[] = [];\n const collections: Collection[] = [];\n\n // Call config hooks in order\n for (const plugin of sorted) {\n if (!plugin.config) continue;\n const partial = plugin.config(config);\n if (!partial) continue;\n\n if (partial.mdx) mdx = mergeMdxConfig(mdx, partial.mdx);\n if (partial.document) document = partial.document;\n if (partial.routes) routes.push(...partial.routes);\n if (partial.collections) collections.push(...partial.collections);\n }\n\n // User config takes precedence (applied last)\n if (config.mdx) mdx = mergeMdxConfig(mdx, config.mdx);\n if (config.document) document = config.document;\n if (config.routes) routes.push(...config.routes);\n if (config.collections) collections.push(...config.collections);\n\n return { config: { mdx, document, routes, collections }, allPlugins: sorted };\n}\n\n/**\n * SSG (Static Site Generator) core class\n * Built on top of server's createApp\n */\nexport class SSG<\n TRegistry extends Record<string, unknown> = Record<string, unknown>,\n> implements SSGInstance<TRegistry> {\n private config: SSGConfig;\n private plugins: SSGPlugin[];\n private rootDir: string;\n private collections: Map<string, Collection>;\n private entriesCache: Map<string, CollectionEntry[]>;\n private app: App;\n private mdxModules: Map<string, string> = new Map();\n\n constructor(config: SSGConfig) {\n // Resolve rootDir\n this.rootDir = config.rootDir ?? process.cwd();\n\n // Run config hooks — merges plugins + user config, collects all plugins (including nested)\n const { config: resolved, allPlugins } = resolvePlugins(config.plugins ?? [], config);\n\n // Store all plugins (including sub-plugins) for lifecycle hooks\n this.plugins = allPlugins;\n\n this.config = {\n base: \"/\",\n ...config,\n mdx: resolved.mdx,\n document: resolved.document,\n routes: resolved.routes,\n collections: resolved.collections,\n outDir: resolve(this.rootDir, config.outDir),\n };\n\n // Call configResolved on all plugins\n for (const plugin of this.plugins) {\n plugin.configResolved?.(this.config);\n }\n this.collections = new Map();\n this.entriesCache = new Map();\n\n // Create App with MDX plugins\n this.app = createApp({\n root: this.rootDir,\n vite: {\n plugins: [\n // Virtual MDX content modules\n {\n name: \"ssg-virtual-mdx\",\n resolveId: (id: string) => {\n if (id.startsWith(\"virtual:mdx:\")) {\n return \"\\0\" + id;\n }\n },\n load: (id: string) => {\n if (id.startsWith(\"\\0virtual:mdx:\")) {\n const mdxId = id.replace(\"\\0virtual:mdx:\", \"\");\n return this.mdxModules.get(mdxId);\n }\n },\n },\n // MDX compiler plugin\n viteMDXPlugin(resolved.mdx),\n ],\n },\n });\n\n // Register collections (from resolved config — plugins + user)\n for (const collection of this.config.collections ?? []) {\n this.collections.set(collection.name, collection);\n }\n }\n\n getRootDir(): string {\n return this.rootDir;\n }\n\n async getCollection<K extends keyof TRegistry & string>(\n name: K,\n ): Promise<CollectionEntry<TRegistry[K]>[]> {\n const collection = this.collections.get(name);\n if (!collection) {\n throw new Error(`Collection \"${name}\" not found`);\n }\n\n if (this.entriesCache.has(name)) {\n return this.entriesCache.get(name) as CollectionEntry<TRegistry[K]>[];\n }\n\n const entries = await collection.source.getEntries();\n\n const validatedEntries = entries.map((entry) => {\n const result = collection.schema.safeParse(entry.data);\n if (!result.success) {\n throw new Error(`Validation error in ${name}/${entry.id}: ${result.error.message}`);\n }\n\n return {\n ...entry,\n data: result.data,\n render: async () => {\n // Get Vite server from app\n const vite = this.app.getViteServer();\n if (!vite) {\n throw new Error(\"Vite server not initialized\");\n }\n\n // Store MDX content as virtual module\n const mdxId = `${name}/${entry.id}.mdx`;\n this.mdxModules.set(mdxId, entry.body);\n\n try {\n // Load module through Vite SSR\n const moduleExports = (await vite.ssrLoadModule(`virtual:mdx:${mdxId}`)) as {\n default: (props: Record<string, unknown>) => unknown;\n };\n\n const Content = (props: Record<string, unknown> = {}): VNode =>\n moduleExports.default({\n ...props,\n components: this.config.mdx?.components ?? {},\n }) as VNode;\n\n return {\n Content,\n headings: this.extractHeadings(entry.body),\n };\n } finally {\n this.mdxModules.delete(mdxId);\n }\n },\n };\n });\n\n this.entriesCache.set(name, validatedEntries);\n return validatedEntries as CollectionEntry<TRegistry[K]>[];\n }\n\n async getEntry<K extends keyof TRegistry & string>(\n name: K,\n id: string,\n ): Promise<CollectionEntry<TRegistry[K]> | null> {\n const entries = await this.getCollection(name);\n return entries.find((e) => e.id === id || e.slug === id) ?? null;\n }\n\n async build(options: BuildOptions = {}): Promise<BuildResult> {\n const { incremental = false, state: prevState } = options;\n const outDir = this.config.outDir;\n\n // Plugin hook: buildStart\n for (const plugin of this.plugins) {\n await plugin.buildStart?.();\n }\n\n // Initialize App (starts Vite)\n await this.app.prepare();\n\n try {\n // Register routes with App\n await this.registerRoutes();\n\n // Build all pages\n const result = await this.buildPages(incremental, prevState, outDir);\n\n // Build islands for client-side hydration\n // Pass renderHtml so the Vite build uses the SSG's Document template\n // instead of a hardcoded minimal HTML template\n const documentTemplate = this.config.document ?? DefaultDocument;\n await this.app.build({\n outDir,\n mode: \"full\",\n minify: true,\n renderHtml: ({ html, css, styles, scripts, title, path: routePath }) => {\n const scriptsHtml = scripts\n .map((s) => `<script type=\"module\" src=\"${s.src}\"></script>`)\n .join(\"\\n\");\n const documentProps: DocumentProps = {\n children: new RawHTML(html),\n title,\n base: this.config.base ?? \"/\",\n path: routePath,\n props: {},\n scripts: scriptsHtml ? new RawHTML(scriptsHtml) : undefined,\n css: css ?? [],\n styles: styles ?? [],\n };\n const documentVNode = documentTemplate(documentProps);\n return renderDocument(documentVNode);\n },\n vite: {\n build: {\n rollupOptions: {\n // Don't externalize for SSG - bundle everything\n external: [],\n },\n },\n },\n });\n\n // Plugin hook: buildEnd\n for (const plugin of this.plugins) {\n await plugin.buildEnd?.(result, this);\n }\n\n return result;\n } finally {\n await this.app.close();\n }\n }\n\n private async registerRoutes(): Promise<void> {\n const routes = this.config.routes ?? [];\n\n for (const route of routes) {\n if (route.getStaticPaths) {\n // Dynamic route - register each path\n const staticPaths = await route.getStaticPaths(this);\n for (const sp of staticPaths) {\n const path = this.applyParams(route.path, sp.params);\n const props: Record<string, unknown> = { ...sp.props, params: sp.params };\n\n this.app.route(\n path,\n (_context: RouteContext) => {\n return route.component(props);\n },\n { title: props.title as string | undefined },\n );\n }\n } else {\n // Static route\n let props: Record<string, unknown> = {};\n if (typeof route.props === \"function\") {\n props = await route.props(this);\n } else if (route.props) {\n props = route.props;\n }\n\n this.app.route(\n route.path,\n (_context: RouteContext) => {\n return route.component(props);\n },\n { title: props.title as string | undefined },\n );\n }\n }\n }\n\n private async buildPages(\n incremental: boolean,\n prevState: BuildState | undefined,\n outDir: string,\n ): Promise<BuildResult> {\n const state: BuildState = {\n cursors: {},\n pageHashes: {},\n timestamp: Date.now(),\n };\n\n const stats = { added: 0, updated: 0, deleted: 0, unchanged: 0 };\n const builtPaths: string[] = [];\n\n if (!incremental) {\n await rm(outDir, { recursive: true, force: true });\n }\n await mkdir(outDir, { recursive: true });\n\n this.entriesCache.clear();\n\n // Get all paths to build\n const allPaths = await this.generateAllPaths();\n const currentPaths = new Set(allPaths.map((p) => p.path));\n\n // Delete removed pages\n if (incremental && prevState) {\n for (const oldPath of Object.keys(prevState.pageHashes)) {\n if (!currentPaths.has(oldPath)) {\n const filePath = this.pathToFilePath(oldPath);\n try {\n await rm(join(outDir, filePath));\n stats.deleted++;\n } catch {\n // ignore\n }\n }\n }\n }\n\n // Build each page\n for (const { path, props } of allPaths) {\n const html = await this.renderPage(path, props);\n const hash = this.hashContent(html);\n\n const prevHash = prevState?.pageHashes[path];\n const needsWrite = !incremental || !prevHash || prevHash !== hash;\n\n if (needsWrite) {\n const filePath = this.pathToFilePath(path);\n const fullPath = join(outDir, filePath);\n\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, html);\n\n builtPaths.push(path);\n if (!prevHash) {\n stats.added++;\n } else {\n stats.updated++;\n }\n } else {\n stats.unchanged++;\n }\n\n state.pageHashes[path] = hash;\n }\n\n for (const [name, collection] of this.collections) {\n if (collection.source.getChanges) {\n state.cursors[name] = Date.now().toString();\n }\n }\n\n return { state, paths: builtPaths, stats };\n }\n\n private async renderPage(path: string, props: Record<string, unknown>): Promise<string> {\n // Use App to render the page\n const result = await this.app.render(path);\n\n // Wrap with document template\n const documentProps: DocumentProps = {\n children: new RawHTML(result.html),\n title: props.title as string | undefined,\n base: this.config.base ?? \"/\",\n path,\n props,\n scripts: result.scripts ? new RawHTML(result.scripts) : undefined,\n css: result.css ?? [],\n styles: result.styles ?? [],\n };\n\n const template = this.config.document ?? DefaultDocument;\n const documentVNode = template(documentProps);\n\n return renderDocument(documentVNode);\n }\n\n private async generateAllPaths(): Promise<\n Array<{ path: string; props: Record<string, unknown> }>\n > {\n const paths: Array<{ path: string; props: Record<string, unknown> }> = [];\n const routes = this.config.routes ?? [];\n\n for (const route of routes) {\n if (route.getStaticPaths) {\n const staticPaths = await route.getStaticPaths(this);\n for (const sp of staticPaths) {\n const path = this.applyParams(route.path, sp.params);\n paths.push({ path, props: { ...sp.props, params: sp.params } });\n }\n } else {\n let props: Record<string, unknown> = {};\n if (typeof route.props === \"function\") {\n props = await route.props(this);\n } else if (route.props) {\n props = route.props;\n }\n paths.push({ path: route.path, props });\n }\n }\n\n return paths;\n }\n\n watch(options: WatchOptions = {}): Watcher {\n const unsubscribers: (() => void)[] = [];\n\n for (const [name, collection] of this.collections) {\n if (collection.source.watch) {\n const unsubscribe = collection.source.watch(async () => {\n try {\n this.entriesCache.delete(name);\n const result = await this.build({ incremental: true });\n options.onRebuild?.(result);\n } catch (error) {\n options.onError?.(error as Error);\n }\n });\n unsubscribers.push(unsubscribe);\n }\n }\n\n return {\n close: () => unsubscribers.forEach((fn) => fn()),\n };\n }\n\n private pathToFilePath(urlPath: string): string {\n if (urlPath === \"/\") return \"index.html\";\n return `${urlPath.slice(1)}/index.html`;\n }\n\n private applyParams(pattern: string, params: Record<string, string>): string {\n let path = pattern;\n for (const [key, value] of Object.entries(params)) {\n path = path.replace(`:${key}`, value);\n }\n return path;\n }\n\n private hashContent(content: string): string {\n let hash = 0;\n for (let i = 0; i < content.length; i++) {\n const char = content.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash.toString(16);\n }\n\n private extractHeadings(content: string): Array<{ depth: number; text: string; slug: string }> {\n const headings: Array<{ depth: number; text: string; slug: string }> = [];\n const regex = /^(#{1,6})\\s+(.+)$/gm;\n\n let match;\n while ((match = regex.exec(content)) !== null) {\n if (!match[1] || !match[2]) continue;\n const depth = match[1].length;\n const text = match[2].trim();\n const slug = text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\");\n headings.push({ depth, text, slug });\n }\n\n return headings;\n }\n}\n\nexport function createSSG<\n const TCollections extends readonly Collection[],\n TRegistry extends Record<string, unknown> = InferCollections<TCollections>,\n>(config: SSGConfig<TCollections, TRegistry>): SSGInstance<TRegistry> {\n return new SSG<TRegistry>(config as unknown as SSGConfig);\n}\n","import type { z } from \"zod\";\nimport type { Collection, CollectionConfig } from \"../types\";\n\n/**\n * Define a collection with schema validation\n */\nexport function defineCollection<T extends z.ZodType>(\n config: CollectionConfig<T>,\n): Collection<z.infer<T>> {\n return {\n name: config.name,\n source: config.source,\n schema: config.schema,\n };\n}\n\nexport type { Collection, CollectionConfig, CollectionEntry } from \"../types\";\n","import type { CollectionSource, CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\n\n/**\n * Base class for collection sources\n */\nexport abstract class BaseSource<T = unknown> implements CollectionSource<T> {\n abstract id: string;\n\n abstract getEntries(): Promise<CollectionEntry<T>[]>;\n\n async getEntry(id: string): Promise<CollectionEntry<T> | null> {\n const entries = await this.getEntries();\n return entries.find((e) => e.id === id) ?? null;\n }\n\n watch?(callback: WatchCallback<T>): () => void;\n\n getChanges?(since: string): Promise<ChangeSet<T>>;\n}\n","import { glob } from \"glob\";\nimport matter from \"gray-matter\";\nimport { readFile, watch as fsWatch } from \"fs/promises\";\nimport { join, relative } from \"path\";\nimport type { CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\nimport type { FileSourceOptions } from \"./types\";\nimport { BaseSource } from \"./base\";\n\n/**\n * File system source for collections\n */\nexport class FileSource<T = unknown> extends BaseSource<T> {\n id: string;\n private directory: string;\n private include: string;\n private shouldWatch: boolean;\n private contentRoot: string;\n\n constructor(options: FileSourceOptions, contentRoot: string = process.cwd()) {\n super();\n this.directory = options.directory;\n this.include = options.include ?? \"**/*.{md,mdx}\";\n this.shouldWatch = options.watch ?? false;\n this.contentRoot = contentRoot;\n this.id = `file:${this.directory}`;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n const dir = join(this.contentRoot, this.directory);\n const pattern = join(dir, this.include);\n const files = await glob(pattern);\n\n const entries = await Promise.all(\n files.map(async (filePath) => {\n const content = await readFile(filePath, \"utf-8\");\n const { data, content: body } = matter(content);\n\n const relativePath = relative(dir, filePath);\n const id = relativePath.replace(/\\.(md|mdx)$/, \"\");\n const slug = id.replace(/\\\\/g, \"/\");\n\n return {\n id,\n slug,\n data: data as T,\n body,\n render: async () => {\n // MDX compilation will be handled by the MDX processor\n return {\n Content: () => {\n throw new Error(\"MDX rendering not yet implemented\");\n },\n };\n },\n };\n }),\n );\n\n return entries;\n }\n\n override watch(callback: WatchCallback<T>): () => void {\n if (!this.shouldWatch) {\n return () => {};\n }\n\n const dir = join(this.contentRoot, this.directory);\n const abortController = new AbortController();\n\n const startWatching = async () => {\n try {\n const watcher = fsWatch(dir, {\n recursive: true,\n signal: abortController.signal,\n });\n\n for await (const _event of watcher) {\n // Debounce and collect changes\n const entries = await this.getEntries();\n callback({\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n });\n }\n } catch (err) {\n if ((err as Error).name !== \"AbortError\") {\n throw err;\n }\n }\n };\n\n startWatching();\n\n return () => {\n abortController.abort();\n };\n }\n\n override async getChanges(_since: string): Promise<ChangeSet<T>> {\n // For file source, we do a full reload\n // A more sophisticated implementation could track file mtimes\n const entries = await this.getEntries();\n return {\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n };\n }\n}\n\n/**\n * Create a file system source\n */\nexport function fileSource<T = unknown>(\n options: FileSourceOptions,\n contentRoot?: string,\n): FileSource<T> {\n return new FileSource<T>(options, contentRoot);\n}\n","import { exec } from \"child_process\";\nimport { promisify } from \"util\";\nimport type { CollectionEntry } from \"../types\";\nimport type { GitSourceOptions, GitCommitSourceOptions, GitTagSourceOptions } from \"./types\";\nimport { BaseSource } from \"./base\";\n\nconst execAsync = promisify(exec);\n\n/**\n * Git source for collections\n */\nexport class GitSource<T = unknown> extends BaseSource<T> {\n id: string;\n private options: GitSourceOptions;\n private cwd: string;\n\n constructor(options: GitSourceOptions, cwd: string = process.cwd()) {\n super();\n this.options = options;\n this.cwd = cwd;\n this.id = `git:${options.type}`;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n if (this.options.type === \"commits\") {\n return this.getCommits(this.options);\n } else {\n return this.getTags(this.options);\n }\n }\n\n private async getCommits(options: GitCommitSourceOptions): Promise<CollectionEntry<T>[]> {\n const args = [\"log\", \"--format=%H|%s|%an|%ae|%aI\"];\n\n if (options.filter?.since) {\n args.push(`--since=${options.filter.since}`);\n }\n if (options.filter?.until) {\n args.push(`--until=${options.filter.until}`);\n }\n if (options.filter?.author) {\n args.push(`--author=${options.filter.author}`);\n }\n if (options.limit) {\n args.push(`-n`, options.limit.toString());\n }\n if (options.filter?.paths?.length) {\n args.push(\"--\", ...options.filter.paths);\n }\n\n const { stdout } = await execAsync(`git ${args.join(\" \")}`, {\n cwd: this.cwd,\n });\n const lines = stdout.trim().split(\"\\n\").filter(Boolean);\n\n return lines.map((line) => {\n const parts = line.split(\"|\");\n const hash = parts[0] ?? \"\";\n const message = parts[1] ?? \"\";\n const author = parts[2] ?? \"\";\n const email = parts[3] ?? \"\";\n const dateStr = parts[4] ?? \"\";\n\n const data = {\n hash,\n message,\n author,\n email,\n date: new Date(dateStr),\n } as unknown as T;\n\n return {\n id: hash,\n slug: hash.slice(0, 7),\n data,\n body: message,\n render: async () => ({\n Content: () => {\n throw new Error(\"Git commits cannot be rendered as content\");\n },\n }),\n };\n });\n }\n\n private async getTags(options: GitTagSourceOptions): Promise<CollectionEntry<T>[]> {\n const pattern = options.pattern ?? \"*\";\n\n // Get tags with date and message\n const { stdout } = await execAsync(\n `git tag -l \"${pattern}\" --format=\"%(refname:short)|%(objectname:short)|%(creatordate:iso)|%(contents:subject)\"`,\n { cwd: this.cwd },\n );\n\n const lines = stdout.trim().split(\"\\n\").filter(Boolean);\n\n return lines.map((line) => {\n const parts = line.split(\"|\");\n const tag = parts[0] ?? \"\";\n const hash = parts[1] ?? \"\";\n const dateStr = parts[2] ?? \"\";\n const message = parts[3] ?? \"\";\n\n const data = {\n tag,\n hash,\n date: new Date(dateStr),\n message: message || undefined,\n } as unknown as T;\n\n return {\n id: tag,\n slug: tag,\n data,\n body: message,\n render: async () => ({\n Content: () => {\n throw new Error(\"Git tags cannot be rendered as content\");\n },\n }),\n };\n });\n }\n}\n\n/**\n * Create a Git source\n */\nexport function gitSource<T = unknown>(options: GitSourceOptions, cwd?: string): GitSource<T> {\n return new GitSource<T>(options, cwd);\n}\n","import type { CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\nimport type { RemoteSourceOptions, WebhookConfig } from \"./types\";\nimport { BaseSource } from \"./base\";\n\n/**\n * Remote API source for collections\n */\nexport class RemoteSource<T = unknown> extends BaseSource<T> {\n id: string;\n private options: RemoteSourceOptions<T>;\n private pollTimer?: ReturnType<typeof setInterval>;\n\n constructor(options: RemoteSourceOptions<T>, id: string = \"remote\") {\n super();\n this.options = options;\n this.id = `remote:${id}`;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n const items = await this.options.fetch();\n\n return items.map((item, index) => {\n const id = (item as Record<string, unknown>).id?.toString() ?? index.toString();\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).content?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Remote content rendering not yet implemented\");\n },\n }),\n };\n });\n }\n\n override async getEntry(id: string): Promise<CollectionEntry<T> | null> {\n if (this.options.fetchOne) {\n const item = await this.options.fetchOne(id);\n if (!item) return null;\n\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).content?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Remote content rendering not yet implemented\");\n },\n }),\n };\n }\n\n return super.getEntry(id);\n }\n\n override watch(callback: WatchCallback<T>): () => void {\n if (this.options.pollInterval) {\n this.pollTimer = setInterval(async () => {\n const entries = await this.getEntries();\n callback({\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n });\n }, this.options.pollInterval);\n\n return () => {\n if (this.pollTimer) {\n clearInterval(this.pollTimer);\n }\n };\n }\n\n return () => {};\n }\n\n override async getChanges(since: string): Promise<ChangeSet<T>> {\n if (this.options.fetchChanges) {\n return this.options.fetchChanges(since);\n }\n\n // Fallback to full reload\n const entries = await this.getEntries();\n return {\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n };\n }\n\n /**\n * Get webhook configuration for external integration\n */\n getWebhookConfig(): WebhookConfig | undefined {\n return this.options.webhook;\n }\n}\n\n/**\n * Create a remote API source\n */\nexport function remoteSource<T = unknown>(\n options: RemoteSourceOptions<T>,\n id?: string,\n): RemoteSource<T> {\n return new RemoteSource<T>(options, id);\n}\n","import type { CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\nimport type { CustomSourceOptions } from \"./types\";\nimport { BaseSource } from \"./base\";\n\n/**\n * Custom source for collections\n */\nexport class CustomSource<T = unknown> extends BaseSource<T> {\n id: string;\n private options: CustomSourceOptions<T>;\n\n constructor(options: CustomSourceOptions<T>) {\n super();\n this.options = options;\n this.id = options.id;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n const items = await this.options.getEntries();\n\n return items.map((item, index) => {\n const id = (item as Record<string, unknown>).id?.toString() ?? index.toString();\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).body?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Custom content rendering not yet implemented\");\n },\n }),\n };\n });\n }\n\n override async getEntry(id: string): Promise<CollectionEntry<T> | null> {\n if (this.options.getEntry) {\n const item = await this.options.getEntry(id);\n if (!item) return null;\n\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).body?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Custom content rendering not yet implemented\");\n },\n }),\n };\n }\n\n return super.getEntry(id);\n }\n\n override watch(callback: WatchCallback<T>): () => void {\n if (this.options.watch) {\n return this.options.watch(callback);\n }\n return () => {};\n }\n\n override async getChanges(since: string): Promise<ChangeSet<T>> {\n if (this.options.getChanges) {\n return this.options.getChanges(since);\n }\n\n const entries = await this.getEntries();\n return {\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n };\n }\n}\n\n/**\n * Create a custom source\n */\nexport function createSource<T = unknown>(options: CustomSourceOptions<T>): CustomSource<T> {\n return new CustomSource<T>(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAa,mBAAqC,EAChD,UACA,QAAQ,YACR,SACA,KACA,aAEA,qBAAC;CAAK,MAAK;YACT,qBAAC;EACC,oBAAC,UAAK,SAAQ,UAAU;EACxB,oBAAC;GAAK,MAAK;GAAW,SAAQ;IAA0C;EACxE,oBAAC,qBAAO,QAAc;EACrB,KAAK,KAAK,SACT,oBAAC;GAAK,KAAI;GAAmB;IAAQ,CACrC;EACD,UAAU,OAAO,SAAS,KAAK,oBAAC,qBAAO,OAAO,KAAK,KAAK,GAAS;KAC7D,EACP,qBAAC,qBACE,UACA,WACI;EACF;;;;;;;ACsGT,IAAa,UAAb,MAAqB;CAKnB,YAAY,AAAgB,MAAc;EAAd;cAJL;kBAEa,EAAE;AAGpC,OAAK,QAAQ,EAAE,yBAAyB,EAAE,QAAQ,MAAM,EAAE;;CAG5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AAM,KAAK,QAAQ,YAAY,EAEhC,KAAK,MAAM,UAAU;GAChC,MAAM,KAAM,KAAiC,IAAI,UAAU,IAAI,MAAM,UAAU;AAG/E,UAAO;IACL;IACA,MAJY,KAAiC,MAAM,UAAU,IAAI;IAKjE,MAAM;IACN,MAAO,KAAiC,MAAM,UAAU,IAAI;IAC5D,QAAQ,aAAa,EACnB,eAAe;AACb,WAAM,IAAI,MAAM,+CAA+C;OAElE;IACF;IACD;;CAGJ,MAAe,SAAS,IAAgD;AACtE,MAAI,KAAK,QAAQ,UAAU;GACzB,MAAM,OAAO,MAAM,KAAK,QAAQ,SAAS,GAAG;AAC5C,OAAI,CAAC,KAAM,QAAO;AAIlB,UAAO;IACL;IACA,MAJY,KAAiC,MAAM,UAAU,IAAI;IAKjE,MAAM;IACN,MAAO,KAAiC,MAAM,UAAU,IAAI;IAC5D,QAAQ,aAAa,EACnB,eAAe;AACb,WAAM,IAAI,MAAM,+CAA+C;OAElE;IACF;;AAGH,SAAO,MAAM,SAAS,GAAG;;CAG3B,AAAS,MAAM,UAAwC;AACrD,MAAI,KAAK,QAAQ,MACf,QAAO,KAAK,QAAQ,MAAM,SAAS;AAErC,eAAa;;CAGf,MAAe,WAAW,OAAsC;AAC9D,MAAI,KAAK,QAAQ,WACf,QAAO,KAAK,QAAQ,WAAW,MAAM;EAGvC,MAAM,UAAU,MAAM,KAAK,YAAY;AACvC,SAAO;GACL,QAAQ,KAAK,KAAK,CAAC,UAAU;GAC7B,OAAO,EAAE;GACT,SAAS;GACT,SAAS,EAAE;GACZ;;;;;;AAOL,SAAgB,aAA0B,SAAkD;AAC1F,QAAO,IAAI,aAAgB,QAAQ"}
1
+ {"version":3,"file":"src-BNQE-0cR.mjs","names":["fsWatch"],"sources":["../../ssg/src/document.tsx","../../ssg/src/types.ts","../../ssg/src/mdx/processor.ts","../../ssg/src/mdx/vite-plugin.ts","../../ssg/src/ssg.ts","../../ssg/src/collection/index.ts","../../ssg/src/sources/base.ts","../../ssg/src/sources/file.ts","../../ssg/src/sources/git.ts","../../ssg/src/sources/remote.ts","../../ssg/src/sources/custom.ts"],"sourcesContent":["/** @jsxImportSource @semajsx/dom */\n\nimport type { DocumentTemplate } from \"./types\";\n\n/**\n * Default HTML document template for SSG\n */\nexport const DefaultDocument: DocumentTemplate = ({\n children,\n title = \"SSG Page\",\n scripts,\n css,\n styles,\n}) => (\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>{title}</title>\n {css?.map((href) => (\n <link rel=\"stylesheet\" href={href} />\n ))}\n {styles && styles.length > 0 && <style>{styles.join(\"\\n\")}</style>}\n </head>\n <body>\n {children}\n {scripts}\n </body>\n </html>\n);\n","import type { Component, VNode } from \"@semajsx/core\";\nimport type { z } from \"zod\";\n\n// =============================================================================\n// Collection Registry (for type inference)\n// =============================================================================\n\n/**\n * Infer a registry type from an array of collections\n * Maps collection names to their data types\n */\nexport type InferCollections<T extends readonly Collection[]> = {\n [K in T[number] as K[\"name\"]]: K extends Collection<infer D> ? D : unknown;\n};\n\n// =============================================================================\n// Collection Entry\n// =============================================================================\n\nexport interface CollectionEntry<T = unknown> {\n /** Unique identifier within the collection */\n id: string;\n /** URL-friendly slug */\n slug: string;\n /** Validated frontmatter data */\n data: T;\n /** Raw content body (markdown/mdx) */\n body: string;\n /** Render the content to JSX */\n render: () => Promise<{ Content: () => VNode }>;\n}\n\n// =============================================================================\n// Collection Source\n// =============================================================================\n\nexport interface ChangeSet<T = unknown> {\n /** Cursor for next incremental fetch */\n cursor: string;\n /** Newly added entries */\n added: CollectionEntry<T>[];\n /** Updated entries */\n updated: CollectionEntry<T>[];\n /** Deleted entry IDs */\n deleted: string[];\n}\n\nexport type WatchCallback<T = unknown> = (changes: ChangeSet<T>) => void;\n\nexport interface CollectionSource<T = unknown> {\n /** Unique identifier for this source */\n id: string;\n\n /** Get all entries from this source */\n getEntries(): Promise<CollectionEntry<T>[]>;\n\n /** Get a single entry by ID */\n getEntry(id: string): Promise<CollectionEntry<T> | null>;\n\n /** Watch for changes (optional) */\n watch?(callback: WatchCallback<T>): () => void;\n\n /** Get incremental changes since cursor (optional) */\n getChanges?(since: string): Promise<ChangeSet<T>>;\n}\n\n// =============================================================================\n// Collection Definition\n// =============================================================================\n\nexport interface CollectionConfig<T extends z.ZodType = z.ZodType> {\n /** Collection name */\n name: string;\n /** Data source (returns raw entries, validated against schema later) */\n source: CollectionSource<unknown>;\n /** Zod schema for validation */\n schema: T;\n}\n\nexport interface Collection<T = unknown> {\n name: string;\n source: CollectionSource<unknown>;\n schema: z.ZodType;\n /** Type-only field for inference */\n _outputType?: T;\n}\n\n// =============================================================================\n// Route Configuration\n// =============================================================================\n\nexport interface StaticPath<P = Record<string, string>> {\n params: P;\n props?: Record<string, unknown>;\n}\n\nexport interface RouteConfig<TRegistry extends Record<string, unknown> = Record<string, unknown>> {\n /** Route path pattern (e.g., '/blog/:slug') */\n path: string;\n /** Component to render. Props are provided dynamically by the route config. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Route props are dynamic, typed via `props`/`getStaticPaths`\n component: (props: any) => VNode;\n /** Static props for the route */\n props?:\n | Record<string, unknown>\n | ((ssg: SSGInstance<TRegistry>) => Promise<Record<string, unknown>>);\n /** Generate static paths for dynamic routes */\n getStaticPaths?: (ssg: SSGInstance<TRegistry>) => Promise<StaticPath[]>;\n}\n\n// =============================================================================\n// MDX Configuration\n// =============================================================================\n\nexport interface MDXConfig {\n /** Remark plugins */\n remarkPlugins?: unknown[];\n /** Rehype plugins */\n rehypePlugins?: unknown[];\n /** Component mapping for MDX */\n components?: Record<string, Component>;\n}\n\n// =============================================================================\n// Document Template\n// =============================================================================\n\n/**\n * Raw HTML VNode that can be used directly in JSX or converted to string\n */\nexport class RawHTML {\n public readonly type = \"div\";\n public readonly props: { dangerouslySetInnerHTML: { __html: string } };\n public readonly children: never[] = [];\n\n constructor(public readonly html: string) {\n this.props = { dangerouslySetInnerHTML: { __html: html } };\n }\n\n toString(): string {\n return this.html;\n }\n}\n\nexport interface DocumentProps {\n /** Rendered page content (VNode with toString) */\n children: RawHTML;\n /** Page title */\n title?: string;\n /** Base URL path */\n base: string;\n /** Route path */\n path: string;\n /** Route props */\n props: Record<string, unknown>;\n /** Script tags for islands (as RawHTML) */\n scripts?: RawHTML;\n /** CSS stylesheet paths */\n css?: string[];\n /** Inline CSS collected from StyleTokens */\n styles?: string[];\n}\n\nexport type DocumentTemplate = (props: DocumentProps) => VNode;\n\n// =============================================================================\n// Plugin System\n// =============================================================================\n\n/**\n * Partial SSG config that a plugin's config() hook can return.\n * Each field has a defined merge strategy:\n * - mdx: merge (concat arrays, merge component objects)\n * - document: override (last writer wins)\n * - routes: concat\n * - collections: concat\n */\nexport interface SSGPluginConfig {\n mdx?: Partial<MDXConfig>;\n document?: DocumentTemplate;\n routes?: RouteConfig[];\n collections?: readonly Collection[];\n}\n\nexport interface SSGPlugin {\n /** Plugin name for identification and debugging */\n name: string;\n\n /** Plugin ordering: 'pre' runs before normal plugins, 'post' runs after */\n enforce?: \"pre\" | \"post\";\n\n /**\n * Modify SSG config before it is resolved.\n * Return partial config to merge.\n * Called in plugin order: enforce:'pre' → normal → enforce:'post' → user config.\n */\n config?(config: SSGConfig): SSGPluginConfig | void;\n\n /** Called after config is fully resolved. Read-only inspection. */\n configResolved?(config: SSGConfig): void;\n\n /** Called before build starts */\n buildStart?(): void | Promise<void>;\n\n /** Called after build completes. Receives the SSG instance for post-build operations. */\n buildEnd?(result: BuildResult, ssg: SSGInstance): void | Promise<void>;\n}\n\n// =============================================================================\n// SSG Configuration\n// =============================================================================\n\nexport interface SSGConfig<\n TCollections extends readonly Collection[] = Collection[],\n TRegistry extends Record<string, unknown> = InferCollections<TCollections>,\n> {\n /** Output directory for built files */\n outDir: string;\n /** Root directory for resolving relative paths (defaults to script location) */\n rootDir?: string;\n /** Base URL path */\n base?: string;\n /** Collections to include */\n collections?: TCollections;\n /** Route definitions */\n routes?: RouteConfig<TRegistry>[];\n /** Plugins that contribute remark/rehype plugins and components.\n * Plugin factories may return arrays (Vite-style); nested arrays are flattened. */\n plugins?: (SSGPlugin | SSGPlugin[])[];\n /** MDX configuration (merged after plugins, takes precedence) */\n mdx?: MDXConfig;\n /** Custom document template */\n document?: DocumentTemplate;\n}\n\n// =============================================================================\n// Build State & Result\n// =============================================================================\n\nexport interface BuildState {\n /** Cursor for each collection */\n cursors: Record<string, string>;\n /** Content hash for each page */\n pageHashes: Record<string, string>;\n /** Last build timestamp */\n timestamp: number;\n}\n\nexport interface BuildResult {\n /** New build state for incremental builds */\n state: BuildState;\n /** Paths that were built */\n paths: string[];\n /** Build statistics */\n stats: {\n added: number;\n updated: number;\n deleted: number;\n unchanged: number;\n };\n}\n\nexport interface BuildOptions {\n /** Enable incremental build */\n incremental?: boolean;\n /** Previous build state */\n state?: BuildState;\n /** Only build specific collections */\n collections?: string[];\n}\n\n// =============================================================================\n// Watcher\n// =============================================================================\n\nexport interface WatchOptions {\n /** Callback when rebuild completes */\n onRebuild?: (result: BuildResult) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n}\n\nexport interface Watcher {\n /** Stop watching */\n close(): void;\n}\n\n// =============================================================================\n// SSG Instance\n// =============================================================================\n\nexport interface SSGInstance<TRegistry extends Record<string, unknown> = Record<string, unknown>> {\n /** Get the root directory for resolving paths */\n getRootDir(): string;\n\n /** Get all entries from a collection */\n getCollection<K extends keyof TRegistry & string>(\n name: K,\n ): Promise<CollectionEntry<TRegistry[K]>[]>;\n\n /** Get a single entry from a collection */\n getEntry<K extends keyof TRegistry & string>(\n name: K,\n id: string,\n ): Promise<CollectionEntry<TRegistry[K]> | null>;\n\n /** Build the static site */\n build(options?: BuildOptions): Promise<BuildResult>;\n\n /** Watch for changes and rebuild */\n watch(options?: WatchOptions): Watcher;\n}\n","import { compile } from \"@mdx-js/mdx\";\nimport type { Pluggable } from \"unified\";\nimport type { VNode } from \"@semajsx/core\";\nimport type { MDXConfig, MDXCompileResult, Heading } from \"./types\";\n\n/**\n * MDX Processor for compiling MDX content to JSX components\n */\nexport class MDXProcessor {\n private config: MDXConfig;\n\n constructor(config: MDXConfig = {}) {\n this.config = config;\n }\n\n /**\n * Compile MDX content to a JSX component\n */\n async compile(\n content: string,\n frontmatter: Record<string, unknown> = {},\n ): Promise<MDXCompileResult> {\n // Extract headings for table of contents\n const headings = this.extractHeadings(content);\n\n // Compile MDX to JavaScript\n const compiled = await compile(content, {\n outputFormat: \"function-body\",\n development: false,\n remarkPlugins: (this.config.remarkPlugins ?? []) as Pluggable[],\n rehypePlugins: (this.config.rehypePlugins ?? []) as Pluggable[],\n // Use SemaJSX runtime\n jsxImportSource: \"semajsx/dom\",\n });\n\n // Dynamic import of JSX runtime\n const jsxRuntime = await import(\"semajsx/dom/jsx-runtime\");\n\n // Create the Content component\n const Content = this.createComponent(\n String(compiled),\n this.config.components ?? {},\n jsxRuntime,\n );\n\n return {\n Content,\n frontmatter,\n headings,\n };\n }\n\n /**\n * Create a component from compiled MDX code\n */\n private createComponent(\n code: string,\n components: Record<string, (props: Record<string, unknown>) => VNode>,\n jsxRuntime: unknown,\n ): (props?: Record<string, unknown>) => VNode {\n // Import JSX runtime\n // This will be resolved at runtime\n return (props: Record<string, unknown> = {}) => {\n try {\n // Create a function from the MDX compiled code\n // MDX compiled code expects jsx runtime in arguments[0]\n // By using new Function() with no parameters, we can pass\n // the runtime via call() and it becomes arguments[0]\n // eslint-disable-next-line @typescript-eslint/no-implied-eval\n const fn = new Function(code + \"\\nreturn MDXContent;\");\n\n // Call with jsxRuntime as arguments[0]\n // MDX returns an object with default export\n const result = fn.call(null, jsxRuntime) as {\n default: (props: Record<string, unknown>) => VNode;\n };\n return result.default({ ...props, components });\n } catch (e) {\n // Fallback for when runtime is not available\n throw new Error(`MDX rendering failed: ${(e as Error).message}`);\n }\n };\n }\n\n /**\n * Extract headings from markdown content\n */\n private extractHeadings(content: string): Heading[] {\n const headings: Heading[] = [];\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n\n let match;\n while ((match = headingRegex.exec(content)) !== null) {\n const hashes = match[1];\n const rawText = match[2];\n if (!hashes || !rawText) continue;\n\n const depth = hashes.length;\n const text = rawText.trim();\n const slug = this.slugify(text);\n\n headings.push({ depth, text, slug });\n }\n\n return headings;\n }\n\n /**\n * Convert text to URL-friendly slug\n */\n private slugify(text: string): string {\n return text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\")\n .replace(/-+/g, \"-\")\n .trim();\n }\n}\n\n/**\n * Create an MDX processor instance\n */\nexport function createMDXProcessor(config?: MDXConfig): MDXProcessor {\n return new MDXProcessor(config);\n}\n","import { compile } from \"@mdx-js/mdx\";\nimport type { Plugin, PluginOption } from \"vite\";\nimport type { Pluggable } from \"unified\";\n\n/**\n * MDX plugin options\n */\nexport interface MDXPluginOptions {\n /** Remark plugins */\n remarkPlugins?: unknown[];\n /** Rehype plugins */\n rehypePlugins?: unknown[];\n}\n\n/**\n * Vite plugin for MDX support\n * Transforms .mdx files to JSX modules\n */\nexport function viteMDXPlugin(options: MDXPluginOptions = {}): PluginOption {\n const plugin: Plugin = {\n name: \"semajsx-mdx\",\n\n async transform(code: string, id: string) {\n // Only transform .mdx files\n if (!id.endsWith(\".mdx\")) {\n return null;\n }\n\n try {\n // Compile MDX to JavaScript (not JSX)\n const compiled = await compile(code, {\n jsxImportSource: \"semajsx/dom\",\n outputFormat: \"program\",\n development: false,\n remarkPlugins: (options.remarkPlugins ?? []) as Pluggable[],\n rehypePlugins: (options.rehypePlugins ?? []) as Pluggable[],\n });\n\n return {\n code: String(compiled),\n map: null,\n };\n } catch (error) {\n const err = error as Error;\n throw new Error(`MDX compilation failed for ${id}: ${err.message}`);\n }\n },\n };\n\n return plugin;\n}\n","import { mkdir, writeFile, rm } from \"fs/promises\";\nimport { join, dirname, resolve } from \"path\";\nimport { createApp, renderDocument } from \"@semajsx/ssr\";\nimport type { App, RouteContext } from \"@semajsx/ssr\";\nimport { DefaultDocument } from \"./document\";\nimport type { VNode } from \"@semajsx/core\";\nimport {\n RawHTML,\n type SSGConfig,\n type SSGPlugin,\n type SSGInstance,\n type MDXConfig,\n type RouteConfig,\n type DocumentTemplate,\n type Collection,\n type CollectionEntry,\n type BuildOptions,\n type BuildResult,\n type BuildState,\n type WatchOptions,\n type Watcher,\n type DocumentProps,\n type InferCollections,\n} from \"./types\";\nimport { viteMDXPlugin } from \"./mdx\";\n\n/**\n * Sort plugins by enforce order: 'pre' → normal → 'post'\n */\nfunction sortPlugins(plugins: SSGPlugin[]): SSGPlugin[] {\n const pre: SSGPlugin[] = [];\n const normal: SSGPlugin[] = [];\n const post: SSGPlugin[] = [];\n\n for (const plugin of plugins) {\n if (plugin.enforce === \"pre\") pre.push(plugin);\n else if (plugin.enforce === \"post\") post.push(plugin);\n else normal.push(plugin);\n }\n\n return [...pre, ...normal, ...post];\n}\n\n/**\n * Merge a partial MDX config into an existing one.\n */\nfunction mergeMdxConfig(base: MDXConfig, partial: Partial<MDXConfig>): MDXConfig {\n return {\n remarkPlugins: [...(base.remarkPlugins ?? []), ...(partial.remarkPlugins ?? [])],\n rehypePlugins: [...(base.rehypePlugins ?? []), ...(partial.rehypePlugins ?? [])],\n components: { ...base.components, ...partial.components },\n };\n}\n\n/**\n * Resolved config produced by running all plugin config hooks.\n */\ninterface ResolvedPluginConfig {\n mdx: MDXConfig;\n document?: DocumentTemplate;\n routes: RouteConfig[];\n collections: Collection[];\n}\n\n/**\n * Result of plugin resolution: merged config + flat list of all plugins.\n */\ninterface PluginResolutionResult {\n config: ResolvedPluginConfig;\n allPlugins: SSGPlugin[];\n}\n\n/**\n * Run config hooks on all plugins, then merge with user config.\n *\n * Plugin arrays are flattened Vite-style: plugin factories may return\n * `SSGPlugin | SSGPlugin[]`, and the top-level array is `.flat()`-ed\n * before sorting and processing.\n *\n * Merge strategies:\n * - mdx: merge (concat arrays, merge component objects)\n * - document: override (last writer wins, user config last)\n * - routes: concat (plugin routes first, then user routes)\n * - collections: concat (plugin collections first, then user collections)\n */\nfunction resolvePlugins(\n plugins: (SSGPlugin | SSGPlugin[])[],\n config: SSGConfig,\n): PluginResolutionResult {\n // Vite-style: flatten nested arrays from plugin factories\n const flat = plugins.flat();\n const sorted = sortPlugins(flat);\n\n let mdx: MDXConfig = { remarkPlugins: [], rehypePlugins: [], components: {} };\n let document: DocumentTemplate | undefined;\n const routes: RouteConfig[] = [];\n const collections: Collection[] = [];\n\n // Call config hooks in order\n for (const plugin of sorted) {\n if (!plugin.config) continue;\n const partial = plugin.config(config);\n if (!partial) continue;\n\n if (partial.mdx) mdx = mergeMdxConfig(mdx, partial.mdx);\n if (partial.document) document = partial.document;\n if (partial.routes) routes.push(...partial.routes);\n if (partial.collections) collections.push(...partial.collections);\n }\n\n // User config takes precedence (applied last)\n if (config.mdx) mdx = mergeMdxConfig(mdx, config.mdx);\n if (config.document) document = config.document;\n if (config.routes) routes.push(...config.routes);\n if (config.collections) collections.push(...config.collections);\n\n return { config: { mdx, document, routes, collections }, allPlugins: sorted };\n}\n\n/**\n * SSG (Static Site Generator) core class\n * Built on top of server's createApp\n */\nexport class SSG<\n TRegistry extends Record<string, unknown> = Record<string, unknown>,\n> implements SSGInstance<TRegistry> {\n private config: SSGConfig;\n private plugins: SSGPlugin[];\n private rootDir: string;\n private collections: Map<string, Collection>;\n private entriesCache: Map<string, CollectionEntry[]>;\n private app: App;\n private mdxModules: Map<string, string> = new Map();\n\n constructor(config: SSGConfig) {\n // Resolve rootDir\n this.rootDir = config.rootDir ?? process.cwd();\n\n // Run config hooks — merges plugins + user config, collects all plugins (including nested)\n const { config: resolved, allPlugins } = resolvePlugins(config.plugins ?? [], config);\n\n // Store all plugins (including sub-plugins) for lifecycle hooks\n this.plugins = allPlugins;\n\n this.config = {\n base: \"/\",\n ...config,\n mdx: resolved.mdx,\n document: resolved.document,\n routes: resolved.routes,\n collections: resolved.collections,\n outDir: resolve(this.rootDir, config.outDir),\n };\n\n // Call configResolved on all plugins\n for (const plugin of this.plugins) {\n plugin.configResolved?.(this.config);\n }\n this.collections = new Map();\n this.entriesCache = new Map();\n\n // Create App with MDX plugins\n this.app = createApp({\n root: this.rootDir,\n vite: {\n plugins: [\n // Virtual MDX content modules\n {\n name: \"ssg-virtual-mdx\",\n resolveId: (id: string) => {\n if (id.startsWith(\"virtual:mdx:\")) {\n return \"\\0\" + id;\n }\n },\n load: (id: string) => {\n if (id.startsWith(\"\\0virtual:mdx:\")) {\n const mdxId = id.replace(\"\\0virtual:mdx:\", \"\");\n return this.mdxModules.get(mdxId);\n }\n },\n },\n // MDX compiler plugin\n viteMDXPlugin(resolved.mdx),\n ],\n },\n });\n\n // Register collections (from resolved config — plugins + user)\n for (const collection of this.config.collections ?? []) {\n this.collections.set(collection.name, collection);\n }\n }\n\n getRootDir(): string {\n return this.rootDir;\n }\n\n async getCollection<K extends keyof TRegistry & string>(\n name: K,\n ): Promise<CollectionEntry<TRegistry[K]>[]> {\n const collection = this.collections.get(name);\n if (!collection) {\n throw new Error(`Collection \"${name}\" not found`);\n }\n\n if (this.entriesCache.has(name)) {\n return this.entriesCache.get(name) as CollectionEntry<TRegistry[K]>[];\n }\n\n const entries = await collection.source.getEntries();\n\n const validatedEntries = entries.map((entry) => {\n const result = collection.schema.safeParse(entry.data);\n if (!result.success) {\n throw new Error(`Validation error in ${name}/${entry.id}: ${result.error.message}`);\n }\n\n return {\n ...entry,\n data: result.data,\n render: async () => {\n // Get Vite server from app\n const vite = this.app.getViteServer();\n if (!vite) {\n throw new Error(\"Vite server not initialized\");\n }\n\n // Store MDX content as virtual module\n const mdxId = `${name}/${entry.id}.mdx`;\n this.mdxModules.set(mdxId, entry.body);\n\n try {\n // Load module through Vite SSR\n const moduleExports = (await vite.ssrLoadModule(`virtual:mdx:${mdxId}`)) as {\n default: (props: Record<string, unknown>) => unknown;\n };\n\n const Content = (props: Record<string, unknown> = {}): VNode =>\n moduleExports.default({\n ...props,\n components: this.config.mdx?.components ?? {},\n }) as VNode;\n\n return {\n Content,\n headings: this.extractHeadings(entry.body),\n };\n } finally {\n this.mdxModules.delete(mdxId);\n }\n },\n };\n });\n\n this.entriesCache.set(name, validatedEntries);\n return validatedEntries as CollectionEntry<TRegistry[K]>[];\n }\n\n async getEntry<K extends keyof TRegistry & string>(\n name: K,\n id: string,\n ): Promise<CollectionEntry<TRegistry[K]> | null> {\n const entries = await this.getCollection(name);\n return entries.find((e) => e.id === id || e.slug === id) ?? null;\n }\n\n async build(options: BuildOptions = {}): Promise<BuildResult> {\n const { incremental = false, state: prevState } = options;\n const outDir = this.config.outDir;\n\n // Plugin hook: buildStart\n for (const plugin of this.plugins) {\n await plugin.buildStart?.();\n }\n\n // Initialize App (starts Vite)\n await this.app.prepare();\n\n try {\n // Register routes with App\n await this.registerRoutes();\n\n // Build all pages\n const result = await this.buildPages(incremental, prevState, outDir);\n\n // Build islands for client-side hydration\n // Pass renderHtml so the Vite build uses the SSG's Document template\n // instead of a hardcoded minimal HTML template\n const documentTemplate = this.config.document ?? DefaultDocument;\n await this.app.build({\n outDir,\n mode: \"full\",\n minify: true,\n renderHtml: ({ html, css, styles, scripts, title, path: routePath }) => {\n const scriptsHtml = scripts\n .map((s) => `<script type=\"module\" src=\"${s.src}\"></script>`)\n .join(\"\\n\");\n const documentProps: DocumentProps = {\n children: new RawHTML(html),\n title,\n base: this.config.base ?? \"/\",\n path: routePath,\n props: {},\n scripts: scriptsHtml ? new RawHTML(scriptsHtml) : undefined,\n css: css ?? [],\n styles: styles ?? [],\n };\n const documentVNode = documentTemplate(documentProps);\n return renderDocument(documentVNode);\n },\n vite: {\n build: {\n rollupOptions: {\n // Don't externalize for SSG - bundle everything\n external: [],\n },\n },\n },\n });\n\n // Plugin hook: buildEnd\n for (const plugin of this.plugins) {\n await plugin.buildEnd?.(result, this);\n }\n\n return result;\n } finally {\n await this.app.close();\n }\n }\n\n private async registerRoutes(): Promise<void> {\n const routes = this.config.routes ?? [];\n\n for (const route of routes) {\n if (route.getStaticPaths) {\n // Dynamic route - register each path\n const staticPaths = await route.getStaticPaths(this);\n for (const sp of staticPaths) {\n const path = this.applyParams(route.path, sp.params);\n const props: Record<string, unknown> = { ...sp.props, params: sp.params };\n\n this.app.route(\n path,\n (_context: RouteContext) => {\n return route.component(props);\n },\n { title: props.title as string | undefined },\n );\n }\n } else {\n // Static route\n let props: Record<string, unknown> = {};\n if (typeof route.props === \"function\") {\n props = await route.props(this);\n } else if (route.props) {\n props = route.props;\n }\n\n this.app.route(\n route.path,\n (_context: RouteContext) => {\n return route.component(props);\n },\n { title: props.title as string | undefined },\n );\n }\n }\n }\n\n private async buildPages(\n incremental: boolean,\n prevState: BuildState | undefined,\n outDir: string,\n ): Promise<BuildResult> {\n const state: BuildState = {\n cursors: {},\n pageHashes: {},\n timestamp: Date.now(),\n };\n\n const stats = { added: 0, updated: 0, deleted: 0, unchanged: 0 };\n const builtPaths: string[] = [];\n\n if (!incremental) {\n await rm(outDir, { recursive: true, force: true });\n }\n await mkdir(outDir, { recursive: true });\n\n this.entriesCache.clear();\n\n // Get all paths to build\n const allPaths = await this.generateAllPaths();\n const currentPaths = new Set(allPaths.map((p) => p.path));\n\n // Delete removed pages\n if (incremental && prevState) {\n for (const oldPath of Object.keys(prevState.pageHashes)) {\n if (!currentPaths.has(oldPath)) {\n const filePath = this.pathToFilePath(oldPath);\n try {\n await rm(join(outDir, filePath));\n stats.deleted++;\n } catch {\n // ignore\n }\n }\n }\n }\n\n // Build each page\n for (const { path, props } of allPaths) {\n const html = await this.renderPage(path, props);\n const hash = this.hashContent(html);\n\n const prevHash = prevState?.pageHashes[path];\n const needsWrite = !incremental || !prevHash || prevHash !== hash;\n\n if (needsWrite) {\n const filePath = this.pathToFilePath(path);\n const fullPath = join(outDir, filePath);\n\n await mkdir(dirname(fullPath), { recursive: true });\n await writeFile(fullPath, html);\n\n builtPaths.push(path);\n if (!prevHash) {\n stats.added++;\n } else {\n stats.updated++;\n }\n } else {\n stats.unchanged++;\n }\n\n state.pageHashes[path] = hash;\n }\n\n for (const [name, collection] of this.collections) {\n if (collection.source.getChanges) {\n state.cursors[name] = Date.now().toString();\n }\n }\n\n return { state, paths: builtPaths, stats };\n }\n\n private async renderPage(path: string, props: Record<string, unknown>): Promise<string> {\n // Use App to render the page\n const result = await this.app.render(path);\n\n // Wrap with document template\n const documentProps: DocumentProps = {\n children: new RawHTML(result.html),\n title: props.title as string | undefined,\n base: this.config.base ?? \"/\",\n path,\n props,\n scripts: result.scripts ? new RawHTML(result.scripts) : undefined,\n css: result.css ?? [],\n styles: result.styles ?? [],\n };\n\n const template = this.config.document ?? DefaultDocument;\n const documentVNode = template(documentProps);\n\n return renderDocument(documentVNode);\n }\n\n private async generateAllPaths(): Promise<\n Array<{ path: string; props: Record<string, unknown> }>\n > {\n const paths: Array<{ path: string; props: Record<string, unknown> }> = [];\n const routes = this.config.routes ?? [];\n\n for (const route of routes) {\n if (route.getStaticPaths) {\n const staticPaths = await route.getStaticPaths(this);\n for (const sp of staticPaths) {\n const path = this.applyParams(route.path, sp.params);\n paths.push({ path, props: { ...sp.props, params: sp.params } });\n }\n } else {\n let props: Record<string, unknown> = {};\n if (typeof route.props === \"function\") {\n props = await route.props(this);\n } else if (route.props) {\n props = route.props;\n }\n paths.push({ path: route.path, props });\n }\n }\n\n return paths;\n }\n\n watch(options: WatchOptions = {}): Watcher {\n const unsubscribers: (() => void)[] = [];\n\n for (const [name, collection] of this.collections) {\n if (collection.source.watch) {\n const unsubscribe = collection.source.watch(async () => {\n try {\n this.entriesCache.delete(name);\n const result = await this.build({ incremental: true });\n options.onRebuild?.(result);\n } catch (error) {\n options.onError?.(error as Error);\n }\n });\n unsubscribers.push(unsubscribe);\n }\n }\n\n return {\n close: () => unsubscribers.forEach((fn) => fn()),\n };\n }\n\n private pathToFilePath(urlPath: string): string {\n if (urlPath === \"/\") return \"index.html\";\n return `${urlPath.slice(1)}/index.html`;\n }\n\n private applyParams(pattern: string, params: Record<string, string>): string {\n let path = pattern;\n for (const [key, value] of Object.entries(params)) {\n path = path.replace(`:${key}`, value);\n }\n return path;\n }\n\n private hashContent(content: string): string {\n let hash = 0;\n for (let i = 0; i < content.length; i++) {\n const char = content.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash.toString(16);\n }\n\n private extractHeadings(content: string): Array<{ depth: number; text: string; slug: string }> {\n const headings: Array<{ depth: number; text: string; slug: string }> = [];\n const regex = /^(#{1,6})\\s+(.+)$/gm;\n\n let match;\n while ((match = regex.exec(content)) !== null) {\n if (!match[1] || !match[2]) continue;\n const depth = match[1].length;\n const text = match[2].trim();\n const slug = text\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\");\n headings.push({ depth, text, slug });\n }\n\n return headings;\n }\n}\n\nexport function createSSG<\n const TCollections extends readonly Collection[],\n TRegistry extends Record<string, unknown> = InferCollections<TCollections>,\n>(config: SSGConfig<TCollections, TRegistry>): SSGInstance<TRegistry> {\n return new SSG<TRegistry>(config as unknown as SSGConfig);\n}\n","import type { z } from \"zod\";\nimport type { Collection, CollectionConfig } from \"../types\";\n\n/**\n * Define a collection with schema validation\n */\nexport function defineCollection<T extends z.ZodType>(\n config: CollectionConfig<T>,\n): Collection<z.infer<T>> {\n return {\n name: config.name,\n source: config.source,\n schema: config.schema,\n };\n}\n\nexport type { Collection, CollectionConfig, CollectionEntry } from \"../types\";\n","import type { CollectionSource, CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\n\n/**\n * Base class for collection sources\n */\nexport abstract class BaseSource<T = unknown> implements CollectionSource<T> {\n abstract id: string;\n\n abstract getEntries(): Promise<CollectionEntry<T>[]>;\n\n async getEntry(id: string): Promise<CollectionEntry<T> | null> {\n const entries = await this.getEntries();\n return entries.find((e) => e.id === id) ?? null;\n }\n\n watch?(callback: WatchCallback<T>): () => void;\n\n getChanges?(since: string): Promise<ChangeSet<T>>;\n}\n","import { glob } from \"glob\";\nimport matter from \"gray-matter\";\nimport { readFile, watch as fsWatch } from \"fs/promises\";\nimport { join, relative } from \"path\";\nimport type { CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\nimport type { FileSourceOptions } from \"./types\";\nimport { BaseSource } from \"./base\";\n\n/**\n * File system source for collections\n */\nexport class FileSource<T = unknown> extends BaseSource<T> {\n id: string;\n private directory: string;\n private include: string;\n private shouldWatch: boolean;\n private contentRoot: string;\n\n constructor(options: FileSourceOptions, contentRoot: string = process.cwd()) {\n super();\n this.directory = options.directory;\n this.include = options.include ?? \"**/*.{md,mdx}\";\n this.shouldWatch = options.watch ?? false;\n this.contentRoot = contentRoot;\n this.id = `file:${this.directory}`;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n const dir = join(this.contentRoot, this.directory);\n const pattern = join(dir, this.include);\n const files = await glob(pattern);\n\n const entries = await Promise.all(\n files.map(async (filePath) => {\n const content = await readFile(filePath, \"utf-8\");\n const { data, content: body } = matter(content);\n\n const relativePath = relative(dir, filePath);\n const id = relativePath.replace(/\\.(md|mdx)$/, \"\");\n const slug = id.replace(/\\\\/g, \"/\");\n\n return {\n id,\n slug,\n data: data as T,\n body,\n render: async () => {\n // MDX compilation will be handled by the MDX processor\n return {\n Content: () => {\n throw new Error(\"MDX rendering not yet implemented\");\n },\n };\n },\n };\n }),\n );\n\n return entries;\n }\n\n override watch(callback: WatchCallback<T>): () => void {\n if (!this.shouldWatch) {\n return () => {};\n }\n\n const dir = join(this.contentRoot, this.directory);\n const abortController = new AbortController();\n\n const startWatching = async () => {\n try {\n const watcher = fsWatch(dir, {\n recursive: true,\n signal: abortController.signal,\n });\n\n for await (const _event of watcher) {\n // Debounce and collect changes\n const entries = await this.getEntries();\n callback({\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n });\n }\n } catch (err) {\n if ((err as Error).name !== \"AbortError\") {\n throw err;\n }\n }\n };\n\n startWatching();\n\n return () => {\n abortController.abort();\n };\n }\n\n override async getChanges(_since: string): Promise<ChangeSet<T>> {\n // For file source, we do a full reload\n // A more sophisticated implementation could track file mtimes\n const entries = await this.getEntries();\n return {\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n };\n }\n}\n\n/**\n * Create a file system source\n */\nexport function fileSource<T = unknown>(\n options: FileSourceOptions,\n contentRoot?: string,\n): FileSource<T> {\n return new FileSource<T>(options, contentRoot);\n}\n","import { exec } from \"child_process\";\nimport { promisify } from \"util\";\nimport type { CollectionEntry } from \"../types\";\nimport type { GitSourceOptions, GitCommitSourceOptions, GitTagSourceOptions } from \"./types\";\nimport { BaseSource } from \"./base\";\n\nconst execAsync = promisify(exec);\n\n/**\n * Git source for collections\n */\nexport class GitSource<T = unknown> extends BaseSource<T> {\n id: string;\n private options: GitSourceOptions;\n private cwd: string;\n\n constructor(options: GitSourceOptions, cwd: string = process.cwd()) {\n super();\n this.options = options;\n this.cwd = cwd;\n this.id = `git:${options.type}`;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n if (this.options.type === \"commits\") {\n return this.getCommits(this.options);\n } else {\n return this.getTags(this.options);\n }\n }\n\n private async getCommits(options: GitCommitSourceOptions): Promise<CollectionEntry<T>[]> {\n const args = [\"log\", \"--format=%H|%s|%an|%ae|%aI\"];\n\n if (options.filter?.since) {\n args.push(`--since=${options.filter.since}`);\n }\n if (options.filter?.until) {\n args.push(`--until=${options.filter.until}`);\n }\n if (options.filter?.author) {\n args.push(`--author=${options.filter.author}`);\n }\n if (options.limit) {\n args.push(`-n`, options.limit.toString());\n }\n if (options.filter?.paths?.length) {\n args.push(\"--\", ...options.filter.paths);\n }\n\n const { stdout } = await execAsync(`git ${args.join(\" \")}`, {\n cwd: this.cwd,\n });\n const lines = stdout.trim().split(\"\\n\").filter(Boolean);\n\n return lines.map((line) => {\n const parts = line.split(\"|\");\n const hash = parts[0] ?? \"\";\n const message = parts[1] ?? \"\";\n const author = parts[2] ?? \"\";\n const email = parts[3] ?? \"\";\n const dateStr = parts[4] ?? \"\";\n\n const data = {\n hash,\n message,\n author,\n email,\n date: new Date(dateStr),\n } as unknown as T;\n\n return {\n id: hash,\n slug: hash.slice(0, 7),\n data,\n body: message,\n render: async () => ({\n Content: () => {\n throw new Error(\"Git commits cannot be rendered as content\");\n },\n }),\n };\n });\n }\n\n private async getTags(options: GitTagSourceOptions): Promise<CollectionEntry<T>[]> {\n const pattern = options.pattern ?? \"*\";\n\n // Get tags with date and message\n const { stdout } = await execAsync(\n `git tag -l \"${pattern}\" --format=\"%(refname:short)|%(objectname:short)|%(creatordate:iso)|%(contents:subject)\"`,\n { cwd: this.cwd },\n );\n\n const lines = stdout.trim().split(\"\\n\").filter(Boolean);\n\n return lines.map((line) => {\n const parts = line.split(\"|\");\n const tag = parts[0] ?? \"\";\n const hash = parts[1] ?? \"\";\n const dateStr = parts[2] ?? \"\";\n const message = parts[3] ?? \"\";\n\n const data = {\n tag,\n hash,\n date: new Date(dateStr),\n message: message || undefined,\n } as unknown as T;\n\n return {\n id: tag,\n slug: tag,\n data,\n body: message,\n render: async () => ({\n Content: () => {\n throw new Error(\"Git tags cannot be rendered as content\");\n },\n }),\n };\n });\n }\n}\n\n/**\n * Create a Git source\n */\nexport function gitSource<T = unknown>(options: GitSourceOptions, cwd?: string): GitSource<T> {\n return new GitSource<T>(options, cwd);\n}\n","import type { CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\nimport type { RemoteSourceOptions, WebhookConfig } from \"./types\";\nimport { BaseSource } from \"./base\";\n\n/**\n * Remote API source for collections\n */\nexport class RemoteSource<T = unknown> extends BaseSource<T> {\n id: string;\n private options: RemoteSourceOptions<T>;\n private pollTimer?: ReturnType<typeof setInterval>;\n\n constructor(options: RemoteSourceOptions<T>, id: string = \"remote\") {\n super();\n this.options = options;\n this.id = `remote:${id}`;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n const items = await this.options.fetch();\n\n return items.map((item, index) => {\n const id = (item as Record<string, unknown>).id?.toString() ?? index.toString();\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).content?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Remote content rendering not yet implemented\");\n },\n }),\n };\n });\n }\n\n override async getEntry(id: string): Promise<CollectionEntry<T> | null> {\n if (this.options.fetchOne) {\n const item = await this.options.fetchOne(id);\n if (!item) return null;\n\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).content?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Remote content rendering not yet implemented\");\n },\n }),\n };\n }\n\n return super.getEntry(id);\n }\n\n override watch(callback: WatchCallback<T>): () => void {\n if (this.options.pollInterval) {\n this.pollTimer = setInterval(async () => {\n const entries = await this.getEntries();\n callback({\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n });\n }, this.options.pollInterval);\n\n return () => {\n if (this.pollTimer) {\n clearInterval(this.pollTimer);\n }\n };\n }\n\n return () => {};\n }\n\n override async getChanges(since: string): Promise<ChangeSet<T>> {\n if (this.options.fetchChanges) {\n return this.options.fetchChanges(since);\n }\n\n // Fallback to full reload\n const entries = await this.getEntries();\n return {\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n };\n }\n\n /**\n * Get webhook configuration for external integration\n */\n getWebhookConfig(): WebhookConfig | undefined {\n return this.options.webhook;\n }\n}\n\n/**\n * Create a remote API source\n */\nexport function remoteSource<T = unknown>(\n options: RemoteSourceOptions<T>,\n id?: string,\n): RemoteSource<T> {\n return new RemoteSource<T>(options, id);\n}\n","import type { CollectionEntry, ChangeSet, WatchCallback } from \"../types\";\nimport type { CustomSourceOptions } from \"./types\";\nimport { BaseSource } from \"./base\";\n\n/**\n * Custom source for collections\n */\nexport class CustomSource<T = unknown> extends BaseSource<T> {\n id: string;\n private options: CustomSourceOptions<T>;\n\n constructor(options: CustomSourceOptions<T>) {\n super();\n this.options = options;\n this.id = options.id;\n }\n\n async getEntries(): Promise<CollectionEntry<T>[]> {\n const items = await this.options.getEntries();\n\n return items.map((item, index) => {\n const id = (item as Record<string, unknown>).id?.toString() ?? index.toString();\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).body?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Custom content rendering not yet implemented\");\n },\n }),\n };\n });\n }\n\n override async getEntry(id: string): Promise<CollectionEntry<T> | null> {\n if (this.options.getEntry) {\n const item = await this.options.getEntry(id);\n if (!item) return null;\n\n const slug = (item as Record<string, unknown>).slug?.toString() ?? id;\n\n return {\n id,\n slug,\n data: item,\n body: (item as Record<string, unknown>).body?.toString() ?? \"\",\n render: async () => ({\n Content: () => {\n throw new Error(\"Custom content rendering not yet implemented\");\n },\n }),\n };\n }\n\n return super.getEntry(id);\n }\n\n override watch(callback: WatchCallback<T>): () => void {\n if (this.options.watch) {\n return this.options.watch(callback);\n }\n return () => {};\n }\n\n override async getChanges(since: string): Promise<ChangeSet<T>> {\n if (this.options.getChanges) {\n return this.options.getChanges(since);\n }\n\n const entries = await this.getEntries();\n return {\n cursor: Date.now().toString(),\n added: [],\n updated: entries,\n deleted: [],\n };\n }\n}\n\n/**\n * Create a custom source\n */\nexport function createSource<T = unknown>(options: CustomSourceOptions<T>): CustomSource<T> {\n return new CustomSource<T>(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAa,mBAAqC,EAChD,UACA,QAAQ,YACR,SACA,KACA,aAEA,qBAAC;CAAK,MAAK;YACT,qBAAC;EACC,oBAAC,UAAK,SAAQ,UAAU;EACxB,oBAAC;GAAK,MAAK;GAAW,SAAQ;IAA0C;EACxE,oBAAC,qBAAO,QAAc;EACrB,KAAK,KAAK,SACT,oBAAC;GAAK,KAAI;GAAmB;IAAQ,CACrC;EACD,UAAU,OAAO,SAAS,KAAK,oBAAC,qBAAO,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,aAAgB,QAAQ"}
@@ -122,6 +122,13 @@ function createElement(tagName) {
122
122
  children: []
123
123
  };
124
124
  if (tagName === "text") yogaNode.setMeasureFunc(measureTextNode.bind(null, element));
125
+ if (tagName === "row") {
126
+ yogaNode.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
127
+ element.style.flexDirection = "row";
128
+ } else if (tagName === "column") {
129
+ yogaNode.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
130
+ element.style.flexDirection = "column";
131
+ }
125
132
  return element;
126
133
  }
127
134
  /**
@@ -292,8 +299,11 @@ function collectText(node) {
292
299
  return text;
293
300
  }
294
301
  /**
295
- * Measure text node for Yoga layout
296
- * This is called by Yoga when calculating layout
302
+ * Measure text node for Yoga layout.
303
+ * Called by Yoga during layout calculation.
304
+ *
305
+ * Yoga passes (width, widthMode, height, heightMode) but we only use
306
+ * width. In MEASURE_MODE_UNDEFINED, width is NaN — return natural size.
297
307
  */
298
308
  function measureTextNode(node, width) {
299
309
  const text = collectText(node);
@@ -303,11 +313,7 @@ function measureTextNode(node, width) {
303
313
  };
304
314
  const textWidth = stringWidth(text);
305
315
  const height = text.split("\n").length;
306
- if (textWidth <= width) return {
307
- width: textWidth,
308
- height
309
- };
310
- if (textWidth >= 1 && width > 0 && width < 1) return {
316
+ if (!Number.isFinite(width) || width < 1 || textWidth <= width) return {
311
317
  width: textWidth,
312
318
  height
313
319
  };
@@ -1065,6 +1071,7 @@ function render(element, options = {}) {
1065
1071
  if (process.stdin.isTTY && process.stdin.setRawMode) try {
1066
1072
  process.stdin.setRawMode(originalRawMode || false);
1067
1073
  } catch {}
1074
+ if (process.stdin.isTTY) process.stdin.unref();
1068
1075
  cleanupSubscriptions(rendered);
1069
1076
  actualRenderer.setResizeCallback(null);
1070
1077
  actualRenderer.destroy();
@@ -1379,4 +1386,4 @@ function MultiSelect({ options, onConfirm, onCancel, title, indicator = "❯", s
1379
1386
 
1380
1387
  //#endregion
1381
1388
  export { replaceNode as A, createElement as C, insertBefore as D, getParent as E, getChalkColor as F, renderBackground as M, renderBorder as N, markNodeAsDirty as O, getChalkBgColor as P, createComment as S, getNextSibling as T, renderTextElement as _, ExitHint as a, applyStyle as b, onCleanup as c, onKeypress as d, parseKeyEvent as f, TerminalRenderer as g, setSignalProperty as h, BlankLine as i, setText as j, removeChild as k, isRawModeSupported as l, setProperty as m, Spinner as n, print as o, useKeypress as p, spinnerFrames as r, render as s, MultiSelect as t, useExit as u, renderTextNode as v, createTextNode as w, collectText as x, appendChild as y };
1382
- //# sourceMappingURL=src-77V1Plyd.mjs.map
1389
+ //# sourceMappingURL=src-BRWShDE1.mjs.map