@qwik.dev/core 2.0.0-beta.37 → 2.0.0-beta.38

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/testing 2.0.0-beta.37-dev+82dc74d
3
+ * @qwik.dev/core/testing 2.0.0-beta.38-dev+0339f17
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -21426,7 +21426,7 @@ import { _isJSXNode, _isStringifiable } from "@qwik.dev/core/internal";
21426
21426
  import { expect } from "vitest";
21427
21427
 
21428
21428
  // packages/qwik/src/core/client/vnode-utils.ts
21429
- import { isDev as isDev27 } from "@qwik.dev/core/build";
21429
+ import { isDev as isDev26 } from "@qwik.dev/core/build";
21430
21430
 
21431
21431
  // packages/qwik/src/core/shared/utils/qdev.ts
21432
21432
  var qDev = globalThis.qDev !== false;
@@ -21619,8 +21619,8 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
21619
21619
  // 27
21620
21620
  "Cannot coerce a Signal, use `.value` instead",
21621
21621
  // 28
21622
- "useComputed$ QRL {{0}} {{1}} cannot return a Promise",
21623
- // 29
21622
+ "",
21623
+ // 29 (cleared: useComputed$ now supports async functions)
21624
21624
  `===
21625
21625
  Qwik version {{0}} already imported while importing {{1}}.
21626
21626
  This can lead to issues due to duplicated shared structures.
@@ -21636,8 +21636,14 @@ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in
21636
21636
  // 33
21637
21637
  "Serialization Error: Cannot serialize function: {{0}}",
21638
21638
  // 34
21639
- "Cannot read .value of a clientOnly async signal during SSR. Use .loading to check state, or provide an initial value."
21639
+ "Cannot read .value of a clientOnly async signal during SSR. Use .loading to check state, or provide an initial value.",
21640
21640
  // 35
21641
+ "Invalid element name for SSR {{0}}",
21642
+ // 36
21643
+ "Invalid serialized Promise dependency",
21644
+ // 37
21645
+ "Invalid serialized Uint8Array payload"
21646
+ // 38
21641
21647
  ];
21642
21648
  let text = MAP[code2] ?? "";
21643
21649
  if (parts.length) {
@@ -21750,6 +21756,7 @@ var QBaseAttr = "q:base";
21750
21756
  var QLocaleAttr = "q:locale";
21751
21757
  var QManifestHashAttr = "q:manifest-hash";
21752
21758
  var QInstanceAttr = "q:instance";
21759
+ var QStatePrewarmAttr = "q:prewarm";
21753
21760
  var QContainerIsland = "q:container-island";
21754
21761
  var QContainerIslandEnd = "/" + QContainerIsland;
21755
21762
  var QIgnore = "q:ignore";
@@ -21934,7 +21941,7 @@ function retryOnPromise(fn, onError = justThrow) {
21934
21941
  }
21935
21942
 
21936
21943
  // packages/qwik/src/core/client/dom-container.ts
21937
- import { isDev as isDev24 } from "@qwik.dev/core/build";
21944
+ import { isDev as isDev23 } from "@qwik.dev/core/build";
21938
21945
 
21939
21946
  // packages/qwik/src/core/shared/utils/event-names.ts
21940
21947
  var EVENT_SUFFIX = "$";
@@ -22040,7 +22047,7 @@ Object.freeze(EMPTY_ARRAY);
22040
22047
  Object.freeze(EMPTY_OBJ);
22041
22048
 
22042
22049
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
22043
- import { isBrowser as isBrowser3, isDev as isDev23 } from "@qwik.dev/core/build";
22050
+ import { isBrowser as isBrowser3, isDev as isDev22 } from "@qwik.dev/core/build";
22044
22051
 
22045
22052
  // packages/qwik/src/core/shared/qrl/qrl-class-dev.ts
22046
22053
  import { isBrowser } from "@qwik.dev/core/build";
@@ -22051,7 +22058,7 @@ var initLazyRefDev = (lazy) => {
22051
22058
  }
22052
22059
  };
22053
22060
  var initQrlClassDev = (lazy, captures, qrl) => {
22054
- if (captures && typeof captures === "object") {
22061
+ if (Array.isArray(captures)) {
22055
22062
  for (let i2 = 0; i2 < captures.length; i2++) {
22056
22063
  const item = captures[i2];
22057
22064
  verifySerializable(item, "Captured variable in the closure can not be serialized");
@@ -22183,16 +22190,24 @@ function qrlToString(serializationContext, qrl, raw) {
22183
22190
  symbol = String(serializationContext.$addSyncFn$(null, 0, fn));
22184
22191
  }
22185
22192
  const captures = qrl.getCaptured();
22186
- let captureIds = null;
22193
+ let captureDeltas = null;
22187
22194
  if (captures && captures.length > 0) {
22188
- captureIds = captures.map((ref) => `${serializationContext.$addRoot$(ref)}`).join(" ");
22195
+ let previous = 0;
22196
+ let output = "";
22197
+ for (let i2 = 0; i2 < captures.length; i2++) {
22198
+ const captureId = serializationContext.$addRoot$(captures[i2]);
22199
+ const delta = captureId - previous;
22200
+ previous = captureId;
22201
+ output += (i2 === 0 ? "" : " ") + delta;
22202
+ }
22203
+ captureDeltas = output;
22189
22204
  }
22190
22205
  if (raw) {
22191
- return [chunk, symbol, captureIds];
22206
+ return [chunk, symbol, captureDeltas];
22192
22207
  }
22193
22208
  let qrlStringInline = `${chunk}#${symbol}`;
22194
- if (captureIds) {
22195
- qrlStringInline += `#${captureIds}`;
22209
+ if (captureDeltas) {
22210
+ qrlStringInline += `#${captureDeltas}`;
22196
22211
  }
22197
22212
  return qrlStringInline;
22198
22213
  }
@@ -22209,8 +22224,12 @@ function createQRLWithBackChannel(chunk, symbol, captures, container) {
22209
22224
  return createQRL(chunk, symbol, null, qrlImporter, captures, container);
22210
22225
  }
22211
22226
  function parseQRL(qrl, container) {
22212
- const [chunk, symbol, captures] = qrl.split("#");
22213
- return createQRLWithBackChannel(chunk, symbol, captures || null, container);
22227
+ const firstHash = qrl.indexOf("#");
22228
+ const secondHash = qrl.indexOf("#", firstHash + 1);
22229
+ const chunk = qrl.slice(0, firstHash);
22230
+ const symbol = secondHash === -1 ? qrl.slice(firstHash + 1) : qrl.slice(firstHash + 1, secondHash);
22231
+ const captures = secondHash !== -1 && secondHash + 1 < qrl.length ? qrl.slice(secondHash + 1) : null;
22232
+ return createQRLWithBackChannel(chunk, symbol, captures, container);
22214
22233
  }
22215
22234
  var QRL_RUNTIME_CHUNK = "mock-chunk";
22216
22235
 
@@ -22220,7 +22239,16 @@ function runEventHandlerQRL(handler, event, element, ctx) {
22220
22239
  return;
22221
22240
  }
22222
22241
  if (!ctx) {
22223
- ctx = newInvokeContextFromDOM(event, element);
22242
+ const container2 = getDomContainer(element);
22243
+ return whenContainerDataReady(
22244
+ container2,
22245
+ () => runEventHandlerQRL(
22246
+ handler,
22247
+ event,
22248
+ element,
22249
+ newInvokeContextFromDOM(event, element, container2)
22250
+ )
22251
+ );
22224
22252
  }
22225
22253
  const container = ctx.$container$;
22226
22254
  const hostElement = ctx.$hostElement$;
@@ -22464,7 +22492,7 @@ var PropsProxyHandler = class {
22464
22492
  addPropsProxyEffect(this, prop);
22465
22493
  }
22466
22494
  }
22467
- return value instanceof WrappedSignalImpl && value.$flags$ & 4 /* UNWRAP */ ? value.value : value;
22495
+ return value instanceof WrappedSignalImpl ? value.value : value;
22468
22496
  }
22469
22497
  set(_, prop, value) {
22470
22498
  if (prop === _OWNER) {
@@ -22605,8 +22633,8 @@ var isPropsProxy = (obj) => {
22605
22633
  return obj && _VAR_PROPS in obj;
22606
22634
  };
22607
22635
 
22608
- // packages/qwik/src/core/reactive-primitives/impl/async-signal-impl.ts
22609
- import { isBrowser as isBrowser2, isDev as isDev11, isServer as isServer5 } from "@qwik.dev/core/build";
22636
+ // packages/qwik/src/core/reactive-primitives/impl/computed-signal-impl.ts
22637
+ import { isBrowser as isBrowser2, isDev as isDev10, isServer as isServer5 } from "@qwik.dev/core/build";
22610
22638
 
22611
22639
  // packages/qwik/src/core/reactive-primitives/subscriber.ts
22612
22640
  import { isServer as isServer4 } from "@qwik.dev/core/build";
@@ -22692,87 +22720,9 @@ var cleanupFn = (target, handleError) => {
22692
22720
  };
22693
22721
 
22694
22722
  // packages/qwik/src/core/reactive-primitives/impl/computed-signal-impl.ts
22695
- import { isDev as isDev10 } from "@qwik.dev/core/build";
22696
22723
  var DEBUG2 = false;
22697
22724
  var log2 = (...args) => console.log("COMPUTED SIGNAL", ...args.map(qwikDebugToString));
22698
- var _a2, _b;
22699
- var ComputedSignalImpl = class extends (_b = SignalImpl, _a2 = _EFFECT_BACK_REF, _b) {
22700
- constructor(container, fn, flags = 1 /* INVALID */ | 16 /* SERIALIZATION_STRATEGY_ALWAYS */) {
22701
- super(container || tryGetInvokeContext()?.$container$, NEEDS_COMPUTATION);
22702
- /**
22703
- * The compute function is stored here.
22704
- *
22705
- * The computed functions must be executed synchronously (because of this we need to eagerly
22706
- * resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
22707
- */
22708
- __publicField(this, "$computeQrl$");
22709
- __publicField(this, "$flags$");
22710
- __publicField(this, _a2);
22711
- this.$computeQrl$ = fn;
22712
- this.$flags$ = flags;
22713
- }
22714
- invalidate() {
22715
- this.$flags$ |= 1 /* INVALID */;
22716
- const ctx = newInvokeContext();
22717
- ctx.$container$ = this.$container$ || void 0;
22718
- const running = retryOnPromise(invokeApply.bind(this, ctx, this.$computeIfNeeded$));
22719
- if (running) {
22720
- running.catch((err) => {
22721
- if (this.$container$) {
22722
- this.$container$.handleError(err, null);
22723
- } else {
22724
- console.error("Error during computation", err);
22725
- }
22726
- });
22727
- }
22728
- }
22729
- get untrackedValue() {
22730
- this.$computeIfNeeded$();
22731
- isDev10 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
22732
- return this.$untrackedValue$;
22733
- }
22734
- set untrackedValue(value) {
22735
- this.$untrackedValue$ = value;
22736
- }
22737
- $computeIfNeeded$() {
22738
- if (!(this.$flags$ & 1 /* INVALID */)) {
22739
- return;
22740
- }
22741
- const computeQrl = this.$computeQrl$;
22742
- throwIfQRLNotResolved(computeQrl);
22743
- const ctx = tryGetInvokeContext();
22744
- const previousEffectSubscription = ctx?.$effectSubscriber$;
22745
- if (ctx) {
22746
- const effectSubscriber = getSubscriber(this, "." /* VNODE */);
22747
- clearEffectSubscription(this.$container$, effectSubscriber);
22748
- ctx.$effectSubscriber$ = effectSubscriber;
22749
- }
22750
- try {
22751
- const untrackedValue = computeQrl.getFn(ctx)();
22752
- if (isPromise(untrackedValue)) {
22753
- throw qError(29 /* computedNotSync */, [
22754
- computeQrl.dev ? computeQrl.dev.file : "",
22755
- computeQrl.$hash$
22756
- ]);
22757
- }
22758
- DEBUG2 && log2("Signal.$compute$", untrackedValue);
22759
- this.$flags$ &= ~1 /* INVALID */;
22760
- super.value = untrackedValue;
22761
- } finally {
22762
- if (ctx) {
22763
- ctx.$effectSubscriber$ = previousEffectSubscription;
22764
- }
22765
- }
22766
- }
22767
- };
22768
-
22769
- // packages/qwik/src/core/reactive-primitives/impl/async-signal-impl.ts
22770
- var DEBUG3 = false;
22771
- var log3 = (...args) => (
22772
- // eslint-disable-next-line no-console
22773
- console.log("ASYNC COMPUTED SIGNAL", ...args.map(qwikDebugToString))
22774
- );
22775
- var AsyncJob = class {
22725
+ var Job = class {
22776
22726
  constructor($signal$, info, $infoVersion$) {
22777
22727
  this.$signal$ = $signal$;
22778
22728
  /** First holds the compute promise and then the cleanup promise */
@@ -22792,8 +22742,8 @@ var AsyncJob = class {
22792
22742
  }
22793
22743
  /** Backward compatible cache method for resource */
22794
22744
  cache() {
22795
- isDev11 && console.error(
22796
- "useResource cache() method does not do anything. Use `useAsync$` instead of `useResource$`, use the `expires` option for polling behavior."
22745
+ isDev10 && console.error(
22746
+ "useResource cache() method does not do anything. Use `useComputed$` instead of `useResource$`, use the `expires` option for polling behavior."
22797
22747
  );
22798
22748
  }
22799
22749
  get previous() {
@@ -22808,39 +22758,44 @@ var AsyncJob = class {
22808
22758
  }
22809
22759
  }
22810
22760
  };
22811
- var _a3, _b2;
22812
- var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BACK_REF, _b2) {
22761
+ var _a2, _b;
22762
+ var ComputedSignalImpl = class extends (_b = SignalImpl, _a2 = _EFFECT_BACK_REF, _b) {
22813
22763
  constructor(container, fn, flags = 1 /* INVALID */ | 16 /* SERIALIZATION_STRATEGY_ALWAYS */, options) {
22814
- super(container, fn, flags);
22815
- __publicField(this, "$untrackedLoading$", false);
22816
- __publicField(this, "$untrackedError$");
22817
- __publicField(this, "$current$", null);
22818
- __publicField(this, _a3);
22764
+ super(container || tryGetInvokeContext()?.$container$, NEEDS_COMPUTATION);
22765
+ /**
22766
+ * The compute function is stored here.
22767
+ *
22768
+ * Sync computed functions must be executed synchronously (because of this we need to eagerly
22769
+ * resolve the QRL during the mark dirty phase so that any call to it will be synchronous).
22770
+ */
22771
+ __publicField(this, "$computeQrl$");
22772
+ __publicField(this, "$flags$");
22773
+ __publicField(this, _a2);
22774
+ this.$computeQrl$ = fn;
22775
+ this.$flags$ = flags;
22819
22776
  if (!options) {
22820
22777
  return;
22821
22778
  }
22822
22779
  const initial = options.initial;
22823
22780
  if (initial !== void 0) {
22824
- const initialValue = typeof initial === "function" ? initial() : initial;
22825
- this.$untrackedValue$ = initialValue;
22781
+ this.$untrackedValue$ = typeof initial === "function" ? initial() : initial;
22826
22782
  }
22827
22783
  const concurrency = options.concurrency;
22828
22784
  if (concurrency !== void 0 && concurrency >= 0 && concurrency !== 1) {
22829
22785
  this.$concurrency$ = concurrency;
22830
22786
  this.$jobs$ = [];
22831
22787
  }
22832
- const timeout = options.timeout;
22833
- if (timeout) {
22834
- this.$timeoutMs$ = timeout;
22788
+ if (options.timeout) {
22789
+ this.$timeoutMs$ = options.timeout;
22835
22790
  }
22836
22791
  if (options.eagerCleanup) {
22837
22792
  this.$flags$ |= 32 /* EAGER_CLEANUP */;
22838
22793
  }
22839
22794
  if (options.clientOnly) {
22840
- this.$flags$ |= 64 /* CLIENT_ONLY */;
22795
+ this.$flags$ |= 64 /* CLIENT_ONLY */ | 512 /* ASYNC_MODE */;
22841
22796
  }
22842
22797
  if (options.allowStale === false) {
22843
- if (isDev11 && initial !== void 0) {
22798
+ if (isDev10 && initial !== void 0) {
22844
22799
  throw new Error(
22845
22800
  "allowStale: false and initial cannot be used together. allowStale: false clears the value on invalidation, which conflicts with providing an initial value."
22846
22801
  );
@@ -22855,27 +22810,28 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
22855
22810
  this.$flags$ |= 256 /* NO_POLL */;
22856
22811
  }
22857
22812
  }
22858
- get untrackedValue() {
22859
- this.$computeIfNeeded$();
22860
- if (this.$current$?.$promise$) {
22861
- if (this.$untrackedValue$ === NEEDS_COMPUTATION || (qTest ? isServerPlatform() : isServer5)) {
22862
- DEBUG3 && log3("Throwing promise while computing initial value", this);
22863
- throw this.$current$?.$promise$;
22864
- }
22865
- DEBUG3 && log3("Returning stale value", this.$untrackedValue$, "while computing", this.$current$);
22866
- return this.$untrackedValue$;
22813
+ invalidate(info) {
22814
+ if (arguments.length > 0) {
22815
+ this.$info$ = info;
22816
+ this.$infoVersion$ = this.$infoVersion$ === void 0 ? 1 : this.$infoVersion$ + 1;
22867
22817
  }
22868
- if (this.$untrackedError$) {
22869
- DEBUG3 && log3("Throwing error while reading value", this);
22870
- throw this.$untrackedError$;
22818
+ if (this.$flags$ & 512 /* ASYNC_MODE */) {
22819
+ this.$setInvalid$(true, this.$flags$ & 128 /* CLEAR_ON_INVALIDATE */);
22820
+ return;
22871
22821
  }
22872
- if ((qTest ? isServerPlatform() : isServer5) && this.$flags$ & 64 /* CLIENT_ONLY */ && this.$untrackedValue$ === NEEDS_COMPUTATION) {
22873
- throw qError(35 /* asyncClientOnlyValueDuringSSR */);
22822
+ this.$flags$ |= 1 /* INVALID */;
22823
+ const ctx = newInvokeContext();
22824
+ ctx.$container$ = this.$container$ || void 0;
22825
+ const running = retryOnPromise(invokeApply.bind(this, ctx, this.$computeIfNeeded$));
22826
+ if (isPromise(running)) {
22827
+ running.catch((err) => {
22828
+ if (this.$container$) {
22829
+ this.$container$.handleError(err, null);
22830
+ } else {
22831
+ console.error("Error during computation", err);
22832
+ }
22833
+ });
22874
22834
  }
22875
- return this.$untrackedValue$;
22876
- }
22877
- set untrackedValue(value) {
22878
- this.$untrackedValue$ = value;
22879
22835
  }
22880
22836
  /**
22881
22837
  * Read the value, subscribing if in a tracking context. Triggers computation if needed.
@@ -22893,32 +22849,62 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
22893
22849
  }
22894
22850
  set value(value) {
22895
22851
  this.$flags$ &= ~1 /* INVALID */;
22896
- this.untrackedLoading = false;
22897
22852
  this.untrackedError = void 0;
22898
- this.$info$ = void 0;
22899
- if (this.$jobs$) {
22900
- for (let i2 = 0; i2 < this.$jobs$.length; i2++) {
22901
- this.$jobs$[i2].$canWrite$ = false;
22853
+ if (this.$flags$ & 512 /* ASYNC_MODE */) {
22854
+ this.untrackedPending = false;
22855
+ this.$info$ = void 0;
22856
+ if (this.$jobs$) {
22857
+ for (let i2 = 0; i2 < this.$jobs$.length; i2++) {
22858
+ this.$jobs$[i2].$canWrite$ = false;
22859
+ }
22860
+ } else if (this.$current$) {
22861
+ this.$current$.$canWrite$ = false;
22902
22862
  }
22903
- } else if (this.$current$) {
22904
- this.$current$.$canWrite$ = false;
22863
+ this.$clearNextPoll$();
22864
+ super.value = value;
22865
+ this.$scheduleNextPoll$();
22866
+ return;
22905
22867
  }
22906
- this.$clearNextPoll$();
22907
22868
  super.value = value;
22908
- this.$scheduleNextPoll$();
22869
+ }
22870
+ get untrackedValue() {
22871
+ this.$computeIfNeeded$();
22872
+ if (this.$current$?.$promise$) {
22873
+ if (this.$untrackedValue$ === NEEDS_COMPUTATION || (qTest ? isServerPlatform() : isServer5)) {
22874
+ DEBUG2 && log2("Throwing promise while computing initial value", this);
22875
+ throw this.$current$?.$promise$;
22876
+ }
22877
+ DEBUG2 && log2("Returning stale value", this.$untrackedValue$, "while computing", this.$current$);
22878
+ return this.$untrackedValue$;
22879
+ }
22880
+ if (this.$untrackedError$) {
22881
+ DEBUG2 && log2("Throwing error while reading value", this);
22882
+ throw this.$untrackedError$;
22883
+ }
22884
+ if ((qTest ? isServerPlatform() : isServer5) && this.$flags$ & 64 /* CLIENT_ONLY */ && this.$untrackedValue$ === NEEDS_COMPUTATION) {
22885
+ throw qError(35 /* asyncClientOnlyValueDuringSSR */);
22886
+ }
22887
+ isDev10 && !(this.$flags$ & 512 /* ASYNC_MODE */) && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
22888
+ return this.$untrackedValue$;
22889
+ }
22890
+ set untrackedValue(value) {
22891
+ this.$untrackedValue$ = value;
22909
22892
  }
22910
22893
  /**
22911
22894
  * Loading is true if the signal is still waiting for the promise to resolve, false if the promise
22912
- * has resolved or rejected.
22895
+ * has resolved or rejected (or the compute function is synchronous).
22896
+ *
22897
+ * Accessing `.pending` will trigger computation if needed, since it's often used like
22913
22898
  *
22914
- * Accessing .loading will trigger computation if needed, since it's often used like
22915
- * `signal.loading ? <Loading /> : signal.value`.
22899
+ * ```ts
22900
+ * signal.pending ? <Loading /> : signal.value
22901
+ * ```
22916
22902
  */
22917
- get loading() {
22918
- const val = this.untrackedLoading;
22903
+ get pending() {
22904
+ const val = this.untrackedPending;
22919
22905
  const ctx = tryGetInvokeContext();
22920
22906
  if (ctx && (this.$container$ || (this.$container$ = ctx.$container$ || null))) {
22921
- isDev11 && assertTrue(
22907
+ isDev10 && assertTrue(
22922
22908
  !ctx.$container$ || ctx.$container$ === this.$container$,
22923
22909
  "Do not use signals across containers"
22924
22910
  );
@@ -22931,27 +22917,46 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
22931
22917
  }
22932
22918
  return val;
22933
22919
  }
22934
- set untrackedLoading(value) {
22935
- if (value !== this.$untrackedLoading$) {
22936
- this.$untrackedLoading$ = value;
22937
- DEBUG3 && log3("Set untrackedLoading", value);
22920
+ set untrackedPending(value) {
22921
+ if (value !== !!this.$untrackedPending$) {
22922
+ this.$untrackedPending$ = value;
22923
+ DEBUG2 && log2("Set untrackedPending", value);
22938
22924
  scheduleEffects(this.$container$, this, this.$loadingEffects$);
22939
22925
  }
22940
22926
  }
22941
- get untrackedLoading() {
22927
+ get untrackedPending() {
22942
22928
  this.$computeIfNeeded$();
22943
22929
  if ((qTest ? isServerPlatform() : isServer5) && this.$current$?.$promise$) {
22944
- DEBUG3 && log3("Throwing loading promise for SSR");
22930
+ DEBUG2 && log2("Throwing loading promise for SSR");
22945
22931
  throw this.$current$?.$promise$;
22946
22932
  }
22947
- return this.$untrackedLoading$;
22933
+ return !!this.$untrackedPending$;
22934
+ }
22935
+ /** @deprecated Use `pending` instead */
22936
+ get loading() {
22937
+ return this.pending;
22948
22938
  }
22949
- /** The error that occurred when the signal was resolved. */
22939
+ /** @deprecated Use `untrackedPending` instead */
22940
+ get untrackedLoading() {
22941
+ return this.untrackedPending;
22942
+ }
22943
+ set untrackedLoading(value) {
22944
+ this.untrackedPending = value;
22945
+ }
22946
+ /**
22947
+ * The error the compute function threw or rejected with.
22948
+ *
22949
+ * Accessing .error will trigger computation if needed, since it's often used like
22950
+ *
22951
+ * ```ts
22952
+ * signal.error ? <Failed /> : signal.value
22953
+ * ```
22954
+ */
22950
22955
  get error() {
22951
22956
  const val = this.untrackedError;
22952
22957
  const ctx = tryGetInvokeContext();
22953
22958
  if (ctx && (this.$container$ || (this.$container$ = ctx.$container$ || null))) {
22954
- isDev11 && assertTrue(
22959
+ isDev10 && assertTrue(
22955
22960
  !ctx.$container$ || ctx.$container$ === this.$container$,
22956
22961
  "Do not use signals across containers"
22957
22962
  );
@@ -22971,6 +22976,10 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
22971
22976
  }
22972
22977
  }
22973
22978
  get untrackedError() {
22979
+ this.$computeIfNeeded$();
22980
+ if ((qTest ? isServerPlatform() : isServer5) && this.$current$?.$promise$) {
22981
+ throw this.$current$?.$promise$;
22982
+ }
22974
22983
  return this.$untrackedError$;
22975
22984
  }
22976
22985
  get expires() {
@@ -23010,14 +23019,6 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23010
23019
  }
23011
23020
  this.expires = Math.abs(value);
23012
23021
  }
23013
- /** Invalidates the signal, causing it to re-compute its value. */
23014
- async invalidate(info) {
23015
- if (arguments.length > 0) {
23016
- this.$info$ = info;
23017
- this.$infoVersion$ = this.$infoVersion$ === void 0 ? 1 : this.$infoVersion$ + 1;
23018
- }
23019
- this.$setInvalid$(true, this.$flags$ & 128 /* CLEAR_ON_INVALIDATE */);
23020
- }
23021
23022
  $setInvalid$(allowRecalc, mustClear) {
23022
23023
  this.$flags$ |= 1 /* INVALID */;
23023
23024
  this.$clearNextPoll$();
@@ -23060,8 +23061,81 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23060
23061
  if (!(this.$flags$ & 1 /* INVALID */)) {
23061
23062
  return;
23062
23063
  }
23064
+ if (this.$flags$ & 512 /* ASYNC_MODE */) {
23065
+ return this.$computeAsync$();
23066
+ }
23067
+ const computeQrl = this.$computeQrl$;
23068
+ throwIfQRLNotResolved(computeQrl);
23069
+ const prevJob = this.$current$;
23070
+ if (prevJob && !prevJob.$cleanupRequested$) {
23071
+ prevJob.$cleanupRequested$ = true;
23072
+ prevJob.$abortController$?.abort();
23073
+ this.$runCleanupCallbacks$(prevJob);
23074
+ }
23075
+ const running = new Job(this, this.$info$, this.$infoVersion$);
23076
+ this.$current$ = running;
23077
+ let result;
23078
+ try {
23079
+ result = this.$invokeComputeFn$(computeQrl.resolved, running);
23080
+ } catch (err) {
23081
+ if (isPromise(err)) {
23082
+ throw err;
23083
+ }
23084
+ if (running.$infoVersion$ === this.$infoVersion$) {
23085
+ this.$info$ = void 0;
23086
+ }
23087
+ this.$flags$ &= ~1 /* INVALID */;
23088
+ this.$setError$(running, err);
23089
+ return;
23090
+ }
23091
+ if (isPromise(result)) {
23092
+ this.$flags$ |= 512 /* ASYNC_MODE */;
23093
+ this.$flags$ &= ~1 /* INVALID */;
23094
+ let first = result;
23095
+ const compute = () => {
23096
+ const r = first ?? this.$invokeComputeFn$(this.$computeQrl$.resolved, running);
23097
+ first = void 0;
23098
+ return r;
23099
+ };
23100
+ running.$promise$ = this.$settleComputation$(running, () => retryOnPromise(compute));
23101
+ return;
23102
+ }
23103
+ DEBUG2 && log2("Signal.$compute$", result);
23104
+ if (running.$infoVersion$ === this.$infoVersion$) {
23105
+ this.$info$ = void 0;
23106
+ }
23107
+ this.$flags$ &= ~1 /* INVALID */;
23108
+ this.untrackedError = void 0;
23109
+ super.value = result;
23110
+ }
23111
+ /**
23112
+ * Invoke the compute fn with the ComputeCtx argument. CTX_ARG signals (useAsync$, useResource$)
23113
+ * only track via its explicit track(). Computeds auto-track every synchronous read instead; after
23114
+ * the first await they must use the explicit track() too.
23115
+ */
23116
+ $invokeComputeFn$(fn, job) {
23117
+ const computeFn = fn;
23118
+ if (this.$flags$ & 1024 /* CTX_ARG */) {
23119
+ let iCtx = tryGetInvokeContext();
23120
+ if (iCtx?.$effectSubscriber$) {
23121
+ iCtx = { ...iCtx, $effectSubscriber$: void 0 };
23122
+ }
23123
+ return invokeApply(iCtx, computeFn, [job]);
23124
+ }
23125
+ const container = this.$container$ || (this.$container$ = tryGetInvokeContext()?.$container$ || null);
23126
+ const subscriber = getSubscriber(this, "." /* VNODE */);
23127
+ if (container) {
23128
+ clearEffectSubscription(container, subscriber);
23129
+ }
23130
+ const ctx = newInvokeContext();
23131
+ ctx.$container$ = container || void 0;
23132
+ ctx.$effectSubscriber$ = subscriber;
23133
+ return invokeApply(ctx, computeFn, [job]);
23134
+ }
23135
+ /** Start an async computation (the async engine; assumes the INVALID flag is set) */
23136
+ $computeAsync$() {
23063
23137
  if ((qTest ? isServerPlatform() : isServer5) && this.$flags$ & 64 /* CLIENT_ONLY */) {
23064
- this.$untrackedLoading$ = true;
23138
+ this.$untrackedPending$ = true;
23065
23139
  this.$container$?.serializationCtx.$eagerResume$.add(this);
23066
23140
  return;
23067
23141
  }
@@ -23073,13 +23147,13 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23073
23147
  }
23074
23148
  const limit = this.$concurrency$ === 0 ? Number.POSITIVE_INFINITY : this.$concurrency$ ?? 1;
23075
23149
  if (this.$jobs$ ? this.$jobs$.length >= limit : current?.$promise$) {
23076
- DEBUG3 && log3(`Concurrency limit ${limit} reached, not starting new computation`);
23150
+ DEBUG2 && log2(`Concurrency limit ${limit} reached, not starting new computation`);
23077
23151
  this.$flags$ |= 1 /* INVALID */;
23078
23152
  return;
23079
23153
  }
23080
- DEBUG3 && log3("Starting new async computation");
23154
+ DEBUG2 && log2("Starting new async computation");
23081
23155
  const infoVersion = this.$infoVersion$;
23082
- const running = new AsyncJob(this, this.$info$, infoVersion);
23156
+ const running = new Job(this, this.$info$, infoVersion);
23083
23157
  this.$current$ = running;
23084
23158
  if (this.$jobs$) {
23085
23159
  this.$jobs$.push(running);
@@ -23087,29 +23161,36 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23087
23161
  running.$promise$ = this.$runComputation$(running);
23088
23162
  }
23089
23163
  async $runComputation$(running) {
23090
- const isCurrent = () => running === this.$current$;
23091
23164
  let fn = this.$computeQrl$.resolved;
23092
23165
  if (!fn) {
23093
- this.untrackedLoading = true;
23166
+ this.untrackedPending = true;
23094
23167
  fn = await this.$computeQrl$.resolve();
23095
23168
  if (running.$abortController$?.signal.aborted) {
23096
- DEBUG3 && log3("Computation aborted before it started");
23169
+ DEBUG2 && log2("Computation aborted before it started");
23097
23170
  running.$promise$ = null;
23098
23171
  return;
23099
23172
  }
23100
23173
  }
23174
+ if (this.$timeoutMs$) {
23175
+ this.$computationTimeoutId$ = setTimeout(() => {
23176
+ const error = new Error(`timeout ${this.$timeoutMs$}ms`);
23177
+ this.$setError$(running, error);
23178
+ running.$abortController$?.abort(error);
23179
+ }, this.$timeoutMs$);
23180
+ }
23181
+ return this.$settleComputation$(
23182
+ running,
23183
+ () => retryOnPromise(() => this.$invokeComputeFn$(fn, running))
23184
+ );
23185
+ }
23186
+ /** Await the computation and publish its result, error, and loading transitions. */
23187
+ async $settleComputation$(running, compute) {
23188
+ const isCurrent = () => running === this.$current$;
23101
23189
  try {
23102
- if (this.$timeoutMs$) {
23103
- this.$computationTimeoutId$ = setTimeout(() => {
23104
- const error = new Error(`timeout ${this.$timeoutMs$}ms`);
23105
- this.$setError$(running, error);
23106
- running.$abortController$?.abort(error);
23107
- }, this.$timeoutMs$);
23108
- }
23109
- const valuePromise = retryOnPromise(fn.bind(null, running));
23190
+ const valuePromise = compute();
23110
23191
  let value;
23111
23192
  if (isPromise(valuePromise)) {
23112
- this.untrackedLoading = true;
23193
+ this.untrackedPending = true;
23113
23194
  value = await valuePromise;
23114
23195
  } else {
23115
23196
  value = valuePromise;
@@ -23127,13 +23208,13 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23127
23208
  }
23128
23209
  }
23129
23210
  }
23130
- DEBUG3 && log3("Promise resolved", value);
23211
+ DEBUG2 && log2("Promise resolved", value);
23131
23212
  this.untrackedError = void 0;
23132
23213
  super.value = value;
23133
23214
  }
23134
23215
  } catch (err) {
23135
23216
  running.$promise$ = null;
23136
- DEBUG3 && log3("Error caught in promise.catch", err);
23217
+ DEBUG2 && log2("Error caught in promise.catch", err);
23137
23218
  this.$setError$(running, err);
23138
23219
  }
23139
23220
  if (isCurrent()) {
@@ -23142,10 +23223,10 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23142
23223
  this.$info$ = void 0;
23143
23224
  }
23144
23225
  if (this.$flags$ & 1 /* INVALID */) {
23145
- DEBUG3 && log3("Computation finished but signal is invalid, re-running");
23226
+ DEBUG2 && log2("Computation finished but signal is invalid, re-running");
23146
23227
  this.$computeIfNeeded$();
23147
23228
  } else {
23148
- this.untrackedLoading = false;
23229
+ this.untrackedPending = false;
23149
23230
  this.$scheduleNextPoll$();
23150
23231
  }
23151
23232
  }
@@ -23205,15 +23286,14 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23205
23286
  if (job.$cleanupRequested$) {
23206
23287
  return;
23207
23288
  }
23208
- DEBUG3 && log3("Requesting cleanups for job", job);
23289
+ DEBUG2 && log2("Requesting cleanups for job", job);
23209
23290
  job.$cleanupRequested$ = true;
23210
23291
  job.$abortController$?.abort(reason);
23211
23292
  job.$promise$ = maybeThen(job.$promise$, () => this.$runCleanups$(job));
23212
23293
  }
23213
- /** Clean up and trigger signal compute once complete */
23214
- $runCleanups$(job) {
23294
+ /** Run a job's cleanup callbacks, returning a promise when any of them are async. */
23295
+ $runCleanupCallbacks$(job) {
23215
23296
  const cleanups = job.$cleanups$;
23216
- DEBUG3 && log3("cleanup start", job);
23217
23297
  const onError = (err) => {
23218
23298
  const handleError = this.$container$?.handleError;
23219
23299
  if (handleError) {
@@ -23222,24 +23302,9 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23222
23302
  console.error("Error in async signal cleanup", err);
23223
23303
  }
23224
23304
  };
23225
- const onDone = () => {
23226
- job.$promise$ = null;
23227
- if (cleanups) {
23228
- cleanups.length = 0;
23229
- }
23230
- DEBUG3 && log3("cleanup finished", job);
23231
- const jobs = this.$jobs$;
23232
- if (jobs) {
23233
- const idx = jobs.indexOf(job);
23234
- if (idx !== -1) {
23235
- jobs.splice(idx, 1);
23236
- }
23237
- }
23238
- this.$computeIfNeeded$();
23239
- };
23240
23305
  let promiseChain = void 0;
23241
23306
  if (cleanups) {
23242
- DEBUG3 && log3("cleanup start for real", job);
23307
+ DEBUG2 && log2("cleanup start for real", job);
23243
23308
  for (let i2 = 0; i2 < cleanups.length; i2++) {
23244
23309
  try {
23245
23310
  const result = cleanups[i2]();
@@ -23250,7 +23315,26 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
23250
23315
  onError(err);
23251
23316
  }
23252
23317
  }
23318
+ cleanups.length = 0;
23253
23319
  }
23320
+ return promiseChain;
23321
+ }
23322
+ /** Clean up and trigger signal compute once complete */
23323
+ $runCleanups$(job) {
23324
+ DEBUG2 && log2("cleanup start", job);
23325
+ const onDone = () => {
23326
+ job.$promise$ = null;
23327
+ DEBUG2 && log2("cleanup finished", job);
23328
+ const jobs = this.$jobs$;
23329
+ if (jobs) {
23330
+ const idx = jobs.indexOf(job);
23331
+ if (idx !== -1) {
23332
+ jobs.splice(idx, 1);
23333
+ }
23334
+ }
23335
+ this.$computeIfNeeded$();
23336
+ };
23337
+ const promiseChain = this.$runCleanupCallbacks$(job);
23254
23338
  if (promiseChain) {
23255
23339
  return promiseChain.then(onDone);
23256
23340
  } else {
@@ -23279,8 +23363,8 @@ var implicit$FirstArg = (fn) => {
23279
23363
  };
23280
23364
 
23281
23365
  // packages/qwik/src/core/reactive-primitives/impl/serializer-signal-impl.ts
23282
- var DEBUG4 = false;
23283
- var log4 = (...args) => console.log("SERIALIZER SIGNAL", ...args.map(qwikDebugToString));
23366
+ var DEBUG3 = false;
23367
+ var log3 = (...args) => console.log("SERIALIZER SIGNAL", ...args.map(qwikDebugToString));
23284
23368
  var SerializerSignalImpl = class extends ComputedSignalImpl {
23285
23369
  constructor(container, argQrl) {
23286
23370
  super(
@@ -23307,7 +23391,7 @@ var SerializerSignalImpl = class extends ComputedSignalImpl {
23307
23391
  );
23308
23392
  this.$didInitialize$ = true;
23309
23393
  this.$flags$ &= ~1 /* INVALID */;
23310
- DEBUG4 && log4("SerializerSignal.$compute$", untrackedValue);
23394
+ DEBUG3 && log3("SerializerSignal.$compute$", untrackedValue);
23311
23395
  const didChange = this.$didInitialize$ && untrackedValue !== "undefined" || untrackedValue !== this.$untrackedValue$;
23312
23396
  if (didChange) {
23313
23397
  this.$untrackedValue$ = untrackedValue;
@@ -23316,6 +23400,13 @@ var SerializerSignalImpl = class extends ComputedSignalImpl {
23316
23400
  }
23317
23401
  };
23318
23402
 
23403
+ // packages/qwik/src/core/reactive-primitives/impl/async-signal-impl.ts
23404
+ var AsyncSignalImpl = class extends ComputedSignalImpl {
23405
+ constructor(container, fn, flags = 1 /* INVALID */ | 16 /* SERIALIZATION_STRATEGY_ALWAYS */, options) {
23406
+ super(container, fn, flags | 512 /* ASYNC_MODE */ | 1024 /* CTX_ARG */, options);
23407
+ }
23408
+ };
23409
+
23319
23410
  // packages/qwik/src/core/reactive-primitives/signal-api.ts
23320
23411
  var createSerializerSignal = (arg) => {
23321
23412
  return new SerializerSignalImpl(null, arg);
@@ -23433,8 +23524,11 @@ function setCursorPosition(container, cursorData, position) {
23433
23524
  }
23434
23525
  }
23435
23526
  function mergeCursors(container, newCursorData, oldCursor) {
23436
- removeCursorFromQueue(oldCursor, container);
23437
23527
  const oldCursorData = getCursorData(oldCursor);
23528
+ if (!oldCursorData || oldCursorData === newCursorData) {
23529
+ return;
23530
+ }
23531
+ removeCursorFromQueue(oldCursor, container);
23438
23532
  mergeCursorData(newCursorData, oldCursorData);
23439
23533
  }
23440
23534
  function mergeCursorData(newCursorData, oldCursorData) {
@@ -23493,7 +23587,7 @@ function setCursorData(vNode, cursorData) {
23493
23587
  }
23494
23588
 
23495
23589
  // packages/qwik/src/core/client/vnode-diff.ts
23496
- import { isDev as isDev14 } from "@qwik.dev/core/build";
23590
+ import { isDev as isDev13 } from "@qwik.dev/core/build";
23497
23591
 
23498
23592
  // packages/qwik/src/core/reactive-primitives/subscription-data.ts
23499
23593
  var SubscriptionData = class {
@@ -23504,11 +23598,11 @@ var SubscriptionData = class {
23504
23598
  };
23505
23599
 
23506
23600
  // packages/qwik/src/core/shared/component.public.ts
23507
- import { isDev as isDev12 } from "@qwik.dev/core/build";
23601
+ import { isDev as isDev11 } from "@qwik.dev/core/build";
23508
23602
  var componentQrl = (componentQrl3) => {
23509
23603
  function QwikComponent(props, key, flags = 0) {
23510
- isDev12 && assertQrl(componentQrl3);
23511
- isDev12 && assertNumber(flags, "The Qwik Component was not invoked correctly");
23604
+ isDev11 && assertQrl(componentQrl3);
23605
+ isDev11 && assertNumber(flags, "The Qwik Component was not invoked correctly");
23512
23606
  const hash = qTest ? "sX" : componentQrl3.$hash$.slice(0, 4);
23513
23607
  const finalKey = hash + ":" + (key ? key : "");
23514
23608
  const InnerCmp = () => {
@@ -23603,9 +23697,9 @@ var SSRRaw = () => null;
23603
23697
  var SSRComment = () => null;
23604
23698
 
23605
23699
  // packages/qwik/src/core/client/vnode-namespace.ts
23606
- import { isDev as isDev13 } from "@qwik.dev/core/build";
23700
+ import { isDev as isDev12 } from "@qwik.dev/core/build";
23607
23701
  var isForeignObjectElement = (elementName) => {
23608
- return isDev13 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23702
+ return isDev12 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
23609
23703
  };
23610
23704
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
23611
23705
  var isMathElement = (elementName) => elementName === "math";
@@ -24664,8 +24758,8 @@ function runDiff(diffContext, jsxNode, vStartNode, vCurrent = vnode_getFirstChil
24664
24758
  }
24665
24759
  function diff(diffContext, jsxNode, vStartNode, vCurrent = vnode_getFirstChild(vStartNode), vEnd = null, forceCreationMode = false) {
24666
24760
  const previousCreationMode = diffContext.$isCreationMode$;
24667
- isDev14 && assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode");
24668
- isDev14 && assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode");
24761
+ isDev13 && assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode");
24762
+ isDev13 && assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode");
24669
24763
  diffContext.$isCreationMode$ = forceCreationMode || previousCreationMode;
24670
24764
  diffContext.$vParent$ = vStartNode;
24671
24765
  diffContext.$vNewNode$ = null;
@@ -24679,7 +24773,7 @@ function diff(diffContext, jsxNode, vStartNode, vCurrent = vnode_getFirstChild(v
24679
24773
  }
24680
24774
  while (diffContext.$stack$.length) {
24681
24775
  while (diffContext.$jsxIdx$ < diffContext.$jsxCount$) {
24682
- isDev14 && assertFalse(
24776
+ isDev13 && assertFalse(
24683
24777
  diffContext.$vParent$ === diffContext.$vCurrent$,
24684
24778
  "Parent and current can't be the same"
24685
24779
  );
@@ -24720,9 +24814,8 @@ function diff(diffContext, jsxNode, vStartNode, vCurrent = vnode_getFirstChild(v
24720
24814
  diffContext,
24721
24815
  diffContext.$jsxValue$.children,
24722
24816
  true,
24723
- // special case for projection, we don't want to expect no children
24724
- // because the projection's children are not removed
24725
- false
24817
+ /* isProjection */
24818
+ true
24726
24819
  );
24727
24820
  } else if (type === SSRComment) {
24728
24821
  expectNoMore(diffContext);
@@ -24811,18 +24904,22 @@ function advance(diffContext) {
24811
24904
  diffContext.$vCurrent$ = peekNextSiblingWithinBoundary(diffContext, diffContext.$vCurrent$);
24812
24905
  }
24813
24906
  }
24814
- function descend(diffContext, children, descendVNode, shouldExpectNoChildren = true) {
24815
- if (shouldExpectNoChildren && (children == null || descendVNode && isArray(children) && children.length === 0)) {
24907
+ function descend(diffContext, children, descendVNode, isProjection = false) {
24908
+ if (!isProjection && (children == null || descendVNode && isArray(children) && children.length === 0)) {
24816
24909
  expectNoChildren(diffContext);
24817
24910
  return;
24818
24911
  }
24819
24912
  stackPush(diffContext, children, descendVNode);
24820
24913
  if (descendVNode) {
24821
- isDev14 && assertDefined(
24914
+ isDev13 && assertDefined(
24822
24915
  diffContext.$vCurrent$ || diffContext.$vNewNode$,
24823
24916
  "Expecting vCurrent to be defined."
24824
24917
  );
24825
- const creationMode = diffContext.$isCreationMode$ || !!diffContext.$vNewNode$ || !vnode_getFirstChild(diffContext.$vCurrent$);
24918
+ const creationMode = (
24919
+ // a projection keeps its children across re-renders, so it never inherits
24920
+ // creation mode from a not-yet-rendered host; create only if new or empty
24921
+ !isProjection && diffContext.$isCreationMode$ || !!diffContext.$vNewNode$ || !vnode_getFirstChild(diffContext.$vCurrent$)
24922
+ );
24826
24923
  diffContext.$isCreationMode$ = creationMode;
24827
24924
  diffContext.$vSideBuffer$ = null;
24828
24925
  diffContext.$vSiblings$ = null;
@@ -24945,8 +25042,8 @@ function expectProjection(diffContext) {
24945
25042
  diffContext.$vCurrent$ = diffContext.$vCurrent$ && diffContext.$vCurrent$.flags & 32 /* Deleted */ ? null : diffContext.$vCurrent$;
24946
25043
  if (diffContext.$vCurrent$ == null) {
24947
25044
  diffContext.$vNewNode$ = vnode_newVirtual();
24948
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* Projection */);
24949
- isDev14 && vnode_setProp(diffContext.$vNewNode$, "q:code", "expectProjection");
25045
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* Projection */);
25046
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, "q:code", "expectProjection");
24950
25047
  vnode_setProp(diffContext.$vNewNode$, QSlot, slotName);
24951
25048
  diffContext.$vNewNode$.slotParent = diffContext.$vParent$;
24952
25049
  vnode_setProp(diffContext.$vParent$, slotName, diffContext.$vNewNode$);
@@ -24975,7 +25072,7 @@ function expectSlot(diffContext) {
24975
25072
  cursorBoundary
24976
25073
  );
24977
25074
  vHost && vnode_setProp(vHost, slotNameKey, diffContext.$vNewNode$);
24978
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* Projection */);
25075
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* Projection */);
24979
25076
  vnode_insertBefore(
24980
25077
  diffContext.$journal$,
24981
25078
  diffContext.$vParent$,
@@ -24995,7 +25092,7 @@ function expectSlot(diffContext) {
24995
25092
  cursorBoundary
24996
25093
  );
24997
25094
  vHost && vnode_setProp(vHost, slotNameKey, diffContext.$vNewNode$);
24998
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* Projection */);
25095
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* Projection */);
24999
25096
  vnode_inflateProjectionTrailingText(
25000
25097
  diffContext.$journal$,
25001
25098
  diffContext.$vNewNode$
@@ -25077,7 +25174,7 @@ function expectNoChildren(diffContext, removeDOM = true) {
25077
25174
  }
25078
25175
  function expectNoMore(diffContext) {
25079
25176
  const boundary = getLevelBoundary(diffContext);
25080
- isDev14 && assertFalse(
25177
+ isDev13 && assertFalse(
25081
25178
  diffContext.$vParent$ === diffContext.$vCurrent$,
25082
25179
  "Parent and current can't be the same"
25083
25180
  );
@@ -25138,7 +25235,7 @@ function applyConstInnerHtml(element, value) {
25138
25235
  }
25139
25236
  function applyConstTextareaValue(element, value, currentFile) {
25140
25237
  if (value && typeof value !== "string") {
25141
- if (isDev14) {
25238
+ if (isDev13) {
25142
25239
  throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
25143
25240
  }
25144
25241
  return true;
@@ -25273,7 +25370,7 @@ function expectElement(diffContext, jsx2, elementName) {
25273
25370
  const jsxProps = jsx2.varProps;
25274
25371
  const vNode = diffContext.$vNewNode$ || diffContext.$vCurrent$;
25275
25372
  if (jsxProps) {
25276
- diffProps(diffContext, vNode, jsxProps, isDev14 && getFileLocationFromJsx(jsx2.dev) || null);
25373
+ diffProps(diffContext, vNode, jsxProps, isDev13 && getFileLocationFromJsx(jsx2.dev) || null);
25277
25374
  }
25278
25375
  }
25279
25376
  function diffProps(diffContext, vnode, newAttrs, currentFile) {
@@ -25281,14 +25378,17 @@ function diffProps(diffContext, vnode, newAttrs, currentFile) {
25281
25378
  vnode_ensureElementInflated(diffContext.$container$, vnode);
25282
25379
  }
25283
25380
  const oldAttrs = vnode.props;
25381
+ const isHtml = (vnode.flags & 1536 /* NAMESPACE_MASK */) === 0 /* NS_html */;
25284
25382
  for (const key in newAttrs) {
25285
25383
  const newValue = newAttrs[key];
25286
- if (oldAttrs && _hasOwnProperty3.call(oldAttrs, key)) {
25287
- const oldValue = oldAttrs[key];
25288
- if (newValue !== oldValue) {
25289
- if (newValue instanceof WrappedSignalImpl && oldValue instanceof WrappedSignalImpl && areWrappedSignalsEqual(newValue, oldValue)) {
25290
- continue;
25291
- }
25384
+ const oldKey = oldAttrs && isHtml && !_hasOwnProperty3.call(oldAttrs, key) ? key.toLowerCase() : key;
25385
+ if (oldAttrs && _hasOwnProperty3.call(oldAttrs, oldKey)) {
25386
+ const oldValue = oldAttrs[oldKey];
25387
+ if (oldKey !== key) {
25388
+ vnode_setProp(vnode, oldKey, null);
25389
+ vnode_setProp(vnode, key, oldValue);
25390
+ }
25391
+ if (!areDiffValuesEqual(newValue, oldValue)) {
25292
25392
  patchProperty(diffContext, vnode, key, newValue, currentFile);
25293
25393
  }
25294
25394
  } else if (newValue != null) {
@@ -25533,7 +25633,7 @@ function expectVirtual(diffContext, type, jsxKey) {
25533
25633
  getInsertBefore(diffContext)
25534
25634
  );
25535
25635
  diffContext.$vNewNode$.key = jsxKey;
25536
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, type);
25636
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, type);
25537
25637
  return;
25538
25638
  }
25539
25639
  if (moveOrCreateKeyedNode(
@@ -25551,7 +25651,7 @@ function expectVirtual(diffContext, type, jsxKey) {
25551
25651
  getInsertBefore(diffContext)
25552
25652
  );
25553
25653
  diffContext.$vNewNode$.key = jsxKey;
25554
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, type);
25654
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, type);
25555
25655
  }
25556
25656
  }
25557
25657
  function expectComponent(diffContext, component) {
@@ -25663,7 +25763,7 @@ function insertNewComponent(diffContext, host, componentQRL, jsxProps) {
25663
25763
  getInsertBefore(diffContext)
25664
25764
  );
25665
25765
  const jsxNode = diffContext.$jsxValue$;
25666
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "C" /* Component */);
25766
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "C" /* Component */);
25667
25767
  vnode_setProp(diffContext.$vNewNode$, OnRenderProp, componentQRL);
25668
25768
  vnode_setProp(diffContext.$vNewNode$, ELEMENT_PROPS, jsxProps);
25669
25769
  diffContext.$vNewNode$.key = jsxNode.key;
@@ -25676,7 +25776,7 @@ function insertNewInlineComponent(diffContext) {
25676
25776
  getInsertBefore(diffContext)
25677
25777
  );
25678
25778
  const jsxNode = diffContext.$jsxValue$;
25679
- isDev14 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "I" /* InlineComponent */);
25779
+ isDev13 && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "I" /* InlineComponent */);
25680
25780
  vnode_setProp(diffContext.$vNewNode$, ELEMENT_PROPS, jsxNode.props);
25681
25781
  if (jsxNode.key) {
25682
25782
  diffContext.$vNewNode$.key = jsxNode.key;
@@ -25755,10 +25855,21 @@ function handleChangedProps(src, dst, propsHandler, container, triggerEffects =
25755
25855
  if (key === "children" || key === QBackRefs) {
25756
25856
  continue;
25757
25857
  }
25758
- if (!dst || src[key] !== dst[key]) {
25858
+ const newValue = src[key];
25859
+ const oldValue = dst?.[key];
25860
+ if (!dst || !(areDiffValuesEqual(newValue, oldValue) || areSignalValuesEqual(newValue, oldValue))) {
25861
+ if (key === "class") {
25862
+ if (areClassValuesEqual(newValue, oldValue)) {
25863
+ continue;
25864
+ }
25865
+ } else if (key === "style") {
25866
+ if (areStyleValuesEqual(newValue, oldValue)) {
25867
+ continue;
25868
+ }
25869
+ }
25759
25870
  if (triggerEffects) {
25760
25871
  if (dst) {
25761
- dst[key] = src[key];
25872
+ dst[key] = newValue;
25762
25873
  }
25763
25874
  const didTigger = triggerPropsProxyEffect(propsHandler, key);
25764
25875
  if (!didTigger) {
@@ -25822,10 +25933,12 @@ function cleanup(container, journal, vNode, cursorRoot = null) {
25822
25933
  obj.$flags$ |= 16 /* NEEDS_CLEANUP */;
25823
25934
  markVNodeDirty(container, vCursor, 128 /* CLEANUP */, cursorRoot);
25824
25935
  continue;
25825
- } else if (obj instanceof SignalImpl || isStore(obj)) {
25826
- clearAllEffects(container, obj);
25936
+ } else if (obj instanceof ComputedSignalImpl || obj instanceof WrappedSignalImpl) {
25937
+ if (!(obj.$flags$ & 4 /* PRESERVE_ON_SEQ_CLEANUP */)) {
25938
+ clearAllEffects(container, obj);
25939
+ }
25827
25940
  }
25828
- if (objIsTask || obj instanceof AsyncSignalImpl) {
25941
+ if (objIsTask || obj instanceof ComputedSignalImpl && (obj.$flags$ & 512 /* ASYNC_MODE */ || obj.$current$)) {
25829
25942
  cleanupDestroyable(obj);
25830
25943
  }
25831
25944
  }
@@ -25917,6 +26030,35 @@ function cleanupStaleUnclaimedProjection(container, journal, projection) {
25917
26030
  function markVNodeAsDeleted(vCursor) {
25918
26031
  vCursor.flags |= 32 /* Deleted */;
25919
26032
  }
26033
+ function areDiffValuesEqual(newValue, oldValue) {
26034
+ if (newValue === oldValue) {
26035
+ return true;
26036
+ }
26037
+ return newValue instanceof WrappedSignalImpl && oldValue instanceof WrappedSignalImpl && areWrappedSignalsEqual(oldValue, newValue);
26038
+ }
26039
+ function areSignalValuesEqual(newValue, oldValue) {
26040
+ if (newValue === oldValue) {
26041
+ return true;
26042
+ }
26043
+ if (isSignal(newValue) && isSignal(oldValue)) {
26044
+ const unwrappedNew = newValue instanceof WrappedSignalImpl ? newValue.$unwrapIfSignal$() : newValue;
26045
+ const unwrappedOld = oldValue instanceof WrappedSignalImpl ? oldValue.$unwrapIfSignal$() : oldValue;
26046
+ return untrack(() => unwrappedNew.value === unwrappedOld.value);
26047
+ }
26048
+ return false;
26049
+ }
26050
+ function areStyleValuesEqual(newValue, oldValue) {
26051
+ if (newValue === oldValue) {
26052
+ return true;
26053
+ }
26054
+ return stringifyStyle(newValue) === stringifyStyle(oldValue);
26055
+ }
26056
+ function areClassValuesEqual(newValue, oldValue) {
26057
+ if (newValue === oldValue) {
26058
+ return true;
26059
+ }
26060
+ return serializeClass(newValue) === serializeClass(oldValue);
26061
+ }
25920
26062
  function areWrappedSignalsEqual(oldSignal, newSignal) {
25921
26063
  if (oldSignal === newSignal) {
25922
26064
  return true;
@@ -25951,7 +26093,7 @@ function containsWrappedSignal(data, signal) {
25951
26093
  }
25952
26094
 
25953
26095
  // packages/qwik/src/core/shared/component-execution.ts
25954
- import { isDev as isDev15, isServer as isServer6 } from "@qwik.dev/core/build";
26096
+ import { isDev as isDev14, isServer as isServer6 } from "@qwik.dev/core/build";
25955
26097
  var executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
25956
26098
  const iCtx = newRenderInvokeContext(
25957
26099
  container.$locale$,
@@ -25967,7 +26109,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
25967
26109
  let isInlineComponent = false;
25968
26110
  if (componentQRL === null) {
25969
26111
  componentQRL = container.getHostProp(renderHost, OnRenderProp);
25970
- isDev15 && assertDefined(componentQRL, "No Component found at this location");
26112
+ isDev14 && assertDefined(componentQRL, "No Component found at this location");
25971
26113
  }
25972
26114
  if (isQrl(componentQRL)) {
25973
26115
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
@@ -26048,7 +26190,7 @@ function addUseOnEvents(container, jsx2, useOnEvents) {
26048
26190
  }
26049
26191
  targetElement = placeholderElement;
26050
26192
  } else {
26051
- if (isDev15) {
26193
+ if (isDev14) {
26052
26194
  const sourceLocation = getUseOnSourceLocation(useOnEvents[key].qrls);
26053
26195
  logWarn(
26054
26196
  'You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component outputs a DOM element.' + (sourceLocation ? ` Offending \`useOn\`: ${sourceLocation}.` : "")
@@ -26060,7 +26202,7 @@ function addUseOnEvents(container, jsx2, useOnEvents) {
26060
26202
  if (targetElement) {
26061
26203
  if (targetElement.type === "script" && key === qVisibleEvent) {
26062
26204
  eventKey = "q-d:qinit";
26063
- if (isDev15) {
26205
+ if (isDev14) {
26064
26206
  const sourceLocation = getUseOnSourceLocation(useOnEvents[key].qrls);
26065
26207
  logWarn(
26066
26208
  `You are trying to add the event "${key}" using the \`useVisibleTask$\` hook with the "intersection-observer" strategy, but this only works when the component outputs a DOM element. Falling back to "document-ready" instead.` + (sourceLocation ? ` Offending \`useVisibleTask$\`: ${sourceLocation}.` : "")
@@ -26173,7 +26315,7 @@ function createPlaceholderScriptNode() {
26173
26315
  }
26174
26316
 
26175
26317
  // packages/qwik/src/core/client/reconcile-keyed-loop.ts
26176
- import { isDev as isDev16 } from "@qwik.dev/core/build";
26318
+ import { isDev as isDev15 } from "@qwik.dev/core/build";
26177
26319
  function collectChildren(first, last = null) {
26178
26320
  const children = [];
26179
26321
  let child = first;
@@ -26188,7 +26330,7 @@ function collectChildren(first, last = null) {
26188
26330
  }
26189
26331
  function renderKeyedRow(item, index, key, renderItem) {
26190
26332
  const jsx2 = renderItem(item, index);
26191
- if (isDev16 && !isJSXNode(jsx2)) {
26333
+ if (isDev15 && !isJSXNode(jsx2)) {
26192
26334
  throw new Error("Each item$ must return a single JSX node");
26193
26335
  }
26194
26336
  jsx2.key = key;
@@ -26414,7 +26556,7 @@ function reconcileKeyedLoopToParent(container, journal, parent, cursor, items, k
26414
26556
  );
26415
26557
  return maybeThen(result, () => {
26416
26558
  const firstInserted = firstInsertedBeforeAnchor(parent, anchor, blockLength);
26417
- if (isDev16 && !firstInserted) {
26559
+ if (isDev15 && !firstInserted) {
26418
26560
  throw new Error("Failed to insert keyed loop block");
26419
26561
  }
26420
26562
  anchor = firstInserted;
@@ -26712,7 +26854,7 @@ function executeReconcile(vNode, container, journal, cursor) {
26712
26854
  }
26713
26855
 
26714
26856
  // packages/qwik/src/core/shared/cursor/cursor-flush.ts
26715
- var DEBUG5 = false;
26857
+ var DEBUG4 = false;
26716
26858
  function executeFlushPhase(cursor, container) {
26717
26859
  const cursorData = getCursorData(cursor);
26718
26860
  const journal = cursorData.journal;
@@ -26730,7 +26872,7 @@ var fastInsertBefore = (insertBeforeParent, target, insertBefore) => {
26730
26872
  _insertBefore.call(insertBeforeParent, target, insertBefore);
26731
26873
  };
26732
26874
  function _flushJournal(journal) {
26733
- DEBUG5 && console.warn("walkCursor: flushing journal", vnode_journalToString(journal));
26875
+ DEBUG4 && console.warn("walkCursor: flushing journal", vnode_journalToString(journal));
26734
26876
  let batchParent = null;
26735
26877
  let batchBefore = null;
26736
26878
  let batchNodes = null;
@@ -26839,7 +26981,7 @@ function executeAfterFlush(container, cursorData) {
26839
26981
  cursorData.afterFlushTasks = null;
26840
26982
  return;
26841
26983
  }
26842
- DEBUG5 && console.warn(
26984
+ DEBUG4 && console.warn(
26843
26985
  "walkCursor: executeAfterFlush",
26844
26986
  visibleTasks.map((t) => t.$qrl$.$symbol$)
26845
26987
  );
@@ -26868,8 +27010,21 @@ var createMacroTask = (fn) => {
26868
27010
  let macroTask;
26869
27011
  if (typeof MessageChannel !== "undefined") {
26870
27012
  const channel = new MessageChannel();
27013
+ let active = true;
26871
27014
  channel.port1.onmessage = () => fn();
26872
- macroTask = () => channel.port2.postMessage(null);
27015
+ macroTask = () => {
27016
+ if (active) {
27017
+ channel.port2.postMessage(null);
27018
+ }
27019
+ };
27020
+ macroTask.$destroy$ = () => {
27021
+ if (active) {
27022
+ active = false;
27023
+ channel.port1.onmessage = null;
27024
+ channel.port1.close();
27025
+ channel.port2.close();
27026
+ }
27027
+ };
26873
27028
  } else {
26874
27029
  macroTask = () => setTimeout(fn);
26875
27030
  }
@@ -26877,8 +27032,8 @@ var createMacroTask = (fn) => {
26877
27032
  };
26878
27033
 
26879
27034
  // packages/qwik/src/core/shared/cursor/cursor-walker.ts
26880
- import { isDev as isDev17, isServer as isServer7 } from "@qwik.dev/core/build";
26881
- var DEBUG6 = false;
27035
+ import { isDev as isDev16, isServer as isServer7 } from "@qwik.dev/core/build";
27036
+ var DEBUG5 = false;
26882
27037
  var nextMicroTask = createMicroTask(processCursorQueue);
26883
27038
  var nextMacroTask = createMacroTask(processCursorQueue);
26884
27039
  var isNextTickScheduled = false;
@@ -26914,7 +27069,7 @@ function walkCursor(cursor, until) {
26914
27069
  return;
26915
27070
  }
26916
27071
  const container = cursorData.container;
26917
- isDev17 && assertDefined(container, "Cursor container not found");
27072
+ isDev16 && assertDefined(container, "Cursor container not found");
26918
27073
  if (!cursor.dirty) {
26919
27074
  finishWalk(container, cursor, cursorData, isRunningOnServer);
26920
27075
  return;
@@ -26923,8 +27078,8 @@ function walkCursor(cursor, until) {
26923
27078
  let currentVNode = null;
26924
27079
  let count = 0;
26925
27080
  while (currentVNode = cursorData.position) {
26926
- DEBUG6 && console.warn("walkCursor", currentVNode.toString());
26927
- if (DEBUG6 && count++ > 1e3) {
27081
+ DEBUG5 && console.warn("walkCursor", currentVNode.toString());
27082
+ if (DEBUG5 && count++ > 1e3) {
26928
27083
  throw new Error("Infinite loop detected in cursor walker");
26929
27084
  }
26930
27085
  if (cursorData.promise) {
@@ -26978,7 +27133,7 @@ function walkCursor(cursor, until) {
26978
27133
  container.handleError(error, currentVNode);
26979
27134
  }
26980
27135
  if (result && isPromise(result)) {
26981
- DEBUG6 && console.warn("walkCursor: blocking promise", currentVNode.toString());
27136
+ DEBUG5 && console.warn("walkCursor: blocking promise", currentVNode.toString());
26982
27137
  addCursorBoundary(cursorData, currentVNode);
26983
27138
  const blockingPromise2 = result;
26984
27139
  cursorData.promise = blockingPromise2;
@@ -27002,7 +27157,7 @@ function walkCursor(cursor, until) {
27002
27157
  return true;
27003
27158
  }
27004
27159
  }
27005
- isDev17 && assertFalse(
27160
+ isDev16 && assertFalse(
27006
27161
  !!(cursor.dirty & 1023 /* DIRTY_MASK */ && !cursorData.position),
27007
27162
  "Cursor is still dirty and position is not set after walking"
27008
27163
  );
@@ -27011,7 +27166,7 @@ function walkCursor(cursor, until) {
27011
27166
  function finishWalk(container, cursor, cursorData, isServer12) {
27012
27167
  if (!(cursor.dirty & 1023 /* DIRTY_MASK */)) {
27013
27168
  removeCursorFromQueue(cursor, container);
27014
- DEBUG6 && console.warn("walkCursor: cursor done", cursor.toString());
27169
+ DEBUG5 && console.warn("walkCursor: cursor done", cursor.toString());
27015
27170
  if (!isServer12) {
27016
27171
  executeFlushPhase(cursor, container);
27017
27172
  }
@@ -27026,7 +27181,7 @@ function finishWalk(container, cursor, cursorData, isServer12) {
27026
27181
  }
27027
27182
  }
27028
27183
  function resolveCursor(container) {
27029
- DEBUG6 && console.warn(`walkCursor: cursor resolved, ${container.$pendingCount$} remaining`);
27184
+ DEBUG5 && console.warn(`walkCursor: cursor resolved, ${container.$pendingCount$} remaining`);
27030
27185
  container.$checkPendingCount$();
27031
27186
  }
27032
27187
  function tryDescendDirtyChildren(container, cursorData, currentVNode, cursor) {
@@ -27118,6 +27273,10 @@ function splitCursorBoundary(container, vNode) {
27118
27273
 
27119
27274
  // packages/qwik/src/core/shared/cursor/cursor.ts
27120
27275
  function addCursor(container, root, priority) {
27276
+ if (isCursor(root)) {
27277
+ triggerCursors();
27278
+ return root;
27279
+ }
27121
27280
  const cursorData = {
27122
27281
  afterFlushTasks: null,
27123
27282
  extraPromises: null,
@@ -27280,10 +27439,10 @@ function addVNodeOperation(journal, operation) {
27280
27439
  }
27281
27440
 
27282
27441
  // packages/qwik/src/core/reactive-primitives/impl/wrapped-signal-impl.ts
27283
- import { isDev as isDev18 } from "@qwik.dev/core/build";
27284
- var _a4, _b3;
27285
- var WrappedSignalImpl = class extends (_b3 = SignalImpl, _a4 = _EFFECT_BACK_REF, _b3) {
27286
- constructor(container, fn, args, fnStr, flags = 1 /* INVALID */ | 4 /* UNWRAP */) {
27442
+ import { isDev as isDev17 } from "@qwik.dev/core/build";
27443
+ var _a3, _b2;
27444
+ var WrappedSignalImpl = class extends (_b2 = SignalImpl, _a3 = _EFFECT_BACK_REF, _b2) {
27445
+ constructor(container, fn, args, fnStr, flags = 1 /* INVALID */) {
27287
27446
  super(container, NEEDS_COMPUTATION);
27288
27447
  __publicField(this, "$args$");
27289
27448
  __publicField(this, "$func$");
@@ -27292,7 +27451,7 @@ var WrappedSignalImpl = class extends (_b3 = SignalImpl, _a4 = _EFFECT_BACK_REF,
27292
27451
  __publicField(this, "$hostElement$");
27293
27452
  // important: don't use implemnets BackRef here
27294
27453
  // it causes v8 optimizations eager bailouts, because of not consistent class shape
27295
- __publicField(this, _a4);
27454
+ __publicField(this, _a3);
27296
27455
  this.$args$ = args;
27297
27456
  this.$func$ = fn;
27298
27457
  this.$funcStr$ = fnStr;
@@ -27315,7 +27474,7 @@ var WrappedSignalImpl = class extends (_b3 = SignalImpl, _a4 = _EFFECT_BACK_REF,
27315
27474
  }
27316
27475
  get untrackedValue() {
27317
27476
  this.$computeIfNeeded$();
27318
- isDev18 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
27477
+ isDev17 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
27319
27478
  return this.$untrackedValue$;
27320
27479
  }
27321
27480
  $computeIfNeeded$() {
@@ -27368,10 +27527,11 @@ function clearEffectSubscription(container, effect) {
27368
27527
  return;
27369
27528
  }
27370
27529
  for (const producer of backRefs) {
27371
- if (producer instanceof AsyncSignalImpl) {
27372
- clearAsyncSignal(producer, effect);
27373
- } else if (producer instanceof SignalImpl) {
27530
+ if (producer instanceof SignalImpl) {
27374
27531
  clearSignal(container, producer, effect);
27532
+ if (producer instanceof ComputedSignalImpl) {
27533
+ clearAsyncSignalEffects(producer, effect);
27534
+ }
27375
27535
  } else if (isPropsProxy(producer)) {
27376
27536
  const propsHandler = producer[_PROPS_HANDLER];
27377
27537
  clearStoreOrProps(propsHandler, effect);
@@ -27393,11 +27553,7 @@ function clearSignal(container, producer, effect) {
27393
27553
  clearAllEffects(container, producer);
27394
27554
  }
27395
27555
  }
27396
- function clearAsyncSignal(producer, effect) {
27397
- const effects = producer.$effects$;
27398
- if (effects && effects.has(effect)) {
27399
- effects.delete(effect);
27400
- }
27556
+ function clearAsyncSignalEffects(producer, effect) {
27401
27557
  const pendingEffects = producer.$loadingEffects$;
27402
27558
  if (pendingEffects && pendingEffects.has(effect)) {
27403
27559
  pendingEffects.delete(effect);
@@ -27467,13 +27623,12 @@ var runTask = (task, container, host) => {
27467
27623
  return result;
27468
27624
  };
27469
27625
  var Task = class extends BackRef {
27470
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
27626
+ constructor($flags$, $index$, $el$, $qrl$, $destroy$) {
27471
27627
  super();
27472
27628
  this.$flags$ = $flags$;
27473
27629
  this.$index$ = $index$;
27474
27630
  this.$el$ = $el$;
27475
27631
  this.$qrl$ = $qrl$;
27476
- this.$state$ = $state$;
27477
27632
  this.$destroy$ = $destroy$;
27478
27633
  __publicField(this, "$destroyPromise$");
27479
27634
  __publicField(this, "$taskPromise$", null);
@@ -27484,7 +27639,7 @@ var isTask = (value) => {
27484
27639
  };
27485
27640
 
27486
27641
  // packages/qwik/src/core/shared/cursor/ssr-chore-execution.ts
27487
- import { isDev as isDev19 } from "@qwik.dev/core/build";
27642
+ import { isDev as isDev18 } from "@qwik.dev/core/build";
27488
27643
  function _executeSsrChores(container, ssrNode) {
27489
27644
  if (!(ssrNode.flags & 1 /* Updatable */)) {
27490
27645
  if (ssrNode.dirty & 16 /* NODE_PROPS */) {
@@ -27493,7 +27648,8 @@ function _executeSsrChores(container, ssrNode) {
27493
27648
  if (ssrNode.dirty & 32 /* COMPUTE */) {
27494
27649
  executeCompute(ssrNode, container);
27495
27650
  }
27496
- if (isDev19 && ssrNode.dirty & 1023 /* DIRTY_MASK */) {
27651
+ if (isDev18 && ssrNode.dirty & 1023 /* DIRTY_MASK */ && !(ssrNode.flags & 2 /* WarnedStreamedChore */)) {
27652
+ ssrNode.flags |= 2 /* WarnedStreamedChore */;
27497
27653
  const warningMessage = `A chore was scheduled on a host element that has already been streamed to the client.
27498
27654
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
27499
27655
 
@@ -27592,22 +27748,27 @@ var getAsyncLocalStorage = () => {
27592
27748
  };
27593
27749
 
27594
27750
  // packages/qwik/src/core/shared/jsx/bind-handlers.ts
27595
- var maybeScopeFromQL = (captureIds, element) => {
27596
- if (typeof captureIds === "string") {
27751
+ var withScopeFromQL = (captureDeltas, element, callback) => {
27752
+ if (typeof captureDeltas === "string") {
27597
27753
  const container = getDomContainer(element);
27598
- setCaptures(deserializeCaptures(container, captureIds));
27754
+ return whenContainerDataReady(container, () => {
27755
+ setCaptures(deserializeCaptureDeltas(container, captureDeltas));
27756
+ return callback();
27757
+ });
27599
27758
  }
27600
- return null;
27759
+ return callback();
27601
27760
  };
27602
27761
  function _val(_, element) {
27603
- maybeScopeFromQL(this, element);
27604
- const signal = _captures[0];
27605
- signal.value = element.type === "number" ? element.valueAsNumber : element.value;
27762
+ return withScopeFromQL(this, element, () => {
27763
+ const signal = _captures[0];
27764
+ signal.value = element.type === "number" ? element.valueAsNumber : element.value;
27765
+ });
27606
27766
  }
27607
27767
  function _chk(_, element) {
27608
- maybeScopeFromQL(this, element);
27609
- const signal = _captures[0];
27610
- signal.value = element.checked;
27768
+ return withScopeFromQL(this, element, () => {
27769
+ const signal = _captures[0];
27770
+ signal.value = element.checked;
27771
+ });
27611
27772
  }
27612
27773
 
27613
27774
  // packages/qwik/src/core/shared/serdes/subscription-patch.ts
@@ -27631,6 +27792,7 @@ var stringifyRootRefPath = (path) => {
27631
27792
  };
27632
27793
  var writeStringRootRef = (writer, id) => writer.write(String(id));
27633
27794
  var writeStringRootRefPath = (writer, path) => writer.write(stringifyRootRefPath(path));
27795
+ var writeStringRootRefDelta = (writer, id, base2) => writer.write(String(id - base2));
27634
27796
  var createStringStreamWriter = (write) => ({
27635
27797
  write,
27636
27798
  writeRootRef(id) {
@@ -27638,11 +27800,14 @@ var createStringStreamWriter = (write) => ({
27638
27800
  },
27639
27801
  writeRootRefPath(path) {
27640
27802
  return writeStringRootRefPath(this, path);
27803
+ },
27804
+ writeRootRefDelta(id, base2) {
27805
+ return writeStringRootRefDelta(this, id, base2);
27641
27806
  }
27642
27807
  });
27643
27808
 
27644
27809
  // packages/qwik/src/core/shared/serdes/serialize.ts
27645
- import { isDev as isDev20 } from "@qwik.dev/core/build";
27810
+ import { isDev as isDev19 } from "@qwik.dev/core/build";
27646
27811
 
27647
27812
  // packages/qwik/src/core/shared/ssr-const.ts
27648
27813
  var LT = "<";
@@ -27782,6 +27947,36 @@ var Serializer = class {
27782
27947
  }
27783
27948
  return Number(key);
27784
27949
  }
27950
+ rebaseQrlCaptureDeltas$(baseRootId, captureDeltas) {
27951
+ let previousCaptureId = 0;
27952
+ let previousOutputBase = baseRootId;
27953
+ const deltaList = captureDeltas.split(" ");
27954
+ for (let i2 = 0; i2 < deltaList.length; i2++) {
27955
+ const captureId = previousCaptureId + Number(deltaList[i2]);
27956
+ deltaList[i2] = String(captureId - previousOutputBase);
27957
+ previousCaptureId = captureId;
27958
+ previousOutputBase = captureId;
27959
+ }
27960
+ return deltaList.join(" ");
27961
+ }
27962
+ outputShortStringConstant$(value) {
27963
+ switch (value) {
27964
+ case ":":
27965
+ this.output(3 /* Constant */, 18 /* Colon */);
27966
+ return true;
27967
+ case ".":
27968
+ this.output(3 /* Constant */, 19 /* Dot */);
27969
+ return true;
27970
+ case "id":
27971
+ this.output(3 /* Constant */, 20 /* Id */);
27972
+ return true;
27973
+ case "ref":
27974
+ this.output(3 /* Constant */, 21 /* Ref */);
27975
+ return true;
27976
+ default:
27977
+ return false;
27978
+ }
27979
+ }
27785
27980
  outputString(value) {
27786
27981
  const s = this.stringNeedsJsonEscape$(value) ? JSON.stringify(value) : QUOTE + value + QUOTE;
27787
27982
  let angleBracketIdx = -1;
@@ -27799,6 +27994,9 @@ var Serializer = class {
27799
27994
  writeRootRefPath(path) {
27800
27995
  this.$writer$.writeRootRefPath(path);
27801
27996
  }
27997
+ writeRootRefDelta(id, base2) {
27998
+ this.$writer$.writeRootRefDelta(id, base2);
27999
+ }
27802
28000
  outputStringChunks(chunks) {
27803
28001
  this.$writer$.write(QUOTE);
27804
28002
  for (let i2 = 0; i2 < chunks.length; i2++) {
@@ -27807,6 +28005,8 @@ var Serializer = class {
27807
28005
  this.$writer$.write(chunk);
27808
28006
  } else if (typeof chunk === "number") {
27809
28007
  this.writeRootRef(chunk);
28008
+ } else if ("base" in chunk) {
28009
+ this.writeRootRefDelta(chunk.id, chunk.base);
27810
28010
  } else {
27811
28011
  this.writeRootRefPath(chunk.path);
27812
28012
  }
@@ -27914,6 +28114,8 @@ var Serializer = class {
27914
28114
  case "string":
27915
28115
  if (value.length === 0) {
27916
28116
  this.output(3 /* Constant */, 4 /* EmptyString */);
28117
+ } else if (this.outputShortStringConstant$(value)) {
28118
+ break;
27917
28119
  } else {
27918
28120
  if (value.length < 4 || this.getSeenRefOrOutput(value, index)) {
27919
28121
  this.output(0 /* Plain */, value);
@@ -27945,29 +28147,38 @@ var Serializer = class {
27945
28147
  this.output(3 /* Constant */, 11 /* Fragment */);
27946
28148
  } else if (isQrl(value)) {
27947
28149
  if (this.getSeenRefOrOutput(value, index)) {
27948
- const [chunk, symbol, captures] = qrlToString(
28150
+ const [chunk, symbol, captureDeltasFromZero] = qrlToString(
27949
28151
  this.$serializationContext$,
27950
28152
  value,
27951
28153
  true
27952
28154
  );
27953
28155
  let data;
27954
28156
  if (chunk !== "") {
27955
- data = [
27956
- this.$serializationContext$.$addRoot$(chunk),
27957
- "#",
27958
- this.$serializationContext$.$addRoot$(symbol)
27959
- ];
27960
- if (captures) {
27961
- const captureIds = captures.split(" ");
28157
+ const chunkRootId = this.$serializationContext$.$addRoot$(chunk);
28158
+ const symbolRootId = this.$serializationContext$.$addRoot$(symbol);
28159
+ const captureDeltas = captureDeltasFromZero ? this.rebaseQrlCaptureDeltas$(symbolRootId, captureDeltasFromZero) : null;
28160
+ data = [chunkRootId, "#", { id: symbolRootId, base: chunkRootId }];
28161
+ if (captureDeltasFromZero) {
28162
+ let previousRootId = 0;
28163
+ let previousOutputBase = symbolRootId;
28164
+ let start = 0;
27962
28165
  data.push("#");
27963
- for (let i2 = 0; i2 < captureIds.length; i2++) {
27964
- if (i2 > 0) {
27965
- data.push(" ");
28166
+ for (let i2 = 0; i2 <= captureDeltasFromZero.length; i2++) {
28167
+ if (i2 === captureDeltasFromZero.length || captureDeltasFromZero[i2] === " ") {
28168
+ if (i2 > start) {
28169
+ const captureId = previousRootId + Number(captureDeltasFromZero.slice(start, i2));
28170
+ if (start > 0) {
28171
+ data.push(" ");
28172
+ }
28173
+ data.push({ id: captureId, base: previousOutputBase });
28174
+ previousRootId = captureId;
28175
+ previousOutputBase = captureId;
28176
+ }
28177
+ start = i2 + 1;
27966
28178
  }
27967
- data.push(Number(captureIds[i2]));
27968
28179
  }
27969
28180
  }
27970
- const qrlKey = data.join("");
28181
+ const qrlKey = `${chunkRootId}#${symbolRootId - chunkRootId}${captureDeltas ? "#" + captureDeltas : ""}`;
27971
28182
  const existing = this.$qrlMap$.get(qrlKey);
27972
28183
  if (existing) {
27973
28184
  const ref = this.$serializationContext$.$addRoot$(existing);
@@ -28023,12 +28234,21 @@ var Serializer = class {
28023
28234
  value[_PROPS_HANDLER].$effects$
28024
28235
  ]);
28025
28236
  } else if (value instanceof SubscriptionData) {
28026
- this.output(39 /* SubscriptionData */, [
28027
- value.data.$scopedStyleIdPrefix$,
28028
- value.data.$isConst$
28029
- ]);
28237
+ const { $scopedStyleIdPrefix$, $isConst$ } = value.data;
28238
+ if ($scopedStyleIdPrefix$ === null) {
28239
+ this.output(
28240
+ $isConst$ ? 42 /* SubscriptionDataConstTrue */ : 43 /* SubscriptionDataConstFalse */,
28241
+ 0
28242
+ );
28243
+ } else {
28244
+ this.output(39 /* SubscriptionData */, [$scopedStyleIdPrefix$, $isConst$]);
28245
+ }
28030
28246
  } else if (value instanceof EffectSubscription) {
28031
- this.output(40 /* EffectSubscription */, [value.consumer, value.property, value.data]);
28247
+ if (value.data === null) {
28248
+ this.output(44 /* EffectSubscriptionNoData */, [value.consumer, value.property]);
28249
+ } else {
28250
+ this.output(40 /* EffectSubscription */, [value.consumer, value.property, value.data]);
28251
+ }
28032
28252
  } else if (value instanceof SubscriptionPatch) {
28033
28253
  this.output(41 /* SubscriptionPatch */, [value.rootId, value.subscriptions]);
28034
28254
  } else if (isStore(value)) {
@@ -28080,7 +28300,7 @@ var Serializer = class {
28080
28300
  }
28081
28301
  }
28082
28302
  }
28083
- this.output(5 /* Object */, out.length ? out : 0);
28303
+ this.output(5 /* Object */, out.length ? out : EMPTY_OBJECT_PAYLOAD);
28084
28304
  }
28085
28305
  } else if (this.$serializationContext$.$isDomRef$(value)) {
28086
28306
  this.$serializationContext$.$markSsrNodeForSerialization$(
@@ -28120,12 +28340,13 @@ var Serializer = class {
28120
28340
  const shouldNeverSerialize = value.$flags$ & 8 /* SERIALIZATION_STRATEGY_NEVER */;
28121
28341
  const isInvalid = value.$flags$ & 1 /* INVALID */;
28122
28342
  const isSkippable = fastSkipSerialize(value.$untrackedValue$);
28123
- const isAsync = value instanceof AsyncSignalImpl;
28343
+ const isAsync = !!(value.$flags$ & 512 /* ASYNC_MODE */);
28344
+ const isErrored = isAsync && !!value.$untrackedError$;
28124
28345
  const expires = isAsync && value.$expires$ !== 0 ? value.$expires$ : void 0;
28125
28346
  const concurrency = isAsync && value.$concurrency$ !== 1 ? value.$concurrency$ : void 0;
28126
28347
  const timeout = isAsync && value.$timeoutMs$ !== 0 ? value.$timeoutMs$ : void 0;
28127
28348
  const asyncFlags = isAsync && value.$flags$ & ~24 /* SERIALIZATION_ALL_STRATEGIES */ || void 0;
28128
- if (isInvalid || isSkippable) {
28349
+ if (isInvalid || isSkippable || isErrored) {
28129
28350
  v = NEEDS_COMPUTATION;
28130
28351
  } else if (shouldAlwaysSerialize) {
28131
28352
  v = value.$untrackedValue$;
@@ -28158,28 +28379,12 @@ var Serializer = class {
28158
28379
  this.output(6 /* URL */, value.href);
28159
28380
  } else if (value instanceof Date) {
28160
28381
  this.output(7 /* Date */, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
28161
- } else if (this.$hasTemporal$ && value instanceof Temporal.Duration) {
28162
- this.output(15 /* TemporalDuration */, value.toJSON());
28163
- } else if (this.$hasTemporal$ && value instanceof Temporal.Instant) {
28164
- this.output(16 /* TemporalInstant */, value.toJSON());
28165
- } else if (this.$hasTemporal$ && value instanceof Temporal.PlainDate) {
28166
- this.output(17 /* TemporalPlainDate */, value.toJSON());
28167
- } else if (this.$hasTemporal$ && value instanceof Temporal.PlainDateTime) {
28168
- this.output(18 /* TemporalPlainDateTime */, value.toJSON());
28169
- } else if (this.$hasTemporal$ && value instanceof Temporal.PlainMonthDay) {
28170
- this.output(19 /* TemporalPlainMonthDay */, value.toJSON());
28171
- } else if (this.$hasTemporal$ && value instanceof Temporal.PlainTime) {
28172
- this.output(20 /* TemporalPlainTime */, value.toJSON());
28173
- } else if (this.$hasTemporal$ && value instanceof Temporal.PlainYearMonth) {
28174
- this.output(21 /* TemporalPlainYearMonth */, value.toJSON());
28175
- } else if (this.$hasTemporal$ && value instanceof Temporal.ZonedDateTime) {
28176
- this.output(22 /* TemporalZonedDateTime */, value.toJSON());
28177
28382
  } else if (value instanceof RegExp) {
28178
28383
  this.output(8 /* Regex */, value.toString());
28179
28384
  } else if (value instanceof Error) {
28180
28385
  const out = [value.message];
28181
28386
  out.push(...Object.entries(value).flat());
28182
- if (isDev20) {
28387
+ if (isDev19) {
28183
28388
  out.push("stack", value.stack);
28184
28389
  }
28185
28390
  this.output(23 /* Error */, out);
@@ -28233,7 +28438,7 @@ var Serializer = class {
28233
28438
  }
28234
28439
  this.output(37 /* JSXNode */, out);
28235
28440
  } else if (value instanceof Task) {
28236
- const out = [value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$state$];
28441
+ const out = [value.$qrl$, value.$flags$, value.$index$, value.$el$];
28237
28442
  while (out[out.length - 1] === void 0) {
28238
28443
  out.pop();
28239
28444
  }
@@ -28277,6 +28482,22 @@ var Serializer = class {
28277
28482
  }
28278
28483
  this.output(2 /* ForwardRef */, this.getForwardRefId(forwardRefId));
28279
28484
  }
28485
+ } else if (this.$hasTemporal$ && value instanceof Temporal.Duration) {
28486
+ this.output(15 /* TemporalDuration */, value.toJSON());
28487
+ } else if (this.$hasTemporal$ && value instanceof Temporal.Instant) {
28488
+ this.output(16 /* TemporalInstant */, value.toJSON());
28489
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainDate) {
28490
+ this.output(17 /* TemporalPlainDate */, value.toJSON());
28491
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainDateTime) {
28492
+ this.output(18 /* TemporalPlainDateTime */, value.toJSON());
28493
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainMonthDay) {
28494
+ this.output(19 /* TemporalPlainMonthDay */, value.toJSON());
28495
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainTime) {
28496
+ this.output(20 /* TemporalPlainTime */, value.toJSON());
28497
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainYearMonth) {
28498
+ this.output(21 /* TemporalPlainYearMonth */, value.toJSON());
28499
+ } else if (this.$hasTemporal$ && value instanceof Temporal.ZonedDateTime) {
28500
+ this.output(22 /* TemporalZonedDateTime */, value.toJSON());
28280
28501
  } else if (vnode_isVNode(value)) {
28281
28502
  this.output(3 /* Constant */, 0 /* Undefined */);
28282
28503
  } else {
@@ -28426,7 +28647,7 @@ var discoverValuesForVNodeData = (vnodeData, callback) => {
28426
28647
  if (isSsrAttrs(value)) {
28427
28648
  for (const key in value) {
28428
28649
  const attrValue = value[key];
28429
- if (attrValue == null || typeof attrValue === "string" || typeof attrValue === "number" && key === ELEMENT_ID || key === ELEMENT_PROPS && isObjectEmpty(attrValue)) {
28650
+ if (attrValue == null || typeof attrValue === "string" || typeof attrValue === "number" && key === ELEMENT_ID || key === ELEMENT_PROPS && (isObjectEmpty(attrValue) || shouldSkipComponentProps(value, attrValue))) {
28430
28651
  continue;
28431
28652
  }
28432
28653
  callback(attrValue);
@@ -28435,6 +28656,19 @@ var discoverValuesForVNodeData = (vnodeData, callback) => {
28435
28656
  }
28436
28657
  };
28437
28658
  var isSsrAttrs = (value) => typeof value === "object" && value !== null && !isObjectEmpty(value);
28659
+ var shouldSkipComponentProps = (attrs, value, isDevMode = isDev19) => {
28660
+ if (isDevMode || !Object.prototype.hasOwnProperty.call(attrs, OnRenderProp)) {
28661
+ return false;
28662
+ }
28663
+ const owner = value[_OWNER];
28664
+ return isObjectEmpty(owner.varProps) && !hasPropsEffects(value) && !hasComponentBackRef(attrs[QBackRefs]);
28665
+ };
28666
+ var hasPropsEffects = (propsProxy) => {
28667
+ return !!propsProxy[_PROPS_HANDLER].$effects$?.size;
28668
+ };
28669
+ var hasComponentBackRef = (backRefs) => {
28670
+ return backRefs instanceof Map && backRefs.has(":" /* COMPONENT */);
28671
+ };
28438
28672
  function isObjectLiteral(obj) {
28439
28673
  const prototype = Object.getPrototypeOf(obj);
28440
28674
  return prototype == null || prototype === Object.prototype || prototype === Array.prototype;
@@ -28692,7 +28926,7 @@ var _SharedContainer = class {
28692
28926
  };
28693
28927
 
28694
28928
  // packages/qwik/src/core/shared/serdes/preprocess-state.ts
28695
- function preprocessState(data, container, segmentId, startIndex = 0) {
28929
+ function* preprocessStateIterator(data, container, startIndex = 0) {
28696
28930
  const isRootDeepRef = (type, value) => {
28697
28931
  return type === 1 /* RootRef */ && typeof value === "string" && value.indexOf(" ") !== -1;
28698
28932
  };
@@ -28734,23 +28968,103 @@ function preprocessState(data, container, segmentId, startIndex = 0) {
28734
28968
  } else if (isForwardRefsMap(data[i2])) {
28735
28969
  container.$forwardRefs$ = data[i2 + 1];
28736
28970
  }
28971
+ yield;
28737
28972
  }
28738
28973
  }
28739
28974
 
28740
28975
  // packages/qwik/src/core/shared/serdes/serdes.public.ts
28741
- import { isDev as isDev21 } from "@qwik.dev/core/build";
28976
+ import { isDev as isDev20 } from "@qwik.dev/core/build";
28977
+
28978
+ // packages/qwik/src/core/client/yielding-iterator.ts
28979
+ var YIELD_INTERVAL = 10;
28980
+ var scheduleYieldingIterator = (state) => {
28981
+ if (!state.$scheduled$) {
28982
+ state.$scheduled$ = true;
28983
+ state.$schedule$();
28984
+ }
28985
+ };
28986
+ var runYieldingIterator = (state, onDone, onError) => {
28987
+ state.$scheduled$ = false;
28988
+ const deadline = performance.now() + YIELD_INTERVAL;
28989
+ let count = 0;
28990
+ try {
28991
+ while (true) {
28992
+ const result = state.$iterator$.next();
28993
+ if (result.done) {
28994
+ onDone(result.value);
28995
+ return;
28996
+ }
28997
+ if ((++count & 31) === 0 && performance.now() >= deadline) {
28998
+ scheduleYieldingIterator(state);
28999
+ return;
29000
+ }
29001
+ }
29002
+ } catch (error) {
29003
+ onError(error);
29004
+ }
29005
+ };
29006
+ var createYieldingIteratorState = (iterator, onDone, onError) => {
29007
+ const state = {
29008
+ $iterator$: iterator,
29009
+ $schedule$: void 0,
29010
+ $scheduled$: false
29011
+ };
29012
+ const schedule = createMacroTask(() => {
29013
+ runYieldingIterator(
29014
+ state,
29015
+ (value) => {
29016
+ schedule.$destroy$?.();
29017
+ onDone(value);
29018
+ },
29019
+ (error) => {
29020
+ schedule.$destroy$?.();
29021
+ onError(error);
29022
+ }
29023
+ );
29024
+ });
29025
+ state.$schedule$ = schedule;
29026
+ return state;
29027
+ };
29028
+
29029
+ // packages/qwik/src/core/shared/serdes/serdes.public.ts
28742
29030
  function getObjectById(id, stateData) {
28743
29031
  if (typeof id === "string") {
28744
29032
  id = parseInt(id, 10);
28745
29033
  return stateData[id];
28746
29034
  }
28747
- isDev21 && assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`);
29035
+ isDev20 && assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`);
28748
29036
  return stateData[id];
28749
29037
  }
28750
29038
 
28751
29039
  // packages/qwik/src/core/shared/serdes/allocate.ts
28752
29040
  var resolvers = /* @__PURE__ */ new WeakMap();
28753
- var pendingStoreTargets = /* @__PURE__ */ new Map();
29041
+ var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
29042
+ var BASE64_REGEXP = /^[A-Za-z0-9+/]*$/;
29043
+ var isCanonicalBase64 = (value) => {
29044
+ if (typeof value !== "string" || !BASE64_REGEXP.test(value)) {
29045
+ return false;
29046
+ }
29047
+ const rest = value.length % 4;
29048
+ if (rest === 0) {
29049
+ return true;
29050
+ }
29051
+ if (rest === 1) {
29052
+ return false;
29053
+ }
29054
+ const lastValue = BASE64_ALPHABET.indexOf(value[value.length - 1]);
29055
+ return (lastValue & (rest === 2 ? 15 : 3)) === 0;
29056
+ };
29057
+ var beginDeserialization = (container) => {
29058
+ const ownsPendingStoreTargets = container.$pendingStoreTargets$ === void 0;
29059
+ container.$pendingStoreTargets$ ?? (container.$pendingStoreTargets$ = /* @__PURE__ */ new Map());
29060
+ return ownsPendingStoreTargets;
29061
+ };
29062
+ var endDeserialization = (container, ownsPendingStoreTargets) => {
29063
+ if (ownsPendingStoreTargets) {
29064
+ container.$pendingStoreTargets$.clear();
29065
+ container.$pendingStoreTargets$ = void 0;
29066
+ }
29067
+ };
28754
29068
  var allocate = (container, typeId, value) => {
28755
29069
  switch (typeId) {
28756
29070
  case 0 /* Plain */:
@@ -28775,13 +29089,18 @@ var allocate = (container, typeId, value) => {
28775
29089
  case 9 /* QRL */: {
28776
29090
  let qrl;
28777
29091
  if (typeof value === "string") {
28778
- const [chunkId, symbolId, captureIds] = value.split("#");
28779
- const chunk = container.$getObjectById$(chunkId);
28780
- const symbol = container.$getObjectById$(symbolId);
29092
+ const serializedQrl = value;
29093
+ const firstHash = serializedQrl.indexOf("#");
29094
+ const secondHash = serializedQrl.indexOf("#", firstHash + 1);
29095
+ const chunkRootId = Number(serializedQrl.slice(0, firstHash));
29096
+ const symbolDelta = secondHash === -1 ? Number(serializedQrl.slice(firstHash + 1)) : Number(serializedQrl.slice(firstHash + 1, secondHash));
29097
+ const symbolRootId = chunkRootId + symbolDelta;
29098
+ const chunk = container.$getObjectById$(chunkRootId);
29099
+ const symbol = container.$getObjectById$(symbolRootId);
28781
29100
  qrl = createQRLWithBackChannel(
28782
29101
  chunk,
28783
29102
  symbol,
28784
- captureIds || null,
29103
+ secondHash !== -1 ? serializedQrl : null,
28785
29104
  container
28786
29105
  );
28787
29106
  } else {
@@ -28790,7 +29109,7 @@ var allocate = (container, typeId, value) => {
28790
29109
  return qrl;
28791
29110
  }
28792
29111
  case 28 /* Task */:
28793
- return new Task(-1, -1, null, null, null, null);
29112
+ return new Task(-1, -1, null, null, null);
28794
29113
  case 6 /* URL */:
28795
29114
  return new URL(value);
28796
29115
  case 7 /* Date */:
@@ -28835,7 +29154,7 @@ var allocate = (container, typeId, value) => {
28835
29154
  const storeValue = allocate(container, t, v);
28836
29155
  const store = getOrCreateStore(storeValue, 0 /* NONE */, container);
28837
29156
  if (needsInflation(t)) {
28838
- pendingStoreTargets.set(storeValue, { t, v });
29157
+ container.$pendingStoreTargets$.set(storeValue, { t, v });
28839
29158
  }
28840
29159
  data[0] = 0 /* Plain */;
28841
29160
  data[1] = storeValue;
@@ -28864,12 +29183,16 @@ var allocate = (container, typeId, value) => {
28864
29183
  promise.catch(() => {
28865
29184
  });
28866
29185
  return promise;
28867
- case 27 /* Uint8Array */:
29186
+ case 27 /* Uint8Array */: {
29187
+ if (!isCanonicalBase64(value)) {
29188
+ throw qError(38 /* invalidUint8ArrayPayload */);
29189
+ }
28868
29190
  const encodedLength = value.length;
28869
- const blocks = encodedLength >>> 2;
28870
- const rest = encodedLength & 3;
29191
+ const blocks = Math.floor(encodedLength / 4);
29192
+ const rest = encodedLength % 4;
28871
29193
  const decodedLength = blocks * 3 + (rest ? rest - 1 : 0);
28872
29194
  return new Uint8Array(decodedLength);
29195
+ }
28873
29196
  case 38 /* PropsProxy */:
28874
29197
  return createPropsProxy(null);
28875
29198
  case 10 /* VNode */:
@@ -28884,7 +29207,12 @@ var allocate = (container, typeId, value) => {
28884
29207
  }
28885
29208
  case 39 /* SubscriptionData */:
28886
29209
  return new SubscriptionData({});
29210
+ case 42 /* SubscriptionDataConstTrue */:
29211
+ return new SubscriptionData({ $scopedStyleIdPrefix$: null, $isConst$: true });
29212
+ case 43 /* SubscriptionDataConstFalse */:
29213
+ return new SubscriptionData({ $scopedStyleIdPrefix$: null, $isConst$: false });
28887
29214
  case 40 /* EffectSubscription */:
29215
+ case 44 /* EffectSubscriptionNoData */:
28888
29216
  return new EffectSubscription(null, null, null, null);
28889
29217
  case 41 /* SubscriptionPatch */:
28890
29218
  return new SubscriptionPatch();
@@ -28913,114 +29241,214 @@ var isSafeObjectKV = (key, value) => {
28913
29241
  return typeof key === "string" && key !== "__proto__" && (typeof value !== "function" || !dangerousObjectKeys.has(key));
28914
29242
  };
28915
29243
  var inflate = (container, target, typeId, data) => {
29244
+ const ownsPendingStoreTargets = beginDeserialization(container);
29245
+ try {
29246
+ const iterator = inflateIterator(container, target, typeId, data);
29247
+ while (!iterator.next().done) {
29248
+ }
29249
+ } finally {
29250
+ endDeserialization(container, ownsPendingStoreTargets);
29251
+ }
29252
+ };
29253
+ function* eagerDeserializeArrayIterator(container, data, output = Array(data.length / 2)) {
29254
+ for (let i2 = 0; i2 < data.length; i2 += 2) {
29255
+ output[i2 / 2] = yield* deserializeDataIterator(container, data[i2], data[i2 + 1]);
29256
+ yield;
29257
+ }
29258
+ return output;
29259
+ }
29260
+ function* eagerDeserializeStateIterator(container, data, output = Array(data.length / 2)) {
29261
+ const ownsPendingStoreTargets = beginDeserialization(container);
29262
+ const length = data.length / 2;
29263
+ const allocated = new Uint8Array(length);
29264
+ const previousGetObjectById = container.$getObjectById$;
29265
+ const allocateRoot = (index) => {
29266
+ if (!allocated[index]) {
29267
+ allocated[index] = 1;
29268
+ const typeIndex = index * 2;
29269
+ const typeId = data[typeIndex];
29270
+ const value = data[typeIndex + 1];
29271
+ output[index] = typeId === 0 /* Plain */ ? value : allocate(container, typeId, value);
29272
+ }
29273
+ return output[index];
29274
+ };
29275
+ container.$getObjectById$ = (id) => allocateRoot(typeof id === "string" ? parseInt(id, 10) : id);
29276
+ try {
29277
+ for (let i2 = 0; i2 < length; i2++) {
29278
+ allocateRoot(i2);
29279
+ yield;
29280
+ }
29281
+ for (let i2 = 0; i2 < length; i2++) {
29282
+ const typeIndex = i2 * 2;
29283
+ const typeId = data[typeIndex];
29284
+ const value = data[typeIndex + 1];
29285
+ const propValue = output[i2];
29286
+ data[typeIndex] = 0 /* Plain */;
29287
+ data[typeIndex + 1] = propValue;
29288
+ if (needsInflation(typeId)) {
29289
+ yield* inflateIterator(container, propValue, typeId, value);
29290
+ }
29291
+ yield;
29292
+ }
29293
+ } finally {
29294
+ container.$getObjectById$ = previousGetObjectById;
29295
+ endDeserialization(container, ownsPendingStoreTargets);
29296
+ }
29297
+ return output;
29298
+ }
29299
+ function* deserializeDataIterator(container, typeId, value) {
29300
+ if (typeId === 0 /* Plain */) {
29301
+ return value;
29302
+ }
29303
+ const propValue = allocate(container, typeId, value);
29304
+ if (needsInflation(typeId)) {
29305
+ yield* inflateIterator(container, propValue, typeId, value);
29306
+ }
29307
+ return propValue;
29308
+ }
29309
+ function* inflateIterator(container, target, typeId, data) {
28916
29310
  if (typeId === 0 /* Plain */) {
28917
29311
  return;
28918
29312
  }
29313
+ if (typeId === 5 /* Object */ && data !== EMPTY_OBJECT_PAYLOAD && !Array.isArray(data)) {
29314
+ throw new Error("Invalid Object payload");
29315
+ }
28919
29316
  if (typeId !== 4 /* Array */ && Array.isArray(data)) {
28920
- data = _eagerDeserializeArray(container, data);
29317
+ data = yield* eagerDeserializeArrayIterator(container, data);
28921
29318
  }
28922
29319
  switch (typeId) {
28923
29320
  case 4 /* Array */:
28924
- _eagerDeserializeArray(container, data, target);
29321
+ yield* eagerDeserializeArrayIterator(container, data, target);
28925
29322
  break;
28926
29323
  case 5 /* Object */:
28927
- if (data === 0) {
29324
+ if (data === EMPTY_OBJECT_PAYLOAD) {
28928
29325
  break;
28929
29326
  }
28930
- for (let i3 = 0; i3 < data.length; i3 += 2) {
28931
- const key = data[i3];
28932
- const value = data[i3 + 1];
29327
+ for (let i2 = 0; i2 < data.length; i2 += 2) {
29328
+ const key = data[i2];
29329
+ const value = data[i2 + 1];
28933
29330
  if (!isSafeObjectKV(key, value)) {
28934
29331
  continue;
28935
29332
  }
28936
29333
  target[key] = value;
28937
29334
  }
28938
29335
  break;
28939
- case 28 /* Task */:
29336
+ case 25 /* Set */: {
29337
+ const set = target;
29338
+ const d = data;
29339
+ for (let i2 = 0; i2 < d.length; i2++) {
29340
+ set.add(d[i2]);
29341
+ yield;
29342
+ }
29343
+ break;
29344
+ }
29345
+ case 26 /* Map */: {
29346
+ const map = target;
29347
+ const d = data;
29348
+ for (let i2 = 0; i2 < d.length; i2++) {
29349
+ map.set(d[i2++], d[i2]);
29350
+ yield;
29351
+ }
29352
+ break;
29353
+ }
29354
+ case 24 /* Promise */: {
29355
+ const promise = target;
29356
+ const [resolved, result] = data;
29357
+ const [resolve, reject] = resolvers.get(promise);
29358
+ if (resolved) {
29359
+ if (resolvers.has(result)) {
29360
+ throw qError(37 /* invalidPromiseDependency */);
29361
+ }
29362
+ resolve(result);
29363
+ } else {
29364
+ reject(result);
29365
+ }
29366
+ break;
29367
+ }
29368
+ case 23 /* Error */: {
29369
+ const d = data;
29370
+ target.message = d[0];
29371
+ for (let i2 = 1; i2 < d.length; i2 += 2) {
29372
+ const key = d[i2];
29373
+ const value = d[i2 + 1];
29374
+ if (isSafeObjectKV(key, value)) {
29375
+ target[key] = value;
29376
+ }
29377
+ yield;
29378
+ }
29379
+ break;
29380
+ }
29381
+ case 28 /* Task */: {
28940
29382
  const task = target;
28941
29383
  const v = data;
28942
29384
  task.$qrl$ = v[0];
28943
29385
  task.$flags$ = v[1];
28944
29386
  task.$index$ = v[2];
28945
29387
  task.$el$ = v[3];
28946
- task.$state$ = v[4];
28947
29388
  break;
29389
+ }
28948
29390
  case 29 /* Component */:
28949
29391
  target[SERIALIZABLE_STATE][0] = data[0];
28950
29392
  break;
28951
- case 35 /* Store */: {
28952
- const store = unwrapStore(target);
28953
- const storeTarget = pendingStoreTargets.get(store);
28954
- if (storeTarget) {
28955
- pendingStoreTargets.delete(store);
28956
- inflate(container, store, storeTarget.t, storeTarget.v);
28957
- }
28958
- const [, flags, effects] = data;
28959
- const storeHandler = getStoreHandler(target);
28960
- storeHandler.$flags$ = flags;
28961
- storeHandler.$effects$ = effects;
28962
- restoreEffectBackRefForEffectsMap(storeHandler.$effects$, store);
28963
- break;
28964
- }
28965
29393
  case 30 /* Signal */: {
28966
29394
  const signal = target;
28967
- const d2 = data;
28968
- signal.$untrackedValue$ = d2[0];
28969
- signal.$effects$ = new Set(d2.slice(1));
29395
+ const d = data;
29396
+ signal.$untrackedValue$ = d[0];
29397
+ signal.$effects$ = new Set(d.slice(1));
28970
29398
  restoreEffectBackRefForEffects(signal.$effects$, signal);
28971
29399
  break;
28972
29400
  }
28973
29401
  case 31 /* WrappedSignal */: {
28974
29402
  const signal = target;
28975
- const d2 = data;
28976
- signal.$func$ = container.getSyncFn(d2[0]);
28977
- signal.$args$ = d2[1];
29403
+ const d = data;
29404
+ signal.$func$ = container.getSyncFn(d[0]);
29405
+ signal.$args$ = d[1];
28978
29406
  signal.$untrackedValue$ = NEEDS_COMPUTATION;
28979
- signal.$flags$ = d2[2];
29407
+ signal.$flags$ = d[2];
28980
29408
  signal.$flags$ |= 1 /* INVALID */;
28981
- signal.$hostElement$ = d2[3];
28982
- signal.$effects$ = new Set(d2.slice(4));
29409
+ signal.$hostElement$ = d[3];
29410
+ signal.$effects$ = new Set(d.slice(4));
28983
29411
  inflateWrappedSignalValue(signal);
28984
29412
  restoreEffectBackRefForEffects(signal.$effects$, signal);
28985
29413
  break;
28986
29414
  }
28987
29415
  case 33 /* AsyncSignal */: {
28988
29416
  const asyncSignal = target;
28989
- const d2 = data;
28990
- asyncSignal.$computeQrl$ = d2[0];
28991
- if (d2[1]) {
28992
- asyncSignal.$effects$ = new Set(d2[1]);
29417
+ const d = data;
29418
+ asyncSignal.$computeQrl$ = d[0];
29419
+ if (d[1]) {
29420
+ asyncSignal.$effects$ = new Set(d[1]);
28993
29421
  }
28994
- if (d2[2]) {
28995
- asyncSignal.$loadingEffects$ = new Set(d2[2]);
29422
+ if (d[2]) {
29423
+ asyncSignal.$loadingEffects$ = new Set(d[2]);
28996
29424
  }
28997
- if (d2[3]) {
28998
- asyncSignal.$errorEffects$ = new Set(d2[3]);
29425
+ if (d[3]) {
29426
+ asyncSignal.$errorEffects$ = new Set(d[3]);
28999
29427
  }
29000
- if (d2[4]) {
29001
- asyncSignal.$untrackedError$ = d2[4];
29428
+ if (d[4]) {
29429
+ asyncSignal.$untrackedError$ = d[4];
29002
29430
  }
29003
- asyncSignal.$flags$ = d2[5] ?? 0;
29431
+ asyncSignal.$flags$ = d[5] ?? 0;
29004
29432
  if (asyncSignal.$flags$ & 64 /* CLIENT_ONLY */) {
29005
- asyncSignal.$untrackedLoading$ = true;
29433
+ asyncSignal.$untrackedPending$ = true;
29006
29434
  }
29007
- const hasValue = d2.length > 6;
29435
+ const hasValue = d.length > 6;
29008
29436
  if (hasValue) {
29009
- asyncSignal.$untrackedValue$ = d2[6];
29437
+ asyncSignal.$untrackedValue$ = d[6];
29010
29438
  }
29011
29439
  if (asyncSignal.$untrackedValue$ === NEEDS_COMPUTATION) {
29012
29440
  asyncSignal.$flags$ |= 1 /* INVALID */;
29013
29441
  }
29014
- const rawExpires = d2[7] ?? 0;
29442
+ const rawExpires = d[7] ?? 0;
29015
29443
  asyncSignal.expires = Math.abs(rawExpires);
29016
29444
  if (rawExpires < 0) {
29017
29445
  asyncSignal.$flags$ |= 256 /* NO_POLL */;
29018
29446
  }
29019
- if (d2[8] !== void 0 && d2[8] !== 1) {
29020
- asyncSignal.$concurrency$ = d2[8] ?? 1;
29447
+ if (d[8] !== void 0 && d[8] !== 1) {
29448
+ asyncSignal.$concurrency$ = d[8] ?? 1;
29021
29449
  asyncSignal.$jobs$ = [];
29022
29450
  }
29023
- asyncSignal.$timeoutMs$ = d2[9] ?? 0;
29451
+ asyncSignal.$timeoutMs$ = d[9] ?? 0;
29024
29452
  restoreEffectBackRefForEffects(asyncSignal.$effects$, asyncSignal);
29025
29453
  restoreEffectBackRefForEffects(asyncSignal.$loadingEffects$, asyncSignal);
29026
29454
  restoreEffectBackRefForEffects(asyncSignal.$errorEffects$, asyncSignal);
@@ -29030,17 +29458,17 @@ var inflate = (container, target, typeId, data) => {
29030
29458
  case 34 /* SerializerSignal */:
29031
29459
  case 32 /* ComputedSignal */: {
29032
29460
  const computed = target;
29033
- const d2 = data;
29034
- computed.$computeQrl$ = d2[0];
29461
+ const d = data;
29462
+ computed.$computeQrl$ = d[0];
29035
29463
  const p = computed.$computeQrl$.resolve(container).catch(() => {
29036
29464
  });
29037
29465
  loading = loading.finally(() => p);
29038
- if (d2[1]) {
29039
- computed.$effects$ = new Set(d2[1]);
29466
+ if (d[1]) {
29467
+ computed.$effects$ = new Set(d[1]);
29040
29468
  }
29041
- const hasValue = d2.length > 2;
29469
+ const hasValue = d.length > 2;
29042
29470
  if (hasValue) {
29043
- computed.$untrackedValue$ = d2[2];
29471
+ computed.$untrackedValue$ = d[2];
29044
29472
  }
29045
29473
  if (typeId !== 34 /* SerializerSignal */ && computed.$untrackedValue$ !== NEEDS_COMPUTATION) {
29046
29474
  computed.$flags$ &= ~1 /* INVALID */;
@@ -29048,19 +29476,12 @@ var inflate = (container, target, typeId, data) => {
29048
29476
  restoreEffectBackRefForEffects(computed.$effects$, computed);
29049
29477
  break;
29050
29478
  }
29051
- case 23 /* Error */: {
29052
- const d2 = data;
29053
- target.message = d2[0];
29054
- for (let i3 = 1; i3 < d2.length; i3 += 2) {
29055
- target[d2[i3]] = d2[i3 + 1];
29056
- }
29057
- break;
29058
- }
29059
29479
  case 36 /* FormData */: {
29060
29480
  const formData = target;
29061
- const d2 = data;
29062
- for (let i3 = 0; i3 < d2.length; i3++) {
29063
- formData.append(d2[i3++], d2[i3]);
29481
+ const d = data;
29482
+ for (let i2 = 0; i2 < d.length; i2++) {
29483
+ formData.append(d[i2++], d[i2]);
29484
+ yield;
29064
29485
  }
29065
29486
  break;
29066
29487
  }
@@ -29075,48 +29496,14 @@ var inflate = (container, target, typeId, data) => {
29075
29496
  jsx2.toSort = !!toSort;
29076
29497
  break;
29077
29498
  }
29078
- case 25 /* Set */: {
29079
- const set = target;
29080
- const d2 = data;
29081
- for (let i3 = 0; i3 < d2.length; i3++) {
29082
- set.add(d2[i3]);
29083
- }
29084
- break;
29085
- }
29086
- case 26 /* Map */: {
29087
- const map = target;
29088
- const d2 = data;
29089
- for (let i3 = 0; i3 < d2.length; i3++) {
29090
- map.set(d2[i3++], d2[i3]);
29091
- }
29092
- break;
29093
- }
29094
- case 24 /* Promise */: {
29095
- const promise = target;
29096
- const [resolved, result] = data;
29097
- const [resolve, reject] = resolvers.get(promise);
29098
- if (resolved) {
29099
- resolve(result);
29100
- } else {
29101
- reject(result);
29102
- }
29103
- break;
29104
- }
29105
- case 27 /* Uint8Array */:
29106
- const bytes = target;
29107
- const buf = atob(data);
29108
- let i2 = 0;
29109
- for (let j = 0; j < buf.length; j++) {
29110
- const s = buf[j];
29111
- bytes[i2++] = s.charCodeAt(0);
29112
- }
29113
- break;
29114
- case 38 /* PropsProxy */:
29499
+ case 38 /* PropsProxy */: {
29115
29500
  const propsProxy = target;
29116
29501
  const d = data;
29117
29502
  let owner = d[0];
29118
29503
  if (owner === _UNINITIALIZED) {
29119
- owner = new JSXNodeImpl(Fragment, d[1], d[2], null, 0, null);
29504
+ owner = new JSXNodeImpl(Fragment, null, null, null, 0, null);
29505
+ owner.varProps = d[1];
29506
+ owner.constProps = d[2];
29120
29507
  owner._proxy = propsProxy;
29121
29508
  }
29122
29509
  propsProxy[_OWNER] = owner;
@@ -29124,47 +29511,69 @@ var inflate = (container, target, typeId, data) => {
29124
29511
  propsHandler.$effects$ = d[3];
29125
29512
  restoreEffectBackRefForEffectsMap(propsHandler.$effects$, propsProxy);
29126
29513
  break;
29514
+ }
29127
29515
  case 39 /* SubscriptionData */: {
29128
29516
  const effectData = target;
29129
29517
  effectData.data.$scopedStyleIdPrefix$ = data[0];
29130
29518
  effectData.data.$isConst$ = data[1];
29131
29519
  break;
29132
29520
  }
29521
+ case 42 /* SubscriptionDataConstTrue */:
29522
+ case 43 /* SubscriptionDataConstFalse */:
29523
+ break;
29133
29524
  case 40 /* EffectSubscription */: {
29134
29525
  const effectSub = target;
29135
- const d2 = data;
29136
- effectSub.consumer = d2[0];
29137
- effectSub.property = d2[1];
29138
- effectSub.data = d2[2];
29526
+ const d = data;
29527
+ effectSub.consumer = d[0];
29528
+ effectSub.property = d[1];
29529
+ effectSub.data = d[2];
29139
29530
  restoreEffectBackRefForConsumer(effectSub);
29140
29531
  break;
29141
29532
  }
29142
29533
  case 41 /* SubscriptionPatch */: {
29143
29534
  const patch = target;
29144
- const d2 = data;
29145
- patch.rootId = d2[0];
29146
- patch.subscriptions = d2[1];
29535
+ const d = data;
29536
+ patch.rootId = d[0];
29537
+ patch.subscriptions = d[1];
29538
+ break;
29539
+ }
29540
+ case 44 /* EffectSubscriptionNoData */: {
29541
+ const effectSub = target;
29542
+ const d = data;
29543
+ effectSub.consumer = d[0];
29544
+ effectSub.property = d[1];
29545
+ effectSub.data = null;
29546
+ restoreEffectBackRefForConsumer(effectSub);
29547
+ break;
29548
+ }
29549
+ case 27 /* Uint8Array */: {
29550
+ const bytes = target;
29551
+ const buf = atob(data);
29552
+ for (let j = 0; j < buf.length; j++) {
29553
+ bytes[j] = buf.charCodeAt(j);
29554
+ if ((j & 31) === 31) {
29555
+ yield;
29556
+ }
29557
+ }
29558
+ break;
29559
+ }
29560
+ case 35 /* Store */: {
29561
+ const store = unwrapStore(target);
29562
+ const storeTarget = container.$pendingStoreTargets$.get(store);
29563
+ if (storeTarget) {
29564
+ container.$pendingStoreTargets$.delete(store);
29565
+ yield* inflateIterator(container, store, storeTarget.t, storeTarget.v);
29566
+ }
29567
+ const [, flags, effects] = data;
29568
+ const storeHandler = getStoreHandler(target);
29569
+ storeHandler.$flags$ = flags;
29570
+ storeHandler.$effects$ = effects;
29571
+ restoreEffectBackRefForEffectsMap(storeHandler.$effects$, store);
29147
29572
  break;
29148
29573
  }
29149
29574
  default:
29150
29575
  throw qError(16 /* serializeErrorNotImplemented */, [typeId]);
29151
29576
  }
29152
- };
29153
- var _eagerDeserializeArray = (container, data, output = Array(data.length / 2)) => {
29154
- for (let i2 = 0; i2 < data.length; i2 += 2) {
29155
- output[i2 / 2] = deserializeData(container, data[i2], data[i2 + 1]);
29156
- }
29157
- return output;
29158
- };
29159
- function deserializeData(container, typeId, value) {
29160
- if (typeId === 0 /* Plain */) {
29161
- return value;
29162
- }
29163
- const propValue = allocate(container, typeId, value);
29164
- if (needsInflation(typeId)) {
29165
- inflate(container, propValue, typeId, value);
29166
- }
29167
- return propValue;
29168
29577
  }
29169
29578
  function inflateWrappedSignalValue(signal) {
29170
29579
  if (signal.$hostElement$ !== null && vnode_isVNode(signal.$hostElement$)) {
@@ -29193,13 +29602,13 @@ function inflateWrappedSignalValue(signal) {
29193
29602
  }
29194
29603
  }
29195
29604
  function restoreEffectBackRefForConsumer(effect) {
29196
- var _a6;
29605
+ var _a5;
29197
29606
  const isServerSide = qTest ? isServerPlatform() : isServer9;
29198
29607
  const consumerBackRef = effect.consumer;
29199
29608
  if (isServerSide && !consumerBackRef) {
29200
29609
  return;
29201
29610
  }
29202
- consumerBackRef[_a6 = _EFFECT_BACK_REF] || (consumerBackRef[_a6] = /* @__PURE__ */ new Map());
29611
+ consumerBackRef[_a5 = _EFFECT_BACK_REF] || (consumerBackRef[_a5] = /* @__PURE__ */ new Map());
29203
29612
  consumerBackRef[_EFFECT_BACK_REF].set(effect.property, effect);
29204
29613
  }
29205
29614
  function restoreEffectBackRefForEffects(effects, consumer) {
@@ -29219,9 +29628,9 @@ function restoreEffectBackRefForEffectsMap(effectsMap, consumer) {
29219
29628
  }
29220
29629
 
29221
29630
  // packages/qwik/src/core/shared/vnode/vnode.ts
29222
- import { isDev as isDev22 } from "@qwik.dev/core/build";
29223
- var _a5;
29224
- _a5 = _EFFECT_BACK_REF;
29631
+ import { isDev as isDev21 } from "@qwik.dev/core/build";
29632
+ var _a4;
29633
+ _a4 = _EFFECT_BACK_REF;
29225
29634
  var VNode = class {
29226
29635
  constructor(flags, parent, previousSibling, nextSibling, props) {
29227
29636
  this.flags = flags;
@@ -29229,7 +29638,7 @@ var VNode = class {
29229
29638
  this.previousSibling = previousSibling;
29230
29639
  this.nextSibling = nextSibling;
29231
29640
  this.props = props;
29232
- __publicField(this, _a5);
29641
+ __publicField(this, _a4);
29233
29642
  __publicField(this, "slotParent", null);
29234
29643
  __publicField(this, "dirty", 0 /* NONE */);
29235
29644
  __publicField(this, "dirtyChildren", null);
@@ -29237,7 +29646,7 @@ var VNode = class {
29237
29646
  }
29238
29647
  // TODO: this creates debug issues
29239
29648
  toString() {
29240
- if (isDev22) {
29649
+ if (isDev21) {
29241
29650
  return vnode_toString.call(this);
29242
29651
  }
29243
29652
  return Object.prototype.toString.call(this);
@@ -29307,7 +29716,7 @@ var LazyRef = class {
29307
29716
  return this.$ref$;
29308
29717
  }
29309
29718
  if (this.$chunk$ === "") {
29310
- isDev23 && assertDefined(this.$container$, "Sync QRL must have container element");
29719
+ isDev22 && assertDefined(this.$container$, "Sync QRL must have container element");
29311
29720
  const hash = this.$container$.$instanceHash$;
29312
29721
  const doc = this.$container$.element?.ownerDocument || document;
29313
29722
  const qFuncs2 = getQFuncs(doc, hash);
@@ -29349,7 +29758,7 @@ var QRLClass = class {
29349
29758
  this.$container$ = container;
29350
29759
  }
29351
29760
  }
29352
- if ($lazy$.$ref$ != null && typeof this.$captures$ !== "string" && !isPromise($lazy$.$ref$)) {
29761
+ if ($lazy$.$ref$ != null && (!this.$captures$ || typeof this.$captures$ !== "string") && !isPromise($lazy$.$ref$)) {
29353
29762
  this.resolved = bindCaptures(this, $lazy$.$ref$);
29354
29763
  }
29355
29764
  }
@@ -29495,27 +29904,45 @@ var _captures = null;
29495
29904
  var setCaptures = (captures) => {
29496
29905
  _captures = captures;
29497
29906
  };
29498
- var deserializeCaptures = (container, captures) => {
29907
+ var deserializeCaptureDeltas = (container, deltaString, startIndex = 0, previousRootId) => {
29499
29908
  const refs = [];
29500
- const captureIds = captures.split(" ");
29501
- for (let i2 = 0; i2 < captureIds.length; i2++) {
29502
- const id = captureIds[i2];
29503
- refs.push(container.$getObjectById$(id));
29909
+ let previous = previousRootId;
29910
+ let start = startIndex;
29911
+ for (let i2 = startIndex; i2 <= deltaString.length; i2++) {
29912
+ if (i2 === deltaString.length || deltaString.charCodeAt(i2) === 32) {
29913
+ if (i2 > start) {
29914
+ const delta = Number(deltaString.slice(start, i2));
29915
+ previous = previous === void 0 ? delta : previous + delta;
29916
+ refs.push(container.$getObjectById$(previous));
29917
+ }
29918
+ start = i2 + 1;
29919
+ }
29504
29920
  }
29505
29921
  return refs;
29506
29922
  };
29923
+ var deserializeQrlCaptureDeltas = (container, qrlString) => {
29924
+ const firstHash = qrlString.indexOf("#");
29925
+ if (firstHash === -1) {
29926
+ return deserializeCaptureDeltas(container, qrlString);
29927
+ }
29928
+ const secondHash = qrlString.indexOf("#", firstHash + 1);
29929
+ const previousRootId = Number(qrlString.slice(0, firstHash)) + Number(qrlString.slice(firstHash + 1, secondHash));
29930
+ return deserializeCaptureDeltas(container, qrlString, secondHash + 1, previousRootId);
29931
+ };
29507
29932
  var ensureQrlCaptures = (qrl) => {
29508
- _captures = qrl.$captures$;
29933
+ const serializedCaptures = qrl.$captures$;
29509
29934
  const container = qrl.$container$;
29510
- if (typeof _captures === "string") {
29935
+ if (typeof serializedCaptures === "string") {
29511
29936
  if (!container) {
29512
29937
  throw qError(13 /* qrlMissingContainer */);
29513
29938
  }
29514
29939
  const prevLoading = loading;
29515
- _captures = qrl.$captures$ = deserializeCaptures(container, _captures);
29940
+ _captures = qrl.$captures$ = deserializeQrlCaptureDeltas(container, serializedCaptures);
29516
29941
  if (loading !== prevLoading) {
29517
29942
  return loading;
29518
29943
  }
29944
+ } else {
29945
+ _captures = serializedCaptures || null;
29519
29946
  }
29520
29947
  };
29521
29948
  var bindCaptures = (qrl, ref) => {
@@ -29888,6 +30315,7 @@ var Slot = (props) => {
29888
30315
 
29889
30316
  // packages/qwik/src/core/shared/serdes/constants.ts
29890
30317
  var explicitUndefined = /* @__PURE__ */ Symbol("undefined");
30318
+ var EMPTY_OBJECT_PAYLOAD = 0;
29891
30319
  var _constants = [
29892
30320
  void 0,
29893
30321
  null,
@@ -29906,7 +30334,11 @@ var _constants = [
29906
30334
  -Infinity,
29907
30335
  Number.MAX_SAFE_INTEGER,
29908
30336
  Number.MAX_SAFE_INTEGER - 1,
29909
- Number.MIN_SAFE_INTEGER
30337
+ Number.MIN_SAFE_INTEGER,
30338
+ ":",
30339
+ ".",
30340
+ "id",
30341
+ "ref"
29910
30342
  ];
29911
30343
 
29912
30344
  // packages/qwik/src/core/shared/serdes/deser-proxy.ts
@@ -29950,14 +30382,19 @@ var DeserializationHandler = class {
29950
30382
  return value;
29951
30383
  }
29952
30384
  const container = this.$container$;
29953
- const propValue = allocate(container, typeId, value);
29954
- Reflect.set(target, property, propValue);
29955
- this.$data$[idx] = 0 /* Plain */;
29956
- this.$data$[idx + 1] = propValue;
29957
- if (needsInflation(typeId)) {
29958
- inflate(container, propValue, typeId, value);
30385
+ const ownsPendingStoreTargets = beginDeserialization(container);
30386
+ try {
30387
+ const propValue = allocate(container, typeId, value);
30388
+ Reflect.set(target, property, propValue);
30389
+ this.$data$[idx] = 0 /* Plain */;
30390
+ this.$data$[idx + 1] = propValue;
30391
+ if (needsInflation(typeId)) {
30392
+ inflate(container, propValue, typeId, value);
30393
+ }
30394
+ return propValue;
30395
+ } finally {
30396
+ endDeserialization(container, ownsPendingStoreTargets);
29959
30397
  }
29960
- return propValue;
29961
30398
  }
29962
30399
  has(target, property) {
29963
30400
  if (property === SERIALIZER_PROXY_UNWRAP) {
@@ -30031,13 +30468,13 @@ var mergeSubscriptionSet = (container, producer, backRef, rootEffects, patchEffe
30031
30468
 
30032
30469
  // packages/qwik/src/core/client/process-segment-state.ts
30033
30470
  var processedStatePatchScripts = /* @__PURE__ */ new WeakMap();
30034
- var processSegmentStateScripts = (container, segmentId) => {
30471
+ function* processSegmentStateScriptsIterator(container, segmentId) {
30035
30472
  if (!__EXPERIMENTAL__.suspense) {
30036
30473
  return;
30037
30474
  }
30038
30475
  const stateContainer = container;
30039
30476
  const qwikStates = stateContainer.element.querySelectorAll(
30040
- `${stateScriptSelector(stateContainer.$instanceHash$)}${QStatePatchAttrSelector}`
30477
+ `script[type="qwik/state"][q\\:instance="${stateContainer.$instanceHash$}"]${QStatePatchAttrSelector}`
30041
30478
  );
30042
30479
  const processedScripts = getProcessedStatePatchScripts(container);
30043
30480
  for (let i2 = 0; i2 < qwikStates.length; i2++) {
@@ -30049,9 +30486,10 @@ var processSegmentStateScripts = (container, segmentId) => {
30049
30486
  continue;
30050
30487
  }
30051
30488
  processedScripts.add(stateScript);
30052
- processStatePatch(container, stateContainer, stateScript.textContent);
30489
+ yield* processStatePatch(container, stateContainer, stateScript.textContent);
30490
+ yield;
30053
30491
  }
30054
- };
30492
+ }
30055
30493
  var getProcessedStatePatchScripts = (container) => {
30056
30494
  let processedScripts = processedStatePatchScripts.get(container);
30057
30495
  if (!processedScripts) {
@@ -30060,23 +30498,21 @@ var getProcessedStatePatchScripts = (container) => {
30060
30498
  }
30061
30499
  return processedScripts;
30062
30500
  };
30063
- var stateScriptSelector = (instanceHash) => {
30064
- return `script[type="qwik/state"][q\\:instance="${instanceHash}"]`;
30065
- };
30066
- var processStatePatch = (container, stateContainer, textContent) => {
30067
- if (textContent) {
30068
- const [rootStart, rawStateData, forwardRefs, subscriptionPatchRootId] = JSON.parse(
30069
- textContent
30070
- );
30071
- appendStatePatchRoots(container, stateContainer, rootStart, rawStateData);
30072
- mergeForwardRefs(stateContainer, forwardRefs || void 0);
30073
- applySubscriptionPatches(
30074
- container,
30075
- subscriptionPatchRootId === void 0 ? void 0 : stateContainer.$getObjectById$(subscriptionPatchRootId)
30076
- );
30501
+ function* processStatePatch(container, stateContainer, textContent) {
30502
+ if (!textContent) {
30503
+ return;
30077
30504
  }
30078
- };
30079
- var appendStatePatchRoots = (container, stateContainer, rootStart, rawStateData) => {
30505
+ const [rootStart, rawStateData, forwardRefs, subscriptionPatchRootId] = JSON.parse(
30506
+ textContent
30507
+ );
30508
+ yield* appendStatePatchRoots(container, stateContainer, rootStart, rawStateData);
30509
+ mergeForwardRefs(stateContainer, forwardRefs || void 0);
30510
+ applySubscriptionPatches(
30511
+ container,
30512
+ subscriptionPatchRootId === void 0 ? void 0 : stateContainer.$getObjectById$(subscriptionPatchRootId)
30513
+ );
30514
+ }
30515
+ function* appendStatePatchRoots(container, stateContainer, rootStart, rawStateData) {
30080
30516
  const currentRootCount = stateContainer.$rawStateData$.length / 2;
30081
30517
  if (rootStart !== currentRootCount) {
30082
30518
  if (qDev) {
@@ -30088,15 +30524,16 @@ var appendStatePatchRoots = (container, stateContainer, rootStart, rawStateData)
30088
30524
  }
30089
30525
  for (let i2 = 0; i2 < rawStateData.length; i2++) {
30090
30526
  stateContainer.$rawStateData$[rootStart * 2 + i2] = rawStateData[i2];
30527
+ yield;
30091
30528
  }
30092
- preprocessState(stateContainer.$rawStateData$, container, void 0, rootStart * 2);
30529
+ yield* preprocessStateIterator(stateContainer.$rawStateData$, container, rootStart * 2);
30093
30530
  stateContainer.$stateData$ = wrapDeserializerProxy(
30094
30531
  container,
30095
30532
  stateContainer.$rawStateData$
30096
30533
  );
30097
30534
  stateContainer.$stateData$.length = stateContainer.$rawStateData$.length / 2;
30098
30535
  stateContainer.$rootForwardRefs$ = stateContainer.$forwardRefs$;
30099
- };
30536
+ }
30100
30537
  var mergeForwardRefs = (stateContainer, forwardRefs) => {
30101
30538
  if (!forwardRefs) {
30102
30539
  return;
@@ -30112,33 +30549,144 @@ var mergeForwardRefs = (stateContainer, forwardRefs) => {
30112
30549
  };
30113
30550
 
30114
30551
  // packages/qwik/src/core/client/process-vnode-data.ts
30552
+ var Q_SUSPENSE_RESOLVED = "q:r";
30553
+ var Q_PATCH = "q:patch";
30554
+ function processVNodeData(document2, containerElement) {
30555
+ const qDocument = document2;
30556
+ if (containerElement?.qVNodeRefs) {
30557
+ return;
30558
+ }
30559
+ if (qDocument.qVNodeDataStarted && !qDocument.qVNodeDataProcessed) {
30560
+ return;
30561
+ }
30562
+ qDocument.qVNodeDataStarted = true;
30563
+ qDocument.qVNodeData || (qDocument.qVNodeData = /* @__PURE__ */ new WeakMap());
30564
+ enqueueProcessVNodeDataJob(qDocument, processRootVNodeData(document2));
30565
+ }
30115
30566
  function processOutOfOrderSegmentVNodeData(document2, segmentId, contentNode) {
30116
30567
  if (!__EXPERIMENTAL__.suspense || !contentNode) {
30117
30568
  return;
30118
30569
  }
30119
30570
  const qContainerElement = contentNode.closest("[q\\:container]");
30120
- const script = qContainerElement?.querySelector(
30571
+ if (!qContainerElement) {
30572
+ return;
30573
+ }
30574
+ const script = qContainerElement.querySelector(
30121
30575
  `script[type="qwik/vnode"][q\\:r="${segmentId}"]:not([q\\:patch])`
30122
30576
  );
30123
- processVNodeDataImpl(
30577
+ const patches = qContainerElement.querySelectorAll(
30578
+ `script[type="qwik/vnode"][q\\:r="${segmentId}"][q\\:patch]`
30579
+ );
30580
+ enqueueProcessVNodeDataJob(
30124
30581
  document2,
30125
- segmentId,
30126
- qContainerElement,
30127
- contentNode,
30128
- script?.textContent || void 0
30582
+ processOutOfOrderSegmentVNodeDataIterator(
30583
+ document2,
30584
+ segmentId,
30585
+ qContainerElement,
30586
+ contentNode,
30587
+ script?.textContent || void 0,
30588
+ patches
30589
+ )
30129
30590
  );
30130
- const patches = qContainerElement?.querySelectorAll(
30131
- `script[type="qwik/vnode"][q\\:r="${segmentId}"][q\\:patch]`
30591
+ }
30592
+ var onVNodeDataReady = (document2, callback) => {
30593
+ const qDocument = document2;
30594
+ if (qDocument.qVNodeDataReady) {
30595
+ callback();
30596
+ } else {
30597
+ (qDocument.qVNodeDataCallbacks || (qDocument.qVNodeDataCallbacks = [])).push(callback);
30598
+ }
30599
+ };
30600
+ function enqueueProcessVNodeDataJob(qDocument, iterator) {
30601
+ const state = qDocument.qVNodeDataState || (qDocument.qVNodeDataState = {
30602
+ $queue$: [],
30603
+ $active$: null
30604
+ });
30605
+ qDocument.qProcessVNodeDataPatch || (qDocument.qProcessVNodeDataPatch = (script) => enqueueProcessVNodeDataJob(qDocument, processVNodeDataPatch(qDocument, script)));
30606
+ qDocument.qVNodeDataReady = false;
30607
+ state.$queue$.push(iterator);
30608
+ scheduleProcessVNodeData(qDocument, state);
30609
+ }
30610
+ function scheduleProcessVNodeData(qDocument, state) {
30611
+ if (state.$active$) {
30612
+ return;
30613
+ }
30614
+ const iterator = state.$queue$.shift();
30615
+ if (!iterator) {
30616
+ markVNodeDataReady(qDocument);
30617
+ return;
30618
+ }
30619
+ state.$active$ = createYieldingIteratorState(
30620
+ runProcessVNodeData(qDocument, state, iterator),
30621
+ () => {
30622
+ if (qDocument.qVNodeDataState === state) {
30623
+ state.$active$ = null;
30624
+ scheduleProcessVNodeData(qDocument, state);
30625
+ }
30626
+ },
30627
+ (error) => {
30628
+ state.$active$ = null;
30629
+ logError(error);
30630
+ markVNodeDataReady(qDocument);
30631
+ }
30132
30632
  );
30133
- for (let i2 = 0; patches && i2 < patches.length; i2++) {
30134
- document2.qProcessVNodeDataPatch?.(patches[i2]);
30633
+ scheduleYieldingIterator(state.$active$);
30634
+ }
30635
+ function* runProcessVNodeData(qDocument, state, iterator) {
30636
+ while (qDocument.qVNodeDataState === state) {
30637
+ if (iterator.next().done) {
30638
+ return;
30639
+ }
30640
+ yield;
30135
30641
  }
30136
30642
  }
30137
- function processVNodeData(document2) {
30138
- processVNodeDataImpl(document2);
30139
- document2.qVNodeDataProcessed = true;
30643
+ function markVNodeDataReady(document2) {
30644
+ if (document2.qVNodeDataReady) {
30645
+ return;
30646
+ }
30647
+ document2.qVNodeDataReady = true;
30648
+ document2.qVNodeDataState = void 0;
30649
+ const callbacks = document2.qVNodeDataCallbacks;
30650
+ document2.qVNodeDataCallbacks = void 0;
30651
+ if (callbacks) {
30652
+ for (let i2 = 0; i2 < callbacks.length; i2++) {
30653
+ callbacks[i2]();
30654
+ }
30655
+ }
30656
+ }
30657
+ function* processRootVNodeData(document2) {
30658
+ yield* processVNodeDataImpl(document2);
30659
+ const qDocument = document2;
30660
+ qDocument.qVNodeDataProcessed = true;
30661
+ qDocument.qVNodeDataStarted = false;
30140
30662
  }
30141
- function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentContent, segmentVNodeData) {
30663
+ function* processOutOfOrderSegmentVNodeDataIterator(document2, segmentId, segmentContainer, segmentContent, segmentVNodeData, patches) {
30664
+ yield* processVNodeDataImpl(
30665
+ document2,
30666
+ segmentId,
30667
+ segmentContainer,
30668
+ segmentContent,
30669
+ segmentVNodeData
30670
+ );
30671
+ for (let i2 = 0; i2 < patches.length; i2++) {
30672
+ yield* processVNodeDataPatch(document2, patches[i2]);
30673
+ }
30674
+ }
30675
+ function* processVNodeDataPatch(document2, script) {
30676
+ const qContainerElement = script?.closest("[q\\:container]");
30677
+ const patchSegment = script?.getAttribute(Q_SUSPENSE_RESOLVED);
30678
+ const contentNode = qContainerElement && (patchSegment ? qContainerElement.querySelector(`[q\\:rp="${patchSegment}"]`) : qContainerElement);
30679
+ if (qContainerElement && contentNode) {
30680
+ yield* processVNodeDataImpl(
30681
+ document2,
30682
+ patchSegment || void 0,
30683
+ qContainerElement,
30684
+ contentNode,
30685
+ script.textContent
30686
+ );
30687
+ }
30688
+ }
30689
+ function* processVNodeDataImpl(document2, segmentId, segmentContainer, segmentContent, segmentVNodeData) {
30142
30690
  const Q_CONTAINER = "q:container";
30143
30691
  const Q_CONTAINER_END = "/" + Q_CONTAINER;
30144
30692
  const Q_PROPS_SEPARATOR2 = ":";
@@ -30147,9 +30695,22 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30147
30695
  const Q_IGNORE_END = "/" + Q_IGNORE;
30148
30696
  const Q_CONTAINER_ISLAND = "q:container-island";
30149
30697
  const Q_CONTAINER_ISLAND_END = "/" + Q_CONTAINER_ISLAND;
30150
- const Q_SUSPENSE_RESOLVED = "q:r";
30151
30698
  const Q_SUSPENSE_RESULT_PARENT = "q:rp";
30152
- const Q_PATCH = "q:patch";
30699
+ let NodeType;
30700
+ ((NodeType2) => {
30701
+ NodeType2[NodeType2["CONTAINER_MASK"] = 1] = "CONTAINER_MASK";
30702
+ NodeType2[NodeType2["ELEMENT"] = 2] = "ELEMENT";
30703
+ NodeType2[NodeType2["ELEMENT_CONTAINER"] = 3] = "ELEMENT_CONTAINER";
30704
+ NodeType2[NodeType2["ELEMENT_SHADOW_ROOT_WRAPPER"] = 6] = "ELEMENT_SHADOW_ROOT_WRAPPER";
30705
+ NodeType2[NodeType2["ELEMENT_SUSPENSE_RESULT_PARENT"] = 130] = "ELEMENT_SUSPENSE_RESULT_PARENT";
30706
+ NodeType2[NodeType2["COMMENT_SKIP_START"] = 9] = "COMMENT_SKIP_START";
30707
+ NodeType2[NodeType2["COMMENT_SKIP_END"] = 8] = "COMMENT_SKIP_END";
30708
+ NodeType2[NodeType2["COMMENT_IGNORE_START"] = 16] = "COMMENT_IGNORE_START";
30709
+ NodeType2[NodeType2["COMMENT_IGNORE_END"] = 32] = "COMMENT_IGNORE_END";
30710
+ NodeType2[NodeType2["COMMENT_ISLAND_START"] = 65] = "COMMENT_ISLAND_START";
30711
+ NodeType2[NodeType2["COMMENT_ISLAND_END"] = 64] = "COMMENT_ISLAND_END";
30712
+ NodeType2[NodeType2["OTHER"] = 0] = "OTHER";
30713
+ })(NodeType || (NodeType = {}));
30153
30714
  const qDocument = document2;
30154
30715
  const vNodeDataMap = qDocument.qVNodeData || (qDocument.qVNodeData = /* @__PURE__ */ new WeakMap());
30155
30716
  const prototype = document2.body;
@@ -30165,7 +30726,7 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30165
30726
  const getAttribute = prototype.getAttribute;
30166
30727
  const hasAttribute = prototype.hasAttribute;
30167
30728
  const getNodeType = getter(prototype, "nodeType");
30168
- const attachVnodeDataAndRefs = (element) => {
30729
+ const attachVnodeDataAndRefs = function* (element) {
30169
30730
  const scripts = element.querySelectorAll('script[type="qwik/vnode"]');
30170
30731
  for (let i2 = 0; i2 < scripts.length; i2++) {
30171
30732
  const script = scripts[i2];
@@ -30173,6 +30734,7 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30173
30734
  qContainer.qVNodeRefs || (qContainer.qVNodeRefs = /* @__PURE__ */ new Map());
30174
30735
  if (script.hasAttribute(Q_PATCH)) {
30175
30736
  qDocument.qProcessVNodeDataPatch?.(script);
30737
+ yield;
30176
30738
  continue;
30177
30739
  }
30178
30740
  const scriptContent = script.textContent;
@@ -30182,29 +30744,18 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30182
30744
  } else {
30183
30745
  qContainer.qVnodeData = scriptContent;
30184
30746
  }
30747
+ yield;
30185
30748
  }
30186
30749
  const shadowRoots = element.querySelectorAll("[q\\:shadowroot]");
30187
30750
  for (let i2 = 0; i2 < shadowRoots.length; i2++) {
30188
30751
  const parent = shadowRoots[i2];
30189
30752
  const shadowRoot = parent.shadowRoot;
30190
- shadowRoot && attachVnodeDataAndRefs(shadowRoot);
30753
+ if (shadowRoot) {
30754
+ yield* attachVnodeDataAndRefs(shadowRoot);
30755
+ }
30756
+ yield;
30191
30757
  }
30192
30758
  };
30193
- let NodeType;
30194
- ((NodeType2) => {
30195
- NodeType2[NodeType2["CONTAINER_MASK"] = 1] = "CONTAINER_MASK";
30196
- NodeType2[NodeType2["ELEMENT"] = 2] = "ELEMENT";
30197
- NodeType2[NodeType2["ELEMENT_CONTAINER"] = 3] = "ELEMENT_CONTAINER";
30198
- NodeType2[NodeType2["ELEMENT_SHADOW_ROOT_WRAPPER"] = 6] = "ELEMENT_SHADOW_ROOT_WRAPPER";
30199
- NodeType2[NodeType2["ELEMENT_SUSPENSE_RESULT_PARENT"] = 130] = "ELEMENT_SUSPENSE_RESULT_PARENT";
30200
- NodeType2[NodeType2["COMMENT_SKIP_START"] = 9] = "COMMENT_SKIP_START";
30201
- NodeType2[NodeType2["COMMENT_SKIP_END"] = 8] = "COMMENT_SKIP_END";
30202
- NodeType2[NodeType2["COMMENT_IGNORE_START"] = 16] = "COMMENT_IGNORE_START";
30203
- NodeType2[NodeType2["COMMENT_IGNORE_END"] = 32] = "COMMENT_IGNORE_END";
30204
- NodeType2[NodeType2["COMMENT_ISLAND_START"] = 65] = "COMMENT_ISLAND_START";
30205
- NodeType2[NodeType2["COMMENT_ISLAND_END"] = 64] = "COMMENT_ISLAND_END";
30206
- NodeType2[NodeType2["OTHER"] = 0] = "OTHER";
30207
- })(NodeType || (NodeType = {}));
30208
30759
  const getFastNodeType = (node) => {
30209
30760
  const nodeType = getNodeType.call(node);
30210
30761
  if (nodeType === 1) {
@@ -30241,7 +30792,7 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30241
30792
  }
30242
30793
  return node;
30243
30794
  };
30244
- const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs, qContainerElement, segmentId2) => {
30795
+ const walkContainer = function* (walker2, containerNode, node, exitNode, vData, qVNodeRefs, qContainerElement, segmentId2) {
30245
30796
  const isSegment = __EXPERIMENTAL__.suspense && segmentId2 !== void 0;
30246
30797
  const vData_length = vData.length;
30247
30798
  let elementIdx = 0;
@@ -30262,6 +30813,9 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30262
30813
  }
30263
30814
  return elementsToSkip;
30264
30815
  };
30816
+ if (!node) {
30817
+ return;
30818
+ }
30265
30819
  do {
30266
30820
  if (node === exitNode) {
30267
30821
  return;
@@ -30274,7 +30828,7 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30274
30828
  while (cursor && !(nextNode = nextSibling(cursor))) {
30275
30829
  cursor = cursor.parentNode;
30276
30830
  }
30277
- walkContainer(
30831
+ yield* walkContainer(
30278
30832
  walker2,
30279
30833
  container,
30280
30834
  node,
@@ -30310,13 +30864,13 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30310
30864
  throw new Error(`<!--${node?.nodeValue}--> not closed!`);
30311
30865
  }
30312
30866
  } while (getFastNodeType(nextNode) !== 8 /* COMMENT_SKIP_END */);
30313
- walkContainer(walker2, node, node, nextNode, "", null, qContainerElement);
30867
+ yield* walkContainer(walker2, node, node, nextNode, "", null, qContainerElement);
30314
30868
  } else if (nodeType === 6 /* ELEMENT_SHADOW_ROOT_WRAPPER */) {
30315
30869
  nextNode = nextSibling(node);
30316
30870
  const shadowRootContainer = node;
30317
30871
  const shadowRoot = shadowRootContainer?.shadowRoot;
30318
30872
  if (shadowRoot) {
30319
- walkContainer(
30873
+ yield* walkContainer(
30320
30874
  // we need to create a new walker for the shadow root
30321
30875
  document2.createTreeWalker(
30322
30876
  shadowRoot,
@@ -30380,16 +30934,21 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30380
30934
  }
30381
30935
  elementIdx++;
30382
30936
  if (__EXPERIMENTAL__.suspense && contentBoundaryId !== null) {
30383
- processSuspenseContentSegment(qContainerElement, node, contentBoundaryId);
30937
+ yield* processSuspenseContentSegment(
30938
+ qContainerElement,
30939
+ node,
30940
+ contentBoundaryId
30941
+ );
30384
30942
  nextNode = nextSibling(node);
30385
30943
  if (nextNode) {
30386
30944
  walker2.currentNode = nextNode;
30387
30945
  }
30388
30946
  }
30389
30947
  }
30948
+ yield;
30390
30949
  } while (node = nextNode || walker2.nextNode());
30391
30950
  };
30392
- const processVNodeDataScope = (qContainerElement, contentNode, vData, scopeSegmentId) => {
30951
+ const processVNodeDataScope = function* (qContainerElement, contentNode, vData, scopeSegmentId) {
30393
30952
  qContainerElement.qVNodeRefs || (qContainerElement.qVNodeRefs = /* @__PURE__ */ new Map());
30394
30953
  const scopeWalker = document2.createTreeWalker(
30395
30954
  document2,
@@ -30397,7 +30956,7 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30397
30956
  /* NodeFilter.SHOW_COMMENT */
30398
30957
  );
30399
30958
  scopeWalker.currentNode = contentNode;
30400
- walkContainer(
30959
+ yield* walkContainer(
30401
30960
  scopeWalker,
30402
30961
  contentNode,
30403
30962
  contentNode,
@@ -30408,39 +30967,33 @@ function processVNodeDataImpl(document2, segmentId, segmentContainer, segmentCon
30408
30967
  scopeSegmentId
30409
30968
  );
30410
30969
  };
30411
- const processSuspenseContentSegment = __EXPERIMENTAL__.suspense ? (qContainerElement, contentNode, boundaryId, vData) => {
30970
+ const processSuspenseContentSegment = function* (qContainerElement, contentNode, boundaryId, vData) {
30412
30971
  vData || (vData = qContainerElement?.qSegmentVnodeData?.get(boundaryId));
30413
30972
  if (qContainerElement && vData) {
30414
- processVNodeDataScope(qContainerElement, contentNode, vData, boundaryId);
30415
- }
30416
- } : null;
30417
- qDocument.qProcessVNodeDataPatch = (script) => {
30418
- const qContainerElement = script?.closest("[q\\:container]");
30419
- const patchSegment = script?.getAttribute(Q_SUSPENSE_RESOLVED);
30420
- const contentNode = qContainerElement && (patchSegment ? qContainerElement.querySelector(`[q\\:rp="${patchSegment}"]`) : qContainerElement);
30421
- if (qContainerElement && contentNode) {
30422
- processVNodeDataScope(
30423
- qContainerElement,
30424
- contentNode,
30425
- script.textContent,
30426
- patchSegment || void 0
30427
- );
30973
+ yield* processVNodeDataScope(qContainerElement, contentNode, vData, boundaryId);
30428
30974
  }
30429
30975
  };
30430
- if (__EXPERIMENTAL__.suspense && segmentId !== void 0) {
30431
- if (segmentContainer && segmentContent && segmentVNodeData) {
30432
- segmentContainer.qVNodeRefs || (segmentContainer.qVNodeRefs = /* @__PURE__ */ new Map());
30433
- processSuspenseContentSegment(segmentContainer, segmentContent, segmentId, segmentVNodeData);
30976
+ if (segmentContainer && segmentContent && segmentVNodeData !== void 0) {
30977
+ segmentContainer.qVNodeRefs || (segmentContainer.qVNodeRefs = /* @__PURE__ */ new Map());
30978
+ if (__EXPERIMENTAL__.suspense && segmentId !== void 0) {
30979
+ yield* processSuspenseContentSegment(
30980
+ segmentContainer,
30981
+ segmentContent,
30982
+ segmentId,
30983
+ segmentVNodeData
30984
+ );
30985
+ } else {
30986
+ yield* processVNodeDataScope(segmentContainer, segmentContent, segmentVNodeData);
30434
30987
  }
30435
30988
  return;
30436
30989
  }
30437
- attachVnodeDataAndRefs(document2);
30990
+ yield* attachVnodeDataAndRefs(document2);
30438
30991
  const walker = document2.createTreeWalker(
30439
30992
  document2,
30440
30993
  1 | 128
30441
30994
  /* NodeFilter.SHOW_COMMENT */
30442
30995
  );
30443
- walkContainer(walker, null, walker.firstChild(), null, "", null, null);
30996
+ yield* walkContainer(walker, null, walker.firstChild(), null, "", null, null);
30444
30997
  }
30445
30998
  var isSeparator = (ch) => (
30446
30999
  /* `!` */
@@ -30470,6 +31023,90 @@ var findVDataSectionEnd = (vData, start, end) => {
30470
31023
  return start;
30471
31024
  };
30472
31025
 
31026
+ // packages/qwik/src/core/client/process-state-data.ts
31027
+ function isContainerReady(container) {
31028
+ return container.$containerDataProcessState$ === 3 /* ProcessingStateDone */;
31029
+ }
31030
+ function processContainerStateData(container, iterator) {
31031
+ const state = container.$containerStateDataState$ || (container.$containerStateDataState$ = {
31032
+ $queue$: [],
31033
+ $active$: null
31034
+ });
31035
+ container.$containerDataProcessState$ = 2 /* ProcessingState */;
31036
+ state.$queue$.push(iterator);
31037
+ scheduleProcessContainerStateData(container, state);
31038
+ }
31039
+ var onContainerDataReady = (container, callback) => {
31040
+ const domContainer = container;
31041
+ const checkReady = () => {
31042
+ if (!isContainerReady(domContainer)) {
31043
+ (domContainer.$containerStateReadyCallbacks$ || (domContainer.$containerStateReadyCallbacks$ = [])).push(checkReady);
31044
+ return;
31045
+ }
31046
+ onVNodeDataReady(domContainer.document, () => {
31047
+ if (isContainerReady(domContainer)) {
31048
+ callback();
31049
+ } else {
31050
+ checkReady();
31051
+ }
31052
+ });
31053
+ };
31054
+ checkReady();
31055
+ };
31056
+ var whenContainerDataReady = (container, callback) => {
31057
+ const domContainer = container;
31058
+ if (isContainerReady(domContainer) && domContainer.document.qVNodeDataReady) {
31059
+ return callback();
31060
+ }
31061
+ return new Promise((resolve, reject) => {
31062
+ onContainerDataReady(domContainer, () => {
31063
+ try {
31064
+ resolve(callback());
31065
+ } catch (error) {
31066
+ reject(error);
31067
+ }
31068
+ });
31069
+ });
31070
+ };
31071
+ function scheduleProcessContainerStateData(container, state) {
31072
+ if (state.$active$) {
31073
+ return;
31074
+ }
31075
+ const iterator = state.$queue$.shift();
31076
+ if (!iterator) {
31077
+ markContainerDataReady(container);
31078
+ return;
31079
+ }
31080
+ state.$active$ = createYieldingIteratorState(
31081
+ iterator,
31082
+ () => {
31083
+ state.$active$ = null;
31084
+ scheduleProcessContainerStateData(container, state);
31085
+ },
31086
+ (error) => {
31087
+ state.$active$ = null;
31088
+ logError(error);
31089
+ markContainerDataReady(container);
31090
+ }
31091
+ );
31092
+ scheduleYieldingIterator(state.$active$);
31093
+ }
31094
+ function markContainerDataReady(container) {
31095
+ const state = container.$containerDataProcessState$;
31096
+ if (state !== 2 /* ProcessingState */) {
31097
+ return;
31098
+ }
31099
+ container.$containerDataProcessState$ = 3 /* ProcessingStateDone */;
31100
+ container.$containerStateDataState$ = void 0;
31101
+ const callbacks = container.$containerStateReadyCallbacks$;
31102
+ container.$containerStateReadyCallbacks$ = void 0;
31103
+ if (callbacks) {
31104
+ for (let i2 = 0; i2 < callbacks.length; i2++) {
31105
+ callbacks[i2]();
31106
+ }
31107
+ }
31108
+ }
31109
+
30473
31110
  // packages/qwik/src/core/client/dom-container.ts
30474
31111
  function getDomContainer(element) {
30475
31112
  const qContainerElement = _getQContainerElement(element);
@@ -30490,8 +31127,14 @@ function getOutOfOrderStreamingScript(boundaryId, content) {
30490
31127
  const qContainerElement = content?.closest(QContainerSelector);
30491
31128
  const qContainer = qContainerElement?.qContainer;
30492
31129
  if (qContainer) {
30493
- processOutOfOrderSegmentVNodeData(qContainer.element.ownerDocument, segmentId, content);
30494
- processSegmentStateScripts(qContainer, segmentId);
31130
+ const document2 = qContainer.element.ownerDocument;
31131
+ processOutOfOrderSegmentVNodeData(document2, segmentId, content);
31132
+ onVNodeDataReady(document2, () => {
31133
+ qContainer.element.qContainer === qContainer && processContainerStateData(
31134
+ qContainer,
31135
+ processSegmentStateScriptsIterator(qContainer, segmentId)
31136
+ );
31137
+ });
30495
31138
  }
30496
31139
  }
30497
31140
  var DomContainer = class extends _SharedContainer {
@@ -30507,6 +31150,9 @@ var DomContainer = class extends _SharedContainer {
30507
31150
  __publicField(this, "$instanceHash$");
30508
31151
  __publicField(this, "$forwardRefs$", null);
30509
31152
  __publicField(this, "vNodeLocate", (id) => vnode_locate(this.rootVNode, id));
31153
+ __publicField(this, "$containerDataProcessState$", 0 /* NotStarted */);
31154
+ __publicField(this, "$containerStateReadyCallbacks$");
31155
+ __publicField(this, "$containerStateDataState$");
30510
31156
  __publicField(this, "$rawStateData$");
30511
31157
  __publicField(this, "$stateData$");
30512
31158
  __publicField(this, "$rootForwardRefs$", null);
@@ -30518,7 +31164,8 @@ var DomContainer = class extends _SharedContainer {
30518
31164
  if (!this.qContainer) {
30519
31165
  throw qError(25 /* elementWithoutContainer */);
30520
31166
  }
30521
- this.document = element.ownerDocument;
31167
+ const document2 = element.ownerDocument;
31168
+ this.document = document2;
30522
31169
  this.element = element;
30523
31170
  this.$buildBase$ = element.getAttribute(QBaseAttr);
30524
31171
  this.$instanceHash$ = element.getAttribute(QInstanceAttr);
@@ -30526,23 +31173,48 @@ var DomContainer = class extends _SharedContainer {
30526
31173
  this.rootVNode = vnode_newUnMaterializedElement(this.element);
30527
31174
  this.$rawStateData$ = [];
30528
31175
  this.$stateData$ = [];
30529
- const document2 = this.element.ownerDocument;
30530
- if (!document2.qVNodeDataProcessed) {
30531
- processVNodeData(document2);
30532
- }
30533
31176
  if (__EXPERIMENTAL__.suspense && document2.querySelector("template[q\\:r]")) {
30534
31177
  document2.qProcessOOOS || (document2.qProcessOOOS = getOutOfOrderStreamingScript);
30535
31178
  }
30536
31179
  this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
30537
31180
  this.$setServerData$();
30538
- element.setAttribute(QContainerAttr, "resumed" /* RESUMED */);
30539
31181
  element.qContainer = this;
30540
31182
  element.qDestroy = () => this.$destroy$();
30541
- this.$processRootStateScript$();
31183
+ this.$containerDataProcessState$ = 1 /* ProcessingVNode */;
31184
+ processVNodeData(document2, element);
31185
+ onVNodeDataReady(document2, () => {
31186
+ if (this.$containerDataProcessState$ === 1 /* ProcessingVNode */) {
31187
+ processContainerStateData(this, this.$processContainerData$());
31188
+ }
31189
+ });
31190
+ }
31191
+ *$processContainerData$() {
31192
+ const element = this.element;
31193
+ if (element.qContainer !== this) {
31194
+ return;
31195
+ }
31196
+ const rootState = element.querySelector(
31197
+ `script[type="qwik/state"][q\\:instance="${this.$instanceHash$}"]:not(${QStatePatchAttrSelector})`
31198
+ ) || element.querySelector(
31199
+ `script[type="qwik/state"]:not([q\\:instance]):not(${QStatePatchAttrSelector})`
31200
+ );
31201
+ if (rootState) {
31202
+ this.$rawStateData$ = JSON.parse(rootState.textContent);
31203
+ yield* preprocessStateIterator(this.$rawStateData$, this);
31204
+ this.$rootForwardRefs$ = this.$forwardRefs$;
31205
+ const rootCount = this.$rawStateData$.length / 2;
31206
+ const statePrewarm = element.getAttribute(QStatePrewarmAttr);
31207
+ if (statePrewarm !== null && rootCount > 0 && rootCount >= Number(statePrewarm)) {
31208
+ this.$stateData$ = yield* eagerDeserializeStateIterator(this, this.$rawStateData$);
31209
+ } else {
31210
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
31211
+ }
31212
+ }
30542
31213
  if (__EXPERIMENTAL__.suspense) {
30543
- processSegmentStateScripts(this);
31214
+ yield* processSegmentStateScriptsIterator(this);
30544
31215
  }
30545
31216
  this.$hoistStyles$();
31217
+ element.setAttribute(QContainerAttr, "resumed" /* RESUMED */);
30546
31218
  if (!qTest && element.isConnected) {
30547
31219
  element.dispatchEvent(new CustomEvent("qresume", { bubbles: true }));
30548
31220
  }
@@ -30562,9 +31234,15 @@ var DomContainer = class extends _SharedContainer {
30562
31234
  }
30563
31235
  el.removeAttribute(QContainerAttr);
30564
31236
  const document2 = el.ownerDocument;
31237
+ this.$containerStateDataState$ = void 0;
31238
+ this.$containerDataProcessState$ = 0 /* NotStarted */;
30565
31239
  const hasContainers = document2.querySelector(QContainerSelector) !== null;
30566
31240
  if (!hasContainers) {
30567
31241
  document2.qVNodeData = void 0;
31242
+ document2.qVNodeDataStarted = void 0;
31243
+ document2.qVNodeDataReady = void 0;
31244
+ document2.qVNodeDataState = void 0;
31245
+ document2.qVNodeDataCallbacks = void 0;
30568
31246
  document2.qVNodeDataProcessed = void 0;
30569
31247
  document2.qProcessVNodeDataPatch = void 0;
30570
31248
  }
@@ -30574,20 +31252,6 @@ var DomContainer = class extends _SharedContainer {
30574
31252
  }
30575
31253
  }
30576
31254
  }
30577
- $processRootStateScript$() {
30578
- const rootState = this.element.querySelector(
30579
- `${this.$stateScriptSelector$()}:not(${QStatePatchAttrSelector})`
30580
- );
30581
- if (rootState) {
30582
- this.$rawStateData$ = JSON.parse(rootState.textContent);
30583
- preprocessState(this.$rawStateData$, this);
30584
- this.$rootForwardRefs$ = this.$forwardRefs$;
30585
- this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
30586
- }
30587
- }
30588
- $stateScriptSelector$() {
30589
- return `script[type="qwik/state"][q\\:instance="${this.$instanceHash$}"]`;
30590
- }
30591
31255
  /**
30592
31256
  * The first time we render we need to hoist the styles. (Meaning we need to move all styles from
30593
31257
  * component inline to <head>)
@@ -30716,7 +31380,7 @@ var DomContainer = class extends _SharedContainer {
30716
31380
  }
30717
31381
  getSyncFn(id) {
30718
31382
  const fn = this.$qFuncs$[id];
30719
- isDev24 && assertTrue(typeof fn === "function", "Invalid reference: " + id);
31383
+ isDev23 && assertTrue(typeof fn === "function", "Invalid reference: " + id);
30720
31384
  return fn;
30721
31385
  }
30722
31386
  $appendStyle$(content, styleId, host, scoped) {
@@ -30795,8 +31459,7 @@ function invokeApply(context, fn, args) {
30795
31459
  _context = previousContext;
30796
31460
  }
30797
31461
  }
30798
- var newInvokeContextFromDOM = (event, element) => {
30799
- const domContainer = getDomContainer(element);
31462
+ var newInvokeContextFromDOM = (event, element, domContainer = getDomContainer(element)) => {
30800
31463
  const hostElement = vnode_locate(domContainer.rootVNode, element);
30801
31464
  const locale = domContainer.$locale$;
30802
31465
  locale && setLocale(locale);
@@ -30868,9 +31531,9 @@ var trackSignalAndAssignHost = (value, host, property, container, data) => {
30868
31531
  };
30869
31532
 
30870
31533
  // packages/qwik/src/core/reactive-primitives/impl/store.ts
30871
- import { isDev as isDev25, isServer as isServer11 } from "@qwik.dev/core/build";
30872
- var DEBUG7 = false;
30873
- var log5 = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
31534
+ import { isDev as isDev24, isServer as isServer11 } from "@qwik.dev/core/build";
31535
+ var DEBUG6 = false;
31536
+ var log4 = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
30874
31537
  var getStoreHandler = (value) => {
30875
31538
  return value[STORE_HANDLER];
30876
31539
  };
@@ -30929,7 +31592,7 @@ var StoreHandler2 = class {
30929
31592
  }
30930
31593
  this.$container$ = ctx.$container$;
30931
31594
  } else {
30932
- isDev25 && assertTrue(
31595
+ isDev24 && assertTrue(
30933
31596
  !ctx.$container$ || isSameContainer(ctx.$container$, this.$container$),
30934
31597
  "Do not use signals across containers"
30935
31598
  );
@@ -30964,11 +31627,11 @@ var StoreHandler2 = class {
30964
31627
  if (prop in target) {
30965
31628
  const oldValue = target[prop];
30966
31629
  if (newValue !== oldValue) {
30967
- DEBUG7 && log5("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
31630
+ DEBUG6 && log4("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
30968
31631
  setNewValueAndTriggerEffects(prop, newValue, target, this);
30969
31632
  }
30970
31633
  } else {
30971
- DEBUG7 && log5("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
31634
+ DEBUG6 && log4("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
30972
31635
  setNewValueAndTriggerEffects(prop, newValue, target, this);
30973
31636
  }
30974
31637
  return true;
@@ -31051,7 +31714,7 @@ function addStoreEffect(target, prop, store, effectSubscription, renderContainer
31051
31714
  }
31052
31715
  addQrlToSerializationCtx(effectSubscription, serializationContainer);
31053
31716
  }
31054
- DEBUG7 && log5(
31717
+ DEBUG6 && log4(
31055
31718
  "sub",
31056
31719
  pad(
31057
31720
  "\n" + [...store.$effects$?.entries() || []].map(([key, value]) => `${String(key)}: ${String(value)}`).join(","),
@@ -31281,9 +31944,9 @@ var NoSerializeSymbol = /* @__PURE__ */ Symbol("noSerialize");
31281
31944
  var SerializerSymbol = /* @__PURE__ */ Symbol("serialize");
31282
31945
 
31283
31946
  // packages/qwik/src/core/reactive-primitives/utils.ts
31284
- import { isBrowser as isBrowser4, isDev as isDev26 } from "@qwik.dev/core/build";
31285
- var DEBUG8 = false;
31286
- var log6 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
31947
+ import { isBrowser as isBrowser4, isDev as isDev25 } from "@qwik.dev/core/build";
31948
+ var DEBUG7 = false;
31949
+ var log5 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
31287
31950
  var throwIfQRLNotResolved = (qrl) => {
31288
31951
  const resolved = qrl.resolved;
31289
31952
  if (!resolved) {
@@ -31328,7 +31991,7 @@ var scheduleEffects = (container, signal, effects) => {
31328
31991
  const scheduleEffect = (effectSubscription) => {
31329
31992
  const consumer = effectSubscription.consumer;
31330
31993
  const property = effectSubscription.property;
31331
- isDev26 && assertDefined(container, "Container must be defined.");
31994
+ isDev25 && assertDefined(container, "Container must be defined.");
31332
31995
  if (isTask(consumer)) {
31333
31996
  consumer.$flags$ |= 4 /* DIRTY */;
31334
31997
  markVNodeDirty(container, consumer.$el$, 1 /* TASKS */);
@@ -31370,7 +32033,7 @@ var scheduleEffects = (container, signal, effects) => {
31370
32033
  scheduleEffect(effectsSnapshot[i2]);
31371
32034
  }
31372
32035
  }
31373
- DEBUG8 && log6("done scheduling");
32036
+ DEBUG7 && log5("done scheduling");
31374
32037
  };
31375
32038
  var isSerializerObj = (obj) => {
31376
32039
  return isObject(obj) && typeof obj[SerializerSymbol] === "function";
@@ -31512,7 +32175,7 @@ var createFastGetter = (propName) => {
31512
32175
 
31513
32176
  // packages/qwik/src/core/client/vnode-utils.ts
31514
32177
  var vnode_newElement = (element, elementName, key = null) => {
31515
- isDev27 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
32178
+ isDev26 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
31516
32179
  const vnode = new ElementVNode(
31517
32180
  key,
31518
32181
  1 /* Element */ | 8 /* Inflated */ | -1 << 12 /* shift */,
@@ -31530,7 +32193,7 @@ var vnode_newElement = (element, elementName, key = null) => {
31530
32193
  return vnode;
31531
32194
  };
31532
32195
  var vnode_newUnMaterializedElement = (element) => {
31533
- isDev27 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
32196
+ isDev26 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
31534
32197
  const vnode = new ElementVNode(
31535
32198
  null,
31536
32199
  1 /* Element */ | -1 << 12 /* shift */,
@@ -31548,7 +32211,7 @@ var vnode_newUnMaterializedElement = (element) => {
31548
32211
  return vnode;
31549
32212
  };
31550
32213
  var vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
31551
- isDev27 && sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
32214
+ isDev26 && sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
31552
32215
  const vnode = new TextVNode(
31553
32216
  4 /* Text */ | -1 << 12 /* shift */,
31554
32217
  // Flag
@@ -31580,10 +32243,10 @@ var vnode_newText = (textNode, textContent) => {
31580
32243
  textContent
31581
32244
  // Text Content
31582
32245
  );
31583
- isDev27 && assertEqual(fastNodeType(textNode), 3, "Expecting text node.");
31584
- isDev27 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
31585
- isDev27 && assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
31586
- isDev27 && assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
32246
+ isDev26 && assertEqual(fastNodeType(textNode), 3, "Expecting text node.");
32247
+ isDev26 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
32248
+ isDev26 && assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
32249
+ isDev26 && assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
31587
32250
  return vnode;
31588
32251
  };
31589
32252
  var vnode_newVirtual = () => {
@@ -31598,9 +32261,9 @@ var vnode_newVirtual = () => {
31598
32261
  null,
31599
32262
  null
31600
32263
  );
31601
- isDev27 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
31602
- isDev27 && assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
31603
- isDev27 && assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
32264
+ isDev26 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
32265
+ isDev26 && assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
32266
+ isDev26 && assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
31604
32267
  return vnode;
31605
32268
  };
31606
32269
  var vnode_isVNode = (vNode) => {
@@ -31610,12 +32273,12 @@ var vnode_isElementVNode = (vNode) => {
31610
32273
  return (vNode.flags & 1 /* Element */) === 1 /* Element */;
31611
32274
  };
31612
32275
  var vnode_isElementOrTextVNode = (vNode) => {
31613
- isDev27 && assertDefined(vNode, "Missing vNode");
32276
+ isDev26 && assertDefined(vNode, "Missing vNode");
31614
32277
  const flag = vNode.flags;
31615
32278
  return (flag & 5 /* ELEMENT_OR_TEXT_MASK */) !== 0;
31616
32279
  };
31617
32280
  var vnode_isMaterialized = (vNode) => {
31618
- isDev27 && assertDefined(vNode, "Missing vNode");
32281
+ isDev26 && assertDefined(vNode, "Missing vNode");
31619
32282
  const flag = vNode.flags;
31620
32283
  return (flag & 1 /* Element */) === 1 /* Element */ && vNode.firstChild !== void 0 && vNode.lastChild !== void 0;
31621
32284
  };
@@ -31626,26 +32289,26 @@ var vnode_isVirtualVNode = (vNode) => {
31626
32289
  return (vNode.flags & 2 /* Virtual */) === 2 /* Virtual */;
31627
32290
  };
31628
32291
  var vnode_isProjection = (vNode) => {
31629
- isDev27 && assertDefined(vNode, "Missing vNode");
32292
+ isDev26 && assertDefined(vNode, "Missing vNode");
31630
32293
  const flag = vNode.flags;
31631
32294
  return (flag & 2 /* Virtual */) === 2 /* Virtual */ && vnode_getProp(vNode, QSlot, null) !== null;
31632
32295
  };
31633
32296
  var ensureTextVNode = (vNode) => {
31634
- isDev27 && assertTrue(
32297
+ isDev26 && assertTrue(
31635
32298
  vnode_isTextVNode(vNode),
31636
32299
  "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)
31637
32300
  );
31638
32301
  return vNode;
31639
32302
  };
31640
32303
  var ensureElementOrVirtualVNode = (vNode) => {
31641
- isDev27 && assertDefined(vNode, "Missing vNode");
31642
- isDev27 && assertTrue(
32304
+ isDev26 && assertDefined(vNode, "Missing vNode");
32305
+ isDev26 && assertTrue(
31643
32306
  (vNode.flags & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0,
31644
32307
  "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode)
31645
32308
  );
31646
32309
  };
31647
32310
  var ensureElementVNode = (vNode) => {
31648
- isDev27 && assertTrue(
32311
+ isDev26 && assertTrue(
31649
32312
  vnode_isElementVNode(vNode),
31650
32313
  "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)
31651
32314
  );
@@ -31886,7 +32549,7 @@ var vnode_ensureTextInflated = (journal, vnode) => {
31886
32549
  const flags = textVNode.flags;
31887
32550
  if ((flags & 8 /* Inflated */) === 0) {
31888
32551
  const parentNode = vnode_getDomParent(vnode, true);
31889
- isDev27 && assertDefined(parentNode, "Missing parent node.");
32552
+ isDev26 && assertDefined(parentNode, "Missing parent node.");
31890
32553
  const sharedTextNode = textVNode.node;
31891
32554
  const doc = fastOwnerDocument(parentNode);
31892
32555
  let vCursor = vnode_getDomSibling(vnode, false, true);
@@ -31936,7 +32599,7 @@ var vnode_locate = (rootVNode, id) => {
31936
32599
  let refElement;
31937
32600
  const localId = typeof id === "string" ? id : "";
31938
32601
  if (typeof id === "string") {
31939
- isDev27 && assertDefined(qVNodeRefs, "Missing qVNodeRefs.");
32602
+ isDev26 && assertDefined(qVNodeRefs, "Missing qVNodeRefs.");
31940
32603
  elementOffset = parseInt(localId);
31941
32604
  refElement = qVNodeRefs.get(elementOffset);
31942
32605
  } else {
@@ -31953,12 +32616,12 @@ var vnode_locate = (rootVNode, id) => {
31953
32616
  return vNode;
31954
32617
  }
31955
32618
  }
31956
- isDev27 && assertDefined(
32619
+ isDev26 && assertDefined(
31957
32620
  refElement,
31958
32621
  "Missing refElement " + (typeof id === "string" ? `for id ${id}` : "")
31959
32622
  );
31960
32623
  if (!vnode_isVNode(refElement)) {
31961
- isDev27 && assertTrue(
32624
+ isDev26 && assertTrue(
31962
32625
  containerElement.contains(refElement),
31963
32626
  `Couldn't find the element inside the container while locating the VNode.`
31964
32627
  );
@@ -32007,10 +32670,10 @@ var vnode_locate = (rootVNode, id) => {
32007
32670
  };
32008
32671
  var vnode_getChildWithIdx = (vNode, childIdx) => {
32009
32672
  let child = vnode_getFirstChild(vNode);
32010
- isDev27 && assertDefined(child, "Missing child.");
32673
+ isDev26 && assertDefined(child, "Missing child.");
32011
32674
  while (child.flags >>> 12 /* shift */ !== childIdx) {
32012
32675
  child = child.nextSibling;
32013
- isDev27 && assertDefined(child, "Missing child.");
32676
+ isDev26 && assertDefined(child, "Missing child.");
32014
32677
  }
32015
32678
  return child;
32016
32679
  };
@@ -32018,7 +32681,7 @@ var vNodeStack = [];
32018
32681
  var vnode_getVNodeForChildNode = (vNode, childElement) => {
32019
32682
  ensureElementVNode(vNode);
32020
32683
  let child = vnode_getFirstChild(vNode);
32021
- isDev27 && assertDefined(child, "Missing child.");
32684
+ isDev26 && assertDefined(child, "Missing child.");
32022
32685
  while (child && (child instanceof ElementVNode ? child.node !== childElement : true)) {
32023
32686
  if (vnode_isVirtualVNode(child)) {
32024
32687
  const next = child.nextSibling;
@@ -32037,13 +32700,13 @@ var vnode_getVNodeForChildNode = (vNode, childElement) => {
32037
32700
  child = next || vNodeStack.pop();
32038
32701
  }
32039
32702
  }
32040
- isDev27 && assertDefined(child, "Missing child.");
32703
+ isDev26 && assertDefined(child, "Missing child.");
32041
32704
  }
32042
32705
  while (vNodeStack.length) {
32043
32706
  vNodeStack.pop();
32044
32707
  }
32045
32708
  ensureElementVNode(child);
32046
- isDev27 && assertEqual(child.node, childElement, "Child not found.");
32709
+ isDev26 && assertEqual(child.node, childElement, "Child not found.");
32047
32710
  return child;
32048
32711
  };
32049
32712
  var indexOfAlphanumeric = (id, length) => {
@@ -32301,7 +32964,7 @@ var vnode_getDomParentVNode = (vnode, includeProjection) => {
32301
32964
  return vnode;
32302
32965
  };
32303
32966
  var vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
32304
- isDev27 && assertEqual(vParent, vToRemove.parent, "Parent mismatch.");
32967
+ isDev26 && assertEqual(vParent, vToRemove.parent, "Parent mismatch.");
32305
32968
  if (vnode_isTextVNode(vToRemove)) {
32306
32969
  vnode_ensureTextInflated(journal, vToRemove);
32307
32970
  }
@@ -32334,7 +32997,7 @@ var vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
32334
32997
  vToRemove.nextSibling = null;
32335
32998
  };
32336
32999
  var vnode_truncate = (journal, vParent, vDelete, removeDOM = true) => {
32337
- isDev27 && assertDefined(vDelete, "Missing vDelete.");
33000
+ isDev26 && assertDefined(vDelete, "Missing vDelete.");
32338
33001
  const parent = vnode_getDomParent(vParent, true);
32339
33002
  if (parent && removeDOM) {
32340
33003
  if (vnode_isElementOrTextVNode(vParent)) {
@@ -32437,8 +33100,8 @@ var ensureMaterialized = (vnode) => {
32437
33100
  vFirstChild = vnode_materialize(vParent);
32438
33101
  }
32439
33102
  }
32440
- isDev27 && assertTrue(vParent.firstChild !== void 0, "Did not materialize.");
32441
- isDev27 && assertTrue(vParent.lastChild !== void 0, "Did not materialize.");
33103
+ isDev26 && assertTrue(vParent.firstChild !== void 0, "Did not materialize.");
33104
+ isDev26 && assertTrue(vParent.lastChild !== void 0, "Did not materialize.");
32442
33105
  return vFirstChild;
32443
33106
  };
32444
33107
  var _fastHasAttribute = null;
@@ -32610,7 +33273,7 @@ var materializeFromDOM = (vParent, firstChild, vData, segmentId) => {
32610
33273
  }
32611
33274
  const id = consumeValue();
32612
33275
  container.$setRawState$(parseInt(id, 10), vParent);
32613
- isDev27 && vnode_setProp(vParent, ELEMENT_ID, id);
33276
+ isDev26 && vnode_setProp(vParent, ELEMENT_ID, id);
32614
33277
  } else if (peek() === VNodeDataChar.BACK_REFS) {
32615
33278
  if (!container) {
32616
33279
  container = getDomContainer(vParent.node);
@@ -32675,8 +33338,17 @@ var processVNodeData2 = (vData, callback) => {
32675
33338
  }
32676
33339
  return vData.substring(start, nextToConsumeIdx);
32677
33340
  };
33341
+ const consumeEncodedValue = () => {
33342
+ if (getChar(nextToConsumeIdx + 1) !== VNodeDataChar.SEPARATOR) {
33343
+ return consumeValue();
33344
+ }
33345
+ consume();
33346
+ const value = decodeURIComponent(decodeVNodeDataString(consumeValue()));
33347
+ consume();
33348
+ return value;
33349
+ };
32678
33350
  while (peek() !== 0) {
32679
- callback(peek, consumeValue, consume, getChar, nextToConsumeIdx);
33351
+ callback(peek, consumeValue, consume, getChar, nextToConsumeIdx, consumeEncodedValue);
32680
33352
  }
32681
33353
  };
32682
33354
  var vnode_getAttrKeys = (container, vnode) => {
@@ -32861,12 +33533,12 @@ function materializeFromVNodeData(vParent, vData, element, child, segmentId) {
32861
33533
  return !nodeIsElement || nodeIsElement && shouldSkipElement(node);
32862
33534
  };
32863
33535
  let components = null;
32864
- processVNodeData2(vData, (peek, consumeValue, consume, getChar, nextToConsumeIdx) => {
33536
+ processVNodeData2(vData, (peek, consumeValue, consume, getChar, dataIdx, consumeEncodedValue) => {
32865
33537
  if (isNumber(peek())) {
32866
33538
  while (shouldSkipNode(child)) {
32867
33539
  child = fastNextSibling(child);
32868
33540
  if (!child) {
32869
- throw qError(27 /* materializeVNodeDataError */, [vData, peek(), nextToConsumeIdx]);
33541
+ throw qError(27 /* materializeVNodeDataError */, [vData, peek(), dataIdx]);
32870
33542
  }
32871
33543
  }
32872
33544
  combinedText = null;
@@ -32887,7 +33559,7 @@ function materializeFromVNodeData(vParent, vData, element, child, segmentId) {
32887
33559
  ) {
32888
33560
  child = fastNextSibling(child);
32889
33561
  if (!child && value > 0) {
32890
- throw qError(27 /* materializeVNodeDataError */, [vData, peek(), nextToConsumeIdx]);
33562
+ throw qError(27 /* materializeVNodeDataError */, [vData, peek(), dataIdx]);
32891
33563
  }
32892
33564
  }
32893
33565
  }
@@ -32902,20 +33574,11 @@ function materializeFromVNodeData(vParent, vData, element, child, segmentId) {
32902
33574
  }
32903
33575
  const id = consumeValue();
32904
33576
  container.$setRawState$(parseInt(id, 10), vParent);
32905
- isDev27 && vnode_setProp(vParent, ELEMENT_ID, id);
33577
+ isDev26 && vnode_setProp(vParent, ELEMENT_ID, id);
32906
33578
  } else if (peek() === VNodeDataChar.PROPS) {
32907
33579
  vnode_setProp(vParent, ELEMENT_PROPS, consumeValue());
32908
33580
  } else if (peek() === VNodeDataChar.KEY) {
32909
- const isEscapedValue = getChar(nextToConsumeIdx + 1) === VNodeDataChar.SEPARATOR;
32910
- let value;
32911
- if (isEscapedValue) {
32912
- consume();
32913
- value = decodeURIComponent(decodeVNodeDataString(consumeValue()));
32914
- consume();
32915
- } else {
32916
- value = consumeValue();
32917
- }
32918
- vParent.key = value;
33581
+ vParent.key = consumeEncodedValue();
32919
33582
  } else if (peek() === VNodeDataChar.SEQ) {
32920
33583
  vnode_setProp(vParent, ELEMENT_SEQ, consumeValue());
32921
33584
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
@@ -32942,7 +33605,7 @@ function materializeFromVNodeData(vParent, vData, element, child, segmentId) {
32942
33605
  } else if (peek() === VNodeDataChar.SEPARATOR) {
32943
33606
  const keyValue = consumeValue();
32944
33607
  const key = decodeVNodeDataString(keyValue);
32945
- const valueSeparatorIdx = nextToConsumeIdx + keyValue.length + 1;
33608
+ const valueSeparatorIdx = dataIdx + keyValue.length + 1;
32946
33609
  const isEscapedValue = getChar(valueSeparatorIdx + 1) === VNodeDataChar.SEPARATOR;
32947
33610
  let value;
32948
33611
  if (isEscapedValue) {
@@ -32962,8 +33625,7 @@ function materializeFromVNodeData(vParent, vData, element, child, segmentId) {
32962
33625
  vFirst = stack.pop();
32963
33626
  vParent = stack.pop();
32964
33627
  } else if (peek() === VNodeDataChar.SLOT) {
32965
- const value = decodeVNodeDataString(consumeValue());
32966
- vnode_setProp(vParent, QSlot, value);
33628
+ vnode_setProp(vParent, QSlot, consumeEncodedValue());
32967
33629
  } else {
32968
33630
  while (isElement(child) && shouldSkipElement(child)) {
32969
33631
  child = fastNextSibling(child);
@@ -34536,7 +35198,7 @@ import {
34536
35198
  _vnode_toString
34537
35199
  } from "@qwik.dev/core/internal";
34538
35200
  import { expect as expect2 } from "vitest";
34539
- import { _dumpState, _preprocessState as preprocessState2 } from "@qwik.dev/core/internal";
35201
+ import { _dumpState, _preprocessState as preprocessState } from "@qwik.dev/core/internal";
34540
35202
  import { useContextProvider } from "../core.mjs";
34541
35203
 
34542
35204
  // packages/qwik/src/core/preloader/bundle-graph.ts
@@ -34579,7 +35241,7 @@ import { getClientManifest } from "../core.mjs";
34579
35241
 
34580
35242
  // packages/qwik/src/server/platform.ts
34581
35243
  import { setPlatform } from "../core.mjs";
34582
- import { isDev as isDev28 } from "@qwik.dev/core/build";
35244
+ import { isDev as isDev27 } from "@qwik.dev/core/build";
34583
35245
  var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
34584
35246
  const existing = mapper?.[hash];
34585
35247
  if (existing) {
@@ -34601,9 +35263,9 @@ var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
34601
35263
  function createPlatform3(opts, resolvedManifest) {
34602
35264
  const mapper = resolvedManifest?.mapper;
34603
35265
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
34604
- if (mapper || isDev28 && import.meta.env?.MODE !== "test") {
35266
+ if (mapper || isDev27 && import.meta.env?.MODE !== "test") {
34605
35267
  const hash = getSymbolHash2(symbolName);
34606
- const result = !isDev28 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
35268
+ const result = !isDev27 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
34607
35269
  if (!result) {
34608
35270
  if (hash === SYNC_QRL) {
34609
35271
  return [hash, ""];
@@ -34650,7 +35312,7 @@ var getSymbolHash2 = (symbolName) => {
34650
35312
  };
34651
35313
 
34652
35314
  // packages/qwik/src/server/ssr-container.ts
34653
- import { isDev as isDev30 } from "@qwik.dev/core/build";
35315
+ import { isDev as isDev29 } from "@qwik.dev/core/build";
34654
35316
  import {
34655
35317
  _SubscriptionData as SubscriptionData2,
34656
35318
  _SharedContainer as _SharedContainer2,
@@ -34915,7 +35577,7 @@ import {
34915
35577
  _EMPTY_OBJ,
34916
35578
  _EFFECT_BACK_REF as _EFFECT_BACK_REF2
34917
35579
  } from "@qwik.dev/core/internal";
34918
- import { isDev as isDev29 } from "@qwik.dev/core/build";
35580
+ import { isDev as isDev28 } from "@qwik.dev/core/build";
34919
35581
  var SsrNode = class {
34920
35582
  constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
34921
35583
  this.parentComponent = parentComponent;
@@ -34940,7 +35602,7 @@ var SsrNode = class {
34940
35602
  this.flags = 1 /* Updatable */;
34941
35603
  this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
34942
35604
  this.parentComponent?.addChild(this);
34943
- if (isDev29 && id.indexOf("undefined") != -1) {
35605
+ if (isDev28 && id.indexOf("undefined") != -1) {
34944
35606
  throw new Error(`Invalid SSR node id: ${id}`);
34945
35607
  }
34946
35608
  }
@@ -35005,7 +35667,7 @@ var SsrNode = class {
35005
35667
  }
35006
35668
  }
35007
35669
  toString() {
35008
- if (isDev29) {
35670
+ if (isDev28) {
35009
35671
  let stringifiedAttrs = "";
35010
35672
  for (const key in this.attrs) {
35011
35673
  const value = this.attrs[key];
@@ -35098,6 +35760,10 @@ var renderSSRChunks = (chunks, remap) => {
35098
35760
  const chunk = chunks[i2];
35099
35761
  if (typeof chunk === "string") {
35100
35762
  out += chunk;
35763
+ } else if (chunk.type === "root-ref-delta") {
35764
+ const id = remap ? remap[chunk.localId] ?? chunk.localId : chunk.localId;
35765
+ const base2 = remap ? remap[chunk.localBaseId] ?? chunk.localBaseId : chunk.localBaseId;
35766
+ out += String(id - base2);
35101
35767
  } else {
35102
35768
  const localId = chunk.type === "root-ref" ? chunk.localId : chunk.localPath[0];
35103
35769
  out += String(remap ? remap[localId] ?? localId : localId);
@@ -35125,6 +35791,9 @@ var StringSSRWriter = class {
35125
35791
  writeRootRefPath(path) {
35126
35792
  writeStringRootRefPath(this, path);
35127
35793
  }
35794
+ writeRootRefDelta(id, base2) {
35795
+ writeStringRootRefDelta(this, id, base2);
35796
+ }
35128
35797
  clear() {
35129
35798
  this.buffer.length = 0;
35130
35799
  }
@@ -35145,6 +35814,9 @@ var StringBufferSegmentWriter = class {
35145
35814
  writeRootRefPath(path) {
35146
35815
  this.chunks.push({ type: "root-ref-path", localPath: path });
35147
35816
  }
35817
+ writeRootRefDelta(id, base2) {
35818
+ this.chunks.push({ type: "root-ref-delta", localId: id, localBaseId: base2 });
35819
+ }
35148
35820
  clear() {
35149
35821
  this.chunks.length = 0;
35150
35822
  }
@@ -35284,6 +35956,7 @@ function encodeAsAlphanumeric(value) {
35284
35956
  }
35285
35957
 
35286
35958
  // packages/qwik/src/server/ssr-container.ts
35959
+ var VALID_ELEMENT_NAME = /^[A-Za-z][A-Za-z0-9._:-]*$/;
35287
35960
  var NO_SCRIPT_HERE_ELEMENTS = /* @__PURE__ */ new Set([
35288
35961
  "script",
35289
35962
  "style",
@@ -35669,11 +36342,17 @@ var SSRContainer = class extends _SharedContainer2 {
35669
36342
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
35670
36343
  containerAttributes[QRuntimeAttr] = "2";
35671
36344
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
35672
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev30 ? "ssr-dev" : "ssr");
36345
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev29 ? "ssr-dev" : "ssr");
35673
36346
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
35674
36347
  containerAttributes[QLocaleAttr] = this.$locale$;
35675
36348
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
35676
36349
  containerAttributes[QInstanceAttr] = this.$instanceHash$;
36350
+ const statePrewarm = this.renderOptions.statePrewarm;
36351
+ if (typeof statePrewarm === "number") {
36352
+ containerAttributes[QStatePrewarmAttr] = String(statePrewarm);
36353
+ } else {
36354
+ delete containerAttributes[QStatePrewarmAttr];
36355
+ }
35677
36356
  this.$serverData$.containerAttributes = containerAttributes;
35678
36357
  this.openElement(this.tag, null, containerAttributes);
35679
36358
  if (!this.isHtml) {
@@ -35686,6 +36365,9 @@ var SSRContainer = class extends _SharedContainer2 {
35686
36365
  }
35687
36366
  /** Renders opening tag for DOM element */
35688
36367
  openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
36368
+ if (!VALID_ELEMENT_NAME.test(elementName)) {
36369
+ throw qError(36 /* invalidElementName */, [JSON.stringify(elementName)]);
36370
+ }
35689
36371
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
35690
36372
  if (NO_SCRIPT_HERE_ELEMENTS.has(elementName)) {
35691
36373
  this.$noScriptHere$++;
@@ -35724,7 +36406,9 @@ var SSRContainer = class extends _SharedContainer2 {
35724
36406
  }
35725
36407
  this.write(" " + Q_PROPS_SEPARATOR);
35726
36408
  if (key !== null) {
35727
- this.write(`="${key}"`);
36409
+ this.write(ATTR_EQUALS_QUOTE);
36410
+ this.write(escapeHTML(key));
36411
+ this.write(QUOTE);
35728
36412
  } else if (qTest) {
35729
36413
  this.write(EMPTY_ATTR);
35730
36414
  }
@@ -35866,7 +36550,7 @@ var SSRContainer = class extends _SharedContainer2 {
35866
36550
  this.markVNodeRefForSerialization(componentFrame.componentNode);
35867
36551
  }
35868
36552
  this.openFragment(
35869
- isDev30 ? {
36553
+ isDev29 ? {
35870
36554
  [DEBUG_TYPE]: "P" /* Projection */,
35871
36555
  [QSlotParent]: componentFrame.componentNode.id,
35872
36556
  [QSlot]: slotName
@@ -35995,7 +36679,7 @@ var SSRContainer = class extends _SharedContainer2 {
35995
36679
  emitRestStateData() {
35996
36680
  this.emitVNodeData();
35997
36681
  this.emitDelayedOutOfOrderSegmentVNodeData();
35998
- if (!isDev30) {
36682
+ if (!isDev29) {
35999
36683
  preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
36000
36684
  }
36001
36685
  this.emitSyncFnsData();
@@ -36197,6 +36881,7 @@ var SSRContainer = class extends _SharedContainer2 {
36197
36881
  this.write(VNodeDataChar.CONTEXT_CHAR);
36198
36882
  break;
36199
36883
  case QSlot:
36884
+ encodeValue = encodeVNodeDataKey;
36200
36885
  this.write(VNodeDataChar.SLOT_CHAR);
36201
36886
  break;
36202
36887
  default: {
@@ -36220,7 +36905,7 @@ var SSRContainer = class extends _SharedContainer2 {
36220
36905
  }
36221
36906
  }
36222
36907
  emitStateData() {
36223
- if (!this.serializationCtx.$roots$.length) {
36908
+ if (!this.serializationCtx.$roots$.length && !this.serializationCtx.$eagerResume$.size) {
36224
36909
  return;
36225
36910
  }
36226
36911
  const attrs = this.stateScriptAttrs();
@@ -36287,7 +36972,7 @@ var SSRContainer = class extends _SharedContainer2 {
36287
36972
  if (this.renderOptions.serverData?.nonce) {
36288
36973
  scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
36289
36974
  }
36290
- this.writeScript(scriptAttrs, JSON.stringify(patches));
36975
+ this.writeScript(scriptAttrs, JSON.stringify(patches).replaceAll("<", "\\u003C"));
36291
36976
  }
36292
36977
  }
36293
36978
  emitBackpatchDataAndExecutorIfNeeded() {
@@ -36306,7 +36991,7 @@ var SSRContainer = class extends _SharedContainer2 {
36306
36991
  if (this.renderOptions.serverData?.nonce) {
36307
36992
  scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
36308
36993
  }
36309
- const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev30 });
36994
+ const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev29 });
36310
36995
  this.writeScript(scriptAttrs, backpatchScript);
36311
36996
  }
36312
36997
  emitOutOfOrderExecutorIfNeeded() {
@@ -36316,7 +37001,7 @@ var SSRContainer = class extends _SharedContainer2 {
36316
37001
  this.isOutOfOrderExecutorEmitted = true;
36317
37002
  this.writeScript(
36318
37003
  { type: "text/javascript", nonce: this.renderOptions.serverData?.nonce },
36319
- getQwikOutOfOrderExecutorScript({ debug: isDev30 })
37004
+ getQwikOutOfOrderExecutorScript({ debug: isDev29 })
36320
37005
  );
36321
37006
  }
36322
37007
  emitInlineScript(script) {
@@ -36342,7 +37027,7 @@ var SSRContainer = class extends _SharedContainer2 {
36342
37027
  this.write("</script>");
36343
37028
  }
36344
37029
  emitPreloaderPre() {
36345
- if (!isDev30) {
37030
+ if (!isDev29) {
36346
37031
  preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
36347
37032
  }
36348
37033
  }
@@ -36447,7 +37132,7 @@ var SSRContainer = class extends _SharedContainer2 {
36447
37132
  }
36448
37133
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
36449
37134
  let tagNesting = 10 /* ANYTHING */;
36450
- if (isDev30) {
37135
+ if (isDev29) {
36451
37136
  if (!this.currentElementFrame) {
36452
37137
  tagNesting = initialTag(elementName);
36453
37138
  } else {
@@ -36494,7 +37179,7 @@ var SSRContainer = class extends _SharedContainer2 {
36494
37179
  elementName,
36495
37180
  depthFirstElementIdx,
36496
37181
  vNodeData: [0 /* NONE */],
36497
- currentFile: isDev30 ? currentFile || null : null,
37182
+ currentFile: isDev29 ? currentFile || null : null,
36498
37183
  refBase: null
36499
37184
  };
36500
37185
  this.currentElementFrame = frame;
@@ -36521,6 +37206,11 @@ var SSRContainer = class extends _SharedContainer2 {
36521
37206
  this.size += 1 + String(path[i2]).length;
36522
37207
  }
36523
37208
  }
37209
+ writeRootRefDelta(id, base2) {
37210
+ const delta = id - base2;
37211
+ this.size += String(delta).length;
37212
+ this.writer.writeRootRefDelta(id, base2);
37213
+ }
36524
37214
  writeArray(array, separator) {
36525
37215
  for (let i2 = 0; i2 < array.length; i2++) {
36526
37216
  const element = array[i2];
@@ -36535,7 +37225,7 @@ var SSRContainer = class extends _SharedContainer2 {
36535
37225
  for (let key in attrs) {
36536
37226
  let value = attrs[key];
36537
37227
  if (isSSRUnsafeAttr(key)) {
36538
- if (isDev30) {
37228
+ if (isDev29) {
36539
37229
  throw qError(32 /* unsafeAttr */, [key]);
36540
37230
  }
36541
37231
  continue;
@@ -36598,7 +37288,7 @@ var SSRContainer = class extends _SharedContainer2 {
36598
37288
  }
36599
37289
  if (tag === "textarea" && key === "value") {
36600
37290
  if (value && typeof value !== "string") {
36601
- if (isDev30) {
37291
+ if (isDev29) {
36602
37292
  throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
36603
37293
  }
36604
37294
  continue;
@@ -36632,6 +37322,8 @@ var SSRContainer = class extends _SharedContainer2 {
36632
37322
  this.write(escapeHTML(chunk));
36633
37323
  } else if (typeof chunk === "number") {
36634
37324
  this.writeRootRef(chunk);
37325
+ } else if ("base" in chunk) {
37326
+ this.writeRootRefDelta(chunk.id, chunk.base);
36635
37327
  } else {
36636
37328
  this.writeRootRefPath(chunk.path);
36637
37329
  }
@@ -37265,7 +37957,8 @@ async function ssrRenderToDom(jsx2, opts = {}) {
37265
37957
  ];
37266
37958
  const renderOptions = {
37267
37959
  containerTagName: opts.containerTagName,
37268
- qwikLoader: opts.qwikLoader ? "inline" : "never"
37960
+ qwikLoader: opts.qwikLoader ? "inline" : "never",
37961
+ statePrewarm: opts.statePrewarm
37269
37962
  };
37270
37963
  if (opts.stream || opts.streaming) {
37271
37964
  const stream = {
@@ -37307,6 +38000,7 @@ async function ssrRenderToDom(jsx2, opts = {}) {
37307
38000
  if (!isStreaming) {
37308
38001
  emulateExecutionOfOutOfOrderScripts(document2);
37309
38002
  }
38003
+ await whenContainerDataReady(container, () => void 0);
37310
38004
  if (opts.debug) {
37311
38005
  console.log("========================================================");
37312
38006
  console.log("------------------------- SSR --------------------------");
@@ -37362,12 +38056,12 @@ async function ssrRenderToDom(jsx2, opts = {}) {
37362
38056
  return { container, document: document2, vNode, getStyles };
37363
38057
  }
37364
38058
  function getDebugSerializedState(container) {
37365
- const stateScriptSelector2 = `script[type="qwik/state"][q\\:instance="${container.$instanceHash$}"]`;
38059
+ const stateScriptSelector = `script[type="qwik/state"][q\\:instance="${container.$instanceHash$}"]`;
37366
38060
  const rootStateScript = container.element.querySelector(
37367
- `${stateScriptSelector2}:not(${QStatePatchAttrSelector})`
38061
+ `${stateScriptSelector}:not(${QStatePatchAttrSelector})`
37368
38062
  );
37369
38063
  const patchStateScripts = container.element.querySelectorAll(
37370
- `${stateScriptSelector2}${QStatePatchAttrSelector}`
38064
+ `${stateScriptSelector}${QStatePatchAttrSelector}`
37371
38065
  );
37372
38066
  if (!rootStateScript && patchStateScripts.length === 0) {
37373
38067
  return null;
@@ -37388,7 +38082,7 @@ function getDebugSerializedState(container) {
37388
38082
  }
37389
38083
  }
37390
38084
  const debugContainer = { $forwardRefs$: null };
37391
- preprocessState2(state, debugContainer);
38085
+ preprocessState(state, debugContainer);
37392
38086
  for (let i2 = 0; i2 < patchForwardRefs.length; i2++) {
37393
38087
  const rootForwardRefs = debugContainer.$forwardRefs$ || (debugContainer.$forwardRefs$ = []);
37394
38088
  const forwardRefs = patchForwardRefs[i2];
@@ -37487,6 +38181,7 @@ function renderStyles(getStyles) {
37487
38181
  }
37488
38182
  async function rerenderComponent(element) {
37489
38183
  const container = _getDomContainer2(element);
38184
+ await whenContainerDataReady(container, () => void 0);
37490
38185
  const vElement = container.vNodeLocate(element);
37491
38186
  const host = getHostVNode(vElement);
37492
38187
  markVNodeDirty(container, host, 4 /* COMPONENT */);