@timber-js/app 0.1.3 → 0.1.5
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/{interception-DIaZN1bF.js → interception-c-a3uODY.js} +8 -8
- package/dist/_chunks/interception-c-a3uODY.js.map +1 -0
- package/dist/_chunks/{registry-DUIpYD_x.js → registry-BfPM41ri.js} +1 -1
- package/dist/_chunks/{registry-DUIpYD_x.js.map → registry-BfPM41ri.js.map} +1 -1
- package/dist/_chunks/{request-context-D6XHINkR.js → request-context-BzES06i1.js} +2 -1
- package/dist/_chunks/request-context-BzES06i1.js.map +1 -0
- package/dist/_chunks/{use-cookie-8ZlA0rr3.js → use-cookie-HcvNlW4L.js} +1 -1
- package/dist/_chunks/{use-cookie-8ZlA0rr3.js.map → use-cookie-HcvNlW4L.js.map} +1 -1
- package/dist/adapters/cloudflare.d.ts +2 -2
- package/dist/adapters/cloudflare.js +4 -4
- package/dist/adapters/cloudflare.js.map +1 -1
- package/dist/adapters/nitro.d.ts +1 -1
- package/dist/adapters/nitro.js +4 -4
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/{_chunks/error-boundary-dj-WO5uq.js → client/error-boundary.js} +4 -2
- package/dist/client/error-boundary.js.map +1 -0
- package/dist/client/form.d.ts +1 -1
- package/dist/client/index.js +10 -9
- package/dist/client/index.js.map +1 -1
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/slot-error-fallback.d.ts +13 -0
- package/dist/client/slot-error-fallback.d.ts.map +1 -0
- package/dist/client/use-link-status.d.ts +1 -1
- package/dist/client/use-navigation-pending.d.ts +1 -1
- package/dist/content/index.d.ts +1 -1
- package/dist/cookies/define-cookie.d.ts +2 -2
- package/dist/cookies/index.d.ts +1 -1
- package/dist/cookies/index.d.ts.map +1 -1
- package/dist/cookies/index.js +4 -4
- package/dist/cookies/index.js.map +1 -1
- package/dist/index.js +23 -22
- package/dist/index.js.map +1 -1
- package/dist/plugins/dev-logs.d.ts +1 -1
- package/dist/plugins/dynamic-transform.d.ts +1 -1
- package/dist/plugins/shims.d.ts +5 -0
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/routing/codegen.d.ts +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/search-params/codecs.d.ts +2 -2
- package/dist/search-params/create.d.ts +1 -1
- package/dist/search-params/index.js +5 -5
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/action-client.d.ts +1 -1
- package/dist/server/dev-fetch-instrumentation.d.ts +22 -0
- package/dist/server/dev-fetch-instrumentation.d.ts.map +1 -0
- package/dist/server/dev-logger.d.ts.map +1 -1
- package/dist/server/form-flash.d.ts +1 -1
- package/dist/server/index.js +4 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/primitives.d.ts +15 -0
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/request-context.d.ts +32 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/slot-resolver.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/shims/headers.d.ts +5 -7
- package/dist/shims/headers.d.ts.map +1 -1
- package/dist/shims/link.d.ts +1 -1
- package/dist/shims/link.d.ts.map +1 -1
- package/dist/shims/navigation.d.ts +5 -15
- package/dist/shims/navigation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/cloudflare.ts +4 -4
- package/src/adapters/nitro.ts +4 -4
- package/src/cache/index.ts +1 -1
- package/src/client/form.tsx +1 -1
- package/src/client/index.ts +1 -1
- package/src/client/link.tsx +2 -0
- package/src/client/slot-error-fallback.tsx +16 -0
- package/src/client/use-link-status.ts +1 -1
- package/src/client/use-navigation-pending.ts +1 -1
- package/src/content/index.ts +1 -1
- package/src/cookies/define-cookie.ts +2 -2
- package/src/cookies/index.ts +2 -6
- package/src/plugins/cache-transform.ts +1 -1
- package/src/plugins/dev-logs.ts +2 -2
- package/src/plugins/dynamic-transform.ts +2 -2
- package/src/plugins/shims.ts +48 -22
- package/src/routing/codegen.ts +9 -9
- package/src/search-params/codecs.ts +2 -2
- package/src/search-params/create.ts +3 -3
- package/src/search-params/index.ts +1 -1
- package/src/server/action-client.ts +1 -1
- package/src/server/asset-headers.ts +1 -1
- package/src/server/dev-fetch-instrumentation.ts +96 -0
- package/src/server/dev-logger.ts +49 -0
- package/src/server/form-flash.ts +1 -1
- package/src/server/index.ts +1 -1
- package/src/server/primitives.ts +24 -1
- package/src/server/request-context.ts +7 -1
- package/src/server/route-element-builder.ts +2 -5
- package/src/server/rsc-entry/index.ts +33 -1
- package/src/server/slot-resolver.ts +20 -1
- package/src/server/ssr-entry.ts +21 -5
- package/src/shims/headers.ts +5 -7
- package/src/shims/link.ts +3 -1
- package/src/shims/navigation.ts +7 -17
- package/dist/_chunks/error-boundary-dj-WO5uq.js.map +0 -1
- package/dist/_chunks/interception-DIaZN1bF.js.map +0 -1
- package/dist/_chunks/request-context-D6XHINkR.js.map +0 -1
|
@@ -128,4 +128,19 @@ export declare function waitUntil(promise: Promise<unknown>, adapter: WaitUntilA
|
|
|
128
128
|
* @internal
|
|
129
129
|
*/
|
|
130
130
|
export declare function _resetWaitUntilWarning(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Error thrown when SSR's renderToReadableStream fails due to an error
|
|
133
|
+
* in the decoded RSC stream (e.g., uncontained slot errors).
|
|
134
|
+
*
|
|
135
|
+
* The RSC entry checks for this error type in its catch block to avoid
|
|
136
|
+
* re-executing server components via renderDenyPage. Instead, it renders
|
|
137
|
+
* a bare deny/error page without layout wrapping.
|
|
138
|
+
*
|
|
139
|
+
* Defined in primitives.ts (not ssr-entry.ts) because ssr-entry.ts imports
|
|
140
|
+
* react-dom/server which cannot be loaded in the RSC environment.
|
|
141
|
+
*/
|
|
142
|
+
export declare class SsrStreamError extends Error {
|
|
143
|
+
readonly cause: unknown;
|
|
144
|
+
constructor(message: string, cause: unknown);
|
|
145
|
+
}
|
|
131
146
|
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/server/primitives.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO;IAO1C;;;;OAIG;IACH,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAqBnC;CACF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,MAAM,GAAE,MAAY,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,CAQhE;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,IAAI,KAAK,CAEhC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAIX;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM7C;AAKD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAY,GAAG,KAAK,CAWlE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAY,GAAG,KAAK,CAoB9F;AAID;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,KAAK,SAAS,M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AAA;KAAE;CAYpE;AAID,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAC7C;AAMD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAapF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAID;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,KAAK,EAAE,OAAO;gBAD9B,OAAO,EAAE,MAAM,EACC,KAAK,EAAE,OAAO;CAKjC"}
|
|
@@ -9,7 +9,38 @@
|
|
|
9
9
|
* and design/11-platform.md §"AsyncLocalStorage".
|
|
10
10
|
* See design/29-cookies.md for cookie mutation semantics.
|
|
11
11
|
*/
|
|
12
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
12
13
|
import type { Routes } from '#/index.js';
|
|
14
|
+
interface RequestContextStore {
|
|
15
|
+
/** Incoming request headers (read-only view). */
|
|
16
|
+
headers: Headers;
|
|
17
|
+
/** Raw cookie header string, parsed lazily into a Map on first access. */
|
|
18
|
+
cookieHeader: string;
|
|
19
|
+
/** Lazily-parsed cookie map (mutable — reflects write-overlay from set()). */
|
|
20
|
+
parsedCookies?: Map<string, string>;
|
|
21
|
+
/** Original (pre-overlay) frozen headers, kept for overlay merging. */
|
|
22
|
+
originalHeaders: Headers;
|
|
23
|
+
/**
|
|
24
|
+
* Promise resolving to the route's typed search params (when search-params.ts
|
|
25
|
+
* exists) or to the raw URLSearchParams. Stored as a Promise so the framework
|
|
26
|
+
* can later support partial pre-rendering where param resolution is deferred.
|
|
27
|
+
*/
|
|
28
|
+
searchParamsPromise: Promise<URLSearchParams | Record<string, unknown>>;
|
|
29
|
+
/** Outgoing Set-Cookie entries (name → serialized value + options). Last write wins. */
|
|
30
|
+
cookieJar: Map<string, CookieEntry>;
|
|
31
|
+
/** Whether the response has flushed (headers committed). */
|
|
32
|
+
flushed: boolean;
|
|
33
|
+
/** Whether the current context allows cookie mutation. */
|
|
34
|
+
mutableContext: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** A single outgoing cookie entry in the cookie jar. */
|
|
37
|
+
interface CookieEntry {
|
|
38
|
+
name: string;
|
|
39
|
+
value: string;
|
|
40
|
+
options: CookieOptions;
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare const requestContextAls: AsyncLocalStorage<RequestContextStore>;
|
|
13
44
|
/**
|
|
14
45
|
* Configure the cookie signing secrets.
|
|
15
46
|
*
|
|
@@ -172,4 +203,5 @@ export declare function getSetCookieHeaders(): string[];
|
|
|
172
203
|
* See design/07-routing.md §"Request Header Injection"
|
|
173
204
|
*/
|
|
174
205
|
export declare function applyRequestHeaderOverlay(overlay: Headers): void;
|
|
206
|
+
export {};
|
|
175
207
|
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/server/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/server/request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIzC,UAAU,mBAAmB;IAC3B,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,uEAAuE;IACvE,eAAe,EAAE,OAAO,CAAC;IACzB;;;;OAIG;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D,KAAK,IAAI,IAAI,CAAC;IACd,mDAAmD;IACnD,QAAQ,IAAI,MAAM,CAAC;CACpB;AAID;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAYrE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAK9D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAI9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmBhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-element-builder.d.ts","sourceRoot":"","sources":["../../src/server/route-element-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"route-element-builder.d.ts","sourceRoot":"","sources":["../../src/server/route-element-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAO7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzD,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;CACvC;AAED,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC;CAC9B;AAED,+CAA+C;AAC/C,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC;IAC5B,2CAA2C;IAC3C,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,wDAAwD;IACxD,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,qCAAqC;IACrC,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAE7B,MAAM,EAAE,UAAU,GAAG,cAAc;aACnC,gBAAgB,EAAE,oBAAoB,EAAE;aACxC,QAAQ,EAAE,mBAAmB,EAAE;gBAF/B,MAAM,EAAE,UAAU,GAAG,cAAc,EACnC,gBAAgB,EAAE,oBAAoB,EAAE,EACxC,QAAQ,EAAE,mBAAmB,EAAE;CAIlD;AAID;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,UAAU,EACjB,YAAY,CAAC,EAAE,mBAAmB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAyS7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AA2EA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAE/F;AA0nBD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;8BAtgBpD,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;AAwgBhD,wBAAiE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot-resolver.d.ts","sourceRoot":"","sources":["../../src/server/slot-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"slot-resolver.d.ts","sourceRoot":"","sources":["../../src/server/slot-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMrE,KAAK,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,KAAK,CAAC,YAAY,CAAC;AAElE;;;;;;;;;;GAUG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,UAAU,EACjB,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,EACzD,CAAC,EAAE,eAAe,EAClB,YAAY,CAAC,EAAE,mBAAmB,GACjC,OAAO,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAiIpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-entry.d.ts","sourceRoot":"","sources":["../../src/server/ssr-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"ssr-entry.d.ts","sourceRoot":"","sources":["../../src/server/ssr-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA6BH;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,eAAe,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qEAAqE;IACrE,SAAS,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACvC;;;0DAGsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;iFAE6E;IAC7E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;4DACwD;IACxD,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EACrC,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,QAAQ,CAAC,CAwEnB;AAED,eAAe,SAAS,CAAC"}
|
package/dist/shims/headers.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shim: next/headers → timber
|
|
2
|
+
* Shim: next/headers → timber server
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* See design/14-ecosystem.md §"next/headers" for the full shim audit.
|
|
4
|
+
* Imports from @timber-js/app/server which Vite resolves to dist/server/index.js
|
|
5
|
+
* via native package.json exports. This ensures the same ALS singleton as the
|
|
6
|
+
* pipeline (both import from the same shared request-context chunk in dist/).
|
|
9
7
|
*/
|
|
10
|
-
export { headers, cookies } from '
|
|
8
|
+
export { headers, cookies } from '@timber-js/app/server';
|
|
11
9
|
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/shims/headers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/shims/headers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/shims/link.d.ts
CHANGED
package/dist/shims/link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/shims/link.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/shims/link.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shim: next/navigation → timber navigation primitives
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* that
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Note: nuqs imports next/navigation.js (with .js extension).
|
|
9
|
-
* The timber-shims plugin strips .js before matching.
|
|
10
|
-
*
|
|
11
|
-
* Intentional divergences from Next.js:
|
|
12
|
-
* - useRouter().replace() currently uses pushState (same as push) —
|
|
13
|
-
* timber's router doesn't distinguish push/replace yet.
|
|
14
|
-
* - redirect() does not accept a RedirectType argument — timber
|
|
15
|
-
* always uses replace semantics for redirects.
|
|
16
|
-
* - permanentRedirect() delegates to redirect(path, 308).
|
|
17
|
-
* See design/14-ecosystem.md for the full shim audit.
|
|
4
|
+
* Client hooks use #/ source imports (individual files with 'use client' directives
|
|
5
|
+
* that the RSC plugin detects).
|
|
6
|
+
* Server functions use @timber-js/app/server (resolved to dist/ via native exports)
|
|
7
|
+
* for ALS singleton consistency.
|
|
18
8
|
*/
|
|
19
9
|
export { useParams } from '#/client/use-params.js';
|
|
20
10
|
export { usePathname } from '#/client/use-pathname.js';
|
|
21
11
|
export { useSearchParams } from '#/client/use-search-params.js';
|
|
22
12
|
export { useRouter } from '#/client/use-router.js';
|
|
23
13
|
export { useSelectedLayoutSegment, useSelectedLayoutSegments, } from '#/client/use-selected-layout-segment.js';
|
|
24
|
-
export { redirect, permanentRedirect, notFound, RedirectType } from '
|
|
14
|
+
export { redirect, permanentRedirect, notFound, RedirectType } from '@timber-js/app/server';
|
|
25
15
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/shims/navigation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/shims/navigation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Vite-native React framework for Cloudflare Workers — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -15,7 +15,7 @@ const IMMUTABLE_CACHE = 'public, max-age=31536000, immutable';
|
|
|
15
15
|
const STATIC_CACHE = 'public, max-age=3600, must-revalidate';
|
|
16
16
|
|
|
17
17
|
function generateHeadersFile(): string {
|
|
18
|
-
return `# Auto-generated by @timber/app — static asset cache headers.
|
|
18
|
+
return `# Auto-generated by @timber-js/app — static asset cache headers.
|
|
19
19
|
# See design/25-production-deployments.md §"CDN / Edge Cache"
|
|
20
20
|
|
|
21
21
|
/assets/*
|
|
@@ -46,7 +46,7 @@ const bindingsAls = new AsyncLocalStorage<Record<string, unknown>>();
|
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
48
|
* ```ts
|
|
49
|
-
* import { getCloudflareBindings } from '@timber/app/adapters/cloudflare'
|
|
49
|
+
* import { getCloudflareBindings } from '@timber-js/app/adapters/cloudflare'
|
|
50
50
|
*
|
|
51
51
|
* export default async function Page() {
|
|
52
52
|
* const { MY_KV, MY_DB } = getCloudflareBindings()
|
|
@@ -103,7 +103,7 @@ export interface CloudflareAdapterOptions {
|
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
105
|
* ```ts
|
|
106
|
-
* import { cloudflare } from '@timber/app/adapters/cloudflare'
|
|
106
|
+
* import { cloudflare } from '@timber-js/app/adapters/cloudflare'
|
|
107
107
|
*
|
|
108
108
|
* export default {
|
|
109
109
|
* output: 'server',
|
|
@@ -229,7 +229,7 @@ export function generateWorkerEntry(
|
|
|
229
229
|
// ESM guarantees imports are evaluated in order.
|
|
230
230
|
const manifestImport = hasManifestInit ? "import './_timber-manifest-init.js'\n" : '';
|
|
231
231
|
|
|
232
|
-
return `// Generated by @timber/app/adapters/cloudflare
|
|
232
|
+
return `// Generated by @timber-js/app/adapters/cloudflare
|
|
233
233
|
// Do not edit — this file is regenerated on each build.
|
|
234
234
|
|
|
235
235
|
${manifestImport}import handler from '${rscEntryRelative}'
|
package/src/adapters/nitro.ts
CHANGED
|
@@ -16,7 +16,7 @@ const IMMUTABLE_CACHE = 'public, max-age=31536000, immutable';
|
|
|
16
16
|
const STATIC_CACHE = 'public, max-age=3600, must-revalidate';
|
|
17
17
|
|
|
18
18
|
function generateHeadersFile(): string {
|
|
19
|
-
return `# Auto-generated by @timber/app — static asset cache headers.
|
|
19
|
+
return `# Auto-generated by @timber-js/app — static asset cache headers.
|
|
20
20
|
# See design/25-production-deployments.md §"CDN / Edge Cache"
|
|
21
21
|
|
|
22
22
|
/assets/*
|
|
@@ -156,7 +156,7 @@ export interface NitroAdapterOptions {
|
|
|
156
156
|
*
|
|
157
157
|
* @example
|
|
158
158
|
* ```ts
|
|
159
|
-
* import { nitro } from '@timber/app/adapters/nitro'
|
|
159
|
+
* import { nitro } from '@timber-js/app/adapters/nitro'
|
|
160
160
|
*
|
|
161
161
|
* export default {
|
|
162
162
|
* output: 'server',
|
|
@@ -265,7 +265,7 @@ export function generateNitroEntry(
|
|
|
265
265
|
: await handler(webRequest)`
|
|
266
266
|
: ` const webResponse = await handler(webRequest)`;
|
|
267
267
|
|
|
268
|
-
return `// Generated by @timber/app/adapters/nitro
|
|
268
|
+
return `// Generated by @timber-js/app/adapters/nitro
|
|
269
269
|
// Do not edit — this file is regenerated on each build.
|
|
270
270
|
|
|
271
271
|
${manifestImport}${earlyHintsImport}import { defineEventHandler, toWebRequest, sendWebResponse } from 'h3'
|
|
@@ -304,7 +304,7 @@ export function generateNitroConfig(
|
|
|
304
304
|
|
|
305
305
|
const configJson = JSON.stringify(config, null, 2);
|
|
306
306
|
|
|
307
|
-
return `// Generated by @timber/app/adapters/nitro
|
|
307
|
+
return `// Generated by @timber-js/app/adapters/nitro
|
|
308
308
|
// Do not edit — this file is regenerated on each build.
|
|
309
309
|
|
|
310
310
|
import { defineNitroConfig } from 'nitropack/config'
|
package/src/cache/index.ts
CHANGED
package/src/client/form.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export type UseActionStateReturn<TData> = [
|
|
|
51
51
|
* @example
|
|
52
52
|
* ```tsx
|
|
53
53
|
* 'use client'
|
|
54
|
-
* import { useActionState } from '@timber/app/client'
|
|
54
|
+
* import { useActionState } from '@timber-js/app/client'
|
|
55
55
|
* import { createTodo } from './actions'
|
|
56
56
|
*
|
|
57
57
|
* export function NewTodoForm({ flash }) {
|
package/src/client/index.ts
CHANGED
package/src/client/link.tsx
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Null fallback component for the slot catch-all error boundary.
|
|
5
|
+
*
|
|
6
|
+
* When a slot throws an error that isn't caught by a user-defined error.tsx,
|
|
7
|
+
* this boundary renders nothing — the slot gracefully degrades per
|
|
8
|
+
* design/02-rendering-pipeline.md §"Slot Access Failure = Graceful Degradation".
|
|
9
|
+
*
|
|
10
|
+
* This must be a 'use client' component because TimberErrorBoundary passes it
|
|
11
|
+
* as a prop (fallbackComponent), and server component functions cannot be
|
|
12
|
+
* passed directly to client components.
|
|
13
|
+
*/
|
|
14
|
+
export default function SlotErrorFallback(): null {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
@@ -25,7 +25,7 @@ export const LinkStatusContext = createContext<LinkStatus>({ pending: false });
|
|
|
25
25
|
*
|
|
26
26
|
* ```tsx
|
|
27
27
|
* 'use client'
|
|
28
|
-
* import { Link, useLinkStatus } from '@timber/app/client'
|
|
28
|
+
* import { Link, useLinkStatus } from '@timber-js/app/client'
|
|
29
29
|
*
|
|
30
30
|
* function Hint() {
|
|
31
31
|
* const { pending } = useLinkStatus()
|
|
@@ -16,7 +16,7 @@ import { getRouter } from './router-ref.js';
|
|
|
16
16
|
*
|
|
17
17
|
* ```tsx
|
|
18
18
|
* 'use client'
|
|
19
|
-
* import { useNavigationPending } from '@timber/app/client'
|
|
19
|
+
* import { useNavigationPending } from '@timber-js/app/client'
|
|
20
20
|
*
|
|
21
21
|
* export function NavBar() {
|
|
22
22
|
* const isPending = useNavigationPending()
|
package/src/content/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @timber/app/content — Public API for content collections.
|
|
2
|
+
* @timber-js/app/content — Public API for content collections.
|
|
3
3
|
*
|
|
4
4
|
* Re-exports from content-collections and provides timber-specific utilities.
|
|
5
5
|
* Users can import directly from 'content-collections' for generated types,
|
|
@@ -60,8 +60,8 @@ export interface CookieDefinition<T> {
|
|
|
60
60
|
* Define a typed cookie.
|
|
61
61
|
*
|
|
62
62
|
* ```ts
|
|
63
|
-
* import { defineCookie } from '@timber/app/cookies';
|
|
64
|
-
* import { fromSchema } from '@timber/app/search-params';
|
|
63
|
+
* import { defineCookie } from '@timber-js/app/cookies';
|
|
64
|
+
* import { fromSchema } from '@timber-js/app/search-params';
|
|
65
65
|
* import { z } from 'zod/v4';
|
|
66
66
|
*
|
|
67
67
|
* export const themeCookie = defineCookie('theme', {
|
package/src/cookies/index.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
// @timber/app/cookies — Typed cookie definitions
|
|
1
|
+
// @timber-js/app/cookies — Typed cookie definitions
|
|
2
2
|
// See design/29-cookies.md §"Typed Cookies with Schema Validation"
|
|
3
3
|
|
|
4
4
|
export { defineCookie } from './define-cookie.js';
|
|
5
|
-
export type {
|
|
6
|
-
CookieDefinition,
|
|
7
|
-
CookieCodec,
|
|
8
|
-
DefineCookieOptions,
|
|
9
|
-
} from './define-cookie.js';
|
|
5
|
+
export type { CookieDefinition, CookieCodec, DefineCookieOptions } from './define-cookie.js';
|
|
@@ -162,7 +162,7 @@ export function transformUseCache(code: string, fileId: string): TransformResult
|
|
|
162
162
|
|
|
163
163
|
if (needsImport) {
|
|
164
164
|
// Add the import at the top of the file
|
|
165
|
-
result = `import { registerCachedFunction } from '@timber/app/cache';\n` + result;
|
|
165
|
+
result = `import { registerCachedFunction } from '@timber-js/app/cache';\n` + result;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
return { code: result, map: null, warnings: warnings.length > 0 ? warnings : undefined };
|
package/src/plugins/dev-logs.ts
CHANGED
|
@@ -178,7 +178,7 @@ function extractCallerLocation(projectRoot: string): string | null {
|
|
|
178
178
|
* (render errors, action errors, route handler errors, etc.).
|
|
179
179
|
*
|
|
180
180
|
* Handles both monorepo paths (timber-app/src/plugins/) and installed
|
|
181
|
-
* package paths (@timber/app/dist/plugins/).
|
|
181
|
+
* package paths (@timber-js/app/dist/plugins/).
|
|
182
182
|
*/
|
|
183
183
|
export function isFrameworkInternalCaller(): boolean {
|
|
184
184
|
const err = new Error();
|
|
@@ -194,7 +194,7 @@ export function isFrameworkInternalCaller(): boolean {
|
|
|
194
194
|
if (line.includes('node:')) continue;
|
|
195
195
|
|
|
196
196
|
// Check if this first real frame is inside timber's own source
|
|
197
|
-
const isTimberPath = line.includes('timber-app/') || line.includes('@timber/app/');
|
|
197
|
+
const isTimberPath = line.includes('timber-app/') || line.includes('@timber-js/app/');
|
|
198
198
|
if (!isTimberPath) return false;
|
|
199
199
|
|
|
200
200
|
// Only filter plugin and adapter internals, not server/ runtime code
|
|
@@ -54,7 +54,7 @@ interface TransformResult {
|
|
|
54
54
|
*
|
|
55
55
|
* Output:
|
|
56
56
|
* ```tsx
|
|
57
|
-
* import { markDynamic as __markDynamic } from '@timber/app/runtime';
|
|
57
|
+
* import { markDynamic as __markDynamic } from '@timber-js/app/runtime';
|
|
58
58
|
* export default async function AddToCartButton({ productId }) {
|
|
59
59
|
* __markDynamic();
|
|
60
60
|
* const user = await getUser()
|
|
@@ -83,7 +83,7 @@ export function transformUseDynamic(code: string): TransformResult | null {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Add the import at the top
|
|
86
|
-
result = `import { markDynamic as __markDynamic } from '@timber/app/runtime';\n` + result;
|
|
86
|
+
result = `import { markDynamic as __markDynamic } from '@timber-js/app/runtime';\n` + result;
|
|
87
87
|
|
|
88
88
|
return { code: result, map: null };
|
|
89
89
|
}
|
package/src/plugins/shims.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
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 resolve @timber-js/app/* subpath imports.
|
|
9
|
+
* Those are handled by Vite's native package.json `exports` resolution,
|
|
10
|
+
* which maps them to dist/ files. This ensures a single module instance
|
|
11
|
+
* for shared modules like request-context (ALS singleton).
|
|
12
|
+
*
|
|
8
13
|
* Design doc: 18-build-system.md §"Shim Map"
|
|
9
14
|
*/
|
|
10
15
|
|
|
@@ -14,7 +19,14 @@ import { fileURLToPath } from 'node:url';
|
|
|
14
19
|
import type { PluginContext } from '#/index.js';
|
|
15
20
|
|
|
16
21
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
-
|
|
22
|
+
// Detect whether we're running from source (src/plugins/) or dist (dist/).
|
|
23
|
+
// From src/plugins/: go up 2 levels to package root.
|
|
24
|
+
// From dist/: go up 1 level to package root.
|
|
25
|
+
// When Rollup bundles into dist/index.js, __dirname is dist/, not src/plugins/.
|
|
26
|
+
const PKG_ROOT = __dirname.endsWith('plugins')
|
|
27
|
+
? resolve(__dirname, '..', '..')
|
|
28
|
+
: resolve(__dirname, '..');
|
|
29
|
+
const SHIMS_DIR = resolve(PKG_ROOT, 'src', 'shims');
|
|
18
30
|
|
|
19
31
|
/**
|
|
20
32
|
* Virtual module IDs for server-only and client-only poison pills.
|
|
@@ -55,20 +67,6 @@ const CLIENT_SHIM_OVERRIDES: Record<string, string> = {
|
|
|
55
67
|
'next/navigation': resolve(SHIMS_DIR, 'navigation-client.ts'),
|
|
56
68
|
};
|
|
57
69
|
|
|
58
|
-
/**
|
|
59
|
-
* Map from @timber/app/* subpath imports to real source files.
|
|
60
|
-
*
|
|
61
|
-
* These resolve subpath imports like `@timber/app/server` to the
|
|
62
|
-
* real entry files in the package source.
|
|
63
|
-
*/
|
|
64
|
-
const TIMBER_SUBPATH_MAP: Record<string, string> = {
|
|
65
|
-
'@timber/app/server': resolve(__dirname, '..', 'server', 'index.ts'),
|
|
66
|
-
'@timber/app/client': resolve(__dirname, '..', 'client', 'index.ts'),
|
|
67
|
-
'@timber/app/cache': resolve(__dirname, '..', 'cache', 'index.ts'),
|
|
68
|
-
'@timber/app/search-params': resolve(__dirname, '..', 'search-params', 'index.ts'),
|
|
69
|
-
'@timber/app/routing': resolve(__dirname, '..', 'routing', 'index.ts'),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
70
|
/**
|
|
73
71
|
* Strip .js extension from an import specifier.
|
|
74
72
|
*
|
|
@@ -94,14 +92,20 @@ export function timberShims(_ctx: PluginContext): Plugin {
|
|
|
94
92
|
enforce: 'pre',
|
|
95
93
|
|
|
96
94
|
/**
|
|
97
|
-
* Resolve next/*
|
|
95
|
+
* Resolve next/* imports to shim files.
|
|
98
96
|
*
|
|
99
97
|
* Resolution order:
|
|
100
98
|
* 1. Check server-only / client-only poison pill packages
|
|
101
99
|
* 2. Strip .js extension from the import specifier
|
|
102
100
|
* 3. Check next/* shim map
|
|
103
|
-
* 4.
|
|
104
|
-
*
|
|
101
|
+
* 4. Return null (pass through) for everything else
|
|
102
|
+
*
|
|
103
|
+
* @timber-js/app/server is resolved to src/ so it shares the same module
|
|
104
|
+
* instance as framework internals (which import via #/). This ensures
|
|
105
|
+
* a single requestContextAls and _getRscFallback variable.
|
|
106
|
+
*
|
|
107
|
+
* @timber-js/app/client is NOT mapped here — it resolves to dist/ via
|
|
108
|
+
* package.json exports, where 'use client' is preserved on the entry.
|
|
105
109
|
*/
|
|
106
110
|
resolveId(id: string) {
|
|
107
111
|
// Poison pill packages — resolve to virtual modules handled by load()
|
|
@@ -121,9 +125,16 @@ export function timberShims(_ctx: PluginContext): Plugin {
|
|
|
121
125
|
return SHIM_MAP[cleanId];
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
// @timber-js/app/server → src/ in server environments so user code
|
|
129
|
+
// shares the same module instance as framework internals (single ALS).
|
|
130
|
+
// In the client environment, return a virtual empty module — server
|
|
131
|
+
// code must never be bundled into the browser.
|
|
132
|
+
if (cleanId === '@timber-js/app/server') {
|
|
133
|
+
const envName = (this as unknown as { environment?: { name?: string } }).environment?.name;
|
|
134
|
+
if (envName === 'client') {
|
|
135
|
+
return '\0timber:server-empty';
|
|
136
|
+
}
|
|
137
|
+
return resolve(PKG_ROOT, 'src', 'server', 'index.ts');
|
|
127
138
|
}
|
|
128
139
|
|
|
129
140
|
return null;
|
|
@@ -162,7 +173,22 @@ export function timberShims(_ctx: PluginContext): Plugin {
|
|
|
162
173
|
return 'export {};';
|
|
163
174
|
}
|
|
164
175
|
|
|
165
|
-
|
|
176
|
+
// Stub for @timber-js/app/server in client environment.
|
|
177
|
+
// Exports throw-on-call stubs so named imports resolve but
|
|
178
|
+
// calling them gives a clear error instead of crashing the bundle.
|
|
179
|
+
if (id === '\0timber:server-empty') {
|
|
180
|
+
return `
|
|
181
|
+
const stub = (name) => () => { throw new Error(name + "() is a server-only function and cannot be called in client code."); };
|
|
182
|
+
export const headers = stub("headers");
|
|
183
|
+
export const cookies = stub("cookies");
|
|
184
|
+
export const notFound = stub("notFound");
|
|
185
|
+
export const redirect = stub("redirect");
|
|
186
|
+
export const permanentRedirect = stub("permanentRedirect");
|
|
187
|
+
export const deny = stub("deny");
|
|
188
|
+
export const searchParams = stub("searchParams");
|
|
189
|
+
export const RedirectType = { push: "push", replace: "replace" };
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
166
192
|
},
|
|
167
193
|
};
|
|
168
194
|
}
|
package/src/routing/codegen.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface CodegenOptions {
|
|
|
46
46
|
/**
|
|
47
47
|
* Generate a TypeScript declaration file string from a scanned route tree.
|
|
48
48
|
*
|
|
49
|
-
* The output is a `declare module '@timber/app'` block containing the Routes
|
|
49
|
+
* The output is a `declare module '@timber-js/app'` block containing the Routes
|
|
50
50
|
* interface that maps every route path to its params and searchParams shape.
|
|
51
51
|
*/
|
|
52
52
|
export function generateRouteMap(tree: RouteTree, options: CodegenOptions = {}): string {
|
|
@@ -180,7 +180,7 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
180
180
|
// (removing exports like bindUseQueryStates that aren't listed here).
|
|
181
181
|
lines.push('export {};');
|
|
182
182
|
lines.push('');
|
|
183
|
-
lines.push("declare module '@timber/app' {");
|
|
183
|
+
lines.push("declare module '@timber-js/app' {");
|
|
184
184
|
lines.push(' interface Routes {');
|
|
185
185
|
|
|
186
186
|
for (const route of routes) {
|
|
@@ -197,12 +197,12 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
197
197
|
lines.push('}');
|
|
198
198
|
lines.push('');
|
|
199
199
|
|
|
200
|
-
// Generate @timber/app/server augmentation — typed searchParams() generic
|
|
200
|
+
// Generate @timber-js/app/server augmentation — typed searchParams() generic
|
|
201
201
|
const pageRoutes = routes.filter((r) => !r.isApiRoute);
|
|
202
202
|
|
|
203
203
|
if (pageRoutes.length > 0) {
|
|
204
|
-
lines.push("declare module '@timber/app/server' {");
|
|
205
|
-
lines.push(" import type { Routes } from '@timber/app'");
|
|
204
|
+
lines.push("declare module '@timber-js/app/server' {");
|
|
205
|
+
lines.push(" import type { Routes } from '@timber-js/app'");
|
|
206
206
|
lines.push(
|
|
207
207
|
" export function searchParams<R extends keyof Routes>(): Promise<Routes[R]['searchParams']>"
|
|
208
208
|
);
|
|
@@ -210,13 +210,13 @@ function formatDeclarationFile(routes: RouteEntry[], importBase?: string): strin
|
|
|
210
210
|
lines.push('');
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
// Generate overloads for @timber/app/client
|
|
213
|
+
// Generate overloads for @timber-js/app/client
|
|
214
214
|
const dynamicRoutes = routes.filter((r) => r.params.length > 0);
|
|
215
215
|
|
|
216
216
|
if (dynamicRoutes.length > 0 || pageRoutes.length > 0) {
|
|
217
|
-
lines.push("declare module '@timber/app/client' {");
|
|
217
|
+
lines.push("declare module '@timber-js/app/client' {");
|
|
218
218
|
lines.push(
|
|
219
|
-
" import type { SearchParamsDefinition, SetParams, QueryStatesOptions, SearchParamCodec } from '@timber/app/search-params'"
|
|
219
|
+
" import type { SearchParamsDefinition, SetParams, QueryStatesOptions, SearchParamCodec } from '@timber-js/app/search-params'"
|
|
220
220
|
);
|
|
221
221
|
lines.push('');
|
|
222
222
|
|
|
@@ -303,7 +303,7 @@ function formatSearchParamsType(route: RouteEntry, importBase?: string): string
|
|
|
303
303
|
// Use (typeof import('...'))[' default'] instead of import('...').default
|
|
304
304
|
// because with moduleResolution:"bundler", import('...').default is treated as
|
|
305
305
|
// a namespace member access which doesn't work for default exports.
|
|
306
|
-
return `(typeof import('${importPath}'))['default'] extends import('@timber/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
|
|
306
|
+
return `(typeof import('${importPath}'))['default'] extends import('@timber-js/app/search-params').SearchParamsDefinition<infer T> ? T : never`;
|
|
307
307
|
}
|
|
308
308
|
return '{}';
|
|
309
309
|
}
|
|
@@ -63,7 +63,7 @@ function validateSync<Output>(
|
|
|
63
63
|
* Serialize: uses `String()` for primitives, `null` for null/undefined.
|
|
64
64
|
*
|
|
65
65
|
* ```ts
|
|
66
|
-
* import { fromSchema } from '@timber/app/search-params'
|
|
66
|
+
* import { fromSchema } from '@timber-js/app/search-params'
|
|
67
67
|
* import { z } from 'zod/v4'
|
|
68
68
|
*
|
|
69
69
|
* const pageCodec = fromSchema(z.coerce.number().int().min(1).default(1))
|
|
@@ -109,7 +109,7 @@ export function fromSchema<T>(schema: StandardSchemaV1<T>): SearchParamCodec<T>
|
|
|
109
109
|
* and repeated query keys (`?tag=a&tag=b`).
|
|
110
110
|
*
|
|
111
111
|
* ```ts
|
|
112
|
-
* import { fromArraySchema } from '@timber/app/search-params'
|
|
112
|
+
* import { fromArraySchema } from '@timber-js/app/search-params'
|
|
113
113
|
* import { z } from 'zod/v4'
|
|
114
114
|
*
|
|
115
115
|
* const tagsCodec = fromArraySchema(z.array(z.string()).default([]))
|