@teyik0/furin 0.9.0-alpha.2 → 0.9.0-alpha.4

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.
package/dist/cli/index.js CHANGED
@@ -1748,7 +1748,7 @@ import { writeFileSync as writeFileSync2 } from "fs";
1748
1748
  import { join as join6 } from "path";
1749
1749
 
1750
1750
  // src/plugin/route-registry.ts
1751
- import { dirname as dirname5, join as join5, resolve as resolve2 } from "path";
1751
+ import { join as join5, resolve as resolve2 } from "path";
1752
1752
 
1753
1753
  // src/plugin/route-modules.ts
1754
1754
  import { existsSync as existsSync5, readFileSync, realpathSync, statSync } from "fs";
@@ -2238,7 +2238,6 @@ var ROUTES_REGISTRY_SPECIFIER = "furin/routes?registry";
2238
2238
  var COMPOSABLE_ROUTES_REGISTRY_SPECIFIER = "furin/routes?registry=composable";
2239
2239
  var ROUTES_REGISTRY_FILTER = /^furin\/routes\?registry(?:=composable)?$/;
2240
2240
  var ROUTE_FILE_FILTER = /^furin-route-file:.+$/;
2241
- var ROUTE_FILES_NAMESPACE = "furin-route-files";
2242
2241
  var ROUTES_REGISTRY_FILE_FILTER = /[\\/]\.furin-routes-registry(?:-composable)?\.ts\?furin-virtual$/;
2243
2242
  var CLIENT_ROUTES_NAMESPACE = "furin-routes-client";
2244
2243
  var CLIENT_ROUTES_FILTER = /^(?:@teyik0\/furin|furin)\/routes$/;
@@ -2370,7 +2369,6 @@ function serverProxySource(instance, includeRootCatchAll) {
2370
2369
  }
2371
2370
  function createRoutesPlugin(options) {
2372
2371
  const routeFilesBySpecifier = new Map;
2373
- const routeFilesByResolvedPath = new Map;
2374
2372
  const registryVirtualPath = join5(resolve2(primaryInstance(options.instances).pagesDir), ".furin-routes-registry.ts?furin-virtual");
2375
2373
  const composableRegistryVirtualPath = join5(resolve2(primaryInstance(options.instances).pagesDir), ".furin-routes-registry-composable.ts?furin-virtual");
2376
2374
  const instancesBySpecifier = new Map(options.instances.flatMap((instance) => [
@@ -2422,20 +2420,7 @@ function createRoutesPlugin(options) {
2422
2420
  if (!routeFile) {
2423
2421
  throw new Error(`[furin] Unknown route module: ${path}`);
2424
2422
  }
2425
- const resolvedPath = routeFile.sourcePath;
2426
- routeFilesByResolvedPath.set(resolvedPath, routeFile);
2427
- return { namespace: ROUTE_FILES_NAMESPACE, path: resolvedPath };
2428
- });
2429
- build.onLoad({ filter: VIRTUAL_ROUTES_FILTER, namespace: ROUTE_FILES_NAMESPACE }, async ({ path }) => {
2430
- const routeFile = routeFilesByResolvedPath.get(path);
2431
- if (!routeFile) {
2432
- throw new Error(`[furin] Unknown route module: ${path}`);
2433
- }
2434
- return {
2435
- contents: await Bun.file(routeFile.sourcePath).text(),
2436
- loader: detectLoaderFromPath(routeFile.sourcePath),
2437
- resolveDir: dirname5(routeFile.sourcePath)
2438
- };
2423
+ return { path: routeFile.sourcePath };
2439
2424
  });
2440
2425
  for (const { instance, namespace, includeRootCatchAll } of instancesBySpecifier.values()) {
2441
2426
  build.onLoad({ filter: VIRTUAL_ROUTES_FILTER, namespace }, () => ({
@@ -5342,7 +5327,7 @@ function pruneOrphanedCode(module, forced, retained) {
5342
5327
 
5343
5328
  // src/plugin/transform-client-module.ts
5344
5329
  import { realpathSync as realpathSync2 } from "fs";
5345
- import { dirname as dirname6 } from "path";
5330
+ import { dirname as dirname5 } from "path";
5346
5331
  var FURIN_CLIENT_MODULES = new Set(["@teyik0/furin/client", "furin/client"]);
5347
5332
  var SERVER_LOAD = '() => Promise.reject(new Error("[furin] clientModule() can only be loaded in the browser."))';
5348
5333
  function clientModuleKey(modulePath) {
@@ -5397,7 +5382,7 @@ function rewriteClientModules(module, environment) {
5397
5382
  }
5398
5383
  let key;
5399
5384
  try {
5400
- key = JSON.stringify(clientModuleKey(Bun.resolveSync(specifier, dirname6(filename))));
5385
+ key = JSON.stringify(clientModuleKey(Bun.resolveSync(specifier, dirname5(filename))));
5401
5386
  } catch (error) {
5402
5387
  throw new Error(`[furin] Cannot resolve clientModule import ${JSON.stringify(specifier)} in ${filename}`, { cause: error });
5403
5388
  }
@@ -5864,7 +5849,7 @@ function assertInstalledRscVersions() {
5864
5849
  }
5865
5850
 
5866
5851
  // src/rsc/build/client-references.ts
5867
- import { dirname as dirname8 } from "path";
5852
+ import { dirname as dirname7 } from "path";
5868
5853
 
5869
5854
  // ../../node_modules/.bun/cjs-module-lexer@2.3.0/node_modules/cjs-module-lexer/dist/lexer.mjs
5870
5855
  var A;
@@ -6049,9 +6034,9 @@ function initSync() {
6049
6034
  import { readFileSync as readFileSync2 } from "fs";
6050
6035
 
6051
6036
  // src/rsc/build/paths.ts
6052
- import { dirname as dirname7, join as join7 } from "path";
6037
+ import { dirname as dirname6, join as join7 } from "path";
6053
6038
  import { fileURLToPath as fileURLToPath3 } from "url";
6054
- var SOURCE_DIR = dirname7(fileURLToPath3(import.meta.resolve("@teyik0/furin/rsc")));
6039
+ var SOURCE_DIR = dirname6(fileURLToPath3(import.meta.resolve("@teyik0/furin/rsc")));
6055
6040
  var CLIENT_REFERENCE_RUNTIME_PATH = join7(SOURCE_DIR, "rsc/client-references.ts");
6056
6041
  var BUNDLED_CLIENT_CODEC_PATH = join7(SOURCE_DIR, "rsc/bundled-client-codec.ts");
6057
6042
 
@@ -6174,7 +6159,7 @@ function clientReferencesPlugin(references) {
6174
6159
  contents: isCommonJsModule(source, sourcePath) ? source : `${source}
6175
6160
  ${clientRegistration(sourcePath, path, prefix, references)}`,
6176
6161
  loader: detectLoaderFromPath(sourcePath),
6177
- resolveDir: dirname8(sourcePath)
6162
+ resolveDir: dirname7(sourcePath)
6178
6163
  };
6179
6164
  });
6180
6165
  build.onLoad({ filter: SCRIPTS }, async ({ path }) => {
@@ -6191,7 +6176,7 @@ registerClientModule(${JSON.stringify(clientModuleId(path))}, implementation);`
6191
6176
  export * from ${JSON.stringify(path + IMPLEMENTATION)};
6192
6177
  ${names.length > 0 ? `export { ${names.map((name) => JSON.stringify(name)).join(", ")} } from ${JSON.stringify(path + IMPLEMENTATION)};` : ""}`,
6193
6178
  loader: "js",
6194
- resolveDir: dirname8(path)
6179
+ resolveDir: dirname7(path)
6195
6180
  };
6196
6181
  });
6197
6182
  }
@@ -6230,7 +6215,7 @@ async function exportedNames(source, path, visited) {
6230
6215
  }
6231
6216
  }
6232
6217
  for (const specifier of reexports) {
6233
- const dependency = Bun.resolveSync(specifier, dirname8(path));
6218
+ const dependency = Bun.resolveSync(specifier, dirname7(path));
6234
6219
  const exported = await exportedNames(await Bun.file(dependency).text(), dependency, visited);
6235
6220
  for (const name of exported) {
6236
6221
  if (name !== "default") {
@@ -6446,20 +6431,20 @@ function exportStaticFromBundle(path, cwd, options) {
6446
6431
  // src/adapter/runtime-build.ts
6447
6432
  import { existsSync as existsSync10, realpathSync as realpathSync4, writeFileSync as writeFileSync6 } from "fs";
6448
6433
  import { createRequire } from "module";
6449
- import { dirname as dirname12, isAbsolute as isAbsolute5, join as join12, relative as relative5, resolve as resolve7 } from "path";
6434
+ import { dirname as dirname11, isAbsolute as isAbsolute5, join as join12, relative as relative5, resolve as resolve7 } from "path";
6450
6435
  import { fileURLToPath as fileURLToPath7 } from "url";
6451
6436
 
6452
6437
  // src/build/client.ts
6453
6438
  import { existsSync as existsSync9, mkdirSync as mkdirSync3 } from "fs";
6454
- import { basename as basename4, dirname as dirname11, join as join11, sep as sep2 } from "path";
6439
+ import { basename as basename4, dirname as dirname10, join as join11, sep as sep2 } from "path";
6455
6440
  import { fileURLToPath as fileURLToPath6 } from "url";
6456
6441
 
6457
6442
  // src/plugin/client-plugin.ts
6458
- import { dirname as dirname10, isAbsolute as isAbsolute4, resolve as resolve4 } from "path";
6443
+ import { dirname as dirname9, isAbsolute as isAbsolute4, resolve as resolve4 } from "path";
6459
6444
 
6460
6445
  // src/plugin/hmr-dependencies.ts
6461
6446
  import { readFileSync as readFileSync4 } from "fs";
6462
- import { dirname as dirname9, isAbsolute as isAbsolute3, resolve as resolve3 } from "path";
6447
+ import { dirname as dirname8, isAbsolute as isAbsolute3, resolve as resolve3 } from "path";
6463
6448
  function hmrDependencySignature(imports, filename) {
6464
6449
  const routePath = resolve3(filename);
6465
6450
  const visited = new Set;
@@ -6468,7 +6453,7 @@ function hmrDependencySignature(imports, filename) {
6468
6453
  if (specifier === "furin" || specifier.startsWith("furin/") || specifier === "@teyik0/furin" || specifier.startsWith("@teyik0/furin/")) {
6469
6454
  return true;
6470
6455
  }
6471
- const path = Bun.resolveSync(specifier, dirname9(importer));
6456
+ const path = Bun.resolveSync(specifier, dirname8(importer));
6472
6457
  if (path === routePath) {
6473
6458
  return false;
6474
6459
  }
@@ -7332,11 +7317,12 @@ function stripServerCode(path, source) {
7332
7317
  var ELYSIA_FILTER = /^elysia$/;
7333
7318
  var BUN_BUILTIN_FILTER = /^bun:/;
7334
7319
  var ANY_FILTER = /.*/;
7335
- var ELYSIA_STUB = `export const t = new Proxy({}, { get: () => (...args) => args[0] ?? {} });
7320
+ var elysiaStub = (typeModule) => `export * as t from ${JSON.stringify(typeModule)};
7336
7321
  export class NotFoundError extends Error { constructor(m) { super(m); this.name = "NotFoundError"; } }
7337
7322
  export class ValidationError extends Error { constructor(m) { super(m); this.name = "ValidationError"; } }
7338
7323
  export default {};
7339
7324
  `;
7325
+ var ELYSIA_STUB_PREFIX = "elysia-stub:";
7340
7326
  function trackHydrationTopology(filePath, source, topologyPaths) {
7341
7327
  const normalizedPath = filePath.replaceAll("\\", "/");
7342
7328
  if (!(normalizedPath.includes("/.furin/") && normalizedPath.endsWith("/_hydrate.tsx"))) {
@@ -7345,7 +7331,7 @@ function trackHydrationTopology(filePath, source, topologyPaths) {
7345
7331
  const transpiler = new Bun.Transpiler({ loader: "tsx" });
7346
7332
  for (const imported of transpiler.scanImports(source)) {
7347
7333
  if (isAbsolute4(imported.path) || imported.path.startsWith(".")) {
7348
- topologyPaths.add(resolve4(dirname10(filePath), imported.path.split("?")[0]));
7334
+ topologyPaths.add(resolve4(dirname9(filePath), imported.path.split("?")[0]));
7349
7335
  }
7350
7336
  }
7351
7337
  }
@@ -7374,16 +7360,16 @@ function createClientStripPlugin({ mode }) {
7374
7360
  environmentGuardPlugin("client").setup(build);
7375
7361
  const topologyPaths = new Set;
7376
7362
  const loadedSources = new Map;
7377
- build.onResolve({ filter: ELYSIA_FILTER }, () => ({
7363
+ build.onResolve({ filter: ELYSIA_FILTER }, (args) => ({
7378
7364
  namespace: "furin-stubs",
7379
- path: "elysia-stub"
7365
+ path: ELYSIA_STUB_PREFIX + Bun.resolveSync("elysia/type", args.resolveDir)
7380
7366
  }));
7381
7367
  build.onResolve({ filter: BUN_BUILTIN_FILTER }, () => ({
7382
7368
  namespace: "furin-stubs",
7383
7369
  path: "bun-builtin-stub"
7384
7370
  }));
7385
7371
  build.onLoad({ filter: ANY_FILTER, namespace: "furin-stubs" }, (args) => ({
7386
- contents: args.path === "elysia-stub" ? ELYSIA_STUB : "",
7372
+ contents: args.path.startsWith(ELYSIA_STUB_PREFIX) ? elysiaStub(args.path.slice(ELYSIA_STUB_PREFIX.length)) : "",
7387
7373
  loader: "js"
7388
7374
  }));
7389
7375
  build.onLoad({ filter: SCRIPT_FILE_FILTER }, async (args) => {
@@ -8037,6 +8023,7 @@ if (__deferred && __deferred._chunks) {
8037
8023
  // with the server (stale deploy) or the server returned something we
8038
8024
  // don't know how to hydrate. Bail loudly; the page stays static.
8039
8025
  log.error({ action: "hydrate_no_match", pathname });
8026
+ if (import.meta.hot) throw new Error(\`[furin] No client route matches \${pathname}; the page stays static.\`);
8040
8027
  return;
8041
8028
  }
8042
8029
  app = createElement(DocumentProvider, { value: documentState }, app);
@@ -8103,6 +8090,7 @@ if (__deferred && __deferred._chunks) {
8103
8090
  log.info({ action: "hydrate_complete", pathname });
8104
8091
  })().catch((err: unknown) => {
8105
8092
  log.error({ action: "hydrate_failed", pathname, error: String(err) });
8093
+ if (import.meta.hot) console.error("[furin] Hydration failed:", err);
8106
8094
  window.dispatchEvent(
8107
8095
  new CustomEvent("furin:client-error", { detail: { error: err, phase: "hydrate" } })
8108
8096
  );
@@ -8167,7 +8155,7 @@ function writeClientPreloadManifest(metafile, outputPaths, entryChunkPath, route
8167
8155
  }
8168
8156
 
8169
8157
  // src/build/client.ts
8170
- var CLIENT_DIST_DIR = `${join11(dirname11(dirname11(fileURLToPath6(import.meta.resolve("@teyik0/furin")))), "dist")}${sep2}`;
8158
+ var CLIENT_DIST_DIR = `${join11(dirname10(dirname10(fileURLToPath6(import.meta.resolve("@teyik0/furin")))), "dist")}${sep2}`;
8171
8159
  async function buildClient(routes, {
8172
8160
  outDir,
8173
8161
  rootLayout,
@@ -8270,7 +8258,7 @@ async function buildClient(routes, {
8270
8258
  }
8271
8259
 
8272
8260
  // src/adapter/runtime-build.ts
8273
- var _pkgRoot2 = dirname12(dirname12(fileURLToPath7(import.meta.resolve("@teyik0/furin"))));
8261
+ var _pkgRoot2 = dirname11(dirname11(fileURLToPath7(import.meta.resolve("@teyik0/furin"))));
8274
8262
  var _pkgSrcDir2 = existsSync10(join12(_pkgRoot2, "src", "furin.ts")) ? join12(_pkgRoot2, "src") : join12(_pkgRoot2, "dist");
8275
8263
  var _ext2 = ".ts";
8276
8264
  function frameworkSourceModule(path) {
@@ -8332,7 +8320,7 @@ function nearestFingerprintFile(directory, names, boundary) {
8332
8320
  return path;
8333
8321
  }
8334
8322
  }
8335
- const parent = dirname12(current);
8323
+ const parent = dirname11(current);
8336
8324
  current = parent === current || current === boundary ? undefined : parent;
8337
8325
  }
8338
8326
  return;
@@ -8387,7 +8375,7 @@ async function createBuildFingerprint(entryChunk, cssChunks, routes, root, serve
8387
8375
  }
8388
8376
  const relativePath = toPosixPath(relative5(rootBoundary, path));
8389
8377
  const manifestBoundary = relativePath === ".." || relativePath.startsWith("../") || isAbsolute5(relativePath) ? undefined : rootBoundary;
8390
- const manifest = nearestFingerprintFile(dirname12(path), ["package.json"], manifestBoundary);
8378
+ const manifest = nearestFingerprintFile(dirname11(path), ["package.json"], manifestBoundary);
8391
8379
  if (manifest) {
8392
8380
  fingerprintPaths.add(manifest);
8393
8381
  await visit(manifest);
@@ -8396,7 +8384,7 @@ async function createBuildFingerprint(entryChunk, cssChunks, routes, root, serve
8396
8384
  await Promise.all(transpiler.scanImports(content).flatMap(({ path: specifier, kind }) => {
8397
8385
  let dependency;
8398
8386
  try {
8399
- dependency = kind === "require-call" || kind === "require-resolve" ? createRequire(path).resolve(specifier) : Bun.resolveSync(specifier, dirname12(path));
8387
+ dependency = kind === "require-call" || kind === "require-resolve" ? createRequire(path).resolve(specifier) : Bun.resolveSync(specifier, dirname11(path));
8400
8388
  } catch {
8401
8389
  return [];
8402
8390
  }
@@ -8480,7 +8468,7 @@ function pprRuntimePlugin(apps) {
8480
8468
  return;
8481
8469
  }
8482
8470
  build.onResolve({ filter: PPR_ROUTE_IMPORT_RE }, ({ path, importer }) => {
8483
- const absolute = resolve7(dirname12(importer.split("?")[0]), path);
8471
+ const absolute = resolve7(dirname11(importer.split("?")[0]), path);
8484
8472
  if (absolute !== pprPath && `${absolute}.ts` !== pprPath) {
8485
8473
  return;
8486
8474
  }
@@ -8506,7 +8494,7 @@ function mixedRuntimePlugin(apps) {
8506
8494
  return;
8507
8495
  }
8508
8496
  build.onResolve({ filter: MIXED_CACHE_IMPORT_RE }, ({ path, importer }) => {
8509
- const absolute = resolve7(dirname12(importer.split("?")[0]), path);
8497
+ const absolute = resolve7(dirname11(importer.split("?")[0]), path);
8510
8498
  if (absolute !== mixedPath && `${absolute}.ts` !== mixedPath) {
8511
8499
  return;
8512
8500
  }
@@ -8536,7 +8524,7 @@ async function buildRuntimeApp(app, projectRoot, targetDir, serverEntry, options
8536
8524
  basePath: prefix,
8537
8525
  clientDirName,
8538
8526
  clientLogging: options.clientLogging ?? false,
8539
- metafilePath: options.analyze ? join12(dirname12(targetDir), "analysis", `${targetName}-${clientDirName}.json`) : undefined,
8527
+ metafilePath: options.analyze ? join12(dirname11(targetDir), "analysis", `${targetName}-${clientDirName}.json`) : undefined,
8540
8528
  optimizeImports: options.optimizeImports,
8541
8529
  outDir: targetDir,
8542
8530
  pages: { pagesDir: app.pagesDir, style: app.style },
@@ -8579,16 +8567,16 @@ ${entryChunk}`, cssChunks, routes, root, serverEntry, modulePaths, projectRoot);
8579
8567
  }
8580
8568
 
8581
8569
  // src/adapter/server-bundle.ts
8582
- import { dirname as dirname15, relative as relative8 } from "path";
8570
+ import { dirname as dirname14, relative as relative8 } from "path";
8583
8571
 
8584
8572
  // src/build/elysia-aot.ts
8585
8573
  import { fork } from "child_process";
8586
8574
  import { existsSync as existsSync11, realpathSync as realpathSync5 } from "fs";
8587
- import { dirname as dirname13, join as join13, relative as relative6, resolve as resolve8 } from "path";
8575
+ import { dirname as dirname12, join as join13, relative as relative6, resolve as resolve8 } from "path";
8588
8576
  import { fileURLToPath as fileURLToPath8 } from "url";
8589
8577
  var AOT_NAMESPACE = "furin-elysia-aot";
8590
- var ELYSIA_RESOLVE_DIR = dirname13(Bun.resolveSync("elysia", import.meta.dir));
8591
- var AOT_PROCESS_PATH = join13(dirname13(dirname13(fileURLToPath8(import.meta.resolve("@teyik0/furin")))), "src/build/elysia-aot-worker.ts");
8578
+ var ELYSIA_RESOLVE_DIR = dirname12(Bun.resolveSync("elysia", import.meta.dir));
8579
+ var AOT_PROCESS_PATH = join13(dirname12(dirname12(fileURLToPath8(import.meta.resolve("@teyik0/furin")))), "src/build/elysia-aot-worker.ts");
8592
8580
  var SOURCE_FILTER = /\.[cm]?[jt]sx?$/;
8593
8581
  var ELYSIA_IMPORT_FILTER = /^elysia(?:\/(?!compiled$|type$).*)?$/;
8594
8582
  var ELYSIA_VIRTUAL_IMPORT_FILTER = /^elysia\/(?:compiled|type)$/;
@@ -8782,7 +8770,7 @@ function elysiaAot(entry, expected) {
8782
8770
  }
8783
8771
 
8784
8772
  // src/build/production-instrumentation.ts
8785
- import { dirname as dirname14, relative as relative7, resolve as resolve9 } from "path";
8773
+ import { dirname as dirname13, relative as relative7, resolve as resolve9 } from "path";
8786
8774
  var INSTRUMENTATION_IMPORT = /(?:^|[/\\])devtools[/\\]instrumentation(?:\.ts|\.js)?$/;
8787
8775
  var DEV_PAGE_PLUGIN_IMPORT = /(?:^|[/\\])server[/\\]dev-page-plugin(?:\.ts|\.js)?$/;
8788
8776
  var DEV_RUNTIME_IMPORT = /(?:^|[/\\])server[/\\]dev[/\\](?:browser-events|diagnostics|graph|plugin|runtime)(?:\.ts|\.js)?$/;
@@ -8809,7 +8797,7 @@ function productionInstrumentationPlugin() {
8809
8797
  name: "furin-production-instrumentation",
8810
8798
  setup(build) {
8811
8799
  build.onResolve({ filter: PRODUCTION_BOUNDARY_IMPORT }, (args) => {
8812
- const importPath = resolve9(dirname14(args.importer), args.path);
8800
+ const importPath = resolve9(dirname13(args.importer), args.path);
8813
8801
  if (!isFurinRuntimePath(importPath)) {
8814
8802
  return;
8815
8803
  }
@@ -8845,7 +8833,7 @@ var PRERENDER_SNAPSHOT_RE = /^\.\/furin-prerender\.json$/;
8845
8833
  var ELYSIA_STATIC_IMPORT_RE = /^@elysia\/static$/;
8846
8834
  var MATCH_ALL_RE = /.*/;
8847
8835
  var STATIC_STUB_NAMESPACE = "furin-platform-assets-stub";
8848
- var FURIN_RUNTIME_ROOT2 = dirname15(import.meta.dir);
8836
+ var FURIN_RUNTIME_ROOT2 = dirname14(import.meta.dir);
8849
8837
  function isFurinRuntimeImporter(importer) {
8850
8838
  if (importer === "") {
8851
8839
  return false;
@@ -9278,7 +9266,7 @@ export declare const prefix: string;
9278
9266
 
9279
9267
  // src/adapter/static.ts
9280
9268
  import { cpSync as cpSync2, existsSync as existsSync15, rmSync as rmSync6, writeFileSync as writeFileSync9 } from "fs";
9281
- import { dirname as dirname16, isAbsolute as isAbsolute6, join as join17, parse as parse3, relative as relative12, resolve as resolve11, sep as sep3, win32 } from "path";
9269
+ import { dirname as dirname15, isAbsolute as isAbsolute6, join as join17, parse as parse3, relative as relative12, resolve as resolve11, sep as sep3, win32 } from "path";
9282
9270
  var TRAILING_SLASHES_RE = /\/+$/;
9283
9271
  var STATIC_RENDER_ORIGIN = "http://localhost";
9284
9272
  function pathToOutputFile(urlPath, outDir, fileName) {
@@ -9403,7 +9391,7 @@ async function collectStaticOutputs(exported, outDir, basePath, onSSR, skippedRo
9403
9391
  return outputs;
9404
9392
  }
9405
9393
  function writeStaticOutput(output) {
9406
- ensureDir(dirname16(output.htmlFile));
9394
+ ensureDir(dirname15(output.htmlFile));
9407
9395
  writeFileSync9(output.htmlFile, output.html);
9408
9396
  if (output.data !== null) {
9409
9397
  writeFileSync9(output.dataFile, output.data);
@@ -9602,7 +9590,7 @@ import {
9602
9590
  symlinkSync,
9603
9591
  writeFileSync as writeFileSync10
9604
9592
  } from "fs";
9605
- import { basename as basename6, dirname as dirname17, join as join18, relative as relative13 } from "path";
9593
+ import { basename as basename6, dirname as dirname16, join as join18, relative as relative13 } from "path";
9606
9594
  import { fileURLToPath as fileURLToPath9, pathToFileURL as pathToFileURL3 } from "url";
9607
9595
 
9608
9596
  // src/adapter/vercel/data.ts
@@ -9647,7 +9635,7 @@ function assertRegions(regions) {
9647
9635
  }
9648
9636
  }
9649
9637
  function frameworkVersion() {
9650
- const packageRoot = dirname17(dirname17(fileURLToPath9(import.meta.resolve("@teyik0/furin"))));
9638
+ const packageRoot = dirname16(dirname16(fileURLToPath9(import.meta.resolve("@teyik0/furin"))));
9651
9639
  const packageJson = JSON.parse(readFileSync8(join18(packageRoot, "package.json"), "utf8"));
9652
9640
  return packageJson.version;
9653
9641
  }
@@ -9788,8 +9776,8 @@ async function addPrerenderFallback(job, response, functionsDir) {
9788
9776
  const { spec } = job;
9789
9777
  const fallback = `${basename6(spec.functionName)}.prerender-fallback.html`;
9790
9778
  const location = response.headers.get("location") ?? undefined;
9791
- const fallbackPath = join18(dirname17(join18(functionsDir, spec.functionName)), fallback);
9792
- ensureDir(dirname17(fallbackPath));
9779
+ const fallbackPath = join18(dirname16(join18(functionsDir, spec.functionName)), fallback);
9780
+ ensureDir(dirname16(fallbackPath));
9793
9781
  writeFileSync10(fallbackPath, await response.text());
9794
9782
  spec.config.fallback = fallback;
9795
9783
  spec.config.initialHeaders = {
@@ -9863,8 +9851,8 @@ async function buildBootstrap(serverFunctionDir) {
9863
9851
  }
9864
9852
  function createFunctionAlias(functionsDir, serverFunctionDir, functionName) {
9865
9853
  const aliasPath = join18(functionsDir, `${functionName}.func`);
9866
- ensureDir(dirname17(aliasPath));
9867
- const target = relative13(dirname17(aliasPath), serverFunctionDir);
9854
+ ensureDir(dirname16(aliasPath));
9855
+ const target = relative13(dirname16(aliasPath), serverFunctionDir);
9868
9856
  symlinkSync(target, aliasPath, process.platform === "win32" ? "junction" : "dir");
9869
9857
  }
9870
9858
  function copyStaticAssets(output, staticDir) {
@@ -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 };
@@ -186,6 +186,24 @@ window.addEventListener("furin:client-error", (event) => {
186
186
  reportClientError(detail).catch(() => undefined);
187
187
  });
188
188
 
189
+ // A module evaluation error (a bundle SyntaxError, a top-level throw in an
190
+ // imported module) stops the hydrate entry before its catch exists. The dev
191
+ // bundle holds the entry's static graph, so report errors from that script
192
+ // until the entry mounts its root; afterwards React boundaries and Bun HMR
193
+ // own runtime errors.
194
+ window.addEventListener("error", (event) => {
195
+ if ((window as { __FURIN_ROOT__?: unknown }).__FURIN_ROOT__ !== undefined) {
196
+ return;
197
+ }
198
+ const entry = document.querySelector<HTMLScriptElement>("script[data-furin-entry][src]");
199
+ if (!entry || event.filename !== entry.src) {
200
+ return;
201
+ }
202
+ reportClientError({ error: event.error ?? event.message, phase: "hydrate" }).catch(
203
+ () => undefined
204
+ );
205
+ });
206
+
189
207
  // Retry only failures from before this update, including when reporting is still
190
208
  // in flight or server readiness has already dismissed the overlay.
191
209
  window.addEventListener("furin:hmr-before-update", () => {
@@ -14,7 +14,7 @@ import {
14
14
  isAbortError,
15
15
  createInvalidationRefresh,
16
16
  createSyncCatchUp
17
- } from "./chunks/client-d9v49jwz.js";
17
+ } from "./chunks/client-p0jqzfvc.js";
18
18
  import {
19
19
  restoreRscSource2
20
20
  } from "./chunks/client-k88668k7.js";
@@ -9,4 +9,17 @@ export declare function useQuery<Result extends ReadResult, Selected = LiveData<
9
9
  error: Result["error"] | null;
10
10
  isFetching: boolean;
11
11
  };
12
+ /**
13
+ * Pages are ordinary store entries keyed by their URL: invalidation refetches every loaded page.
14
+ * The hook owns only how many pages are shown; a new first page (changed filters) restarts at one.
15
+ */
16
+ export declare function useInfiniteQuery<Result extends ReadResult>(page: (index: number) => LiveQuery<Result>, options: {
17
+ next: (last: LiveData<Result>) => boolean;
18
+ }): {
19
+ error: Result["error"] | null;
20
+ fetchNext: () => void;
21
+ hasNext: boolean;
22
+ isFetching: boolean;
23
+ pages: LiveData<Result>[];
24
+ };
12
25
  export {};
package/dist/client.d.ts CHANGED
@@ -3,7 +3,7 @@ export { defineRootRoute, defineRoute } from "./client/define-route.ts";
3
3
  export { type DocumentAssets, DocumentProvider, type DocumentState, HeadContent, Scripts, } from "./client/document.tsx";
4
4
  export { type HotComponentRegistry, reconcileHotComponentRegistry, updateHotComponent, } from "./client/hmr.ts";
5
5
  export { useMutation } from "./client/mutation.ts";
6
- export { useQuery } from "./client/query.tsx";
6
+ export { useInfiniteQuery, useQuery } from "./client/query.tsx";
7
7
  export type { LiveQuery } from "./client/query-store.ts";
8
8
  export { getRouteApi } from "./client/route-api.tsx";
9
9
  export { furinSync, type OptimisticCache, type SyncCallOptions } from "./client/sync.ts";
package/dist/client.js CHANGED
@@ -9,9 +9,10 @@ import {
9
9
  SYNC_REQUEST,
10
10
  findOptimisticRuntime,
11
11
  useQuery2,
12
+ useInfiniteQuery2,
12
13
  getRouteApi2,
13
14
  createSyncCatchUp
14
- } from "./client/chunks/client-d9v49jwz.js";
15
+ } from "./client/chunks/client-p0jqzfvc.js";
15
16
 
16
17
  // src/client/client-module.ts
17
18
  import { preloadModule } from "react-dom";
@@ -1340,6 +1341,7 @@ export {
1340
1341
  updateHotComponent,
1341
1342
  useAsyncError,
1342
1343
  useAsyncValue,
1344
+ useInfiniteQuery2 as useInfiniteQuery,
1343
1345
  useMutation,
1344
1346
  useQuery2 as useQuery
1345
1347
  };
package/dist/furin.js CHANGED
@@ -1318,7 +1318,6 @@ class DevGraph {
1318
1318
  #eventSequence = 0;
1319
1319
  #revision = 0;
1320
1320
  #snapshot;
1321
- #sourceGeneration = 0;
1322
1321
  constructor(initialSnapshot) {
1323
1322
  this.#snapshot = initialSnapshot;
1324
1323
  }
@@ -1521,9 +1520,6 @@ class DevGraph {
1521
1520
  }
1522
1521
  }
1523
1522
  }
1524
- invalidateModules() {
1525
- this.#sourceGeneration += 1;
1526
- }
1527
1523
  sourceVersion(path) {
1528
1524
  const modulePath = normalizeModulePath(path);
1529
1525
  const fingerprint = this.#sourceFingerprint(modulePath, new Set);
@@ -1543,9 +1539,9 @@ class DevGraph {
1543
1539
  let ownFingerprint;
1544
1540
  try {
1545
1541
  const stats = statSync(path, { bigint: true });
1546
- ownFingerprint = `${stats.mtimeNs}:${stats.size}:${this.#sourceGeneration}`;
1542
+ ownFingerprint = `${stats.mtimeNs}:${stats.size}`;
1547
1543
  } catch {
1548
- ownFingerprint = `missing:${this.#sourceGeneration}`;
1544
+ ownFingerprint = "missing";
1549
1545
  }
1550
1546
  const dependencies = [...this.#dependencies.get(path) ?? []].toSorted((left, right) => left.localeCompare(right)).map((dependency) => this.#sourceFingerprint(dependency, visited));
1551
1547
  return `${path}:${ownFingerprint}:${dependencies.join(",")}`;
@@ -4579,10 +4575,10 @@ class QueryStore {
4579
4575
  }
4580
4576
  }
4581
4577
  entry.snapshot = { ...entry.snapshot, data };
4578
+ this.revisionValue += 1;
4582
4579
  for (const listener of entry.listeners) {
4583
4580
  listener();
4584
4581
  }
4585
- this.revisionValue += 1;
4586
4582
  for (const listener of this.listeners) {
4587
4583
  listener();
4588
4584
  }
@@ -7951,9 +7947,6 @@ function routeModuleSourceVersion(path) {
7951
7947
  });
7952
7948
  return String(Math.max(...(relevant.length > 0 ? relevant : [current]).map((graph) => Number(graph.sourceVersion(path)))));
7953
7949
  }
7954
- function invalidateRouteModuleSourceVersions() {
7955
- devGraph(undefined).invalidateModules();
7956
- }
7957
7950
  var init_source_version = __esm(() => {
7958
7951
  init_graph();
7959
7952
  init_instance();
@@ -10074,6 +10067,7 @@ import {
10074
10067
  useCallback,
10075
10068
  useContext as useContext2,
10076
10069
  useEffect,
10070
+ useState,
10077
10071
  useSyncExternalStore
10078
10072
  } from "react";
10079
10073
  var QUERY_CONTEXT2, contextGlobal2, QueryStoreContext;
@@ -16962,9 +16956,6 @@ function importStampedRouteModule(path, resolveImport) {
16962
16956
  const stamp = routeModuleSourceVersion(path);
16963
16957
  return devGraph(undefined).importModule(path, stamp, resolveImport);
16964
16958
  }
16965
- function invalidateStampedRouteModules() {
16966
- invalidateRouteModuleSourceVersions();
16967
- }
16968
16959
  function isResolvedRouteModuleCandidate(layoutPath, imported, ctx) {
16969
16960
  if (existsSync6(layoutPath) || ctx?.modules[layoutPath]) {
16970
16961
  return true;
@@ -21433,11 +21424,12 @@ function transformDevSource(raw, filePath, options) {
21433
21424
  for (const graph of developmentGraphs()) {
21434
21425
  graph.clearSourceErrors(filePath);
21435
21426
  }
21427
+ const source = raw.startsWith("#!") ? `//${raw.slice(2)}` : raw;
21436
21428
  try {
21437
21429
  if (!options.renderFragment) {
21438
- recordDevImports(raw, filePath);
21430
+ recordDevImports(source, filePath);
21439
21431
  }
21440
- const server = parseModule(raw, filePath);
21432
+ const server = parseModule(source, filePath);
21441
21433
  for (const statement of server.program.body) {
21442
21434
  if (statement.type === "ImportDeclaration" && statement.specifiers.length === 0 && CSS_IMPORT.test(statement.source.value)) {
21443
21435
  removeRange(server, statement.start, statement.end);
@@ -22886,6 +22878,7 @@ if (__deferred && __deferred._chunks) {
22886
22878
  // with the server (stale deploy) or the server returned something we
22887
22879
  // don't know how to hydrate. Bail loudly; the page stays static.
22888
22880
  log.error({ action: "hydrate_no_match", pathname });
22881
+ if (import.meta.hot) throw new Error(\`[furin] No client route matches \${pathname}; the page stays static.\`);
22889
22882
  return;
22890
22883
  }
22891
22884
  app = createElement(DocumentProvider, { value: documentState }, app);
@@ -22952,6 +22945,7 @@ if (__deferred && __deferred._chunks) {
22952
22945
  log.info({ action: "hydrate_complete", pathname });
22953
22946
  })().catch((err: unknown) => {
22954
22947
  log.error({ action: "hydrate_failed", pathname, error: String(err) });
22948
+ if (import.meta.hot) console.error("[furin] Hydration failed:", err);
22955
22949
  window.dispatchEvent(
22956
22950
  new CustomEvent("furin:client-error", { detail: { error: err, phase: "hydrate" } })
22957
22951
  );
@@ -23626,7 +23620,6 @@ async function createDevRuntime(instance, resolvedPagesDir, style, options) {
23626
23620
  reportRouteConfig();
23627
23621
  const hmrEntry = (await import(join9(furinDir, "index.html"))).default;
23628
23622
  const refreshDevelopmentRoutes = (changedSources) => withInstance(instance, async () => {
23629
- invalidateStampedRouteModules();
23630
23623
  try {
23631
23624
  const previousSnapshot = currentSnapshot();
23632
23625
  const repaired = repairedDevelopmentRoutes(previousSnapshot, changedSources, graph);