@timber-js/app 0.2.0-alpha.114 → 0.2.0-alpha.116
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/_chunks/{actions-ILhDUzES.js → actions-DAVm0FQe.js} +17 -17
- package/dist/_chunks/actions-DAVm0FQe.js.map +1 -0
- package/dist/_chunks/{define-a0CCE6Nx.js → define-zQX6e1tN.js} +2 -2
- package/dist/_chunks/{define-a0CCE6Nx.js.map → define-zQX6e1tN.js.map} +1 -1
- package/dist/_chunks/{navigation-root-CY3pRMxF.js → navigation-root-DKsJ5Di7.js} +2 -2
- package/dist/_chunks/{navigation-root-CY3pRMxF.js.map → navigation-root-DKsJ5Di7.js.map} +1 -1
- package/dist/_chunks/tracing-DvKLzCFa.js.map +1 -1
- package/dist/_chunks/{use-segment-params-BSt_O2cb.js → use-segment-params-CskiK-59.js} +2 -2
- package/dist/_chunks/{use-segment-params-BSt_O2cb.js.map → use-segment-params-CskiK-59.js.map} +1 -1
- package/dist/_chunks/{walkers-DGV9dQRq.js → walkers-DgOXkTts.js} +12 -10
- package/dist/_chunks/walkers-DgOXkTts.js.map +1 -0
- package/dist/client/index.js +3 -3
- package/dist/client/internal.js +2 -2
- package/dist/client/use-segment-params.d.ts +3 -3
- package/dist/client/use-segment-params.d.ts.map +1 -1
- package/dist/index.js +43 -26
- package/dist/index.js.map +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/routing/codegen-types.d.ts +3 -0
- package/dist/routing/codegen-types.d.ts.map +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/routing/segment-codegen.d.ts +22 -9
- package/dist/routing/segment-codegen.d.ts.map +1 -1
- package/dist/segment-params/index.js +1 -1
- package/dist/server/als-registry.d.ts +5 -4
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/internal.js +3 -3
- package/dist/server/internal.js.map +1 -1
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +9 -9
- package/dist/server/request-context.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/use-segment-params.ts +4 -4
- package/src/plugins/routing.ts +26 -17
- package/src/routing/codegen-types.ts +3 -0
- package/src/routing/codegen.ts +18 -9
- package/src/routing/segment-codegen.ts +46 -21
- package/src/server/als-registry.ts +5 -4
- package/src/server/pipeline-phases.ts +9 -7
- package/src/server/request-context.ts +17 -17
- package/dist/_chunks/actions-ILhDUzES.js.map +0 -1
- package/dist/_chunks/walkers-DGV9dQRq.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as setViteServer } from "./_chunks/warnings-B30wpfaS.js";
|
|
2
2
|
import { h as swallow } from "./_chunks/logger-DDmK5skc.js";
|
|
3
3
|
import { t as scanRoutes } from "./_chunks/scanner-DmfoB7iK.js";
|
|
4
|
-
import { n as collectInterceptionRewrites, r as generateRouteMap, t as collectLeafRoutes } from "./_chunks/walkers-
|
|
4
|
+
import { n as collectInterceptionRewrites, r as generateRouteMap, t as collectLeafRoutes } from "./_chunks/walkers-DgOXkTts.js";
|
|
5
5
|
import { a as DEFAULT_BUILD_DIR, c as mergeFileConfig, d as resolveClientJavascript, f as createNoopTimer, l as resolveAppDir, n as findSchemaFile, o as createPluginContext, r as parseExistingSchemaKeys, s as loadTimberConfigFile, t as collectDynamicSegments, u as resolveBuildDir } from "./_chunks/cli-schema-sync-DFZmnmqG.js";
|
|
6
6
|
import { t as formatSize } from "./_chunks/format-CR6v1pWE.js";
|
|
7
7
|
import { dirname, extname, join, normalize, resolve } from "node:path";
|
|
@@ -1981,34 +1981,47 @@ function timberMdx(ctx) {
|
|
|
1981
1981
|
//#endregion
|
|
1982
1982
|
//#region src/routing/segment-codegen.ts
|
|
1983
1983
|
/**
|
|
1984
|
-
*
|
|
1984
|
+
* $segment type generation and directory-to-route mapping.
|
|
1985
1985
|
*
|
|
1986
|
-
* Generates per-route
|
|
1986
|
+
* Generates per-route $segment.d.ts files in .timber/types/ that mirror
|
|
1987
1987
|
* the app/ directory structure. TypeScript's rootDirs feature makes these
|
|
1988
|
-
* importable as '
|
|
1988
|
+
* importable as './$segment' from route files.
|
|
1989
1989
|
*
|
|
1990
|
-
* Design doc: design/41-global-params.md §The
|
|
1990
|
+
* Design doc: design/41-global-params.md §The $segment Module
|
|
1991
1991
|
*/
|
|
1992
1992
|
/**
|
|
1993
|
-
* Build a map of absolute filesystem directory →
|
|
1994
|
-
* Used by resolveId to map a
|
|
1993
|
+
* Build a map of absolute filesystem directory → segment info.
|
|
1994
|
+
* Used by resolveId to map a $segment import's importer to the correct route,
|
|
1995
|
+
* and by writeSegmentTypes to generate per-route $segment.d.ts files.
|
|
1995
1996
|
*
|
|
1996
1997
|
* Walks every segment (not just leaves) so layouts and middleware
|
|
1997
|
-
* at any depth can import
|
|
1998
|
+
* at any depth can import $segment.
|
|
1998
1999
|
*/
|
|
1999
2000
|
function buildDirToRouteMap(tree, appDir) {
|
|
2000
2001
|
const map = /* @__PURE__ */ new Map();
|
|
2001
|
-
function walk(node, fsPath) {
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2002
|
+
function walk(node, fsPath, treePath) {
|
|
2003
|
+
map.set(fsPath, {
|
|
2004
|
+
route: node.urlPath || "/",
|
|
2005
|
+
segmentPath: treePath || "/"
|
|
2006
|
+
});
|
|
2007
|
+
for (const child of node.children) walk(child, join(fsPath, child.segmentName), `${treePath}/${child.segmentName}`);
|
|
2008
|
+
for (const [slotName, slotNode] of Object.entries(node.slots)) walk(slotNode, join(fsPath, `@${slotName}`), `${treePath}/@${slotName}`);
|
|
2006
2009
|
}
|
|
2007
|
-
walk(tree.root, appDir);
|
|
2010
|
+
walk(tree.root, appDir, "");
|
|
2008
2011
|
return map;
|
|
2009
2012
|
}
|
|
2010
2013
|
/**
|
|
2011
|
-
* Generate
|
|
2014
|
+
* Generate the full $segment.d.ts content for a segment.
|
|
2015
|
+
*/
|
|
2016
|
+
function generateSegmentDts(info) {
|
|
2017
|
+
return [
|
|
2018
|
+
`export const ROUTE: '${info.route}';`,
|
|
2019
|
+
`export const SEGMENT_PATH: '${info.segmentPath}';`,
|
|
2020
|
+
""
|
|
2021
|
+
].join("\n");
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* Generate per-route $segment.d.ts files in .timber/types/ mirroring
|
|
2012
2025
|
* the app/ directory structure. These files are importable via TypeScript's
|
|
2013
2026
|
* rootDirs feature.
|
|
2014
2027
|
*/
|
|
@@ -2016,11 +2029,11 @@ async function writeSegmentTypes(routeTree, appDir, root) {
|
|
|
2016
2029
|
const typesBase = join(root, ".timber", "types", appDir.slice(root.length + 1));
|
|
2017
2030
|
const map = buildDirToRouteMap(routeTree, appDir);
|
|
2018
2031
|
const writes = [];
|
|
2019
|
-
for (const [fsDir,
|
|
2032
|
+
for (const [fsDir, info] of map) {
|
|
2020
2033
|
const segmentDir = join(typesBase, fsDir.slice(appDir.length));
|
|
2021
|
-
const
|
|
2022
|
-
const content =
|
|
2023
|
-
writes.push(mkdir(segmentDir, { recursive: true }).then(() => writeFile(
|
|
2034
|
+
const segmentFile = join(segmentDir, "$segment.d.ts");
|
|
2035
|
+
const content = generateSegmentDts(info);
|
|
2036
|
+
writes.push(mkdir(segmentDir, { recursive: true }).then(() => writeFile(segmentFile, content, "utf-8")));
|
|
2024
2037
|
}
|
|
2025
2038
|
await Promise.all(writes);
|
|
2026
2039
|
}
|
|
@@ -2263,7 +2276,7 @@ var SEARCH_PARAMS_REGISTRY_ID = "virtual:timber-search-params-registry";
|
|
|
2263
2276
|
var RESOLVED_SEARCH_PARAMS_REGISTRY_ID = `\0${SEARCH_PARAMS_REGISTRY_ID}`;
|
|
2264
2277
|
var SCHEMA_ID = "virtual:timber-schema";
|
|
2265
2278
|
var RESOLVED_SCHEMA_ID = `\0${SCHEMA_ID}`;
|
|
2266
|
-
var SEGMENT_PREFIX = "\
|
|
2279
|
+
var SEGMENT_PREFIX = "\0$segment:";
|
|
2267
2280
|
/**
|
|
2268
2281
|
* File convention names we track for changes that require manifest regeneration.
|
|
2269
2282
|
*/
|
|
@@ -2315,7 +2328,7 @@ function writeCodegen(ctx) {
|
|
|
2315
2328
|
function timberRouting(ctx) {
|
|
2316
2329
|
/** Track warned files to avoid repeating warnings on rescan. */
|
|
2317
2330
|
const warnedFiles = /* @__PURE__ */ new Set();
|
|
2318
|
-
/** Maps absolute filesystem directory →
|
|
2331
|
+
/** Maps absolute filesystem directory → segment info for $segment resolution. */
|
|
2319
2332
|
let dirToRoute = /* @__PURE__ */ new Map();
|
|
2320
2333
|
function rescan() {
|
|
2321
2334
|
const appDirWarning = checkAppDirExists(ctx.appDir);
|
|
@@ -2352,11 +2365,11 @@ function timberRouting(ctx) {
|
|
|
2352
2365
|
if (cleanId.endsWith(`/${VIRTUAL_MODULE_ID$1}`)) return RESOLVED_VIRTUAL_ID$1;
|
|
2353
2366
|
if (cleanId === SEARCH_PARAMS_REGISTRY_ID || cleanId.endsWith(`/${SEARCH_PARAMS_REGISTRY_ID}`)) return RESOLVED_SEARCH_PARAMS_REGISTRY_ID;
|
|
2354
2367
|
if (cleanId === SCHEMA_ID || cleanId.endsWith(`/${SCHEMA_ID}`)) return RESOLVED_SCHEMA_ID;
|
|
2355
|
-
if (importer && (cleanId === "
|
|
2368
|
+
if (importer && (cleanId === "./$segment" || cleanId === "./$segment.js" || cleanId === "./$segment.ts")) {
|
|
2356
2369
|
const cleanImporter = importer.startsWith("\0") ? importer.slice(1) : importer;
|
|
2357
2370
|
const importerDir = cleanImporter.substring(0, cleanImporter.lastIndexOf("/"));
|
|
2358
|
-
const
|
|
2359
|
-
if (
|
|
2371
|
+
const segmentInfo = dirToRoute.get(importerDir);
|
|
2372
|
+
if (segmentInfo !== void 0) return `${SEGMENT_PREFIX}${JSON.stringify(segmentInfo)}`;
|
|
2360
2373
|
}
|
|
2361
2374
|
return null;
|
|
2362
2375
|
},
|
|
@@ -2371,8 +2384,12 @@ function timberRouting(ctx) {
|
|
|
2371
2384
|
}
|
|
2372
2385
|
if (id === RESOLVED_SCHEMA_ID) return generateSchemaModule(ctx.appDir);
|
|
2373
2386
|
if (id.startsWith(SEGMENT_PREFIX)) {
|
|
2374
|
-
const
|
|
2375
|
-
return
|
|
2387
|
+
const info = JSON.parse(id.slice(10));
|
|
2388
|
+
return [
|
|
2389
|
+
`export const ROUTE = ${JSON.stringify(info.route)};`,
|
|
2390
|
+
`export const SEGMENT_PATH = ${JSON.stringify(info.segmentPath)};`,
|
|
2391
|
+
""
|
|
2392
|
+
].join("\n");
|
|
2376
2393
|
}
|
|
2377
2394
|
return null;
|
|
2378
2395
|
},
|