@rebask/core 0.2.1 → 0.4.0

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 (210) hide show
  1. package/dist/components/head.d.ts +2 -11
  2. package/dist/components/head.d.ts.map +1 -1
  3. package/dist/components/head.js +12 -24
  4. package/dist/components/image.d.ts +16 -3
  5. package/dist/components/image.d.ts.map +1 -1
  6. package/dist/components/image.js +50 -68
  7. package/dist/components/link.d.ts.map +1 -1
  8. package/dist/components/link.js +6 -2
  9. package/dist/entry.browser.js +2 -2
  10. package/dist/entry.ssr.d.ts.map +1 -1
  11. package/dist/entry.ssr.js +12 -7
  12. package/dist/handlers/rsc/background-render.js +2 -2
  13. package/dist/handlers/rsc/render-request.js +2 -2
  14. package/dist/handlers/rsc/render-to-response.js +2 -2
  15. package/dist/handlers/rsc/state.d.ts.map +1 -1
  16. package/dist/handlers/rsc/state.js +11 -5
  17. package/dist/lib/client-route-prediction.d.ts +1 -1
  18. package/dist/lib/client-route-prediction.d.ts.map +1 -1
  19. package/dist/lib/client-route-prediction.js +2 -7
  20. package/dist/lib/head/head-manager.d.ts +9 -0
  21. package/dist/lib/head/head-manager.d.ts.map +1 -0
  22. package/dist/lib/head/head-manager.js +98 -0
  23. package/dist/lib/head/head-script.js +8 -13
  24. package/dist/lib/image-optimization/fetch-remote-image.d.ts +17 -0
  25. package/dist/lib/image-optimization/fetch-remote-image.d.ts.map +1 -0
  26. package/dist/lib/image-optimization/fetch-remote-image.js +157 -0
  27. package/dist/lib/image-optimization/get-img-props.d.ts +3 -5
  28. package/dist/lib/image-optimization/get-img-props.d.ts.map +1 -1
  29. package/dist/lib/image-optimization/get-img-props.js +66 -40
  30. package/dist/lib/image-optimization/handler.d.ts +0 -3
  31. package/dist/lib/image-optimization/handler.d.ts.map +1 -1
  32. package/dist/lib/image-optimization/handler.js +339 -124
  33. package/dist/lib/image-optimization/image-config.d.ts +31 -4
  34. package/dist/lib/image-optimization/image-config.d.ts.map +1 -1
  35. package/dist/lib/image-optimization/image-config.js +6 -0
  36. package/dist/lib/image-optimization/image-error.d.ts +8 -0
  37. package/dist/lib/image-optimization/image-error.d.ts.map +1 -0
  38. package/dist/lib/image-optimization/image-error.js +10 -0
  39. package/dist/lib/image-optimization/image-plugin.d.ts +2 -0
  40. package/dist/lib/image-optimization/image-plugin.d.ts.map +1 -1
  41. package/dist/lib/image-optimization/image-plugin.js +36 -16
  42. package/dist/lib/image-optimization/is-private-ip.d.ts +2 -0
  43. package/dist/lib/image-optimization/is-private-ip.d.ts.map +1 -0
  44. package/dist/lib/image-optimization/is-private-ip.js +43 -0
  45. package/dist/lib/image-optimization/match-patterns.d.ts +4 -0
  46. package/dist/lib/image-optimization/match-patterns.d.ts.map +1 -0
  47. package/dist/lib/image-optimization/match-patterns.js +39 -0
  48. package/dist/lib/image-optimization/read-body.d.ts +2 -0
  49. package/dist/lib/image-optimization/read-body.d.ts.map +1 -0
  50. package/dist/lib/image-optimization/read-body.js +27 -0
  51. package/dist/lib/image-optimization/static-image-loader.d.ts +2 -0
  52. package/dist/lib/image-optimization/static-image-loader.d.ts.map +1 -0
  53. package/dist/lib/image-optimization/static-image-loader.js +60 -0
  54. package/dist/lib/plugin-names.d.ts +3 -0
  55. package/dist/lib/plugin-names.d.ts.map +1 -0
  56. package/dist/lib/plugin-names.js +2 -0
  57. package/dist/lib/proxy/build-proxy.d.ts +1 -1
  58. package/dist/lib/proxy/build-proxy.d.ts.map +1 -1
  59. package/dist/lib/proxy/build-proxy.js +4 -11
  60. package/dist/lib/proxy/pattern.d.ts +7 -0
  61. package/dist/lib/proxy/pattern.d.ts.map +1 -0
  62. package/dist/lib/proxy/pattern.js +18 -0
  63. package/dist/lib/proxy/types.d.ts +3 -1
  64. package/dist/lib/proxy/types.d.ts.map +1 -1
  65. package/dist/lib/route-prediction.d.ts.map +1 -1
  66. package/dist/lib/rsc-request.d.ts.map +1 -1
  67. package/dist/lib/rsc-request.js +6 -4
  68. package/dist/lib/server-router/build-entries.d.ts +76 -0
  69. package/dist/lib/server-router/build-entries.d.ts.map +1 -0
  70. package/dist/lib/server-router/build-entries.js +74 -0
  71. package/dist/lib/server-router/get-router.d.ts.map +1 -1
  72. package/dist/lib/server-router/get-router.js +55 -105
  73. package/dist/lib/server-router/rou3.d.ts +20 -0
  74. package/dist/lib/server-router/rou3.d.ts.map +1 -0
  75. package/dist/lib/server-router/rou3.js +55 -0
  76. package/dist/lib/server-router/route-entries.d.ts +16 -0
  77. package/dist/lib/server-router/route-entries.d.ts.map +1 -0
  78. package/dist/lib/server-router/route-entries.js +67 -0
  79. package/dist/lib/server-router/types.d.ts +24 -33
  80. package/dist/lib/server-router/types.d.ts.map +1 -1
  81. package/dist/lib/server-router/types.js +1 -6
  82. package/dist/lib/types.d.ts +2 -2
  83. package/dist/lib/types.d.ts.map +1 -1
  84. package/dist/plugins/prerender.d.ts +3 -4
  85. package/dist/plugins/prerender.d.ts.map +1 -1
  86. package/dist/plugins/prerender.js +31 -0
  87. package/dist/plugins/proxy.d.ts.map +1 -1
  88. package/dist/plugins/proxy.js +7 -1
  89. package/dist/plugins/router/rou3-compiled.d.ts +9 -0
  90. package/dist/plugins/router/rou3-compiled.d.ts.map +1 -0
  91. package/dist/plugins/router/rou3-compiled.js +14 -0
  92. package/dist/plugins/router/rou3-router.d.ts +3 -0
  93. package/dist/plugins/router/rou3-router.d.ts.map +1 -0
  94. package/dist/plugins/router/rou3-router.js +16 -0
  95. package/dist/plugins/router/router-plugin.d.ts +6 -16
  96. package/dist/plugins/router/router-plugin.d.ts.map +1 -1
  97. package/dist/plugins/router/router-plugin.js +43 -22
  98. package/dist/proxy.d.ts +1 -0
  99. package/dist/proxy.d.ts.map +1 -1
  100. package/dist/proxy.js +1 -0
  101. package/dist/request-context.d.ts +0 -2
  102. package/dist/request-context.d.ts.map +1 -1
  103. package/dist/request-context.js +0 -4
  104. package/dist/router.d.ts +1 -1
  105. package/dist/router.d.ts.map +1 -1
  106. package/dist/router.js +4 -4
  107. package/dist/server-router.d.ts +3 -3
  108. package/dist/server-router.d.ts.map +1 -1
  109. package/dist/server-router.js +2 -2
  110. package/dist/vite.d.ts +8 -3
  111. package/dist/vite.d.ts.map +1 -1
  112. package/dist/vite.js +72 -33
  113. package/package.json +6 -4
  114. package/dist/components/error-boundary-client.d.ts +0 -49
  115. package/dist/components/error-boundary-client.d.ts.map +0 -1
  116. package/dist/components/error-boundary-client.js +0 -71
  117. package/dist/components/error-boundary.browser.d.ts +0 -8
  118. package/dist/components/error-boundary.browser.d.ts.map +0 -1
  119. package/dist/components/error-boundary.browser.js +0 -6
  120. package/dist/components/error.d.ts +0 -2
  121. package/dist/components/error.d.ts.map +0 -1
  122. package/dist/components/error.js +0 -5
  123. package/dist/components/not-found-activator.d.ts +0 -11
  124. package/dist/components/not-found-activator.d.ts.map +0 -1
  125. package/dist/components/not-found-activator.js +0 -26
  126. package/dist/components/not-found-boundary-client.d.ts +0 -3
  127. package/dist/components/not-found-boundary-client.d.ts.map +0 -1
  128. package/dist/components/not-found-boundary-client.js +0 -20
  129. package/dist/components/not-found-boundary.browser.d.ts +0 -8
  130. package/dist/components/not-found-boundary.browser.d.ts.map +0 -1
  131. package/dist/components/not-found-boundary.browser.js +0 -4
  132. package/dist/components/not-found-boundary.d.ts +0 -8
  133. package/dist/components/not-found-boundary.d.ts.map +0 -1
  134. package/dist/components/not-found-boundary.js +0 -9
  135. package/dist/components/not-found-thrower.d.ts +0 -2
  136. package/dist/components/not-found-thrower.d.ts.map +0 -1
  137. package/dist/components/not-found-thrower.js +0 -7
  138. package/dist/components/not-found.d.ts +0 -2
  139. package/dist/components/not-found.d.ts.map +0 -1
  140. package/dist/components/not-found.js +0 -5
  141. package/dist/components/status-page.d.ts +0 -6
  142. package/dist/components/status-page.d.ts.map +0 -1
  143. package/dist/components/status-page.js +0 -61
  144. package/dist/handler.d.ts +0 -12
  145. package/dist/handler.d.ts.map +0 -1
  146. package/dist/handler.js +0 -21
  147. package/dist/handlers/rsc/constants.d.ts +0 -3
  148. package/dist/handlers/rsc/constants.d.ts.map +0 -1
  149. package/dist/handlers/rsc/constants.js +0 -2
  150. package/dist/handlers/rsc/create-response.d.ts +0 -3
  151. package/dist/handlers/rsc/create-response.d.ts.map +0 -1
  152. package/dist/handlers/rsc/create-response.js +0 -378
  153. package/dist/handlers/rsc/render-with-retries.d.ts +0 -4
  154. package/dist/handlers/rsc/render-with-retries.d.ts.map +0 -1
  155. package/dist/handlers/rsc/render-with-retries.js +0 -154
  156. package/dist/handlers/rsc/retry-loop.d.ts +0 -3
  157. package/dist/handlers/rsc/retry-loop.d.ts.map +0 -1
  158. package/dist/handlers/rsc/retry-loop.js +0 -145
  159. package/dist/handlers/rsc/stream-rsc-payload.d.ts +0 -9
  160. package/dist/handlers/rsc/stream-rsc-payload.d.ts.map +0 -1
  161. package/dist/handlers/rsc/stream-rsc-payload.js +0 -20
  162. package/dist/handlers/rsc/types.d.ts +0 -26
  163. package/dist/handlers/rsc/types.d.ts.map +0 -1
  164. package/dist/handlers/rsc/types.js +0 -7
  165. package/dist/handlers/rsc.d.ts +0 -20
  166. package/dist/handlers/rsc.d.ts.map +0 -1
  167. package/dist/handlers/rsc.js +0 -872
  168. package/dist/integration.d.ts +0 -14
  169. package/dist/integration.d.ts.map +0 -1
  170. package/dist/integration.js +0 -9
  171. package/dist/lib/dev-module-load-race.d.ts +0 -8
  172. package/dist/lib/dev-module-load-race.d.ts.map +0 -1
  173. package/dist/lib/dev-module-load-race.js +0 -31
  174. package/dist/lib/dev-page-exports.d.ts +0 -5
  175. package/dist/lib/dev-page-exports.d.ts.map +0 -1
  176. package/dist/lib/dev-page-exports.js +0 -14
  177. package/dist/lib/environment-names.d.ts +0 -11
  178. package/dist/lib/environment-names.d.ts.map +0 -1
  179. package/dist/lib/environment-names.js +0 -10
  180. package/dist/lib/initial-hash-scroll.d.ts.map +0 -1
  181. package/dist/lib/not-found.d.ts +0 -5
  182. package/dist/lib/not-found.d.ts.map +0 -1
  183. package/dist/lib/not-found.js +0 -7
  184. package/dist/lib/page-exports.d.ts +0 -9
  185. package/dist/lib/page-exports.d.ts.map +0 -1
  186. package/dist/lib/page-exports.js +0 -47
  187. package/dist/lib/pattern-segments.d.ts +0 -8
  188. package/dist/lib/pattern-segments.d.ts.map +0 -1
  189. package/dist/lib/pattern-segments.js +0 -22
  190. package/dist/lib/ppr/cache-status.d.ts +0 -3
  191. package/dist/lib/ppr/cache-status.d.ts.map +0 -1
  192. package/dist/lib/ppr/cache-status.js +0 -5
  193. package/dist/lib/server-router-contract.d.ts +0 -42
  194. package/dist/lib/server-router-contract.d.ts.map +0 -1
  195. package/dist/lib/server-router-contract.js +0 -6
  196. package/dist/lib/server-router-loader.d.ts +0 -10
  197. package/dist/lib/server-router-loader.d.ts.map +0 -1
  198. package/dist/lib/server-router-loader.js +0 -180
  199. package/dist/lib/server-router.d.ts +0 -8
  200. package/dist/lib/server-router.d.ts.map +0 -1
  201. package/dist/lib/server-router.js +0 -173
  202. package/dist/plugins/ppr-upgrade.d.ts +0 -36
  203. package/dist/plugins/ppr-upgrade.d.ts.map +0 -1
  204. package/dist/plugins/ppr-upgrade.js +0 -32
  205. package/dist/plugins/server-router-fallback.d.ts +0 -15
  206. package/dist/plugins/server-router-fallback.d.ts.map +0 -1
  207. package/dist/plugins/server-router-fallback.js +0 -30
  208. package/dist/server.d.ts +0 -10
  209. package/dist/server.d.ts.map +0 -1
  210. package/dist/server.js +0 -57
@@ -0,0 +1,16 @@
1
+ import { addRoute, createRouter, findRoute } from "rou3";
2
+ export function createMatcher(entries) {
3
+ const router = createRouter();
4
+ for (const entry of entries) {
5
+ for (const method of entry.methods)
6
+ addRoute(router, method, entry.pattern, entry);
7
+ }
8
+ return {
9
+ find(method, url) {
10
+ const match = findRoute(router, method, new URL(url, "http://localhost").pathname);
11
+ if (!match)
12
+ return null;
13
+ return { entry: match.data, params: match.params };
14
+ },
15
+ };
16
+ }
@@ -1,15 +1,18 @@
1
1
  import type { Plugin } from "vite";
2
+ import type { MatcherEntry } from "../../lib/server-router/types.js";
2
3
  export interface RouterPluginOptions {
3
4
  /** Plugin name. */
4
5
  name: string;
5
6
  /** Absolute path to the module that exports `createMatcher`. */
6
7
  matcherModule: string;
8
+ /** Compiles the matcher entries into the source of a `find` function for production builds. */
9
+ compile?: (entries: readonly MatcherEntry[]) => string;
7
10
  }
8
11
  /**
9
12
  * Create a Vite plugin that provides a custom server router for Rebask.
10
13
  *
11
- * The plugin resolves `virtual:rebask/server-router` to the given `matcherModule`, which must
12
- * export a `createMatcher` function.
14
+ * `matcherModule` provides `createMatcher` in development, and in production unless `compile` is
15
+ * provided. `compile` replaces it in production builds.
13
16
  *
14
17
  * @example
15
18
  * ```ts
@@ -24,18 +27,5 @@ export interface RouterPluginOptions {
24
27
  * ```
25
28
  */
26
29
  export declare function createRouterPlugin(options: RouterPluginOptions): Plugin;
27
- /**
28
- * Default router of Rebask. Adding it manually is optional.
29
- *
30
- * @example
31
- * ```ts
32
- * import { rebask } from "@rebask/core/vite"
33
- * import { rebaskRouter } from "@rebask/core/server-router"
34
- *
35
- * export default defineConfig({
36
- * plugins: [rsc(), react(), rebask(), rebaskRouter()],
37
- * })
38
- * ```
39
- */
40
- export declare function rebaskRouter(): Plugin;
30
+ export declare function defaultRouterPlugin(): Plugin;
41
31
  //# sourceMappingURL=router-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/router/router-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC,MAAM,WAAW,mBAAmB;IACnC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAYvE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAKrC"}
1
+ {"version":3,"file":"router-plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/router/router-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAGlC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAMpE,MAAM,WAAW,mBAAmB;IACnC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,gEAAgE;IAChE,aAAa,EAAE,MAAM,CAAA;IACrB,+FAA+F;IAC/F,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,KAAK,MAAM,CAAA;CACtD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAkCvE;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAiB5C"}
@@ -1,10 +1,14 @@
1
+ import { addRoute, createRouter } from "rou3";
2
+ import { compileRouterToString } from "rou3/compiler";
3
+ import { REBASK_PLUGIN_NAME } from "../../lib/plugin-names.js";
4
+ import { getPluginApi } from "../../lib/plugin-utils.js";
1
5
  const VIRTUAL_MODULE_ID = "virtual:rebask/server-router";
2
6
  const RESOLVED_MODULE_ID = "\0virtual:rebask/server-router";
3
7
  /**
4
8
  * Create a Vite plugin that provides a custom server router for Rebask.
5
9
  *
6
- * The plugin resolves `virtual:rebask/server-router` to the given `matcherModule`, which must
7
- * export a `createMatcher` function.
10
+ * `matcherModule` provides `createMatcher` in development, and in production unless `compile` is
11
+ * provided. `compile` replaces it in production builds.
8
12
  *
9
13
  * @example
10
14
  * ```ts
@@ -19,36 +23,53 @@ const RESOLVED_MODULE_ID = "\0virtual:rebask/server-router";
19
23
  * ```
20
24
  */
21
25
  export function createRouterPlugin(options) {
26
+ let isBuild = false;
27
+ let api;
22
28
  return {
23
29
  name: options.name,
24
30
  enforce: "pre",
31
+ configResolved(config) {
32
+ isBuild = config.command === "build";
33
+ if (options.compile) {
34
+ api = getPluginApi(config.plugins, REBASK_PLUGIN_NAME);
35
+ }
36
+ },
25
37
  resolveId(id) {
26
38
  if (id === VIRTUAL_MODULE_ID)
27
39
  return RESOLVED_MODULE_ID;
28
40
  },
29
- load(id) {
41
+ async load(id) {
30
42
  if (id !== RESOLVED_MODULE_ID)
31
43
  return;
32
- return `export { createMatcher } from ${JSON.stringify(options.matcherModule)};`;
44
+ if (!options.compile || !isBuild) {
45
+ return `export { createMatcher } from ${JSON.stringify(options.matcherModule)};`;
46
+ }
47
+ if (!api) {
48
+ throw new Error('createRouterPlugin with "compile" requires the Rebask Vite plugin.');
49
+ }
50
+ const entries = await api.getMatcherEntries();
51
+ return [
52
+ `import { createCompiledMatcher } from "@rebask/core/server-router";`,
53
+ `const find = ${options.compile(entries)};`,
54
+ `export function createMatcher(entries) { return createCompiledMatcher(find, entries); }`,
55
+ ].join("\n");
33
56
  },
34
57
  };
35
58
  }
36
- /**
37
- * Default router of Rebask. Adding it manually is optional.
38
- *
39
- * @example
40
- * ```ts
41
- * import { rebask } from "@rebask/core/vite"
42
- * import { rebaskRouter } from "@rebask/core/server-router"
43
- *
44
- * export default defineConfig({
45
- * plugins: [rsc(), react(), rebask(), rebaskRouter()],
46
- * })
47
- * ```
48
- */
49
- export function rebaskRouter() {
50
- return createRouterPlugin({
51
- name: "rebask:router",
52
- matcherModule: new URL("./wint-router.js", import.meta.url).pathname,
53
- });
59
+ export function defaultRouterPlugin() {
60
+ return {
61
+ ...createRouterPlugin({
62
+ name: "rebask:server-router",
63
+ matcherModule: new URL("./rou3-router.js", import.meta.url).pathname,
64
+ compile: (entries) => {
65
+ const router = createRouter();
66
+ for (const [index, entry] of entries.entries()) {
67
+ for (const method of entry.methods)
68
+ addRoute(router, method, entry.pattern, index);
69
+ }
70
+ return compileRouterToString(router);
71
+ },
72
+ }),
73
+ enforce: "post",
74
+ };
54
75
  }
package/dist/proxy.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { rewrite } from "./lib/proxy/rewrite.js";
2
2
  export { REBASK_PROXY_BUNDLE_PATH } from "./lib/proxy/types.js";
3
3
  export type { ProxyBundle, ProxyHandler, ProxyRoutes, ProxyRouter } from "./lib/proxy/types.js";
4
+ export { proxyPatternToRegExpSource } from "./lib/proxy/pattern.js";
4
5
  //# sourceMappingURL=proxy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA"}
package/dist/proxy.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { rewrite } from "./lib/proxy/rewrite.js";
2
2
  export { REBASK_PROXY_BUNDLE_PATH } from "./lib/proxy/types.js";
3
+ export { proxyPatternToRegExpSource } from "./lib/proxy/pattern.js";
@@ -96,8 +96,6 @@ export declare function trackRequestIO(): void;
96
96
  export declare function hasRequestIO(): boolean;
97
97
  /** Record that the render read `key` and the value `get` returned for it. */
98
98
  export declare function trackSearchParam(key: string, value: SearchParamValue): void;
99
- /** The search params a render read, or `undefined` when it read none. */
100
- export declare function getUsedSearch(): UsedSearch | undefined;
101
99
  /** Whether the render read dynamic data (`routeParams()`, `headers()`, `cookies()`). */
102
100
  export declare function hasDynamicIO(): boolean;
103
101
  /** Marks that the render failed. */
@@ -1 +1 @@
1
- {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../src/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEzE,UAAU,mBAAmB;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;CACvB;AAED,UAAU,sBAAsB;IAC/B,OAAO,CAAC,EAAE,uBAAuB,CAAA;CACjC;AAED,UAAU,mBAAmB;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC9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AACvD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,QAKxE;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,2BAGhC;AAED,qBAAa,uBAAwB,SAAQ,OAAO;IACnD,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,MAAM,CAAQ;IAEtB,OAAO,CAAC,gBAAgB;IAQxB,MAAM,SAEL;IAEQ,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMjD;CACD;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAYtE"}
@@ -51,10 +51,6 @@ export function trackSearchParam(key, value) {
51
51
  state.usedSearch ??= new Map();
52
52
  state.usedSearch.set(key, value);
53
53
  }
54
- /** The search params a render read, or `undefined` when it read none. */
55
- export function getUsedSearch() {
56
- return getRequiredRequestState("getUsedSearch()").usedSearch;
57
- }
58
54
  /** Whether the render read dynamic data (`routeParams()`, `headers()`, `cookies()`). */
59
55
  export function hasDynamicIO() {
60
56
  return getRequiredRequestState("hasDynamicIO()").dynamicIO ?? false;
package/dist/router.d.ts CHANGED
@@ -22,7 +22,7 @@ export type NavigateOptions = {
22
22
  /** Control window scrolling after navigation. Defaults to `true`. */
23
23
  scroll?: boolean;
24
24
  };
25
- export declare const proxyPatternsAtom: import("@lfades/atom").Atom<string[] | undefined>;
25
+ export declare const proxyRegexpsAtom: import("@lfades/atom").Atom<string[] | undefined>;
26
26
  /** The tags and segment paths a cache invalidation affected. */
27
27
  type CacheInvalidation = {
28
28
  tags: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAcrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAczD,OAAO,KAAK,EAAE,WA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;;;;;;;;;;;;;OAiBG;IACH,UAAU,YACA,OAAO,GAAG,MAAM,GAAG,GAAG,YACtB,iBAAiB,KACxB,OAAO,CAAC,OAAO,CAAC,CAkClB;IAED;;;;;;OAMG;IACH,aAAa,QACP,MAAM,GAAG,MAAM,EAAE,YACb,iBAAiB,KACxB,OAAO,CAAC,MAAM,CAAC,CAUjB;IAED,sDAAsD;IACtD,OAAO,CAAC,iBAAiB,CA6DxB;CACD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,WAKxB;AAED,iEAAiE;AACjE,wBAAgB,WAAW,WAQ1B;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,KAAK,CAAC,CAwBlE;AAED,mDAAmD;AACnD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,CAAC,YAAY,EAAE,iBAAiB,KAAK,IAAI,QAYzF"}
package/dist/router.js CHANGED
@@ -28,7 +28,7 @@ const inflightTreeCache = new Map();
28
28
  const inflightRouteTreeByParent = new Map();
29
29
  const inflightSegmentCache = new Map();
30
30
  const inflightShellCache = new Map();
31
- export const proxyPatternsAtom = atom(undefined);
31
+ export const proxyRegexpsAtom = atom(undefined);
32
32
  /** Latest cache invalidation, or `null` before the first one. */
33
33
  const cacheInvalidationAtom = atom(null);
34
34
  /**
@@ -593,8 +593,8 @@ class Router {
593
593
  const parentPathname = `/${segments.slice(0, -1).join("/")}`;
594
594
  const inflightSiblingTree = inflightRouteTreeByParent.get(parentPathname);
595
595
  if (cache) {
596
- const proxyPatterns = proxyPatternsAtom.get();
597
- const predicted = predictRouteTree(target.href, proxyPatterns);
596
+ const proxyRegexps = proxyRegexpsAtom.get();
597
+ const predicted = predictRouteTree(target.href, proxyRegexps);
598
598
  if (predicted) {
599
599
  this.cache.registerRouteTree(predicted);
600
600
  return predicted;
@@ -667,7 +667,7 @@ class Router {
667
667
  return;
668
668
  const target = getUrl(url);
669
669
  const routeTreeResponse = this.cache.getRouteTreeResponse(target.href) ??
670
- predictRouteTree(target.href, proxyPatternsAtom.get()) ??
670
+ predictRouteTree(target.href, proxyRegexpsAtom.get()) ??
671
671
  (await this.prefetchRouteTree(url));
672
672
  const expectedRoutePrediction = routeTreeResponse.routePrediction;
673
673
  const missing = this.cache.findMissingSegmentLocations(routeTreeResponse);
@@ -1,5 +1,5 @@
1
- export { RouteType } from "./lib/server-router/types.js";
2
- export type { CreateMatcherFn, MatchedHandler, RouteEntry, RouteMatcher, } from "./lib/server-router/types.js";
1
+ export type { CreateMatcherFn, MatcherEntry, RouteMatcher } from "./lib/server-router/types.js";
3
2
  export type { LayoutRoute, NotFoundRoute, Route, RouteSegment, RouteHandlerRoute, } from "./lib/route-matcher.js";
4
- export { createRouterPlugin, rebaskRouter, type RouterPluginOptions, } from "./plugins/router/router-plugin.js";
3
+ export { createCompiledMatcher, type CompiledFind } from "./plugins/router/rou3-compiled.js";
4
+ export { createRouterPlugin, type RouterPluginOptions } from "./plugins/router/router-plugin.js";
5
5
  //# sourceMappingURL=server-router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-router.d.ts","sourceRoot":"","sources":["../src/server-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,YAAY,EACX,eAAe,EACf,cAAc,EACd,UAAU,EACV,YAAY,GACZ,MAAM,8BAA8B,CAAA;AACrC,YAAY,EACX,WAAW,EACX,aAAa,EACb,KAAK,EACL,YAAY,EACZ,iBAAiB,GACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACN,kBAAkB,EAClB,YAAY,EACZ,KAAK,mBAAmB,GACxB,MAAM,mCAAmC,CAAA"}
1
+ {"version":3,"file":"server-router.d.ts","sourceRoot":"","sources":["../src/server-router.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC/F,YAAY,EACX,WAAW,EACX,aAAa,EACb,KAAK,EACL,YAAY,EACZ,iBAAiB,GACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,qBAAqB,EAAE,KAAK,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAC5F,OAAO,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,mCAAmC,CAAA"}
@@ -1,2 +1,2 @@
1
- export { RouteType } from "./lib/server-router/types.js";
2
- export { createRouterPlugin, rebaskRouter, } from "./plugins/router/router-plugin.js";
1
+ export { createCompiledMatcher } from "./plugins/router/rou3-compiled.js";
2
+ export { createRouterPlugin } from "./plugins/router/router-plugin.js";
package/dist/vite.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { type Plugin } from "vite";
2
+ import { REBASK_PLUGIN_NAME } from "./lib/plugin-names.js";
2
3
  import type { LayoutRoute, Route, RouteHandlerRoute } from "./lib/route-matcher.js";
3
- /** The `name` of the Vite plugin. */
4
- export declare const REBASK_PLUGIN_NAME = "rebask:app-config";
4
+ import type { MatcherEntry } from "./lib/server-router/types.js";
5
+ export { REBASK_PLUGIN_NAME };
5
6
  type ShellPrerenderBase = {
6
7
  filePath: string;
7
8
  postponedState: string;
@@ -58,6 +59,11 @@ export interface RebaskPluginApi {
58
59
  getLayoutRoutes: () => LayoutRoute[];
59
60
  /** Get route handler routes (available after RSC build) */
60
61
  getRouteHandlerRoutes: () => RouteHandlerRoute[];
62
+ /**
63
+ * Get the entries used to build a compiled router. Their order matches the entries passed to
64
+ * `createMatcher` at runtime, so compiled indexes resolve correctly. Scans routes on first use.
65
+ */
66
+ getMatcherEntries: () => Promise<MatcherEntry[]>;
61
67
  /** Whether routes with a Markdown representation are also served at `.md` URLs. */
62
68
  hasMarkdownUrls: () => boolean;
63
69
  /** Get the built RSC entry, which a platform can move out of `dist` (available after config resolution) */
@@ -138,5 +144,4 @@ export interface RebaskPluginOptions {
138
144
  shellPrerenderTimeout?: number;
139
145
  }
140
146
  export declare function rebask(options?: RebaskPluginOptions): Plug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CHANGED
@@ -1,22 +1,28 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { rm, stat } from "node:fs/promises";
3
+ import { createRequire } from "node:module";
3
4
  import { isAbsolute, join, relative, resolve } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
5
6
  import { parse } from "vite";
6
7
  import { notifyRscUpdate, setDevServer } from "./lib/dev-server.js";
7
8
  import { SCOPED_CACHE_DIR } from "./lib/file-system-cache.js";
8
9
  import { headPlugin } from "./lib/head/head-plugin.js";
10
+ import { REBASK_IMAGE_PLUGIN_NAME, } from "./lib/image-optimization/image-plugin.js";
11
+ import { REBASK_PLUGIN_NAME } from "./lib/plugin-names.js";
12
+ import { getPluginApi } from "./lib/plugin-utils.js";
9
13
  import { CONFIG_EXTENSIONS, findProjectFile, PAGE_EXTENSIONS, scanAppDirectory, } from "./lib/project-files.js";
10
14
  import { assertNoPageRouteHandlerConflicts, buildLayoutRoutes, buildRouteHandlerRoutes, buildRoutes, } from "./lib/route-builder.js";
15
+ import { buildRouteEntries } from "./lib/server-router/route-entries.js";
11
16
  import { useCachePlugin } from "./lib/use-cache-plugin.js";
12
17
  import { devtoolsPlugin } from "./plugins/devtools.js";
13
18
  import { pprPlugin } from "./plugins/ppr.js";
14
- import { prerenderPlugin } from "./plugins/prerender.js";
19
+ import { prerenderPlugin, routeMetadataPlugin } from "./plugins/prerender.js";
15
20
  import { proxyPlugin } from "./plugins/proxy.js";
16
- import { rebaskRouter } from "./plugins/router/router-plugin.js";
21
+ import { defaultRouterPlugin } from "./plugins/router/router-plugin.js";
17
22
  import { serverOnlyPlugin } from "./plugins/server-only-plugin.js";
18
- /** The `name` of the Vite plugin. */
19
- export const REBASK_PLUGIN_NAME = "rebask:app-config";
23
+ const require = createRequire(import.meta.url);
24
+ const rebaskVersion = require("../package.json").version;
25
+ export { REBASK_PLUGIN_NAME };
20
26
  const BROWSER_ENTRY = fileURLToPath(new URL("./entry.browser.js", import.meta.url));
21
27
  const APP_CONFIG_MODULE_ID = "\0virtual:rebask/config";
22
28
  async function hasUseClientDirective(code, id) {
@@ -92,9 +98,18 @@ export function rebask(options = {}) {
92
98
  let routes = [];
93
99
  let layoutRoutes = [];
94
100
  let routeHandlerRoutes = [];
101
+ let routesScan = null;
102
+ let imageApi;
95
103
  const rscClientModules = new Set();
96
104
  const shellPrerenders = [];
97
105
  const cacheFunctions = new Map();
106
+ const stubHandler = async () => new Response();
107
+ const stubHandlers = {
108
+ page: () => stubHandler,
109
+ markdown: () => stubHandler,
110
+ routeHandler: () => stubHandler,
111
+ layout: () => stubHandler,
112
+ };
98
113
  const api = {
99
114
  getRoutes: () => routes,
100
115
  getLayoutRscRoutes: () => layoutRoutes.map((route) => ({
@@ -108,6 +123,13 @@ export function rebask(options = {}) {
108
123
  })),
109
124
  getLayoutRoutes: () => layoutRoutes,
110
125
  getRouteHandlerRoutes: () => routeHandlerRoutes,
126
+ async getMatcherEntries() {
127
+ await ensureRoutes();
128
+ const imagePattern = imageApi && (await imageApi.hasHandler()) ? imageApi.getImageConfig().path : null;
129
+ const imageEntry = imagePattern ? { pattern: imagePattern, handler: stubHandler } : null;
130
+ const { entries } = buildRouteEntries(routes, routeHandlerRoutes, layoutRoutes, imageEntry, stubHandlers);
131
+ return entries.map(({ methods, pattern }) => ({ methods, pattern }));
132
+ },
111
133
  hasMarkdownUrls: () => markdownUrls,
112
134
  getRscEntry: () => rscEntry,
113
135
  setDeploymentId: (deploymentId) => {
@@ -121,6 +143,24 @@ export function rebask(options = {}) {
121
143
  shellPrerenders.push(result);
122
144
  },
123
145
  };
146
+ async function ensureRoutes() {
147
+ if (!routesScan) {
148
+ routesScan = (async () => {
149
+ const appDir = join(projectRoot, "app");
150
+ await stat(appDir).catch((error) => {
151
+ if (error?.code !== "ENOENT") {
152
+ throw error;
153
+ }
154
+ });
155
+ const { pages, layouts, routeHandlers, markdownFiles } = await scanAppDirectory(appDir, markdownUrls);
156
+ assertNoPageRouteHandlerConflicts(pages, routeHandlers, markdownFiles);
157
+ routeHandlerRoutes = buildRouteHandlerRoutes(routeHandlers);
158
+ routes = buildRoutes(layouts, pages, markdownFiles);
159
+ layoutRoutes = buildLayoutRoutes(layouts);
160
+ })();
161
+ }
162
+ await routesScan;
163
+ }
124
164
  const plugins = [
125
165
  {
126
166
  name: "rebask:runtime-config",
@@ -129,6 +169,7 @@ export function rebask(options = {}) {
129
169
  projectRoot = config.root;
130
170
  rscEntry = resolve(config.root, config.environments.rsc.build.outDir, "index.js");
131
171
  isBuild = config.command === "build";
172
+ imageApi = getPluginApi(config.plugins, REBASK_IMAGE_PLUGIN_NAME);
132
173
  },
133
174
  async resolveId(id) {
134
175
  if (id === "virtual:rebask/runtime-config") {
@@ -182,6 +223,7 @@ export function rebask(options = {}) {
182
223
  async config() {
183
224
  return {
184
225
  define: {
226
+ __REBASK_VERSION__: JSON.stringify(rebaskVersion),
185
227
  __REBASK_FULL_HTML_FOR_BOTS: JSON.stringify(fullHtmlForBots),
186
228
  __REBASK_MARKDOWN_URLS: JSON.stringify(markdownUrls),
187
229
  __REBASK_DEDUPE_FETCH: JSON.stringify(dedupeFetch),
@@ -225,10 +267,18 @@ export function rebask(options = {}) {
225
267
  },
226
268
  },
227
269
  optimizeDeps: {
228
- // Point Vite's dep scanner at user app files so it discovers their bare imports at
229
- // startup. Without this, user deps are discovered mid-hydration and that causes us to
230
- // potentially have duplicated React issues.
231
- entries: ["app/**/*.{tsx,ts,jsx,js}", BROWSER_ENTRY],
270
+ // Point Vite's dep scanner at user source so it discovers bare imports at startup.
271
+ // App files cover the static route graph. The JSX/TSX glob also covers components
272
+ // reached only through computed imports, which would otherwise trigger a late
273
+ // re-optimization that duplicates React during a client navigation.
274
+ entries: [
275
+ "app/**/*.{tsx,ts,jsx,js}",
276
+ "**/*.{tsx,jsx}",
277
+ "!**/*.test.{tsx,jsx}",
278
+ "!**/*.spec.{tsx,jsx}",
279
+ "!**/__tests__/**",
280
+ BROWSER_ENTRY,
281
+ ],
232
282
  // Exclude the framework itself so Vite serves it as native ESM instead of pre-bundling
233
283
  // it. If `@rebask/core` is pre-bundled, React would be baked into the optimized chunk,
234
284
  // resulting in two React copies (one inside the framework chunk, one for app code).
@@ -368,24 +418,8 @@ export function rebask(options = {}) {
368
418
  if (id !== APP_CONFIG_MODULE_ID)
369
419
  return;
370
420
  // In development the router builds its routes from the app manifest on each request.
371
- if (this.environment.mode === "build") {
372
- const appDir = join(projectRoot, "app");
373
- await stat(appDir).catch((error) => {
374
- // If app directory doesn't exist, use empty routes
375
- if (error?.code !== "ENOENT") {
376
- throw error;
377
- }
378
- });
379
- const { pages, layouts, routeHandlers, markdownFiles } = await scanAppDirectory(appDir, markdownUrls);
380
- assertNoPageRouteHandlerConflicts(pages, routeHandlers, markdownFiles);
381
- routeHandlerRoutes = buildRouteHandlerRoutes(routeHandlers);
382
- // Generate page/layout routes only for the RSC environment
383
- if (this.environment.name === "rsc") {
384
- // Store routes in shared state (accessible via plugin API)
385
- routes = buildRoutes(layouts, pages, markdownFiles);
386
- layoutRoutes = buildLayoutRoutes(layouts);
387
- }
388
- }
421
+ if (this.environment.mode === "build")
422
+ await ensureRoutes();
389
423
  return [
390
424
  `export const routes = ${JSON.stringify(routes, null, 2)};`,
391
425
  `export const layoutRoutes = ${JSON.stringify(layoutRoutes, null, 2)};`,
@@ -429,21 +463,23 @@ export function rebask(options = {}) {
429
463
  }
430
464
  },
431
465
  },
432
- { ...rebaskRouter(), name: "rebask:server-router-fallback", enforce: "post" },
466
+ defaultRouterPlugin(),
433
467
  proxyPlugin(api),
434
468
  pprPlugin(),
435
469
  serverOnlyPlugin(),
436
470
  useCachePlugin(cacheFunctions),
437
471
  {
438
- name: "rebask:scoped-cache",
472
+ name: "rebask:build-cache",
439
473
  buildApp: {
440
474
  order: "pre",
441
475
  async handler() {
442
- // Scoped entries belong to the previous deployment.
443
- await rm(join(process.cwd(), "dist", ".rebask", "cache", SCOPED_CACHE_DIR), {
444
- recursive: true,
445
- force: true,
446
- });
476
+ const rebaskDir = join(process.cwd(), "dist", ".rebask");
477
+ // Scoped entries belong to the previous deployment. The manifest is about to be
478
+ // regenerated, and a stale one would make a no-prerender build trust old route data.
479
+ await Promise.all([
480
+ rm(join(rebaskDir, "cache", SCOPED_CACHE_DIR), { recursive: true, force: true }),
481
+ rm(join(rebaskDir, "prerendered-paths.json"), { force: true }),
482
+ ]);
447
483
  },
448
484
  },
449
485
  },
@@ -452,5 +488,8 @@ export function rebask(options = {}) {
452
488
  const prerenderOptions = typeof prerender === "object" ? prerender : {};
453
489
  plugins.push(prerenderPlugin(api, prerenderOptions));
454
490
  }
491
+ else {
492
+ plugins.push(routeMetadataPlugin(api));
493
+ }
455
494
  return plugins;
456
495
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebask/core",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Vite plugin and runtime for React Server Components",
5
5
  "homepage": "https://github.com/lfades/vext#readme",
6
6
  "license": "MIT",
@@ -145,8 +145,9 @@
145
145
  "dependencies": {
146
146
  "@lfades/atom": "^3.0.0",
147
147
  "@opentelemetry/api": "~1.9.1",
148
- "rsc-html-stream": "^0.0.8",
149
- "wint-js": "^1.2.7"
148
+ "image-size": "^2.1.0",
149
+ "rou3": "^1.0.0",
150
+ "rsc-html-stream": "^0.0.8"
150
151
  },
151
152
  "devDependencies": {
152
153
  "@opentelemetry/context-async-hooks": "^2.12.0",
@@ -177,6 +178,7 @@
177
178
  "dev": "tsc -p tsconfig.build.json -w",
178
179
  "build": "tsc -p tsconfig.build.json",
179
180
  "test:unit": "vitest run",
180
- "test:dev": "vitest"
181
+ "test:dev": "vitest",
182
+ "publint": "publint"
181
183
  }
182
184
  }
@@ -1,49 +0,0 @@
1
- import { Component, type ReactNode } from "react";
2
- import type { RevisionSnapshot, RouterCache } from "../lib/router-cache.js";
3
- type BoundaryRenderProps = {
4
- children: ReactNode;
5
- fallback: ReactNode;
6
- hasError?: boolean;
7
- };
8
- export type BoundaryClientProps = BoundaryRenderProps & {
9
- boundaryKey: string;
10
- };
11
- type BoundaryCacheState = {
12
- boundaryKey: string;
13
- segmentPath: string;
14
- snapshot: RevisionSnapshot;
15
- failed: boolean;
16
- };
17
- type ErrorBoundaryClientInnerProps = BoundaryRenderProps & BoundaryCacheState;
18
- type BoundaryCacheStateResult = BoundaryCacheState & {
19
- acceptsServerError: boolean;
20
- };
21
- type ErrorBoundaryClientState = {
22
- hasError: boolean;
23
- snapshot: RevisionSnapshot;
24
- };
25
- export declare class ErrorBoundaryClientInner extends Component<ErrorBoundaryClientInnerProps, ErrorBoundaryClientState> {
26
- static contextType: import("react").Context<RouterCache | null>;
27
- context: RouterCache | null;
28
- state: ErrorBoundaryClientState;
29
- constructor(props: ErrorBoundaryClientInnerProps);
30
- static getDerivedStateFromProps(props: ErrorBoundaryClientInnerProps, state: ErrorBoundaryClientState): {
31
- hasError: boolean;
32
- snapshot: RevisionSnapshot;
33
- } | {
34
- snapshot?: undefined;
35
- hasError: boolean;
36
- } | null;
37
- static getDerivedStateFromError(error: Error): {
38
- hasError: boolean;
39
- };
40
- componentDidMount(): void;
41
- componentDidUpdate(_prevProps: ErrorBoundaryClientInnerProps, prevState: ErrorBoundaryClientState): void;
42
- componentDidCatch(error: Error): void;
43
- render(): ReactNode;
44
- protected recordFailure(): void;
45
- }
46
- export declare function ErrorBoundaryClient(props: BoundaryClientProps): import("react").JSX.Element;
47
- export declare function useBoundaryCacheState(boundaryKey: string): BoundaryCacheStateResult;
48
- export {};
49
- //# sourceMappingURL=error-boundary-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-boundary-client.d.ts","sourceRoot":"","sources":["../../src/components/error-boundary-client.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAA;AAEvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAK3E,KAAK,mBAAmB,GAAG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