@stratal/inertia 0.0.21 → 0.0.23

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-generator-DFpha_Fp.mjs","names":[],"sources":["../src/generator/type-generator.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\n\nexport interface PageTypeInfo {\n componentName: string\n propsType: string\n}\n\nexport interface SharedDataTypeInfo {\n members: SharedDataMember[]\n}\n\nexport interface SharedDataMember {\n name: string\n type: string\n optional: boolean\n}\n\nexport interface FlashTypeInfo {\n members: { name: string; type: string }[]\n}\n\nasync function loadTsMorph() {\n return import('ts-morph')\n}\n\ntype TsMorphModule = Awaited<ReturnType<typeof loadTsMorph>>\ntype TsObj = TsMorphModule['ts']\ntype Project = InstanceType<TsMorphModule['Project']>\ntype SourceFile = InstanceType<TsMorphModule['Project']> extends { getSourceFiles(): (infer S)[] } ? S : never\ntype Node = ReturnType<SourceFile['getDescendants']>[number]\ntype Type = ReturnType<Node['getType']>\n\n// --- Shared ts-morph project creation ---\n\nasync function createProject(tsConfigPath?: string): Promise<{ project: Project; SyntaxKind: TsMorphModule['SyntaxKind']; ts: TsObj }> {\n const { Project, SyntaxKind, ts } = await loadTsMorph()\n\n const project = new Project({\n tsConfigFilePath: tsConfigPath,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: tsConfigPath ? undefined : {\n jsx: ts.JsxEmit.ReactJSX,\n esModuleInterop: true,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n module: ts.ModuleKind.ESNext,\n target: ts.ScriptTarget.ESNext,\n },\n })\n\n return { project, SyntaxKind, ts }\n}\n\n// --- Controller ctx.inertia() extraction ---\n\nconst WRAPPER_TYPE_NAMES = [\n 'InertiaDeferredProp',\n 'InertiaMergeProp',\n 'InertiaOptionalProp',\n 'InertiaOnceProp',\n 'InertiaAlwaysProp',\n]\n\nexport function extractControllerPageTypes(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n tsObj: TsObj,\n srcDir: string,\n pagesDir: string,\n): PageTypeInfo[] {\n project.addSourceFilesAtPaths(join(srcDir, '**/*.ts'))\n\n // Map from component name to all collected prop type strings (one per call site)\n const pages = new Map<string, string[]>()\n\n for (const sourceFile of project.getSourceFiles()) {\n const filePath = sourceFile.getFilePath()\n if (filePath.includes(pagesDir.replace(/\\\\/g, '/'))) continue\n // Skip test files\n if (filePath.includes('__tests__') || filePath.includes('.spec.') || filePath.includes('.test.')) continue\n\n const callExpressions = sourceFile.getDescendantsOfKind(SK.CallExpression)\n\n for (const call of callExpressions) {\n const expr = call.getExpression()\n if (!expr.isKind(SK.PropertyAccessExpression)) continue\n if (expr.getName() !== 'inertia') continue\n\n const args = call.getArguments()\n if (args.length === 0) continue\n\n // First arg must be a string literal (component name)\n const firstArg = args[0]\n if (!firstArg.isKind(SK.StringLiteral)) continue\n const componentName = firstArg.getLiteralValue()\n\n if (!pages.has(componentName)) {\n pages.set(componentName, [])\n }\n\n // Second arg is the props object\n if (args.length < 2) {\n pages.get(componentName)!.push('Record<string, never>')\n continue\n }\n\n const propsArg = args[1]\n const propsType = propsArg.getType()\n\n // Unwrap prop wrappers from each property\n if (propsType.isObject() && !propsType.isArray()) {\n const properties = propsType.getProperties()\n if (properties.length === 0) {\n pages.get(componentName)!.push('Record<string, never>')\n continue\n }\n\n const members = properties.map((prop) => {\n const decl = prop.getDeclarations()[0] ?? prop.getValueDeclaration()\n const location = decl ?? propsArg\n const isOptional = prop.isOptional()\n const propType = prop.getTypeAtLocation(location)\n const unwrapped = unwrapWrapperType(propType, tsObj, propsArg)\n return `${prop.getName()}${isOptional ? '?' : ''}: ${unwrapped}`\n })\n\n pages.get(componentName)!.push(`{ ${members.join('; ')} }`)\n } else {\n pages.get(componentName)!.push(typeToString(propsType, tsObj, propsArg))\n }\n }\n }\n\n return Array.from(pages.entries())\n .map(([componentName, typeVariants]) => {\n // Deduplicate identical variants then join with union\n const unique = [...new Set(typeVariants)]\n const propsType = unique.length === 1 ? unique[0] : unique.join(' | ')\n return { componentName, propsType }\n })\n .sort((a, b) => a.componentName.localeCompare(b.componentName))\n}\n\nfunction unwrapWrapperType(type: Type, tsObj: TsObj, fallbackLocation?: Node): string {\n if (type.isUnion()) {\n const unionTypes = type.getUnionTypes()\n const unwrapped = unionTypes\n .filter((t) => {\n const text = t.getText(undefined, tsObj.TypeFormatFlags.NoTruncation)\n return !WRAPPER_TYPE_NAMES.some((name) => text.includes(name))\n })\n .map((t) => typeToString(t, tsObj, fallbackLocation))\n\n if (unwrapped.length > 0) {\n return unwrapped.join(' | ')\n }\n }\n\n // Check if the type itself is a wrapper type — extract callback return type\n const text = type.getText(undefined, tsObj.TypeFormatFlags.NoTruncation)\n for (const wrapperName of WRAPPER_TYPE_NAMES) {\n if (text.includes(wrapperName)) {\n const callbackProp = type.getProperty('callback')\n if (callbackProp) {\n const decl = callbackProp.getDeclarations()[0] ?? callbackProp.getValueDeclaration()\n const location = decl ?? fallbackLocation\n if (!location) return 'unknown'\n const callbackType = callbackProp.getTypeAtLocation(location)\n const callSignatures = callbackType.getCallSignatures()\n if (callSignatures.length > 0) {\n return unwrapPromise(callSignatures[0].getReturnType(), tsObj, fallbackLocation)\n }\n }\n return 'unknown'\n }\n }\n\n return widenLiteralType(type, tsObj, fallbackLocation)\n}\n\nfunction unwrapPromise(type: Type, tsObj: TsObj, fallbackLocation?: Node): string {\n // `getAwaitedType()` resolves the `Awaited<T>` of any thenable — covers\n // `Promise<T>`, `PromiseLike<T>`, and branded thenables (e.g. ZenStack's\n // `ZenStackPromise<T>`) whose text doesn't start with `Promise<`.\n const awaited = type.getAwaitedType?.()\n if (awaited && awaited !== type) {\n return stripReadonly(awaited, tsObj, fallbackLocation)\n }\n return stripReadonly(type, tsObj, fallbackLocation)\n}\n\nfunction stripReadonly(type: Type, tsObj: TsObj, fallbackLocation?: Node): string {\n if (type.isTuple()) {\n const elements = type.getTupleElements()\n const parts = elements.map((e) => typeToString(e, tsObj, fallbackLocation))\n return `[${parts.join(', ')}]`\n }\n\n const text = type.getText(undefined, tsObj.TypeFormatFlags.NoTruncation)\n if (text.startsWith('readonly ') && type.isArray()) {\n const elementType = type.getArrayElementType()\n if (elementType) {\n return `Array<${typeToString(elementType, tsObj, fallbackLocation)}>`\n }\n }\n\n return typeToString(type, tsObj, fallbackLocation)\n}\n\n// --- Extract this.inertia.share() call types ---\n\nexport function extractShareCallTypes(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n tsObj: TsObj,\n srcDir: string,\n): Map<string, string> {\n const shareTypes = new Map<string, string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n const filePath = sourceFile.getFilePath()\n if (!filePath.startsWith(srcDir.replace(/\\\\/g, '/'))) continue\n if (filePath.includes('__tests__') || filePath.includes('.spec.') || filePath.includes('.test.')) continue\n\n const callExpressions = sourceFile.getDescendantsOfKind(SK.CallExpression)\n\n for (const call of callExpressions) {\n const expr = call.getExpression()\n if (!expr.isKind(SK.PropertyAccessExpression)) continue\n if (expr.getName() !== 'share') continue\n\n // Check that the object is inertia-related (this.inertia.share, inertia.share)\n const objExpr = expr.getExpression()\n const objText = objExpr.getText()\n if (!objText.includes('inertia')) continue\n\n const args = call.getArguments()\n if (args.length < 2) continue\n\n const keyArg = args[0]\n if (!keyArg.isKind(SK.StringLiteral)) continue\n const key = keyArg.getLiteralValue()\n\n if (shareTypes.has(key)) continue\n\n const valueType = widenLiteralType(args[1].getType(), tsObj)\n shareTypes.set(key, valueType)\n }\n }\n\n return shareTypes\n}\n\n// --- Detect i18n config in InertiaModule.forRoot() ---\n\n/**\n * Given the first argument of `Module.forRoot(...)` or `Module.forRootAsync(...)`,\n * return the object literal where downstream options actually live.\n *\n * - For `forRoot({...})` the literal IS the first arg.\n * - For `forRootAsync({ inject, useFactory: (...) => ({...}) })` we drill into\n * the `useFactory`'s return value:\n * `() => ({ … })` — ParenthesizedExpression → ObjectLiteral\n * `() => ({ ... } as Foo)` — AsExpression → ObjectLiteral\n * `() => { return { … } }` — Block → ReturnStatement → ObjectLiteral\n *\n * Returns `null` when nothing usable is found.\n */\nfunction resolveModuleOptionsLiteral(\n optionsArg: Node,\n SK: TsMorphModule['SyntaxKind'],\n): Node | null {\n if (!optionsArg.isKind(SK.ObjectLiteralExpression)) return null\n\n // forRootAsync wrapper: { inject, useFactory: (env) => ({ ... }) }\n const useFactoryProp = optionsArg.getProperty('useFactory')\n if (useFactoryProp?.isKind(SK.PropertyAssignment)) {\n const initializer = useFactoryProp.getInitializer()\n if (initializer?.isKind(SK.ArrowFunction) || initializer?.isKind(SK.FunctionExpression)) {\n const body = initializer.getBody()\n\n // Concise arrow body: () => ({...}) — Parenthesized\n if (body.isKind(SK.ParenthesizedExpression)) {\n const inner = unwrapAs(body.getExpression(), SK)\n if (inner?.isKind(SK.ObjectLiteralExpression)) return inner\n }\n\n // Concise arrow body returning a plain literal (rare without parens but legal)\n const unwrapped = unwrapAs(body, SK)\n if (unwrapped?.isKind(SK.ObjectLiteralExpression)) return unwrapped\n\n // Block body: { ... return {...}; }\n if (body.isKind(SK.Block)) {\n const returnStatements = body.getDescendantsOfKind(SK.ReturnStatement)\n // Walk in reverse so a later `return` wins (last-write-wins semantics)\n for (let i = returnStatements.length - 1; i >= 0; i--) {\n const ret = returnStatements[i]\n const expr = ret.getExpression()\n if (!expr) continue\n if (expr.isKind(SK.ParenthesizedExpression)) {\n const inner = unwrapAs(expr.getExpression(), SK)\n if (inner?.isKind(SK.ObjectLiteralExpression)) return inner\n continue\n }\n const direct = unwrapAs(expr, SK)\n if (direct?.isKind(SK.ObjectLiteralExpression)) return direct\n }\n }\n }\n }\n\n // Plain forRoot({...}) — the first arg IS the options literal.\n return optionsArg\n}\n\n/**\n * Strip a single `as Foo` cast if present, otherwise return the node as-is.\n * `useFactory: (env) => ({ ... } as Options)` is common in TypeScript.\n */\nfunction unwrapAs(node: Node | undefined, SK: TsMorphModule['SyntaxKind']): Node | undefined {\n if (!node) return undefined\n if (node.isKind(SK.AsExpression) || node.isKind(SK.TypeAssertionExpression)) {\n return node.getExpression()\n }\n if (node.isKind(SK.SatisfiesExpression)) {\n return node.getExpression()\n }\n return node\n}\n\nexport interface I18nDetectionResult {\n enabled: boolean\n only: string[]\n}\n\nexport function detectI18nConfig(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n srcDir: string,\n): I18nDetectionResult {\n const none: I18nDetectionResult = { enabled: false, only: [] }\n const normalizedSrcDir = srcDir.replace(/\\\\/g, '/')\n\n for (const sourceFile of project.getSourceFiles()) {\n const filePath = sourceFile.getFilePath()\n if (!filePath.startsWith(normalizedSrcDir)) continue\n if (filePath.includes('__tests__') || filePath.includes('.spec.') || filePath.includes('.test.')) continue\n\n const callExpressions = sourceFile.getDescendantsOfKind(SK.CallExpression)\n\n for (const call of callExpressions) {\n const expr = call.getExpression()\n if (!expr.isKind(SK.PropertyAccessExpression)) continue\n\n const propName = expr.getName()\n if (propName !== 'forRoot' && propName !== 'forRootAsync') continue\n\n const objExpr = expr.getExpression()\n if (!objExpr.isKind(SK.Identifier) || objExpr.getText() !== 'InertiaModule') continue\n\n const args = call.getArguments()\n if (args.length === 0) continue\n\n // 1. AST-based: direct object literals (same-file forRoot / forRootAsync with inline useFactory)\n const optionsLiteral = resolveModuleOptionsLiteral(args[0], SK)\n if (optionsLiteral?.isKind(SK.ObjectLiteralExpression)) {\n const i18nProp = optionsLiteral.getProperty('i18n')\n if (!i18nProp) continue\n return { enabled: true, only: extractOnlyFromLiteral(i18nProp, SK) }\n }\n\n // 2. AST-based cross-file: follow identifier.asProvider() → registerAs factory\n const configLiteral = resolveConfigLiteralFromAsProvider(args[0], SK)\n if (configLiteral?.isKind(SK.ObjectLiteralExpression)) {\n const i18nProp = configLiteral.getProperty('i18n')\n if (i18nProp) return { enabled: true, only: extractOnlyFromLiteral(i18nProp, SK) }\n }\n\n // 3. Type-based fallback: check if the resolved type has an i18n property\n const optionsType = resolveOptionsType(args[0], propName)\n if (optionsType?.getProperty('i18n')) {\n return { enabled: true, only: extractOnlyFromType(optionsType, args[0]) }\n }\n }\n }\n\n return none\n}\n\nfunction resolveConfigLiteralFromAsProvider(\n arg: Node,\n SK: TsMorphModule['SyntaxKind'],\n): Node | null {\n if (!arg.isKind(SK.CallExpression)) return null\n\n const callExpr = arg.getExpression()\n if (!callExpr.isKind(SK.PropertyAccessExpression)) return null\n if (callExpr.getName() !== 'asProvider') return null\n\n const configIdentifier = callExpr.getExpression()\n if (!configIdentifier.isKind(SK.Identifier)) return null\n\n const varDecl = resolveToVariableDeclaration(configIdentifier, SK)\n if (!varDecl) return null\n\n return extractLiteralFromRegisterAs(varDecl, SK)\n}\n\nfunction resolveToVariableDeclaration(\n identifier: Node,\n SK: TsMorphModule['SyntaxKind'],\n): Node | null {\n const symbol = identifier.getSymbol()\n if (!symbol) return null\n\n for (const decl of symbol.getDeclarations()) {\n if (decl.isKind(SK.VariableDeclaration)) return decl\n\n if (decl.isKind(SK.ImportSpecifier)) {\n const sourceFile = decl.getImportDeclaration().getModuleSpecifierSourceFile()\n if (!sourceFile) continue\n\n const exportName = decl.getName()\n const exported = sourceFile.getExportedDeclarations().get(exportName)\n if (!exported) continue\n\n for (const exportDecl of exported) {\n if (exportDecl.isKind(SK.VariableDeclaration)) return exportDecl\n }\n }\n }\n\n return null\n}\n\nfunction extractLiteralFromRegisterAs(\n varDecl: Node,\n SK: TsMorphModule['SyntaxKind'],\n): Node | null {\n if (!varDecl.isKind(SK.VariableDeclaration)) return null\n\n const init = varDecl.getInitializer()\n if (!init?.isKind(SK.CallExpression)) return null\n\n const factoryArgs = init.getArguments()\n if (factoryArgs.length < 2) return null\n\n const factory = factoryArgs[1]\n if (!factory.isKind(SK.ArrowFunction) && !factory.isKind(SK.FunctionExpression)) return null\n\n const body = factory.getBody()\n\n if (body.isKind(SK.ParenthesizedExpression)) {\n const inner = unwrapAs(body.getExpression(), SK)\n if (inner?.isKind(SK.ObjectLiteralExpression)) return inner\n }\n\n const unwrapped = unwrapAs(body, SK)\n if (unwrapped?.isKind(SK.ObjectLiteralExpression)) return unwrapped\n\n if (body.isKind(SK.Block)) {\n const returnStatements = body.getDescendantsOfKind(SK.ReturnStatement)\n for (let i = returnStatements.length - 1; i >= 0; i--) {\n const ret = returnStatements[i]\n const retExpr = ret.getExpression()\n if (!retExpr) continue\n if (retExpr.isKind(SK.ParenthesizedExpression)) {\n const inner = unwrapAs(retExpr.getExpression(), SK)\n if (inner?.isKind(SK.ObjectLiteralExpression)) return inner\n continue\n }\n const direct = unwrapAs(retExpr, SK)\n if (direct?.isKind(SK.ObjectLiteralExpression)) return direct\n }\n }\n\n return null\n}\n\nfunction extractOnlyFromLiteral(i18nProp: Node, SK: TsMorphModule['SyntaxKind']): string[] {\n const only: string[] = []\n if (!i18nProp.isKind(SK.PropertyAssignment)) return only\n const init = i18nProp.getInitializer()\n if (!init?.isKind(SK.ObjectLiteralExpression)) return only\n const onlyProp = init.getProperty('only')\n if (!onlyProp?.isKind(SK.PropertyAssignment)) return only\n const onlyInit = onlyProp.getInitializer()\n if (!onlyInit?.isKind(SK.ArrayLiteralExpression)) return only\n for (const el of onlyInit.getElements()) {\n if (el.isKind(SK.StringLiteral)) {\n only.push(el.getLiteralValue())\n }\n }\n return only\n}\n\nfunction resolveOptionsType(arg: Node, methodName: string): Type | null {\n const argType = arg.getType()\n\n if (methodName === 'forRoot') {\n return argType\n }\n\n // forRootAsync: arg is FactoryProvider-shaped — drill through useFactory return type\n const useFactorySymbol = argType.getProperty('useFactory')\n if (!useFactorySymbol) return null\n\n const useFactoryType = useFactorySymbol.getTypeAtLocation(arg)\n const signatures = useFactoryType.getCallSignatures()\n if (signatures.length === 0) return null\n\n const returnType = signatures[0].getReturnType()\n\n // Return type is T | Promise<T> — find the branch with i18n\n if (returnType.isUnion()) {\n for (const member of returnType.getUnionTypes()) {\n if (member.getProperty('i18n')) return member\n }\n return null\n }\n\n return returnType\n}\n\nfunction extractOnlyFromType(optionsType: Type, locationNode: Node): string[] {\n const i18nSymbol = optionsType.getProperty('i18n')\n if (!i18nSymbol) return []\n\n const i18nType = i18nSymbol.getTypeAtLocation(locationNode)\n const onlySymbol = i18nType.getProperty('only')\n if (!onlySymbol) return []\n\n const onlyType = onlySymbol.getTypeAtLocation(locationNode)\n const elementType = onlyType.getNumberIndexType()\n if (!elementType) return []\n\n const result: string[] = []\n if (elementType.isUnion()) {\n for (const member of elementType.getUnionTypes()) {\n if (member.isStringLiteral()) {\n result.push(member.getLiteralValue() as string)\n }\n }\n } else if (elementType.isStringLiteral()) {\n result.push(elementType.getLiteralValue() as string)\n }\n return result\n}\n\n// --- Extract ctx.flash() call types ---\n\n/**\n * Collect every string-literal value a flash-key argument can resolve to.\n *\n * A direct string literal yields a single key. A conditional expression\n * (`cond ? 'a' : 'b'`, including nested ternaries) contributes the literals\n * from each branch. Non-literal keys (variables, template strings) yield\n * nothing — they can't be statically known.\n */\nfunction collectFlashKeyLiterals(node: Node, SK: TsMorphModule['SyntaxKind']): string[] {\n const stringLiteral = node.asKind(SK.StringLiteral)\n if (stringLiteral) return [stringLiteral.getLiteralValue()]\n\n const conditional = node.asKind(SK.ConditionalExpression)\n if (conditional) {\n return [\n ...collectFlashKeyLiterals(conditional.getWhenTrue(), SK),\n ...collectFlashKeyLiterals(conditional.getWhenFalse(), SK),\n ]\n }\n\n return []\n}\n\nexport function extractFlashTypes(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n tsObj: TsObj,\n srcDir: string,\n): FlashTypeInfo | null {\n const flashMembers = new Map<string, string>()\n\n for (const sourceFile of project.getSourceFiles()) {\n const filePath = sourceFile.getFilePath()\n if (!filePath.startsWith(srcDir.replace(/\\\\/g, '/'))) continue\n if (filePath.includes('__tests__') || filePath.includes('.spec.') || filePath.includes('.test.')) continue\n\n const callExpressions = sourceFile.getDescendantsOfKind(SK.CallExpression)\n\n for (const call of callExpressions) {\n const expr = call.getExpression()\n if (!expr.isKind(SK.PropertyAccessExpression)) continue\n if (expr.getName() !== 'flash') continue\n\n const args = call.getArguments()\n if (args.length < 2) continue\n\n // The key may be a plain string literal or a conditional expression\n // selecting between several literals (e.g. `cond ? 'success' : 'error'`).\n // Every literal a branch can produce is a real flash key.\n const keys = collectFlashKeyLiterals(args[0], SK)\n if (keys.length === 0) continue\n\n const valueType = widenLiteralType(args[1].getType(), tsObj)\n for (const key of keys) {\n if (flashMembers.has(key)) continue\n flashMembers.set(key, valueType)\n }\n }\n }\n\n if (flashMembers.size === 0) return null\n\n return {\n members: Array.from(flashMembers.entries()).map(([name, type]) => ({ name, type })),\n }\n}\n\n// --- Extract shared data from module config (existing, refactored) ---\n\nexport function extractSharedDataType(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n tsObj: TsObj,\n moduleFilePath: string,\n): SharedDataTypeInfo | null {\n const sourceFile = project.getSourceFile(moduleFilePath)\n ?? project.addSourceFileAtPath(moduleFilePath)\n\n const callExpressions = sourceFile.getDescendantsOfKind(SK.CallExpression)\n\n for (const call of callExpressions) {\n const expr = call.getExpression()\n if (!expr.isKind(SK.PropertyAccessExpression)) continue\n\n const propName = expr.getName()\n if (propName !== 'forRoot' && propName !== 'forRootAsync') continue\n\n const objExpr = expr.getExpression()\n if (!objExpr.isKind(SK.Identifier) || objExpr.getText() !== 'InertiaModule') continue\n\n const args = call.getArguments()\n if (args.length === 0) continue\n\n const optionsLiteral = resolveModuleOptionsLiteral(args[0], SK)\n if (!optionsLiteral || !optionsLiteral.isKind(SK.ObjectLiteralExpression)) continue\n\n const sharedDataProp = optionsLiteral.getProperty('sharedData')\n if (!sharedDataProp) continue\n\n if (!sharedDataProp.isKind(SK.PropertyAssignment)) continue\n\n const initializer = sharedDataProp.getInitializer()\n if (!initializer?.isKind(SK.ObjectLiteralExpression)) continue\n\n const members: SharedDataMember[] = []\n for (const prop of initializer.getProperties()) {\n if (!prop.isKind(SK.PropertyAssignment)) continue\n\n const name = prop.getName()\n const value = prop.getInitializer()\n if (!value) continue\n\n let valueType: string\n\n if (value.isKind(SK.ArrowFunction) || value.isKind(SK.FunctionExpression)) {\n const returnType = value.getReturnType()\n valueType = typeToString(returnType, tsObj)\n } else {\n valueType = typeToString(value.getType(), tsObj)\n }\n\n members.push({ name, type: valueType, optional: false })\n }\n\n if (members.length > 0) {\n return { members }\n }\n }\n\n return null\n}\n\n// --- Generate output ---\n\nexport interface GenerateTypesInput {\n pages: PageTypeInfo[]\n sharedData: SharedDataTypeInfo | null\n shareCallTypes: Map<string, string>\n i18n: I18nDetectionResult\n flashTypes: FlashTypeInfo | null\n}\n\nfunction componentNameToPropsTypeName(componentName: string, segmentCount = 2): string {\n const segments = componentName.split('/')\n const used = segments.slice(-segmentCount)\n return used.map(toPascalCase).join('') + 'PageProps'\n}\n\nfunction toPascalCase(segment: string): string {\n return segment\n .split(/[-_\\s]+/)\n .filter((part) => part.length > 0)\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('')\n}\n\nfunction resolvePagePropsTypeNames(pages: PageTypeInfo[]): Map<string, string> {\n const result = new Map<string, string>()\n\n // First pass: use last 2 segments\n const nameToComponents = new Map<string, string[]>()\n for (const page of pages) {\n const typeName = componentNameToPropsTypeName(page.componentName)\n const existing = nameToComponents.get(typeName) ?? []\n existing.push(page.componentName)\n nameToComponents.set(typeName, existing)\n }\n\n // Second pass: resolve collisions by using all segments\n for (const [typeName, components] of nameToComponents) {\n if (components.length === 1) {\n result.set(components[0], typeName)\n } else {\n for (const componentName of components) {\n const fullSegments = componentName.split('/').length\n result.set(componentName, componentNameToPropsTypeName(componentName, fullSegments))\n }\n }\n }\n\n return result\n}\n\nexport function generateInertiaTypes(input: GenerateTypesInput): string {\n const { pages, sharedData, shareCallTypes, i18n, flashTypes } = input\n\n // Compute type names with collision resolution\n const typeNames = resolvePagePropsTypeNames(pages)\n\n const lines: string[] = [\n '// Auto-generated by @stratal/inertia. Do not edit.',\n ]\n\n // Global page props types\n if (pages.length > 0) {\n lines.push('declare global {')\n for (const page of pages) {\n const typeName = typeNames.get(page.componentName)!\n lines.push(` type ${typeName} = ${page.propsType}`)\n }\n lines.push('}')\n lines.push('')\n }\n\n // InertiaPageRegistry augmentation referencing global types\n lines.push(\"declare module '@stratal/inertia' {\")\n lines.push(' interface InertiaPageRegistry {')\n for (const page of pages) {\n const typeName = typeNames.get(page.componentName)!\n lines.push(` '${page.componentName}': ${typeName}`)\n }\n lines.push(' }')\n if (i18n.enabled && i18n.only.length > 0) {\n const prefixUnion = i18n.only.map((p) => `'${p}'`).join(' | ')\n lines.push(' interface InertiaI18nConfig {')\n lines.push(` translationKeys: import('stratal/i18n').FilterByPrefix<import('stratal/i18n').MessageKeys, ${prefixUnion}>`)\n lines.push(' }')\n }\n lines.push('}')\n\n // Build InertiaConfig augmentation\n const configMembers: string[] = []\n\n // Flash data type\n if (flashTypes && flashTypes.members.length > 0) {\n const flashProps = flashTypes.members\n .map((m) => `${m.name}?: ${m.type}`)\n .join('; ')\n configMembers.push(` flashDataType: { ${flashProps} }`)\n }\n\n // Shared page props\n const sharedMembers: string[] = []\n\n // From module config (non-optional)\n if (sharedData) {\n for (const member of sharedData.members) {\n sharedMembers.push(` ${member.name}${member.optional ? '?' : ''}: ${member.type}`)\n }\n }\n\n // From i18n detection (non-optional)\n if (i18n.enabled) {\n sharedMembers.push(' locale: string')\n sharedMembers.push(' translations: Record<string, string>')\n }\n\n // From .share() calls (optional — per-request)\n for (const [key, type] of shareCallTypes) {\n // Skip if already declared by module config\n if (sharedData?.members.some((m) => m.name === key)) continue\n sharedMembers.push(` ${key}?: ${type}`)\n }\n\n if (sharedMembers.length > 0) {\n configMembers.push(` sharedPageProps: {\\n${sharedMembers.join('\\n')}\\n }`)\n }\n\n if (configMembers.length > 0) {\n lines.push('')\n lines.push(\"declare module '@inertiajs/core' {\")\n lines.push(' export interface InertiaConfig {')\n for (const member of configMembers) {\n lines.push(member)\n }\n lines.push(' }')\n lines.push('}')\n }\n\n lines.push('', 'export {}', '')\n\n return lines.join('\\n')\n}\n\n// --- Type string helpers ---\n\nfunction widenLiteralType(type: Type, tsObj: TsObj, fallbackLocation?: Node): string {\n if (type.isStringLiteral()) return 'string'\n if (type.isNumberLiteral()) return 'number'\n if (type.isBooleanLiteral()) return 'boolean'\n return typeToString(type, tsObj, fallbackLocation)\n}\n\nfunction typeToString(type: Type, tsObj: TsObj, fallbackLocation?: Node): string {\n // Preserve MessageKeys as InertiaTranslationKeys — narrows automatically via i18n.only augmentation\n if (type.isUnion() && type.getAliasSymbol?.()?.getName() === 'MessageKeys') {\n return \"import('@stratal/inertia').InertiaTranslationKeys\"\n }\n\n // Always expand objects/unions/intersections so getText() can't leak inline\n // index signatures (e.g. StratalRouteMap params' `[key: string]: ...`).\n if (type.isObject() || type.isUnion() || type.isIntersection()) {\n return expandTypeToInline(type, tsObj, fallbackLocation)\n }\n\n const text = type.getText(undefined, tsObj.TypeFormatFlags.NoTruncation | tsObj.TypeFormatFlags.UseFullyQualifiedType)\n\n if (text.includes('import(')) {\n return expandTypeToInline(type, tsObj, fallbackLocation)\n }\n\n return text\n}\n\nfunction expandPropertyType(\n type: Type,\n tsObj: TsObj,\n fallbackLocation: Node | undefined,\n visiting: Set<Type>,\n isOptional: boolean,\n): string {\n // The `?` marker already implies `undefined`, so strip it from the union\n // to avoid `id?: undefined | string`.\n if (isOptional && type.isUnion()) {\n const parts = type.getUnionTypes().filter((t) => !t.isUndefined())\n if (parts.length === 0) return 'undefined'\n if (parts.length === 1) return expandTypeToInline(parts[0], tsObj, fallbackLocation, visiting)\n return parts.map((t) => expandTypeToInline(t, tsObj, fallbackLocation, visiting)).join(' | ')\n }\n return expandTypeToInline(type, tsObj, fallbackLocation, visiting)\n}\n\nfunction expandTypeToInline(\n type: Type,\n tsObj: TsObj,\n fallbackLocation?: Node,\n visiting = new Set<Type>(),\n): string {\n if (visiting.has(type)) return 'unknown'\n // `boolean` is internally `true | false` — short-circuit before the union branch.\n if (type.isBoolean()) return 'boolean'\n visiting.add(type)\n try {\n if (type.isObject() && !type.isArray() && !type.isReadonlyArray()) {\n // Named global types (Date, RegExp, Map, Set, ...) — emit text as-is.\n // Expanding them iterates every method and produces garbage like\n // `{ toString: ...; getTime: ...; }` for Date.\n const symbolName = type.getSymbol()?.getName()\n const text = type.getText(undefined, tsObj.TypeFormatFlags.NoTruncation | tsObj.TypeFormatFlags.UseFullyQualifiedType)\n if (\n symbolName\n && !symbolName.startsWith('__')\n && symbolName !== 'Object'\n && !text.includes('import(')\n ) {\n return text\n }\n\n const properties = type.getProperties()\n if (properties.length === 0) {\n const stringIndexType = type.getStringIndexType()\n if (stringIndexType) {\n return `Record<string, ${expandTypeToInline(stringIndexType, tsObj, fallbackLocation, visiting)}>`\n }\n // Use `{}` not `Record<string, never>` — `never` collapses intersections.\n return '{}'\n }\n\n const members = properties.map((prop) => {\n const decl = prop.getDeclarations()[0] ?? prop.getValueDeclaration()\n const location = decl ?? fallbackLocation\n const isOptional = prop.isOptional()\n if (!location) return `${prop.getName()}${isOptional ? '?' : ''}: unknown`\n const propType = prop.getTypeAtLocation(location)\n const propTypeStr = expandPropertyType(propType, tsObj, fallbackLocation, visiting, isOptional)\n return `${prop.getName()}${isOptional ? '?' : ''}: ${propTypeStr}`\n })\n\n return `{ ${members.join('; ')} }`\n }\n\n if (type.isArray() || type.isReadonlyArray()) {\n const elementType = type.getArrayElementType()\n if (elementType) {\n const inner = expandTypeToInline(elementType, tsObj, fallbackLocation, visiting)\n return type.isReadonlyArray() ? `ReadonlyArray<${inner}>` : `Array<${inner}>`\n }\n }\n\n if (type.isUnion()) {\n if (type.getAliasSymbol?.()?.getName() === 'MessageKeys') {\n return \"import('@stratal/inertia').InertiaTranslationKeys\"\n }\n return type.getUnionTypes().map((t) => expandTypeToInline(t, tsObj, fallbackLocation, visiting)).join(' | ')\n }\n\n if (type.isIntersection()) {\n return type.getIntersectionTypes().map((t) => expandTypeToInline(t, tsObj, fallbackLocation, visiting)).join(' & ')\n }\n\n const text = type.getText(undefined, tsObj.TypeFormatFlags.NoTruncation)\n if (text.includes('import(')) {\n return 'unknown'\n }\n return text\n } finally {\n visiting.delete(type)\n }\n}\n\n// --- File path helpers ---\n\nexport function writeInertiaTypes(outputPath: string, content: string): boolean {\n if (existsSync(outputPath)) {\n try {\n if (readFileSync(outputPath, 'utf-8') === content) return false\n } catch {\n // fall through and write\n }\n }\n mkdirSync(dirname(outputPath), { recursive: true })\n const tmpPath = `${outputPath}.tmp-${process.pid}-${Date.now()}`\n writeFileSync(tmpPath, content, 'utf-8')\n renameSync(tmpPath, outputPath)\n return true\n}\n\nexport function findAppModulePath(cwd: string): string | undefined {\n const candidates = [\n join(cwd, 'src', 'app.module.ts'),\n join(cwd, 'src', 'app.module.tsx'),\n ]\n\n return candidates.find(existsSync)\n}\n\nexport function findPagesDir(cwd: string): string {\n return join(cwd, 'src', 'inertia', 'pages')\n}\n\nexport function findOutputPath(cwd: string): string {\n return join(cwd, 'src', 'inertia', 'inertia.d.ts')\n}\n\nexport function findTsConfigPath(cwd: string): string | undefined {\n const candidate = join(cwd, 'tsconfig.json')\n return existsSync(candidate) ? candidate : undefined\n}\n\n// --- Main pipeline ---\n\nexport async function runTypeGeneration(cwd: string): Promise<{ outputPath: string; pageCount: number }> {\n const pagesDir = findPagesDir(cwd)\n const srcDir = join(cwd, 'src')\n const outputPath = findOutputPath(cwd)\n const moduleFilePath = findAppModulePath(cwd)\n const tsConfigPath = findTsConfigPath(cwd)\n\n // Single shared project for all extractors\n const { project, SyntaxKind, ts } = await createProject(tsConfigPath)\n\n // 1. Controller ctx.inertia() calls — sole source of truth for InertiaPageRegistry\n const pages = extractControllerPageTypes(project, SyntaxKind, ts, srcDir, pagesDir)\n\n // 2. Module shared data config\n const sharedData = moduleFilePath\n ? extractSharedDataType(project, SyntaxKind, ts, moduleFilePath)\n : null\n\n // 3. i18n detection (scans all source files for InertiaModule.forRoot*)\n const i18n = detectI18nConfig(project, SyntaxKind, srcDir)\n\n // 4. Per-request .share() calls\n const shareCallTypes = extractShareCallTypes(project, SyntaxKind, ts, srcDir)\n\n // 5. Flash ctx.flash() calls\n const flashTypes = extractFlashTypes(project, SyntaxKind, ts, srcDir)\n\n // 6. Generate\n const content = generateInertiaTypes({\n pages,\n sharedData,\n shareCallTypes,\n i18n,\n flashTypes,\n })\n writeInertiaTypes(outputPath, content)\n\n return { outputPath, pageCount: pages.length }\n}\n"],"mappings":";;;AAsBA,eAAe,cAAc;CAC3B,OAAO,OAAO;AAChB;AAWA,eAAe,cAAc,cAA0G;CACrI,MAAM,EAAE,SAAS,YAAY,OAAO,MAAM,YAAY;CActD,OAAO;EAAE,SAAA,IAZW,QAAQ;GAC1B,kBAAkB;GAClB,6BAA6B;GAC7B,iBAAiB,eAAe,KAAA,IAAY;IAC1C,KAAK,GAAG,QAAQ;IAChB,iBAAiB;IACjB,kBAAkB,GAAG,qBAAqB;IAC1C,QAAQ,GAAG,WAAW;IACtB,QAAQ,GAAG,aAAa;GAC1B;EACF,CAEe;EAAG;EAAY;CAAG;AACnC;AAIA,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,2BACd,SACA,IACA,OACA,QACA,UACgB;CAChB,QAAQ,sBAAsB,KAAK,QAAQ,SAAS,CAAC;CAGrD,MAAM,wBAAQ,IAAI,IAAsB;CAExC,KAAK,MAAM,cAAc,QAAQ,eAAe,GAAG;EACjD,MAAM,WAAW,WAAW,YAAY;EACxC,IAAI,SAAS,SAAS,SAAS,QAAQ,OAAO,GAAG,CAAC,GAAG;EAErD,IAAI,SAAS,SAAS,WAAW,KAAK,SAAS,SAAS,QAAQ,KAAK,SAAS,SAAS,QAAQ,GAAG;EAElG,MAAM,kBAAkB,WAAW,qBAAqB,GAAG,cAAc;EAEzE,KAAK,MAAM,QAAQ,iBAAiB;GAClC,MAAM,OAAO,KAAK,cAAc;GAChC,IAAI,CAAC,KAAK,OAAO,GAAG,wBAAwB,GAAG;GAC/C,IAAI,KAAK,QAAQ,MAAM,WAA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;AAC5C;AAEA,SAAgB,eAAe,KAAqB;CAClD,OAAO,KAAK,KAAK,OAAO,WAAW,cAAc;AACnD;AAEA,SAAgB,iBAAiB,KAAiC;CAChE,MAAM,YAAY,KAAK,KAAK,eAAe;CAC3C,OAAO,WAAW,SAAS,IAAI,YAAY,KAAA;AAC7C;AAIA,eAAsB,kBAAkB,KAAiE;CACvG,MAAM,WAAW,aAAa,GAAG;CACjC,MAAM,SAAS,KAAK,KAAK,KAAK;CAC9B,MAAM,aAAa,eAAe,GAAG;CACrC,MAAM,iBAAiB,kBAAkB,GAAG;CAI5C,MAAM,EAAE,SAAS,YAAY,OAAO,MAAM,cAHrB,iBAAiB,GAG6B,CAAC;CAGpE,MAAM,QAAQ,2BAA2B,SAAS,YAAY,IAAI,QAAQ,QAAQ;CAGlF,MAAM,aAAa,iBACf,sBAAsB,SAAS,YAAY,IAAI,cAAc,IAC7D;CAGJ,MAAM,OAAO,iBAAiB,SAAS,YAAY,MAAM;CAgBzD,kBAAkB,YAPF,qBAAqB;EACnC;EACA;EACA,gBATqB,sBAAsB,SAAS,YAAY,IAAI,MASvD;EACb;EACA,YARiB,kBAAkB,SAAS,YAAY,IAAI,MAQnD;CACX,CACoC,CAAC;CAErC,OAAO;EAAE;EAAY,WAAW,MAAM;CAAO;AAC/C"}
@@ -0,0 +1,148 @@
1
+ import { RouterContext } from "stratal/router";
2
+ import { MessageKeys } from "stratal/i18n";
3
+ import { InertiaAppSSRResponse, Page, Page as InertiaPage, SharedPageProps } from "@inertiajs/core";
4
+ import { ContentfulStatusCode } from "hono/utils/http-status";
5
+
6
+ //#region src/seo/types.d.ts
7
+ /**
8
+ * Public SEO data model for `@stratal/inertia`.
9
+ *
10
+ * These types are framework-free (no DI, worker, or React imports) so the same
11
+ * definitions can be shared by the server-side {@link import('../services/seo.service').SeoService}
12
+ * and the client-side head-sync runtime.
13
+ */
14
+ /** Open Graph metadata. Maps to `<meta property="og:*">` tags. */
15
+ interface SeoOpenGraph {
16
+ title?: string;
17
+ description?: string;
18
+ image?: string;
19
+ type?: string;
20
+ url?: string;
21
+ siteName?: string;
22
+ }
23
+ /** Twitter card metadata. Maps to `<meta name="twitter:*">` tags. */
24
+ interface SeoTwitter {
25
+ card?: 'summary' | 'summary_large_image' | 'app' | 'player';
26
+ title?: string;
27
+ description?: string;
28
+ image?: string;
29
+ site?: string;
30
+ creator?: string;
31
+ }
32
+ /** A custom `<meta>` tag. Provide either `name` or `property` plus `content`. */
33
+ interface SeoMetaTag {
34
+ name?: string;
35
+ property?: string;
36
+ content: string;
37
+ }
38
+ /** A custom `<link>` tag. `rel` and `href` are required; extra attributes are passed through. */
39
+ type SeoLinkTag = {
40
+ rel: string;
41
+ href: string;
42
+ } & Record<string, string>;
43
+ /**
44
+ * SEO metadata for a page. Set per-request via `ctx.seo()` and/or as app-wide
45
+ * defaults through {@link import('../inertia.options').InertiaSeoOptions}.
46
+ */
47
+ interface SeoData {
48
+ /** Document title (`<title>`). Subject to the configured `titleTemplate`. */
49
+ title?: string;
50
+ /** Meta description (`<meta name="description">`). */
51
+ description?: string;
52
+ /** Canonical URL (`<link rel="canonical">`). */
53
+ canonical?: string;
54
+ /** Robots directive (`<meta name="robots">`), e.g. `"noindex, nofollow"`. */
55
+ robots?: string;
56
+ /** Keywords (`<meta name="keywords">`). Arrays are joined with `", "`. */
57
+ keywords?: string | string[];
58
+ /** Author (`<meta name="author">`). */
59
+ author?: string;
60
+ /** Open Graph metadata. */
61
+ openGraph?: SeoOpenGraph;
62
+ /** Twitter card metadata. */
63
+ twitter?: SeoTwitter;
64
+ /** Arbitrary additional `<meta>` tags. */
65
+ meta?: SeoMetaTag[];
66
+ /** Arbitrary additional `<link>` tags. */
67
+ link?: SeoLinkTag[];
68
+ }
69
+ /**
70
+ * A renderable description of a single head tag, produced by
71
+ * {@link import('./build-seo-tags').buildSeoTags}. The server turns these into
72
+ * HTML strings; the client turns them into DOM nodes — one source of truth.
73
+ */
74
+ interface SeoTagDescriptor {
75
+ tag: 'title' | 'meta' | 'link';
76
+ attrs: Record<string, string>;
77
+ content?: string;
78
+ }
79
+ //#endregion
80
+ //#region src/types.d.ts
81
+ interface InertiaPageRegistry {}
82
+ interface InertiaI18nConfig {}
83
+ type InertiaTranslationKeys = InertiaI18nConfig extends {
84
+ translationKeys: infer T extends string;
85
+ } ? T : MessageKeys;
86
+ type InertiaSharedProps = SharedPageProps;
87
+ type InertiaPageComponent = keyof InertiaPageRegistry extends never ? string : Extract<keyof InertiaPageRegistry, string>;
88
+ type AllowInertiaWrappers<T> = { [K in keyof T]: T[K] | InertiaDeferredProp | InertiaMergeProp | InertiaOptionalProp | InertiaOnceProp | InertiaAlwaysProp };
89
+ type ResolvedInertiaPageProps<C extends InertiaPageComponent> = C extends keyof InertiaPageRegistry ? AllowInertiaWrappers<InertiaPageRegistry[C]> : Record<string, unknown>;
90
+ type InertiaFullPageProps<C extends InertiaPageComponent> = (C extends keyof InertiaPageRegistry ? InertiaPageRegistry[C] : Record<string, unknown>) & InertiaSharedProps;
91
+ interface InertiaRenderOptions {
92
+ encryptHistory?: boolean;
93
+ clearHistory?: boolean;
94
+ preserveFragment?: boolean;
95
+ /**
96
+ * HTTP status code to use for the rendered response. Defaults to `200`.
97
+ * Useful for rendering Inertia error pages (e.g. `Errors/404` with status 404).
98
+ */
99
+ status?: ContentfulStatusCode;
100
+ }
101
+ type InertiaSsrResult = InertiaAppSSRResponse;
102
+ interface InertiaSsrBundle {
103
+ render(page: Page): Promise<InertiaSsrResult>;
104
+ }
105
+ type SharedDataResolver = (ctx: RouterContext) => any;
106
+ interface ViteManifestEntry {
107
+ file: string;
108
+ css?: string[];
109
+ isEntry?: boolean;
110
+ imports?: string[];
111
+ dynamicImports?: string[];
112
+ src?: string;
113
+ }
114
+ type ViteManifest = Record<string, ViteManifestEntry>;
115
+ declare const INERTIA_PROP_OPTIONAL: unique symbol;
116
+ declare const INERTIA_PROP_DEFERRED: unique symbol;
117
+ declare const INERTIA_PROP_MERGE: unique symbol;
118
+ declare const INERTIA_PROP_ONCE: unique symbol;
119
+ declare const INERTIA_PROP_ALWAYS: unique symbol;
120
+ interface InertiaOptionalProp<T = unknown> {
121
+ [INERTIA_PROP_OPTIONAL]: true;
122
+ callback: () => T;
123
+ }
124
+ interface InertiaDeferredProp<T = unknown> {
125
+ [INERTIA_PROP_DEFERRED]: true;
126
+ callback: () => T;
127
+ group: string;
128
+ }
129
+ type InertiaMergeStrategy = 'append' | 'prepend' | 'deep';
130
+ interface InertiaMergeProp<T = unknown> {
131
+ [INERTIA_PROP_MERGE]: true;
132
+ callback: () => T;
133
+ strategy: InertiaMergeStrategy;
134
+ matchOn?: string;
135
+ }
136
+ interface InertiaOnceProp<T = unknown> {
137
+ [INERTIA_PROP_ONCE]: true;
138
+ callback: () => T;
139
+ expiresAt?: number | null;
140
+ key?: string;
141
+ }
142
+ interface InertiaAlwaysProp<T = unknown> {
143
+ [INERTIA_PROP_ALWAYS]: true;
144
+ callback: () => T;
145
+ }
146
+ //#endregion
147
+ export { SeoMetaTag as C, SeoTwitter as E, SeoLinkTag as S, SeoTagDescriptor as T, 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, SeoOpenGraph as w, SeoData as x, ViteManifest as y };
148
+ //# sourceMappingURL=types--_iJ04lT.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types--_iJ04lT.d.mts","names":[],"sources":["../src/seo/types.ts","../src/types.ts"],"mappings":";;;;;;;;;;;;AASA;;UAAiB,YAAA;EACf,KAAA;EACA,WAAA;EACA,KAAA;EACA,IAAA;EACA,GAAA;EACA,QAAA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qBAAqB;AAAA,UAEnC,gBAAA;EACf,MAAA,CAAO,IAAA,EAAM,IAAA,GAAO,OAAA,CAAQ,gBAAA;AAAA;AAAA,KAIlB,kBAAA,IAAsB,GAAkB,EAAb,aAAa;AAAA,UAEnC,iBAAA;EACf,IAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;EACA,cAAA;EACA,GAAA;AAAA;AAAA,KAGU,YAAA,GAAe,MAAM,SAAS,iBAAA;AAAA,cAE7B,qBAAA;AAAA,cACA,qBAAA;AAAA,cACA,kBAAA;AAAA,cACA,iBAAA;AAAA,cACA,mBAAA;AAAA,UAEI,mBAAA;EAAA,CACd,qBAAA;EACD,QAAA,QAAgB,CAAC;AAAA;AAAA,UAGF,mBAAA;EAAA,CACd,qBAAA;EACD,QAAA,QAAgB,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"}
package/dist/vite.d.mts CHANGED
@@ -14,6 +14,25 @@ declare function stratalInertiaTypes(): Plugin;
14
14
  interface StratalInertiaPluginOptions {
15
15
  /** Client entry path(s) for CSS collection (default: ['/src/inertia/app.tsx']) */
16
16
  entries?: string[];
17
+ /**
18
+ * Whether to emit sourcemaps in `vite build`. Default: `'dev-and-staging'`
19
+ * — sourcemaps in development and staging deploys for debugging, but never
20
+ * in production (which would inflate the worker upload).
21
+ *
22
+ * - `true` / `false` — force on / off
23
+ * - `'dev-and-staging'` — on unless `CLOUDFLARE_ENV === 'prod'`
24
+ */
25
+ sourcemap?: boolean | 'dev-and-staging';
26
+ /**
27
+ * Path (relative to project root) to the Vite client manifest emitted by
28
+ * the standalone browser-bundle build phase. The injector plugin reads it
29
+ * during the worker build and inlines it onto the worker entry chunk so
30
+ * `ManifestService` can resolve hashed asset URLs at runtime.
31
+ *
32
+ * Default: `'dist/client/.vite/manifest.json'` — matches the layout
33
+ * `quarry inertia:build` produces.
34
+ */
35
+ clientManifestPath?: string;
17
36
  }
18
37
  declare function stratalInertia(options?: StratalInertiaPluginOptions): Plugin[];
19
38
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite/inertia-dev-css-plugin.ts","../src/vite/inertia-types-plugin.ts","../src/vite.ts"],"mappings":";;;UAMiB,oBAAA;EACf,OAAA;AAAA;AAAA,iBAqEc,oBAAA,CAAqB,OAAA,EAAS,oBAAA,GAAuB,MAAA;;;iBCpErD,mBAAA,CAAA,GAAuB,MAAA;;;UCFtB,2BAAA;;EAEf,OAAA;AAAA;AAAA,iBAGc,cAAA,CAAe,OAAA,GAAU,2BAAA,GAA8B,MAAA"}
1
+ {"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite/inertia-dev-css-plugin.ts","../src/vite/inertia-types-plugin.ts","../src/vite.ts"],"mappings":";;;UAMiB,oBAAA;EACf,OAAO;AAAA;AAAA,iBAqEO,oBAAA,CAAqB,OAAA,EAAS,oBAAA,GAAuB,MAAM;;;iBCpE3D,mBAAA,IAAuB,MAAM;;;UCA5B,2BAAA;;EAEf,OAAA;EFHO;AAqET;;;;;;;EEzDE,SAAA;EFyDyE;;;;ACpE3E;;;;AAA6C;ECqB3C,kBAAA;AAAA;AAAA,iBAGc,cAAA,CAAe,OAAA,GAAU,2BAAA,GAA8B,MAAM"}
package/dist/vite.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { n as runTypeGeneration, t as findPagesDir } from "./type-generator-o_PxETTs.mjs";
1
+ import { n as runTypeGeneration, t as findPagesDir } from "./type-generator-DFpha_Fp.mjs";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
- import { join, relative } from "node:path";
3
+ import { isAbsolute, join, relative } from "node:path";
4
4
  import { URL as URL$1 } from "node:url";
5
5
  import { Worker } from "node:worker_threads";
6
6
  //#region src/vite/inertia-dev-css-plugin.ts
7
7
  const CSS_LANGS_RE = /\.(css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|\?)/;
8
8
  const VIRTUAL_MODULE_ID = "virtual:inertia-ssr.css";
9
- const RESOLVED_VIRTUAL_MODULE_ID = "\0" + VIRTUAL_MODULE_ID;
9
+ const RESOLVED_VIRTUAL_MODULE_ID = "\0virtual:inertia-ssr.css";
10
10
  function collectStyleUrls(server, entries) {
11
11
  const urls = [];
12
12
  const visited = /* @__PURE__ */ new Set();
@@ -207,6 +207,8 @@ function stratalInertiaTypes() {
207
207
  //#region src/vite.ts
208
208
  function stratalInertia(options) {
209
209
  const entries = options?.entries ?? ["/src/inertia/app.tsx"];
210
+ const sourcemapOption = options?.sourcemap ?? "dev-and-staging";
211
+ const sourcemap = sourcemapOption === "dev-and-staging" ? process.env.CLOUDFLARE_ENV !== "prod" && process.env.CLOUDFLARE_ENV !== "production" : sourcemapOption;
210
212
  const optimizeDepsExclude = [
211
213
  "@cloudflare/vite-plugin",
212
214
  "wrangler",
@@ -240,13 +242,23 @@ function stratalInertia(options) {
240
242
  "base64-js",
241
243
  "ieee754"
242
244
  ];
243
- const devOnlyExternals = ["ts-morph"];
245
+ const devOnlyExternals = [
246
+ "ts-morph",
247
+ /^langium($|\/)/,
248
+ /^@zenstackhq\/cli($|\/)/,
249
+ /^@zenstackhq\/language($|\/)/,
250
+ /^@zenstackhq\/sdk($|\/)/
251
+ ];
252
+ const clientManifestPath = options?.clientManifestPath ?? "dist/client/.vite/manifest.json";
244
253
  return [
245
254
  stratalInertiaDevCss({ entries }),
246
255
  stratalInertiaTypes(),
247
256
  {
248
257
  name: "stratal:optimize-deps-fix",
249
- configEnvironment(_name, env) {
258
+ config(config) {
259
+ config.publicDir ??= "src/inertia/public";
260
+ },
261
+ configEnvironment(name, env) {
250
262
  const existing = env.optimizeDeps?.exclude ?? [];
251
263
  const existingInclude = env.optimizeDeps?.include ?? [];
252
264
  env.optimizeDeps = {
@@ -262,18 +274,65 @@ function stratalInertia(options) {
262
274
  dedupe: [...existingDedupe, ...dedupe],
263
275
  noExternal: existingNoExternal === true ? true : mergedNoExternal
264
276
  };
265
- const existingExternal = env.build?.rolldownOptions?.external ?? [];
277
+ const existingExternal = env.build?.rolldownOptions?.external;
278
+ const existingExternalArray = Array.isArray(existingExternal) ? existingExternal : existingExternal != null ? [existingExternal] : [];
266
279
  env.build = {
267
280
  ...env.build,
281
+ sourcemap: env.build?.sourcemap ?? sourcemap,
268
282
  rolldownOptions: {
269
283
  ...env.build?.rolldownOptions,
270
- external: [...existingExternal, ...devOnlyExternals]
284
+ external: [...existingExternalArray, ...devOnlyExternals]
271
285
  }
272
286
  };
287
+ if (name === "client") env.build.emptyOutDir = false;
273
288
  }
274
- }
289
+ },
290
+ injectSeoRuntime({ entries }),
291
+ injectClientManifestIntoWorker({ clientManifestPath })
275
292
  ];
276
293
  }
294
+ function injectSeoRuntime(args) {
295
+ const runtime = "@stratal/inertia/seo-runtime";
296
+ const targets = args.entries.map((entry) => entry.replace(/^\//, ""));
297
+ return {
298
+ name: "stratal:inertia-inject-seo-runtime",
299
+ transform(code, id) {
300
+ const file = id.split("?")[0];
301
+ if (!targets.some((target) => file.endsWith(target))) return null;
302
+ if (code.includes(runtime)) return null;
303
+ return {
304
+ code: `import '${runtime}';\n${code}`,
305
+ map: null
306
+ };
307
+ }
308
+ };
309
+ }
310
+ function injectClientManifestIntoWorker(args) {
311
+ let projectRoot = process.cwd();
312
+ return {
313
+ name: "stratal:inertia-inject-manifest",
314
+ apply: "build",
315
+ configResolved(config) {
316
+ projectRoot = config.root;
317
+ },
318
+ generateBundle(_options, bundle) {
319
+ if (this.environment.name === "client") return;
320
+ const manifestPath = isAbsolute(args.clientManifestPath) ? args.clientManifestPath : join(projectRoot, args.clientManifestPath);
321
+ if (!existsSync(manifestPath)) this.error("@stratal/inertia: client manifest not found at " + manifestPath + ". Run `quarry inertia:build` to build the browser bundle before deploying.");
322
+ const manifestJson = readFileSync(manifestPath, "utf-8");
323
+ const manifest = JSON.parse(manifestJson);
324
+ const inlined = JSON.stringify(manifest);
325
+ const sentinel = "globalThis.__STRATAL_INERTIA_MANIFEST__";
326
+ for (const fileName of Object.keys(bundle)) {
327
+ const chunk = bundle[fileName];
328
+ if (chunk.type !== "chunk") continue;
329
+ if (!chunk.isEntry) continue;
330
+ if (chunk.code.startsWith(sentinel)) continue;
331
+ chunk.code = `${sentinel} = ${inlined};\n${chunk.code}`;
332
+ }
333
+ }
334
+ };
335
+ }
277
336
  //#endregion
278
337
  export { stratalInertia, stratalInertiaDevCss, stratalInertiaTypes };
279
338
 
package/dist/vite.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.mjs","names":["URL"],"sources":["../src/vite/inertia-dev-css-plugin.ts","../src/vite/type-gen-dispatcher.ts","../src/vite/inertia-types-plugin.ts","../src/vite.ts"],"sourcesContent":["import type { ModuleNode, Plugin, ViteDevServer } from 'vite'\n\nconst CSS_LANGS_RE = /\\.(css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|\\?)/\nconst VIRTUAL_MODULE_ID = 'virtual:inertia-ssr.css'\nconst RESOLVED_VIRTUAL_MODULE_ID = '\\0' + VIRTUAL_MODULE_ID\n\nexport interface InertiaDevCssOptions {\n entries: string[]\n}\n\nfunction collectStyleUrls(server: ViteDevServer, entries: string[]): string[] {\n const urls: string[] = []\n const visited = new Set<string>()\n\n function traverse(mod: ModuleNode) {\n if (visited.has(mod.url)) return\n visited.add(mod.url)\n\n if (CSS_LANGS_RE.test(mod.url)) {\n urls.push(mod.url)\n }\n\n for (const imported of mod.importedModules) {\n traverse(imported)\n }\n }\n\n for (const entry of entries) {\n const mod = server.moduleGraph.getModulesByFile(\n entry.startsWith('/') ? entry.slice(1) : entry,\n )\n\n if (mod) {\n for (const m of mod) {\n traverse(m)\n }\n }\n\n const urlMod = server.moduleGraph.urlToModuleMap.get(entry)\n if (urlMod) {\n traverse(urlMod)\n }\n }\n\n return urls\n}\n\nasync function collectStyle(server: ViteDevServer, entries: string[]): Promise<string> {\n for (const entry of entries) {\n try {\n await server.transformRequest(entry)\n }\n catch {\n //\n }\n }\n\n const urls = collectStyleUrls(server, entries)\n const styles: string[] = []\n\n for (const url of urls) {\n try {\n const separator = url.includes('?') ? '&' : '?'\n const result = await server.transformRequest(url + separator + 'direct')\n if (result?.code) {\n styles.push(result.code)\n }\n }\n catch {\n //\n }\n }\n\n return styles.join('\\n')\n}\n\nexport function stratalInertiaDevCss(options: InertiaDevCssOptions): Plugin {\n let server: ViteDevServer\n let cachedCss: string | null = null\n let inflight: Promise<string> | null = null\n let cacheEpoch = 0\n\n function invalidate(): void {\n cachedCss = null\n cacheEpoch++\n }\n\n async function getCss(): Promise<string> {\n if (cachedCss !== null) return cachedCss\n if (inflight) return inflight\n const epoch = cacheEpoch\n inflight = collectStyle(server, options.entries)\n .then((css) => {\n // Drop stale result if invalidated mid-flight, so the next caller re-collects.\n if (epoch === cacheEpoch) cachedCss = css\n return css\n })\n .finally(() => {\n inflight = null\n })\n return inflight\n }\n\n return {\n name: 'stratal:inertia-dev-css',\n apply: 'serve',\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n return await getCss()\n }\n },\n\n handleHotUpdate() {\n // JS/TS edits can add or remove CSS imports, which changes the SSR CSS graph\n // without the changed file itself matching CSS_LANGS_RE. Invalidate on every\n // HMR tick — collectStyle() is fast and dev-only.\n invalidate()\n },\n\n configureServer(devServer) {\n server = devServer\n\n server.middlewares.use((req, res, next) => {\n const pathname = new URL(req.url ?? '', 'http://localhost').pathname\n if (pathname !== '/__inertia/ssr-css') { next(); return; }\n\n getCss().then((css) => {\n res.setHeader('Content-Type', 'text/css')\n res.setHeader('Cache-Control', 'no-store')\n res.end(css)\n }).catch(() => {\n res.statusCode = 500\n res.end('')\n })\n })\n },\n }\n}\n","import { URL } from 'node:url'\nimport { Worker } from 'node:worker_threads'\n\nexport interface TypeGenWorkerResult {\n ok: boolean\n outputPath?: string\n pageCount?: number\n error?: string\n}\n\nexport interface TypeGenWorkerHandle {\n on(event: 'message', cb: (m: TypeGenWorkerResult) => void): this\n on(event: 'error', cb: (e: Error) => void): this\n on(event: 'exit', cb: (code: number) => void): this\n terminate(): Promise<number> | number\n}\n\nexport type TypeGenWorkerSpawner = (cwd: string) => TypeGenWorkerHandle\n\nexport interface TypeGenDispatcher {\n schedule(): void\n dispose(): Promise<void>\n}\n\nexport interface TypeGenDispatcherOptions {\n cwd: string\n spawn?: TypeGenWorkerSpawner\n debounceMs?: number\n onResult?: (result: TypeGenWorkerResult) => void\n onError?: (error: Error) => void\n}\n\nconst defaultSpawn: TypeGenWorkerSpawner = (cwd) =>\n new Worker(new URL('./generator/type-generator.worker.mjs', import.meta.url), {\n workerData: { cwd },\n })\n\nexport function createTypeGenDispatcher(options: TypeGenDispatcherOptions): TypeGenDispatcher {\n const spawn = options.spawn ?? defaultSpawn\n const debounceMs = options.debounceMs ?? 250\n\n let pendingTimer: ReturnType<typeof setTimeout> | null = null\n let inflight: TypeGenWorkerHandle | null = null\n let queued = false\n let disposed = false\n\n function fire() {\n pendingTimer = null\n if (disposed) return\n if (inflight) {\n queued = true\n return\n }\n\n const worker = spawn(options.cwd)\n inflight = worker\n\n const finish = () => {\n if (inflight === worker) inflight = null\n if (disposed) return\n if (queued) {\n queued = false\n fire()\n }\n }\n\n worker.on('message', (msg) => {\n // `exit` will follow; finish() runs there so terminate() has settled before the next spawn.\n options.onResult?.(msg)\n })\n\n worker.on('error', (err) => {\n options.onError?.(err)\n })\n\n worker.on('exit', () => {\n finish()\n })\n }\n\n return {\n schedule() {\n if (disposed) return\n if (inflight) {\n queued = true\n return\n }\n if (pendingTimer) clearTimeout(pendingTimer)\n pendingTimer = setTimeout(fire, debounceMs)\n },\n\n async dispose() {\n disposed = true\n queued = false\n if (pendingTimer) {\n clearTimeout(pendingTimer)\n pendingTimer = null\n }\n const worker = inflight\n inflight = null\n if (worker) {\n try {\n await worker.terminate()\n } catch {\n // ignore\n }\n }\n },\n }\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\nimport type { Plugin } from 'vite'\nimport { findPagesDir, runTypeGeneration } from '../generator/type-generator'\nimport { createTypeGenDispatcher, type TypeGenDispatcher } from './type-gen-dispatcher'\n\nconst INERTIA_CALL_PATTERN = /ctx\\.inertia\\(|\\.share\\(|ctx\\.flash\\(|ctx\\.defer\\(|ctx\\.optional\\(|ctx\\.merge\\(|ctx\\.once\\(|ctx\\.always\\(/\n\nexport function stratalInertiaTypes(): Plugin {\n let cwd: string\n let pagesDir: string\n let srcDir: string\n let dispatcher: TypeGenDispatcher | null = null\n\n return {\n name: 'stratal:inertia-types',\n\n configResolved(config) {\n cwd = config.root\n pagesDir = findPagesDir(cwd) + '/'\n srcDir = join(cwd, 'src') + '/'\n dispatcher = createTypeGenDispatcher({\n cwd,\n onError(err) {\n console.warn('[stratal:inertia-types] Type generation worker errored:', err.message)\n },\n onResult(result) {\n if (!result.ok && result.error) {\n console.warn('[stratal:inertia-types] Type generation failed:', result.error)\n }\n },\n })\n },\n\n async buildStart() {\n if (!existsSync(pagesDir)) return\n try {\n await runTypeGeneration(cwd)\n } catch (error) {\n console.warn('[stratal:inertia-types] Type generation failed during build:', error)\n }\n },\n\n handleHotUpdate({ file }) {\n if (!dispatcher) return\n if (!/\\.(tsx|ts)$/.test(file)) return\n\n const relToSrc = relative(srcDir, file)\n const isInSrc = !relToSrc.startsWith('..')\n\n if (!isInSrc) return\n\n // Page files always trigger regeneration\n const relToPages = relative(pagesDir, file)\n const isPageFile = !relToPages.startsWith('..')\n\n if (!isPageFile) {\n // For non-page files, only regenerate if they contain inertia-related calls\n try {\n const content = readFileSync(file, 'utf-8')\n if (!INERTIA_CALL_PATTERN.test(content)) return\n } catch {\n return\n }\n }\n\n dispatcher.schedule()\n },\n\n async closeBundle() {\n if (dispatcher) {\n await dispatcher.dispose()\n dispatcher = null\n }\n },\n }\n}\n","import type { EnvironmentOptions, Plugin } from 'vite'\nimport { stratalInertiaDevCss } from './vite/inertia-dev-css-plugin'\nimport { stratalInertiaTypes } from './vite/inertia-types-plugin'\n\nexport { stratalInertiaDevCss, stratalInertiaTypes }\n\nexport interface StratalInertiaPluginOptions {\n /** Client entry path(s) for CSS collection (default: ['/src/inertia/app.tsx']) */\n entries?: string[]\n}\n\nexport function stratalInertia(options?: StratalInertiaPluginOptions): Plugin[] {\n const entries = options?.entries ?? ['/src/inertia/app.tsx']\n\n // Hono and stratal must NOT be pre-bundled by Vite's optimizeDeps. When they are,\n // a duplicate copy ends up in `.vite/deps_<env>/` while the worker bundle imports\n // another copy from node_modules — Response objects from one instance flow into\n // a Context class from the other, and Hono's `set res` setter crashes inside\n // `this.#res.headers.entries()` because the prototype chain doesn't match.\n //\n // React 19 ships its main entry as CJS and relies on the optimizer's CJS→ESM\n // conversion, so it cannot be excluded outright. To prevent the related\n // identity-mismatch bug (two `?v=<hash>` copies after the optimizer re-runs\n // when a new dep is auto-discovered), the React-ecosystem packages are listed\n // in `resolve.noExternal` so Vite treats them as part of the user module graph\n // and `resolve.dedupe` so all imports collapse to a single physical copy.\n const optimizeDepsExclude = [\n '@cloudflare/vite-plugin',\n 'wrangler',\n 'blake3-wasm',\n '@stratal/inertia',\n 'stratal',\n 'hono',\n '@hono/zod-openapi',\n '@hono/swagger-ui',\n ]\n const dedupe = [\n 'react',\n 'react-dom',\n 'react-is',\n 'scheduler',\n '@inertiajs/core',\n '@inertiajs/react',\n ]\n const noExternal = [\n 'react',\n 'react-dom',\n 'react-is',\n 'scheduler',\n 'use-sync-external-store',\n '@inertiajs/core',\n '@inertiajs/react',\n ]\n const optimizeDepsInclude = ['buffer', 'buffer/', 'base64-js', 'ieee754']\n const devOnlyExternals = ['ts-morph']\n\n return [\n stratalInertiaDevCss({ entries }),\n stratalInertiaTypes(),\n {\n name: 'stratal:optimize-deps-fix',\n configEnvironment(_name: string, env: EnvironmentOptions) {\n const existing = env.optimizeDeps?.exclude ?? []\n const existingInclude = env.optimizeDeps?.include ?? []\n env.optimizeDeps = {\n ...env.optimizeDeps,\n exclude: [...existing, ...optimizeDepsExclude],\n include: [...existingInclude, ...optimizeDepsInclude],\n }\n\n const existingDedupe = env.resolve?.dedupe ?? []\n const existingNoExternal = env.resolve?.noExternal\n const mergedNoExternal: (string | RegExp)[] = [\n ...(Array.isArray(existingNoExternal)\n ? existingNoExternal\n : typeof existingNoExternal === 'string' || existingNoExternal instanceof RegExp\n ? [existingNoExternal]\n : []),\n ...noExternal,\n ]\n env.resolve = {\n ...env.resolve,\n dedupe: [...existingDedupe, ...dedupe],\n noExternal: existingNoExternal === true ? true : mergedNoExternal,\n }\n\n const existingExternal = (env.build?.rolldownOptions?.external as string[]) ?? []\n env.build = {\n ...env.build,\n rolldownOptions: {\n ...env.build?.rolldownOptions,\n external: [...existingExternal, ...devOnlyExternals],\n },\n }\n },\n },\n ]\n}\n"],"mappings":";;;;;;AAEA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B,OAAO;AAM1C,SAAS,iBAAiB,QAAuB,SAA6B;CAC5E,MAAM,OAAiB,EAAE;CACzB,MAAM,0BAAU,IAAI,KAAa;CAEjC,SAAS,SAAS,KAAiB;EACjC,IAAI,QAAQ,IAAI,IAAI,IAAI,EAAE;EAC1B,QAAQ,IAAI,IAAI,IAAI;EAEpB,IAAI,aAAa,KAAK,IAAI,IAAI,EAC5B,KAAK,KAAK,IAAI,IAAI;EAGpB,KAAK,MAAM,YAAY,IAAI,iBACzB,SAAS,SAAS;;CAItB,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,MAAM,OAAO,YAAY,iBAC7B,MAAM,WAAW,IAAI,GAAG,MAAM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;EACA;EACA;EACA;EACA;EACA;EACD;CACD,MAAM,aAAa;EACjB;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACD,MAAM,sBAAsB;EAAC;EAAU;EAAW;EAAa;EAAU;CACzE,MAAM,mBAAmB,CAAC,WAAW;CAErC,OAAO;EACL,qBAAqB,EAAE,SAAS,CAAC;EACjC,qBAAqB;EACrB;GACE,MAAM;GACN,kBAAkB,OAAe,KAAyB;IACxD,MAAM,WAAW,IAAI,cAAc,WAAW,EAAE;IAChD,MAAM,kBAAkB,IAAI,cAAc,WAAW,EAAE;IACvD,IAAI,eAAe;KACjB,GAAG,IAAI;KACP,SAAS,CAAC,GAAG,UAAU,GAAG,oBAAoB;KAC9C,SAAS,CAAC,GAAG,iBAAiB,GAAG,oBAAoB;KACtD;IAED,MAAM,iBAAiB,IAAI,SAAS,UAAU,EAAE;IAChD,MAAM,qBAAqB,IAAI,SAAS;IACxC,MAAM,mBAAwC,CAC5C,GAAI,MAAM,QAAQ,mBAAmB,GACjC,qBACA,OAAO,uBAAuB,YAAY,8BAA8B,SACtE,CAAC,mBAAmB,GACpB,EAAE,EACR,GAAG,WACJ;IACD,IAAI,UAAU;KACZ,GAAG,IAAI;KACP,QAAQ,CAAC,GAAG,gBAAgB,GAAG,OAAO;KACtC,YAAY,uBAAuB,OAAO,OAAO;KAClD;IAED,MAAM,mBAAoB,IAAI,OAAO,iBAAiB,YAAyB,EAAE;IACjF,IAAI,QAAQ;KACV,GAAG,IAAI;KACP,iBAAiB;MACf,GAAG,IAAI,OAAO;MACd,UAAU,CAAC,GAAG,kBAAkB,GAAG,iBAAiB;MACrD;KACF;;GAEJ;EACF"}
1
+ {"version":3,"file":"vite.mjs","names":["URL"],"sources":["../src/vite/inertia-dev-css-plugin.ts","../src/vite/type-gen-dispatcher.ts","../src/vite/inertia-types-plugin.ts","../src/vite.ts"],"sourcesContent":["import type { ModuleNode, Plugin, ViteDevServer } from 'vite'\n\nconst CSS_LANGS_RE = /\\.(css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|\\?)/\nconst VIRTUAL_MODULE_ID = 'virtual:inertia-ssr.css'\nconst RESOLVED_VIRTUAL_MODULE_ID = '\\0' + VIRTUAL_MODULE_ID\n\nexport interface InertiaDevCssOptions {\n entries: string[]\n}\n\nfunction collectStyleUrls(server: ViteDevServer, entries: string[]): string[] {\n const urls: string[] = []\n const visited = new Set<string>()\n\n function traverse(mod: ModuleNode) {\n if (visited.has(mod.url)) return\n visited.add(mod.url)\n\n if (CSS_LANGS_RE.test(mod.url)) {\n urls.push(mod.url)\n }\n\n for (const imported of mod.importedModules) {\n traverse(imported)\n }\n }\n\n for (const entry of entries) {\n const mod = server.moduleGraph.getModulesByFile(\n entry.startsWith('/') ? entry.slice(1) : entry,\n )\n\n if (mod) {\n for (const m of mod) {\n traverse(m)\n }\n }\n\n const urlMod = server.moduleGraph.urlToModuleMap.get(entry)\n if (urlMod) {\n traverse(urlMod)\n }\n }\n\n return urls\n}\n\nasync function collectStyle(server: ViteDevServer, entries: string[]): Promise<string> {\n for (const entry of entries) {\n try {\n await server.transformRequest(entry)\n }\n catch {\n //\n }\n }\n\n const urls = collectStyleUrls(server, entries)\n const styles: string[] = []\n\n for (const url of urls) {\n try {\n const separator = url.includes('?') ? '&' : '?'\n const result = await server.transformRequest(url + separator + 'direct')\n if (result?.code) {\n styles.push(result.code)\n }\n }\n catch {\n //\n }\n }\n\n return styles.join('\\n')\n}\n\nexport function stratalInertiaDevCss(options: InertiaDevCssOptions): Plugin {\n let server: ViteDevServer\n let cachedCss: string | null = null\n let inflight: Promise<string> | null = null\n let cacheEpoch = 0\n\n function invalidate(): void {\n cachedCss = null\n cacheEpoch++\n }\n\n async function getCss(): Promise<string> {\n if (cachedCss !== null) return cachedCss\n if (inflight) return inflight\n const epoch = cacheEpoch\n inflight = collectStyle(server, options.entries)\n .then((css) => {\n // Drop stale result if invalidated mid-flight, so the next caller re-collects.\n if (epoch === cacheEpoch) cachedCss = css\n return css\n })\n .finally(() => {\n inflight = null\n })\n return inflight\n }\n\n return {\n name: 'stratal:inertia-dev-css',\n apply: 'serve',\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n return await getCss()\n }\n },\n\n handleHotUpdate() {\n // JS/TS edits can add or remove CSS imports, which changes the SSR CSS graph\n // without the changed file itself matching CSS_LANGS_RE. Invalidate on every\n // HMR tick — collectStyle() is fast and dev-only.\n invalidate()\n },\n\n configureServer(devServer) {\n server = devServer\n\n server.middlewares.use((req, res, next) => {\n const pathname = new URL(req.url ?? '', 'http://localhost').pathname\n if (pathname !== '/__inertia/ssr-css') { next(); return; }\n\n getCss().then((css) => {\n res.setHeader('Content-Type', 'text/css')\n res.setHeader('Cache-Control', 'no-store')\n res.end(css)\n }).catch(() => {\n res.statusCode = 500\n res.end('')\n })\n })\n },\n }\n}\n","import { URL } from 'node:url'\nimport { Worker } from 'node:worker_threads'\n\nexport interface TypeGenWorkerResult {\n ok: boolean\n outputPath?: string\n pageCount?: number\n error?: string\n}\n\nexport interface TypeGenWorkerHandle {\n on(event: 'message', cb: (m: TypeGenWorkerResult) => void): this\n on(event: 'error', cb: (e: Error) => void): this\n on(event: 'exit', cb: (code: number) => void): this\n terminate(): Promise<number> | number\n}\n\nexport type TypeGenWorkerSpawner = (cwd: string) => TypeGenWorkerHandle\n\nexport interface TypeGenDispatcher {\n schedule(): void\n dispose(): Promise<void>\n}\n\nexport interface TypeGenDispatcherOptions {\n cwd: string\n spawn?: TypeGenWorkerSpawner\n debounceMs?: number\n onResult?: (result: TypeGenWorkerResult) => void\n onError?: (error: Error) => void\n}\n\nconst defaultSpawn: TypeGenWorkerSpawner = (cwd) =>\n new Worker(new URL('./generator/type-generator.worker.mjs', import.meta.url), {\n workerData: { cwd },\n })\n\nexport function createTypeGenDispatcher(options: TypeGenDispatcherOptions): TypeGenDispatcher {\n const spawn = options.spawn ?? defaultSpawn\n const debounceMs = options.debounceMs ?? 250\n\n let pendingTimer: ReturnType<typeof setTimeout> | null = null\n let inflight: TypeGenWorkerHandle | null = null\n let queued = false\n let disposed = false\n\n function fire() {\n pendingTimer = null\n if (disposed) return\n if (inflight) {\n queued = true\n return\n }\n\n const worker = spawn(options.cwd)\n inflight = worker\n\n const finish = () => {\n if (inflight === worker) inflight = null\n if (disposed) return\n if (queued) {\n queued = false\n fire()\n }\n }\n\n worker.on('message', (msg) => {\n // `exit` will follow; finish() runs there so terminate() has settled before the next spawn.\n options.onResult?.(msg)\n })\n\n worker.on('error', (err) => {\n options.onError?.(err)\n })\n\n worker.on('exit', () => {\n finish()\n })\n }\n\n return {\n schedule() {\n if (disposed) return\n if (inflight) {\n queued = true\n return\n }\n if (pendingTimer) clearTimeout(pendingTimer)\n pendingTimer = setTimeout(fire, debounceMs)\n },\n\n async dispose() {\n disposed = true\n queued = false\n if (pendingTimer) {\n clearTimeout(pendingTimer)\n pendingTimer = null\n }\n const worker = inflight\n inflight = null\n if (worker) {\n try {\n await worker.terminate()\n } catch {\n // ignore\n }\n }\n },\n }\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\nimport type { Plugin } from 'vite'\nimport { findPagesDir, runTypeGeneration } from '../generator/type-generator'\nimport { createTypeGenDispatcher, type TypeGenDispatcher } from './type-gen-dispatcher'\n\nconst INERTIA_CALL_PATTERN = /ctx\\.inertia\\(|\\.share\\(|ctx\\.flash\\(|ctx\\.defer\\(|ctx\\.optional\\(|ctx\\.merge\\(|ctx\\.once\\(|ctx\\.always\\(/\n\nexport function stratalInertiaTypes(): Plugin {\n let cwd: string\n let pagesDir: string\n let srcDir: string\n let dispatcher: TypeGenDispatcher | null = null\n\n return {\n name: 'stratal:inertia-types',\n\n configResolved(config) {\n cwd = config.root\n pagesDir = findPagesDir(cwd) + '/'\n srcDir = join(cwd, 'src') + '/'\n dispatcher = createTypeGenDispatcher({\n cwd,\n onError(err) {\n console.warn('[stratal:inertia-types] Type generation worker errored:', err.message)\n },\n onResult(result) {\n if (!result.ok && result.error) {\n console.warn('[stratal:inertia-types] Type generation failed:', result.error)\n }\n },\n })\n },\n\n async buildStart() {\n if (!existsSync(pagesDir)) return\n try {\n await runTypeGeneration(cwd)\n } catch (error) {\n console.warn('[stratal:inertia-types] Type generation failed during build:', error)\n }\n },\n\n handleHotUpdate({ file }) {\n if (!dispatcher) return\n if (!/\\.(tsx|ts)$/.test(file)) return\n\n const relToSrc = relative(srcDir, file)\n const isInSrc = !relToSrc.startsWith('..')\n\n if (!isInSrc) return\n\n // Page files always trigger regeneration\n const relToPages = relative(pagesDir, file)\n const isPageFile = !relToPages.startsWith('..')\n\n if (!isPageFile) {\n // For non-page files, only regenerate if they contain inertia-related calls\n try {\n const content = readFileSync(file, 'utf-8')\n if (!INERTIA_CALL_PATTERN.test(content)) return\n } catch {\n return\n }\n }\n\n dispatcher.schedule()\n },\n\n async closeBundle() {\n if (dispatcher) {\n await dispatcher.dispose()\n dispatcher = null\n }\n },\n }\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { isAbsolute, join } from 'node:path';\nimport type { EnvironmentOptions, Plugin } from 'vite';\nimport { stratalInertiaDevCss } from './vite/inertia-dev-css-plugin';\nimport { stratalInertiaTypes } from './vite/inertia-types-plugin';\n\nexport { stratalInertiaDevCss, stratalInertiaTypes };\n\nexport interface StratalInertiaPluginOptions {\n /** Client entry path(s) for CSS collection (default: ['/src/inertia/app.tsx']) */\n entries?: string[]\n /**\n * Whether to emit sourcemaps in `vite build`. Default: `'dev-and-staging'`\n * — sourcemaps in development and staging deploys for debugging, but never\n * in production (which would inflate the worker upload).\n *\n * - `true` / `false` — force on / off\n * - `'dev-and-staging'` — on unless `CLOUDFLARE_ENV === 'prod'`\n */\n sourcemap?: boolean | 'dev-and-staging'\n /**\n * Path (relative to project root) to the Vite client manifest emitted by\n * the standalone browser-bundle build phase. The injector plugin reads it\n * during the worker build and inlines it onto the worker entry chunk so\n * `ManifestService` can resolve hashed asset URLs at runtime.\n *\n * Default: `'dist/client/.vite/manifest.json'` — matches the layout\n * `quarry inertia:build` produces.\n */\n clientManifestPath?: string\n}\n\nexport function stratalInertia(options?: StratalInertiaPluginOptions): Plugin[] {\n const entries = options?.entries ?? ['/src/inertia/app.tsx']\n const sourcemapOption = options?.sourcemap ?? 'dev-and-staging'\n const sourcemap = sourcemapOption === 'dev-and-staging'\n ? process.env.CLOUDFLARE_ENV !== 'prod' && process.env.CLOUDFLARE_ENV! !== 'production'\n : sourcemapOption\n\n // Hono and stratal must NOT be pre-bundled by Vite's optimizeDeps. When they are,\n // a duplicate copy ends up in `.vite/deps_<env>/` while the worker bundle imports\n // another copy from node_modules — Response objects from one instance flow into\n // a Context class from the other, and Hono's `set res` setter crashes inside\n // `this.#res.headers.entries()` because the prototype chain doesn't match.\n //\n // React 19 ships its main entry as CJS and relies on the optimizer's CJS→ESM\n // conversion, so it cannot be excluded outright. To prevent the related\n // identity-mismatch bug (two `?v=<hash>` copies after the optimizer re-runs\n // when a new dep is auto-discovered), the React-ecosystem packages are listed\n // in `resolve.noExternal` so Vite treats them as part of the user module graph\n // and `resolve.dedupe` so all imports collapse to a single physical copy.\n const optimizeDepsExclude = [\n '@cloudflare/vite-plugin',\n 'wrangler',\n 'blake3-wasm',\n '@stratal/inertia',\n 'stratal',\n 'hono',\n '@hono/zod-openapi',\n '@hono/swagger-ui',\n ]\n const dedupe = [\n 'react',\n 'react-dom',\n 'react-is',\n 'scheduler',\n '@inertiajs/core',\n '@inertiajs/react',\n ]\n const noExternal = [\n 'react',\n 'react-dom',\n 'react-is',\n 'scheduler',\n 'use-sync-external-store',\n '@inertiajs/core',\n '@inertiajs/react',\n ]\n const optimizeDepsInclude = ['buffer', 'buffer/', 'base64-js', 'ieee754']\n // Dev/build-time-only packages that must never reach the worker or browser\n // bundle. `ts-morph` is used by the type generator. The langium / zenstack\n // CLI/SDK group is dragged in transitively by ZenStack's runtime barrel\n // (e.g. `@zenstackhq/better-auth` imports a `schema-generator` that\n // references `@zenstackhq/language` which depends on `langium`); no actual\n // runtime code path executes any of it. If a future refactor genuinely\n // needs one of these at runtime, this list should be revisited explicitly.\n const devOnlyExternals: (string | RegExp)[] = [\n 'ts-morph',\n /^langium($|\\/)/,\n /^@zenstackhq\\/cli($|\\/)/,\n /^@zenstackhq\\/language($|\\/)/,\n /^@zenstackhq\\/sdk($|\\/)/,\n ]\n\n const clientManifestPath = options?.clientManifestPath ?? 'dist/client/.vite/manifest.json'\n\n return [\n stratalInertiaDevCss({ entries }),\n stratalInertiaTypes(),\n {\n name: 'stratal:optimize-deps-fix',\n config(config) {\n config.publicDir ??= 'src/inertia/public';\n },\n configEnvironment(name: string, env: EnvironmentOptions) {\n const existing = env.optimizeDeps?.exclude ?? []\n const existingInclude = env.optimizeDeps?.include ?? []\n env.optimizeDeps = {\n ...env.optimizeDeps,\n exclude: [...existing, ...optimizeDepsExclude],\n include: [...existingInclude, ...optimizeDepsInclude],\n }\n\n const existingDedupe = env.resolve?.dedupe ?? []\n const existingNoExternal = env.resolve?.noExternal\n const mergedNoExternal: (string | RegExp)[] = [\n ...(Array.isArray(existingNoExternal)\n ? existingNoExternal\n : typeof existingNoExternal === 'string' || existingNoExternal instanceof RegExp\n ? [existingNoExternal]\n : []),\n ...noExternal,\n ]\n env.resolve = {\n ...env.resolve,\n dedupe: [...existingDedupe, ...dedupe],\n noExternal: existingNoExternal === true ? true : mergedNoExternal,\n }\n\n const existingExternal = env.build?.rolldownOptions?.external\n const existingExternalArray: (string | RegExp)[] = Array.isArray(existingExternal)\n ? (existingExternal as (string | RegExp)[])\n : existingExternal != null\n ? [existingExternal as string | RegExp]\n : []\n env.build = {\n ...env.build,\n // Only override sourcemap when the user hasn't set it explicitly,\n // so a per-app `build.sourcemap` in vite.config.ts still wins.\n sourcemap: env.build?.sourcemap ?? sourcemap,\n rolldownOptions: {\n ...env.build?.rolldownOptions,\n external: [...existingExternalArray, ...devOnlyExternals],\n },\n }\n\n // `quarry inertia:build` runs a standalone client build (phase 1) that\n // emits the browser bundle + manifest to dist/client/ before invoking\n // this worker build (phase 2). `@cloudflare/vite-plugin`'s `buildApp`\n // then runs a \"fallback\" build for its own `client` env (because no\n // input is set on it here) which, with Vite's default\n // `build.emptyOutDir = true` for in-root outDirs, would wipe phase 1's\n // chunks. Pinning `emptyOutDir = false` for the client env preserves\n // the browser bundle so CF's asset binding can serve `/assets/app-<hash>.js`.\n if (name === 'client') {\n env.build.emptyOutDir = false\n }\n },\n },\n injectSeoRuntime({ entries }),\n injectClientManifestIntoWorker({ clientManifestPath }),\n ]\n}\n\n// Injects the client-side SEO head-sync runtime into the browser entry so\n// backend `ctx.seo()` metadata stays in sync across Inertia navigations with\n// zero app wiring. The runtime is a side-effect import (`@stratal/inertia/seo-runtime`)\n// prepended to each configured client entry; it only reaches the browser bundle\n// because the worker/SSR builds never transform these entry files.\nfunction injectSeoRuntime(args: { entries: string[] }): Plugin {\n const runtime = '@stratal/inertia/seo-runtime'\n const targets = args.entries.map((entry) => entry.replace(/^\\//, ''))\n\n return {\n name: 'stratal:inertia-inject-seo-runtime',\n transform(code, id) {\n const file = id.split('?')[0]\n if (!targets.some((target) => file.endsWith(target))) return null\n if (code.includes(runtime)) return null\n return { code: `import '${runtime}';\\n${code}`, map: null }\n },\n }\n}\n\n// Reads the manifest produced by the standalone browser-bundle build (run\n// before this build by `quarry inertia:build`) and inlines it onto the worker\n// entry chunk as `globalThis.__STRATAL_INERTIA_MANIFEST__`. The manifest must\n// be inlined in the bundle itself — Cloudflare Workers have no filesystem at\n// runtime — so `ManifestService` can resolve hashed asset URLs without any\n// consumer-side wiring.\nfunction injectClientManifestIntoWorker(args: { clientManifestPath: string }): Plugin {\n let projectRoot = process.cwd()\n\n return {\n name: 'stratal:inertia-inject-manifest',\n apply: 'build',\n configResolved(config) {\n projectRoot = config.root\n },\n generateBundle(_options, bundle) {\n // Only inject into worker / SSR bundles. The browser-bundle build runs\n // in a separate `vite build` invocation and never reaches this plugin.\n if (this.environment.name === 'client') return\n\n const manifestPath = isAbsolute(args.clientManifestPath)\n ? args.clientManifestPath\n : join(projectRoot, args.clientManifestPath)\n\n if (!existsSync(manifestPath)) {\n this.error(\n '@stratal/inertia: client manifest not found at ' + manifestPath\n + '. Run `quarry inertia:build` to build the browser bundle before deploying.',\n )\n }\n\n const manifestJson = readFileSync(manifestPath, 'utf-8')\n // Parse + re-stringify so a malformed manifest fails loudly here rather\n // than at worker boot, and so the inlined value is normalized.\n const manifest = JSON.parse(manifestJson) as unknown\n const inlined = JSON.stringify(manifest)\n const sentinel = 'globalThis.__STRATAL_INERTIA_MANIFEST__'\n\n for (const fileName of Object.keys(bundle)) {\n const chunk = bundle[fileName]\n if (chunk.type !== 'chunk') continue\n if (!chunk.isEntry) continue\n if (chunk.code.startsWith(sentinel)) continue\n chunk.code = `${sentinel} = ${inlined};\\n${chunk.code}`\n }\n },\n }\n}\n\n"],"mappings":";;;;;;AAEA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B;AAMnC,SAAS,iBAAiB,QAAuB,SAA6B;CAC5E,MAAM,OAAiB,CAAC;CACxB,MAAM,0BAAU,IAAI,IAAY;CAEhC,SAAS,SAAS,KAAiB;EACjC,IAAI,QAAQ,IAAI,IAAI,GAAG,GAAG;EAC1B,QAAQ,IAAI,IAAI,GAAG;EAEnB,IAAI,aAAa,KAAK,IAAI,GAAG,GAC3B,KAAK,KAAK,IAAI,GAAG;EAGnB,KAAK,MAAM,YAAY,IAAI,iBACzB,SAAS,QAAQ;CAErB;CAEA,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,MAAM,OAAO,YAAY,iBAC7B,MAAM,WAAW,GAAG,IAAI,MAAM,MAAM,CAAC,IAAI,KAC3C;EAEA,IAAI,KACF,KAAK,MAAM,KAAK,KACd,SAAS,CAAC;EAId,MAAM,SAAS,OAAO,YAAY,eAAe,IAAI,KAAK;EAC1D,IAAI,QACF,S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