@teyik0/furin 0.9.0-alpha.3 → 0.9.0-alpha.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 (75) hide show
  1. package/dist/adapter/runtime-build.d.ts +1 -0
  2. package/dist/build/index.js +65 -25
  3. package/dist/build/route-metadata.d.ts +1 -1
  4. package/dist/cli/index.js +65 -25
  5. package/dist/client/chunks/{client-rdxyrw11.js → client-hjqd5m3b.js} +1 -1
  6. package/dist/client/chunks/{client-d9v49jwz.js → client-whph3y67.js} +66 -3
  7. package/dist/client/chunks/{client-a7spxfnn.js → client-xf7r768c.js} +13 -1
  8. package/dist/client/define-route.d.ts +12 -0
  9. package/dist/client/internal/runtime-types.d.ts +7 -0
  10. package/dist/client/link.js +200 -40
  11. package/dist/client/query.d.ts +13 -0
  12. package/dist/client/route-element.d.ts +5 -0
  13. package/dist/client/router/history.d.ts +6 -0
  14. package/dist/client/router/link-utils.d.ts +7 -0
  15. package/dist/client/router/navigation-controller.d.ts +20 -2
  16. package/dist/client/router/pending.d.ts +17 -0
  17. package/dist/client/router/search/index.d.ts +2 -0
  18. package/dist/client/router/search/index.js +7 -3
  19. package/dist/client/router/types.d.ts +21 -1
  20. package/dist/client.d.ts +1 -1
  21. package/dist/client.js +21 -4
  22. package/dist/define-route.d.ts +37 -10
  23. package/dist/furin.js +92 -43
  24. package/dist/plugin/client-plugin.d.ts +1 -1
  25. package/dist/plugin/index.js +36 -17
  26. package/dist/plugin/route-manifest.d.ts +2 -1
  27. package/dist/plugin/strip-server-stages.d.ts +1 -1
  28. package/dist/server/dev/graph.d.ts +0 -1
  29. package/dist/server/internal.d.ts +1 -0
  30. package/dist/server/internal.js +46 -22
  31. package/dist/server/router/defined-route.d.ts +3 -0
  32. package/dist/server/router/hmr.d.ts +0 -1
  33. package/dist/server/router/source-version.d.ts +0 -1
  34. package/dist/server/router/types.d.ts +7 -1
  35. package/dist/server/static-export.js +49 -22
  36. package/dist/server/sync/index.js +1 -1
  37. package/dist/shared/pending.d.ts +13 -0
  38. package/dist/shared/search-params.d.ts +1 -0
  39. package/dist/sync-client.js +1 -1
  40. package/package.json +1 -1
  41. package/src/adapter/runtime-build.ts +4 -0
  42. package/src/build/hydrate.ts +11 -2
  43. package/src/build/preload-manifest.ts +3 -1
  44. package/src/build/route-metadata.ts +3 -2
  45. package/src/client/define-route.ts +23 -3
  46. package/src/client/internal/runtime-types.ts +7 -0
  47. package/src/client/link.tsx +26 -4
  48. package/src/client/query-store.ts +2 -1
  49. package/src/client/query.tsx +87 -0
  50. package/src/client/route-element.tsx +41 -15
  51. package/src/client/router/context.ts +29 -8
  52. package/src/client/router/history.ts +10 -0
  53. package/src/client/router/link-utils.ts +23 -0
  54. package/src/client/router/navigation-controller.ts +239 -19
  55. package/src/client/router/pending.ts +58 -0
  56. package/src/client/router/provider.tsx +5 -2
  57. package/src/client/router/search/index.ts +7 -2
  58. package/src/client/router/types.ts +29 -3
  59. package/src/client.ts +1 -1
  60. package/src/define-route.ts +74 -26
  61. package/src/plugin/client-plugin.ts +5 -4
  62. package/src/plugin/route-config.ts +9 -2
  63. package/src/plugin/route-manifest.ts +11 -3
  64. package/src/plugin/route-tree.ts +2 -2
  65. package/src/plugin/strip-server-stages.ts +60 -35
  66. package/src/server/dev/graph.ts +2 -7
  67. package/src/server/dev/runtime.ts +1 -2
  68. package/src/server/internal.ts +1 -0
  69. package/src/server/router/defined-route.ts +6 -0
  70. package/src/server/router/discovery.ts +5 -2
  71. package/src/server/router/hmr.ts +1 -5
  72. package/src/server/router/source-version.ts +3 -6
  73. package/src/server/router/types.ts +7 -1
  74. package/src/shared/pending.ts +16 -0
  75. package/src/shared/search-params.ts +1 -1
@@ -33,6 +33,7 @@ export declare function buildCompileMetadata(root: BuildRoot | RootLayout, route
33
33
  errorPath?: string;
34
34
  fromRoute?: true;
35
35
  notFoundPath?: string;
36
+ pendingPath?: string;
36
37
  }>;
37
38
  }>;
38
39
  };
@@ -2019,6 +2019,8 @@ function addNextFile(state, base, segments, sourcePath) {
2019
2019
  state.boundary.errorPath ??= sourcePath;
2020
2020
  } else if (base === "not-found") {
2021
2021
  state.boundary.notFoundPath ??= sourcePath;
2022
+ } else if (base === "loading") {
2023
+ state.boundary.pendingPath ??= sourcePath;
2022
2024
  }
2023
2025
  }
2024
2026
  function scanNext(pagesDir) {
@@ -2026,7 +2028,12 @@ function scanNext(pagesDir) {
2026
2028
  const boundaries = [];
2027
2029
  let rootPath;
2028
2030
  const walk = (directory, segments) => {
2029
- const boundary = { directory, errorPath: undefined, notFoundPath: undefined };
2031
+ const boundary = {
2032
+ directory,
2033
+ errorPath: undefined,
2034
+ notFoundPath: undefined,
2035
+ pendingPath: undefined
2036
+ };
2030
2037
  const state = { boundary, candidates, rootPath };
2031
2038
  for (const entry of sortedEntries(directory)) {
2032
2039
  const sourcePath = child(directory, entry.name);
@@ -2037,7 +2044,7 @@ function scanNext(pagesDir) {
2037
2044
  }
2038
2045
  }
2039
2046
  rootPath ??= state.rootPath;
2040
- if (boundary.errorPath || boundary.notFoundPath) {
2047
+ if (boundary.errorPath || boundary.notFoundPath || boundary.pendingPath) {
2041
2048
  boundaries.push(boundary);
2042
2049
  }
2043
2050
  };
@@ -7145,14 +7152,16 @@ function memberAccessStart(source, object, property) {
7145
7152
  const separator = accessGap.replace(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g, (comment) => " ".repeat(comment.length)).lastIndexOf(".");
7146
7153
  return object.end + separator - (accessGap[separator - 1] === "?" ? 1 : 0);
7147
7154
  }
7148
- function stripServerStage(module, stripped, range, remount) {
7155
+ function stripServerStage(module, stripped, range, policies) {
7149
7156
  const { removed, source } = module;
7150
- if (remount) {
7151
- const policy = source.slice(remount.start, remount.end);
7152
- for (const name of referencedNames(remount, removed)) {
7153
- stripped.retained.add(name);
7157
+ if (policies.length > 0) {
7158
+ const retained = policies.map((policy) => source.slice(policy.start, policy.end));
7159
+ for (const policy of policies) {
7160
+ for (const name of referencedNames(policy, removed)) {
7161
+ stripped.retained.add(name);
7162
+ }
7154
7163
  }
7155
- replaceRange(module, range.start, range.end, `.config({ ${policy} })`);
7164
+ replaceRange(module, range.start, range.end, `.config({ ${retained.join(", ")} })`);
7156
7165
  } else {
7157
7166
  removeRange(module, range.start, range.end);
7158
7167
  }
@@ -7165,20 +7174,36 @@ function removeChainedServerCalls(module, bindings, chains, stripped) {
7165
7174
  if (isRemoved(call, module.removed)) {
7166
7175
  continue;
7167
7176
  }
7168
- let remount = null;
7177
+ let policies = [];
7169
7178
  if (property.name === "config" && Array.isArray(call.arguments)) {
7170
7179
  const config = unwrapped(call.arguments[0]);
7171
7180
  if (config?.type === "ObjectExpression" && Array.isArray(config.properties)) {
7172
7181
  collectConfigBindings(config, declarations, stripped.configBindings);
7173
- remount = resolveRemountProperty(config, declarations, stripped.configBindings, new Set, filename);
7182
+ policies = clientPolicies(config, declarations, stripped.configBindings, filename);
7174
7183
  }
7175
7184
  }
7176
7185
  const accessStart = memberAccessStart(source.original, object, property);
7177
- stripServerStage(module, stripped, { end: call.end, start: accessStart }, remount);
7186
+ stripServerStage(module, stripped, { end: call.end, start: accessStart }, policies);
7178
7187
  transformed = true;
7179
7188
  }
7180
7189
  return transformed;
7181
7190
  }
7191
+ function clientPolicies(config, declarations, configBindings, filename) {
7192
+ const resolve = (name) => resolveConfigProperty(config, name, declarations, configBindings, new Set);
7193
+ const loaderDeps = resolve("loaderDeps");
7194
+ const remount = resolve("remountDeps");
7195
+ if (remount === UNRESOLVED) {
7196
+ throw new Error(`[furin] ${filename}: route config spreads must resolve to local object literals; declare remountDeps after dynamic spreads.`);
7197
+ }
7198
+ const policies = [];
7199
+ if (loaderDeps !== null && loaderDeps !== UNRESOLVED) {
7200
+ policies.push(loaderDeps);
7201
+ }
7202
+ if (remount !== null) {
7203
+ policies.push(remount);
7204
+ }
7205
+ return policies;
7206
+ }
7182
7207
  function declaredInitializer(declaration) {
7183
7208
  return declaration?.type === "VariableDeclarator" ? unwrapped(declaration.init) : null;
7184
7209
  }
@@ -7196,28 +7221,29 @@ function collectConfigBindings(config, declarations, names) {
7196
7221
  }
7197
7222
  }
7198
7223
  }
7199
- function resolveRemountProperty(config, declarations, configBindings, visiting, filename) {
7224
+ var UNRESOLVED = Symbol("unresolved");
7225
+ function resolveConfigProperty(config, name, declarations, configBindings, visiting) {
7200
7226
  if (config?.type === "Identifier" && !visiting.has(config.name)) {
7201
7227
  visiting.add(config.name);
7202
7228
  configBindings.add(config.name);
7203
7229
  const declaration = declarations.get(config.name);
7204
- const result = resolveRemountProperty(declaredInitializer(declaration), declarations, configBindings, visiting, filename);
7230
+ const result = resolveConfigProperty(declaredInitializer(declaration), name, declarations, configBindings, visiting);
7205
7231
  visiting.delete(config.name);
7206
7232
  return result;
7207
7233
  }
7208
7234
  if (config?.type !== "ObjectExpression" || !Array.isArray(config.properties)) {
7209
- throw new Error(`[furin] ${filename}: route config spreads must resolve to local object literals; declare remountDeps after dynamic spreads.`);
7235
+ return UNRESOLVED;
7210
7236
  }
7211
7237
  for (let index = config.properties.length - 1;index >= 0; index -= 1) {
7212
7238
  const entry = unwrapped(config.properties[index]);
7213
7239
  if (entry?.type === "SpreadElement") {
7214
- const remount = resolveRemountProperty(unwrapped(entry.argument), declarations, configBindings, visiting, filename);
7215
- if (remount) {
7216
- return remount;
7240
+ const property = resolveConfigProperty(unwrapped(entry.argument), name, declarations, configBindings, visiting);
7241
+ if (property) {
7242
+ return property;
7217
7243
  }
7218
7244
  } else if (entry?.type === "Property") {
7219
7245
  const key = unwrapped(entry.key);
7220
- if (key?.type === "Identifier" && entry.computed !== true && key.name === "remountDeps" || key?.type === "Literal" && key.value === "remountDeps") {
7246
+ if (key?.type === "Identifier" && entry.computed !== true && key.name === name || key?.type === "Literal" && key.value === name) {
7221
7247
  return entry;
7222
7248
  }
7223
7249
  }
@@ -7311,8 +7337,8 @@ var ELYSIA_FILTER = /^elysia$/;
7311
7337
  var BUN_BUILTIN_FILTER = /^bun:/;
7312
7338
  var ANY_FILTER = /.*/;
7313
7339
  var elysiaStub = (typeModule) => `export * as t from ${JSON.stringify(typeModule)};
7340
+ export { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, NotFound, ParseError, ValidationError, problem, status, validationDetail } from ${JSON.stringify(Bun.resolveSync("elysia/error", dirname9(typeModule)))};
7314
7341
  export class NotFoundError extends Error { constructor(m) { super(m); this.name = "NotFoundError"; } }
7315
- export class ValidationError extends Error { constructor(m) { super(m); this.name = "ValidationError"; } }
7316
7342
  export default {};
7317
7343
  `;
7318
7344
  var ELYSIA_STUB_PREFIX = "elysia-stub:";
@@ -7741,7 +7767,8 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7741
7767
  for (const seg of route.segmentBoundaries ?? []) {
7742
7768
  const errorIdent = getBoundaryIdent(boundaryIdents, seg.errorPath);
7743
7769
  const notFoundIdent = getBoundaryIdent(boundaryIdents, seg.notFoundPath);
7744
- if (!(errorIdent || notFoundIdent)) {
7770
+ const pendingIdent = getBoundaryIdent(boundaryIdents, seg.pendingPath);
7771
+ if (!(errorIdent || notFoundIdent || pendingIdent)) {
7745
7772
  continue;
7746
7773
  }
7747
7774
  const parts = [`depth: ${seg.depth}`];
@@ -7753,6 +7780,9 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7753
7780
  if (notFoundIdent) {
7754
7781
  parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
7755
7782
  }
7783
+ if (pendingIdent) {
7784
+ parts.push(seg.fromRoute ? `pending: ${pendingIdent}.route.pending` : `pending: { component: ${pendingIdent}.default, minMs: ${pendingIdent}.pendingMinMs, ms: ${pendingIdent}.pendingMs }`);
7785
+ }
7756
7786
  if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
7757
7787
  parts.push("isRoot: false");
7758
7788
  }
@@ -7771,7 +7801,7 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7771
7801
  }).join(" ");
7772
7802
  const boundaryResult = boundaryLiterals.length > 0 ? `, segmentBoundaries: [${boundaryLiterals.join(", ")}]` : "";
7773
7803
  const pageComponentKey = JSON.stringify(`page:${modulePathKey(resolvedPage)}`);
7774
- const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent, remountDeps: __furin_page_route.remountDeps }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
7804
+ const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent, loaderDeps: __furin_page_route.loaderDeps, remountDeps: __furin_page_route.remountDeps }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
7775
7805
  const searchDefaultsEntry = searchDefaults ? `, searchDefaults: ${JSON.stringify(searchDefaults)}` : "";
7776
7806
  routeEntries.push(` { pattern: ${JSON.stringify(route.pattern)}, regex: new RegExp(${JSON.stringify(regexPattern)}), load: () => ${loadBody}${searchDefaultsEntry} }`);
7777
7807
  }
@@ -8098,7 +8128,7 @@ import { basename as basename3, resolve as resolve6 } from "path";
8098
8128
  var CLIENT_MODULE_KEY_RE = /(["'`])(__FURIN_CLIENT_MODULE_[a-z0-9]+__)\1/g;
8099
8129
  function routeModulePaths(route) {
8100
8130
  const layouts = (route.routeChain ?? []).slice(1).filter((entry) => entry.layout && entry.sourcePath).map((entry) => entry.sourcePath);
8101
- const boundaries = (route.segmentBoundaries ?? []).flatMap((segment) => [segment.errorPath, segment.notFoundPath].filter((path) => path !== undefined));
8131
+ const boundaries = (route.segmentBoundaries ?? []).flatMap((segment) => [segment.errorPath, segment.notFoundPath, segment.pendingPath].filter((path) => path !== undefined));
8102
8132
  return [route.path, ...layouts, ...boundaries];
8103
8133
  }
8104
8134
  function realPath(path) {
@@ -8347,6 +8377,9 @@ async function createBuildFingerprint(entryChunk, cssChunks, routes, root, serve
8347
8377
  if (segment.notFoundPath) {
8348
8378
  fingerprintPaths.add(segment.notFoundPath);
8349
8379
  }
8380
+ if (segment.pendingPath) {
8381
+ fingerprintPaths.add(segment.pendingPath);
8382
+ }
8350
8383
  }
8351
8384
  }
8352
8385
  const sources = new Map;
@@ -8441,7 +8474,8 @@ function buildCompileMetadata(root, routes) {
8441
8474
  errorPath: boundary.errorPath ? toPosixPath(boundary.errorPath) : undefined,
8442
8475
  ...boundary.fromRoute ? { fromRoute: boundary.fromRoute } : {},
8443
8476
  notFoundPath: boundary.notFoundPath ? toPosixPath(boundary.notFoundPath) : undefined,
8444
- path: toPosixPath(boundary.path)
8477
+ path: toPosixPath(boundary.path),
8478
+ pendingPath: boundary.pendingPath ? toPosixPath(boundary.pendingPath) : undefined
8445
8479
  }))
8446
8480
  };
8447
8481
  }
@@ -10163,12 +10197,18 @@ function checkParams(file, route, parsed) {
10163
10197
  return issueAt(file, parsed, parsed.route.config ?? parsed.route.head, `The path param${plural ? "s" : ""} ${missing.map(({ name }) => name).join(", ")} ${plural ? "are" : "is"} missing from this page's params schema. Each page declares every dynamic segment of its path, including those of its layouts. Add to config():${tImport}
10164
10198
  ${paramsSchema(missing)}`);
10165
10199
  }
10200
+ var BOUNDARY_CONVENTIONS = {
10201
+ error: "an error.tsx",
10202
+ notFound: "a not-found.tsx",
10203
+ pending: "a loading.tsx"
10204
+ };
10205
+ var BOUNDARY_METHODS = ["error", "notFound", "pending"];
10166
10206
  function checkBoundaryMethods(file, instance, parsed) {
10167
- const method = ["error", "notFound"].find((name) => parsed.route.methods.has(name));
10207
+ const method = BOUNDARY_METHODS.find((name) => parsed.route.methods.has(name));
10168
10208
  if (instance.style !== "nextjs" || method === undefined) {
10169
10209
  return;
10170
10210
  }
10171
- const convention = method === "error" ? "an error.tsx" : "a not-found.tsx";
10211
+ const convention = BOUNDARY_CONVENTIONS[method];
10172
10212
  return issueAt(file, parsed, parsed.route.head, `.${method}() is the TanStack style. In the nextjs style, default-export the component from ${convention} next to this route.`);
10173
10213
  }
10174
10214
  function checkRoute(file, instance, route, parsed) {
@@ -18,7 +18,7 @@ export interface BuildRoute extends Pick<ResolvedRoute, "layouts" | "mode" | "pa
18
18
  layout: boolean;
19
19
  sourcePath?: string;
20
20
  }[];
21
- segmentBoundaries: Pick<SegmentBoundary, "depth" | "path" | "errorPath" | "fromRoute" | "notFoundPath">[];
21
+ segmentBoundaries: Pick<SegmentBoundary, "depth" | "path" | "errorPath" | "fromRoute" | "notFoundPath" | "pendingPath">[];
22
22
  }
23
23
  export type BuildRouteInput = BuildRoute | ResolvedRoute;
24
24
  export type BuildRoot = Pick<RootLayout, "path" | "errorPath" | "notFoundPath"> & {
package/dist/cli/index.js CHANGED
@@ -2026,6 +2026,8 @@ function addNextFile(state, base, segments, sourcePath) {
2026
2026
  state.boundary.errorPath ??= sourcePath;
2027
2027
  } else if (base === "not-found") {
2028
2028
  state.boundary.notFoundPath ??= sourcePath;
2029
+ } else if (base === "loading") {
2030
+ state.boundary.pendingPath ??= sourcePath;
2029
2031
  }
2030
2032
  }
2031
2033
  function scanNext(pagesDir) {
@@ -2033,7 +2035,12 @@ function scanNext(pagesDir) {
2033
2035
  const boundaries = [];
2034
2036
  let rootPath;
2035
2037
  const walk = (directory, segments) => {
2036
- const boundary = { directory, errorPath: undefined, notFoundPath: undefined };
2038
+ const boundary = {
2039
+ directory,
2040
+ errorPath: undefined,
2041
+ notFoundPath: undefined,
2042
+ pendingPath: undefined
2043
+ };
2037
2044
  const state = { boundary, candidates, rootPath };
2038
2045
  for (const entry of sortedEntries(directory)) {
2039
2046
  const sourcePath = child(directory, entry.name);
@@ -2044,7 +2051,7 @@ function scanNext(pagesDir) {
2044
2051
  }
2045
2052
  }
2046
2053
  rootPath ??= state.rootPath;
2047
- if (boundary.errorPath || boundary.notFoundPath) {
2054
+ if (boundary.errorPath || boundary.notFoundPath || boundary.pendingPath) {
2048
2055
  boundaries.push(boundary);
2049
2056
  }
2050
2057
  };
@@ -7152,14 +7159,16 @@ function memberAccessStart(source, object, property) {
7152
7159
  const separator = accessGap.replace(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g, (comment) => " ".repeat(comment.length)).lastIndexOf(".");
7153
7160
  return object.end + separator - (accessGap[separator - 1] === "?" ? 1 : 0);
7154
7161
  }
7155
- function stripServerStage(module, stripped, range, remount) {
7162
+ function stripServerStage(module, stripped, range, policies) {
7156
7163
  const { removed, source } = module;
7157
- if (remount) {
7158
- const policy = source.slice(remount.start, remount.end);
7159
- for (const name of referencedNames(remount, removed)) {
7160
- stripped.retained.add(name);
7164
+ if (policies.length > 0) {
7165
+ const retained = policies.map((policy) => source.slice(policy.start, policy.end));
7166
+ for (const policy of policies) {
7167
+ for (const name of referencedNames(policy, removed)) {
7168
+ stripped.retained.add(name);
7169
+ }
7161
7170
  }
7162
- replaceRange(module, range.start, range.end, `.config({ ${policy} })`);
7171
+ replaceRange(module, range.start, range.end, `.config({ ${retained.join(", ")} })`);
7163
7172
  } else {
7164
7173
  removeRange(module, range.start, range.end);
7165
7174
  }
@@ -7172,20 +7181,36 @@ function removeChainedServerCalls(module, bindings, chains, stripped) {
7172
7181
  if (isRemoved(call, module.removed)) {
7173
7182
  continue;
7174
7183
  }
7175
- let remount = null;
7184
+ let policies = [];
7176
7185
  if (property.name === "config" && Array.isArray(call.arguments)) {
7177
7186
  const config = unwrapped(call.arguments[0]);
7178
7187
  if (config?.type === "ObjectExpression" && Array.isArray(config.properties)) {
7179
7188
  collectConfigBindings(config, declarations, stripped.configBindings);
7180
- remount = resolveRemountProperty(config, declarations, stripped.configBindings, new Set, filename);
7189
+ policies = clientPolicies(config, declarations, stripped.configBindings, filename);
7181
7190
  }
7182
7191
  }
7183
7192
  const accessStart = memberAccessStart(source.original, object, property);
7184
- stripServerStage(module, stripped, { end: call.end, start: accessStart }, remount);
7193
+ stripServerStage(module, stripped, { end: call.end, start: accessStart }, policies);
7185
7194
  transformed = true;
7186
7195
  }
7187
7196
  return transformed;
7188
7197
  }
7198
+ function clientPolicies(config, declarations, configBindings, filename) {
7199
+ const resolve = (name) => resolveConfigProperty(config, name, declarations, configBindings, new Set);
7200
+ const loaderDeps = resolve("loaderDeps");
7201
+ const remount = resolve("remountDeps");
7202
+ if (remount === UNRESOLVED) {
7203
+ throw new Error(`[furin] ${filename}: route config spreads must resolve to local object literals; declare remountDeps after dynamic spreads.`);
7204
+ }
7205
+ const policies = [];
7206
+ if (loaderDeps !== null && loaderDeps !== UNRESOLVED) {
7207
+ policies.push(loaderDeps);
7208
+ }
7209
+ if (remount !== null) {
7210
+ policies.push(remount);
7211
+ }
7212
+ return policies;
7213
+ }
7189
7214
  function declaredInitializer(declaration) {
7190
7215
  return declaration?.type === "VariableDeclarator" ? unwrapped(declaration.init) : null;
7191
7216
  }
@@ -7203,28 +7228,29 @@ function collectConfigBindings(config, declarations, names) {
7203
7228
  }
7204
7229
  }
7205
7230
  }
7206
- function resolveRemountProperty(config, declarations, configBindings, visiting, filename) {
7231
+ var UNRESOLVED = Symbol("unresolved");
7232
+ function resolveConfigProperty(config, name, declarations, configBindings, visiting) {
7207
7233
  if (config?.type === "Identifier" && !visiting.has(config.name)) {
7208
7234
  visiting.add(config.name);
7209
7235
  configBindings.add(config.name);
7210
7236
  const declaration = declarations.get(config.name);
7211
- const result = resolveRemountProperty(declaredInitializer(declaration), declarations, configBindings, visiting, filename);
7237
+ const result = resolveConfigProperty(declaredInitializer(declaration), name, declarations, configBindings, visiting);
7212
7238
  visiting.delete(config.name);
7213
7239
  return result;
7214
7240
  }
7215
7241
  if (config?.type !== "ObjectExpression" || !Array.isArray(config.properties)) {
7216
- throw new Error(`[furin] ${filename}: route config spreads must resolve to local object literals; declare remountDeps after dynamic spreads.`);
7242
+ return UNRESOLVED;
7217
7243
  }
7218
7244
  for (let index = config.properties.length - 1;index >= 0; index -= 1) {
7219
7245
  const entry = unwrapped(config.properties[index]);
7220
7246
  if (entry?.type === "SpreadElement") {
7221
- const remount = resolveRemountProperty(unwrapped(entry.argument), declarations, configBindings, visiting, filename);
7222
- if (remount) {
7223
- return remount;
7247
+ const property = resolveConfigProperty(unwrapped(entry.argument), name, declarations, configBindings, visiting);
7248
+ if (property) {
7249
+ return property;
7224
7250
  }
7225
7251
  } else if (entry?.type === "Property") {
7226
7252
  const key = unwrapped(entry.key);
7227
- if (key?.type === "Identifier" && entry.computed !== true && key.name === "remountDeps" || key?.type === "Literal" && key.value === "remountDeps") {
7253
+ if (key?.type === "Identifier" && entry.computed !== true && key.name === name || key?.type === "Literal" && key.value === name) {
7228
7254
  return entry;
7229
7255
  }
7230
7256
  }
@@ -7318,8 +7344,8 @@ var ELYSIA_FILTER = /^elysia$/;
7318
7344
  var BUN_BUILTIN_FILTER = /^bun:/;
7319
7345
  var ANY_FILTER = /.*/;
7320
7346
  var elysiaStub = (typeModule) => `export * as t from ${JSON.stringify(typeModule)};
7347
+ export { ElysiaError, ElysiaStatus, HTTPError, InternalServerError, InvalidCookie, NotFound, ParseError, ValidationError, problem, status, validationDetail } from ${JSON.stringify(Bun.resolveSync("elysia/error", dirname9(typeModule)))};
7321
7348
  export class NotFoundError extends Error { constructor(m) { super(m); this.name = "NotFoundError"; } }
7322
- export class ValidationError extends Error { constructor(m) { super(m); this.name = "ValidationError"; } }
7323
7349
  export default {};
7324
7350
  `;
7325
7351
  var ELYSIA_STUB_PREFIX = "elysia-stub:";
@@ -7748,7 +7774,8 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7748
7774
  for (const seg of route.segmentBoundaries ?? []) {
7749
7775
  const errorIdent = getBoundaryIdent(boundaryIdents, seg.errorPath);
7750
7776
  const notFoundIdent = getBoundaryIdent(boundaryIdents, seg.notFoundPath);
7751
- if (!(errorIdent || notFoundIdent)) {
7777
+ const pendingIdent = getBoundaryIdent(boundaryIdents, seg.pendingPath);
7778
+ if (!(errorIdent || notFoundIdent || pendingIdent)) {
7752
7779
  continue;
7753
7780
  }
7754
7781
  const parts = [`depth: ${seg.depth}`];
@@ -7760,6 +7787,9 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7760
7787
  if (notFoundIdent) {
7761
7788
  parts.push(`notFound: ${notFoundIdent}.${notFoundExport}`);
7762
7789
  }
7790
+ if (pendingIdent) {
7791
+ parts.push(seg.fromRoute ? `pending: ${pendingIdent}.route.pending` : `pending: { component: ${pendingIdent}.default, minMs: ${pendingIdent}.pendingMinMs, ms: ${pendingIdent}.pendingMs }`);
7792
+ }
7763
7793
  if (seg.depth === 0 && seg.path.replaceAll("\\", "/") !== rootDirectory) {
7764
7794
  parts.push("isRoot: false");
7765
7795
  }
@@ -7778,7 +7808,7 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
7778
7808
  }).join(" ");
7779
7809
  const boundaryResult = boundaryLiterals.length > 0 ? `, segmentBoundaries: [${boundaryLiterals.join(", ")}]` : "";
7780
7810
  const pageComponentKey = JSON.stringify(`page:${modulePathKey(resolvedPage)}`);
7781
- const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent, remountDeps: __furin_page_route.remountDeps }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
7811
+ const loadBody = `Promise.all([${lazyImports.join(", ")}]).then(([${importIdents.join(", ")}]) => { const __furin_page_route = __furin_page.route; let __furin_parent = root; ${layoutAssignments} return { default: { __type: "FURIN_PAGE", _route: { __type: "FURIN_ROUTE", parent: __furin_parent, loaderDeps: __furin_page_route.loaderDeps, remountDeps: __furin_page_route.remountDeps }, component: hotComponent(${pageComponentKey}, __furin_page_route.component) }${boundaryResult} }; })`;
7782
7812
  const searchDefaultsEntry = searchDefaults ? `, searchDefaults: ${JSON.stringify(searchDefaults)}` : "";
7783
7813
  routeEntries.push(` { pattern: ${JSON.stringify(route.pattern)}, regex: new RegExp(${JSON.stringify(regexPattern)}), load: () => ${loadBody}${searchDefaultsEntry} }`);
7784
7814
  }
@@ -8105,7 +8135,7 @@ import { basename as basename3, resolve as resolve6 } from "path";
8105
8135
  var CLIENT_MODULE_KEY_RE = /(["'`])(__FURIN_CLIENT_MODULE_[a-z0-9]+__)\1/g;
8106
8136
  function routeModulePaths(route) {
8107
8137
  const layouts = (route.routeChain ?? []).slice(1).filter((entry) => entry.layout && entry.sourcePath).map((entry) => entry.sourcePath);
8108
- const boundaries = (route.segmentBoundaries ?? []).flatMap((segment) => [segment.errorPath, segment.notFoundPath].filter((path) => path !== undefined));
8138
+ const boundaries = (route.segmentBoundaries ?? []).flatMap((segment) => [segment.errorPath, segment.notFoundPath, segment.pendingPath].filter((path) => path !== undefined));
8109
8139
  return [route.path, ...layouts, ...boundaries];
8110
8140
  }
8111
8141
  function realPath(path) {
@@ -8354,6 +8384,9 @@ async function createBuildFingerprint(entryChunk, cssChunks, routes, root, serve
8354
8384
  if (segment.notFoundPath) {
8355
8385
  fingerprintPaths.add(segment.notFoundPath);
8356
8386
  }
8387
+ if (segment.pendingPath) {
8388
+ fingerprintPaths.add(segment.pendingPath);
8389
+ }
8357
8390
  }
8358
8391
  }
8359
8392
  const sources = new Map;
@@ -8448,7 +8481,8 @@ function buildCompileMetadata(root, routes) {
8448
8481
  errorPath: boundary.errorPath ? toPosixPath(boundary.errorPath) : undefined,
8449
8482
  ...boundary.fromRoute ? { fromRoute: boundary.fromRoute } : {},
8450
8483
  notFoundPath: boundary.notFoundPath ? toPosixPath(boundary.notFoundPath) : undefined,
8451
- path: toPosixPath(boundary.path)
8484
+ path: toPosixPath(boundary.path),
8485
+ pendingPath: boundary.pendingPath ? toPosixPath(boundary.pendingPath) : undefined
8452
8486
  }))
8453
8487
  };
8454
8488
  }
@@ -10170,12 +10204,18 @@ function checkParams(file, route, parsed) {
10170
10204
  return issueAt(file, parsed, parsed.route.config ?? parsed.route.head, `The path param${plural ? "s" : ""} ${missing.map(({ name }) => name).join(", ")} ${plural ? "are" : "is"} missing from this page's params schema. Each page declares every dynamic segment of its path, including those of its layouts. Add to config():${tImport}
10171
10205
  ${paramsSchema(missing)}`);
10172
10206
  }
10207
+ var BOUNDARY_CONVENTIONS = {
10208
+ error: "an error.tsx",
10209
+ notFound: "a not-found.tsx",
10210
+ pending: "a loading.tsx"
10211
+ };
10212
+ var BOUNDARY_METHODS = ["error", "notFound", "pending"];
10173
10213
  function checkBoundaryMethods(file, instance, parsed) {
10174
- const method = ["error", "notFound"].find((name) => parsed.route.methods.has(name));
10214
+ const method = BOUNDARY_METHODS.find((name) => parsed.route.methods.has(name));
10175
10215
  if (instance.style !== "nextjs" || method === undefined) {
10176
10216
  return;
10177
10217
  }
10178
- const convention = method === "error" ? "an error.tsx" : "a not-found.tsx";
10218
+ const convention = BOUNDARY_CONVENTIONS[method];
10179
10219
  return issueAt(file, parsed, parsed.route.head, `.${method}() is the TanStack style. In the nextjs style, default-export the component from ${convention} next to this route.`);
10180
10220
  }
10181
10221
  function checkRoute(file, instance, route, parsed) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  navigationHrefPolicy
3
- } from "./client-a7spxfnn.js";
3
+ } from "./client-xf7r768c.js";
4
4
 
5
5
  // src/client/router/search-store.ts
6
6
  import { createContext } from "react";
@@ -2,7 +2,7 @@ import {
2
2
  isWithinPrefix,
3
3
  encodeInvalidationEntry,
4
4
  buildHref2
5
- } from "./client-a7spxfnn.js";
5
+ } from "./client-xf7r768c.js";
6
6
 
7
7
  // src/client/document.tsx
8
8
  import { createContext, createElement, useContext } from "react";
@@ -391,10 +391,10 @@ class QueryStore {
391
391
  }
392
392
  }
393
393
  entry.snapshot = { ...entry.snapshot, data };
394
+ this.revisionValue += 1;
394
395
  for (const listener of entry.listeners) {
395
396
  listener();
396
397
  }
397
- this.revisionValue += 1;
398
398
  for (const listener of this.listeners) {
399
399
  listener();
400
400
  }
@@ -826,6 +826,7 @@ import {
826
826
  useCallback,
827
827
  useContext as useContext2,
828
828
  useEffect,
829
+ useState,
829
830
  useSyncExternalStore
830
831
  } from "react";
831
832
  var QUERY_CONTEXT = Symbol.for("furin.query.context.v1");
@@ -854,6 +855,68 @@ function useQuery2(query, options) {
854
855
  isFetching: state.isFetching
855
856
  };
856
857
  }
858
+ function useInfiniteQuery2(page, options) {
859
+ const first = page(0)[LIVE_QUERY];
860
+ const context = useContext2(QueryStoreContext);
861
+ const store = context ?? first.reference.client;
862
+ const firstUrl = store.readKey(first.reference, first.options);
863
+ const [loaded, setLoaded] = useState({ count: 1, firstUrl });
864
+ if (loaded.firstUrl !== firstUrl) {
865
+ setLoaded({ count: 1, firstUrl });
866
+ }
867
+ const count = loaded.firstUrl === firstUrl ? loaded.count : 1;
868
+ const urls = Array.from({ length: count }, (_, index) => {
869
+ const { options: readOptions, reference } = page(index)[LIVE_QUERY];
870
+ const url = store.readKey(reference, readOptions);
871
+ store.bind(url, () => reference.load(readOptions), reference.client);
872
+ return url;
873
+ });
874
+ const key = urls.join(`
875
+ `);
876
+ const subscribe = useCallback((listener) => {
877
+ const unsubscribes = key.split(`
878
+ `).map((url) => store.subscribe(url, listener));
879
+ return () => {
880
+ for (const unsubscribe of unsubscribes) {
881
+ unsubscribe();
882
+ }
883
+ };
884
+ }, [store, key]);
885
+ useSyncExternalStore(subscribe, store.revision, store.revision);
886
+ useEffect(() => {
887
+ for (const url of key.split(`
888
+ `)) {
889
+ store.fetch(url);
890
+ }
891
+ }, [store, key]);
892
+ const snapshots = urls.map((url) => store.snapshot(url));
893
+ const pages = [];
894
+ for (const entry of snapshots) {
895
+ if (entry.data === undefined) {
896
+ break;
897
+ }
898
+ pages.push(entry.data);
899
+ }
900
+ const last = pages.at(-1);
901
+ const hasNext = pages.length === count && last !== undefined && options.next(last);
902
+ const fetchNext = () => {
903
+ const failed = urls.filter((_, index) => snapshots[index]?.error !== null);
904
+ if (failed.length > 0) {
905
+ for (const url of failed) {
906
+ store.fetch(url);
907
+ }
908
+ } else if (hasNext) {
909
+ setLoaded((previous) => previous.firstUrl === firstUrl && previous.count === count ? { count: count + 1, firstUrl } : previous);
910
+ }
911
+ };
912
+ return {
913
+ error: snapshots.find((entry) => entry.error !== null)?.error ?? null,
914
+ fetchNext,
915
+ hasNext,
916
+ isFetching: snapshots.some((entry) => entry.isFetching),
917
+ pages
918
+ };
919
+ }
857
920
 
858
921
  // src/client/route-api.tsx
859
922
  import { createContext as createContext3, createElement as createElement2, useContext as useContext3 } from "react";
@@ -1032,4 +1095,4 @@ function createSyncCatchUp(options) {
1032
1095
  };
1033
1096
  }
1034
1097
 
1035
- export { DocumentProvider2, useDocumentState, HeadContent2, Scripts2, FurinDocumentFallback, createRequestId, mergeQuerySeeds, queryTag, queryTags, LIVE_QUERY, currentQueryEnvironment, QueryStore, SYNC_REQUEST, registerOptimisticRuntime, findOptimisticRuntime, createOptimisticRuntime, QueryStoreContext, useQuery2, withRouteSnapshot, getRouteApi2, isAbortError, createInvalidationRefresh, createSyncCatchUp };
1098
+ export { DocumentProvider2, useDocumentState, HeadContent2, Scripts2, FurinDocumentFallback, createRequestId, mergeQuerySeeds, queryTag, queryTags, LIVE_QUERY, currentQueryEnvironment, QueryStore, SYNC_REQUEST, registerOptimisticRuntime, findOptimisticRuntime, createOptimisticRuntime, QueryStoreContext, useQuery2, useInfiniteQuery2, withRouteSnapshot, getRouteApi2, isAbortError, createInvalidationRefresh, createSyncCatchUp };
@@ -240,6 +240,18 @@ function resolveRouteTarget(target, routes) {
240
240
  const path = applyLinkParams(target.to, target.params);
241
241
  return buildHref2(path, target.search, target.hash, findSearchDefaultsForRouteTarget(path, routes));
242
242
  }
243
+ function resolveTargetSearch(path, search, routes) {
244
+ if (path.includes("?")) {
245
+ return;
246
+ }
247
+ const resolved = { ...findSearchDefaultsForRouteTarget(path, routes) };
248
+ for (const [key, value] of Object.entries(search ?? {})) {
249
+ if (value !== null && value !== undefined) {
250
+ resolved[key] = value;
251
+ }
252
+ }
253
+ return resolved;
254
+ }
243
255
  function buildHref2(to, search, hash, searchDefaults) {
244
256
  let url = to;
245
257
  if (search && Object.keys(search).length > 0) {
@@ -333,4 +345,4 @@ function toLogical2(physicalPathname, basePath) {
333
345
  return physicalPathname;
334
346
  }
335
347
 
336
- export { physicalPath, isWithinPrefix, encodeInvalidationEntry, findSearchDefaultsForRouteTarget, TRAILING_SLASHES_RE, navigationHrefPolicy, decodeHashFragment, isSameOriginFetchResult, applyLinkParams, resolveRouteTarget, buildHref2, applyRevalidateHeader2, applyRevalidateEntries, shouldAutoRefreshPath2, stripHashFromHref, normalizeHref2, shouldRefetch2, shouldInterceptClick2, toLogical2 };
348
+ export { physicalPath, isWithinPrefix, encodeInvalidationEntry, deepEqual, findSearchDefaultsForRouteTarget, TRAILING_SLASHES_RE, navigationHrefPolicy, decodeHashFragment, isSameOriginFetchResult, applyLinkParams, resolveRouteTarget, resolveTargetSearch, buildHref2, applyRevalidateHeader2, applyRevalidateEntries, shouldAutoRefreshPath2, stripHashFromHref, normalizeHref2, shouldRefetch2, shouldInterceptClick2, toLogical2 };
@@ -1,6 +1,7 @@
1
1
  import type { ErrorComponent } from "../shared/error.ts";
2
2
  import type { NotFoundComponent } from "../shared/not-found.ts";
3
3
  import type { RemountDeps } from "../shared/page-key.ts";
4
+ import type { PendingComponent, PendingOptions, RoutePending } from "../shared/pending.ts";
4
5
  type ClientComponent = (props: never) => React.ReactNode;
5
6
  interface ClientRuntimeProps {
6
7
  children?: React.ReactNode;
@@ -10,9 +11,11 @@ interface ClientRuntimeProps {
10
11
  [key: string]: unknown;
11
12
  }
12
13
  type ClientRuntimeComponent = (props: ClientRuntimeProps) => React.ReactNode;
14
+ type LoaderDeps = (query: never) => object;
13
15
  /** The file id of `defineRoute(id)` is type-only: the client ignores it. */
14
16
  export declare function defineRoute(_id: string): {
15
17
  config(options: {
18
+ loaderDeps?: LoaderDeps;
16
19
  remountDeps?: RemountDeps<never, never>;
17
20
  }): /*elided*/ any;
18
21
  error(component: ErrorComponent): /*elided*/ any;
@@ -22,20 +25,25 @@ export declare function defineRoute(_id: string): {
22
25
  errorComponent: ErrorComponent | undefined;
23
26
  layout: ClientRuntimeComponent;
24
27
  notFoundComponent: NotFoundComponent | undefined;
28
+ pending: RoutePending | undefined;
25
29
  };
26
30
  notFound(component: NotFoundComponent): /*elided*/ any;
31
+ pending(component: PendingComponent, options?: PendingOptions): /*elided*/ any;
27
32
  page<Component extends ClientComponent>(component: Component): {
28
33
  __type: "FURIN_ROUTE";
29
34
  component: ClientRuntimeComponent;
30
35
  errorComponent: ErrorComponent | undefined;
36
+ loaderDeps: LoaderDeps | undefined;
31
37
  notFoundComponent: NotFoundComponent | undefined;
32
38
  page: ClientRuntimeComponent;
39
+ pending: RoutePending | undefined;
33
40
  remountDeps: RemountDeps<never, never> | undefined;
34
41
  };
35
42
  };
36
43
  /** Client stub for the root-layout builder — identical surface. */
37
44
  export declare function defineRootRoute(): {
38
45
  config(options: {
46
+ loaderDeps?: LoaderDeps;
39
47
  remountDeps?: RemountDeps<never, never>;
40
48
  }): /*elided*/ any;
41
49
  error(component: ErrorComponent): /*elided*/ any;
@@ -45,14 +53,18 @@ export declare function defineRootRoute(): {
45
53
  errorComponent: ErrorComponent | undefined;
46
54
  layout: ClientRuntimeComponent;
47
55
  notFoundComponent: NotFoundComponent | undefined;
56
+ pending: RoutePending | undefined;
48
57
  };
49
58
  notFound(component: NotFoundComponent): /*elided*/ any;
59
+ pending(component: PendingComponent, options?: PendingOptions): /*elided*/ any;
50
60
  page<Component extends ClientComponent>(component: Component): {
51
61
  __type: "FURIN_ROUTE";
52
62
  component: ClientRuntimeComponent;
53
63
  errorComponent: ErrorComponent | undefined;
64
+ loaderDeps: LoaderDeps | undefined;
54
65
  notFoundComponent: NotFoundComponent | undefined;
55
66
  page: ClientRuntimeComponent;
67
+ pending: RoutePending | undefined;
56
68
  remountDeps: RemountDeps<never, never> | undefined;
57
69
  };
58
70
  };