@stratal/inertia 0.0.21 → 0.0.22

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.
@@ -99,10 +99,8 @@ function unwrapWrapperType(type, tsObj, fallbackLocation) {
99
99
  return widenLiteralType(type, tsObj, fallbackLocation);
100
100
  }
101
101
  function unwrapPromise(type, tsObj, fallbackLocation) {
102
- if (type.getText(void 0, tsObj.TypeFormatFlags.NoTruncation).startsWith("Promise<")) {
103
- const typeArgs = type.getTypeArguments();
104
- if (typeArgs.length > 0) return stripReadonly(typeArgs[0], tsObj, fallbackLocation);
105
- }
102
+ const awaited = type.getAwaitedType?.();
103
+ if (awaited && awaited !== type) return stripReadonly(awaited, tsObj, fallbackLocation);
106
104
  return stripReadonly(type, tsObj, fallbackLocation);
107
105
  }
108
106
  function stripReadonly(type, tsObj, fallbackLocation) {
@@ -137,6 +135,60 @@ function extractShareCallTypes(project, SK, tsObj, srcDir) {
137
135
  }
138
136
  return shareTypes;
139
137
  }
138
+ /**
139
+ * Given the first argument of `Module.forRoot(...)` or `Module.forRootAsync(...)`,
140
+ * return the object literal where downstream options actually live.
141
+ *
142
+ * - For `forRoot({...})` the literal IS the first arg.
143
+ * - For `forRootAsync({ inject, useFactory: (...) => ({...}) })` we drill into
144
+ * the `useFactory`'s return value:
145
+ * `() => ({ … })` — ParenthesizedExpression → ObjectLiteral
146
+ * `() => ({ ... } as Foo)` — AsExpression → ObjectLiteral
147
+ * `() => { return { … } }` — Block → ReturnStatement → ObjectLiteral
148
+ *
149
+ * Returns `null` when nothing usable is found.
150
+ */
151
+ function resolveModuleOptionsLiteral(optionsArg, SK) {
152
+ if (!optionsArg.isKind(SK.ObjectLiteralExpression)) return null;
153
+ const useFactoryProp = optionsArg.getProperty("useFactory");
154
+ if (useFactoryProp?.isKind(SK.PropertyAssignment)) {
155
+ const initializer = useFactoryProp.getInitializer();
156
+ if (initializer?.isKind(SK.ArrowFunction) || initializer?.isKind(SK.FunctionExpression)) {
157
+ const body = initializer.getBody();
158
+ if (body.isKind(SK.ParenthesizedExpression)) {
159
+ const inner = unwrapAs(body.getExpression(), SK);
160
+ if (inner?.isKind(SK.ObjectLiteralExpression)) return inner;
161
+ }
162
+ const unwrapped = unwrapAs(body, SK);
163
+ if (unwrapped?.isKind(SK.ObjectLiteralExpression)) return unwrapped;
164
+ if (body.isKind(SK.Block)) {
165
+ const returnStatements = body.getDescendantsOfKind(SK.ReturnStatement);
166
+ for (let i = returnStatements.length - 1; i >= 0; i--) {
167
+ const expr = returnStatements[i].getExpression();
168
+ if (!expr) continue;
169
+ if (expr.isKind(SK.ParenthesizedExpression)) {
170
+ const inner = unwrapAs(expr.getExpression(), SK);
171
+ if (inner?.isKind(SK.ObjectLiteralExpression)) return inner;
172
+ continue;
173
+ }
174
+ const direct = unwrapAs(expr, SK);
175
+ if (direct?.isKind(SK.ObjectLiteralExpression)) return direct;
176
+ }
177
+ }
178
+ }
179
+ }
180
+ return optionsArg;
181
+ }
182
+ /**
183
+ * Strip a single `as Foo` cast if present, otherwise return the node as-is.
184
+ * `useFactory: (env) => ({ ... } as Options)` is common in TypeScript.
185
+ */
186
+ function unwrapAs(node, SK) {
187
+ if (!node) return void 0;
188
+ if (node.isKind(SK.AsExpression) || node.isKind(SK.TypeAssertionExpression)) return node.getExpression();
189
+ if (node.isKind(SK.SatisfiesExpression)) return node.getExpression();
190
+ return node;
191
+ }
140
192
  function detectI18nConfig(project, SK, moduleFilePath) {
141
193
  const sourceFile = project.getSourceFile(moduleFilePath);
142
194
  if (!sourceFile) return false;
@@ -150,9 +202,9 @@ function detectI18nConfig(project, SK, moduleFilePath) {
150
202
  if (!objExpr.isKind(SK.Identifier) || objExpr.getText() !== "InertiaModule") continue;
151
203
  const args = call.getArguments();
152
204
  if (args.length === 0) continue;
153
- const optionsArg = args[0];
154
- if (!optionsArg.isKind(SK.ObjectLiteralExpression)) continue;
155
- return !!optionsArg.getProperty("i18n");
205
+ const optionsLiteral = resolveModuleOptionsLiteral(args[0], SK);
206
+ if (!optionsLiteral) continue;
207
+ if (optionsLiteral.isKind(SK.ObjectLiteralExpression) && optionsLiteral.getProperty("i18n")) return true;
156
208
  }
157
209
  return false;
158
210
  }
@@ -194,9 +246,9 @@ function extractSharedDataType(project, SK, tsObj, moduleFilePath) {
194
246
  if (!objExpr.isKind(SK.Identifier) || objExpr.getText() !== "InertiaModule") continue;
195
247
  const args = call.getArguments();
196
248
  if (args.length === 0) continue;
197
- const optionsArg = args[0];
198
- if (!optionsArg.isKind(SK.ObjectLiteralExpression)) continue;
199
- const sharedDataProp = optionsArg.getProperty("sharedData");
249
+ const optionsLiteral = resolveModuleOptionsLiteral(args[0], SK);
250
+ if (!optionsLiteral || !optionsLiteral.isKind(SK.ObjectLiteralExpression)) continue;
251
+ const sharedDataProp = optionsLiteral.getProperty("sharedData");
200
252
  if (!sharedDataProp) continue;
201
253
  if (!sharedDataProp.isKind(SK.PropertyAssignment)) continue;
202
254
  const initializer = sharedDataProp.getInitializer();
@@ -397,4 +449,4 @@ async function runTypeGeneration(cwd) {
397
449
  //#endregion
398
450
  export { runTypeGeneration as n, findPagesDir as t };
399
451
 
400
- //# sourceMappingURL=type-generator-o_PxETTs.mjs.map
452
+ //# sourceMappingURL=type-generator-bfo14BJI.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-generator-bfo14BJI.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 function detectI18nConfig(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n moduleFilePath: string,\n): boolean {\n const sourceFile = project.getSourceFile(moduleFilePath)\n if (!sourceFile) return false\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) continue\n\n if (optionsLiteral.isKind(SK.ObjectLiteralExpression) && optionsLiteral.getProperty('i18n')) {\n return true\n }\n }\n\n return false\n}\n\n// --- Extract ctx.flash() call types ---\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 const keyArg = args[0]\n if (!keyArg.isKind(SK.StringLiteral)) continue\n const key = keyArg.getLiteralValue()\n\n if (flashMembers.has(key)) continue\n\n const valueType = widenLiteralType(args[1].getType(), tsObj)\n flashMembers.set(key, valueType)\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 hasI18n: boolean\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, hasI18n, 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 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 (hasI18n) {\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 // 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 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\n const hasI18n = moduleFilePath\n ? detectI18nConfig(project, SyntaxKind, moduleFilePath)\n : false\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 hasI18n,\n flashTypes,\n })\n writeInertiaTypes(outputPath, content)\n\n return { outputPath, pageCount: pages.length }\n}\n"],"mappings":";;;AAsBA,eAAe,cAAc;CAC3B,OAAO,OAAO;;AAYhB,eAAe,cAAc,cAA0G;CACrI,MAAM,EAAE,SAAS,YAAY,OAAO,MAAM,aAAa;CAcvD,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;IACzB;GACF,CAEe;EAAE;EAAY;EAAI;;AAKpC,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;CACD;AAED,SAAgB,2BACd,SACA,IACA,OACA,QACA,UACgB;CAChB,QAAQ,sBAAsB,KAAK,QAAQ,UAAU,CAAC;CAGtD,MAAM,wBAAQ,IAAI,KAAuB;CAEzC,KAAK,MAAM,cAAc,QAAQ,gBAAgB,EAAE;EACjD,MAAM,WAAW,WAAW,aAAa;EACzC,IAAI,SAAS,SAAS,SAAS,QAAQ,OAAO,IAAI,CAAC,EAAE;EAErD,IAAI,SAAS,SAAS,YAAY,IAAI,SAAS,SAAS,SAAS,IAAI,SAAS,SAAS,SAAS,EAAE;EAElG,MAAM,kBAAkB,WAAW,qBAAqB,GAAG,eAAe;EAE1E,KAAK,MAAM,QAAQ,iBAAiB;GAClC,MAAM,OAAO,KAAK,eAAe;GACjC,IAAI,CAAC,KAAK,OAAO,G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,WAAW,aAAa,IAAI;CAClC,MAAM,SAAS,KAAK,KAAK,MAAM;CAC/B,MAAM,aAAa,eAAe,IAAI;CACtC,MAAM,iBAAiB,kBAAkB,IAAI;CAI7C,MAAM,EAAE,SAAS,YAAY,OAAO,MAAM,cAHrB,iBAAiB,IAG8B,CAAC;CAGrE,MAAM,QAAQ,2BAA2B,SAAS,YAAY,IAAI,QAAQ,SAAS;CAGnF,MAAM,aAAa,iBACf,sBAAsB,SAAS,YAAY,IAAI,eAAe,GAC9D;CAGJ,MAAM,UAAU,iBACZ,iBAAiB,SAAS,YAAY,eAAe,GACrD;CAgBJ,kBAAkB,YAPF,qBAAqB;EACnC;EACA;EACA,gBATqB,sBAAsB,SAAS,YAAY,IAAI,OAStD;EACd;EACA,YARiB,kBAAkB,SAAS,YAAY,IAAI,OAQlD;EACX,CACoC,CAAC;CAEtC,OAAO;EAAE;EAAY,WAAW,MAAM;EAAQ"}
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,OAAA;AAAA;AAAA,iBAqEc,oBAAA,CAAqB,OAAA,EAAS,oBAAA,GAAuB,MAAA;;;iBCpErD,mBAAA,CAAA,GAAuB,MAAA;;;UCAtB,2BAAA;;EAEf,OAAA;EFHO;AAqET;;;;;;;EEzDE,SAAA;EFyDyE;;;;ACpE3E;;;;;ECqBE,kBAAA;AAAA;AAAA,iBAGc,cAAA,CAAe,OAAA,GAAU,2BAAA,GAA8B,MAAA"}
package/dist/vite.mjs CHANGED
@@ -1,6 +1,6 @@
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-bfo14BJI.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
@@ -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,20 @@ 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
+ configEnvironment(name, env) {
250
259
  const existing = env.optimizeDeps?.exclude ?? [];
251
260
  const existingInclude = env.optimizeDeps?.include ?? [];
252
261
  env.optimizeDeps = {
@@ -262,18 +271,48 @@ function stratalInertia(options) {
262
271
  dedupe: [...existingDedupe, ...dedupe],
263
272
  noExternal: existingNoExternal === true ? true : mergedNoExternal
264
273
  };
265
- const existingExternal = env.build?.rolldownOptions?.external ?? [];
274
+ const existingExternal = env.build?.rolldownOptions?.external;
275
+ const existingExternalArray = Array.isArray(existingExternal) ? existingExternal : existingExternal != null ? [existingExternal] : [];
266
276
  env.build = {
267
277
  ...env.build,
278
+ sourcemap: env.build?.sourcemap ?? sourcemap,
268
279
  rolldownOptions: {
269
280
  ...env.build?.rolldownOptions,
270
- external: [...existingExternal, ...devOnlyExternals]
281
+ external: [...existingExternalArray, ...devOnlyExternals]
271
282
  }
272
283
  };
284
+ if (name === "client") env.build.emptyOutDir = false;
273
285
  }
274
- }
286
+ },
287
+ injectClientManifestIntoWorker({ clientManifestPath })
275
288
  ];
276
289
  }
290
+ function injectClientManifestIntoWorker(args) {
291
+ let projectRoot = process.cwd();
292
+ return {
293
+ name: "stratal:inertia-inject-manifest",
294
+ apply: "build",
295
+ configResolved(config) {
296
+ projectRoot = config.root;
297
+ },
298
+ generateBundle(_options, bundle) {
299
+ if (this.environment.name === "client") return;
300
+ const manifestPath = isAbsolute(args.clientManifestPath) ? args.clientManifestPath : join(projectRoot, args.clientManifestPath);
301
+ if (!existsSync(manifestPath)) this.error("@stratal/inertia: client manifest not found at " + manifestPath + ". Run `quarry inertia:build` to build the browser bundle before deploying.");
302
+ const manifestJson = readFileSync(manifestPath, "utf-8");
303
+ const manifest = JSON.parse(manifestJson);
304
+ const inlined = JSON.stringify(manifest);
305
+ const sentinel = "globalThis.__STRATAL_INERTIA_MANIFEST__";
306
+ for (const fileName of Object.keys(bundle)) {
307
+ const chunk = bundle[fileName];
308
+ if (chunk.type !== "chunk") continue;
309
+ if (!chunk.isEntry) continue;
310
+ if (chunk.code.startsWith(sentinel)) continue;
311
+ chunk.code = `${sentinel} = ${inlined};\n${chunk.code}`;
312
+ }
313
+ }
314
+ };
315
+ }
277
316
  //#endregion
278
317
  export { stratalInertia, stratalInertiaDevCss, stratalInertiaTypes };
279
318
 
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,IAA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ACV,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 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 injectClientManifestIntoWorker({ clientManifestPath }),\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,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,MAAM,EAAE,GAAG,MAC1C;EAED,IAAI,KACF,KAAK,MAAM,KAAK,KACd,SAAS,EAAE;EAIf,MAAM,SAAS,OAAO,YAAY,eAAe,IAAI,MAAM;EAC3D,IAAI,QACF,SAAS,OAAO;;CAIpB,OAAO;;AAGT,eAAe,aAAa,QAAuB,SAAoC;CACrF,KAAK,MAAM,SAAS,SAClB,IAAI;EACF,MAAM,OAAO,iBAAiB,MAAM;SAEhC;CAKR,MAAM,OAAO,iBAAiB,QAAQ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U,QAAQ;GAG/B,IAAI,KAAK,YAAY,SAAS,UAAU;GAExC,MAAM,eAAe,WAAW,KAAK,mBAAmB,GACpD,KAAK,qBACL,KAAK,aAAa,KAAK,mBAAmB;GAE9C,IAAI,CAAC,WAAW,aAAa,EAC3B,KAAK,MACH,oDAAoD,eAClD,6EACH;GAGH,MAAM,eAAe,aAAa,cAAc,QAAQ;GAGxD,MAAM,WAAW,KAAK,MAAM,aAAa;GACzC,MAAM,UAAU,KAAK,UAAU,SAAS;GACxC,MAAM,WAAW;GAEjB,KAAK,MAAM,YAAY,OAAO,KAAK,OAAO,EAAE;IAC1C,MAAM,QAAQ,OAAO;IACrB,IAAI,MAAM,SAAS,SAAS;IAC5B,IAAI,CAAC,MAAM,SAAS;IACpB,IAAI,MAAM,KAAK,WAAW,SAAS,EAAE;IACrC,MAAM,OAAO,GAAG,SAAS,KAAK,QAAQ,KAAK,MAAM;;;EAGtD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stratal/inertia",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Inertia.js v3 server adapter for Stratal framework — server-driven React SPAs",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,6 +40,10 @@
40
40
  "types": "./dist/index.d.mts",
41
41
  "import": "./dist/index.mjs"
42
42
  },
43
+ "./quarry": {
44
+ "types": "./dist/quarry.d.mts",
45
+ "import": "./dist/quarry.mjs"
46
+ },
43
47
  "./react": {
44
48
  "types": "./dist/react.d.mts",
45
49
  "import": "./dist/react.mjs"
@@ -63,6 +67,7 @@
63
67
  "lint:fix": "npx oxlint --fix ."
64
68
  },
65
69
  "dependencies": {
70
+ "intl-messageformat": "^11.2.7",
66
71
  "ts-morph": "^28.0.0"
67
72
  },
68
73
  "peerDependencies": {
@@ -70,13 +75,11 @@
70
75
  "@inertiajs/core": ">=3",
71
76
  "@inertiajs/react": ">=3",
72
77
  "@inertiajs/vite": ">=3",
73
- "@intlify/core-base": ">=11",
74
- "@stratal/testing": ">=0.0.21",
78
+ "@stratal/testing": ">=0.0.22",
75
79
  "hono": ">=4",
76
80
  "react": ">=19",
77
81
  "react-dom": ">=19",
78
- "reflect-metadata": ">=0.2",
79
- "stratal": ">=0.0.21",
82
+ "stratal": ">=0.0.22",
80
83
  "vite": ">=8",
81
84
  "vitest": ">=4"
82
85
  },
@@ -93,9 +96,6 @@
93
96
  "@inertiajs/vite": {
94
97
  "optional": true
95
98
  },
96
- "@intlify/core-base": {
97
- "optional": true
98
- },
99
99
  "@stratal/testing": {
100
100
  "optional": true
101
101
  },
@@ -115,7 +115,6 @@
115
115
  "@inertiajs/core": "^3.1.1",
116
116
  "@inertiajs/react": "^3.1.1",
117
117
  "@inertiajs/vite": "^3.1.1",
118
- "@intlify/core-base": "^11.4.2",
119
118
  "@stratal/testing": "workspace:*",
120
119
  "@types/node": "^25.6.2",
121
120
  "@types/react": "^19.2.14",
@@ -125,7 +124,6 @@
125
124
  "hono": "^4.12.18",
126
125
  "react": "^19.2.6",
127
126
  "react-dom": "^19.2.6",
128
- "reflect-metadata": "^0.2.2",
129
127
  "stratal": "workspace:*",
130
128
  "tsdown": "^0.22.0",
131
129
  "typescript": "^6.0.3",
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-generator-o_PxETTs.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 const text = type.getText(undefined, tsObj.TypeFormatFlags.NoTruncation)\n if (text.startsWith('Promise<')) {\n const typeArgs = type.getTypeArguments()\n if (typeArgs.length > 0) {\n return stripReadonly(typeArgs[0], tsObj, fallbackLocation)\n }\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\nexport function detectI18nConfig(\n project: Project,\n SK: TsMorphModule['SyntaxKind'],\n moduleFilePath: string,\n): boolean {\n const sourceFile = project.getSourceFile(moduleFilePath)\n if (!sourceFile) return false\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 optionsArg = args[0]\n if (!optionsArg.isKind(SK.ObjectLiteralExpression)) continue\n\n return !!optionsArg.getProperty('i18n')\n }\n\n return false\n}\n\n// --- Extract ctx.flash() call types ---\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 const keyArg = args[0]\n if (!keyArg.isKind(SK.StringLiteral)) continue\n const key = keyArg.getLiteralValue()\n\n if (flashMembers.has(key)) continue\n\n const valueType = widenLiteralType(args[1].getType(), tsObj)\n flashMembers.set(key, valueType)\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 optionsArg = args[0]\n if (!optionsArg.isKind(SK.ObjectLiteralExpression)) continue\n\n const sharedDataProp = optionsArg.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 hasI18n: boolean\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, hasI18n, 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 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 (hasI18n) {\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 // 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 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\n const hasI18n = moduleFilePath\n ? detectI18nConfig(project, SyntaxKind, moduleFilePath)\n : false\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 hasI18n,\n flashTypes,\n })\n writeInertiaTypes(outputPath, content)\n\n return { outputPath, pageCount: pages.length }\n}\n"],"mappings":";;;AAsBA,eAAe,cAAc;CAC3B,OAAO,OAAO;;AAYhB,eAAe,cAAc,cAA0G;CACrI,MAAM,EAAE,SAAS,YAAY,OAAO,MAAM,aAAa;CAcvD,OAAO;EAAE,SAAA,IAZW,QAAQ;GAC1B,kBAAkB;GAClB,6BAA6B;GAC7B,iBAAiB,eAAe,KAAA,IAAY;IAC1C,KAAK,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