token-usage-dashboard 1.0.9 → 1.0.10

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 (64) hide show
  1. package/build/client/_app/immutable/chunks/{Cs9ix4uI.js → BX77ZfNv.js} +2 -2
  2. package/build/client/_app/immutable/chunks/BX77ZfNv.js.br +0 -0
  3. package/build/client/_app/immutable/chunks/BX77ZfNv.js.gz +0 -0
  4. package/build/client/_app/immutable/chunks/Dsm7b1TR.js +3 -0
  5. package/build/client/_app/immutable/chunks/Dsm7b1TR.js.br +0 -0
  6. package/build/client/_app/immutable/chunks/Dsm7b1TR.js.gz +0 -0
  7. package/build/client/_app/immutable/entry/app.ZbFPDnha.js +2 -0
  8. package/build/client/_app/immutable/entry/app.ZbFPDnha.js.br +0 -0
  9. package/build/client/_app/immutable/entry/app.ZbFPDnha.js.gz +0 -0
  10. package/build/client/_app/immutable/entry/start.BMzOzqbh.js +1 -0
  11. package/build/client/_app/immutable/entry/start.BMzOzqbh.js.br +0 -0
  12. package/build/client/_app/immutable/entry/start.BMzOzqbh.js.gz +0 -0
  13. package/build/client/_app/immutable/nodes/0.PGglbI9f.js +1 -0
  14. package/build/client/_app/immutable/nodes/0.PGglbI9f.js.br +0 -0
  15. package/build/client/_app/immutable/nodes/0.PGglbI9f.js.gz +0 -0
  16. package/build/client/_app/immutable/nodes/1.eNYaBHjQ.js +1 -0
  17. package/build/client/_app/immutable/nodes/1.eNYaBHjQ.js.br +0 -0
  18. package/build/client/_app/immutable/nodes/1.eNYaBHjQ.js.gz +0 -0
  19. package/build/client/_app/immutable/nodes/2.D9j49PHt.js +2 -0
  20. package/build/client/_app/immutable/nodes/2.D9j49PHt.js.br +0 -0
  21. package/build/client/_app/immutable/nodes/2.D9j49PHt.js.gz +0 -0
  22. package/build/client/_app/version.json +1 -1
  23. package/build/client/_app/version.json.br +0 -0
  24. package/build/client/_app/version.json.gz +0 -0
  25. package/build/handler.js +8 -8
  26. package/build/index.js +8 -8
  27. package/build/server/chunks/chunks/{client.js-dzA-_vbM.js → client.js-D-QnW99V.js} +6 -6
  28. package/build/server/chunks/chunks/{exports.js-Dd48p7Ih.js → exports.js-D7S4dPRP.js} +88 -2
  29. package/build/server/chunks/chunks/{internal.js-WfBRMRsu.js → internal.js-D7pDQEIA.js} +4 -3
  30. package/build/server/chunks/chunks/{server.js-mTMwhapa.js → server.js-DxWEh0qK.js} +286 -260
  31. package/build/server/chunks/chunks/{shared.js-7DyfRqo3.js → shared.js-CAkvBFpL.js} +2 -2
  32. package/build/server/chunks/chunks/{utils.js-DzwqnkBT.js → utils.js-U7QVKoQm.js} +3 -3
  33. package/build/server/chunks/entries/endpoints/api/refresh/{_server.ts.js-ByCHvh6I.js → _server.ts.js-DmuUmmD4.js} +4 -4
  34. package/build/server/chunks/entries/endpoints/api/settings/{_server.ts.js-z3BUpIC2.js → _server.ts.js-CiGFkz6L.js} +4 -4
  35. package/build/server/chunks/entries/endpoints/api/usage/{_server.ts.js-C6vS-sK1.js → _server.ts.js-GScKbdma.js} +4 -4
  36. package/build/server/chunks/entries/fallbacks/{error.svelte.js-CAWEWGLK.js → error.svelte.js-Da4mOvS4.js} +7 -7
  37. package/build/server/chunks/entries/pages/{_page.svelte.js-DWD4fuiY.js → _page.svelte.js-CEtKjhZt.js} +7 -7
  38. package/build/server/chunks/{handler-CvhtfVM1.js → handler-5jjgLxup.js} +5 -5
  39. package/build/server/chunks/{index.js-CItxG5Fx.js → index.js-DZbu1XvC.js} +6 -6
  40. package/build/server/chunks/{manifest.js-B6xVyARC.js → manifest.js-DRxtl2Jo.js} +8 -8
  41. package/build/server/chunks/nodes/{0.js-CxT79s9-.js → 0.js-7EReDAeT.js} +2 -2
  42. package/build/server/chunks/nodes/{1.js-ClmHS2nO.js → 1.js-DuQIc_6j.js} +3 -3
  43. package/build/server/chunks/nodes/{2.js-CdZxFyXS.js → 2.js-XpTi4AUK.js} +3 -3
  44. package/package.json +1 -1
  45. package/build/client/_app/immutable/chunks/Cs9ix4uI.js.br +0 -0
  46. package/build/client/_app/immutable/chunks/Cs9ix4uI.js.gz +0 -0
  47. package/build/client/_app/immutable/chunks/DC6tN2WI.js +0 -3
  48. package/build/client/_app/immutable/chunks/DC6tN2WI.js.br +0 -0
  49. package/build/client/_app/immutable/chunks/DC6tN2WI.js.gz +0 -0
  50. package/build/client/_app/immutable/entry/app.D4LA_7JD.js +0 -2
  51. package/build/client/_app/immutable/entry/app.D4LA_7JD.js.br +0 -0
  52. package/build/client/_app/immutable/entry/app.D4LA_7JD.js.gz +0 -0
  53. package/build/client/_app/immutable/entry/start.h5yz1FcE.js +0 -1
  54. package/build/client/_app/immutable/entry/start.h5yz1FcE.js.br +0 -0
  55. package/build/client/_app/immutable/entry/start.h5yz1FcE.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/0.CrqqkQn-.js +0 -1
  57. package/build/client/_app/immutable/nodes/0.CrqqkQn-.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/0.CrqqkQn-.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/1.CTKJ-7rB.js +0 -1
  60. package/build/client/_app/immutable/nodes/1.CTKJ-7rB.js.br +0 -0
  61. package/build/client/_app/immutable/nodes/1.CTKJ-7rB.js.gz +0 -0
  62. package/build/client/_app/immutable/nodes/2.BdW0LqA6.js +0 -2
  63. package/build/client/_app/immutable/nodes/2.BdW0LqA6.js.br +0 -0
  64. package/build/client/_app/immutable/nodes/2.BdW0LqA6.js.gz +0 -0
@@ -1722,13 +1722,6 @@ var DESTROYING = 1 << 25;
1722
1722
  var EFFECT_TRANSPARENT = 65536;
1723
1723
  var EFFECT_PRESERVED = 1 << 19;
1724
1724
  var USER_EFFECT = 1 << 20;
1725
- /**
1726
- * Tells that we marked this derived and its reactions as visited during the "mark as (maybe) dirty"-phase.
1727
- * Will be lifted during execution of the derived and during checking its dirty state (both are necessary
1728
- * because a derived might be checked but not executed). This is a pure performance optimization flag and
1729
- * should not be used for any other purpose!
1730
- */
1731
- var WAS_MARKED = 65536;
1732
1725
  var REACTION_IS_UPDATING = 1 << 21;
1733
1726
  var ERROR_VALUE = 1 << 23;
1734
1727
  var STATE_SYMBOL = Symbol("$state");
@@ -1852,6 +1845,13 @@ function missing_context() {
1852
1845
  throw new Error(`https://svelte.dev/e/missing_context`);
1853
1846
  }
1854
1847
  /**
1848
+ * `setContext` must be called when a component first initializes, not in a subsequent effect or after an `await` expression
1849
+ * @returns {never}
1850
+ */
1851
+ function set_context_after_init() {
1852
+ throw new Error(`https://svelte.dev/e/set_context_after_init`);
1853
+ }
1854
+ /**
1855
1855
  * Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
1856
1856
  * @returns {never}
1857
1857
  */
@@ -2037,21 +2037,7 @@ function update_derived_status(derived) {
2037
2037
  }
2038
2038
  //#endregion
2039
2039
  //#region node_modules/svelte/src/internal/client/reactivity/utils.js
2040
- /** @import { Derived, Effect, Value } from '#client' */
2041
- /**
2042
- * @param {Value[] | null} deps
2043
- */
2044
- function clear_marked(deps) {
2045
- if (deps === null) return;
2046
- for (const dep of deps) {
2047
- if ((dep.f & 2) === 0 || (dep.f & 65536) === 0) continue;
2048
- dep.f ^= WAS_MARKED;
2049
- clear_marked(
2050
- /** @type {Derived} */
2051
- dep.deps
2052
- );
2053
- }
2054
- }
2040
+ /** @import { Effect } from '#client' */
2055
2041
  /**
2056
2042
  * @param {Effect} effect
2057
2043
  * @param {Set<Effect>} dirty_effects
@@ -2060,7 +2046,6 @@ function clear_marked(deps) {
2060
2046
  function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
2061
2047
  if ((effect.f & 2048) !== 0) dirty_effects.add(effect);
2062
2048
  else if ((effect.f & 4096) !== 0) maybe_dirty_effects.add(effect);
2063
- clear_marked(effect.deps);
2064
2049
  set_signal_status(effect, CLEAN);
2065
2050
  }
2066
2051
  //#endregion
@@ -2108,7 +2093,6 @@ function execute_derived(derived) {
2108
2093
  }
2109
2094
  set_active_effect(parent);
2110
2095
  try {
2111
- derived.f &= ~WAS_MARKED;
2112
2096
  destroy_derived_effects(derived);
2113
2097
  value = update_reaction(derived);
2114
2098
  } finally {
@@ -2257,10 +2241,17 @@ var Batch = class Batch {
2257
2241
  */
2258
2242
  #deferred = null;
2259
2243
  /**
2260
- * The root effects that need to be flushed
2244
+ * Effects that were scheduled in this batch but not yet 'resolved' into the
2245
+ * root effects that need to be flushed. Resolving — the upwards traversal that
2246
+ * marks the path to each effect on the shared effect tree (see #resolve) — is
2247
+ * deferred until the batch is processed, so that the markers are created and
2248
+ * consumed within a single traversal. Scheduling into other batches (which can
2249
+ * happen concurrently, e.g. while a batch is committed) can therefore never
2250
+ * observe (and be confused by) this batch's markers.
2251
+ * May contain duplicates — deduplication happens during resolving
2261
2252
  * @type {Effect[]}
2262
2253
  */
2263
- #roots = [];
2254
+ #scheduled = [];
2264
2255
  /**
2265
2256
  * Effects created while this batch was active.
2266
2257
  * @type {Effect[]}
@@ -2347,12 +2338,40 @@ var Batch = class Batch {
2347
2338
  }
2348
2339
  this.#unskipped_branches.add(effect);
2349
2340
  }
2341
+ /**
2342
+ * Convert the effects that were scheduled in this batch into the root effects
2343
+ * that need to be traversed, marking the path to each effect (by clearing the
2344
+ * `CLEAN` flag on ancestor branches) so that the traversal can find them.
2345
+ * This happens right before traversal rather than at scheduling time, so that
2346
+ * the markers left on the (shared) effect tree are created and consumed within
2347
+ * a single traversal — scheduling into other batches can never observe them
2348
+ * @returns {Effect[]}
2349
+ */
2350
+ #resolve() {
2351
+ /** @type {Effect[]} */
2352
+ var roots = [];
2353
+ for (const effect of this.#scheduled) {
2354
+ if ((effect.f & 16384) !== 0 || (effect.f & 6144) === 0) continue;
2355
+ var e = effect;
2356
+ var covered = false;
2357
+ while (e.parent !== null) {
2358
+ e = e.parent;
2359
+ var flags = e.f;
2360
+ if ((flags & 96) !== 0) {
2361
+ if ((flags & 1024) === 0) {
2362
+ covered = true;
2363
+ break;
2364
+ }
2365
+ e.f ^= CLEAN;
2366
+ }
2367
+ }
2368
+ if (!covered) roots.push(e);
2369
+ }
2370
+ this.#scheduled = [];
2371
+ return roots;
2372
+ }
2350
2373
  #process() {
2351
2374
  this.#started = true;
2352
- if (flush_count++ > 1e3) {
2353
- this.#unlink();
2354
- infinite_loop_guard();
2355
- }
2356
2375
  for (const e of this.#dirty_effects) {
2357
2376
  this.#maybe_dirty_effects.delete(e);
2358
2377
  set_signal_status(e, DIRTY);
@@ -2362,8 +2381,6 @@ var Batch = class Batch {
2362
2381
  set_signal_status(e, MAYBE_DIRTY);
2363
2382
  this.schedule(e);
2364
2383
  }
2365
- const roots = this.#roots;
2366
- this.#roots = [];
2367
2384
  this.apply();
2368
2385
  /** @type {Effect[]} */
2369
2386
  var effects = collected_effects = [];
@@ -2374,12 +2391,18 @@ var Batch = class Batch {
2374
2391
  * @deprecated when we get rid of legacy mode and stores, we can get rid of this
2375
2392
  */
2376
2393
  var updates = legacy_updates = [];
2377
- for (const root of roots) try {
2378
- this.#traverse(root, effects, render_effects);
2379
- } catch (e) {
2380
- reset_all(root);
2381
- if (!this.#is_deferred()) this.discard();
2382
- throw e;
2394
+ while (this.#scheduled.length > 0) {
2395
+ if (flush_count++ > 1e3) {
2396
+ this.#unlink();
2397
+ infinite_loop_guard();
2398
+ }
2399
+ for (const root of this.#resolve()) try {
2400
+ this.#traverse(root, effects, render_effects);
2401
+ } catch (e) {
2402
+ reset_all(root);
2403
+ if (!this.#is_deferred()) this.discard();
2404
+ throw e;
2405
+ }
2383
2406
  }
2384
2407
  current_batch = null;
2385
2408
  if (updates.length > 0) {
@@ -2413,13 +2436,13 @@ var Batch = class Batch {
2413
2436
  previous_batch = null;
2414
2437
  this.#deferred?.resolve();
2415
2438
  var next_batch = current_batch;
2416
- if (this.#pending === 0 && (this.#roots.length === 0 || next_batch !== null)) {
2439
+ if (this.#pending === 0 && (this.#scheduled.length === 0 || next_batch !== null)) {
2417
2440
  this.#unlink();
2418
2441
  }
2419
- if (this.#roots.length > 0) {
2442
+ if (this.#scheduled.length > 0) {
2420
2443
  if (next_batch !== null) {
2421
- const batch = next_batch;
2422
- batch.#roots.push(...this.#roots.filter((r) => !batch.#roots.includes(r)));
2444
+ for (const e of this.#scheduled) next_batch.#scheduled.push(e);
2445
+ this.#scheduled = [];
2423
2446
  } else next_batch = this;
2424
2447
  }
2425
2448
  if (next_batch !== null) {
@@ -2622,10 +2645,9 @@ var Batch = class Batch {
2622
2645
  } else batch.#dirty_effects.add(effect);
2623
2646
  }
2624
2647
  }
2625
- if (batch.#roots.length > 0 && !batch.#decrement_queued) {
2648
+ if (batch.#scheduled.length > 0 && !batch.#decrement_queued) {
2626
2649
  batch.apply();
2627
- for (var root of batch.#roots) batch.#traverse(root, [], []);
2628
- batch.#roots = [];
2650
+ for (var root of batch.#resolve()) batch.#traverse(root, [], []);
2629
2651
  }
2630
2652
  batch.deactivate();
2631
2653
  }
@@ -2706,19 +2728,7 @@ var Batch = class Batch {
2706
2728
  effect.b.defer_effect(effect);
2707
2729
  return;
2708
2730
  }
2709
- var e = effect;
2710
- while (e.parent !== null) {
2711
- e = e.parent;
2712
- var flags = e.f;
2713
- if (collected_effects !== null && e === active_effect) {
2714
- if ((active_reaction === null || (active_reaction.f & 2) === 0) && true) return;
2715
- }
2716
- if ((flags & 96) !== 0) {
2717
- if ((flags & 1024) === 0) return;
2718
- e.f ^= CLEAN;
2719
- }
2720
- }
2721
- this.#roots.push(e);
2731
+ this.#scheduled.push(effect);
2722
2732
  }
2723
2733
  #unlink() {
2724
2734
  if (!this.linked) return;
@@ -2937,6 +2947,16 @@ function set(source, value, should_proxy = false) {
2937
2947
  return internal_set(source, should_proxy ? proxy(value) : value, legacy_updates);
2938
2948
  }
2939
2949
  /**
2950
+ * A set of signals we have already seen while traversing in mark_reactions.
2951
+ * Not always set to balance the common case of sources only having a couple
2952
+ * of (transitive) dependencies (where always creating a Set would be bad for perf)
2953
+ * with the edge case of extremely deep or wide dependency arrays with cycles.
2954
+ * @type {Set<any> | null}
2955
+ */
2956
+ var seen = null;
2957
+ /** Number of transitive dependencies, see {@link seen} for more info */
2958
+ var count_deps = 0;
2959
+ /**
2940
2960
  * @template V
2941
2961
  * @param {Source<V>} source
2942
2962
  * @param {V} value
@@ -2955,7 +2975,10 @@ function internal_set(source, value, updated_during_traversal = null) {
2955
2975
  if (batch_values === null) update_derived_status(derived);
2956
2976
  }
2957
2977
  source.wv = increment_write_version();
2978
+ seen = null;
2979
+ count_deps = 0;
2958
2980
  mark_reactions(source, DIRTY, updated_during_traversal);
2981
+ seen = null;
2959
2982
  if (active_effect !== null && (active_effect.f & 1024) !== 0 && (active_effect.f & 96) === 0) {
2960
2983
  if (untracked_writes === null) set_untracked_writes([source]);
2961
2984
  else untracked_writes.push(source);
@@ -2995,6 +3018,12 @@ function mark_reactions(signal, status, updated_during_traversal) {
2995
3018
  var reactions = signal.reactions;
2996
3019
  if (reactions === null) return;
2997
3020
  var length = reactions.length;
3021
+ count_deps += length;
3022
+ if (count_deps > 1e5 && seen === null) seen = /* @__PURE__ */ new Set();
3023
+ if (seen !== null) {
3024
+ if (seen.has(signal)) return;
3025
+ seen.add(signal);
3026
+ }
2998
3027
  for (var i = 0; i < length; i++) {
2999
3028
  var reaction = reactions[i];
3000
3029
  var flags = reaction.f;
@@ -3004,10 +3033,7 @@ function mark_reactions(signal, status, updated_during_traversal) {
3004
3033
  else if ((flags & 2) !== 0) {
3005
3034
  var derived = reaction;
3006
3035
  batch_values?.delete(derived);
3007
- if ((flags & 65536) === 0) {
3008
- if (flags & 512 && (active_effect === null || (active_effect.f & 2097152) === 0)) reaction.f |= WAS_MARKED;
3009
- mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
3010
- }
3036
+ mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
3011
3037
  } else if (not_dirty) {
3012
3038
  var effect = reaction;
3013
3039
  if ((flags & 16) !== 0 && eager_block_effects !== null) eager_block_effects.add(effect);
@@ -3092,14 +3118,14 @@ function proxy(value) {
3092
3118
  return Reflect.get(target, prop, receiver);
3093
3119
  },
3094
3120
  getOwnPropertyDescriptor(target, prop) {
3121
+ this.has?.(target, prop);
3095
3122
  var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
3096
- if (descriptor && "value" in descriptor) {
3097
- var s = sources.get(prop);
3098
- if (s) descriptor.value = get(s);
3099
- } else if (descriptor === void 0) {
3100
- var source = sources.get(prop);
3101
- var value = source?.v;
3102
- if (source !== void 0 && value !== UNINITIALIZED) return {
3123
+ var s = sources.get(prop);
3124
+ if (s !== void 0) {
3125
+ var value = get(s);
3126
+ if (value === UNINITIALIZED) return;
3127
+ if (descriptor && "value" in descriptor) descriptor.value = value;
3128
+ else return {
3103
3129
  enumerable: true,
3104
3130
  configurable: true,
3105
3131
  value,
@@ -3585,7 +3611,7 @@ function set_active_effect(effect) {
3585
3611
  var current_sources = null;
3586
3612
  /** @param {Value} value */
3587
3613
  function push_reaction_value(value) {
3588
- if (active_reaction !== null && (true)) (current_sources ??= /* @__PURE__ */ new Set()).add(value);
3614
+ if (active_reaction !== null && ((active_reaction.f & 2097152) !== 0 || (active_reaction.f & 2) !== 0)) (current_sources ??= /* @__PURE__ */ new Set()).add(value);
3589
3615
  }
3590
3616
  /**
3591
3617
  * The dependencies of the reaction that is currently being executed. In many cases,
@@ -3629,7 +3655,6 @@ function increment_write_version() {
3629
3655
  function is_dirty(reaction) {
3630
3656
  var flags = reaction.f;
3631
3657
  if ((flags & 2048) !== 0) return true;
3632
- if (flags & 2) reaction.f &= ~WAS_MARKED;
3633
3658
  if ((flags & 4096) !== 0) {
3634
3659
  var dependencies = reaction.deps;
3635
3660
  var length = dependencies.length;
@@ -3760,10 +3785,7 @@ function remove_reaction(signal, dependency) {
3760
3785
  }
3761
3786
  if (reactions === null && (dependency.f & 2) !== 0 && (new_deps === null || !includes.call(new_deps, dependency))) {
3762
3787
  var derived = dependency;
3763
- if ((derived.f & 512) !== 0) {
3764
- derived.f ^= 512;
3765
- derived.f &= ~WAS_MARKED;
3766
- }
3788
+ if ((derived.f & 512) !== 0) derived.f ^= 512;
3767
3789
  if (derived.v !== UNINITIALIZED) update_derived_status(derived);
3768
3790
  if (derived.ac !== null) without_reactive_context(() => {
3769
3791
  /** @type {AbortController} */ derived.ac.abort(STALE_REACTION);
@@ -3910,90 +3932,6 @@ function untrack(fn) {
3910
3932
  }
3911
3933
  }
3912
3934
  //#endregion
3913
- //#region node_modules/svelte/src/store/shared/index.js
3914
- /** @import { Readable, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable } from '../public.js' */
3915
- /** @import { Stores, StoresValues, SubscribeInvalidateTuple } from '../private.js' */
3916
- /**
3917
- * @type {Array<SubscribeInvalidateTuple<any> | any>}
3918
- */
3919
- var subscriber_queue = [];
3920
- /**
3921
- * Creates a `Readable` store that allows reading by subscription.
3922
- *
3923
- * @template T
3924
- * @param {T} [value] initial value
3925
- * @param {StartStopNotifier<T>} [start]
3926
- * @returns {Readable<T>}
3927
- */
3928
- function readable(value, start) {
3929
- return { subscribe: writable(value, start).subscribe };
3930
- }
3931
- /**
3932
- * Create a `Writable` store that allows both updating and reading by subscription.
3933
- *
3934
- * @template T
3935
- * @param {T} [value] initial value
3936
- * @param {StartStopNotifier<T>} [start]
3937
- * @returns {Writable<T>}
3938
- */
3939
- function writable(value, start = noop) {
3940
- /** @type {Unsubscriber | null} */
3941
- let stop = null;
3942
- /** @type {Set<SubscribeInvalidateTuple<T>>} */
3943
- const subscribers = /* @__PURE__ */ new Set();
3944
- /**
3945
- * @param {T} new_value
3946
- * @returns {void}
3947
- */
3948
- function set(new_value) {
3949
- if (safe_not_equal(value, new_value)) {
3950
- value = new_value;
3951
- if (stop) {
3952
- const run_queue = !subscriber_queue.length;
3953
- for (const subscriber of subscribers) {
3954
- subscriber[1]();
3955
- subscriber_queue.push(subscriber, value);
3956
- }
3957
- if (run_queue) {
3958
- for (let i = 0; i < subscriber_queue.length; i += 2) subscriber_queue[i][0](subscriber_queue[i + 1]);
3959
- subscriber_queue.length = 0;
3960
- }
3961
- }
3962
- }
3963
- }
3964
- /**
3965
- * @param {Updater<T>} fn
3966
- * @returns {void}
3967
- */
3968
- function update(fn) {
3969
- set(fn(value));
3970
- }
3971
- /**
3972
- * @param {Subscriber<T>} run
3973
- * @param {() => void} [invalidate]
3974
- * @returns {Unsubscriber}
3975
- */
3976
- function subscribe(run, invalidate = noop) {
3977
- /** @type {SubscribeInvalidateTuple<T>} */
3978
- const subscriber = [run, invalidate];
3979
- subscribers.add(subscriber);
3980
- if (subscribers.size === 1) stop = start(set, update) || noop;
3981
- run(value);
3982
- return () => {
3983
- subscribers.delete(subscriber);
3984
- if (subscribers.size === 0 && stop) {
3985
- stop();
3986
- stop = null;
3987
- }
3988
- };
3989
- }
3990
- return {
3991
- set,
3992
- update,
3993
- subscribe
3994
- };
3995
- }
3996
- //#endregion
3997
3935
  //#region node_modules/svelte/src/utils.js
3998
3936
  var VOID_ELEMENT_NAMES = [
3999
3937
  "area",
@@ -4257,63 +4195,15 @@ var BLOCK_OPEN = `<!--[-->`;
4257
4195
  var BLOCK_CLOSE = `<!--]-->`;
4258
4196
  var EMPTY_COMMENT = `<!---->`;
4259
4197
  //#endregion
4260
- //#region node_modules/svelte/src/internal/server/context.js
4261
- /** @import { SSRContext } from '#server' */
4262
- /** @type {SSRContext | null} */
4263
- var ssr_context = null;
4264
- /** @param {SSRContext | null} v */
4265
- function set_ssr_context(v) {
4266
- ssr_context = v;
4267
- }
4268
- /**
4269
- * @template T
4270
- * @returns {[() => T, (context: T) => T, () => boolean]}
4271
- * @since 5.40.0
4272
- */
4273
- function createContext() {
4274
- return create_context(getContext, setContext, hasContext);
4275
- }
4276
- /**
4277
- * @template T
4278
- * @param {any} key
4279
- * @returns {T}
4280
- */
4281
- function getContext(key) {
4282
- return get_or_init_context_map(ssr_context).get(key);
4283
- }
4198
+ //#region node_modules/svelte/src/internal/server/errors.js
4284
4199
  /**
4285
- * @template T
4286
- * @param {any} key
4287
- * @param {T} context
4288
- * @returns {T}
4289
- */
4290
- function setContext(key, context) {
4291
- get_or_init_context_map(ssr_context).set(key, context);
4292
- return context;
4293
- }
4294
- /**
4295
- * @param {any} key
4296
- * @returns {boolean}
4297
- */
4298
- function hasContext(key) {
4299
- return get_or_init_context_map(ssr_context).has(key);
4300
- }
4301
- /** @returns {Map<any, any>} */
4302
- function getAllContexts() {
4303
- return get_or_init_context_map(ssr_context);
4304
- }
4305
- /**
4306
- * @param {Function} [fn]
4200
+ * The node API `AsyncLocalStorage` is not available, but is required to use async server rendering.
4201
+ * @returns {never}
4307
4202
  */
4308
- function push(fn) {
4309
- ssr_context = {
4310
- p: ssr_context,
4311
- c: null,
4312
- r: null
4313
- };
4314
- }
4315
- function pop() {
4316
- ssr_context = ssr_context.p;
4203
+ function async_local_storage_unavailable() {
4204
+ const error = /* @__PURE__ */ new Error(`async_local_storage_unavailable\nThe node API \`AsyncLocalStorage\` is not available, but is required to use async server rendering.\nhttps://svelte.dev/e/async_local_storage_unavailable`);
4205
+ error.name = "Svelte error";
4206
+ throw error;
4317
4207
  }
4318
4208
  /**
4319
4209
  * Encountered asynchronous work while rendering synchronously.
@@ -4392,6 +4282,68 @@ function server_context_required() {
4392
4282
  error.name = "Svelte error";
4393
4283
  throw error;
4394
4284
  }
4285
+ //#endregion
4286
+ //#region node_modules/svelte/src/internal/server/context.js
4287
+ /** @import { SSRContext } from '#server' */
4288
+ /** @type {SSRContext | null} */
4289
+ var ssr_context = null;
4290
+ /** @param {SSRContext | null} v */
4291
+ function set_ssr_context(v) {
4292
+ ssr_context = v;
4293
+ }
4294
+ /**
4295
+ * @template T
4296
+ * @returns {[() => T, (context: T) => T, () => boolean]}
4297
+ * @since 5.40.0
4298
+ */
4299
+ function createContext() {
4300
+ return create_context(getContext, setContext, hasContext);
4301
+ }
4302
+ /**
4303
+ * @template T
4304
+ * @param {any} key
4305
+ * @returns {T}
4306
+ */
4307
+ function getContext(key) {
4308
+ return get_or_init_context_map(ssr_context).get(key);
4309
+ }
4310
+ /**
4311
+ * @template T
4312
+ * @param {any} key
4313
+ * @param {T} context
4314
+ * @returns {T}
4315
+ */
4316
+ function setContext(key, context) {
4317
+ const context_map = get_or_init_context_map(ssr_context);
4318
+ if (ssr_context.i) set_context_after_init();
4319
+ context_map.set(key, context);
4320
+ return context;
4321
+ }
4322
+ /**
4323
+ * @param {any} key
4324
+ * @returns {boolean}
4325
+ */
4326
+ function hasContext(key) {
4327
+ return get_or_init_context_map(ssr_context).has(key);
4328
+ }
4329
+ /** @returns {Map<any, any>} */
4330
+ function getAllContexts() {
4331
+ return get_or_init_context_map(ssr_context);
4332
+ }
4333
+ /**
4334
+ * @param {Function} [fn]
4335
+ */
4336
+ function push(fn) {
4337
+ ssr_context = {
4338
+ p: ssr_context,
4339
+ c: null,
4340
+ r: null,
4341
+ i: false
4342
+ };
4343
+ }
4344
+ function pop() {
4345
+ ssr_context = ssr_context.p;
4346
+ }
4395
4347
  /**
4396
4348
  * A `hydratable` value with key `%key%` was created, but at least part of it was not used during the render.
4397
4349
  *
@@ -4403,14 +4355,62 @@ function server_context_required() {
4403
4355
  function unresolved_hydratable(key, stack) {
4404
4356
  console.warn(`https://svelte.dev/e/unresolved_hydratable`);
4405
4357
  }
4358
+ //#endregion
4359
+ //#region node_modules/svelte/src/internal/server/render-context.js
4360
+ /** @import { AsyncLocalStorage } from 'node:async_hooks' */
4361
+ /** @import { RenderContext } from '#server' */
4362
+ /** @type {Promise<void> | null} */
4363
+ var current_render = null;
4364
+ /** @type {RenderContext | null} */
4365
+ var context = null;
4406
4366
  /** @returns {RenderContext} */
4407
4367
  function get_render_context() {
4408
- const store = als?.getStore();
4409
- server_context_required();
4368
+ const store = context ?? als?.getStore();
4369
+ if (!store) server_context_required();
4410
4370
  return store;
4411
4371
  }
4372
+ /**
4373
+ * @template T
4374
+ * @param {() => Promise<T>} fn
4375
+ * @returns {Promise<T>}
4376
+ */
4377
+ async function with_render_context(fn) {
4378
+ context = { hydratable: {
4379
+ lookup: /* @__PURE__ */ new Map(),
4380
+ comparisons: [],
4381
+ unresolved_promises: /* @__PURE__ */ new Map()
4382
+ } };
4383
+ if (in_webcontainer()) {
4384
+ const { promise, resolve } = deferred();
4385
+ const previous_render = current_render;
4386
+ current_render = promise;
4387
+ await previous_render;
4388
+ return fn().finally(resolve);
4389
+ }
4390
+ try {
4391
+ if (als === null) async_local_storage_unavailable();
4392
+ return als.run(context, fn);
4393
+ } finally {
4394
+ context = null;
4395
+ }
4396
+ }
4412
4397
  /** @type {AsyncLocalStorage<RenderContext | null> | null} */
4413
4398
  var als = null;
4399
+ /** @type {Promise<void> | null} */
4400
+ var als_import = null;
4401
+ /**
4402
+ *
4403
+ * @returns {Promise<void>}
4404
+ */
4405
+ function init_render_context() {
4406
+ als_import ??= import('node:async_hooks').then((hooks) => {
4407
+ als = new hooks.AsyncLocalStorage();
4408
+ }).then(noop, noop);
4409
+ return als_import;
4410
+ }
4411
+ function in_webcontainer() {
4412
+ return !!globalThis.process?.versions?.webcontainer;
4413
+ }
4414
4414
  //#endregion
4415
4415
  //#region node_modules/svelte/src/internal/server/crypto.js
4416
4416
  var text_encoder;
@@ -4447,6 +4447,61 @@ function base64_encode(bytes) {
4447
4447
  /**
4448
4448
  * @typedef {string | Renderer} RendererItem
4449
4449
  */
4450
+ var RenderResult = class {
4451
+ /** @type {() => AccumulatedContent} */
4452
+ #render;
4453
+ /** @type {() => Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>} */
4454
+ #render_async;
4455
+ /** @type {AccumulatedContent | undefined} */
4456
+ #sync;
4457
+ /** @type {{ script: '' }} */
4458
+ #hashes = { script: "" };
4459
+ /** @type {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }> | undefined} */
4460
+ #promise;
4461
+ /**
4462
+ * @param {() => AccumulatedContent} render
4463
+ * @param {() => Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>} render_async
4464
+ */
4465
+ constructor(render, render_async) {
4466
+ this.#render = render;
4467
+ this.#render_async = render_async;
4468
+ }
4469
+ #get() {
4470
+ return this.#sync ??= this.#render();
4471
+ }
4472
+ get html() {
4473
+ return this.#get().body;
4474
+ }
4475
+ get head() {
4476
+ return this.#get().head;
4477
+ }
4478
+ get body() {
4479
+ return this.#get().body;
4480
+ }
4481
+ get hashes() {
4482
+ return this.#hashes;
4483
+ }
4484
+ /**
4485
+ * This is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
4486
+ *
4487
+ * @template TResult1
4488
+ * @template [TResult2=never]
4489
+ * @param {(value: SyncRenderOutput) => TResult1} onfulfilled
4490
+ * @param {(reason: unknown) => TResult2} onrejected
4491
+ */
4492
+ then(onfulfilled, onrejected) {
4493
+ {
4494
+ const result = this.#get();
4495
+ const user_result = onfulfilled({
4496
+ head: result.head,
4497
+ body: result.body,
4498
+ html: result.body,
4499
+ hashes: { script: [] }
4500
+ });
4501
+ return Promise.resolve(user_result);
4502
+ }
4503
+ }
4504
+ };
4450
4505
  /**
4451
4506
  * Renderers are basically a tree of `string | Renderer`s, where each `Renderer` in the tree represents
4452
4507
  * work that may or may not have completed. A renderer can be {@link collect}ed to aggregate the
@@ -4568,6 +4623,7 @@ var Renderer = class Renderer {
4568
4623
  const context = ssr_context;
4569
4624
  let promise = Promise.resolve(thunks[0]());
4570
4625
  const promises = [promise];
4626
+ if (context !== null && thunks.length > 1) context.i = true;
4571
4627
  for (const fn of thunks.slice(1)) {
4572
4628
  promise = promise.then(() => {
4573
4629
  const previous_context = ssr_context;
@@ -4605,7 +4661,8 @@ var Renderer = class Renderer {
4605
4661
  ...ssr_context,
4606
4662
  p: parent,
4607
4663
  c: null,
4608
- r: child
4664
+ r: child,
4665
+ i: ssr_context?.i ?? false
4609
4666
  });
4610
4667
  const result = fn(child);
4611
4668
  set_ssr_context(parent);
@@ -4638,7 +4695,8 @@ var Renderer = class Renderer {
4638
4695
  ...ssr_context,
4639
4696
  p: parent_context,
4640
4697
  c: null,
4641
- r: child
4698
+ r: child,
4699
+ i: ssr_context?.i ?? false
4642
4700
  });
4643
4701
  try {
4644
4702
  const result = children_fn(child);
@@ -4838,43 +4896,7 @@ var Renderer = class Renderer {
4838
4896
  * @returns {RenderOutput}
4839
4897
  */
4840
4898
  static render(component, options = {}) {
4841
- /** @type {AccumulatedContent | undefined} */
4842
- let sync;
4843
- const result = {};
4844
- Object.defineProperties(result, {
4845
- html: { get: () => {
4846
- return (sync ??= Renderer.#render(component, options)).body;
4847
- } },
4848
- head: { get: () => {
4849
- return (sync ??= Renderer.#render(component, options)).head;
4850
- } },
4851
- body: { get: () => {
4852
- return (sync ??= Renderer.#render(component, options)).body;
4853
- } },
4854
- hashes: { value: { script: "" } },
4855
- then: { value:
4856
- /**
4857
- * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
4858
- *
4859
- * @template TResult1
4860
- * @template [TResult2=never]
4861
- * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
4862
- * @param { (reason: unknown) => TResult2 } onrejected
4863
- */
4864
- (onfulfilled, onrejected) => {
4865
- {
4866
- const result = sync ??= Renderer.#render(component, options);
4867
- const user_result = onfulfilled({
4868
- head: result.head,
4869
- body: result.body,
4870
- html: result.body,
4871
- hashes: { script: [] }
4872
- });
4873
- return Promise.resolve(user_result);
4874
- }
4875
- } }
4876
- });
4877
- return result;
4899
+ return new RenderResult(() => Renderer.#render(component, options), () => init_render_context().then(() => with_render_context(() => Renderer.#render_async(component, options))));
4878
4900
  }
4879
4901
  /**
4880
4902
  * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
@@ -5068,7 +5090,8 @@ var Renderer = class Renderer {
5068
5090
  set_ssr_context({
5069
5091
  p: null,
5070
5092
  c: options.context ?? null,
5071
- r: renderer
5093
+ r: renderer,
5094
+ i: false
5072
5095
  });
5073
5096
  renderer.push(BLOCK_OPEN);
5074
5097
  component(renderer, options.props ?? {});
@@ -5283,7 +5306,9 @@ function attributes(attrs, css_hash, classes, styles, flags = 0) {
5283
5306
  const is_html = (flags & 1) === 0;
5284
5307
  const lowercase = (flags & 2) === 0;
5285
5308
  const is_input = (flags & 4) !== 0;
5286
- for (name of Object.keys(attrs)) {
5309
+ const names = Object.keys(attrs);
5310
+ outer: for (let i = 0; i < names.length; i++) {
5311
+ name = names[i];
5287
5312
  if (typeof attrs[name] === "function") continue;
5288
5313
  if (name[0] === "$" && name[1] === "$") continue;
5289
5314
  if (name === "" || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
@@ -5294,7 +5319,8 @@ function attributes(attrs, css_hash, classes, styles, flags = 0) {
5294
5319
  if (is_input) {
5295
5320
  if (name === "defaultvalue" || name === "defaultchecked") {
5296
5321
  name = name === "defaultvalue" ? "value" : "checked";
5297
- if (attrs[name]) continue;
5322
+ if (name in attrs) continue;
5323
+ for (let j = 0; j < names.length; j++) if (names[j].toLowerCase() === name) continue outer;
5298
5324
  }
5299
5325
  }
5300
5326
  attr_str += attr(name, value, is_html && is_boolean_attribute(name));
@@ -5370,5 +5396,5 @@ function derived(fn) {
5370
5396
  };
5371
5397
  }
5372
5398
 
5373
- export { pop$1 as $, queue_micro_task as A, invoke_error_boundary as B, current_batch as C, pause_effect as D, move_effect as E, defer_effect as F, set_component_context as G, HYDRATION_ERROR as H, Batch as I, component_context as J, internal_set as K, LEGACY_PROPS as L, destroy_effect as M, next as N, skip_nodes as O, derived as P, effect_tracking as Q, render_effect as R, svelte_boundary_reset_noop as S, svelte_boundary_reset_onerror as T, source as U, untrack as V, increment as W, hydrate_next as X, push$1 as Y, mark_as_component as Z, hydration_mismatch as _, get_first_child as a, run as a0, noop as a1, hasContext as a2, getContext as a3, getAllContexts as a4, createContext as a5, ssr_context as a6, lifecycle_function_unavailable as a7, EFFECT_TRANSPARENT as a8, EFFECT_PRESERVED as a9, experimental_async_required as aa, get_render_context as ab, uneval as ac, hydratable_serialization_failed as ad, parse as ae, stringify$1 as af, writable as ag, readable as ah, escape_html as ai, head as aj, attr_class as ak, attr as al, ensure_array_like as am, bind_props as an, stringify as ao, attr_style as ap, element as aq, get_next_sibling as b, set_hydrating as c, define_property as d, set_hydrate_node as e, flushSync as f, get as g, hydration_failed as h, init_operations as i, clear_text_content as j, component_root as k, hydrate_node as l, mutable_source as m, create_text as n, array_from as o, is_passive_event as p, set_active_reaction as q, render as r, set as s, set_active_effect as t, active_reaction as u, active_effect as v, setContext as w, hydrating as x, block as y, branch as z };
5374
- //# sourceMappingURL=server.js-mTMwhapa.js.map
5399
+ export { pop$1 as $, queue_micro_task as A, invoke_error_boundary as B, current_batch as C, pause_effect as D, move_effect as E, defer_effect as F, set_component_context as G, HYDRATION_ERROR as H, Batch as I, component_context as J, internal_set as K, LEGACY_PROPS as L, destroy_effect as M, next as N, skip_nodes as O, derived as P, effect_tracking as Q, render_effect as R, svelte_boundary_reset_noop as S, svelte_boundary_reset_onerror as T, source as U, untrack as V, increment as W, hydrate_next as X, push$1 as Y, mark_as_component as Z, hydration_mismatch as _, get_first_child as a, run as a0, noop as a1, hasContext as a2, getContext as a3, getAllContexts as a4, createContext as a5, ssr_context as a6, lifecycle_function_unavailable as a7, EFFECT_TRANSPARENT as a8, EFFECT_PRESERVED as a9, experimental_async_required as aa, get_render_context as ab, uneval as ac, hydratable_serialization_failed as ad, parse as ae, stringify$1 as af, safe_not_equal as ag, escape_html as ah, head as ai, attr_class as aj, attr as ak, ensure_array_like as al, bind_props as am, stringify as an, attr_style as ao, element as ap, get_next_sibling as b, set_hydrating as c, define_property as d, set_hydrate_node as e, flushSync as f, get as g, hydration_failed as h, init_operations as i, clear_text_content as j, component_root as k, hydrate_node as l, mutable_source as m, create_text as n, array_from as o, is_passive_event as p, set_active_reaction as q, render as r, set as s, set_active_effect as t, active_reaction as u, active_effect as v, setContext as w, hydrating as x, block as y, branch as z };
5400
+ //# sourceMappingURL=server.js-DxWEh0qK.js.map