@timber-js/app 0.2.0-alpha.230 → 0.2.0-alpha.231
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/agent-skill.md +13 -0
- package/dist/_chunks/{actions-DHum77eH.js → actions-CYjRMpZI.js} +3 -2
- package/dist/_chunks/{actions-DHum77eH.js.map → actions-CYjRMpZI.js.map} +1 -1
- package/dist/_chunks/{cli-check-B-JZkpBD.js → cli-check-BAKOSTkg.js} +2 -2
- package/dist/_chunks/{cli-check-B-JZkpBD.js.map → cli-check-BAKOSTkg.js.map} +1 -1
- package/dist/_chunks/codec-registry-C8hOGmZo.js +13 -0
- package/dist/_chunks/codec-registry-C8hOGmZo.js.map +1 -0
- package/dist/_chunks/{codegen-B9oWkWGf.js → codegen-vaCyFyVN.js} +67 -17
- package/dist/_chunks/codegen-vaCyFyVN.js.map +1 -0
- package/dist/_chunks/{convention-lint-CrDKERHg.js → convention-lint-D54k6uUM.js} +2 -2
- package/dist/_chunks/{convention-lint-CrDKERHg.js.map → convention-lint-D54k6uUM.js.map} +1 -1
- package/dist/_chunks/href-BtspoNc9.js +164 -0
- package/dist/_chunks/href-BtspoNc9.js.map +1 -0
- package/dist/_chunks/href-validation-DNg-zV7u.js +102 -0
- package/dist/_chunks/href-validation-DNg-zV7u.js.map +1 -0
- package/dist/_chunks/merge-search-params-7o_5yX0L.js +111 -0
- package/dist/_chunks/merge-search-params-7o_5yX0L.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -121
- package/dist/client/index.js.map +1 -1
- package/dist/client/link.d.ts +4 -25
- package/dist/client/link.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/params/codec-registry.d.ts +21 -11
- package/dist/params/codec-registry.d.ts.map +1 -1
- package/dist/params/index.d.ts +0 -1
- package/dist/params/index.d.ts.map +1 -1
- package/dist/params/index.js +1 -2
- package/dist/params/index.js.map +1 -1
- package/dist/plugins/shims.d.ts.map +1 -1
- package/dist/routes/href.d.ts +124 -0
- package/dist/routes/href.d.ts.map +1 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +8 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routing/codegen.d.ts.map +1 -1
- package/dist/routing/index.js +1 -1
- package/dist/routing/link-codegen.d.ts +39 -8
- package/dist/routing/link-codegen.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/internal.js +4 -6
- package/dist/server/internal.js.map +1 -1
- package/dist/server/param-coercion.d.ts +0 -7
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/shared/href.d.ts +88 -0
- package/dist/shared/href.d.ts.map +1 -0
- package/docs/api/31-api-client.mdx +1 -1
- package/docs/api/35-api-typescript.mdx +47 -15
- package/docs/learn/07-typed-routes.mdx +75 -10
- package/package.json +5 -1
- package/src/client/browser-entry/index.ts +4 -4
- package/src/client/index.ts +3 -1
- package/src/client/link.tsx +5 -238
- package/src/index.ts +3 -0
- package/src/params/codec-registry.ts +24 -11
- package/src/params/index.ts +0 -1
- package/src/plugins/shims.ts +10 -0
- package/src/routes/href.ts +171 -0
- package/src/routes/index.ts +10 -0
- package/src/routing/codegen.ts +8 -1
- package/src/routing/link-codegen.ts +103 -37
- package/src/server/param-coercion.ts +5 -23
- package/src/server/rsc-entry/index.ts +6 -3
- package/src/server/ssr-entry.ts +2 -2
- package/src/shared/href.ts +257 -0
- package/dist/_chunks/codec-registry-CPc6bjVl.js +0 -20
- package/dist/_chunks/codec-registry-CPc6bjVl.js.map +0 -1
- package/dist/_chunks/codegen-B9oWkWGf.js.map +0 -1
- package/dist/_chunks/href-validation-CEZy1V-k.js +0 -210
- package/dist/_chunks/href-validation-CEZy1V-k.js.map +0 -1
package/agent-skill.md
CHANGED
|
@@ -67,6 +67,9 @@ import { codec } from '@timber-js/app/codec';
|
|
|
67
67
|
import { defineSearchParams } from '@timber-js/app/search-params';
|
|
68
68
|
import { defineCookie } from '@timber-js/app/cookies';
|
|
69
69
|
|
|
70
|
+
// Typed URL strings (server and client)
|
|
71
|
+
import { href } from '@timber-js/app/routes';
|
|
72
|
+
|
|
70
73
|
// Caching
|
|
71
74
|
import { cache } from '@timber-js/app/cache';
|
|
72
75
|
|
|
@@ -307,6 +310,15 @@ import { Link } from '@timber-js/app/client';
|
|
|
307
310
|
<Link href="/products/123" prefetch>Product</Link>
|
|
308
311
|
```
|
|
309
312
|
|
|
313
|
+
Build every internal URL string with `href()` from `@timber-js/app/routes`. It works in server components, client components, middleware and actions. It checks the pattern and params against the route map and serializes through the schema codecs:
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
href('/products/[id]', { id });
|
|
317
|
+
href('/artists/[artistSlug]', { artistSlug }, artistParams.buildSearchParams({ sort }));
|
|
318
|
+
router.push(href('/products/[id]', { id }));
|
|
319
|
+
redirect(href('/products/[id]', { id }));
|
|
320
|
+
```
|
|
321
|
+
|
|
310
322
|
```tsx
|
|
311
323
|
const router = useRouter();
|
|
312
324
|
router.push('/dashboard');
|
|
@@ -344,6 +356,7 @@ Return a primitive from the selector: a navigation re-renders the component only
|
|
|
344
356
|
8. **`useActionState` comes from `react`** — timber has no wrapper. Read errors with `readFormErrors(state)` from `@timber-js/app/client`: `errors.field('sets.0.name')` (typed from the schema), `errors.form`, `errors.server`. JS-only fields (chip lists, comboboxes) use `useFieldState`.
|
|
345
357
|
9. **Middleware has one arg** — `middleware(ctx: MiddlewareContext)`, not `(req, res)`.
|
|
346
358
|
10. **Don't use `next/` imports** — use `@timber-js/app/server`, `@timber-js/app/client`, etc.
|
|
359
|
+
11. **No URL helper modules, no hand-built query strings** — don't write `lib/urls.ts` helpers or template-string paths like `` `/artists/${slug}?sort=x` ``. Use `href(pattern, params, def.buildSearchParams(…))`: a renamed route then fails the build, and the query goes through its codecs and aliases.
|
|
347
360
|
|
|
348
361
|
## Commands
|
|
349
362
|
|
|
@@ -3,9 +3,10 @@ import { a as revalidationAls, i as requestContextAls, r as reactCacheScopeAls }
|
|
|
3
3
|
import { I as isDenySignal, L as isRedirectSignal, M as withSpan, N as DENY_BRAND, P as REDIRECT_BRAND, S as isDevMode, x as isDebug } from "./logger-YtMSKfft.js";
|
|
4
4
|
import { n as _setGetSegmentParamsFn, t as _setGetSearchParamsFn } from "./als-slots-kbQrHTzm.js";
|
|
5
5
|
import { r as appVisibleSearch } from "./rsc-cache-key-D0cb0Gmc.js";
|
|
6
|
-
import {
|
|
6
|
+
import { n as resolveSegmentParams, t as mergePreservedSearchParams } from "./merge-search-params-7o_5yX0L.js";
|
|
7
7
|
import { a as assertValidCookieOptions, i as assertValidCookieName, n as parseSetCookie$1, o as assertValidCookieValue, r as stringifySetCookie, t as parseCookie } from "./dist-C1Rjlo6s.js";
|
|
8
8
|
import { _ as getWaitUntil, t as cache } from "./cache-api-BZJNt01a.js";
|
|
9
|
+
import { r as validateExternalRedirectUrl, t as assertRelativeRedirectPath } from "./href-validation-DNg-zV7u.js";
|
|
9
10
|
// src/server/react-cache-scope.ts
|
|
10
11
|
/**
|
|
11
12
|
* React.cache scopes — opening, resuming, and leaving the per-request
|
|
@@ -1269,4 +1270,4 @@ function revalidationPathMatches(revalidatedPath, requestPathname, requestSearch
|
|
|
1269
1270
|
}
|
|
1270
1271
|
export { setMatchedSegmentPath as C, runOutsideReactCacheScope as E, runWithSegmentParams as S, setSegmentParams as T, getHeaders as _, parseFormData as a, markResponseFlushed as b, deny as c, waitUntil as d, getCookie as f, getHeader as g, applyRequestHeaderOverlay as h, coerce as i, redirect as l, getSetCookieHeaders as m, revalidatePath as n, DenySignal as o, getCookieJar as p, revalidateTag as r, RedirectSignal as s, executeAction as t, redirectExternal as u, getSearchParams as v, setMutableCookieContext as w, runWithRequestContext as x, getSegmentParams as y };
|
|
1271
1272
|
|
|
1272
|
-
//# sourceMappingURL=actions-
|
|
1273
|
+
//# sourceMappingURL=actions-CYjRMpZI.js.map
|