@moku-labs/web 2.4.14 → 2.4.15

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.
@@ -2022,12 +2022,6 @@ interface DataState {
2022
2022
  * the fetch settles, on success and on failure, so a failure is never cached.
2023
2023
  */
2024
2024
  pending: Map<string, Promise<unknown | null>>;
2025
- /**
2026
- * The preload bundle fetch while it is in flight (browser, `preload: "all"`).
2027
- * `at()` awaits it before fetching a single file. Never rejects. `null` when no
2028
- * bundle fetch is running.
2029
- */
2030
- bundle: Promise<void> | null;
2031
2025
  /** Cancels the scheduled idle callback or aborts the bundle fetch. `null` when nothing is scheduled. */
2032
2026
  cancelPreload: (() => void) | null;
2033
2027
  }
package/dist/browser.mjs CHANGED
@@ -2408,9 +2408,8 @@ function dataApi(ctx) {
2408
2408
  return {
2409
2409
  /**
2410
2410
  * READ (browser) — fetch (and cache) the persisted data for a page path.
2411
- * Concurrent calls for one path share one in-flight request. While a preload
2412
- * bundle is in flight, it waits for the bundle and fetches the single file
2413
- * only if the bundle did not bring the path.
2411
+ * Concurrent calls for one path share one in-flight request. It never waits
2412
+ * for an in-flight preload bundle: an uncached path is fetched at once.
2414
2413
  * Returns the raw JSON as `unknown`, which the route uses directly as `ctx.data`
2415
2414
  * (no route `.parse()`); returns `null` if the fetch or JSON parse fails (so
2416
2415
  * `spa` can fall back to HTML).
@@ -2424,10 +2423,6 @@ function dataApi(ctx) {
2424
2423
  */
2425
2424
  async at(path) {
2426
2425
  if (ctx.state.cache.has(path)) return ctx.state.cache.get(path);
2427
- if (ctx.state.bundle) {
2428
- await ctx.state.bundle;
2429
- if (ctx.state.cache.has(path)) return ctx.state.cache.get(path);
2430
- }
2431
2426
  const inFlight = ctx.state.pending.get(path);
2432
2427
  if (inFlight) return inFlight;
2433
2428
  const request = fetchAndCache(ctx, path);
@@ -2502,7 +2497,7 @@ const defaultDataConfig = {
2502
2497
  //#region src/plugins/data/preload.ts
2503
2498
  /**
2504
2499
  * Fetches the bundle and caches every path not already cached. Never rejects:
2505
- * a failed fetch leaves lazy `at()` working. Clears the preload slots when done.
2500
+ * a failed fetch leaves lazy `at()` working. Clears `cancelPreload` when done.
2506
2501
  *
2507
2502
  * @param ctx - The data plugin context.
2508
2503
  * @param signal - Aborts the fetch on stop.
@@ -2518,7 +2513,7 @@ async function fill(ctx, signal) {
2518
2513
  const bundle = response.ok ? await response.json() : {};
2519
2514
  for (const [path, data] of Object.entries(bundle)) if (!signal.aborted && !ctx.state.cache.has(path)) ctx.state.cache.set(path, data);
2520
2515
  } catch {} finally {
2521
- ctx.state.bundle = ctx.state.cancelPreload = null;
2516
+ ctx.state.cancelPreload = null;
2522
2517
  }
2523
2518
  }
2524
2519
  /**
@@ -2536,7 +2531,7 @@ function startPreload(ctx) {
2536
2531
  if (ctx.config.preload !== "all" || typeof document === "undefined" || ctx.state.cancelPreload !== null || nav?.connection?.saveData === true) return;
2537
2532
  const controller = new AbortController();
2538
2533
  const run = () => {
2539
- ctx.state.bundle = fill(ctx, controller.signal);
2534
+ fill(ctx, controller.signal);
2540
2535
  };
2541
2536
  const idle = typeof requestIdleCallback === "function";
2542
2537
  const handle = idle ? requestIdleCallback(run, { timeout: 2e3 }) : setTimeout(run, 0);
@@ -2565,7 +2560,7 @@ function stopPreload(ctx) {
2565
2560
  * Creates initial data state: a null `lastWrite` slot (populated by the Node
2566
2561
  * `write()` side), an empty `cache` (populated lazily by the browser `at(path)`
2567
2562
  * side on first fetch), an empty `pending` map of in-flight fetches, and no
2568
- * preload bundle in flight or scheduled.
2563
+ * preload scheduled.
2569
2564
  *
2570
2565
  * @param _ctx - Minimal context with global and config.
2571
2566
  * @param _ctx.global - Global framework configuration.
@@ -2581,7 +2576,6 @@ function createDataState(_ctx) {
2581
2576
  lastWrite: null,
2582
2577
  cache: /* @__PURE__ */ new Map(),
2583
2578
  pending: /* @__PURE__ */ new Map(),
2584
- bundle: null,
2585
2579
  cancelPreload: null
2586
2580
  };
2587
2581
  }
package/dist/index.cjs CHANGED
@@ -4666,9 +4666,8 @@ function dataApi(ctx) {
4666
4666
  return {
4667
4667
  /**
4668
4668
  * READ (browser) — fetch (and cache) the persisted data for a page path.
4669
- * Concurrent calls for one path share one in-flight request. While a preload
4670
- * bundle is in flight, it waits for the bundle and fetches the single file
4671
- * only if the bundle did not bring the path.
4669
+ * Concurrent calls for one path share one in-flight request. It never waits
4670
+ * for an in-flight preload bundle: an uncached path is fetched at once.
4672
4671
  * Returns the raw JSON as `unknown`, which the route uses directly as `ctx.data`
4673
4672
  * (no route `.parse()`); returns `null` if the fetch or JSON parse fails (so
4674
4673
  * `spa` can fall back to HTML).
@@ -4682,10 +4681,6 @@ function dataApi(ctx) {
4682
4681
  */
4683
4682
  async at(path) {
4684
4683
  if (ctx.state.cache.has(path)) return ctx.state.cache.get(path);
4685
- if (ctx.state.bundle) {
4686
- await ctx.state.bundle;
4687
- if (ctx.state.cache.has(path)) return ctx.state.cache.get(path);
4688
- }
4689
4684
  const inFlight = ctx.state.pending.get(path);
4690
4685
  if (inFlight) return inFlight;
4691
4686
  const request = fetchAndCache(ctx, path);
@@ -4760,7 +4755,7 @@ const defaultDataConfig = {
4760
4755
  //#region src/plugins/data/preload.ts
4761
4756
  /**
4762
4757
  * Fetches the bundle and caches every path not already cached. Never rejects:
4763
- * a failed fetch leaves lazy `at()` working. Clears the preload slots when done.
4758
+ * a failed fetch leaves lazy `at()` working. Clears `cancelPreload` when done.
4764
4759
  *
4765
4760
  * @param ctx - The data plugin context.
4766
4761
  * @param signal - Aborts the fetch on stop.
@@ -4776,7 +4771,7 @@ async function fill(ctx, signal) {
4776
4771
  const bundle = response.ok ? await response.json() : {};
4777
4772
  for (const [path, data] of Object.entries(bundle)) if (!signal.aborted && !ctx.state.cache.has(path)) ctx.state.cache.set(path, data);
4778
4773
  } catch {} finally {
4779
- ctx.state.bundle = ctx.state.cancelPreload = null;
4774
+ ctx.state.cancelPreload = null;
4780
4775
  }
4781
4776
  }
4782
4777
  /**
@@ -4794,7 +4789,7 @@ function startPreload(ctx) {
4794
4789
  if (ctx.config.preload !== "all" || typeof document === "undefined" || ctx.state.cancelPreload !== null || nav?.connection?.saveData === true) return;
4795
4790
  const controller = new AbortController();
4796
4791
  const run = () => {
4797
- ctx.state.bundle = fill(ctx, controller.signal);
4792
+ fill(ctx, controller.signal);
4798
4793
  };
4799
4794
  const idle = typeof requestIdleCallback === "function";
4800
4795
  const handle = idle ? requestIdleCallback(run, { timeout: 2e3 }) : setTimeout(run, 0);
@@ -4823,7 +4818,7 @@ function stopPreload(ctx) {
4823
4818
  * Creates initial data state: a null `lastWrite` slot (populated by the Node
4824
4819
  * `write()` side), an empty `cache` (populated lazily by the browser `at(path)`
4825
4820
  * side on first fetch), an empty `pending` map of in-flight fetches, and no
4826
- * preload bundle in flight or scheduled.
4821
+ * preload scheduled.
4827
4822
  *
4828
4823
  * @param _ctx - Minimal context with global and config.
4829
4824
  * @param _ctx.global - Global framework configuration.
@@ -4839,7 +4834,6 @@ function createDataState(_ctx) {
4839
4834
  lastWrite: null,
4840
4835
  cache: /* @__PURE__ */ new Map(),
4841
4836
  pending: /* @__PURE__ */ new Map(),
4842
- bundle: null,
4843
4837
  cancelPreload: null
4844
4838
  };
4845
4839
  }
package/dist/index.d.cts CHANGED
@@ -3491,12 +3491,6 @@ interface DataState {
3491
3491
  * the fetch settles, on success and on failure, so a failure is never cached.
3492
3492
  */
3493
3493
  pending: Map<string, Promise<unknown | null>>;
3494
- /**
3495
- * The preload bundle fetch while it is in flight (browser, `preload: "all"`).
3496
- * `at()` awaits it before fetching a single file. Never rejects. `null` when no
3497
- * bundle fetch is running.
3498
- */
3499
- bundle: Promise<void> | null;
3500
3494
  /** Cancels the scheduled idle callback or aborts the bundle fetch. `null` when nothing is scheduled. */
3501
3495
  cancelPreload: (() => void) | null;
3502
3496
  }
package/dist/index.d.mts CHANGED
@@ -3489,12 +3489,6 @@ interface DataState {
3489
3489
  * the fetch settles, on success and on failure, so a failure is never cached.
3490
3490
  */
3491
3491
  pending: Map<string, Promise<unknown | null>>;
3492
- /**
3493
- * The preload bundle fetch while it is in flight (browser, `preload: "all"`).
3494
- * `at()` awaits it before fetching a single file. Never rejects. `null` when no
3495
- * bundle fetch is running.
3496
- */
3497
- bundle: Promise<void> | null;
3498
3492
  /** Cancels the scheduled idle callback or aborts the bundle fetch. `null` when nothing is scheduled. */
3499
3493
  cancelPreload: (() => void) | null;
3500
3494
  }
package/dist/index.mjs CHANGED
@@ -4622,9 +4622,8 @@ function dataApi(ctx) {
4622
4622
  return {
4623
4623
  /**
4624
4624
  * READ (browser) — fetch (and cache) the persisted data for a page path.
4625
- * Concurrent calls for one path share one in-flight request. While a preload
4626
- * bundle is in flight, it waits for the bundle and fetches the single file
4627
- * only if the bundle did not bring the path.
4625
+ * Concurrent calls for one path share one in-flight request. It never waits
4626
+ * for an in-flight preload bundle: an uncached path is fetched at once.
4628
4627
  * Returns the raw JSON as `unknown`, which the route uses directly as `ctx.data`
4629
4628
  * (no route `.parse()`); returns `null` if the fetch or JSON parse fails (so
4630
4629
  * `spa` can fall back to HTML).
@@ -4638,10 +4637,6 @@ function dataApi(ctx) {
4638
4637
  */
4639
4638
  async at(path) {
4640
4639
  if (ctx.state.cache.has(path)) return ctx.state.cache.get(path);
4641
- if (ctx.state.bundle) {
4642
- await ctx.state.bundle;
4643
- if (ctx.state.cache.has(path)) return ctx.state.cache.get(path);
4644
- }
4645
4640
  const inFlight = ctx.state.pending.get(path);
4646
4641
  if (inFlight) return inFlight;
4647
4642
  const request = fetchAndCache(ctx, path);
@@ -4716,7 +4711,7 @@ const defaultDataConfig = {
4716
4711
  //#region src/plugins/data/preload.ts
4717
4712
  /**
4718
4713
  * Fetches the bundle and caches every path not already cached. Never rejects:
4719
- * a failed fetch leaves lazy `at()` working. Clears the preload slots when done.
4714
+ * a failed fetch leaves lazy `at()` working. Clears `cancelPreload` when done.
4720
4715
  *
4721
4716
  * @param ctx - The data plugin context.
4722
4717
  * @param signal - Aborts the fetch on stop.
@@ -4732,7 +4727,7 @@ async function fill(ctx, signal) {
4732
4727
  const bundle = response.ok ? await response.json() : {};
4733
4728
  for (const [path, data] of Object.entries(bundle)) if (!signal.aborted && !ctx.state.cache.has(path)) ctx.state.cache.set(path, data);
4734
4729
  } catch {} finally {
4735
- ctx.state.bundle = ctx.state.cancelPreload = null;
4730
+ ctx.state.cancelPreload = null;
4736
4731
  }
4737
4732
  }
4738
4733
  /**
@@ -4750,7 +4745,7 @@ function startPreload(ctx) {
4750
4745
  if (ctx.config.preload !== "all" || typeof document === "undefined" || ctx.state.cancelPreload !== null || nav?.connection?.saveData === true) return;
4751
4746
  const controller = new AbortController();
4752
4747
  const run = () => {
4753
- ctx.state.bundle = fill(ctx, controller.signal);
4748
+ fill(ctx, controller.signal);
4754
4749
  };
4755
4750
  const idle = typeof requestIdleCallback === "function";
4756
4751
  const handle = idle ? requestIdleCallback(run, { timeout: 2e3 }) : setTimeout(run, 0);
@@ -4779,7 +4774,7 @@ function stopPreload(ctx) {
4779
4774
  * Creates initial data state: a null `lastWrite` slot (populated by the Node
4780
4775
  * `write()` side), an empty `cache` (populated lazily by the browser `at(path)`
4781
4776
  * side on first fetch), an empty `pending` map of in-flight fetches, and no
4782
- * preload bundle in flight or scheduled.
4777
+ * preload scheduled.
4783
4778
  *
4784
4779
  * @param _ctx - Minimal context with global and config.
4785
4780
  * @param _ctx.global - Global framework configuration.
@@ -4795,7 +4790,6 @@ function createDataState(_ctx) {
4795
4790
  lastWrite: null,
4796
4791
  cache: /* @__PURE__ */ new Map(),
4797
4792
  pending: /* @__PURE__ */ new Map(),
4798
- bundle: null,
4799
4793
  cancelPreload: null
4800
4794
  };
4801
4795
  }
package/package.json CHANGED
@@ -139,5 +139,5 @@
139
139
  "typescript-eslint": "8.58.0",
140
140
  "vitest": "4.0.18"
141
141
  },
142
- "version": "2.4.14"
142
+ "version": "2.4.15"
143
143
  }