@stratal/inertia 0.0.23 → 0.0.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"quarry.mjs","names":[],"sources":["../src/vite/create-client-vite-config.ts","../src/vite/create-vite-config.ts","../src/commands/inertia-build.command.ts","../src/commands/inertia-dev.command.ts","../src/commands/inertia-install.command.ts","../src/commands/inertia-types.command.ts","../src/quarry.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\n\nexport interface TempClientViteConfigOptions {\n cwd: string\n entry?: string\n outDir?: string\n}\n\n/**\n * Emits a standalone Vite config for building the Inertia browser bundle.\n *\n * This runs as a separate `vite build` invocation BEFORE the worker build so\n * the worker's `stratal:inertia-inject-manifest` plugin has a finished\n * `<outDir>/.vite/manifest.json` to read. `@cloudflare/vite-plugin` builds its\n * environments in parallel, which made a single-config build racy — splitting\n * the two phases removes the race entirely and keeps each build minimal.\n */\nexport function writeTempClientViteConfig(options: TempClientViteConfigOptions): string {\n const configDir = join(options.cwd, 'node_modules', '.stratal')\n const configPath = join(configDir, 'vite.client.config.mjs')\n mkdirSync(dirname(configPath), { recursive: true })\n\n const entry = (options.entry ?? 'src/inertia/app.tsx').replace(/\\\\/g, '/')\n const outDir = (options.outDir ?? 'dist/client').replace(/\\\\/g, '/')\n const hasUserConfig = existsSync(join(options.cwd, 'vite.config.ts'))\n const publicDir = join(options.cwd, 'src', 'inertia', 'public').replace(/\\\\/g, '/')\n\n const content = `\nimport { mergeConfig } from 'vite'\n\nconst baseConfig = {\n publicDir: '${publicDir}',\n build: {\n outDir: '${outDir}',\n manifest: true,\n emptyOutDir: true,\n rollupOptions: {\n input: { app: '${entry}' },\n },\n },\n}\n\n${hasUserConfig\n ? `const userModule = await import('${join(options.cwd, 'vite.config.ts').replace(/\\\\/g, '/')}')\nconst userConfig = userModule.default ?? userModule\nexport default mergeConfig(userConfig, baseConfig)`\n : 'export default baseConfig'\n }\n`\n\n writeFileSync(configPath, content, 'utf-8')\n return configPath\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nexport interface TempViteConfigOptions {\n cwd: string\n server?: { port?: number; host?: boolean }\n outDir?: string\n persistTo?: string\n /**\n * Path (relative to `cwd`) to the Vite client manifest the worker bundle\n * should inline. Defaults to `dist/client/.vite/manifest.json`, matching\n * what `quarry inertia:build` emits in phase 1.\n */\n clientManifestPath?: string\n}\n\nexport function writeTempViteConfig(options: TempViteConfigOptions): string {\n const configDir = join(options.cwd, 'node_modules', '.stratal')\n const configPath = join(configDir, 'vite.config.mjs')\n mkdirSync(dirname(configPath), { recursive: true })\n\n const hasUserConfig = existsSync(join(options.cwd, 'vite.config.ts'))\n\n const serverConfig = options.server\n ? `server: { port: ${options.server.port}, host: ${options.server.host ? 'true' : 'undefined'} },`\n : ''\n\n const outDirConfig = options.outDir\n ? `outDir: '${options.outDir}',`\n : ''\n\n const cloudflareArgs = options.persistTo\n ? `{ persistState: { path: ${JSON.stringify(options.persistTo)} } }`\n : ''\n\n const stratalArgs = options.clientManifestPath\n ? `{ clientManifestPath: ${JSON.stringify(options.clientManifestPath)} }`\n : ''\n\n const content = `\nimport { mergeConfig } from 'vite'\nimport { cloudflare } from '@cloudflare/vite-plugin'\nimport { stratalInertia } from '@stratal/inertia/vite'\n\nlet inertiaPlugin = null\ntry {\n const mod = await import('@inertiajs/vite')\n const inertia = mod.default ?? mod\n inertiaPlugin = inertia()\n} catch {}\n\nconst baseConfig = {\n publicDir: 'src/inertia/public',\n plugins: [\n cloudflare(${cloudflareArgs}),\n ...(inertiaPlugin ? [inertiaPlugin] : []),\n ...stratalInertia(${stratalArgs}),\n ],\n build: {\n ${outDirConfig}\n },\n ${serverConfig}\n}\n\n${hasUserConfig\n ? `const userModule = await import('${join(options.cwd, 'vite.config.ts').replace(/\\\\/g, '/')}')\nconst userConfig = userModule.default ?? userModule\nexport default mergeConfig(baseConfig, userConfig)`\n : 'export default baseConfig'\n }\n`\n\n writeFileSync(configPath, content, 'utf-8')\n return configPath\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { writeTempClientViteConfig } from '../vite/create-client-vite-config'\nimport { writeTempViteConfig } from '../vite/create-vite-config'\n\nexport class InertiaBuildCommand extends Command {\n static command = 'inertia:build {--outDir=dist : Output directory} {--ssr : Also build SSR bundle}'\n static description = 'Build Inertia.js frontend for production'\n\n async handle(): Promise<number | undefined> {\n const outDir = this.string('outDir') || 'dist'\n const shouldBuildSsr = this.boolean('ssr')\n const cwd = process.cwd()\n\n const entryPath = 'src/inertia/app.tsx'\n if (!existsSync(join(cwd, entryPath))) {\n this.fail('src/inertia/app.tsx not found. Run `quarry inertia:install` first.')\n return 1\n }\n\n // Phase 1: standalone browser-bundle build. Runs without the Cloudflare\n // vite-plugin so it isn't subject to its parallel env orchestration. The\n // resulting `<clientOutDir>/.vite/manifest.json` is what the worker build\n // (phase 2) inlines into the worker entry via `stratal:inertia-inject-manifest`.\n const clientOutDir = join(outDir, 'client').replace(/\\\\/g, '/')\n const clientConfigPath = writeTempClientViteConfig({\n cwd,\n entry: entryPath,\n outDir: clientOutDir,\n })\n\n this.info('Building Inertia.js browser bundle...')\n const browserCode = await this.spawnVite(cwd, clientConfigPath, ['build'])\n if (browserCode !== 0) {\n this.fail('Browser bundle build failed.')\n return browserCode\n }\n this.success(`Browser bundle written to ${clientOutDir}/`)\n\n // Phase 2: worker build (Cloudflare vite-plugin). The injector plugin\n // reads the manifest produced in phase 1 and inlines it onto the worker\n // entry chunk.\n const configPath = writeTempViteConfig({\n cwd,\n outDir,\n clientManifestPath: join(clientOutDir, '.vite', 'manifest.json').replace(/\\\\/g, '/'),\n })\n\n this.info('Building Cloudflare worker bundle...')\n const workerCode = await this.spawnVite(cwd, configPath, ['build'])\n if (workerCode !== 0) {\n this.fail('Worker build failed.')\n return workerCode\n }\n this.success('Worker build complete!')\n\n if (shouldBuildSsr) {\n this.info('Building SSR bundle...')\n const ssrCode = await this.spawnVite(cwd, configPath, ['build', '--ssr'])\n if (ssrCode !== 0) {\n this.fail('SSR build failed.')\n return ssrCode\n }\n this.success('SSR build complete!')\n }\n\n this.success(`Output in ${outDir}/`)\n this.info('Deploy with: npx wrangler deploy')\n return 0\n }\n\n private spawnVite(cwd: string, configPath: string, args: string[]): Promise<number> {\n return new Promise((resolve) => {\n const child = spawn('npx', ['vite', '--config', configPath, ...args], {\n cwd,\n stdio: 'inherit',\n shell: true,\n })\n\n child.on('error', (err) => {\n this.fail(`Vite process error: ${err.message}`)\n resolve(1)\n })\n\n child.on('close', (code) => {\n resolve(code ?? 0)\n })\n })\n }\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { writeTempViteConfig } from '../vite/create-vite-config'\n\nexport class InertiaDevCommand extends Command {\n static command = 'inertia:dev {--port= : Dev server port} {--host : Expose to network} {--persist-to= : Shared persist directory for @cloudflare/vite-plugin (relative to cwd; the plugin appends /v3). Use to share R2/KV/cache emulator state across multiple workers in dev.}'\n static description = 'Start Inertia.js Vite development server'\n\n async handle(): Promise<number | undefined> {\n const port = this.number('port')\n const host = this.boolean('host')\n const persistTo = this.string('persist-to')\n const cwd = process.cwd()\n\n const entryPath = 'src/inertia/app.tsx'\n if (!existsSync(join(cwd, entryPath))) {\n this.fail('src/inertia/app.tsx not found. Run `quarry inertia:install` first.')\n return 1\n }\n\n const configPath = writeTempViteConfig({\n cwd,\n server: { port, host },\n persistTo,\n })\n\n this.info('Starting Vite dev server...')\n\n const args = ['vite', 'dev', '--config', configPath]\n if (host) args.push('--host')\n\n return new Promise<number>((resolve) => {\n const child = spawn('npx', args, {\n cwd,\n stdio: 'inherit',\n shell: true,\n })\n\n child.on('error', (err) => {\n this.fail(`Failed to start dev server: ${err.message}`)\n resolve(1)\n })\n\n child.on('close', (code) => {\n resolve(code ?? 0)\n })\n })\n }\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { runTypeGeneration } from '../generator/type-generator'\n\nconst ROOT_HTML = `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n @viteHead\n @inertiaHead\n</head>\n<body>\n @inertia\n @viteScripts\n</body>\n</html>`\n\nconst APP_TSX = `import { createInertiaApp } from '@inertiajs/react'\n\ncreateInertiaApp({\n resolve: async (name) => {\n const pages = import.meta.glob('./pages/**/*.tsx')\n const page = await pages[\\`./pages/\\${name}.tsx\\`]?.()\n if (!page) throw new Error(\\`Page not found: \\${name}\\`)\n return page\n },\n})`\n\nconst HOME_TSX = `export default function Home({ message }: { message: string }) {\n return (\n <div>\n <h1>{message}</h1>\n <p>This page is rendered with Inertia.js and Stratal.</p>\n </div>\n )\n}`\n\nexport class InertiaInstallCommand extends Command {\n static command = 'inertia:install {--skip-deps : Skip installing npm dependencies}'\n static description = 'Scaffold Inertia.js files for a Stratal project'\n\n async handle(): Promise<number | undefined> {\n const skipDeps = this.boolean('skip-deps')\n const cwd = process.cwd()\n const inertiaDir = join(cwd, 'src', 'inertia')\n const pagesDir = join(inertiaDir, 'pages')\n\n // Create directories\n this.info('Creating src/inertia/ directory...')\n mkdirSync(pagesDir, { recursive: true })\n\n const publicDir = join(inertiaDir, 'public')\n mkdirSync(publicDir, { recursive: true })\n const gitkeepPath = join(publicDir, '.gitkeep')\n if (!existsSync(gitkeepPath)) {\n writeFileSync(gitkeepPath, '', 'utf-8')\n }\n this.success('Created src/inertia/public/')\n\n // Write template files\n const files = [\n { path: join(inertiaDir, 'root.html'), content: ROOT_HTML, name: 'root.html' },\n { path: join(inertiaDir, 'app.tsx'), content: APP_TSX, name: 'app.tsx' },\n { path: join(pagesDir, 'Home.tsx'), content: HOME_TSX, name: 'pages/Home.tsx' },\n ]\n\n for (const file of files) {\n if (existsSync(file.path)) {\n this.warn(`Skipping ${file.name} (already exists)`)\n } else {\n writeFileSync(file.path, file.content, 'utf-8')\n this.success(`Created src/inertia/${file.name}`)\n }\n }\n\n // Modify app.module.ts\n const appModulePath = join(cwd, 'src', 'app.module.ts')\n if (existsSync(appModulePath)) {\n this.info('Updating src/app.module.ts...')\n try {\n const updated = await this.updateAppModule(appModulePath)\n if (updated) {\n this.success('Updated src/app.module.ts with InertiaModule')\n } else {\n this.info('InertiaModule already configured in app.module.ts')\n }\n } catch (err) {\n this.warn(`Could not auto-update app.module.ts: ${(err as Error).message}`)\n this.info('Please manually add InertiaModule.forRoot() to your module imports')\n }\n } else {\n this.info('No src/app.module.ts found — please manually configure InertiaModule')\n }\n\n // Generate initial type definitions\n try {\n const { outputPath, pageCount } = await runTypeGeneration(cwd)\n const relPath = relative(cwd, outputPath)\n this.success(`Generated ${relPath} (${pageCount} page${pageCount !== 1 ? 's' : ''})`)\n } catch {\n this.warn('Could not generate initial type definitions. Run `quarry inertia:types` manually.')\n }\n\n if (!skipDeps) {\n this.newLine()\n this.info('Install the following dependencies:')\n this.line(' npm install @stratal/inertia @inertiajs/react @inertiajs/vite react react-dom')\n this.line(' npm install -D @types/react @types/react-dom vite @cloudflare/vite-plugin')\n }\n\n this.newLine()\n this.success('Inertia.js scaffolding complete!')\n this.info('Run `quarry inertia:dev` to start the dev server')\n\n return 0\n }\n\n private async updateAppModule(modulePath: string): Promise<boolean> {\n const { Project, SyntaxKind } = await import('ts-morph')\n\n const project = new Project({ useInMemoryFileSystem: false })\n const sourceFile = project.addSourceFileAtPath(modulePath)\n\n // Check if InertiaModule is already imported\n const existingImport = sourceFile.getImportDeclaration((decl) =>\n decl.getModuleSpecifierValue() === '@stratal/inertia',\n )\n if (existingImport) {\n return false\n }\n\n // Add rootView import\n sourceFile.addImportDeclaration({\n defaultImport: 'rootView',\n moduleSpecifier: './inertia/root.html?raw',\n })\n\n // Add InertiaModule import\n sourceFile.addImportDeclaration({\n namedImports: ['InertiaModule'],\n moduleSpecifier: '@stratal/inertia',\n })\n\n // Find the @Module decorator and add InertiaModule to imports\n const classes = sourceFile.getClasses()\n for (const cls of classes) {\n const moduleDecorator = cls.getDecorator('Module')\n if (!moduleDecorator) continue\n\n const args = moduleDecorator.getArguments()\n if (args.length === 0) continue\n\n const objLiteral = args[0].asKind(SyntaxKind.ObjectLiteralExpression)\n if (!objLiteral) continue\n\n const importsProp = objLiteral.getProperty('imports')\n if (importsProp) {\n // Add to existing imports array\n const initializer = importsProp.asKind(SyntaxKind.PropertyAssignment)?.getInitializer()\n const arrayLiteral = initializer?.asKind(SyntaxKind.ArrayLiteralExpression)\n if (arrayLiteral) {\n arrayLiteral.addElement(`InertiaModule.forRoot({\\n rootView,\\n })`)\n }\n } else {\n // Add imports property\n objLiteral.addPropertyAssignment({\n name: 'imports',\n initializer: `[\\n InertiaModule.forRoot({\\n rootView,\\n }),\\n ]`,\n })\n }\n\n break\n }\n\n await sourceFile.save()\n return true\n }\n}\n","import { existsSync } from 'node:fs'\nimport { watch } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { findPagesDir, runTypeGeneration } from '../generator/type-generator'\n\nexport class InertiaTypesCommand extends Command {\n static command = 'inertia:types {--watch : Watch for changes and regenerate}'\n static description = 'Generate Inertia.js page type definitions'\n\n async handle(): Promise<number | undefined> {\n const cwd = process.cwd()\n const pagesDir = findPagesDir(cwd)\n\n if (!existsSync(pagesDir)) {\n this.fail('src/inertia/pages/ not found. Run `quarry inertia:install` first.')\n return 1\n }\n\n const result = await this.generate(cwd)\n if (!result) return 1\n\n if (this.boolean('watch')) {\n this.info('Watching for changes...')\n await this.watchForChanges(cwd)\n }\n\n return 0\n }\n\n private async generate(cwd: string): Promise<boolean> {\n try {\n const { outputPath, pageCount } = await runTypeGeneration(cwd)\n const relPath = relative(cwd, outputPath)\n this.success(`Generated ${relPath} (${pageCount} page${pageCount !== 1 ? 's' : ''})`)\n return true\n } catch (err) {\n this.fail(`Type generation failed: ${(err as Error).message}`)\n return false\n }\n }\n\n private async watchForChanges(cwd: string): Promise<void> {\n const srcDir = join(cwd, 'src')\n\n try {\n const watcher = watch(srcDir, { recursive: true })\n for await (const event of watcher) {\n if (event.filename && /\\.(tsx|ts)$/.test(event.filename)) {\n this.info(`Change detected: ${event.filename}`)\n await this.generate(cwd)\n }\n }\n } catch (err) {\n this.fail(`Watch failed: ${(err as Error).message}`)\n }\n }\n}\n","import { Module } from 'stratal/module'\nimport { InertiaBuildCommand } from './commands/inertia-build.command'\nimport { InertiaDevCommand } from './commands/inertia-dev.command'\nimport { InertiaInstallCommand } from './commands/inertia-install.command'\nimport { InertiaTypesCommand } from './commands/inertia-types.command'\n\n@Module({\n providers: [\n InertiaInstallCommand,\n InertiaTypesCommand,\n InertiaDevCommand,\n InertiaBuildCommand,\n ],\n})\nexport class InertiaQuarryModule {}\n\nexport { InertiaBuildCommand } from './commands/inertia-build.command'\nexport { InertiaDevCommand } from './commands/inertia-dev.command'\nexport { InertiaInstallCommand } from './commands/inertia-install.command'\nexport { InertiaTypesCommand } from './commands/inertia-types.command'\nexport { runTypeGeneration } from './generator/type-generator'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAgB,0BAA0B,SAA8C;CAEtF,MAAM,aAAa,KADD,KAAK,QAAQ,KAAK,gBAAgB,UACpB,GAAG,wBAAwB;CAC3D,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAElD,MAAM,SAAS,QAAQ,SAAS,uBAAuB,QAAQ,OAAO,GAAG;CACzE,MAAM,UAAU,QAAQ,UAAU,eAAe,QAAQ,OAAO,GAAG;CACnE,MAAM,gBAAgB,WAAW,KAAK,QAAQ,KAAK,gBAAgB,CAAC;CA0BpE,cAAc,YAAY;;;;gBAzBR,KAAK,QAAQ,KAAK,OAAO,W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AQ;CAC/C,OAAO,UAAU;CACjB,OAAO,cAAc;CAErB,MAAM,SAAsC;EAC1C,MAAM,MAAM,QAAQ,IAAI;EAGxB,IAAI,CAAC,WAFY,aAAa,GAEP,CAAC,GAAG;GACzB,KAAK,KAAK,mEAAmE;GAC7E,OAAO;EACT;EAGA,IAAI,CAAC,MADgB,KAAK,SAAS,GAAG,GACzB,OAAO;EAEpB,IAAI,KAAK,QAAQ,OAAO,GAAG;GACzB,KAAK,KAAK,yBAAyB;GACnC,MAAM,KAAK,gBAAgB,GAAG;EAChC;EAEA,OAAO;CACT;CAEA,MAAc,SAAS,KAA+B;EACpD,IAAI;GACF,MAAM,EAAE,YAAY,cAAc,MAAM,kBAAkB,GAAG;GAC7D,MAAM,UAAU,SAAS,KAAK,UAAU;GACxC,KAAK,QAAQ,aAAa,QAAQ,IAAI,UAAU,OAAO,cAAc,IAAI,MAAM,GAAG,EAAE;GACpF,OAAO;EACT,SAAS,KAAK;GACZ,KAAK,KAAK,2BAA4B,IAAc,SAAS;GAC7D,OAAO;EACT;CACF;CAEA,MAAc,gBAAgB,KAA4B;EACxD,MAAM,SAAS,KAAK,KAAK,KAAK;EAE9B,IAAI;GACF,MAAM,UAAU,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;GACjD,WAAW,MAAM,SAAS,SACxB,IAAI,MAAM,YAAY,cAAc,KAAK,MAAM,QAAQ,GAAG;IACxD,KAAK,KAAK,oBAAoB,MAAM,UAAU;IAC9C,MAAM,KAAK,SAAS,GAAG;GACzB;EAEJ,SAAS,KAAK;GACZ,KAAK,KAAK,iBAAkB,IAAc,SAAS;EACrD;CACF;AACF;;;AC3CO,IAAA,sBAAA,MAAM,oBAAoB,CAAC;kCARjC,OAAO,EACN,WAAW;CACT;CACA;CACA;CACA;AACF,EACF,CAAC,CAAA,GAAA,mBAAA"}
1
+ {"version":3,"file":"quarry.mjs","names":[],"sources":["../src/vite/create-client-vite-config.ts","../src/vite/create-vite-config.ts","../src/commands/inertia-build.command.ts","../src/commands/inertia-dev.command.ts","../src/commands/inertia-install.command.ts","../src/commands/inertia-types.command.ts","../src/quarry.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\n\nexport interface TempClientViteConfigOptions {\n cwd: string\n entry?: string\n outDir?: string\n}\n\n/**\n * Emits a standalone Vite config for building the Inertia browser bundle.\n *\n * This runs as a separate `vite build` invocation BEFORE the worker build so\n * the worker's `stratal:inertia-inject-manifest` plugin has a finished\n * `<outDir>/.vite/manifest.json` to read. `@cloudflare/vite-plugin` builds its\n * environments in parallel, which made a single-config build racy — splitting\n * the two phases removes the race entirely and keeps each build minimal.\n */\nexport function writeTempClientViteConfig(options: TempClientViteConfigOptions): string {\n const configDir = join(options.cwd, 'node_modules', '.stratal')\n const configPath = join(configDir, 'vite.client.config.mjs')\n mkdirSync(dirname(configPath), { recursive: true })\n\n const entry = (options.entry ?? 'src/inertia/app.tsx').replace(/\\\\/g, '/')\n const outDir = (options.outDir ?? 'dist/client').replace(/\\\\/g, '/')\n const hasUserConfig = existsSync(join(options.cwd, 'vite.config.ts'))\n const publicDir = join(options.cwd, 'src', 'inertia', 'public').replace(/\\\\/g, '/')\n\n const content = `\nimport { mergeConfig } from 'vite'\n\nconst baseConfig = {\n publicDir: '${publicDir}',\n build: {\n outDir: '${outDir}',\n manifest: true,\n emptyOutDir: true,\n rollupOptions: {\n input: { app: '${entry}' },\n },\n },\n}\n\n${hasUserConfig\n ? `const userModule = await import('${join(options.cwd, 'vite.config.ts').replace(/\\\\/g, '/')}')\nconst userConfig = userModule.default ?? userModule\nexport default mergeConfig(userConfig, baseConfig)`\n : 'export default baseConfig'\n }\n`\n\n writeFileSync(configPath, content, 'utf-8')\n return configPath\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nexport interface TempViteConfigOptions {\n cwd: string\n server?: { port?: number; host?: boolean }\n outDir?: string\n persistTo?: string\n /**\n * Path (relative to `cwd`) to the Vite client manifest the worker bundle\n * should inline. Defaults to `dist/client/.vite/manifest.json`, matching\n * what `quarry inertia:build` emits in phase 1.\n */\n clientManifestPath?: string\n}\n\nexport function writeTempViteConfig(options: TempViteConfigOptions): string {\n const configDir = join(options.cwd, 'node_modules', '.stratal')\n const configPath = join(configDir, 'vite.config.mjs')\n mkdirSync(dirname(configPath), { recursive: true })\n\n const hasUserConfig = existsSync(join(options.cwd, 'vite.config.ts'))\n\n const serverConfig = options.server\n ? `server: { port: ${options.server.port}, host: ${options.server.host ? 'true' : 'undefined'} },`\n : ''\n\n const outDirConfig = options.outDir\n ? `outDir: '${options.outDir}',`\n : ''\n\n const cloudflareArgs = options.persistTo\n ? `{ persistState: { path: ${JSON.stringify(options.persistTo)} } }`\n : ''\n\n const stratalArgs = options.clientManifestPath\n ? `{ clientManifestPath: ${JSON.stringify(options.clientManifestPath)} }`\n : ''\n\n const content = `\nimport { mergeConfig } from 'vite'\nimport { cloudflare } from '@cloudflare/vite-plugin'\nimport { stratalInertia } from '@stratal/inertia/vite'\n\nlet inertiaPlugin = null\ntry {\n const mod = await import('@inertiajs/vite')\n const inertia = mod.default ?? mod\n inertiaPlugin = inertia()\n} catch {}\n\nconst baseConfig = {\n publicDir: 'src/inertia/public',\n plugins: [\n cloudflare(${cloudflareArgs}),\n ...(inertiaPlugin ? [inertiaPlugin] : []),\n ...stratalInertia(${stratalArgs}),\n ],\n build: {\n ${outDirConfig}\n },\n ${serverConfig}\n}\n\n${hasUserConfig\n ? `const userModule = await import('${join(options.cwd, 'vite.config.ts').replace(/\\\\/g, '/')}')\nconst userConfig = userModule.default ?? userModule\nexport default mergeConfig(baseConfig, userConfig)`\n : 'export default baseConfig'\n }\n`\n\n writeFileSync(configPath, content, 'utf-8')\n return configPath\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { writeTempClientViteConfig } from '../vite/create-client-vite-config'\nimport { writeTempViteConfig } from '../vite/create-vite-config'\n\nexport class InertiaBuildCommand extends Command {\n static command = 'inertia:build {--outDir=dist : Output directory} {--ssr : Also build SSR bundle}'\n static description = 'Build Inertia.js frontend for production'\n\n async handle(): Promise<number | undefined> {\n const outDir = this.string('outDir') || 'dist'\n const shouldBuildSsr = this.boolean('ssr')\n const cwd = process.cwd()\n\n const entryPath = 'src/inertia/app.tsx'\n if (!existsSync(join(cwd, entryPath))) {\n this.fail('src/inertia/app.tsx not found. Run `quarry inertia:install` first.')\n return 1\n }\n\n // Phase 1: standalone browser-bundle build. Runs without the Cloudflare\n // vite-plugin so it isn't subject to its parallel env orchestration. The\n // resulting `<clientOutDir>/.vite/manifest.json` is what the worker build\n // (phase 2) inlines into the worker entry via `stratal:inertia-inject-manifest`.\n const clientOutDir = join(outDir, 'client').replace(/\\\\/g, '/')\n const clientConfigPath = writeTempClientViteConfig({\n cwd,\n entry: entryPath,\n outDir: clientOutDir,\n })\n\n this.info('Building Inertia.js browser bundle...')\n const browserCode = await this.spawnVite(cwd, clientConfigPath, ['build'])\n if (browserCode !== 0) {\n this.fail('Browser bundle build failed.')\n return browserCode\n }\n this.success(`Browser bundle written to ${clientOutDir}/`)\n\n // Phase 2: worker build (Cloudflare vite-plugin). The injector plugin\n // reads the manifest produced in phase 1 and inlines it onto the worker\n // entry chunk.\n const configPath = writeTempViteConfig({\n cwd,\n outDir,\n clientManifestPath: join(clientOutDir, '.vite', 'manifest.json').replace(/\\\\/g, '/'),\n })\n\n this.info('Building Cloudflare worker bundle...')\n const workerCode = await this.spawnVite(cwd, configPath, ['build'])\n if (workerCode !== 0) {\n this.fail('Worker build failed.')\n return workerCode\n }\n this.success('Worker build complete!')\n\n if (shouldBuildSsr) {\n this.info('Building SSR bundle...')\n const ssrCode = await this.spawnVite(cwd, configPath, ['build', '--ssr'])\n if (ssrCode !== 0) {\n this.fail('SSR build failed.')\n return ssrCode\n }\n this.success('SSR build complete!')\n }\n\n this.success(`Output in ${outDir}/`)\n this.info('Deploy with: npx wrangler deploy')\n return 0\n }\n\n private spawnVite(cwd: string, configPath: string, args: string[]): Promise<number> {\n return new Promise((resolve) => {\n const child = spawn('npx', ['vite', '--config', configPath, ...args], {\n cwd,\n stdio: 'inherit',\n shell: true,\n })\n\n child.on('error', (err) => {\n this.fail(`Vite process error: ${err.message}`)\n resolve(1)\n })\n\n child.on('close', (code) => {\n resolve(code ?? 0)\n })\n })\n }\n}\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { writeTempViteConfig } from '../vite/create-vite-config'\n\nexport class InertiaDevCommand extends Command {\n static command = 'inertia:dev {--port= : Dev server port} {--host : Expose to network} {--persist-to= : Shared persist directory for @cloudflare/vite-plugin (relative to cwd; the plugin appends /v3). Use to share R2/KV/cache emulator state across multiple workers in dev.}'\n static description = 'Start Inertia.js Vite development server'\n\n async handle(): Promise<number | undefined> {\n const port = this.number('port')\n const host = this.boolean('host')\n const persistTo = this.string('persist-to')\n const cwd = process.cwd()\n\n const entryPath = 'src/inertia/app.tsx'\n if (!existsSync(join(cwd, entryPath))) {\n this.fail('src/inertia/app.tsx not found. Run `quarry inertia:install` first.')\n return 1\n }\n\n const configPath = writeTempViteConfig({\n cwd,\n server: { port, host },\n persistTo,\n })\n\n this.info('Starting Vite dev server...')\n\n const args = ['vite', 'dev', '--config', configPath]\n if (host) args.push('--host')\n\n return new Promise<number>((resolve) => {\n const child = spawn('npx', args, {\n cwd,\n stdio: 'inherit',\n shell: true,\n })\n\n child.on('error', (err) => {\n this.fail(`Failed to start dev server: ${err.message}`)\n resolve(1)\n })\n\n child.on('close', (code) => {\n resolve(code ?? 0)\n })\n })\n }\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport type { SourceFile, SyntaxKind } from 'ts-morph'\nimport { runTypeGeneration } from '../generator/type-generator'\n\n/** Outcome of reconciling `src/app.module.ts` with the SSR-enabled InertiaModule. */\ntype AppModuleUpdate = 'created' | 'ssr-added' | 'unchanged' | 'unwired'\n/**\n * The subset of ts-morph's runtime `SyntaxKind` enum that `ensureSsrWiring` reads.\n * Declared structurally (via the enum-member literal types) so ts-morph stays a\n * type-only import here and is loaded lazily where it's actually used.\n */\ninterface SyntaxKinds {\n CallExpression: SyntaxKind.CallExpression\n ObjectLiteralExpression: SyntaxKind.ObjectLiteralExpression\n}\n\nconst ROOT_HTML = `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n @viteHead\n @inertiaHead\n</head>\n<body>\n @inertia\n @viteScripts\n</body>\n</html>`\n\nconst APP_TSX = `import { createInertiaApp } from '@inertiajs/react'\n\ncreateInertiaApp({\n resolve: async (name) => {\n const pages = import.meta.glob('./pages/**/*.tsx')\n const page = await pages[\\`./pages/\\${name}.tsx\\`]?.()\n if (!page) throw new Error(\\`Page not found: \\${name}\\`)\n return page\n },\n})`\n\nconst SSR_TSX = `import { createInertiaSsrApp } from '@stratal/inertia/ssr'\n\nexport const { render } = createInertiaSsrApp({\n resolve: async (name) => {\n const pages = import.meta.glob('./pages/**/*.tsx')\n const page = await pages[\\`./pages/\\${name}.tsx\\`]?.()\n if (!page) throw new Error(\\`Page not found: \\${name}\\`)\n return page\n },\n})`\n\nconst HOME_TSX = `export default function Home({ message }: { message: string }) {\n return (\n <div>\n <h1>{message}</h1>\n <p>This page is rendered with Inertia.js and Stratal.</p>\n </div>\n )\n}`\n\nexport class InertiaInstallCommand extends Command {\n static command = 'inertia:install {--skip-deps : Skip installing npm dependencies}'\n static description = 'Scaffold Inertia.js files for a Stratal project'\n\n async handle(): Promise<number | undefined> {\n const skipDeps = this.boolean('skip-deps')\n const cwd = process.cwd()\n const inertiaDir = join(cwd, 'src', 'inertia')\n const pagesDir = join(inertiaDir, 'pages')\n\n // Create directories\n this.info('Creating src/inertia/ directory...')\n mkdirSync(pagesDir, { recursive: true })\n\n const publicDir = join(inertiaDir, 'public')\n mkdirSync(publicDir, { recursive: true })\n const gitkeepPath = join(publicDir, '.gitkeep')\n if (!existsSync(gitkeepPath)) {\n writeFileSync(gitkeepPath, '', 'utf-8')\n }\n this.success('Created src/inertia/public/')\n\n // Write template files\n const files = [\n { path: join(inertiaDir, 'root.html'), content: ROOT_HTML, name: 'root.html' },\n { path: join(inertiaDir, 'app.tsx'), content: APP_TSX, name: 'app.tsx' },\n { path: join(inertiaDir, 'ssr.tsx'), content: SSR_TSX, name: 'ssr.tsx' },\n { path: join(pagesDir, 'Home.tsx'), content: HOME_TSX, name: 'pages/Home.tsx' },\n ]\n\n for (const file of files) {\n if (existsSync(file.path)) {\n this.warn(`Skipping ${file.name} (already exists)`)\n } else {\n writeFileSync(file.path, file.content, 'utf-8')\n this.success(`Created src/inertia/${file.name}`)\n }\n }\n\n // Modify app.module.ts\n const appModulePath = join(cwd, 'src', 'app.module.ts')\n if (existsSync(appModulePath)) {\n this.info('Updating src/app.module.ts...')\n try {\n const result = await this.updateAppModule(appModulePath)\n if (result === 'created') {\n this.success('Updated src/app.module.ts with InertiaModule')\n } else if (result === 'ssr-added') {\n this.success('Enabled streaming SSR in src/app.module.ts')\n } else if (result === 'unchanged') {\n this.info('InertiaModule (with SSR) already configured in app.module.ts')\n } else {\n this.warn('InertiaModule is configured but SSR could not be auto-wired.')\n this.info(\"Add `ssr: { bundle: () => import('./inertia/ssr') }` to your InertiaModule options\")\n }\n } catch (err) {\n this.warn(`Could not auto-update app.module.ts: ${(err as Error).message}`)\n this.info('Please manually add InertiaModule.forRoot() to your module imports')\n }\n } else {\n this.info('No src/app.module.ts found — please manually configure InertiaModule')\n }\n\n // Generate initial type definitions\n try {\n const { outputPath, pageCount } = await runTypeGeneration(cwd)\n const relPath = relative(cwd, outputPath)\n this.success(`Generated ${relPath} (${pageCount} page${pageCount !== 1 ? 's' : ''})`)\n } catch {\n this.warn('Could not generate initial type definitions. Run `quarry inertia:types` manually.')\n }\n\n if (!skipDeps) {\n this.newLine()\n this.info('Install the following dependencies:')\n this.line(' npm install @stratal/inertia @inertiajs/react @inertiajs/vite react react-dom')\n this.line(' npm install -D @types/react @types/react-dom vite @cloudflare/vite-plugin')\n }\n\n this.newLine()\n this.success('Inertia.js scaffolding complete!')\n this.info('Run `quarry inertia:dev` to start the dev server')\n\n return 0\n }\n\n private async updateAppModule(modulePath: string): Promise<AppModuleUpdate> {\n const { Project, SyntaxKind } = await import('ts-morph')\n\n const project = new Project({ useInMemoryFileSystem: false })\n const sourceFile = project.addSourceFileAtPath(modulePath)\n\n // Already importing the package — an older install that predates streaming\n // SSR. Wire the existing InertiaModule config to the SSR bundle rather than\n // bailing (which would leave SSR silently disabled).\n const existingImport = sourceFile.getImportDeclaration((decl) =>\n decl.getModuleSpecifierValue() === '@stratal/inertia',\n )\n if (existingImport) {\n const result = this.ensureSsrWiring(sourceFile, SyntaxKind)\n if (result === 'ssr-added') await sourceFile.save()\n return result\n }\n\n // Fresh install: add the imports and an InertiaModule.forRoot wired for SSR.\n sourceFile.addImportDeclaration({\n defaultImport: 'rootView',\n moduleSpecifier: './inertia/root.html?raw',\n })\n sourceFile.addImportDeclaration({\n namedImports: ['InertiaModule'],\n moduleSpecifier: '@stratal/inertia',\n })\n\n // Find the @Module decorator and add InertiaModule to imports\n const classes = sourceFile.getClasses()\n for (const cls of classes) {\n const moduleDecorator = cls.getDecorator('Module')\n if (!moduleDecorator) continue\n\n const args = moduleDecorator.getArguments()\n if (args.length === 0) continue\n\n const objLiteral = args[0].asKind(SyntaxKind.ObjectLiteralExpression)\n if (!objLiteral) continue\n\n const importsProp = objLiteral.getProperty('imports')\n if (importsProp) {\n // Add to existing imports array\n const initializer = importsProp.asKind(SyntaxKind.PropertyAssignment)?.getInitializer()\n const arrayLiteral = initializer?.asKind(SyntaxKind.ArrayLiteralExpression)\n if (arrayLiteral) {\n arrayLiteral.addElement(`InertiaModule.forRoot({\\n rootView,\\n ssr: { bundle: () => import('./inertia/ssr') },\\n })`)\n }\n } else {\n // Add imports property\n objLiteral.addPropertyAssignment({\n name: 'imports',\n initializer: `[\\n InertiaModule.forRoot({\\n rootView,\\n ssr: { bundle: () => import('./inertia/ssr') },\\n }),\\n ]`,\n })\n }\n\n break\n }\n\n await sourceFile.save()\n return 'created'\n }\n\n /**\n * Ensure an existing `InertiaModule.forRoot({...})` call opts into the streaming\n * SSR bundle. Returns `ssr-added` when the option is inserted, `unchanged` when\n * one is already present, or `unwired` when no plain `forRoot({...})` object\n * literal is found (e.g. `forRootAsync`, or a config passed by reference) — in\n * which case the caller surfaces a manual instruction.\n */\n private ensureSsrWiring(sourceFile: SourceFile, syntaxKind: SyntaxKinds): AppModuleUpdate {\n const calls = sourceFile.getDescendantsOfKind(syntaxKind.CallExpression)\n for (const call of calls) {\n if (call.getExpression().getText() !== 'InertiaModule.forRoot') continue\n\n const objLiteral = call.getArguments()[0]?.asKind(syntaxKind.ObjectLiteralExpression)\n if (!objLiteral) continue\n\n if (objLiteral.getProperty('ssr')) return 'unchanged'\n\n objLiteral.addPropertyAssignment({\n name: 'ssr',\n initializer: `{ bundle: () => import('./inertia/ssr') }`,\n })\n return 'ssr-added'\n }\n return 'unwired'\n }\n}\n","import { existsSync } from 'node:fs'\nimport { watch } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport { Command } from 'stratal/quarry'\nimport { findPagesDir, runTypeGeneration } from '../generator/type-generator'\n\nexport class InertiaTypesCommand extends Command {\n static command = 'inertia:types {--watch : Watch for changes and regenerate}'\n static description = 'Generate Inertia.js page type definitions'\n\n async handle(): Promise<number | undefined> {\n const cwd = process.cwd()\n const pagesDir = findPagesDir(cwd)\n\n if (!existsSync(pagesDir)) {\n this.fail('src/inertia/pages/ not found. Run `quarry inertia:install` first.')\n return 1\n }\n\n const result = await this.generate(cwd)\n if (!result) return 1\n\n if (this.boolean('watch')) {\n this.info('Watching for changes...')\n await this.watchForChanges(cwd)\n }\n\n return 0\n }\n\n private async generate(cwd: string): Promise<boolean> {\n try {\n const { outputPath, pageCount } = await runTypeGeneration(cwd)\n const relPath = relative(cwd, outputPath)\n this.success(`Generated ${relPath} (${pageCount} page${pageCount !== 1 ? 's' : ''})`)\n return true\n } catch (err) {\n this.fail(`Type generation failed: ${(err as Error).message}`)\n return false\n }\n }\n\n private async watchForChanges(cwd: string): Promise<void> {\n const srcDir = join(cwd, 'src')\n\n try {\n const watcher = watch(srcDir, { recursive: true })\n for await (const event of watcher) {\n if (event.filename && /\\.(tsx|ts)$/.test(event.filename)) {\n this.info(`Change detected: ${event.filename}`)\n await this.generate(cwd)\n }\n }\n } catch (err) {\n this.fail(`Watch failed: ${(err as Error).message}`)\n }\n }\n}\n","import { Module } from 'stratal/module'\nimport { InertiaBuildCommand } from './commands/inertia-build.command'\nimport { InertiaDevCommand } from './commands/inertia-dev.command'\nimport { InertiaInstallCommand } from './commands/inertia-install.command'\nimport { InertiaTypesCommand } from './commands/inertia-types.command'\n\n@Module({\n providers: [\n InertiaInstallCommand,\n InertiaTypesCommand,\n InertiaDevCommand,\n InertiaBuildCommand,\n ],\n})\nexport class InertiaQuarryModule {}\n\nexport { InertiaBuildCommand } from './commands/inertia-build.command'\nexport { InertiaDevCommand } from './commands/inertia-dev.command'\nexport { InertiaInstallCommand } from './commands/inertia-install.command'\nexport { InertiaTypesCommand } from './commands/inertia-types.command'\nexport { runTypeGeneration } from './generator/type-generator'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,SAAgB,0BAA0B,SAA8C;CAEtF,MAAM,aAAa,KADD,KAAK,QAAQ,KAAK,gBAAgB,UACpB,GAAG,wBAAwB;CAC3D,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAElD,MAAM,SAAS,QAAQ,SAAS,uBAAuB,QAAQ,OAAO,GAAG;CACzE,MAAM,UAAU,QAAQ,UAAU,eAAe,QAAQ,OAAO,GAAG;CACnE,MA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;GACF,MAAM,EAAE,YAAY,cAAc,MAAM,kBAAkB,GAAG;GAC7D,MAAM,UAAU,SAAS,KAAK,UAAU;GACxC,KAAK,QAAQ,aAAa,QAAQ,IAAI,UAAU,OAAO,cAAc,IAAI,MAAM,GAAG,EAAE;GACpF,OAAO;EACT,SAAS,KAAK;GACZ,KAAK,KAAK,2BAA4B,IAAc,SAAS;GAC7D,OAAO;EACT;CACF;CAEA,MAAc,gBAAgB,KAA4B;EACxD,MAAM,SAAS,KAAK,KAAK,KAAK;EAE9B,IAAI;GACF,MAAM,UAAU,MAAM,QAAQ,EAAE,WAAW,KAAK,CAAC;GACjD,WAAW,MAAM,SAAS,SACxB,IAAI,MAAM,YAAY,cAAc,KAAK,MAAM,QAAQ,GAAG;IACxD,KAAK,KAAK,oBAAoB,MAAM,UAAU;IAC9C,MAAM,KAAK,SAAS,GAAG;GACzB;EAEJ,SAAS,KAAK;GACZ,KAAK,KAAK,iBAAkB,IAAc,SAAS;EACrD;CACF;AACF;;;AC3CO,IAAA,sBAAA,MAAM,oBAAoB,CAAC;kCARjC,OAAO,EACN,WAAW;CACT;CACA;CACA;CACA;AACF,EACF,CAAC,CAAA,GAAA,mBAAA"}
package/dist/react.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference path="../global.d.ts" />
2
- import { g as InertiaTranslationKeys, x as SeoData } from "./types--_iJ04lT.mjs";
2
+ import { t as SeoData } from "./types-DzE1pdZs.mjs";
3
+ import { g as InertiaTranslationKeys } from "./types-BhgXhWx6.mjs";
3
4
  import { CurrentRoute, RouteMatcher, RouteName, RouteParams } from "stratal/router";
4
5
  import { MessageParams } from "stratal/i18n";
5
6
 
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.mts","names":[],"sources":["../src/react/seo.ts","../src/react/use-i18n.ts","../src/react/use-route.ts"],"mappings":";;;;;;;;;AAeA;;;iBAAgB,MAAA,IAAU,OAAO;;;iBCHjB,OAAA;WAUC,sBAAA,EAAsB,MAAA,GAAW,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCmN/C,QAAA;oBAKK,SAAA,EAAS,IAAA,EAAQ,CAAA,EAAC,MAAA,GAAW,WAAA,CAAY,CAAA;;QAOvC,SAAA;IAAA,OACG,YAAA;EAAA"}
1
+ {"version":3,"file":"react.d.mts","names":[],"sources":["../src/react/seo.ts","../src/react/use-i18n.ts","../src/react/use-route.ts"],"mappings":";;;;;;;;;;;AAeA;;iBAAgB,MAAA,IAAU,OAAO;;;iBCHjB,OAAA;WAUC,sBAAA,EAAsB,MAAA,GAAW,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCmN/C,QAAA;oBAKK,SAAA,EAAS,IAAA,EAAQ,CAAA,EAAC,MAAA,GAAW,WAAA,CAAY,CAAA;;QAOvC,SAAA;IAAA,OACG,YAAA;EAAA"}
package/dist/ssr.d.mts ADDED
@@ -0,0 +1,65 @@
1
+ import { h as InertiaSsrResult } from "./types-BhgXhWx6.mjs";
2
+ import { ComponentType, ReactNode } from "react";
3
+ import { HeadManagerTitleCallback, Page } from "@inertiajs/core";
4
+
5
+ //#region src/ssr.d.ts
6
+ /**
7
+ * The props Inertia's `App` component receives, reconstructed locally from
8
+ * `@inertiajs/core` + React types. Mirrors `@inertiajs/react`'s `InertiaAppProps`
9
+ * without importing it — see the `App` import note above for why that matters.
10
+ */
11
+ interface AppProps {
12
+ initialPage: Page;
13
+ initialComponent?: ComponentType<any>;
14
+ resolveComponent?: (name: string, page?: Page) => ComponentType<any> | Promise<ComponentType<any>>;
15
+ titleCallback?: HeadManagerTitleCallback;
16
+ onHeadUpdate?: (elements: string[]) => void;
17
+ }
18
+ /** A page component for `TProps`, or a module namespace whose `default` is one. */
19
+ type ResolvedPage<TProps> = ComponentType<TProps> | {
20
+ default: ComponentType<TProps>;
21
+ };
22
+ /**
23
+ * The resolver's return type, keyed on whether a props type argument was supplied:
24
+ * with none (`TProps` defaults to `unknown`) it stays opaque — matching what
25
+ * `import.meta.glob` yields — and with one it is the typed component/module.
26
+ */
27
+ type ResolverReturn<TProps> = [unknown] extends [TProps] ? unknown : ResolvedPage<TProps> | Promise<ResolvedPage<TProps>>;
28
+ interface CreateInertiaSsrAppOptions<TProps = unknown> {
29
+ /**
30
+ * Resolve a page by name. Typically backed by `import.meta.glob`, whose modules
31
+ * are opaque (`unknown`) — the returned value is unwrapped (a `default` export is
32
+ * taken when present) and narrowed to a component at runtime, so an invalid
33
+ * resolver result fails loudly rather than rendering nothing. Pass a props type
34
+ * argument to {@link createInertiaSsrApp} to type the resolver's return.
35
+ */
36
+ resolve: (name: string) => ResolverReturn<NoInfer<TProps>>;
37
+ /**
38
+ * Optional wrapper for application-level providers (theme, store, i18n, …).
39
+ * Receives the Inertia `App` component and its props; return the React tree to
40
+ * render. When omitted, `App` is rendered directly.
41
+ */
42
+ setup?: (args: {
43
+ App: ComponentType<AppProps>;
44
+ props: AppProps;
45
+ }) => ReactNode;
46
+ /**
47
+ * Optional document-title callback (Inertia `title`), applied to page titles.
48
+ */
49
+ title?: HeadManagerTitleCallback;
50
+ }
51
+ interface InertiaSsrApp {
52
+ render(page: Page): Promise<InertiaSsrResult>;
53
+ }
54
+ /**
55
+ * Build a streaming Inertia SSR handler.
56
+ *
57
+ * The returned `render(page)` resolves once React's shell is ready — at which
58
+ * point Inertia's `<Head>` tags have been collected — and streams the body
59
+ * progressively. Head tags rendered inside a *suspended* boundary are not
60
+ * captured; use Stratal's server-side SEO (`ctx.seo()`) for `<head>` metadata.
61
+ */
62
+ declare function createInertiaSsrApp<TProps = unknown>(options: CreateInertiaSsrAppOptions<TProps>): InertiaSsrApp;
63
+ //#endregion
64
+ export { CreateInertiaSsrAppOptions, InertiaSsrApp, createInertiaSsrApp };
65
+ //# sourceMappingURL=ssr.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr.d.mts","names":[],"sources":["../src/ssr.ts"],"mappings":";;;;;;;;;;UAqCU,QAAA;EACR,WAAA,EAAa,IAAA;EAKb,gBAAA,GAAmB,aAAA;EAEnB,gBAAA,IAAoB,IAAA,UAAc,IAAA,GAAO,IAAA,KAAS,aAAA,QAAqB,OAAA,CAAQ,aAAA;EAC/E,aAAA,GAAgB,wBAAA;EAChB,YAAA,IAAgB,QAAA;AAAA;;KAIb,YAAA,WAAuB,aAAA,CAAc,MAAA;EAAY,OAAA,EAAS,aAAA,CAAc,MAAA;AAAA;;;AAJzC;AAAA;;KAW/B,cAAA,8BAA4C,MAAA,cAE7C,YAAA,CAAa,MAAA,IAAU,OAAA,CAAQ,YAAA,CAAa,MAAA;AAAA,UAkB/B,0BAAA;EA3BW;;;;;;;EAqC1B,OAAA,GAAU,IAAA,aAAiB,cAAA,CAAe,OAAA,CAAQ,MAAA;EArCE;;;;AAA6B;EA2CjF,KAAA,IAAS,IAAA;IAAQ,GAAA,EAAK,aAAA,CAAc,QAAA;IAAW,KAAA,EAAO,QAAA;EAAA,MAAe,SAAA;EAlCtD;;;EAsCf,KAAA,GAAQ,wBAAA;AAAA;AAAA,UAGO,aAAA;EACf,MAAA,CAAO,IAAA,EAAM,IAAA,GAAO,OAAA,CAAQ,gBAAA;AAAA;;;;;;;;AA1CwB;iBAqDtC,mBAAA,mBACd,OAAA,EAAS,0BAAA,CAA2B,MAAA,IACnC,aAAA"}
package/dist/ssr.mjs ADDED
@@ -0,0 +1,56 @@
1
+ import { ApplicationError } from "stratal/errors";
2
+ import { App } from "@inertiajs/react";
3
+ import { createElement } from "react";
4
+ import { renderToReadableStream } from "react-dom/server";
5
+ //#region src/ssr.ts
6
+ /** Unwrap a module namespace's `default` export, leaving a bare component as-is. */
7
+ function unwrapDefault(module) {
8
+ return typeof module === "object" && module !== null && "default" in module ? module.default : module;
9
+ }
10
+ /**
11
+ * A React component is either a function (function/class component) or an object
12
+ * (a `memo`/`forwardRef`/`lazy` exotic component). This narrows the opaque value a
13
+ * dynamic import yields without admitting `any`.
14
+ */
15
+ function isPageComponent(value) {
16
+ return typeof value === "function" || typeof value === "object" && value !== null;
17
+ }
18
+ /**
19
+ * Build a streaming Inertia SSR handler.
20
+ *
21
+ * The returned `render(page)` resolves once React's shell is ready — at which
22
+ * point Inertia's `<Head>` tags have been collected — and streams the body
23
+ * progressively. Head tags rendered inside a *suspended* boundary are not
24
+ * captured; use Stratal's server-side SEO (`ctx.seo()`) for `<head>` metadata.
25
+ */
26
+ function createInertiaSsrApp(options) {
27
+ const resolveComponent = (name) => Promise.resolve(options.resolve(name)).then((module) => {
28
+ const component = unwrapDefault(module);
29
+ if (!isPageComponent(component)) throw new ApplicationError(`[stratal:inertia] resolve("${name}") did not return a React component.`);
30
+ return component;
31
+ });
32
+ return { async render(page) {
33
+ let head = [];
34
+ const props = {
35
+ initialPage: page,
36
+ initialComponent: await resolveComponent(page.component),
37
+ resolveComponent,
38
+ titleCallback: options.title,
39
+ onHeadUpdate: (elements) => {
40
+ head = elements;
41
+ }
42
+ };
43
+ const stream = await renderToReadableStream(options.setup ? options.setup({
44
+ App,
45
+ props
46
+ }) : createElement(App, props));
47
+ return {
48
+ head,
49
+ stream
50
+ };
51
+ } };
52
+ }
53
+ //#endregion
54
+ export { createInertiaSsrApp };
55
+
56
+ //# sourceMappingURL=ssr.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssr.mjs","names":[],"sources":["../src/ssr.ts"],"sourcesContent":["/**\n * Server-side rendering entry for Stratal Inertia.\n *\n * Provides {@link createInertiaSsrApp}, which encapsulates React 19 streaming SSR\n * (`renderToReadableStream`) and Inertia's head collection, returning the\n * `render(page)` function the `InertiaModule` SSR bundle option expects.\n *\n * This entry pulls React + `react-dom/server` into the worker SSR bundle and is\n * intentionally separate from the client (`./react`) and server (`.`) entries.\n *\n * @packageDocumentation\n */\n\nimport type { HeadManagerTitleCallback, Page } from '@inertiajs/core'\n// Import `App` as a runtime value only — never reference its *type*\n// (`typeof App`, `Parameters<typeof App>`, `ComponentProps<typeof App>`, …) in\n// this module's exported surface. Any such reference makes the emitted `.d.mts`\n// re-export `import { App } from '@inertiajs/react'`, which pulls Inertia's whole\n// type graph into resolution the moment a consumer imports this SSR entry. That\n// eagerly evaluates `@inertiajs/core`'s config-driven types (`FlashData`,\n// `SharedPageProps`, derived from its `InertiaConfig` interface) before a\n// consumer's own `declare module '@inertiajs/core'` augmentation has been\n// applied, caching the un-augmented defaults — so `usePage().flash` /\n// `usePage().props` degrade to `unknown` at call sites. Typing this entry's\n// surface structurally (below) keeps `@inertiajs/react` out of the generated\n// declarations and avoids the hazard.\nimport { App } from '@inertiajs/react'\nimport { type ComponentType, type ReactNode, createElement } from 'react'\nimport { renderToReadableStream } from 'react-dom/server'\nimport { ApplicationError } from 'stratal/errors'\nimport type { InertiaSsrResult } from './types'\n\n/**\n * The props Inertia's `App` component receives, reconstructed locally from\n * `@inertiajs/core` + React types. Mirrors `@inertiajs/react`'s `InertiaAppProps`\n * without importing it — see the `App` import note above for why that matters.\n */\ninterface AppProps {\n initialPage: Page\n // `ComponentType<any>` mirrors Inertia's own `ReactComponent` (page components\n // are resolved opaquely), keeping the resolver's `ComponentType<TProps>` output\n // assignable here without coupling to `@inertiajs/react`'s exported types.\n // oxlint-disable-next-line typescript/no-explicit-any\n initialComponent?: ComponentType<any>\n // oxlint-disable-next-line typescript/no-explicit-any\n resolveComponent?: (name: string, page?: Page) => ComponentType<any> | Promise<ComponentType<any>>\n titleCallback?: HeadManagerTitleCallback\n onHeadUpdate?: (elements: string[]) => void\n}\n\n/** A page component for `TProps`, or a module namespace whose `default` is one. */\ntype ResolvedPage<TProps> = ComponentType<TProps> | { default: ComponentType<TProps> }\n\n/**\n * The resolver's return type, keyed on whether a props type argument was supplied:\n * with none (`TProps` defaults to `unknown`) it stays opaque — matching what\n * `import.meta.glob` yields — and with one it is the typed component/module.\n */\ntype ResolverReturn<TProps> = [unknown] extends [TProps]\n ? unknown\n : ResolvedPage<TProps> | Promise<ResolvedPage<TProps>>\n\n/** Unwrap a module namespace's `default` export, leaving a bare component as-is. */\nfunction unwrapDefault(module: unknown): unknown {\n return typeof module === 'object' && module !== null && 'default' in module\n ? (module as { default: unknown }).default\n : module\n}\n\n/**\n * A React component is either a function (function/class component) or an object\n * (a `memo`/`forwardRef`/`lazy` exotic component). This narrows the opaque value a\n * dynamic import yields without admitting `any`.\n */\nfunction isPageComponent<TProps>(value: unknown): value is ComponentType<TProps> {\n return typeof value === 'function' || (typeof value === 'object' && value !== null)\n}\n\nexport interface CreateInertiaSsrAppOptions<TProps = unknown> {\n /**\n * Resolve a page by name. Typically backed by `import.meta.glob`, whose modules\n * are opaque (`unknown`) — the returned value is unwrapped (a `default` export is\n * taken when present) and narrowed to a component at runtime, so an invalid\n * resolver result fails loudly rather than rendering nothing. Pass a props type\n * argument to {@link createInertiaSsrApp} to type the resolver's return.\n */\n // `NoInfer` keeps `TProps` pinned to its explicit type argument (or the\n // `unknown` default) instead of being widened back out of the resolver return.\n resolve: (name: string) => ResolverReturn<NoInfer<TProps>>\n /**\n * Optional wrapper for application-level providers (theme, store, i18n, …).\n * Receives the Inertia `App` component and its props; return the React tree to\n * render. When omitted, `App` is rendered directly.\n */\n setup?: (args: { App: ComponentType<AppProps>; props: AppProps }) => ReactNode\n /**\n * Optional document-title callback (Inertia `title`), applied to page titles.\n */\n title?: HeadManagerTitleCallback\n}\n\nexport interface InertiaSsrApp {\n render(page: Page): Promise<InertiaSsrResult>\n}\n\n/**\n * Build a streaming Inertia SSR handler.\n *\n * The returned `render(page)` resolves once React's shell is ready — at which\n * point Inertia's `<Head>` tags have been collected — and streams the body\n * progressively. Head tags rendered inside a *suspended* boundary are not\n * captured; use Stratal's server-side SEO (`ctx.seo()`) for `<head>` metadata.\n */\nexport function createInertiaSsrApp<TProps = unknown>(\n options: CreateInertiaSsrAppOptions<TProps>,\n): InertiaSsrApp {\n const resolveComponent = (name: string): Promise<ComponentType<TProps>> =>\n Promise.resolve(options.resolve(name)).then((module) => {\n const component = unwrapDefault(module)\n if (!isPageComponent<TProps>(component)) {\n throw new ApplicationError(`[stratal:inertia] resolve(\"${name}\") did not return a React component.`)\n }\n return component\n })\n\n return {\n async render(page: Page): Promise<InertiaSsrResult> {\n let head: string[] = []\n const initialComponent = await resolveComponent(page.component)\n const props: AppProps = {\n initialPage: page,\n initialComponent,\n resolveComponent,\n titleCallback: options.title,\n onHeadUpdate: (elements: string[]) => { head = elements },\n }\n const app = options.setup\n ? options.setup({ App, props })\n : createElement(App, props)\n const stream = await renderToReadableStream(app)\n return { head, stream }\n },\n }\n}\n"],"mappings":";;;;;;AA+DA,SAAS,cAAc,QAA0B;CAC/C,OAAO,OAAO,WAAW,YAAY,WAAW,QAAQ,aAAa,SAChE,OAAgC,UACjC;AACN;;;;;;AAOA,SAAS,gBAAwB,OAAgD;CAC/E,OAAO,OAAO,UAAU,cAAe,OAAO,UAAU,YAAY,UAAU;AAChF;;;;;;;;;AAqCA,SAAgB,oBACd,SACe;CACf,MAAM,oBAAoB,SACxB,QAAQ,QAAQ,QAAQ,QAAQ,IAAI,CAAC,EAAE,MAAM,WAAW;EACtD,MAAM,YAAY,cAAc,MAAM;EACtC,IAAI,CAAC,gBAAwB,SAAS,GACpC,MAAM,IAAI,iBAAiB,8BAA8B,KAAK,qCAAqC;EAErG,OAAO;CACT,CAAC;CAEH,OAAO,EACL,MAAM,OAAO,MAAuC;EAClD,IAAI,OAAiB,CAAC;EAEtB,MAAM,QAAkB;GACtB,aAAa;GACb,kBAAA,MAH6B,iBAAiB,KAAK,SAAS;GAI5D;GACA,eAAe,QAAQ;GACvB,eAAe,aAAuB;IAAE,OAAO;GAAS;EAC1D;EAIA,MAAM,SAAS,MAAM,uBAHT,QAAQ,QAChB,QAAQ,MAAM;GAAE;GAAK;EAAM,CAAC,IAC5B,cAAc,KAAK,KAAK,CACmB;EAC/C,OAAO;GAAE;GAAM;EAAO;CACxB,EACF;AACF"}
@@ -0,0 +1,82 @@
1
+ import { RouterContext } from "stratal/router";
2
+ import { MessageKeys } from "stratal/i18n";
3
+ import { Page, Page as InertiaPage, SharedPageProps } from "@inertiajs/core";
4
+ import { ContentfulStatusCode } from "hono/utils/http-status";
5
+
6
+ //#region src/types.d.ts
7
+ interface InertiaPageRegistry {}
8
+ interface InertiaI18nConfig {}
9
+ type InertiaTranslationKeys = InertiaI18nConfig extends {
10
+ translationKeys: infer T extends string;
11
+ } ? T : MessageKeys;
12
+ type InertiaSharedProps = SharedPageProps;
13
+ type InertiaPageComponent = keyof InertiaPageRegistry extends never ? string : Extract<keyof InertiaPageRegistry, string>;
14
+ type AllowInertiaWrappers<T> = { [K in keyof T]: T[K] | InertiaDeferredProp | InertiaMergeProp | InertiaOptionalProp | InertiaOnceProp | InertiaAlwaysProp };
15
+ type ResolvedInertiaPageProps<C extends InertiaPageComponent> = C extends keyof InertiaPageRegistry ? AllowInertiaWrappers<InertiaPageRegistry[C]> : Record<string, unknown>;
16
+ type InertiaFullPageProps<C extends InertiaPageComponent> = (C extends keyof InertiaPageRegistry ? InertiaPageRegistry[C] : Record<string, unknown>) & InertiaSharedProps;
17
+ interface InertiaRenderOptions {
18
+ encryptHistory?: boolean;
19
+ clearHistory?: boolean;
20
+ preserveFragment?: boolean;
21
+ /**
22
+ * HTTP status code to use for the rendered response. Defaults to `200`.
23
+ * Useful for rendering Inertia error pages (e.g. `Errors/404` with status 404).
24
+ */
25
+ status?: ContentfulStatusCode;
26
+ }
27
+ /**
28
+ * Streaming SSR render result. `head` carries the document `<head>` tags Inertia
29
+ * collected during the synchronous shell render (known once the shell is ready);
30
+ * `stream` is React's `renderToReadableStream` output, piped into the `#app` body.
31
+ */
32
+ interface InertiaSsrResult {
33
+ head: string[];
34
+ stream: ReadableStream<Uint8Array>;
35
+ }
36
+ interface InertiaSsrBundle {
37
+ render(page: Page): Promise<InertiaSsrResult>;
38
+ }
39
+ type SharedDataResolver = (ctx: RouterContext) => any;
40
+ interface ViteManifestEntry {
41
+ file: string;
42
+ css?: string[];
43
+ isEntry?: boolean;
44
+ imports?: string[];
45
+ dynamicImports?: string[];
46
+ src?: string;
47
+ }
48
+ type ViteManifest = Record<string, ViteManifestEntry>;
49
+ declare const INERTIA_PROP_OPTIONAL: unique symbol;
50
+ declare const INERTIA_PROP_DEFERRED: unique symbol;
51
+ declare const INERTIA_PROP_MERGE: unique symbol;
52
+ declare const INERTIA_PROP_ONCE: unique symbol;
53
+ declare const INERTIA_PROP_ALWAYS: unique symbol;
54
+ interface InertiaOptionalProp<T = unknown> {
55
+ [INERTIA_PROP_OPTIONAL]: true;
56
+ callback: () => T;
57
+ }
58
+ interface InertiaDeferredProp<T = unknown> {
59
+ [INERTIA_PROP_DEFERRED]: true;
60
+ callback: () => T;
61
+ group: string;
62
+ }
63
+ type InertiaMergeStrategy = 'append' | 'prepend' | 'deep';
64
+ interface InertiaMergeProp<T = unknown> {
65
+ [INERTIA_PROP_MERGE]: true;
66
+ callback: () => T;
67
+ strategy: InertiaMergeStrategy;
68
+ matchOn?: string;
69
+ }
70
+ interface InertiaOnceProp<T = unknown> {
71
+ [INERTIA_PROP_ONCE]: true;
72
+ callback: () => T;
73
+ expiresAt?: number | null;
74
+ key?: string;
75
+ }
76
+ interface InertiaAlwaysProp<T = unknown> {
77
+ [INERTIA_PROP_ALWAYS]: true;
78
+ callback: () => T;
79
+ }
80
+ //#endregion
81
+ export { ResolvedInertiaPageProps as _, InertiaMergeProp as a, ViteManifestEntry as b, InertiaOptionalProp as c, InertiaPageRegistry as d, InertiaRenderOptions as f, InertiaTranslationKeys as g, InertiaSsrResult as h, InertiaI18nConfig as i, InertiaPage as l, InertiaSsrBundle as m, InertiaDeferredProp as n, InertiaMergeStrategy as o, InertiaSharedProps as p, InertiaFullPageProps as r, InertiaOnceProp as s, InertiaAlwaysProp as t, InertiaPageComponent as u, SharedDataResolver as v, ViteManifest as y };
82
+ //# sourceMappingURL=types-BhgXhWx6.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BhgXhWx6.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;UAMiB,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,CAAC;EACjB,KAAA;AAAA;AAAA,KAGU,oBAAA;AAAA,UAEK,gBAAA;EAAA,CACd,kBAAA;EACD,QAAA,QAAgB,CAAA;EAChB,QAAA,EAAU,oBAAA;EACV,OAAA;AAAA;AAAA,UAGe,eAAA;EAAA,CACd,iBAAA;EACD,QAAA,QAAgB,CAAC;EACjB,SAAA;EACA,GAAA;AAAA;AAAA,UAGe,iBAAA;EAAA,CACd,mBAAA;EACD,QAAA,QAAgB,CAAC;AAAA"}
@@ -0,0 +1,76 @@
1
+ //#region src/seo/types.d.ts
2
+ /**
3
+ * Public SEO data model for `@stratal/inertia`.
4
+ *
5
+ * These types are framework-free (no DI, worker, or React imports) so the same
6
+ * definitions can be shared by the server-side {@link import('../services/seo.service').SeoService}
7
+ * and the client-side head-sync runtime.
8
+ */
9
+ /** Open Graph metadata. Maps to `<meta property="og:*">` tags. */
10
+ interface SeoOpenGraph {
11
+ title?: string;
12
+ description?: string;
13
+ image?: string;
14
+ type?: string;
15
+ url?: string;
16
+ siteName?: string;
17
+ }
18
+ /** Twitter card metadata. Maps to `<meta name="twitter:*">` tags. */
19
+ interface SeoTwitter {
20
+ card?: 'summary' | 'summary_large_image' | 'app' | 'player';
21
+ title?: string;
22
+ description?: string;
23
+ image?: string;
24
+ site?: string;
25
+ creator?: string;
26
+ }
27
+ /** A custom `<meta>` tag. Provide either `name` or `property` plus `content`. */
28
+ interface SeoMetaTag {
29
+ name?: string;
30
+ property?: string;
31
+ content: string;
32
+ }
33
+ /** A custom `<link>` tag. `rel` and `href` are required; extra attributes are passed through. */
34
+ type SeoLinkTag = {
35
+ rel: string;
36
+ href: string;
37
+ } & Record<string, string>;
38
+ /**
39
+ * SEO metadata for a page. Set per-request via `ctx.seo()` and/or as app-wide
40
+ * defaults through {@link import('../inertia.options').InertiaSeoOptions}.
41
+ */
42
+ interface SeoData {
43
+ /** Document title (`<title>`). Subject to the configured `titleTemplate`. */
44
+ title?: string;
45
+ /** Meta description (`<meta name="description">`). */
46
+ description?: string;
47
+ /** Canonical URL (`<link rel="canonical">`). */
48
+ canonical?: string;
49
+ /** Robots directive (`<meta name="robots">`), e.g. `"noindex, nofollow"`. */
50
+ robots?: string;
51
+ /** Keywords (`<meta name="keywords">`). Arrays are joined with `", "`. */
52
+ keywords?: string | string[];
53
+ /** Author (`<meta name="author">`). */
54
+ author?: string;
55
+ /** Open Graph metadata. */
56
+ openGraph?: SeoOpenGraph;
57
+ /** Twitter card metadata. */
58
+ twitter?: SeoTwitter;
59
+ /** Arbitrary additional `<meta>` tags. */
60
+ meta?: SeoMetaTag[];
61
+ /** Arbitrary additional `<link>` tags. */
62
+ link?: SeoLinkTag[];
63
+ }
64
+ /**
65
+ * A renderable description of a single head tag, produced by
66
+ * {@link import('./build-seo-tags').buildSeoTags}. The server turns these into
67
+ * HTML strings; the client turns them into DOM nodes — one source of truth.
68
+ */
69
+ interface SeoTagDescriptor {
70
+ tag: 'title' | 'meta' | 'link';
71
+ attrs: Record<string, string>;
72
+ content?: string;
73
+ }
74
+ //#endregion
75
+ export { SeoTagDescriptor as a, SeoOpenGraph as i, SeoLinkTag as n, SeoTwitter as o, SeoMetaTag as r, SeoData as t };
76
+ //# sourceMappingURL=types-DzE1pdZs.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DzE1pdZs.d.mts","names":[],"sources":["../src/seo/types.ts"],"mappings":";;AASA;;;;;;;UAAiB,YAAA;EACf,KAAA;EACA,WAAA;EACA,KAAA;EACA,IAAA;EACA,GAAA;EACA,QAAA;AAAA;;UAIe,UAAA;EACf,IAAA;EACA,KAAA;EACA,WAAA;EACA,KAAA;EACA,IAAA;EACA,OAAA;AAAA;AAIF;AAAA,UAAiB,UAAA;EACf,IAAA;EACA,QAAA;EACA,OAAA;AAAA;;KAIU,UAAA;EAAe,GAAA;EAAa,IAAA;AAAA,IAAiB,MAAM;;;;;UAM9C,OAAA;EAN8C;EAQ7D,KAAA;EAFe;EAIf,WAAA;;EAEA,SAAA;EAUU;EARV,MAAA;EAYO;EAVP,QAAA;EAUiB;EARjB,MAAA;EARA;EAUA,SAAA,GAAY,YAAA;EANZ;EAQA,OAAA,GAAU,UAAA;EAJV;EAMA,IAAA,GAAO,UAAA;EAJK;EAMZ,IAAA,GAAO,UAAA;AAAA;;;;;;UAQQ,gBAAA;EACf,GAAA;EACA,KAAA,EAAO,MAAM;EACb,OAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stratal/inertia",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Inertia.js v3 server adapter for Stratal framework — server-driven React SPAs",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -52,6 +52,10 @@
52
52
  "types": "./dist/seo-runtime.d.mts",
53
53
  "import": "./dist/seo-runtime.mjs"
54
54
  },
55
+ "./ssr": {
56
+ "types": "./dist/ssr.d.mts",
57
+ "import": "./dist/ssr.mjs"
58
+ },
55
59
  "./testing": {
56
60
  "types": "./dist/testing.d.mts",
57
61
  "import": "./dist/testing.mjs"
@@ -79,11 +83,11 @@
79
83
  "@inertiajs/core": ">=3",
80
84
  "@inertiajs/react": ">=3",
81
85
  "@inertiajs/vite": ">=3",
82
- "@stratal/testing": ">=0.0.23",
86
+ "@stratal/testing": ">=0.0.24",
83
87
  "hono": ">=4",
84
88
  "react": ">=19",
85
89
  "react-dom": ">=19",
86
- "stratal": ">=0.0.23",
90
+ "stratal": ">=0.0.24",
87
91
  "vite": ">=8",
88
92
  "vitest": ">=4"
89
93
  },