@timber-js/app 0.2.0-alpha.121 → 0.2.0-alpha.123
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/LICENSE +8 -0
- package/dist/_chunks/{actions-Dy8vOjFt.js → actions-ZlcKx0H9.js} +5 -5
- package/dist/_chunks/actions-ZlcKx0H9.js.map +1 -0
- package/dist/_chunks/{build-output-helper-B1n0sUqj.js → build-output-helper-DYOWsPjZ.js} +47 -6
- package/dist/_chunks/build-output-helper-DYOWsPjZ.js.map +1 -0
- package/dist/_chunks/cli-schema-sync-4HcQIziG.js +2 -0
- package/dist/_chunks/{cli-schema-sync-ByZPGGmS.js → cli-schema-sync-VcCf1TFY.js} +17 -3
- package/dist/_chunks/{cli-schema-sync-ByZPGGmS.js.map → cli-schema-sync-VcCf1TFY.js.map} +1 -1
- package/dist/_chunks/{define-CPVQaWbx.js → define-C0V_eKiW.js} +6 -18
- package/dist/_chunks/define-C0V_eKiW.js.map +1 -0
- package/dist/_chunks/{handler-store-CcwNX-gk.js → handler-store-bIAstrxQ.js} +1 -1
- package/dist/_chunks/{handler-store-CcwNX-gk.js.map → handler-store-bIAstrxQ.js.map} +1 -1
- package/dist/_chunks/{merge-search-params-az6ZiBeU.js → merge-search-params-Cm1j99HC.js} +1 -1
- package/dist/_chunks/{merge-search-params-az6ZiBeU.js.map → merge-search-params-Cm1j99HC.js.map} +1 -1
- package/dist/_chunks/{metadata-routes-Cjmvi3rQ.js → metadata-routes-DESG8uk5.js} +32 -19
- package/dist/_chunks/metadata-routes-DESG8uk5.js.map +1 -0
- package/dist/_chunks/{navigation-root-DoRTeBm5.js → navigation-root-Ds_hDtRW.js} +2 -2
- package/dist/_chunks/{navigation-root-DoRTeBm5.js.map → navigation-root-Ds_hDtRW.js.map} +1 -1
- package/dist/_chunks/{resolve-schema-Bf8eC6q6.js → resolve-schema-DU2nbVOi.js} +5 -1
- package/dist/_chunks/resolve-schema-DU2nbVOi.js.map +1 -0
- package/dist/_chunks/{router-ref-CpvjBqdu.js → router-ref-B2-2kIIC.js} +2 -2
- package/dist/_chunks/{router-ref-CpvjBqdu.js.map → router-ref-B2-2kIIC.js.map} +1 -1
- package/dist/_chunks/{segment-classify-CnfLLvir.js → segment-classify-BjfuctV2.js} +1 -1
- package/dist/_chunks/{segment-classify-CnfLLvir.js.map → segment-classify-BjfuctV2.js.map} +1 -1
- package/dist/_chunks/{segment-context-EsfQpS--.js → segment-context-Bg0pFbLT.js} +1 -1
- package/dist/_chunks/{segment-context-EsfQpS--.js.map → segment-context-Bg0pFbLT.js.map} +1 -1
- package/dist/_chunks/{ssr-data-m9-cNEIw.js → ssr-data-DVX8S7vj.js} +1 -1
- package/dist/_chunks/{ssr-data-m9-cNEIw.js.map → ssr-data-DVX8S7vj.js.map} +1 -1
- package/dist/_chunks/{use-segment-params-CtIAjqK0.js → use-segment-params-Du7u25cK.js} +3 -8
- package/dist/_chunks/{use-segment-params-CtIAjqK0.js.map → use-segment-params-Du7u25cK.js.map} +1 -1
- package/dist/_chunks/{validation-BMU5MPzP.js → validation-AfEFM5ze.js} +1 -1
- package/dist/_chunks/{validation-BMU5MPzP.js.map → validation-AfEFM5ze.js.map} +1 -1
- package/dist/_chunks/{walkers-DNp9tHyV.js → walkers-tkw7sDlj.js} +12 -9
- package/dist/_chunks/walkers-tkw7sDlj.js.map +1 -0
- package/dist/adapters/build-output-helper.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +1 -1
- package/dist/adapters/nitro.js +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cli-schema-sync.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/browser-entry/action-dispatch.d.ts.map +1 -1
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
- package/dist/client/error-boundary.js +2 -2
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +48 -15
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +67 -32
- package/dist/client/internal.js.map +1 -1
- package/dist/client/link.d.ts +9 -5
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts +8 -0
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/shallow-url.d.ts +10 -0
- package/dist/client/shallow-url.d.ts.map +1 -0
- package/dist/cookies/index.js +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +102 -10
- package/dist/index.js.map +1 -1
- package/dist/params/index.js +1 -1
- package/dist/params/resolve-schema.d.ts.map +1 -1
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/plugins/cloudflare-wasm.d.ts +18 -0
- package/dist/plugins/cloudflare-wasm.d.ts.map +1 -0
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/routing/codegen-shared.d.ts +5 -4
- package/dist/routing/codegen-shared.d.ts.map +1 -1
- package/dist/routing/index.js +3 -3
- package/dist/segment-params/define.d.ts +0 -6
- package/dist/segment-params/define.d.ts.map +1 -1
- package/dist/segment-params/index.js +1 -1
- package/dist/server/actions.d.ts +3 -8
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/build-manifest.d.ts +6 -0
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/internal.d.ts +1 -1
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +15 -6
- package/dist/server/internal.js.map +1 -1
- package/dist/server/metadata-routes.d.ts +23 -7
- package/dist/server/metadata-routes.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/route-matcher.d.ts +4 -2
- package/dist/server/route-matcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/tree-match.d.ts +12 -4
- package/dist/server/tree-match.d.ts.map +1 -1
- package/dist/server/types.d.ts +2 -2
- package/package.json +6 -7
- package/src/adapters/build-output-helper.ts +67 -5
- package/src/cli-schema-sync.ts +25 -4
- package/src/cli.ts +0 -0
- package/src/client/browser-entry/action-dispatch.ts +9 -10
- package/src/client/browser-entry/index.ts +1 -1
- package/src/client/browser-entry/post-hydration.ts +12 -6
- package/src/client/index.ts +1 -5
- package/src/client/link.tsx +34 -21
- package/src/client/router.ts +74 -25
- package/src/client/rsc-fetch.ts +20 -5
- package/src/client/shallow-url.ts +22 -0
- package/src/index.ts +2 -0
- package/src/params/resolve-schema.ts +15 -0
- package/src/plugins/build-manifest.ts +57 -5
- package/src/plugins/cloudflare-wasm.ts +103 -0
- package/src/plugins/dev-server.ts +4 -2
- package/src/plugins/routing.ts +1 -1
- package/src/routing/codegen-shared.ts +8 -5
- package/src/routing/codegen.ts +5 -0
- package/src/routing/link-codegen.ts +1 -1
- package/src/segment-params/define.ts +2 -29
- package/src/server/actions.ts +4 -14
- package/src/server/build-manifest.ts +7 -0
- package/src/server/internal.ts +7 -1
- package/src/server/metadata-routes.ts +44 -19
- package/src/server/pipeline-phases.ts +8 -0
- package/src/server/request-context.ts +0 -4
- package/src/server/route-element-builder.ts +57 -11
- package/src/server/route-matcher.ts +81 -49
- package/src/server/rsc-entry/index.ts +7 -1
- package/src/server/rsc-entry/render-route.ts +7 -1
- package/src/server/ssr-entry.ts +6 -0
- package/src/server/tree-match.ts +23 -11
- package/src/server/types.ts +2 -2
- package/dist/_chunks/actions-Dy8vOjFt.js.map +0 -1
- package/dist/_chunks/build-output-helper-B1n0sUqj.js.map +0 -1
- package/dist/_chunks/cli-schema-sync-DHQLjFu3.js +0 -2
- package/dist/_chunks/define-CPVQaWbx.js.map +0 -1
- package/dist/_chunks/metadata-routes-Cjmvi3rQ.js.map +0 -1
- package/dist/_chunks/resolve-schema-Bf8eC6q6.js.map +0 -1
- package/dist/_chunks/walkers-DNp9tHyV.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { n as setViteServer } from "./_chunks/warnings-B30wpfaS.js";
|
|
2
|
+
import { a as isDynamicMetadataExtension, o as isMetadataRouteServePath } from "./_chunks/metadata-routes-DESG8uk5.js";
|
|
2
3
|
import { h as swallow } from "./_chunks/logger-DDmK5skc.js";
|
|
3
|
-
import { a as DEFAULT_BUILD_DIR, c as mergeFileConfig, d as resolveClientJavascript, f as createNoopTimer, l as resolveAppDir, o as createPluginContext, p as scanRoutes, s as loadTimberConfigFile, u as resolveBuildDir } from "./_chunks/cli-schema-sync-
|
|
4
|
-
import { a as generateRouteMap, i as collectInterceptionRewrites, r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-
|
|
4
|
+
import { a as DEFAULT_BUILD_DIR, c as mergeFileConfig, d as resolveClientJavascript, f as createNoopTimer, l as resolveAppDir, o as createPluginContext, p as scanRoutes, s as loadTimberConfigFile, u as resolveBuildDir } from "./_chunks/cli-schema-sync-VcCf1TFY.js";
|
|
5
|
+
import { a as generateRouteMap, i as collectInterceptionRewrites, r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-tkw7sDlj.js";
|
|
5
6
|
import { t as formatSize } from "./_chunks/format-BjN9HLu9.js";
|
|
6
|
-
import { dirname, extname, join, normalize, resolve } from "node:path";
|
|
7
|
+
import { basename, dirname, extname, join, normalize, resolve } from "node:path";
|
|
7
8
|
import { createRequire } from "node:module";
|
|
8
9
|
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
|
|
9
10
|
import { existsSync, readFileSync } from "node:fs";
|
|
10
11
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
12
|
import { constants, createGzip, gzipSync } from "node:zlib";
|
|
12
13
|
import { Readable } from "node:stream";
|
|
13
|
-
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
14
|
+
import { copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
14
15
|
import { createHash, randomUUID } from "node:crypto";
|
|
15
16
|
import { parseAst } from "vite";
|
|
16
17
|
import http from "node:http";
|
|
@@ -1412,7 +1413,7 @@ function createTimberMiddleware(server, projectRoot) {
|
|
|
1412
1413
|
next();
|
|
1413
1414
|
return;
|
|
1414
1415
|
}
|
|
1415
|
-
if (isAssetRequest(url)) {
|
|
1416
|
+
if (isAssetRequest(url) && !isMetadataRouteServePath(url)) {
|
|
1416
1417
|
next();
|
|
1417
1418
|
return;
|
|
1418
1419
|
}
|
|
@@ -2279,7 +2280,7 @@ var SEGMENT_PREFIX = "\0$segment:";
|
|
|
2279
2280
|
/**
|
|
2280
2281
|
* File convention names we track for changes that require manifest regeneration.
|
|
2281
2282
|
*/
|
|
2282
|
-
var ROUTE_FILE_PATTERNS = /\/(page|layout|middleware|access|route|error|global-error|default|denied|params|schema|\d{3}|[45]xx|not-found|forbidden|unauthorized|sitemap|robots|manifest|favicon|icon|opengraph-image|
|
|
2283
|
+
var ROUTE_FILE_PATTERNS = /\/(page|layout|middleware|access|route|error|global-error|default|denied|params|schema|\d{3}|[45]xx|not-found|forbidden|unauthorized|sitemap|robots|manifest|favicon|icon|opengraph-image|apple-icon)\./;
|
|
2283
2284
|
/**
|
|
2284
2285
|
* Create the timber-routing Vite plugin.
|
|
2285
2286
|
*
|
|
@@ -5702,7 +5703,8 @@ function buildManifestFromBundle(bundle, base, root) {
|
|
|
5702
5703
|
css,
|
|
5703
5704
|
js,
|
|
5704
5705
|
modulepreload,
|
|
5705
|
-
fonts: {}
|
|
5706
|
+
fonts: {},
|
|
5707
|
+
metadataRouteHashes: {}
|
|
5706
5708
|
};
|
|
5707
5709
|
}
|
|
5708
5710
|
/**
|
|
@@ -5724,6 +5726,27 @@ function collectTransitiveBundleDeps(chunk, chunksByFileName, base) {
|
|
|
5724
5726
|
return result;
|
|
5725
5727
|
}
|
|
5726
5728
|
/**
|
|
5729
|
+
* Walk the route tree and compute short content hashes for metadata route files
|
|
5730
|
+
* (opengraph-image, icon, apple-icon) used for cache-busting
|
|
5731
|
+
* the auto-linked URLs in <head>.
|
|
5732
|
+
*/
|
|
5733
|
+
function computeMetadataRouteHashes(node) {
|
|
5734
|
+
const hashes = {};
|
|
5735
|
+
if (node.metadataRoutes) for (const [baseName, file] of Object.entries(node.metadataRoutes)) if (!isDynamicMetadataExtension(baseName, file.extension)) try {
|
|
5736
|
+
const content = readFileSync(file.filePath);
|
|
5737
|
+
const hash = createHash("sha256").update(content).digest("hex").slice(0, 8);
|
|
5738
|
+
hashes[file.filePath] = hash;
|
|
5739
|
+
} catch {}
|
|
5740
|
+
else try {
|
|
5741
|
+
const content = readFileSync(file.filePath);
|
|
5742
|
+
const hash = createHash("sha256").update(content).digest("hex").slice(0, 8);
|
|
5743
|
+
hashes[file.filePath] = hash;
|
|
5744
|
+
} catch {}
|
|
5745
|
+
for (const child of node.children) Object.assign(hashes, computeMetadataRouteHashes(child));
|
|
5746
|
+
for (const slot of Object.values(node.slots)) Object.assign(hashes, computeMetadataRouteHashes(slot));
|
|
5747
|
+
return hashes;
|
|
5748
|
+
}
|
|
5749
|
+
/**
|
|
5727
5750
|
* Create the timber-build-manifest Vite plugin.
|
|
5728
5751
|
*
|
|
5729
5752
|
* Hooks: configResolved, resolveId, load, generateBundle (client env only)
|
|
@@ -5750,7 +5773,7 @@ function timberBuildManifest(ctx) {
|
|
|
5750
5773
|
"// Auto-generated build manifest — do not edit.",
|
|
5751
5774
|
"// Dev mode: empty manifest (Vite HMR handles CSS/JS).",
|
|
5752
5775
|
"",
|
|
5753
|
-
"const manifest = { css: {}, js: {}, modulepreload: {}, fonts: {} };",
|
|
5776
|
+
"const manifest = { css: {}, js: {}, modulepreload: {}, fonts: {}, metadataRouteHashes: {} };",
|
|
5754
5777
|
"",
|
|
5755
5778
|
"export default manifest;"
|
|
5756
5779
|
].join("\n");
|
|
@@ -5758,7 +5781,7 @@ function timberBuildManifest(ctx) {
|
|
|
5758
5781
|
"// Auto-generated build manifest — do not edit.",
|
|
5759
5782
|
"// Production: reads manifest from globalThis (set by _timber-manifest-init.js).",
|
|
5760
5783
|
"",
|
|
5761
|
-
"const manifest = globalThis.__TIMBER_BUILD_MANIFEST__ ?? { css: {}, js: {}, modulepreload: {}, fonts: {} };",
|
|
5784
|
+
"const manifest = globalThis.__TIMBER_BUILD_MANIFEST__ ?? { css: {}, js: {}, modulepreload: {}, fonts: {}, metadataRouteHashes: {} };",
|
|
5762
5785
|
"",
|
|
5763
5786
|
"export default manifest;"
|
|
5764
5787
|
].join("\n");
|
|
@@ -5767,6 +5790,7 @@ function timberBuildManifest(ctx) {
|
|
|
5767
5790
|
if (isDev) return;
|
|
5768
5791
|
if (this.environment?.name === "client") {
|
|
5769
5792
|
ctx.buildManifest = buildManifestFromBundle(bundle, resolvedBase, ctx.root);
|
|
5793
|
+
if (ctx.routeTree) ctx.buildManifest.metadataRouteHashes = computeMetadataRouteHashes(ctx.routeTree.root);
|
|
5770
5794
|
if (ctx.clientJavascript.disabled) {
|
|
5771
5795
|
ctx.buildManifest.js = {};
|
|
5772
5796
|
ctx.buildManifest.modulepreload = {};
|
|
@@ -6298,6 +6322,73 @@ function timberServerBundle() {
|
|
|
6298
6322
|
];
|
|
6299
6323
|
}
|
|
6300
6324
|
//#endregion
|
|
6325
|
+
//#region src/plugins/cloudflare-wasm.ts
|
|
6326
|
+
/**
|
|
6327
|
+
* timber-cloudflare-wasm — Handle WASM modules for Cloudflare Workers builds.
|
|
6328
|
+
*
|
|
6329
|
+
* Cloudflare Workers can natively import `.wasm` files as compiled
|
|
6330
|
+
* WebAssembly.Module. But Rolldown can't load `.wasm` files at build time.
|
|
6331
|
+
*
|
|
6332
|
+
* This plugin bridges the gap:
|
|
6333
|
+
* 1. Adds the `workerd` resolve condition so libraries like @takumi-rs/wasm
|
|
6334
|
+
* resolve to their Cloudflare-native entry (bare `.wasm` import)
|
|
6335
|
+
* 2. Externalizes `.wasm` imports so Rolldown skips them
|
|
6336
|
+
* 3. Copies the WASM files to the build output so wrangler can find them
|
|
6337
|
+
*
|
|
6338
|
+
* Only active for Cloudflare adapter production builds.
|
|
6339
|
+
*/
|
|
6340
|
+
function isCloudflareAdapter(ctx) {
|
|
6341
|
+
return ctx.config.adapter?.name === "cloudflare";
|
|
6342
|
+
}
|
|
6343
|
+
function timberCloudflareWasm(ctx) {
|
|
6344
|
+
const wasmFiles = /* @__PURE__ */ new Map();
|
|
6345
|
+
return [{
|
|
6346
|
+
name: "timber-cloudflare-wasm",
|
|
6347
|
+
configResolved(resolved) {
|
|
6348
|
+
if (resolved.command !== "build") return;
|
|
6349
|
+
if (!isCloudflareAdapter(ctx)) return;
|
|
6350
|
+
for (const envName of ["rsc", "ssr"]) {
|
|
6351
|
+
const env = resolved.environments[envName];
|
|
6352
|
+
if (!env) continue;
|
|
6353
|
+
const conditions = env.resolve.conditions;
|
|
6354
|
+
if (!conditions.includes("workerd")) conditions.unshift("workerd");
|
|
6355
|
+
}
|
|
6356
|
+
},
|
|
6357
|
+
resolveId: {
|
|
6358
|
+
order: "pre",
|
|
6359
|
+
async handler(source, importer) {
|
|
6360
|
+
if (!source.endsWith(".wasm")) return;
|
|
6361
|
+
let absolutePath;
|
|
6362
|
+
if (source.startsWith(".") && importer) absolutePath = resolve(dirname(importer), source);
|
|
6363
|
+
else return;
|
|
6364
|
+
const filename = basename(absolutePath);
|
|
6365
|
+
wasmFiles.set(filename, absolutePath);
|
|
6366
|
+
return {
|
|
6367
|
+
id: "./" + filename,
|
|
6368
|
+
external: true
|
|
6369
|
+
};
|
|
6370
|
+
}
|
|
6371
|
+
},
|
|
6372
|
+
async writeBundle(options, bundle) {
|
|
6373
|
+
if (wasmFiles.size === 0) return;
|
|
6374
|
+
const outDir = options.dir;
|
|
6375
|
+
if (!outDir) return;
|
|
6376
|
+
const targetDirs = /* @__PURE__ */ new Set();
|
|
6377
|
+
for (const chunk of Object.values(bundle)) {
|
|
6378
|
+
if (chunk.type !== "chunk") continue;
|
|
6379
|
+
for (const filename of wasmFiles.keys()) if (chunk.code.includes(filename)) targetDirs.add(dirname(resolve(outDir, chunk.fileName)));
|
|
6380
|
+
}
|
|
6381
|
+
if (targetDirs.size === 0) return;
|
|
6382
|
+
const copies = [];
|
|
6383
|
+
for (const dir of targetDirs) {
|
|
6384
|
+
await mkdir(dir, { recursive: true });
|
|
6385
|
+
for (const [filename, absolutePath] of wasmFiles) copies.push(copyFile(absolutePath, resolve(dir, filename)));
|
|
6386
|
+
}
|
|
6387
|
+
await Promise.all(copies);
|
|
6388
|
+
}
|
|
6389
|
+
}];
|
|
6390
|
+
}
|
|
6391
|
+
//#endregion
|
|
6301
6392
|
//#region src/plugins/adapter-build.ts
|
|
6302
6393
|
function timberAdapterBuild(ctx) {
|
|
6303
6394
|
return {
|
|
@@ -7139,6 +7230,7 @@ function timber(config) {
|
|
|
7139
7230
|
timberMdx(ctx),
|
|
7140
7231
|
timberContent(ctx),
|
|
7141
7232
|
timberServerBundle(),
|
|
7233
|
+
timberCloudflareWasm(ctx),
|
|
7142
7234
|
timberChunks(),
|
|
7143
7235
|
timberBuildReport(ctx),
|
|
7144
7236
|
timberAdapterBuild(ctx),
|
|
@@ -7148,6 +7240,6 @@ function timber(config) {
|
|
|
7148
7240
|
];
|
|
7149
7241
|
}
|
|
7150
7242
|
//#endregion
|
|
7151
|
-
export { timber as default, timber, defineConfig
|
|
7243
|
+
export { timber as default, timber, defineConfig };
|
|
7152
7244
|
|
|
7153
7245
|
//# sourceMappingURL=index.js.map
|