@timber-js/app 0.2.0-alpha.230 → 0.2.0-alpha.232

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.
Files changed (98) hide show
  1. package/agent-skill.md +13 -0
  2. package/dist/_chunks/{actions-DHum77eH.js → actions-CYjRMpZI.js} +3 -2
  3. package/dist/_chunks/{actions-DHum77eH.js.map → actions-CYjRMpZI.js.map} +1 -1
  4. package/dist/_chunks/{cli-check-B-JZkpBD.js → cli-check-BAKOSTkg.js} +2 -2
  5. package/dist/_chunks/{cli-check-B-JZkpBD.js.map → cli-check-BAKOSTkg.js.map} +1 -1
  6. package/dist/_chunks/codec-registry-C8hOGmZo.js +13 -0
  7. package/dist/_chunks/codec-registry-C8hOGmZo.js.map +1 -0
  8. package/dist/_chunks/{codegen-B9oWkWGf.js → codegen-vaCyFyVN.js} +67 -17
  9. package/dist/_chunks/codegen-vaCyFyVN.js.map +1 -0
  10. package/dist/_chunks/{convention-lint-CrDKERHg.js → convention-lint-D54k6uUM.js} +2 -2
  11. package/dist/_chunks/{convention-lint-CrDKERHg.js.map → convention-lint-D54k6uUM.js.map} +1 -1
  12. package/dist/_chunks/href-BtspoNc9.js +164 -0
  13. package/dist/_chunks/href-BtspoNc9.js.map +1 -0
  14. package/dist/_chunks/href-validation-DNg-zV7u.js +102 -0
  15. package/dist/_chunks/href-validation-DNg-zV7u.js.map +1 -0
  16. package/dist/_chunks/merge-search-params-7o_5yX0L.js +111 -0
  17. package/dist/_chunks/merge-search-params-7o_5yX0L.js.map +1 -0
  18. package/dist/_chunks/{use-query-states-pkDV-jSg.js → use-query-states-D3MMl-KM.js} +12 -12
  19. package/dist/_chunks/use-query-states-D3MMl-KM.js.map +1 -0
  20. package/dist/cli.js +1 -1
  21. package/dist/client/index.d.ts +2 -1
  22. package/dist/client/index.d.ts.map +1 -1
  23. package/dist/client/index.js +4 -122
  24. package/dist/client/index.js.map +1 -1
  25. package/dist/client/internal.js +1 -1
  26. package/dist/client/link.d.ts +4 -25
  27. package/dist/client/link.d.ts.map +1 -1
  28. package/dist/client/nuqs-adapter.d.ts.map +1 -1
  29. package/dist/client/use-query-states.d.ts +1 -1
  30. package/dist/client/use-query-states.d.ts.map +1 -1
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +57 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/params/codec-registry.d.ts +21 -11
  36. package/dist/params/codec-registry.d.ts.map +1 -1
  37. package/dist/params/index.d.ts +0 -1
  38. package/dist/params/index.d.ts.map +1 -1
  39. package/dist/params/index.js +1 -2
  40. package/dist/params/index.js.map +1 -1
  41. package/dist/plugins/node-flight-builds.d.ts +38 -0
  42. package/dist/plugins/node-flight-builds.d.ts.map +1 -0
  43. package/dist/plugins/shims.d.ts.map +1 -1
  44. package/dist/routes/href.d.ts +124 -0
  45. package/dist/routes/href.d.ts.map +1 -0
  46. package/dist/routes/index.d.ts +4 -0
  47. package/dist/routes/index.d.ts.map +1 -0
  48. package/dist/routes/index.js +8 -0
  49. package/dist/routes/index.js.map +1 -0
  50. package/dist/routing/codegen.d.ts.map +1 -1
  51. package/dist/routing/index.js +1 -1
  52. package/dist/routing/link-codegen.d.ts +39 -8
  53. package/dist/routing/link-codegen.d.ts.map +1 -1
  54. package/dist/search-params/define.d.ts +37 -17
  55. package/dist/search-params/define.d.ts.map +1 -1
  56. package/dist/search-params/index.d.ts +1 -0
  57. package/dist/search-params/index.d.ts.map +1 -1
  58. package/dist/search-params/index.js +3 -2
  59. package/dist/search-params/index.js.map +1 -1
  60. package/dist/server/index.js +1 -1
  61. package/dist/server/internal.js +4 -6
  62. package/dist/server/internal.js.map +1 -1
  63. package/dist/server/param-coercion.d.ts +0 -7
  64. package/dist/server/param-coercion.d.ts.map +1 -1
  65. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  66. package/dist/shared/href.d.ts +88 -0
  67. package/dist/shared/href.d.ts.map +1 -0
  68. package/docs/api/31-api-client.mdx +1 -1
  69. package/docs/api/35-api-typescript.mdx +47 -15
  70. package/docs/learn/06-typed-params.mdx +33 -0
  71. package/docs/learn/07-typed-routes.mdx +75 -10
  72. package/package.json +6 -2
  73. package/src/client/browser-entry/index.ts +4 -4
  74. package/src/client/index.ts +3 -1
  75. package/src/client/link.tsx +5 -238
  76. package/src/client/nuqs-adapter.tsx +45 -2
  77. package/src/client/use-query-states.ts +27 -23
  78. package/src/index.ts +5 -0
  79. package/src/params/codec-registry.ts +24 -11
  80. package/src/params/index.ts +0 -1
  81. package/src/plugins/node-flight-builds.ts +94 -0
  82. package/src/plugins/shims.ts +10 -0
  83. package/src/routes/href.ts +171 -0
  84. package/src/routes/index.ts +10 -0
  85. package/src/routing/codegen.ts +8 -1
  86. package/src/routing/link-codegen.ts +103 -37
  87. package/src/search-params/define.ts +37 -17
  88. package/src/search-params/index.ts +10 -0
  89. package/src/server/param-coercion.ts +5 -23
  90. package/src/server/rsc-entry/index.ts +6 -3
  91. package/src/server/ssr-entry.ts +2 -2
  92. package/src/shared/href.ts +257 -0
  93. package/dist/_chunks/codec-registry-CPc6bjVl.js +0 -20
  94. package/dist/_chunks/codec-registry-CPc6bjVl.js.map +0 -1
  95. package/dist/_chunks/codegen-B9oWkWGf.js.map +0 -1
  96. package/dist/_chunks/href-validation-CEZy1V-k.js +0 -210
  97. package/dist/_chunks/href-validation-CEZy1V-k.js.map +0 -1
  98. package/dist/_chunks/use-query-states-pkDV-jSg.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 { a as mergePreservedSearchParams, o as resolveSegmentParams, r as validateExternalRedirectUrl, t as assertRelativeRedirectPath } from "./href-validation-CEZy1V-k.js";
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-DHum77eH.js.map
1273
+ //# sourceMappingURL=actions-CYjRMpZI.js.map