@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.
Files changed (103) hide show
  1. package/dist/_chunks/{interception-DIaZN1bF.js → interception-c-a3uODY.js} +8 -8
  2. package/dist/_chunks/interception-c-a3uODY.js.map +1 -0
  3. package/dist/_chunks/{registry-DUIpYD_x.js → registry-BfPM41ri.js} +1 -1
  4. package/dist/_chunks/{registry-DUIpYD_x.js.map → registry-BfPM41ri.js.map} +1 -1
  5. package/dist/_chunks/{request-context-D6XHINkR.js → request-context-BzES06i1.js} +2 -1
  6. package/dist/_chunks/request-context-BzES06i1.js.map +1 -0
  7. package/dist/_chunks/{use-cookie-8ZlA0rr3.js → use-cookie-HcvNlW4L.js} +1 -1
  8. package/dist/_chunks/{use-cookie-8ZlA0rr3.js.map → use-cookie-HcvNlW4L.js.map} +1 -1
  9. package/dist/adapters/cloudflare.d.ts +2 -2
  10. package/dist/adapters/cloudflare.js +4 -4
  11. package/dist/adapters/cloudflare.js.map +1 -1
  12. package/dist/adapters/nitro.d.ts +1 -1
  13. package/dist/adapters/nitro.js +4 -4
  14. package/dist/adapters/nitro.js.map +1 -1
  15. package/dist/cache/index.js.map +1 -1
  16. package/dist/{_chunks/error-boundary-dj-WO5uq.js → client/error-boundary.js} +4 -2
  17. package/dist/client/error-boundary.js.map +1 -0
  18. package/dist/client/form.d.ts +1 -1
  19. package/dist/client/index.js +10 -9
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/client/link.d.ts.map +1 -1
  22. package/dist/client/slot-error-fallback.d.ts +13 -0
  23. package/dist/client/slot-error-fallback.d.ts.map +1 -0
  24. package/dist/client/use-link-status.d.ts +1 -1
  25. package/dist/client/use-navigation-pending.d.ts +1 -1
  26. package/dist/content/index.d.ts +1 -1
  27. package/dist/cookies/define-cookie.d.ts +2 -2
  28. package/dist/cookies/index.d.ts +1 -1
  29. package/dist/cookies/index.d.ts.map +1 -1
  30. package/dist/cookies/index.js +4 -4
  31. package/dist/cookies/index.js.map +1 -1
  32. package/dist/index.js +23 -22
  33. package/dist/index.js.map +1 -1
  34. package/dist/plugins/dev-logs.d.ts +1 -1
  35. package/dist/plugins/dynamic-transform.d.ts +1 -1
  36. package/dist/plugins/shims.d.ts +5 -0
  37. package/dist/plugins/shims.d.ts.map +1 -1
  38. package/dist/routing/codegen.d.ts +1 -1
  39. package/dist/routing/index.js +1 -1
  40. package/dist/search-params/codecs.d.ts +2 -2
  41. package/dist/search-params/create.d.ts +1 -1
  42. package/dist/search-params/index.js +5 -5
  43. package/dist/search-params/index.js.map +1 -1
  44. package/dist/server/action-client.d.ts +1 -1
  45. package/dist/server/dev-fetch-instrumentation.d.ts +22 -0
  46. package/dist/server/dev-fetch-instrumentation.d.ts.map +1 -0
  47. package/dist/server/dev-logger.d.ts.map +1 -1
  48. package/dist/server/form-flash.d.ts +1 -1
  49. package/dist/server/index.js +4 -4
  50. package/dist/server/index.js.map +1 -1
  51. package/dist/server/primitives.d.ts +15 -0
  52. package/dist/server/primitives.d.ts.map +1 -1
  53. package/dist/server/request-context.d.ts +32 -0
  54. package/dist/server/request-context.d.ts.map +1 -1
  55. package/dist/server/route-element-builder.d.ts.map +1 -1
  56. package/dist/server/rsc-entry/index.d.ts.map +1 -1
  57. package/dist/server/slot-resolver.d.ts.map +1 -1
  58. package/dist/server/ssr-entry.d.ts.map +1 -1
  59. package/dist/shims/headers.d.ts +5 -7
  60. package/dist/shims/headers.d.ts.map +1 -1
  61. package/dist/shims/link.d.ts +1 -1
  62. package/dist/shims/link.d.ts.map +1 -1
  63. package/dist/shims/navigation.d.ts +5 -15
  64. package/dist/shims/navigation.d.ts.map +1 -1
  65. package/package.json +1 -1
  66. package/src/adapters/cloudflare.ts +4 -4
  67. package/src/adapters/nitro.ts +4 -4
  68. package/src/cache/index.ts +1 -1
  69. package/src/client/form.tsx +1 -1
  70. package/src/client/index.ts +1 -1
  71. package/src/client/link.tsx +2 -0
  72. package/src/client/slot-error-fallback.tsx +16 -0
  73. package/src/client/use-link-status.ts +1 -1
  74. package/src/client/use-navigation-pending.ts +1 -1
  75. package/src/content/index.ts +1 -1
  76. package/src/cookies/define-cookie.ts +2 -2
  77. package/src/cookies/index.ts +2 -6
  78. package/src/plugins/cache-transform.ts +1 -1
  79. package/src/plugins/dev-logs.ts +2 -2
  80. package/src/plugins/dynamic-transform.ts +2 -2
  81. package/src/plugins/shims.ts +48 -22
  82. package/src/routing/codegen.ts +9 -9
  83. package/src/search-params/codecs.ts +2 -2
  84. package/src/search-params/create.ts +3 -3
  85. package/src/search-params/index.ts +1 -1
  86. package/src/server/action-client.ts +1 -1
  87. package/src/server/asset-headers.ts +1 -1
  88. package/src/server/dev-fetch-instrumentation.ts +96 -0
  89. package/src/server/dev-logger.ts +49 -0
  90. package/src/server/form-flash.ts +1 -1
  91. package/src/server/index.ts +1 -1
  92. package/src/server/primitives.ts +24 -1
  93. package/src/server/request-context.ts +7 -1
  94. package/src/server/route-element-builder.ts +2 -5
  95. package/src/server/rsc-entry/index.ts +33 -1
  96. package/src/server/slot-resolver.ts +20 -1
  97. package/src/server/ssr-entry.ts +21 -5
  98. package/src/shims/headers.ts +5 -7
  99. package/src/shims/link.ts +3 -1
  100. package/src/shims/navigation.ts +7 -17
  101. package/dist/_chunks/error-boundary-dj-WO5uq.js.map +0 -1
  102. package/dist/_chunks/interception-DIaZN1bF.js.map +0 -1
  103. package/dist/_chunks/request-context-D6XHINkR.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as setViteServer, t as formatSize } from "./_chunks/format-DNt20Kt8.js";
2
- import { i as scanRoutes, n as generateRouteMap, t as collectInterceptionRewrites } from "./_chunks/interception-DIaZN1bF.js";
2
+ import { i as scanRoutes, n as generateRouteMap, t as collectInterceptionRewrites } from "./_chunks/interception-c-a3uODY.js";
3
3
  import { existsSync, readFileSync } from "node:fs";
4
4
  import { dirname, extname, join, resolve } from "node:path";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -11273,7 +11273,7 @@ function transformUseCache(code, fileId) {
11273
11273
  result = result.slice(0, fn.start) + replacement + result.slice(fn.end);
11274
11274
  needsImport = true;
11275
11275
  }
11276
- if (needsImport) result = `import { registerCachedFunction } from '@timber/app/cache';\n` + result;
11276
+ if (needsImport) result = `import { registerCachedFunction } from '@timber-js/app/cache';\n` + result;
11277
11277
  return {
11278
11278
  code: result,
11279
11279
  map: null,
@@ -12287,7 +12287,8 @@ function generateManifestModule(tree) {
12287
12287
  //#endregion
12288
12288
  //#region src/plugins/shims.ts
12289
12289
  var __dirname = dirname(fileURLToPath(import.meta.url));
12290
- var SHIMS_DIR = resolve(__dirname, "..", "shims");
12290
+ var PKG_ROOT = __dirname.endsWith("plugins") ? resolve(__dirname, "..", "..") : resolve(__dirname, "..");
12291
+ var SHIMS_DIR = resolve(PKG_ROOT, "src", "shims");
12291
12292
  /**
12292
12293
  * Virtual module IDs for server-only and client-only poison pills.
12293
12294
  *
@@ -12321,19 +12322,6 @@ var SHIM_MAP = {
12321
12322
  */
12322
12323
  var CLIENT_SHIM_OVERRIDES = { "next/navigation": resolve(SHIMS_DIR, "navigation-client.ts") };
12323
12324
  /**
12324
- * Map from @timber/app/* subpath imports to real source files.
12325
- *
12326
- * These resolve subpath imports like `@timber/app/server` to the
12327
- * real entry files in the package source.
12328
- */
12329
- var TIMBER_SUBPATH_MAP = {
12330
- "@timber/app/server": resolve(__dirname, "..", "server", "index.ts"),
12331
- "@timber/app/client": resolve(__dirname, "..", "client", "index.ts"),
12332
- "@timber/app/cache": resolve(__dirname, "..", "cache", "index.ts"),
12333
- "@timber/app/search-params": resolve(__dirname, "..", "search-params", "index.ts"),
12334
- "@timber/app/routing": resolve(__dirname, "..", "routing", "index.ts")
12335
- };
12336
- /**
12337
12325
  * Strip .js extension from an import specifier.
12338
12326
  *
12339
12327
  * Libraries like nuqs import `next/navigation.js` with an explicit
@@ -12359,7 +12347,10 @@ function timberShims(_ctx) {
12359
12347
  if (this.environment?.name === "client" && cleanId in CLIENT_SHIM_OVERRIDES) return CLIENT_SHIM_OVERRIDES[cleanId];
12360
12348
  return SHIM_MAP[cleanId];
12361
12349
  }
12362
- if (cleanId in TIMBER_SUBPATH_MAP) return TIMBER_SUBPATH_MAP[cleanId];
12350
+ if (cleanId === "@timber-js/app/server") {
12351
+ if (this.environment?.name === "client") return "\0timber:server-empty";
12352
+ return resolve(PKG_ROOT, "src", "server", "index.ts");
12353
+ }
12363
12354
  return null;
12364
12355
  },
12365
12356
  load(id) {
@@ -12378,7 +12369,17 @@ function timberShims(_ctx) {
12378
12369
  );`;
12379
12370
  return "export {};";
12380
12371
  }
12381
- return null;
12372
+ if (id === "\0timber:server-empty") return `
12373
+ const stub = (name) => () => { throw new Error(name + "() is a server-only function and cannot be called in client code."); };
12374
+ export const headers = stub("headers");
12375
+ export const cookies = stub("cookies");
12376
+ export const notFound = stub("notFound");
12377
+ export const redirect = stub("redirect");
12378
+ export const permanentRedirect = stub("permanentRedirect");
12379
+ export const deny = stub("deny");
12380
+ export const searchParams = stub("searchParams");
12381
+ export const RedirectType = { push: "push", replace: "replace" };
12382
+ `;
12382
12383
  }
12383
12384
  };
12384
12385
  }
@@ -13543,7 +13544,7 @@ function containsUseDynamic(code) {
13543
13544
  *
13544
13545
  * Output:
13545
13546
  * ```tsx
13546
- * import { markDynamic as __markDynamic } from '@timber/app/runtime';
13547
+ * import { markDynamic as __markDynamic } from '@timber-js/app/runtime';
13547
13548
  * export default async function AddToCartButton({ productId }) {
13548
13549
  * __markDynamic();
13549
13550
  * const user = await getUser()
@@ -13564,7 +13565,7 @@ function transformUseDynamic(code) {
13564
13565
  const cleanBody = fn.bodyContent.replace(/['"]use dynamic['"];?/, "__markDynamic();");
13565
13566
  result = result.slice(0, fn.bodyStart) + cleanBody + result.slice(fn.bodyEnd);
13566
13567
  }
13567
- result = `import { markDynamic as __markDynamic } from '@timber/app/runtime';\n` + result;
13568
+ result = `import { markDynamic as __markDynamic } from '@timber-js/app/runtime';\n` + result;
13568
13569
  return {
13569
13570
  code: result,
13570
13571
  map: null
@@ -13962,7 +13963,7 @@ function extractCallerLocation(projectRoot) {
13962
13963
  * (render errors, action errors, route handler errors, etc.).
13963
13964
  *
13964
13965
  * Handles both monorepo paths (timber-app/src/plugins/) and installed
13965
- * package paths (@timber/app/dist/plugins/).
13966
+ * package paths (@timber-js/app/dist/plugins/).
13966
13967
  */
13967
13968
  function isFrameworkInternalCaller() {
13968
13969
  const stack = (/* @__PURE__ */ new Error()).stack;
@@ -13972,7 +13973,7 @@ function isFrameworkInternalCaller() {
13972
13973
  const line = lines[i].trim();
13973
13974
  if (line.includes("dev-logs")) continue;
13974
13975
  if (line.includes("node:")) continue;
13975
- if (!(line.includes("timber-app/") || line.includes("@timber/app/"))) return false;
13976
+ if (!(line.includes("timber-app/") || line.includes("@timber-js/app/"))) return false;
13976
13977
  return line.includes("/plugins/") || line.includes("/adapters/");
13977
13978
  }
13978
13979
  return false;