@thexjs/core 1.2.2 → 1.2.4

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/adapter.d.ts CHANGED
@@ -1,3 +1,26 @@
1
+ /**
2
+ * The scratch directory that holds the transient (transpiled module / entry
3
+ * source) files the bundler reads before inlining everything into
4
+ * `index.mjs`. Part of the adapter SDK contract: the entry generator computes
5
+ * relative `import` paths off the directory the adapter creates via this
6
+ * helper, so both sides must agree on the same location.
7
+ */
8
+ declare function adapterScratchDir(functionDir: string): string;
9
+ /**
10
+ * Bundles the pure `index.mjs` render function that inlines the whole
11
+ * SSR/API dependency graph (`@thexjs/core`, `react`, `react-dom`, every
12
+ * route/layout/middleware/action module) so it runs on a platform's Node
13
+ * runtime with zero `node_modules` and zero dynamic filesystem access at
14
+ * request time.
15
+ *
16
+ * `entrySource` (as produced by `generateAdapterEntry`, plus whatever
17
+ * platform bridge the adapter appended) should reference the transpiled
18
+ * module refs by compiled path. The scratch dir lives *inside* `functionDir`
19
+ * (inside the project tree) so Bun's bare-import resolution walks up to the
20
+ * project's real `node_modules`.
21
+ */
22
+ declare function bundleRenderFunction(functionDir: string, entrySource: string): Promise<void>;
23
+
1
24
  interface AdapterOptions {
2
25
  /** Project root (defaults to process.cwd()). */
3
26
  projectRoot?: string;
@@ -62,41 +85,6 @@ interface BuildManifest {
62
85
  images?: AdapterOptions["images"];
63
86
  }
64
87
 
65
- /** Registry of every unique source file that needs transpiling, keyed by absolute path. */
66
- declare class ModuleRegistry {
67
- private scratchDir;
68
- private byPath;
69
- constructor(scratchDir: string);
70
- ref(sourcePath: string, prefix: string): CompiledModuleRef;
71
- all(): CompiledModuleRef[];
72
- }
73
- /**
74
- * Resolve the full set of server-mode routes, API routes, layout chains,
75
- * middleware chains and standalone server-action files -- entirely at build
76
- * time, using the same scanners `createApp`/`build` use internally. Nothing
77
- * here touches the filesystem at request time, which is what makes the
78
- * output safe to run on any Node.js runtime (no dynamic fs scanning,
79
- * no dynamic `import(path)` of a `.tsx` file).
80
- */
81
- declare function resolveBuildManifest(options: AdapterOptions, scratchDir: string): Promise<BuildManifest>;
82
- declare function allModuleRefs(manifest: BuildManifest): CompiledModuleRef[];
83
-
84
- /**
85
- * Transpiles each referenced route/layout/middleware/action source file
86
- * (TSX/TS, authored for Bun) into a standalone Node-runnable ESM module.
87
- *
88
- * We deliberately transpile file-by-file (rather than letting the final
89
- * bundle step follow dynamic `import()` calls) because `@thexjs/core`'s own
90
- * scanners find these files by walking the filesystem at *runtime* -- that
91
- * strategy only works on Bun, which understands `.tsx`/`.ts` natively.
92
- * A deployed Node.js runtime does not, so every route file that will run
93
- * inside the render function has to already be plain JS before it gets
94
- * there. `react`/`react-dom`/`@thexjs/core` stay external here; they get
95
- * inlined once, together, in the final bundle step so we don't duplicate
96
- * framework code per-route.
97
- */
98
- declare function transpileModules(refs: CompiledModuleRef[]): Promise<void>;
99
-
100
88
  /**
101
89
  * Serializes runtime config (security / observability / images) into the
102
90
  * generated entry. Only JSON-serializable values can cross the build
@@ -127,27 +115,39 @@ declare function serializeRuntimeOptions(label: string, options: Record<string,
127
115
  */
128
116
  declare function generateAdapterEntry(manifest: BuildManifest, entryDir: string): string;
129
117
 
118
+ /** Registry of every unique source file that needs transpiling, keyed by absolute path. */
119
+ declare class ModuleRegistry {
120
+ private scratchDir;
121
+ private byPath;
122
+ constructor(scratchDir: string);
123
+ ref(sourcePath: string, prefix: string): CompiledModuleRef;
124
+ all(): CompiledModuleRef[];
125
+ }
130
126
  /**
131
- * The scratch directory that holds the transient (transpiled module / entry
132
- * source) files the bundler reads before inlining everything into
133
- * `index.mjs`. Part of the adapter SDK contract: the entry generator computes
134
- * relative `import` paths off the directory the adapter creates via this
135
- * helper, so both sides must agree on the same location.
127
+ * Resolve the full set of server-mode routes, API routes, layout chains,
128
+ * middleware chains and standalone server-action files -- entirely at build
129
+ * time, using the same scanners `createApp`/`build` use internally. Nothing
130
+ * here touches the filesystem at request time, which is what makes the
131
+ * output safe to run on any Node.js runtime (no dynamic fs scanning,
132
+ * no dynamic `import(path)` of a `.tsx` file).
136
133
  */
137
- declare function adapterScratchDir(functionDir: string): string;
134
+ declare function resolveBuildManifest(options: AdapterOptions, scratchDir: string): Promise<BuildManifest>;
135
+ declare function allModuleRefs(manifest: BuildManifest): CompiledModuleRef[];
136
+
138
137
  /**
139
- * Bundles the pure `index.mjs` render function that inlines the whole
140
- * SSR/API dependency graph (`@thexjs/core`, `react`, `react-dom`, every
141
- * route/layout/middleware/action module) so it runs on a platform's Node
142
- * runtime with zero `node_modules` and zero dynamic filesystem access at
143
- * request time.
138
+ * Transpiles each referenced route/layout/middleware/action source file
139
+ * (TSX/TS, authored for Bun) into a standalone Node-runnable ESM module.
144
140
  *
145
- * `entrySource` (as produced by `generateAdapterEntry`, plus whatever
146
- * platform bridge the adapter appended) should reference the transpiled
147
- * module refs by compiled path. The scratch dir lives *inside* `functionDir`
148
- * (inside the project tree) so Bun's bare-import resolution walks up to the
149
- * project's real `node_modules`.
141
+ * We deliberately transpile file-by-file (rather than letting the final
142
+ * bundle step follow dynamic `import()` calls) because `@thexjs/core`'s own
143
+ * scanners find these files by walking the filesystem at *runtime* -- that
144
+ * strategy only works on Bun, which understands `.tsx`/`.ts` natively.
145
+ * A deployed Node.js runtime does not, so every route file that will run
146
+ * inside the render function has to already be plain JS before it gets
147
+ * there. `react`/`react-dom`/`@thexjs/core` stay external here; they get
148
+ * inlined once, together, in the final bundle step so we don't duplicate
149
+ * framework code per-route.
150
150
  */
151
- declare function bundleRenderFunction(functionDir: string, entrySource: string): Promise<void>;
151
+ declare function transpileModules(refs: CompiledModuleRef[]): Promise<void>;
152
152
 
153
153
  export { type AdapterOptions, type BuildManifest, type CompiledModuleRef, ModuleRegistry, type ResolvedAction, type ResolvedRoute, adapterScratchDir, allModuleRefs, bundleRenderFunction, generateAdapterEntry, resolveBuildManifest, serializeRuntimeOptions, transpileModules };
package/dist/adapter.js CHANGED
@@ -8,154 +8,38 @@ import {
8
8
  scanNotFound,
9
9
  scanPages,
10
10
  scanRoutes
11
- } from "./chunk-Y3MLOFAG.js";
11
+ } from "./chunk-O6SIM7EF.js";
12
12
 
13
- // src/adapter/scan.ts
14
- import { existsSync } from "fs";
13
+ // src/adapter/bundle.ts
14
+ import { mkdirSync, rmSync, writeFileSync } from "fs";
15
15
  import { join } from "path";
16
- var idCounter = 0;
17
- function nextIdentifier(prefix) {
18
- idCounter += 1;
19
- return `__x_${prefix}_${idCounter}`;
20
- }
21
- var ModuleRegistry = class {
22
- constructor(scratchDir) {
23
- this.scratchDir = scratchDir;
24
- }
25
- scratchDir;
26
- byPath = /* @__PURE__ */ new Map();
27
- ref(sourcePath, prefix) {
28
- const existing = this.byPath.get(sourcePath);
29
- if (existing) return existing;
30
- const identifier = nextIdentifier(prefix);
31
- const compiledPath = join(this.scratchDir, `${identifier}.mjs`);
32
- const entry = { sourcePath, compiledPath, identifier };
33
- this.byPath.set(sourcePath, entry);
34
- return entry;
35
- }
36
- all() {
37
- return [...this.byPath.values()];
38
- }
39
- };
40
- async function resolveBuildManifest(options, scratchDir) {
41
- const projectRoot = options.projectRoot ?? process.cwd();
42
- const pagesDir = options.pagesDir || options.routesDir || join(projectRoot, "src", "pages");
43
- const apiDir = options.apiDir;
44
- const layoutsDir = options.layoutsDir || pagesDir;
45
- const actionsDir = options.actionsDir ?? (existsSync(join(projectRoot, "src", "actions")) ? join(projectRoot, "src", "actions") : void 0);
46
- const registry = new ModuleRegistry(scratchDir);
47
- let found = existsSync(pagesDir) ? scanPages(pagesDir) : [];
48
- const apiFound = [];
49
- if (apiDir && existsSync(apiDir)) apiFound.push(...scanApiDir(apiDir));
50
- const legacyApiDir = join(pagesDir, "api");
51
- if (existsSync(legacyApiDir) && legacyApiDir !== apiDir) {
52
- apiFound.push(...scanApiDir(legacyApiDir));
53
- }
54
- found = found.filter((r) => !r.isApi);
55
- found.push(...apiFound);
56
- const dedicatedLayouts = options.layoutsDir && existsSync(options.layoutsDir) ? scanLayoutsDir(options.layoutsDir) : [];
57
- const nestedLayouts = existsSync(pagesDir) ? scanLayouts(pagesDir) : [];
58
- const layouts = [...dedicatedLayouts, ...nestedLayouts];
59
- const middlewareEntries = existsSync(pagesDir) ? scanMiddleware(pagesDir) : [];
60
- const routes = [];
61
- for (const entry of found) {
62
- if (entry.isApi) {
63
- routes.push({
64
- routePath: entry.routePath,
65
- paramNames: entry.paramNames,
66
- isApi: true,
67
- mode: "server",
68
- route: registry.ref(entry.filePath, "api"),
69
- layoutChain: [],
70
- middlewareChain: []
71
- });
72
- continue;
73
- }
74
- const mod = await import(entry.filePath);
75
- if (!mod.default && !mod.actions) continue;
76
- if ((mod.mode ?? "server") === "static") continue;
77
- const layoutChain = findLayoutChain(entry.filePath, layouts, pagesDir);
78
- const missingDedicated = dedicatedLayouts.filter(
79
- (rootLayout2) => !layoutChain.some((l) => l.filePath === rootLayout2.filePath)
80
- );
81
- if (missingDedicated.length > 0) layoutChain.unshift(...missingDedicated);
82
- const mwChain = findMiddlewareChain(entry.filePath, middlewareEntries, pagesDir);
83
- routes.push({
84
- routePath: entry.routePath,
85
- paramNames: entry.paramNames,
86
- isApi: false,
87
- mode: mod.mode ?? "server",
88
- ...mod.revalidate !== void 0 ? { revalidate: mod.revalidate } : {},
89
- route: registry.ref(entry.filePath, "page"),
90
- layoutChain: layoutChain.map((l) => registry.ref(l.filePath, "layout")),
91
- middlewareChain: mwChain.map((m) => registry.ref(m.filePath, "mw"))
92
- });
93
- }
94
- const actions = [];
95
- if (actionsDir && existsSync(actionsDir)) {
96
- for (const actionFile of scanRoutes(actionsDir)) {
97
- const segments = actionFile.routePath.split("/").filter(Boolean);
98
- const fileName = segments[segments.length - 1] ?? "";
99
- const parentPath = fileName === "index" || !fileName ? actionFile.routePath : `/${segments.slice(0, -1).join("/")}`;
100
- actions.push({
101
- parentPath,
102
- paramNames: actionFile.paramNames,
103
- module: registry.ref(actionFile.filePath, "action")
104
- });
105
- }
106
- }
107
- const notFoundEntry = existsSync(pagesDir) ? scanNotFound(pagesDir) : null;
108
- const notFound = notFoundEntry ? registry.ref(notFoundEntry.filePath, "notfound") : void 0;
109
- const rootLayoutEntry = dedicatedLayouts[0] ?? layouts.find((l) => l.dirPath === pagesDir);
110
- const rootLayout = rootLayoutEntry ? registry.ref(rootLayoutEntry.filePath, "rootlayout") : void 0;
111
- return {
112
- projectRoot,
113
- pagesDirLabel: pagesDir,
114
- routes,
115
- actions,
116
- ...notFound ? { notFound } : {},
117
- ...rootLayout ? { rootLayout } : {},
118
- hasServerSurface: routes.length > 0 || actions.length > 0,
119
- ...existsSync(join(projectRoot, "public", "styles.css")) ? { stylesheetHref: "/styles.css" } : {},
120
- security: options.security,
121
- observability: options.observability,
122
- images: options.images
123
- };
124
- }
125
- function allModuleRefs(manifest) {
126
- const map = /* @__PURE__ */ new Map();
127
- const add = (ref) => map.set(ref.sourcePath, ref);
128
- for (const r of manifest.routes) {
129
- add(r.route);
130
- for (const l of r.layoutChain) add(l);
131
- for (const m of r.middlewareChain) add(m);
132
- }
133
- for (const a of manifest.actions) add(a.module);
134
- if (manifest.notFound) add(manifest.notFound);
135
- if (manifest.rootLayout) add(manifest.rootLayout);
136
- return [...map.values()];
16
+ function adapterScratchDir(functionDir) {
17
+ return join(functionDir, ".scratch");
137
18
  }
138
-
139
- // src/adapter/transpile.ts
140
- import { mkdirSync } from "fs";
141
- import { dirname } from "path";
142
- async function transpileModules(refs) {
143
- for (const ref of refs) {
19
+ async function bundleRenderFunction(functionDir, entrySource) {
20
+ mkdirSync(functionDir, { recursive: true });
21
+ const scratchDir = adapterScratchDir(functionDir);
22
+ mkdirSync(scratchDir, { recursive: true });
23
+ try {
24
+ const entryPath = join(scratchDir, "entry.mjs");
25
+ writeFileSync(entryPath, entrySource, "utf-8");
144
26
  const result = await Bun.build({
145
- entrypoints: [ref.sourcePath],
27
+ entrypoints: [entryPath],
146
28
  target: "node",
147
29
  format: "esm",
148
30
  splitting: false,
149
- external: ["react", "react/*", "react-dom", "react-dom/*", "@thexjs/core", "@thexjs/core/*"]
31
+ minify: false
150
32
  });
151
33
  if (!result.success || result.outputs.length === 0) {
152
34
  const messages = result.logs.map((l) => l.message).join("\n");
153
- throw new Error(`[@thexjs/core] failed to transpile ${ref.sourcePath}:
35
+ throw new Error(`[@thexjs/core] failed to bundle render function:
154
36
  ${messages}`);
155
37
  }
156
38
  const [output] = result.outputs;
157
- mkdirSync(dirname(ref.compiledPath), { recursive: true });
158
- await Bun.write(ref.compiledPath, await output.arrayBuffer());
39
+ const code = await output.text();
40
+ writeFileSync(join(functionDir, "index.mjs"), code, "utf-8");
41
+ } finally {
42
+ rmSync(scratchDir, { recursive: true, force: true });
159
43
  }
160
44
  }
161
45
 
@@ -276,36 +160,151 @@ function generateAdapterEntry(manifest, entryDir) {
276
160
  return lines.join("\n");
277
161
  }
278
162
 
279
- // src/adapter/bundle.ts
280
- import { mkdirSync as mkdirSync2, rmSync, writeFileSync } from "fs";
163
+ // src/adapter/scan.ts
164
+ import { existsSync } from "fs";
281
165
  import { join as join2 } from "path";
282
- function adapterScratchDir(functionDir) {
283
- return join2(functionDir, ".scratch");
166
+ var idCounter = 0;
167
+ function nextIdentifier(prefix) {
168
+ idCounter += 1;
169
+ return `__x_${prefix}_${idCounter}`;
284
170
  }
285
- async function bundleRenderFunction(functionDir, entrySource) {
286
- mkdirSync2(functionDir, { recursive: true });
287
- const scratchDir = adapterScratchDir(functionDir);
288
- mkdirSync2(scratchDir, { recursive: true });
289
- try {
290
- const entryPath = join2(scratchDir, "entry.mjs");
291
- writeFileSync(entryPath, entrySource, "utf-8");
171
+ var ModuleRegistry = class {
172
+ constructor(scratchDir) {
173
+ this.scratchDir = scratchDir;
174
+ }
175
+ scratchDir;
176
+ byPath = /* @__PURE__ */ new Map();
177
+ ref(sourcePath, prefix) {
178
+ const existing = this.byPath.get(sourcePath);
179
+ if (existing) return existing;
180
+ const identifier = nextIdentifier(prefix);
181
+ const compiledPath = join2(this.scratchDir, `${identifier}.mjs`);
182
+ const entry = { sourcePath, compiledPath, identifier };
183
+ this.byPath.set(sourcePath, entry);
184
+ return entry;
185
+ }
186
+ all() {
187
+ return [...this.byPath.values()];
188
+ }
189
+ };
190
+ async function resolveBuildManifest(options, scratchDir) {
191
+ const projectRoot = options.projectRoot ?? process.cwd();
192
+ const pagesDir = options.pagesDir || options.routesDir || join2(projectRoot, "src", "pages");
193
+ const apiDir = options.apiDir;
194
+ const actionsDir = options.actionsDir ?? (existsSync(join2(projectRoot, "src", "actions")) ? join2(projectRoot, "src", "actions") : void 0);
195
+ const registry = new ModuleRegistry(scratchDir);
196
+ let found = existsSync(pagesDir) ? scanPages(pagesDir) : [];
197
+ const apiFound = [];
198
+ if (apiDir && existsSync(apiDir)) apiFound.push(...scanApiDir(apiDir));
199
+ const legacyApiDir = join2(pagesDir, "api");
200
+ if (existsSync(legacyApiDir) && legacyApiDir !== apiDir) {
201
+ apiFound.push(...scanApiDir(legacyApiDir));
202
+ }
203
+ found = found.filter((r) => !r.isApi);
204
+ found.push(...apiFound);
205
+ const dedicatedLayouts = options.layoutsDir && existsSync(options.layoutsDir) ? scanLayoutsDir(options.layoutsDir) : [];
206
+ const nestedLayouts = existsSync(pagesDir) ? scanLayouts(pagesDir) : [];
207
+ const layouts = [...dedicatedLayouts, ...nestedLayouts];
208
+ const middlewareEntries = existsSync(pagesDir) ? scanMiddleware(pagesDir) : [];
209
+ const routes = [];
210
+ for (const entry of found) {
211
+ if (entry.isApi) {
212
+ routes.push({
213
+ routePath: entry.routePath,
214
+ paramNames: entry.paramNames,
215
+ isApi: true,
216
+ mode: "server",
217
+ route: registry.ref(entry.filePath, "api"),
218
+ layoutChain: [],
219
+ middlewareChain: []
220
+ });
221
+ continue;
222
+ }
223
+ const mod = await import(entry.filePath);
224
+ if (!mod.default && !mod.actions) continue;
225
+ if ((mod.mode ?? "server") === "static") continue;
226
+ const layoutChain = findLayoutChain(entry.filePath, layouts, pagesDir);
227
+ const missingDedicated = dedicatedLayouts.filter(
228
+ (rootLayout2) => !layoutChain.some((l) => l.filePath === rootLayout2.filePath)
229
+ );
230
+ if (missingDedicated.length > 0) layoutChain.unshift(...missingDedicated);
231
+ const mwChain = findMiddlewareChain(entry.filePath, middlewareEntries, pagesDir);
232
+ routes.push({
233
+ routePath: entry.routePath,
234
+ paramNames: entry.paramNames,
235
+ isApi: false,
236
+ mode: mod.mode ?? "server",
237
+ ...mod.revalidate !== void 0 ? { revalidate: mod.revalidate } : {},
238
+ route: registry.ref(entry.filePath, "page"),
239
+ layoutChain: layoutChain.map((l) => registry.ref(l.filePath, "layout")),
240
+ middlewareChain: mwChain.map((m) => registry.ref(m.filePath, "mw"))
241
+ });
242
+ }
243
+ const actions = [];
244
+ if (actionsDir && existsSync(actionsDir)) {
245
+ for (const actionFile of scanRoutes(actionsDir)) {
246
+ const segments = actionFile.routePath.split("/").filter(Boolean);
247
+ const fileName = segments[segments.length - 1] ?? "";
248
+ const parentPath = fileName === "index" || !fileName ? actionFile.routePath : `/${segments.slice(0, -1).join("/")}`;
249
+ actions.push({
250
+ parentPath,
251
+ paramNames: actionFile.paramNames,
252
+ module: registry.ref(actionFile.filePath, "action")
253
+ });
254
+ }
255
+ }
256
+ const notFoundEntry = existsSync(pagesDir) ? scanNotFound(pagesDir) : null;
257
+ const notFound = notFoundEntry ? registry.ref(notFoundEntry.filePath, "notfound") : void 0;
258
+ const rootLayoutEntry = dedicatedLayouts[0] ?? layouts.find((l) => l.dirPath === pagesDir);
259
+ const rootLayout = rootLayoutEntry ? registry.ref(rootLayoutEntry.filePath, "rootlayout") : void 0;
260
+ return {
261
+ projectRoot,
262
+ pagesDirLabel: pagesDir,
263
+ routes,
264
+ actions,
265
+ ...notFound ? { notFound } : {},
266
+ ...rootLayout ? { rootLayout } : {},
267
+ hasServerSurface: routes.length > 0 || actions.length > 0,
268
+ ...existsSync(join2(projectRoot, "public", "styles.css")) ? { stylesheetHref: "/styles.css" } : {},
269
+ security: options.security,
270
+ observability: options.observability,
271
+ images: options.images
272
+ };
273
+ }
274
+ function allModuleRefs(manifest) {
275
+ const map = /* @__PURE__ */ new Map();
276
+ const add = (ref) => map.set(ref.sourcePath, ref);
277
+ for (const r of manifest.routes) {
278
+ add(r.route);
279
+ for (const l of r.layoutChain) add(l);
280
+ for (const m of r.middlewareChain) add(m);
281
+ }
282
+ for (const a of manifest.actions) add(a.module);
283
+ if (manifest.notFound) add(manifest.notFound);
284
+ if (manifest.rootLayout) add(manifest.rootLayout);
285
+ return [...map.values()];
286
+ }
287
+
288
+ // src/adapter/transpile.ts
289
+ import { mkdirSync as mkdirSync2 } from "fs";
290
+ import { dirname } from "path";
291
+ async function transpileModules(refs) {
292
+ for (const ref of refs) {
292
293
  const result = await Bun.build({
293
- entrypoints: [entryPath],
294
+ entrypoints: [ref.sourcePath],
294
295
  target: "node",
295
296
  format: "esm",
296
297
  splitting: false,
297
- minify: false
298
+ external: ["react", "react/*", "react-dom", "react-dom/*", "@thexjs/core", "@thexjs/core/*"]
298
299
  });
299
300
  if (!result.success || result.outputs.length === 0) {
300
301
  const messages = result.logs.map((l) => l.message).join("\n");
301
- throw new Error(`[@thexjs/core] failed to bundle render function:
302
+ throw new Error(`[@thexjs/core] failed to transpile ${ref.sourcePath}:
302
303
  ${messages}`);
303
304
  }
304
305
  const [output] = result.outputs;
305
- const code = await output.text();
306
- writeFileSync(join2(functionDir, "index.mjs"), code, "utf-8");
307
- } finally {
308
- rmSync(scratchDir, { recursive: true, force: true });
306
+ mkdirSync2(dirname(ref.compiledPath), { recursive: true });
307
+ await Bun.write(ref.compiledPath, await output.arrayBuffer());
309
308
  }
310
309
  }
311
310
  export {
@@ -160,12 +160,19 @@ function extractParams(routePath, paramNames, url) {
160
160
  for (const name of paramNames) {
161
161
  const value = match[idx];
162
162
  if (value !== void 0) {
163
- params[name] = value;
163
+ params[name] = safeDecodeURIComponent(value);
164
164
  }
165
165
  idx++;
166
166
  }
167
167
  return params;
168
168
  }
169
+ function safeDecodeURIComponent(value) {
170
+ try {
171
+ return decodeURIComponent(value);
172
+ } catch {
173
+ return value;
174
+ }
175
+ }
169
176
  function generateManifestSource(routes) {
170
177
  const routeEntries = routes.map((r) => {
171
178
  const paramsType = r.paramNames.length === 0 ? "Record<string, never>" : `{ ${r.paramNames.map((n) => `${n}: string`).join("; ")} }`;
package/dist/data.d.ts CHANGED
@@ -1,12 +1,5 @@
1
1
  import { Database } from 'bun:sqlite';
2
2
 
3
- interface SQLiteOptions {
4
- path?: string;
5
- wal?: boolean;
6
- foreignKeys?: boolean;
7
- }
8
- declare function connectSQLite(options?: SQLiteOptions): Database;
9
-
10
3
  /** A Postgres client scoped to a single transaction (auto-commit/rollback). */
11
4
  interface PostgresTransactionClient {
12
5
  unsafe(query: string, params?: unknown[]): Promise<unknown>;
@@ -64,4 +57,11 @@ interface PostgresMigrationResult {
64
57
  }
65
58
  declare function runPostgresMigrations(client: PostgresClient, migrationsDir: string): Promise<PostgresMigrationResult>;
66
59
 
60
+ interface SQLiteOptions {
61
+ path?: string;
62
+ wal?: boolean;
63
+ foreignKeys?: boolean;
64
+ }
65
+ declare function connectSQLite(options?: SQLiteOptions): Database;
66
+
67
67
  export { type MigrationResult, type PostgresMigrationResult, type PostgresOptions, type SQLiteOptions, connectPostgres, connectSQLite, runPostgresMigrations, runSQLiteMigrations };