@stratal/inertia 0.0.19 → 0.0.21
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.
- package/dist/generator/type-generator.worker.d.mts +1 -0
- package/dist/generator/type-generator.worker.mjs +25 -0
- package/dist/generator/type-generator.worker.mjs.map +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +30 -8
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +23 -16
- package/dist/react.d.mts.map +1 -1
- package/dist/react.mjs +99 -35
- package/dist/react.mjs.map +1 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/{type-generator-C5JljyzK.mjs → type-generator-o_PxETTs.mjs} +13 -4
- package/dist/type-generator-o_PxETTs.mjs.map +1 -0
- package/dist/vite.d.mts.map +1 -1
- package/dist/vite.mjs +137 -9
- package/dist/vite.mjs.map +1 -1
- package/package.json +25 -25
- package/dist/type-generator-C5JljyzK.mjs.map +0 -1
package/dist/vite.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { n as runTypeGeneration, t as findPagesDir } from "./type-generator-
|
|
1
|
+
import { n as runTypeGeneration, t as findPagesDir } from "./type-generator-o_PxETTs.mjs";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join, relative } from "node:path";
|
|
4
|
+
import { URL as URL$1 } from "node:url";
|
|
5
|
+
import { Worker } from "node:worker_threads";
|
|
4
6
|
//#region src/vite/inertia-dev-css-plugin.ts
|
|
5
7
|
const CSS_LANGS_RE = /\.(css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|\?)/;
|
|
6
8
|
const VIRTUAL_MODULE_ID = "virtual:inertia-ssr.css";
|
|
@@ -37,6 +39,25 @@ async function collectStyle(server, entries) {
|
|
|
37
39
|
}
|
|
38
40
|
function stratalInertiaDevCss(options) {
|
|
39
41
|
let server;
|
|
42
|
+
let cachedCss = null;
|
|
43
|
+
let inflight = null;
|
|
44
|
+
let cacheEpoch = 0;
|
|
45
|
+
function invalidate() {
|
|
46
|
+
cachedCss = null;
|
|
47
|
+
cacheEpoch++;
|
|
48
|
+
}
|
|
49
|
+
async function getCss() {
|
|
50
|
+
if (cachedCss !== null) return cachedCss;
|
|
51
|
+
if (inflight) return inflight;
|
|
52
|
+
const epoch = cacheEpoch;
|
|
53
|
+
inflight = collectStyle(server, options.entries).then((css) => {
|
|
54
|
+
if (epoch === cacheEpoch) cachedCss = css;
|
|
55
|
+
return css;
|
|
56
|
+
}).finally(() => {
|
|
57
|
+
inflight = null;
|
|
58
|
+
});
|
|
59
|
+
return inflight;
|
|
60
|
+
}
|
|
40
61
|
return {
|
|
41
62
|
name: "stratal:inertia-dev-css",
|
|
42
63
|
apply: "serve",
|
|
@@ -44,7 +65,10 @@ function stratalInertiaDevCss(options) {
|
|
|
44
65
|
if (id === VIRTUAL_MODULE_ID) return RESOLVED_VIRTUAL_MODULE_ID;
|
|
45
66
|
},
|
|
46
67
|
async load(id) {
|
|
47
|
-
if (id === RESOLVED_VIRTUAL_MODULE_ID) return await
|
|
68
|
+
if (id === RESOLVED_VIRTUAL_MODULE_ID) return await getCss();
|
|
69
|
+
},
|
|
70
|
+
handleHotUpdate() {
|
|
71
|
+
invalidate();
|
|
48
72
|
},
|
|
49
73
|
configureServer(devServer) {
|
|
50
74
|
server = devServer;
|
|
@@ -53,7 +77,7 @@ function stratalInertiaDevCss(options) {
|
|
|
53
77
|
next();
|
|
54
78
|
return;
|
|
55
79
|
}
|
|
56
|
-
|
|
80
|
+
getCss().then((css) => {
|
|
57
81
|
res.setHeader("Content-Type", "text/css");
|
|
58
82
|
res.setHeader("Cache-Control", "no-store");
|
|
59
83
|
res.end(css);
|
|
@@ -66,18 +90,90 @@ function stratalInertiaDevCss(options) {
|
|
|
66
90
|
};
|
|
67
91
|
}
|
|
68
92
|
//#endregion
|
|
93
|
+
//#region src/vite/type-gen-dispatcher.ts
|
|
94
|
+
const defaultSpawn = (cwd) => new Worker(new URL$1("./generator/type-generator.worker.mjs", import.meta.url), { workerData: { cwd } });
|
|
95
|
+
function createTypeGenDispatcher(options) {
|
|
96
|
+
const spawn = options.spawn ?? defaultSpawn;
|
|
97
|
+
const debounceMs = options.debounceMs ?? 250;
|
|
98
|
+
let pendingTimer = null;
|
|
99
|
+
let inflight = null;
|
|
100
|
+
let queued = false;
|
|
101
|
+
let disposed = false;
|
|
102
|
+
function fire() {
|
|
103
|
+
pendingTimer = null;
|
|
104
|
+
if (disposed) return;
|
|
105
|
+
if (inflight) {
|
|
106
|
+
queued = true;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const worker = spawn(options.cwd);
|
|
110
|
+
inflight = worker;
|
|
111
|
+
const finish = () => {
|
|
112
|
+
if (inflight === worker) inflight = null;
|
|
113
|
+
if (disposed) return;
|
|
114
|
+
if (queued) {
|
|
115
|
+
queued = false;
|
|
116
|
+
fire();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
worker.on("message", (msg) => {
|
|
120
|
+
options.onResult?.(msg);
|
|
121
|
+
});
|
|
122
|
+
worker.on("error", (err) => {
|
|
123
|
+
options.onError?.(err);
|
|
124
|
+
});
|
|
125
|
+
worker.on("exit", () => {
|
|
126
|
+
finish();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
schedule() {
|
|
131
|
+
if (disposed) return;
|
|
132
|
+
if (inflight) {
|
|
133
|
+
queued = true;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (pendingTimer) clearTimeout(pendingTimer);
|
|
137
|
+
pendingTimer = setTimeout(fire, debounceMs);
|
|
138
|
+
},
|
|
139
|
+
async dispose() {
|
|
140
|
+
disposed = true;
|
|
141
|
+
queued = false;
|
|
142
|
+
if (pendingTimer) {
|
|
143
|
+
clearTimeout(pendingTimer);
|
|
144
|
+
pendingTimer = null;
|
|
145
|
+
}
|
|
146
|
+
const worker = inflight;
|
|
147
|
+
inflight = null;
|
|
148
|
+
if (worker) try {
|
|
149
|
+
await worker.terminate();
|
|
150
|
+
} catch {}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
69
155
|
//#region src/vite/inertia-types-plugin.ts
|
|
70
156
|
const INERTIA_CALL_PATTERN = /ctx\.inertia\(|\.share\(|ctx\.flash\(|ctx\.defer\(|ctx\.optional\(|ctx\.merge\(|ctx\.once\(|ctx\.always\(/;
|
|
71
157
|
function stratalInertiaTypes() {
|
|
72
158
|
let cwd;
|
|
73
159
|
let pagesDir;
|
|
74
160
|
let srcDir;
|
|
161
|
+
let dispatcher = null;
|
|
75
162
|
return {
|
|
76
163
|
name: "stratal:inertia-types",
|
|
77
164
|
configResolved(config) {
|
|
78
165
|
cwd = config.root;
|
|
79
166
|
pagesDir = findPagesDir(cwd) + "/";
|
|
80
167
|
srcDir = join(cwd, "src") + "/";
|
|
168
|
+
dispatcher = createTypeGenDispatcher({
|
|
169
|
+
cwd,
|
|
170
|
+
onError(err) {
|
|
171
|
+
console.warn("[stratal:inertia-types] Type generation worker errored:", err.message);
|
|
172
|
+
},
|
|
173
|
+
onResult(result) {
|
|
174
|
+
if (!result.ok && result.error) console.warn("[stratal:inertia-types] Type generation failed:", result.error);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
81
177
|
},
|
|
82
178
|
async buildStart() {
|
|
83
179
|
if (!existsSync(pagesDir)) return;
|
|
@@ -87,7 +183,8 @@ function stratalInertiaTypes() {
|
|
|
87
183
|
console.warn("[stratal:inertia-types] Type generation failed during build:", error);
|
|
88
184
|
}
|
|
89
185
|
},
|
|
90
|
-
|
|
186
|
+
handleHotUpdate({ file }) {
|
|
187
|
+
if (!dispatcher) return;
|
|
91
188
|
if (!/\.(tsx|ts)$/.test(file)) return;
|
|
92
189
|
if (!!relative(srcDir, file).startsWith("..")) return;
|
|
93
190
|
if (!!relative(pagesDir, file).startsWith("..")) try {
|
|
@@ -96,10 +193,12 @@ function stratalInertiaTypes() {
|
|
|
96
193
|
} catch {
|
|
97
194
|
return;
|
|
98
195
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
196
|
+
dispatcher.schedule();
|
|
197
|
+
},
|
|
198
|
+
async closeBundle() {
|
|
199
|
+
if (dispatcher) {
|
|
200
|
+
await dispatcher.dispose();
|
|
201
|
+
dispatcher = null;
|
|
103
202
|
}
|
|
104
203
|
}
|
|
105
204
|
};
|
|
@@ -112,7 +211,28 @@ function stratalInertia(options) {
|
|
|
112
211
|
"@cloudflare/vite-plugin",
|
|
113
212
|
"wrangler",
|
|
114
213
|
"blake3-wasm",
|
|
115
|
-
"@stratal/inertia"
|
|
214
|
+
"@stratal/inertia",
|
|
215
|
+
"stratal",
|
|
216
|
+
"hono",
|
|
217
|
+
"@hono/zod-openapi",
|
|
218
|
+
"@hono/swagger-ui"
|
|
219
|
+
];
|
|
220
|
+
const dedupe = [
|
|
221
|
+
"react",
|
|
222
|
+
"react-dom",
|
|
223
|
+
"react-is",
|
|
224
|
+
"scheduler",
|
|
225
|
+
"@inertiajs/core",
|
|
226
|
+
"@inertiajs/react"
|
|
227
|
+
];
|
|
228
|
+
const noExternal = [
|
|
229
|
+
"react",
|
|
230
|
+
"react-dom",
|
|
231
|
+
"react-is",
|
|
232
|
+
"scheduler",
|
|
233
|
+
"use-sync-external-store",
|
|
234
|
+
"@inertiajs/core",
|
|
235
|
+
"@inertiajs/react"
|
|
116
236
|
];
|
|
117
237
|
const optimizeDepsInclude = [
|
|
118
238
|
"buffer",
|
|
@@ -134,6 +254,14 @@ function stratalInertia(options) {
|
|
|
134
254
|
exclude: [...existing, ...optimizeDepsExclude],
|
|
135
255
|
include: [...existingInclude, ...optimizeDepsInclude]
|
|
136
256
|
};
|
|
257
|
+
const existingDedupe = env.resolve?.dedupe ?? [];
|
|
258
|
+
const existingNoExternal = env.resolve?.noExternal;
|
|
259
|
+
const mergedNoExternal = [...Array.isArray(existingNoExternal) ? existingNoExternal : typeof existingNoExternal === "string" || existingNoExternal instanceof RegExp ? [existingNoExternal] : [], ...noExternal];
|
|
260
|
+
env.resolve = {
|
|
261
|
+
...env.resolve,
|
|
262
|
+
dedupe: [...existingDedupe, ...dedupe],
|
|
263
|
+
noExternal: existingNoExternal === true ? true : mergedNoExternal
|
|
264
|
+
};
|
|
137
265
|
const existingExternal = env.build?.rolldownOptions?.external ?? [];
|
|
138
266
|
env.build = {
|
|
139
267
|
...env.build,
|
package/dist/vite.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.mjs","names":[],"sources":["../src/vite/inertia-dev-css-plugin.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\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 collectStyle(server, options.entries)\n }\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 collectStyle(server, options.entries).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 { existsSync, readFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\nimport type { Plugin } from 'vite'\nimport { findPagesDir, runTypeGeneration } from '../generator/type-generator'\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\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 },\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 async handleHotUpdate({ file }) {\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 try {\n await runTypeGeneration(cwd)\n } catch (error) {\n console.warn('[stratal:inertia-types] Type generation failed during HMR:', error)\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 const optimizeDepsExclude = ['@cloudflare/vite-plugin', 'wrangler', 'blake3-wasm', '@stratal/inertia']\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 existingExternal = (env.build?.rolldownOptions?.external as string[]) ?? []\n env.build = {\n ...env.build,\n rolldownOptions: {\n ...env.build?.rolldownOptions,\n external: [...existingExternal, ...devOnlyExtern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AC/CH,SAAgB,eAAe,SAAiD;CAC9E,MAAM,UAAU,SAAS,WAAW,CAAC,uBAAuB;CAE5D,MAAM,sBAAsB;EAAC;EAA2B;EAAY;EAAe;EAAmB;CACtG,MAAM,sBAAsB;EAAC;EAAU;EAAW;EAAa;EAAU;CACzE,MAAM,mBAAmB,CAAC,WAAW;AAErC,QAAO;EACL,qBAAqB,EAAE,SAAS,CAAC;EACjC,qBAAqB;EACrB;GACE,MAAM;GACN,kBAAkB,OAAe,KAAyB;IACxD,MAAM,WAAW,IAAI,cAAc,WAAW,EAAE;IAChD,MAAM,kBAAkB,IAAI,cAAc,WAAW,EAAE;AACvD,QAAI,eAAe;KACjB,GAAG,IAAI;KACP,SAAS,CAAC,GAAG,UAAU,GAAG,oBAAoB;KAC9C,SAAS,CAAC,GAAG,iBAAiB,GAAG,oBAAoB;KACtD;IAED,MAAM,mBAAoB,IAAI,OAAO,iBAAiB,YAAyB,EAAE;AACjF,QAAI,QAAQ;KACV,GAAG,IAAI;KACP,iBAAiB;MACf,GAAG,IAAI,OAAO;MACd,UAAU,CAAC,GAAG,kBAAkB,GAAG,iBAAiB;MACrD;KACF;;GAEJ;EACF"}
|
|
1
|
+
{"version":3,"file":"vite.mjs","names":["URL"],"sources":["../src/vite/inertia-dev-css-plugin.ts","../src/vite/type-gen-dispatcher.ts","../src/vite/inertia-types-plugin.ts","../src/vite.ts"],"sourcesContent":["import type { ModuleNode, Plugin, ViteDevServer } from 'vite'\n\nconst CSS_LANGS_RE = /\\.(css|scss|sass|less|styl|stylus|pcss|postcss)(?:$|\\?)/\nconst VIRTUAL_MODULE_ID = 'virtual:inertia-ssr.css'\nconst RESOLVED_VIRTUAL_MODULE_ID = '\\0' + VIRTUAL_MODULE_ID\n\nexport interface InertiaDevCssOptions {\n entries: string[]\n}\n\nfunction collectStyleUrls(server: ViteDevServer, entries: string[]): string[] {\n const urls: string[] = []\n const visited = new Set<string>()\n\n function traverse(mod: ModuleNode) {\n if (visited.has(mod.url)) return\n visited.add(mod.url)\n\n if (CSS_LANGS_RE.test(mod.url)) {\n urls.push(mod.url)\n }\n\n for (const imported of mod.importedModules) {\n traverse(imported)\n }\n }\n\n for (const entry of entries) {\n const mod = server.moduleGraph.getModulesByFile(\n entry.startsWith('/') ? entry.slice(1) : entry,\n )\n\n if (mod) {\n for (const m of mod) {\n traverse(m)\n }\n }\n\n const urlMod = server.moduleGraph.urlToModuleMap.get(entry)\n if (urlMod) {\n traverse(urlMod)\n }\n }\n\n return urls\n}\n\nasync function collectStyle(server: ViteDevServer, entries: string[]): Promise<string> {\n for (const entry of entries) {\n try {\n await server.transformRequest(entry)\n }\n catch {\n //\n }\n }\n\n const urls = collectStyleUrls(server, entries)\n const styles: string[] = []\n\n for (const url of urls) {\n try {\n const separator = url.includes('?') ? '&' : '?'\n const result = await server.transformRequest(url + separator + 'direct')\n if (result?.code) {\n styles.push(result.code)\n }\n }\n catch {\n //\n }\n }\n\n return styles.join('\\n')\n}\n\nexport function stratalInertiaDevCss(options: InertiaDevCssOptions): Plugin {\n let server: ViteDevServer\n let cachedCss: string | null = null\n let inflight: Promise<string> | null = null\n let cacheEpoch = 0\n\n function invalidate(): void {\n cachedCss = null\n cacheEpoch++\n }\n\n async function getCss(): Promise<string> {\n if (cachedCss !== null) return cachedCss\n if (inflight) return inflight\n const epoch = cacheEpoch\n inflight = collectStyle(server, options.entries)\n .then((css) => {\n // Drop stale result if invalidated mid-flight, so the next caller re-collects.\n if (epoch === cacheEpoch) cachedCss = css\n return css\n })\n .finally(() => {\n inflight = null\n })\n return inflight\n }\n\n return {\n name: 'stratal:inertia-dev-css',\n apply: 'serve',\n\n resolveId(id) {\n if (id === VIRTUAL_MODULE_ID) {\n return RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n\n async load(id) {\n if (id === RESOLVED_VIRTUAL_MODULE_ID) {\n return await getCss()\n }\n },\n\n handleHotUpdate() {\n // JS/TS edits can add or remove CSS imports, which changes the SSR CSS graph\n // without the changed file itself matching CSS_LANGS_RE. Invalidate on every\n // HMR tick — collectStyle() is fast and dev-only.\n invalidate()\n },\n\n configureServer(devServer) {\n server = devServer\n\n server.middlewares.use((req, res, next) => {\n const pathname = new URL(req.url ?? '', 'http://localhost').pathname\n if (pathname !== '/__inertia/ssr-css') { next(); return; }\n\n getCss().then((css) => {\n res.setHeader('Content-Type', 'text/css')\n res.setHeader('Cache-Control', 'no-store')\n res.end(css)\n }).catch(() => {\n res.statusCode = 500\n res.end('')\n })\n })\n },\n }\n}\n","import { URL } from 'node:url'\nimport { Worker } from 'node:worker_threads'\n\nexport interface TypeGenWorkerResult {\n ok: boolean\n outputPath?: string\n pageCount?: number\n error?: string\n}\n\nexport interface TypeGenWorkerHandle {\n on(event: 'message', cb: (m: TypeGenWorkerResult) => void): this\n on(event: 'error', cb: (e: Error) => void): this\n on(event: 'exit', cb: (code: number) => void): this\n terminate(): Promise<number> | number\n}\n\nexport type TypeGenWorkerSpawner = (cwd: string) => TypeGenWorkerHandle\n\nexport interface TypeGenDispatcher {\n schedule(): void\n dispose(): Promise<void>\n}\n\nexport interface TypeGenDispatcherOptions {\n cwd: string\n spawn?: TypeGenWorkerSpawner\n debounceMs?: number\n onResult?: (result: TypeGenWorkerResult) => void\n onError?: (error: Error) => void\n}\n\nconst defaultSpawn: TypeGenWorkerSpawner = (cwd) =>\n new Worker(new URL('./generator/type-generator.worker.mjs', import.meta.url), {\n workerData: { cwd },\n })\n\nexport function createTypeGenDispatcher(options: TypeGenDispatcherOptions): TypeGenDispatcher {\n const spawn = options.spawn ?? defaultSpawn\n const debounceMs = options.debounceMs ?? 250\n\n let pendingTimer: ReturnType<typeof setTimeout> | null = null\n let inflight: TypeGenWorkerHandle | null = null\n let queued = false\n let disposed = false\n\n function fire() {\n pendingTimer = null\n if (disposed) return\n if (inflight) {\n queued = true\n return\n }\n\n const worker = spawn(options.cwd)\n inflight = worker\n\n const finish = () => {\n if (inflight === worker) inflight = null\n if (disposed) return\n if (queued) {\n queued = false\n fire()\n }\n }\n\n worker.on('message', (msg) => {\n // `exit` will follow; finish() runs there so terminate() has settled before the next spawn.\n options.onResult?.(msg)\n })\n\n worker.on('error', (err) => {\n options.onError?.(err)\n })\n\n worker.on('exit', () => {\n finish()\n })\n }\n\n return {\n schedule() {\n if (disposed) return\n if (inflight) {\n queued = true\n return\n }\n if (pendingTimer) clearTimeout(pendingTimer)\n pendingTimer = setTimeout(fire, debounceMs)\n },\n\n async dispose() {\n disposed = true\n queued = false\n if (pendingTimer) {\n clearTimeout(pendingTimer)\n pendingTimer = null\n }\n const worker = inflight\n inflight = null\n if (worker) {\n try {\n await worker.terminate()\n } catch {\n // ignore\n }\n }\n },\n }\n}\n","import { existsSync, readFileSync } from 'node:fs'\nimport { join, relative } from 'node:path'\nimport type { Plugin } from 'vite'\nimport { findPagesDir, runTypeGeneration } from '../generator/type-generator'\nimport { createTypeGenDispatcher, type TypeGenDispatcher } from './type-gen-dispatcher'\n\nconst INERTIA_CALL_PATTERN = /ctx\\.inertia\\(|\\.share\\(|ctx\\.flash\\(|ctx\\.defer\\(|ctx\\.optional\\(|ctx\\.merge\\(|ctx\\.once\\(|ctx\\.always\\(/\n\nexport function stratalInertiaTypes(): Plugin {\n let cwd: string\n let pagesDir: string\n let srcDir: string\n let dispatcher: TypeGenDispatcher | null = null\n\n return {\n name: 'stratal:inertia-types',\n\n configResolved(config) {\n cwd = config.root\n pagesDir = findPagesDir(cwd) + '/'\n srcDir = join(cwd, 'src') + '/'\n dispatcher = createTypeGenDispatcher({\n cwd,\n onError(err) {\n console.warn('[stratal:inertia-types] Type generation worker errored:', err.message)\n },\n onResult(result) {\n if (!result.ok && result.error) {\n console.warn('[stratal:inertia-types] Type generation failed:', result.error)\n }\n },\n })\n },\n\n async buildStart() {\n if (!existsSync(pagesDir)) return\n try {\n await runTypeGeneration(cwd)\n } catch (error) {\n console.warn('[stratal:inertia-types] Type generation failed during build:', error)\n }\n },\n\n handleHotUpdate({ file }) {\n if (!dispatcher) return\n if (!/\\.(tsx|ts)$/.test(file)) return\n\n const relToSrc = relative(srcDir, file)\n const isInSrc = !relToSrc.startsWith('..')\n\n if (!isInSrc) return\n\n // Page files always trigger regeneration\n const relToPages = relative(pagesDir, file)\n const isPageFile = !relToPages.startsWith('..')\n\n if (!isPageFile) {\n // For non-page files, only regenerate if they contain inertia-related calls\n try {\n const content = readFileSync(file, 'utf-8')\n if (!INERTIA_CALL_PATTERN.test(content)) return\n } catch {\n return\n }\n }\n\n dispatcher.schedule()\n },\n\n async closeBundle() {\n if (dispatcher) {\n await dispatcher.dispose()\n dispatcher = null\n }\n },\n }\n}\n","import type { EnvironmentOptions, Plugin } from 'vite'\nimport { stratalInertiaDevCss } from './vite/inertia-dev-css-plugin'\nimport { stratalInertiaTypes } from './vite/inertia-types-plugin'\n\nexport { stratalInertiaDevCss, stratalInertiaTypes }\n\nexport interface StratalInertiaPluginOptions {\n /** Client entry path(s) for CSS collection (default: ['/src/inertia/app.tsx']) */\n entries?: string[]\n}\n\nexport function stratalInertia(options?: StratalInertiaPluginOptions): Plugin[] {\n const entries = options?.entries ?? ['/src/inertia/app.tsx']\n\n // Hono and stratal must NOT be pre-bundled by Vite's optimizeDeps. When they are,\n // a duplicate copy ends up in `.vite/deps_<env>/` while the worker bundle imports\n // another copy from node_modules — Response objects from one instance flow into\n // a Context class from the other, and Hono's `set res` setter crashes inside\n // `this.#res.headers.entries()` because the prototype chain doesn't match.\n //\n // React 19 ships its main entry as CJS and relies on the optimizer's CJS→ESM\n // conversion, so it cannot be excluded outright. To prevent the related\n // identity-mismatch bug (two `?v=<hash>` copies after the optimizer re-runs\n // when a new dep is auto-discovered), the React-ecosystem packages are listed\n // in `resolve.noExternal` so Vite treats them as part of the user module graph\n // and `resolve.dedupe` so all imports collapse to a single physical copy.\n const optimizeDepsExclude = [\n '@cloudflare/vite-plugin',\n 'wrangler',\n 'blake3-wasm',\n '@stratal/inertia',\n 'stratal',\n 'hono',\n '@hono/zod-openapi',\n '@hono/swagger-ui',\n ]\n const dedupe = [\n 'react',\n 'react-dom',\n 'react-is',\n 'scheduler',\n '@inertiajs/core',\n '@inertiajs/react',\n ]\n const noExternal = [\n 'react',\n 'react-dom',\n 'react-is',\n 'scheduler',\n 'use-sync-external-store',\n '@inertiajs/core',\n '@inertiajs/react',\n ]\n const optimizeDepsInclude = ['buffer', 'buffer/', 'base64-js', 'ieee754']\n const devOnlyExternals = ['ts-morph']\n\n return [\n stratalInertiaDevCss({ entries }),\n stratalInertiaTypes(),\n {\n name: 'stratal:optimize-deps-fix',\n configEnvironment(_name: string, env: EnvironmentOptions) {\n const existing = env.optimizeDeps?.exclude ?? []\n const existingInclude = env.optimizeDeps?.include ?? []\n env.optimizeDeps = {\n ...env.optimizeDeps,\n exclude: [...existing, ...optimizeDepsExclude],\n include: [...existingInclude, ...optimizeDepsInclude],\n }\n\n const existingDedupe = env.resolve?.dedupe ?? []\n const existingNoExternal = env.resolve?.noExternal\n const mergedNoExternal: (string | RegExp)[] = [\n ...(Array.isArray(existingNoExternal)\n ? existingNoExternal\n : typeof existingNoExternal === 'string' || existingNoExternal instanceof RegExp\n ? [existingNoExternal]\n : []),\n ...noExternal,\n ]\n env.resolve = {\n ...env.resolve,\n dedupe: [...existingDedupe, ...dedupe],\n noExternal: existingNoExternal === true ? true : mergedNoExternal,\n }\n\n const existingExternal = (env.build?.rolldownOptions?.external as string[]) ?? []\n env.build = {\n ...env.build,\n rolldownOptions: {\n ...env.build?.rolldownOptions,\n external: [...existingExternal, ...devOnlyExternals],\n },\n }\n },\n },\n ]\n}\n"],"mappings":";;;;;;AAEA,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,6BAA6B,OAAO;AAM1C,SAAS,iBAAiB,QAAuB,SAA6B;CAC5E,MAAM,OAAiB,EAAE;CACzB,MAAM,0BAAU,IAAI,KAAa;CAEjC,SAAS,SAAS,KAAiB;EACjC,IAAI,QAAQ,IAAI,IAAI,IAAI,EAAE;EAC1B,QAAQ,IAAI,IAAI,IAAI;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AEJ;EACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stratal/inertia",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Inertia.js v3 server adapter for Stratal framework — server-driven React SPAs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@cloudflare/vite-plugin": ">=1.0.0",
|
|
70
|
-
"@inertiajs/core": "
|
|
71
|
-
"@inertiajs/react": "
|
|
72
|
-
"@inertiajs/vite": "
|
|
73
|
-
"@intlify/core-base": ">=11
|
|
74
|
-
"@stratal/testing": ">=0.0.
|
|
75
|
-
"hono": "
|
|
76
|
-
"react": "
|
|
77
|
-
"react-dom": "
|
|
78
|
-
"reflect-metadata": "
|
|
79
|
-
"stratal": "
|
|
80
|
-
"vite": "
|
|
81
|
-
"vitest": "
|
|
70
|
+
"@inertiajs/core": ">=3",
|
|
71
|
+
"@inertiajs/react": ">=3",
|
|
72
|
+
"@inertiajs/vite": ">=3",
|
|
73
|
+
"@intlify/core-base": ">=11",
|
|
74
|
+
"@stratal/testing": ">=0.0.21",
|
|
75
|
+
"hono": ">=4",
|
|
76
|
+
"react": ">=19",
|
|
77
|
+
"react-dom": ">=19",
|
|
78
|
+
"reflect-metadata": ">=0.2",
|
|
79
|
+
"stratal": ">=0.0.21",
|
|
80
|
+
"vite": ">=8",
|
|
81
|
+
"vitest": ">=4"
|
|
82
82
|
},
|
|
83
83
|
"peerDependenciesMeta": {
|
|
84
84
|
"@cloudflare/vite-plugin": {
|
|
@@ -110,26 +110,26 @@
|
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@cloudflare/vite-plugin": "^1.
|
|
114
|
-
"@cloudflare/workers-types": "4.
|
|
115
|
-
"@inertiajs/core": "^3.
|
|
116
|
-
"@inertiajs/react": "^3.
|
|
117
|
-
"@inertiajs/vite": "^3.
|
|
118
|
-
"@intlify/core-base": "^11.4.
|
|
113
|
+
"@cloudflare/vite-plugin": "^1.36.3",
|
|
114
|
+
"@cloudflare/workers-types": "4.20260510.1",
|
|
115
|
+
"@inertiajs/core": "^3.1.1",
|
|
116
|
+
"@inertiajs/react": "^3.1.1",
|
|
117
|
+
"@inertiajs/vite": "^3.1.1",
|
|
118
|
+
"@intlify/core-base": "^11.4.2",
|
|
119
119
|
"@stratal/testing": "workspace:*",
|
|
120
|
-
"@types/node": "^25.6.
|
|
120
|
+
"@types/node": "^25.6.2",
|
|
121
121
|
"@types/react": "^19.2.14",
|
|
122
122
|
"@types/react-dom": "^19.2.3",
|
|
123
123
|
"@vitest/runner": "~4.1.5",
|
|
124
124
|
"@vitest/snapshot": "~4.1.5",
|
|
125
|
-
"hono": "^4.12.
|
|
126
|
-
"react": "^19.2.
|
|
127
|
-
"react-dom": "^19.2.
|
|
125
|
+
"hono": "^4.12.18",
|
|
126
|
+
"react": "^19.2.6",
|
|
127
|
+
"react-dom": "^19.2.6",
|
|
128
128
|
"reflect-metadata": "^0.2.2",
|
|
129
129
|
"stratal": "workspace:*",
|
|
130
|
-
"tsdown": "^0.
|
|
130
|
+
"tsdown": "^0.22.0",
|
|
131
131
|
"typescript": "^6.0.3",
|
|
132
|
-
"vite": "^8.0.
|
|
132
|
+
"vite": "^8.0.11",
|
|
133
133
|
"vitest": "~4.1.5"
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-generator-C5JljyzK.mjs","names":[],"sources":["../src/generator/type-generator.ts"],"sourcesContent":["import { existsSync, mkdirSync, 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((s) => s.charAt(0).toUpperCase() + s.slice(1)).join('') + 'PageProps'\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): void {\n mkdirSync(dirname(outputPath), { recursive: true })\n writeFileSync(outputPath, content, 'utf-8')\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;AAC3B,QAAO,OAAO;;AAYhB,eAAe,cAAc,cAA0G;CACrI,MAAM,EAAE,SAAS,YAAY,OAAO,MAAM,aAAa;AAcvD,QAAO;EAAE,SAAA,IAZW,QAAQ;GAC1B,kBAAkB;GAClB,6BAA6B;GAC7B,iBAAiB,eAAe,KAAA,IAAY;IAC1C,KAAK,GAAG,QAAQ;IAChB,iBAAiB;IACjB,kBAA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