@timber-js/app 0.2.0-alpha.57 → 0.2.0-alpha.59
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/als-registry-Ba7URUIn.js.map +1 -1
- package/dist/_chunks/define-D5STJpIr.js +121 -0
- package/dist/_chunks/define-D5STJpIr.js.map +1 -0
- package/dist/_chunks/define-TK8C1M3x.js.map +1 -1
- package/dist/_chunks/{define-cookie-k9btcEfI.js → define-cookie-DtAavax4.js} +4 -4
- package/dist/_chunks/define-cookie-DtAavax4.js.map +1 -0
- package/dist/_chunks/{error-boundary-B9vT_YK_.js → error-boundary-DpZJBCqh.js} +1 -1
- package/dist/_chunks/{error-boundary-B9vT_YK_.js.map → error-boundary-DpZJBCqh.js.map} +1 -1
- package/dist/_chunks/interception-Cey5DCGr.js.map +1 -1
- package/dist/_chunks/{request-context-0h-6Voad.js → request-context-0wfZsnhh.js} +3 -1
- package/dist/_chunks/request-context-0wfZsnhh.js.map +1 -0
- package/dist/_chunks/{segment-context-Bmugn-ao.js → segment-context-CyaM1mrD.js} +1 -1
- package/dist/_chunks/{segment-context-Bmugn-ao.js.map → segment-context-CyaM1mrD.js.map} +1 -1
- package/dist/_chunks/{stale-reload-Db4wqE46.js → stale-reload-DKN3aXxR.js} +1 -1
- package/dist/_chunks/{stale-reload-Db4wqE46.js.map → stale-reload-DKN3aXxR.js.map} +1 -1
- package/dist/_chunks/{tracing-JI4cYUdz.js → tracing-VYETCQsg.js} +1 -1
- package/dist/_chunks/{tracing-JI4cYUdz.js.map → tracing-VYETCQsg.js.map} +1 -1
- package/dist/_chunks/use-query-states-wEXY2JQB.js.map +1 -1
- package/dist/_chunks/{wrappers-C9XPg7-U.js → wrappers-BaG1bnM3.js} +1 -1
- package/dist/_chunks/{wrappers-C9XPg7-U.js.map → wrappers-BaG1bnM3.js.map} +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/error-reconstituter.d.ts +54 -0
- package/dist/client/error-reconstituter.d.ts.map +1 -0
- package/dist/client/form.d.ts +2 -2
- package/dist/client/form.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/link.d.ts +1 -1
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/segment-outlet.d.ts +63 -0
- package/dist/client/segment-outlet.d.ts.map +1 -0
- package/dist/client/use-params.d.ts +1 -1
- package/dist/client/use-params.d.ts.map +1 -1
- package/dist/client/use-query-states.d.ts +1 -1
- package/dist/client/use-query-states.d.ts.map +1 -1
- package/dist/cookies/define-cookie.d.ts +3 -3
- package/dist/cookies/define-cookie.d.ts.map +1 -1
- package/dist/cookies/index.js +1 -1
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +173 -6
- package/dist/index.js.map +1 -1
- package/dist/params/define.d.ts +25 -1
- package/dist/params/define.d.ts.map +1 -1
- package/dist/params/index.d.ts +5 -5
- package/dist/params/index.d.ts.map +1 -1
- package/dist/params/index.js +2 -103
- package/dist/plugins/adapter-build.d.ts +1 -1
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/build-manifest.d.ts +2 -2
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/plugins/build-report.d.ts +3 -3
- package/dist/plugins/build-report.d.ts.map +1 -1
- package/dist/plugins/content.d.ts +1 -1
- package/dist/plugins/content.d.ts.map +1 -1
- package/dist/plugins/dev-browser-logs.d.ts +84 -0
- package/dist/plugins/dev-browser-logs.d.ts.map +1 -0
- package/dist/plugins/dev-logs.d.ts +1 -1
- package/dist/plugins/dev-logs.d.ts.map +1 -1
- package/dist/plugins/dev-server.d.ts +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts +1 -1
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts +2 -2
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/mdx.d.ts +1 -1
- package/dist/plugins/mdx.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/plugins/shims.d.ts +8 -5
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/plugins/static-build.d.ts +1 -1
- package/dist/plugins/static-build.d.ts.map +1 -1
- package/dist/search-params/define.d.ts +1 -1
- package/dist/search-params/define.d.ts.map +1 -1
- package/dist/search-params/index.d.ts +1 -1
- package/dist/search-params/index.d.ts.map +1 -1
- package/dist/search-params/index.js +1 -1
- package/dist/server/actions.d.ts +1 -1
- package/dist/server/actions.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +7 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/deny-renderer.d.ts.map +1 -1
- package/dist/server/fallback-error.d.ts +3 -3
- package/dist/server/fallback-error.d.ts.map +1 -1
- package/dist/server/index.js +4 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/pipeline-interception.d.ts +1 -1
- package/dist/server/pipeline-interception.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +2 -2
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/rsc-entry/api-handler.d.ts +2 -2
- package/dist/server/rsc-entry/api-handler.d.ts.map +1 -1
- package/dist/server/rsc-entry/error-renderer.d.ts +13 -13
- package/dist/server/rsc-entry/error-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/helpers.d.ts +2 -2
- package/dist/server/rsc-entry/helpers.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts +2 -2
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts +3 -3
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts +1 -1
- package/dist/server/rsc-entry/ssr-bridge.d.ts.map +1 -1
- package/dist/server/rsc-entry/ssr-renderer.d.ts +4 -4
- package/dist/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/status-code-resolver.d.ts +1 -1
- package/dist/server/status-code-resolver.d.ts.map +1 -1
- package/dist/server/stream-utils.d.ts +36 -0
- package/dist/server/stream-utils.d.ts.map +1 -0
- package/dist/server/tree-builder.d.ts +1 -1
- package/dist/server/tree-builder.d.ts.map +1 -1
- package/dist/shims/font-google.d.ts +1 -1
- package/dist/shims/font-google.d.ts.map +1 -1
- package/package.json +1 -4
- package/src/cache/timber-cache.ts +1 -1
- package/src/client/browser-entry.ts +7 -8
- package/src/client/error-reconstituter.tsx +65 -0
- package/src/client/form.tsx +2 -2
- package/src/client/index.ts +2 -2
- package/src/client/link.tsx +2 -2
- package/src/client/segment-outlet.tsx +86 -0
- package/src/client/use-params.ts +1 -1
- package/src/client/use-query-states.ts +2 -2
- package/src/cookies/define-cookie.ts +9 -9
- package/src/index.ts +17 -0
- package/src/params/define.ts +61 -1
- package/src/params/index.ts +5 -5
- package/src/plugins/adapter-build.ts +2 -2
- package/src/plugins/build-manifest.ts +2 -2
- package/src/plugins/build-report.ts +3 -3
- package/src/plugins/cache-transform.ts +1 -1
- package/src/plugins/content.ts +1 -1
- package/src/plugins/dev-browser-logs.ts +274 -0
- package/src/plugins/dev-logs.ts +1 -1
- package/src/plugins/dev-server.ts +3 -3
- package/src/plugins/entries.ts +1 -1
- package/src/plugins/fonts.ts +9 -9
- package/src/plugins/mdx.ts +1 -1
- package/src/plugins/routing.ts +6 -6
- package/src/plugins/server-action-exports.ts +1 -1
- package/src/plugins/shims.ts +19 -39
- package/src/plugins/static-build.ts +2 -2
- package/src/routing/scanner.ts +1 -1
- package/src/routing/status-file-lint.ts +1 -1
- package/src/search-params/define.ts +2 -2
- package/src/search-params/index.ts +1 -1
- package/src/server/action-client.ts +1 -1
- package/src/server/action-handler.ts +1 -1
- package/src/server/actions.ts +1 -1
- package/src/server/als-registry.ts +7 -0
- package/src/server/deny-renderer.ts +3 -2
- package/src/server/error-boundary-wrapper.ts +1 -1
- package/src/server/fallback-error.ts +6 -6
- package/src/server/pipeline-interception.ts +1 -1
- package/src/server/pipeline.ts +2 -2
- package/src/server/primitives.ts +1 -1
- package/src/server/request-context.ts +7 -1
- package/src/server/route-element-builder.ts +1 -1
- package/src/server/rsc-entry/api-handler.ts +8 -8
- package/src/server/rsc-entry/error-renderer.ts +120 -185
- package/src/server/rsc-entry/helpers.ts +2 -2
- package/src/server/rsc-entry/index.ts +42 -38
- package/src/server/rsc-entry/rsc-payload.ts +6 -6
- package/src/server/rsc-entry/rsc-stream.ts +6 -6
- package/src/server/rsc-entry/ssr-bridge.ts +2 -2
- package/src/server/rsc-entry/ssr-renderer.ts +16 -12
- package/src/server/slot-resolver.ts +2 -2
- package/src/server/ssr-entry.ts +3 -3
- package/src/server/status-code-resolver.ts +1 -1
- package/src/server/stream-utils.ts +209 -0
- package/src/server/tree-builder.ts +1 -1
- package/src/shims/font-google.ts +1 -1
- package/dist/_chunks/define-cookie-k9btcEfI.js.map +0 -1
- package/dist/_chunks/request-context-0h-6Voad.js.map +0 -1
- package/dist/params/index.js.map +0 -1
- package/dist/server/rsc-entry/ssr-error-bridge.d.ts +0 -12
- package/dist/server/rsc-entry/ssr-error-bridge.d.ts.map +0 -1
- package/dist/server/ssr-error-entry.d.ts +0 -65
- package/dist/server/ssr-error-entry.d.ts.map +0 -1
- package/src/server/rsc-entry/ssr-error-bridge.ts +0 -20
- package/src/server/ssr-error-entry.ts +0 -237
package/src/plugins/entries.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { Plugin } from 'vite';
|
|
|
15
15
|
import { resolve, dirname } from 'node:path';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
17
|
import { existsSync } from 'node:fs';
|
|
18
|
-
import type { PluginContext } from '
|
|
18
|
+
import type { PluginContext } from '../index.js';
|
|
19
19
|
|
|
20
20
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
21
21
|
|
package/src/plugins/fonts.ts
CHANGED
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
import type { Plugin, ViteDevServer } from 'vite';
|
|
18
18
|
import { readFileSync, existsSync } from 'node:fs';
|
|
19
19
|
import { resolve, normalize } from 'node:path';
|
|
20
|
-
import type { PluginContext } from '
|
|
21
|
-
import type { ExtractedFont, GoogleFontConfig } from '
|
|
22
|
-
import type { ManifestFontEntry } from '
|
|
23
|
-
import { generateVariableClass, generateFontFamilyClass, generateFontFaces } from '
|
|
24
|
-
import { generateFallbackCss, buildFontStack } from '
|
|
25
|
-
import { processLocalFont, generateLocalFontFaces } from '
|
|
26
|
-
import { inferFontFormat } from '
|
|
27
|
-
import { downloadAndCacheFonts, type CachedFont } from '
|
|
20
|
+
import type { PluginContext } from '../index.js';
|
|
21
|
+
import type { ExtractedFont, GoogleFontConfig } from '../fonts/types.js';
|
|
22
|
+
import type { ManifestFontEntry } from '../server/build-manifest.js';
|
|
23
|
+
import { generateVariableClass, generateFontFamilyClass, generateFontFaces } from '../fonts/css.js';
|
|
24
|
+
import { generateFallbackCss, buildFontStack } from '../fonts/fallbacks.js';
|
|
25
|
+
import { processLocalFont, generateLocalFontFaces } from '../fonts/local.js';
|
|
26
|
+
import { inferFontFormat } from '../fonts/local.js';
|
|
27
|
+
import { downloadAndCacheFonts, type CachedFont } from '../fonts/google.js';
|
|
28
28
|
import {
|
|
29
29
|
extractFontConfigAst,
|
|
30
30
|
extractLocalFontConfigAst,
|
|
31
31
|
detectDynamicFontCallAst,
|
|
32
|
-
} from '
|
|
32
|
+
} from '../fonts/ast.js';
|
|
33
33
|
|
|
34
34
|
const VIRTUAL_GOOGLE = '@timber/fonts/google';
|
|
35
35
|
const VIRTUAL_LOCAL = '@timber/fonts/local';
|
package/src/plugins/mdx.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import type { Plugin } from 'vite';
|
|
12
12
|
import { existsSync } from 'node:fs';
|
|
13
13
|
import { join } from 'node:path';
|
|
14
|
-
import type { PluginContext } from '
|
|
14
|
+
import type { PluginContext } from '../index.js';
|
|
15
15
|
|
|
16
16
|
const MDX_EXTENSIONS = ['mdx', 'md'];
|
|
17
17
|
|
package/src/plugins/routing.ts
CHANGED
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
import type { Plugin, ViteDevServer } from 'vite';
|
|
12
12
|
import { writeFile, mkdir } from 'node:fs/promises';
|
|
13
13
|
import { join } from 'node:path';
|
|
14
|
-
import { scanRoutes } from '
|
|
15
|
-
import { generateRouteMap } from '
|
|
16
|
-
import { collectInterceptionRewrites } from '
|
|
14
|
+
import { scanRoutes } from '../routing/scanner.js';
|
|
15
|
+
import { generateRouteMap } from '../routing/codegen.js';
|
|
16
|
+
import { collectInterceptionRewrites } from '../routing/interception.js';
|
|
17
17
|
import {
|
|
18
18
|
lintStatusFileDirectives,
|
|
19
19
|
formatStatusFileLintWarnings,
|
|
20
|
-
} from '
|
|
21
|
-
import type { RouteTree, SegmentNode, RouteFile } from '
|
|
22
|
-
import type { PluginContext } from '
|
|
20
|
+
} from '../routing/status-file-lint.js';
|
|
21
|
+
import type { RouteTree, SegmentNode, RouteFile } from '../routing/types.js';
|
|
22
|
+
import type { PluginContext } from '../index.js';
|
|
23
23
|
|
|
24
24
|
const VIRTUAL_MODULE_ID = 'virtual:timber-route-manifest';
|
|
25
25
|
const RESOLVED_VIRTUAL_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
import { Parser } from 'acorn';
|
|
3
3
|
import acornJsx from 'acorn-jsx';
|
|
4
|
-
import { detectFileDirective } from '
|
|
4
|
+
import { detectFileDirective } from '../utils/directive-parser.js';
|
|
5
5
|
|
|
6
6
|
const jsxParser = Parser.extend(acornJsx());
|
|
7
7
|
|
package/src/plugins/shims.ts
CHANGED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
* shim implementations. This enables Next.js-compatible libraries
|
|
6
6
|
* (nuqs, next-intl, etc.) to work unmodified.
|
|
7
7
|
*
|
|
8
|
-
* NOTE: This plugin does NOT
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* for shared
|
|
8
|
+
* NOTE: This plugin does NOT remap @timber-js/app/* subpath imports to
|
|
9
|
+
* src/. All subpath imports resolve to dist/ via Vite's native
|
|
10
|
+
* package.json `exports` resolution, ensuring a single module instance
|
|
11
|
+
* for shared code. The only exception is @timber-js/app/server in the
|
|
12
|
+
* client environment, which returns a virtual stub to prevent server
|
|
13
|
+
* code in browser bundles. See TIM-568 for why src/ remapping was
|
|
14
|
+
* removed.
|
|
12
15
|
*
|
|
13
16
|
* Design doc: 18-build-system.md §"Shim Map"
|
|
14
17
|
*/
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
import type { Plugin } from 'vite';
|
|
17
20
|
import { resolve, dirname } from 'node:path';
|
|
18
21
|
import { fileURLToPath } from 'node:url';
|
|
19
|
-
import type { PluginContext } from '
|
|
22
|
+
import type { PluginContext } from '../index.js';
|
|
20
23
|
|
|
21
24
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
25
|
// Detect whether we're running from source (src/plugins/) or dist (dist/).
|
|
@@ -88,14 +91,14 @@ export function timberShims(_ctx: PluginContext): Plugin {
|
|
|
88
91
|
* 3. Check next/* shim map
|
|
89
92
|
* 4. Return null (pass through) for everything else
|
|
90
93
|
*
|
|
91
|
-
* @timber-js/app
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
+
* All @timber-js/app/* subpath imports resolve to dist/ via package.json
|
|
95
|
+
* exports in all environments. This ensures a single module instance
|
|
96
|
+
* for each module — the dist/ chunks share code via rollup's code
|
|
97
|
+
* splitting. No src/ remapping is needed (see TIM-568).
|
|
94
98
|
*
|
|
95
|
-
* @timber-js/app/
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
* is preserved on the entry for client boundary detection.
|
|
99
|
+
* The only exception is @timber-js/app/server in the client (browser)
|
|
100
|
+
* environment, which returns a virtual stub — server code must never
|
|
101
|
+
* be bundled into the browser.
|
|
99
102
|
*/
|
|
100
103
|
resolveId(id: string) {
|
|
101
104
|
// Poison pill packages — resolve to virtual modules handled by load()
|
|
@@ -117,38 +120,15 @@ export function timberShims(_ctx: PluginContext): Plugin {
|
|
|
117
120
|
return SHIM_MAP[cleanId];
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
// @timber-js/app/server
|
|
121
|
-
//
|
|
122
|
-
// In
|
|
123
|
-
//
|
|
123
|
+
// @timber-js/app/server in the client environment → virtual stub.
|
|
124
|
+
// Server code must never be bundled into the browser.
|
|
125
|
+
// In server environments (RSC, SSR), let Vite resolve to dist/ via
|
|
126
|
+
// package.json exports — no src/ remap needed.
|
|
124
127
|
if (cleanId === '@timber-js/app/server') {
|
|
125
128
|
const envName = (this as unknown as { environment?: { name?: string } }).environment?.name;
|
|
126
129
|
if (envName === 'client') {
|
|
127
130
|
return '\0timber:server-empty';
|
|
128
131
|
}
|
|
129
|
-
return resolve(PKG_ROOT, 'src', 'server', 'index.ts');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// @timber-js/app/client → src/ in the SSR environment so client hooks
|
|
133
|
-
// (useParams, usePathname, etc.) share the same module instance as
|
|
134
|
-
// ssr-entry.ts's internal imports (via #/client/...).
|
|
135
|
-
//
|
|
136
|
-
// Without this remap, @timber-js/app/client resolves to dist/ (via
|
|
137
|
-
// package.json exports), creating a module instance split: ssr-entry.ts
|
|
138
|
-
// registers the ALS-backed SSR data provider on the src/ instance of
|
|
139
|
-
// ssr-data.ts, but client component hooks read getSsrData() from the
|
|
140
|
-
// dist/ instance — which has no provider. Result: hooks like useSegmentParams()
|
|
141
|
-
// return empty defaults during SSR.
|
|
142
|
-
//
|
|
143
|
-
// This remap is SSR-only. The RSC environment still resolves to dist/
|
|
144
|
-
// where 'use client' is preserved on the entry (needed for client
|
|
145
|
-
// boundary detection). The client (browser) environment uses dist/
|
|
146
|
-
// for bundling.
|
|
147
|
-
if (cleanId === '@timber-js/app/client') {
|
|
148
|
-
const envName = (this as unknown as { environment?: { name?: string } }).environment?.name;
|
|
149
|
-
if (envName === 'ssr') {
|
|
150
|
-
return resolve(PKG_ROOT, 'src', 'client', 'index.ts');
|
|
151
|
-
}
|
|
152
132
|
}
|
|
153
133
|
|
|
154
134
|
return null;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type { Plugin } from 'vite';
|
|
13
|
-
import type { PluginContext } from '
|
|
14
|
-
import { detectFileDirective } from '
|
|
13
|
+
import type { PluginContext } from '../index.js';
|
|
14
|
+
import { detectFileDirective } from '../utils/directive-parser.js';
|
|
15
15
|
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
// Types
|
package/src/routing/scanner.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
InterceptionMarker,
|
|
20
20
|
} from './types.js';
|
|
21
21
|
import { DEFAULT_PAGE_EXTENSIONS, INTERCEPTION_MARKERS } from './types.js';
|
|
22
|
-
import { classifyMetadataRoute, isDynamicMetadataExtension } from '
|
|
22
|
+
import { classifyMetadataRoute, isDynamicMetadataExtension } from '../server/metadata-routes.js';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Pattern matching encoded path delimiters that must be rejected during route discovery.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import { readFileSync } from 'node:fs';
|
|
17
17
|
import type { RouteTree, SegmentNode } from './types.js';
|
|
18
|
-
import { detectFileDirective } from '
|
|
18
|
+
import { detectFileDirective } from '../utils/directive-parser.js';
|
|
19
19
|
|
|
20
20
|
/** Extensions that require 'use client' (component files, not MDX/JSON). */
|
|
21
21
|
const CLIENT_REQUIRED_EXTENSIONS = new Set(['tsx', 'jsx', 'ts', 'js']);
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* Design doc: design/23-search-params.md §"defineSearchParams — The Factory"
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { useQueryStates as clientUseQueryStates } from '
|
|
13
|
+
import { useQueryStates as clientUseQueryStates } from '../client/use-query-states.js';
|
|
14
14
|
import { fromSchema } from './codecs.js';
|
|
15
|
-
import type { Codec } from '
|
|
15
|
+
import type { Codec } from '../codec.js';
|
|
16
16
|
|
|
17
17
|
// Server-only reference for .load() — avoids pulling server ALS into client bundles.
|
|
18
18
|
// In client environments, .load() throws before reaching this code path.
|
|
@@ -183,7 +183,7 @@ async function runActionMiddleware<TCtx>(
|
|
|
183
183
|
|
|
184
184
|
// Re-export parseFormData for use throughout the framework
|
|
185
185
|
import { parseFormData } from './form-data.js';
|
|
186
|
-
import { formatSize } from '
|
|
186
|
+
import { formatSize } from '../utils/format.js';
|
|
187
187
|
import { isDebug, isDevMode } from './debug.js';
|
|
188
188
|
|
|
189
189
|
/**
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
decodeReply,
|
|
19
19
|
decodeAction,
|
|
20
20
|
renderToReadableStream,
|
|
21
|
-
} from '
|
|
21
|
+
} from '../rsc-runtime/rsc.js';
|
|
22
22
|
|
|
23
23
|
import { validateCsrf, type CsrfConfig } from './csrf.js';
|
|
24
24
|
import { executeAction, type RevalidateRenderer } from './actions.js';
|
package/src/server/actions.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See design/08-forms-and-actions.md
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { CacheHandler } from '
|
|
17
|
+
import type { CacheHandler } from '../cache/index';
|
|
18
18
|
import { RedirectSignal } from './primitives';
|
|
19
19
|
import { withSpan } from './tracing';
|
|
20
20
|
import { revalidationAls, type RevalidationState } from './als-registry.js';
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
24
|
+
import type { DebugComponentEntry } from './rsc-entry/helpers.js';
|
|
24
25
|
|
|
25
26
|
// ─── Request Context ──────────────────────────────────────────────────────
|
|
26
27
|
// Used by: request-context.ts (headers(), cookies(), searchParams())
|
|
@@ -64,6 +65,12 @@ export interface RequestContextStore {
|
|
|
64
65
|
flushed: boolean;
|
|
65
66
|
/** Whether the current context allows cookie mutation. */
|
|
66
67
|
mutableContext: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Dev-only: getter for the current request's RSC debug components.
|
|
70
|
+
* Set by renderRoute() so onPipelineError can include component tree
|
|
71
|
+
* context for render-phase errors without module-level shared state.
|
|
72
|
+
*/
|
|
73
|
+
debugComponentsGetter?: () => DebugComponentEntry[];
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
/** A single outgoing cookie entry in the cookie jar. */
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { createElement } from 'react';
|
|
19
|
-
import { renderToReadableStream } from '
|
|
19
|
+
import { renderToReadableStream } from '../rsc-runtime/rsc.js';
|
|
20
20
|
|
|
21
21
|
import { DenySignal } from './primitives.js';
|
|
22
22
|
import { logRenderError } from './logger.js';
|
|
@@ -29,6 +29,7 @@ import type { NavContext } from './ssr-entry.js';
|
|
|
29
29
|
import { flightInitScript } from './flight-scripts.js';
|
|
30
30
|
import type { ClientBootstrapConfig } from './html-injectors.js';
|
|
31
31
|
import type { Metadata } from './types.js';
|
|
32
|
+
import { teeWithErrorPropagation } from './stream-utils.js';
|
|
32
33
|
|
|
33
34
|
/** RSC content type for client navigation payload requests. */
|
|
34
35
|
const RSC_CONTENT_TYPE = 'text/x-component';
|
|
@@ -171,7 +172,7 @@ export async function renderDenyPage(
|
|
|
171
172
|
debugChannel: createDebugChannelSink(),
|
|
172
173
|
});
|
|
173
174
|
|
|
174
|
-
const [ssrStream, inlineStream] = rscStream
|
|
175
|
+
const [ssrStream, inlineStream] = teeWithErrorPropagation(rscStream);
|
|
175
176
|
|
|
176
177
|
const navContext: NavContext = {
|
|
177
178
|
pathname: new URL(req.url).pathname,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* See design/10-error-handling.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { TimberErrorBoundary } from '
|
|
8
|
+
import { TimberErrorBoundary } from '../client/error-boundary.js';
|
|
9
9
|
import type { ManifestSegmentNode } from './route-matcher.js';
|
|
10
10
|
|
|
11
11
|
/** MDX/markdown extensions — server components that cannot be passed as function props. */
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* exposed to the client (design/13-security.md principle 4).
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type { RouteMatch } from '
|
|
14
|
-
import type { ManifestSegmentNode } from '
|
|
15
|
-
import type { ClientBootstrapConfig } from '
|
|
16
|
-
import type { LayoutEntry } from '
|
|
17
|
-
import type { GlobalErrorFile } from '
|
|
13
|
+
import type { RouteMatch } from './pipeline.js';
|
|
14
|
+
import type { ManifestSegmentNode } from './route-matcher.js';
|
|
15
|
+
import type { ClientBootstrapConfig } from './html-injectors.js';
|
|
16
|
+
import type { LayoutEntry } from './deny-renderer.js';
|
|
17
|
+
import type { GlobalErrorFile } from './rsc-entry/error-renderer.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Render a fallback error page when the render pipeline throws.
|
|
@@ -35,7 +35,7 @@ export async function renderFallbackError(
|
|
|
35
35
|
return renderDevErrorPage(error);
|
|
36
36
|
}
|
|
37
37
|
// Lazy import to avoid loading error-renderer in the pipeline module
|
|
38
|
-
const { renderErrorPage } = await import('
|
|
38
|
+
const { renderErrorPage } = await import('./rsc-entry/error-renderer.js');
|
|
39
39
|
const segments = [rootSegment];
|
|
40
40
|
const layoutComponents: LayoutEntry[] = [];
|
|
41
41
|
if (rootSegment.layout) {
|
|
@@ -26,7 +26,7 @@ export interface InterceptionMatchResult {
|
|
|
26
26
|
export function findInterceptionMatch(
|
|
27
27
|
targetPathname: string,
|
|
28
28
|
sourceUrl: string,
|
|
29
|
-
rewrites: import('
|
|
29
|
+
rewrites: import('../routing/interception.js').InterceptionRewrite[]
|
|
30
30
|
): InterceptionMatchResult | null {
|
|
31
31
|
for (const rewrite of rewrites) {
|
|
32
32
|
// Check if the source URL starts with the intercepting prefix
|
package/src/server/pipeline.ts
CHANGED
|
@@ -48,7 +48,7 @@ import { checkVersionSkew, applyReloadHeaders } from './version-skew.js';
|
|
|
48
48
|
import { serveStaticMetadataFile, serializeSitemap } from './pipeline-metadata.js';
|
|
49
49
|
import { findInterceptionMatch } from './pipeline-interception.js';
|
|
50
50
|
import type { MiddlewareContext } from './types.js';
|
|
51
|
-
import type { SegmentNode } from '
|
|
51
|
+
import type { SegmentNode } from '../routing/types.js';
|
|
52
52
|
|
|
53
53
|
// ─── Route Match Result ────────────────────────────────────────────────────
|
|
54
54
|
|
|
@@ -118,7 +118,7 @@ export interface PipelineConfig {
|
|
|
118
118
|
* Generated at build time from intercepting route directories.
|
|
119
119
|
* See design/07-routing.md §"Intercepting Routes"
|
|
120
120
|
*/
|
|
121
|
-
interceptionRewrites?: import('
|
|
121
|
+
interceptionRewrites?: import('../routing/interception.js').InterceptionRewrite[];
|
|
122
122
|
/**
|
|
123
123
|
* Control Server-Timing header output.
|
|
124
124
|
*
|
package/src/server/primitives.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { JsonSerializable } from './types.js';
|
|
|
7
7
|
import { getWaitUntil as _getWaitUntil } from './waituntil-bridge.js';
|
|
8
8
|
import { isDebug } from './debug.js';
|
|
9
9
|
import { getRequestSearchString } from './request-context.js';
|
|
10
|
-
import { mergePreservedSearchParams } from '
|
|
10
|
+
import { mergePreservedSearchParams } from '../shared/merge-search-params.js';
|
|
11
11
|
|
|
12
12
|
// ─── Dev-mode validation ────────────────────────────────────────────────────
|
|
13
13
|
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import { requestContextAls, type RequestContextStore, type CookieEntry } from './als-registry.js';
|
|
14
14
|
import { isDebug } from './debug.js';
|
|
15
|
-
import { _setRawSearchParamsFn } from '
|
|
15
|
+
import { _setRawSearchParamsFn } from '../search-params/define.js';
|
|
16
|
+
import { _setRawSegmentParamsFn } from '../params/define.js';
|
|
16
17
|
|
|
17
18
|
// Re-export the ALS for framework-internal consumers that need direct access.
|
|
18
19
|
export { requestContextAls };
|
|
@@ -185,6 +186,11 @@ export function rawSearchParams(): Promise<URLSearchParams> {
|
|
|
185
186
|
// breaking rawSearchParams() in parallel slot pages. See TIM-523.
|
|
186
187
|
_setRawSearchParamsFn(rawSearchParams);
|
|
187
188
|
|
|
189
|
+
// Eagerly register rawSegmentParams with the params module so
|
|
190
|
+
// segmentParams.load() can call it synchronously without a dynamic import.
|
|
191
|
+
// Same pattern as search params — dynamic imports lose ALS context. See TIM-523.
|
|
192
|
+
_setRawSegmentParamsFn(rawSegmentParams);
|
|
193
|
+
|
|
188
194
|
/**
|
|
189
195
|
* Returns a Promise resolving to the current request's coerced segment params.
|
|
190
196
|
*
|
|
@@ -27,7 +27,7 @@ import { METADATA_ROUTE_CONVENTIONS, getMetadataRouteAutoLink } from './metadata
|
|
|
27
27
|
import { DenySignal, RedirectSignal } from './primitives.js';
|
|
28
28
|
import { AccessGate } from './access-gate.js';
|
|
29
29
|
import { resolveSlotElement } from './slot-resolver.js';
|
|
30
|
-
import { SegmentProvider } from '
|
|
30
|
+
import { SegmentProvider } from '../client/segment-context.js';
|
|
31
31
|
|
|
32
32
|
import { wrapSegmentWithErrorBoundaries } from './error-boundary-wrapper.js';
|
|
33
33
|
import type { InterceptionContext } from './pipeline.js';
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* See design/04-authorization.md §"Auth in API Routes".
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { withSpan, setSpanAttribute } from '
|
|
10
|
-
import type { ManifestSegmentNode } from '
|
|
11
|
-
import type { RouteMatch } from '
|
|
12
|
-
import { DenySignal, RedirectSignal } from '
|
|
13
|
-
import { handleRouteRequest } from '
|
|
14
|
-
import type { RouteModule } from '
|
|
15
|
-
import type { RouteContext } from '
|
|
9
|
+
import { withSpan, setSpanAttribute } from '../tracing.js';
|
|
10
|
+
import type { ManifestSegmentNode } from '../route-matcher.js';
|
|
11
|
+
import type { RouteMatch } from '../pipeline.js';
|
|
12
|
+
import { DenySignal, RedirectSignal } from '../primitives.js';
|
|
13
|
+
import { handleRouteRequest } from '../route-handler.js';
|
|
14
|
+
import type { RouteModule } from '../route-handler.js';
|
|
15
|
+
import type { RouteContext } from '../types.js';
|
|
16
16
|
|
|
17
17
|
export async function handleApiRoute(
|
|
18
18
|
req: Request,
|
|
@@ -90,7 +90,7 @@ async function renderApiDeny(
|
|
|
90
90
|
segments: ManifestSegmentNode[],
|
|
91
91
|
responseHeaders: Headers
|
|
92
92
|
): Promise<Response> {
|
|
93
|
-
const { resolveManifestStatusFile } = await import('
|
|
93
|
+
const { resolveManifestStatusFile } = await import('../manifest-status-resolver.js');
|
|
94
94
|
|
|
95
95
|
const resolution = resolveManifestStatusFile(deny.status, segments, 'json');
|
|
96
96
|
if (resolution) {
|