@guren/core 1.8.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,6 +77,30 @@ interface ClientAssetEnv {
77
77
  * @param label Platform name for the warning message, e.g. `'Lambda build'`.
78
78
  */
79
79
  declare function resolveClientAssetEnv(publicDir: string, clientEntryKey: string, label: string): ClientAssetEnv;
80
+ /**
81
+ * The client build manifest as JSON text, for the deploy targets' runtime
82
+ * manifest injection (`GUREN_VITE_MANIFEST`): `viteAsset()` resolves
83
+ * content-page asset URLs from the client manifest at render time, and a
84
+ * bundled function or worker has no `public/assets/manifest.json` to read.
85
+ * How the payload reaches the runtime is per-plugin (a generated-entry
86
+ * assignment, a bundler `define`); *what* the payload is, is this.
87
+ *
88
+ * Separate from `resolveClientAssetEnv` because that helper answers only for
89
+ * the client *entry*: a content-page app can have a manifest of CSS build
90
+ * inputs and no `resources/js/app.tsx` at all, and its `viteAsset()` calls
91
+ * still need the whole manifest.
92
+ *
93
+ * The payload is trimmed to the fields the runtime rule reads — `file` and
94
+ * `css` per entry (`getManifestFile`/`getManifestCss` in @guren/server's
95
+ * vite-manifest.ts) — because it ships inside executable code: a large app's
96
+ * manifest is dominated by per-chunk `imports`/`dynamicImports` graph
97
+ * metadata nothing consumes, and Workers caps bundle size. Trimming also
98
+ * validates the shape at build time, so a parseable-but-not-a-manifest file
99
+ * (`null`, an array) is reported as "no manifest" here instead of being baked
100
+ * in to fail at first render. String and array entry forms pass through
101
+ * untrimmed — the runtime accepts them, and the two paths must not diverge.
102
+ */
103
+ declare function clientManifestJson(publicDir: string): string | undefined;
80
104
  /**
81
105
  * Absolute path of the built SSR entry chunk, or undefined when the app has no
82
106
  * SSR build. Verifying that the chunk actually exports a renderer is left to
@@ -332,4 +356,4 @@ declare function renderDevOnlyStub(module: DevOnlyModule, message: string): stri
332
356
  */
333
357
  declare const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
334
358
  //#endregion
335
- export { ClientAssetEnv, DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, DatabaseDialect, DatabaseDialectDetection, DevOnlyModule, DevOnlyModuleKind, DevOnlySpecifier, MCP_SDK_SUBPATH_PREFIX, Manifest, ManifestEntry, PathLike, SQL_CLIENT_MODULES, SqlClientModule, SqlClientSpecifier, UnusedSqlClient, assertOutputDirOutsideRoot, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, unusedSqlClients };
359
+ export { ClientAssetEnv, DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, DatabaseDialect, DatabaseDialectDetection, DevOnlyModule, DevOnlyModuleKind, DevOnlySpecifier, MCP_SDK_SUBPATH_PREFIX, Manifest, ManifestEntry, PathLike, SQL_CLIENT_MODULES, SqlClientModule, SqlClientSpecifier, UnusedSqlClient, assertOutputDirOutsideRoot, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, unusedSqlClients };
@@ -59,11 +59,29 @@ function readManifest(...paths) {
59
59
  }
60
60
  }
61
61
  }
62
- /** The two layouts `readManifest` accepts, in preference order. */
62
+ /**
63
+ * The two layouts `readManifest` accepts, in preference order: `.vite/` first,
64
+ * because Vite >= 5 writes it there and a flat `manifest.json` beside it is
65
+ * most likely stale output of an older config. `@guren/server`'s runtime
66
+ * lookup (`clientManifestCandidates` in `http/vite-manifest.ts`) prefers the
67
+ * same layout — the orders must agree, or an app with both files resolves
68
+ * different asset versions locally than after a deploy; the server's
69
+ * `tests/http/vite-manifest.test.ts` pins the agreement (the rule cannot be
70
+ * shared as code, since this module imports nothing beyond node builtins).
71
+ */
63
72
  function manifestPaths(dir) {
64
73
  return [resolve(dir, ".vite/manifest.json"), resolve(dir, "manifest.json")];
65
74
  }
66
75
  /**
76
+ * The one statement of where an app's *client* manifest lives: under
77
+ * `<publicDir>/assets`, in either Vite layout. `resolveClientAssetEnv` and
78
+ * `clientManifestJson` both answer from this read — stating the composition
79
+ * twice is how the two would come to look in different places.
80
+ */
81
+ function readClientManifest(publicDir) {
82
+ return readManifest(...manifestPaths(resolve(publicDir, "assets")))?.manifest;
83
+ }
84
+ /**
67
85
  * Resolve symlinks in the parts of `path` that exist, keeping the trailing
68
86
  * components that do not. `realpathSync` throws on a path that is not there
69
87
  * yet, and an output directory usually is not on a first build.
@@ -155,7 +173,7 @@ function importSpecifier(fromDir, target, label) {
155
173
  * @param label Platform name for the warning message, e.g. `'Lambda build'`.
156
174
  */
157
175
  function resolveClientAssetEnv(publicDir, clientEntryKey, label) {
158
- const entry = (readManifest(...manifestPaths(resolve(publicDir, "assets")))?.manifest)?.[clientEntryKey];
176
+ const entry = readClientManifest(publicDir)?.[clientEntryKey];
159
177
  if (!entry?.file) {
160
178
  console.warn(`${label}: no client manifest entry for "${clientEntryKey}"; GUREN_INERTIA_ENTRY will not be set.`);
161
179
  return {};
@@ -166,6 +184,47 @@ function resolveClientAssetEnv(publicDir, clientEntryKey, label) {
166
184
  };
167
185
  }
168
186
  /**
187
+ * The client build manifest as JSON text, for the deploy targets' runtime
188
+ * manifest injection (`GUREN_VITE_MANIFEST`): `viteAsset()` resolves
189
+ * content-page asset URLs from the client manifest at render time, and a
190
+ * bundled function or worker has no `public/assets/manifest.json` to read.
191
+ * How the payload reaches the runtime is per-plugin (a generated-entry
192
+ * assignment, a bundler `define`); *what* the payload is, is this.
193
+ *
194
+ * Separate from `resolveClientAssetEnv` because that helper answers only for
195
+ * the client *entry*: a content-page app can have a manifest of CSS build
196
+ * inputs and no `resources/js/app.tsx` at all, and its `viteAsset()` calls
197
+ * still need the whole manifest.
198
+ *
199
+ * The payload is trimmed to the fields the runtime rule reads — `file` and
200
+ * `css` per entry (`getManifestFile`/`getManifestCss` in @guren/server's
201
+ * vite-manifest.ts) — because it ships inside executable code: a large app's
202
+ * manifest is dominated by per-chunk `imports`/`dynamicImports` graph
203
+ * metadata nothing consumes, and Workers caps bundle size. Trimming also
204
+ * validates the shape at build time, so a parseable-but-not-a-manifest file
205
+ * (`null`, an array) is reported as "no manifest" here instead of being baked
206
+ * in to fail at first render. String and array entry forms pass through
207
+ * untrimmed — the runtime accepts them, and the two paths must not diverge.
208
+ */
209
+ function clientManifestJson(publicDir) {
210
+ const manifest = readClientManifest(publicDir);
211
+ if (manifest === void 0) return;
212
+ if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) return;
213
+ const trimmed = {};
214
+ for (const [key, entry] of Object.entries(manifest)) {
215
+ if (typeof entry === "string" || Array.isArray(entry)) {
216
+ trimmed[key] = entry;
217
+ continue;
218
+ }
219
+ if (typeof entry !== "object" || entry === null) continue;
220
+ const kept = {};
221
+ if (typeof entry.file === "string") kept.file = entry.file;
222
+ if (Array.isArray(entry.css) && entry.css.length > 0) kept.css = entry.css;
223
+ if (kept.file !== void 0 || kept.css !== void 0) trimmed[key] = kept;
224
+ }
225
+ return JSON.stringify(trimmed);
226
+ }
227
+ /**
169
228
  * Absolute path of the built SSR entry chunk, or undefined when the app has no
170
229
  * SSR build. Verifying that the chunk actually exports a renderer is left to
171
230
  * the caller: the platforms disagree on whether importing it during a build is
@@ -498,4 +557,4 @@ function renderDevOnlyStub(module, message) {
498
557
  */
499
558
  const MCP_SDK_SUBPATH_PREFIX = "@modelcontextprotocol/sdk/";
500
559
  //#endregion
501
- export { DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, MCP_SDK_SUBPATH_PREFIX, SQL_CLIENT_MODULES, assertOutputDirOutsideRoot, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, unusedSqlClients };
560
+ export { DATABASE_CONFIG_CANDIDATES, DATABASE_DIALECTS, DATABASE_FACTORIES, DEV_ONLY_MODULES, MCP_SDK_SUBPATH_PREFIX, SQL_CLIENT_MODULES, assertOutputDirOutsideRoot, clientManifestJson, detectDatabaseDialects, importSpecifier, parseDatabaseDialects, readManifest, renderDevOnlyStub, resetOutputDir, resolveClientAssetEnv, resolvePathLike, resolveSsrEntryFile, ssrRuntimePaths, stageStaticAssets, unusedSqlClients };
@@ -0,0 +1 @@
1
+ export * from "@guren/server/jsx-dev-runtime";
@@ -0,0 +1,2 @@
1
+ export * from "@guren/server/jsx-dev-runtime";
2
+ export {};
@@ -0,0 +1 @@
1
+ export * from "@guren/server/jsx-runtime";
@@ -0,0 +1,2 @@
1
+ export * from "@guren/server/jsx-runtime";
2
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/core",
3
- "version": "1.8.1",
3
+ "version": "1.10.0",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "./src/bin.ts",
@@ -52,6 +52,14 @@
52
52
  "./internal/zod-compat": {
53
53
  "types": "./dist/internal/zod-compat.d.ts",
54
54
  "default": "./dist/internal/zod-compat.js"
55
+ },
56
+ "./jsx-runtime": {
57
+ "types": "./dist/jsx-runtime.d.ts",
58
+ "default": "./dist/jsx-runtime.js"
59
+ },
60
+ "./jsx-dev-runtime": {
61
+ "types": "./dist/jsx-dev-runtime.d.ts",
62
+ "default": "./dist/jsx-dev-runtime.js"
55
63
  }
56
64
  },
57
65
  "bin": {
@@ -64,9 +72,9 @@
64
72
  "typecheck": "tsc --noEmit"
65
73
  },
66
74
  "dependencies": {
67
- "@guren/cli": "^2.9.1",
75
+ "@guren/cli": "^2.11.0",
68
76
  "@guren/orm": "^2.6.1",
69
- "@guren/server": "^2.10.1"
77
+ "@guren/server": "^2.12.0"
70
78
  },
71
79
  "devDependencies": {
72
80
  "@types/node": "^20.14.10",