@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/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { i as resolveRenderTimeoutMs } from "./_chunks/render-timeout-MrrqD1wd.j
3
3
  import { t as writeFileAtomic } from "./_chunks/write-file-atomic-DW8m_Atv.js";
4
4
  import { d as collectInterceptionRewrites, l as getPrerenderExport, n as scanRoutes } from "./_chunks/scanner-BNQ4qnLX.js";
5
5
  import { b as swallow } from "./_chunks/logger-YtMSKfft.js";
6
- import { c as buildDirToRouteMap, n as formatConventionWarnings, o as flushCodegenWrites, r as lintConventions, s as writeRouteCodegen, t as checkAppDirExists } from "./_chunks/convention-lint-CrDKERHg.js";
6
+ import { c as buildDirToRouteMap, n as formatConventionWarnings, o as flushCodegenWrites, r as lintConventions, s as writeRouteCodegen, t as checkAppDirExists } from "./_chunks/convention-lint-D54k6uUM.js";
7
7
  import { a as contextAdapter, c as loadTimberConfigFile, d as resolveBuildDir, f as resolveClientJavascript, l as mergeFileConfig, m as createNoopTimer, o as createPluginContext, r as adapterConfig, u as resolveAppDir } from "./_chunks/plugin-context-FCkaNLUB.js";
8
8
  import { i as withBasePath, n as normalizeBasePath, t as isRelativeBase } from "./_chunks/base-path-DDIx0FXe.js";
9
9
  import { r as validateSchemaAgainstRoutes, t as collectLeafRoutes } from "./_chunks/walkers-D_QHR_nf.js";
@@ -1020,6 +1020,7 @@ var SUBPATH_SRC_MAP = {
1020
1020
  "codec": "codec.ts",
1021
1021
  "cookies": "cookies/index.ts",
1022
1022
  "params": "params/index.ts",
1023
+ "routes": "routes/index.ts",
1023
1024
  "search-params": "search-params/index.ts",
1024
1025
  "cache/stores/memory": "cache/stores/memory.ts",
1025
1026
  "cache/stores/redis": "cache/stores/redis.ts",
@@ -1150,6 +1151,7 @@ function timberShims(_ctx) {
1150
1151
  }
1151
1152
  if (cleanId === "#client-internal") return resolve(PKG_ROOT, "src", "client", "internal.ts");
1152
1153
  if (cleanId === "#routing") return resolve(PKG_ROOT, "src", "routing", "index.ts");
1154
+ if (cleanId === "@timber-js/app/routes") return resolve(PKG_ROOT, "src", "routes", "index.ts");
1153
1155
  if (cleanId === "@timber-js/app/server/internal") {
1154
1156
  if (envName(this) === "client") return "\0timber:server-empty";
1155
1157
  return resolve(PKG_ROOT, "src", "server", "internal.ts");
@@ -8132,6 +8134,58 @@ function timberClientInServerPackageDeps(rscEnvironmentName = "rsc") {
8132
8134
  }
8133
8135
  };
8134
8136
  }
8137
+ // src/plugins/node-flight-builds.ts
8138
+ var SERVER_ENVIRONMENTS = /* @__PURE__ */ new Set(["rsc", "ssr"]);
8139
+ var VENDOR = "@vitejs/plugin-rsc/vendor/react-server-dom";
8140
+ var VENDOR_EDGE_RE = /^@vitejs\/plugin-rsc\/vendor\/react-server-dom\/(server|client|static)\.edge$/;
8141
+ var REACT_DOM_SERVER_RE = /^react-dom\/(server|static)(?:\.edge)?$/;
8142
+ /**
8143
+ * A server renderer specifier → its Node build; null for anything else.
8144
+ *
8145
+ * react-dom's bare `react-dom/server` already resolves to the Node build on
8146
+ * Node, but as a raw file: once `react-dom/server.node` is pre-bundled it
8147
+ * would be a second instance, so it is redirected too. SSR only: in RSC,
8148
+ * plugin-rsc rejects `react-dom/server`, and that error must stay.
8149
+ */
8150
+ function nodeBuildOf(specifier, environmentName) {
8151
+ const vendor = VENDOR_EDGE_RE.exec(specifier);
8152
+ if (vendor) return `${VENDOR}/${vendor[1]}.node`;
8153
+ if (environmentName !== "ssr") return null;
8154
+ const reactDom = REACT_DOM_SERVER_RE.exec(specifier);
8155
+ if (reactDom) return `react-dom/${reactDom[1]}.node`;
8156
+ return null;
8157
+ }
8158
+ /**
8159
+ * The pre-bundle list with each edge build replaced by its Node build. A Node
8160
+ * build already listed is not listed twice.
8161
+ */
8162
+ function withNodeFlightBuilds(include, environmentName) {
8163
+ return [...new Set(include.map((entry) => nodeBuildOf(entry, environmentName) ?? entry))];
8164
+ }
8165
+ function timberNodeFlightBuilds() {
8166
+ return {
8167
+ name: "timber-node-flight-builds",
8168
+ apply: "serve",
8169
+ enforce: "pre",
8170
+ configEnvironment: {
8171
+ order: "post",
8172
+ handler(name, config) {
8173
+ if (!SERVER_ENVIRONMENTS.has(name)) return;
8174
+ const deps = config.optimizeDeps;
8175
+ if (deps?.include) deps.include = withNodeFlightBuilds(deps.include, name);
8176
+ }
8177
+ },
8178
+ resolveId(source, importer, options) {
8179
+ if (!SERVER_ENVIRONMENTS.has(this.environment.name)) return;
8180
+ const nodeBuild = nodeBuildOf(source, this.environment.name);
8181
+ if (!nodeBuild) return;
8182
+ return this.resolve(nodeBuild, importer, {
8183
+ ...options,
8184
+ skipSelf: true
8185
+ });
8186
+ }
8187
+ };
8188
+ }
8135
8189
  // src/plugins/callsite-jsx.ts
8136
8190
  /**
8137
8191
  * Try to extract a static JSON-safe value from an AST expression node.
@@ -10663,6 +10717,7 @@ function timber(config) {
10663
10717
  "@timber-js/app/cache",
10664
10718
  "@timber-js/app/search-params",
10665
10719
  "@timber-js/app/params",
10720
+ "@timber-js/app/routes",
10666
10721
  "@timber-js/app/codec"
10667
10722
  ];
10668
10723
  if (command === "build") return {
@@ -10724,6 +10779,7 @@ function timber(config) {
10724
10779
  return [
10725
10780
  rootSync,
10726
10781
  timberReactResolve(),
10782
+ timberNodeFlightBuilds(),
10727
10783
  timberReactProd(),
10728
10784
  ...patchReactCompilerForProdJsx(react({ compiler: effectiveReactCompiler || false })),
10729
10785
  vitePluginRsc(createRscOptions(ctx, encryptionKeyExpr)),