@qwik.dev/core 2.0.0-beta.23 → 2.0.0-beta.25

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.23-dev+03de42d
3
+ * @qwik.dev/core/testing 2.0.0-beta.25-dev+2677279
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
@@ -23645,7 +23645,10 @@ import { _isJSXNode, _isStringifiable } from "@qwik.dev/core/internal";
23645
23645
  import { expect } from "vitest";
23646
23646
 
23647
23647
  // packages/qwik/src/core/client/vnode-utils.ts
23648
- import { isDev as isDev23 } from "@qwik.dev/core/build";
23648
+ import { isDev as isDev24 } from "@qwik.dev/core/build";
23649
+
23650
+ // packages/qwik/src/core/shared/error/assert.ts
23651
+ import { isDev } from "@qwik.dev/core/build";
23649
23652
 
23650
23653
  // packages/qwik/src/core/shared/utils/qdev.ts
23651
23654
  var qDev = globalThis.qDev !== false;
@@ -23702,7 +23705,7 @@ var createAndLogError = (asyncThrow, message, ...optionalParams) => {
23702
23705
  // packages/qwik/src/core/shared/error/assert.ts
23703
23706
  var ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
23704
23707
  function assertDefined(value, text, ...parts) {
23705
- if (qDev) {
23708
+ if (isDev) {
23706
23709
  if (value != null) {
23707
23710
  return;
23708
23711
  }
@@ -23710,7 +23713,7 @@ function assertDefined(value, text, ...parts) {
23710
23713
  }
23711
23714
  }
23712
23715
  function assertEqual(value1, value2, text, ...parts) {
23713
- if (qDev) {
23716
+ if (isDev) {
23714
23717
  if (value1 === value2) {
23715
23718
  return;
23716
23719
  }
@@ -23718,7 +23721,7 @@ function assertEqual(value1, value2, text, ...parts) {
23718
23721
  }
23719
23722
  }
23720
23723
  function assertTrue(value1, text, ...parts) {
23721
- if (qDev) {
23724
+ if (isDev) {
23722
23725
  if (value1 === true) {
23723
23726
  return;
23724
23727
  }
@@ -23726,7 +23729,7 @@ function assertTrue(value1, text, ...parts) {
23726
23729
  }
23727
23730
  }
23728
23731
  function assertFalse(value1, text, ...parts) {
23729
- if (qDev) {
23732
+ if (isDev) {
23730
23733
  if (value1 === false) {
23731
23734
  return;
23732
23735
  }
@@ -23734,7 +23737,7 @@ function assertFalse(value1, text, ...parts) {
23734
23737
  }
23735
23738
  }
23736
23739
  function assertNumber(value1, text, ...parts) {
23737
- if (qDev) {
23740
+ if (isDev) {
23738
23741
  if (typeof value1 === "number") {
23739
23742
  return;
23740
23743
  }
@@ -23834,7 +23837,12 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
23834
23837
  // 28
23835
23838
  "useComputed$ QRL {{0}} {{1}} cannot return a Promise",
23836
23839
  // 29
23837
- "ComputedSignal is read-only",
23840
+ `===
23841
+ Qwik version {{0}} already imported while importing {{1}}.
23842
+ This can lead to issues due to duplicated shared structures.
23843
+ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude".
23844
+ ===
23845
+ `,
23838
23846
  // 30
23839
23847
  "WrappedSignal is read-only",
23840
23848
  // 31
@@ -23857,7 +23865,7 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
23857
23865
  }
23858
23866
  return `Code(Q${code2}): ${text}`;
23859
23867
  } else {
23860
- return `Code(Q${code2}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code2}`;
23868
+ return `Code(Q${code2}) https://github.com/QwikDev/qwik/blob/build/v2/packages/qwik/src/core/shared/error/error.ts#${parts.join()}L${9 + code2}`;
23861
23869
  }
23862
23870
  };
23863
23871
  var qError = (code2, errorMessageArgs = []) => {
@@ -23866,7 +23874,7 @@ var qError = (code2, errorMessageArgs = []) => {
23866
23874
  };
23867
23875
 
23868
23876
  // packages/qwik/src/core/shared/qrl/qrl-utils.ts
23869
- import { isDev } from "@qwik.dev/core/build";
23877
+ import { isDev as isDev2 } from "@qwik.dev/core/build";
23870
23878
  var SYNC_QRL = "<sync>";
23871
23879
  var isSyncQrl = (value) => {
23872
23880
  return isQrl(value) && value.$symbol$ == SYNC_QRL;
@@ -23875,7 +23883,7 @@ var isQrl = (value) => {
23875
23883
  return typeof value === "function" && typeof value.getSymbol === "function";
23876
23884
  };
23877
23885
  function assertQrl(qrl) {
23878
- if (isDev) {
23886
+ if (isDev2) {
23879
23887
  if (!isQrl(qrl)) {
23880
23888
  throw new Error("Not a QRL");
23881
23889
  }
@@ -23981,9 +23989,6 @@ var NON_SERIALIZABLE_MARKER_PREFIX = ":";
23981
23989
  var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
23982
23990
  var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
23983
23991
  var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
23984
- var FLUSH_COMMENT = "qkssr-f";
23985
- var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
23986
- var STREAM_BLOCK_END_COMMENT = "qkssr-po";
23987
23992
  var Q_PROPS_SEPARATOR = ":";
23988
23993
  var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
23989
23994
  var debugStyleScopeIdPrefixAttr = "__scopedStyleIdPrefix__";
@@ -24055,7 +24060,7 @@ var isText = (value) => {
24055
24060
  };
24056
24061
 
24057
24062
  // packages/qwik/src/core/shared/utils/promises.ts
24058
- import { isDev as isDev2, isServer as isServer2 } from "@qwik.dev/core/build";
24063
+ import { isDev as isDev3, isServer as isServer2 } from "@qwik.dev/core/build";
24059
24064
  var MAX_RETRY_ON_PROMISE_COUNT = 100;
24060
24065
  var isPromise = (value) => {
24061
24066
  return !!value && typeof value == "object" && typeof value.then === "function";
@@ -24096,7 +24101,7 @@ function retryOnPromise(fn, onError = justThrow) {
24096
24101
  if (ok) {
24097
24102
  return result2;
24098
24103
  }
24099
- isDev2 && checkError(result2);
24104
+ isDev3 && checkError(result2);
24100
24105
  return onError(result2);
24101
24106
  }
24102
24107
  let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
@@ -24119,17 +24124,17 @@ function retryOnPromise(fn, onError = justThrow) {
24119
24124
  }
24120
24125
  }
24121
24126
  }
24122
- isDev2 && checkError(p);
24127
+ isDev3 && checkError(p);
24123
24128
  return onError(p);
24124
24129
  };
24125
24130
  return ok ? result2.catch(retry) : retry(result2);
24126
24131
  }
24127
24132
 
24128
24133
  // packages/qwik/src/core/use/use-core.ts
24129
- import { isDev as isDev19 } from "@qwik.dev/core/build";
24134
+ import { isDev as isDev20 } from "@qwik.dev/core/build";
24130
24135
 
24131
24136
  // packages/qwik/src/core/client/dom-container.ts
24132
- import { isDev as isDev18 } from "@qwik.dev/core/build";
24137
+ import { isDev as isDev19 } from "@qwik.dev/core/build";
24133
24138
 
24134
24139
  // packages/qwik/src/core/use/use-sequential-scope.ts
24135
24140
  var useSequentialScope = () => {
@@ -24217,9 +24222,9 @@ var fromCamelToKebabCase = (text) => {
24217
24222
  };
24218
24223
 
24219
24224
  // packages/qwik/src/core/use/use-context.ts
24220
- import { isDev as isDev3 } from "@qwik.dev/core/build";
24225
+ import { isDev as isDev4 } from "@qwik.dev/core/build";
24221
24226
  var createContextId = (name) => {
24222
- isDev3 && assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9,_,.,-", name);
24227
+ isDev4 && assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9,_,.,-", name);
24223
24228
  return /* @__PURE__ */ Object.freeze({
24224
24229
  id: fromCamelToKebabCase(name)
24225
24230
  });
@@ -24283,7 +24288,7 @@ Object.freeze(EMPTY_ARRAY);
24283
24288
  Object.freeze(EMPTY_OBJ);
24284
24289
 
24285
24290
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
24286
- import { isBrowser as isBrowser2, isDev as isDev17 } from "@qwik.dev/core/build";
24291
+ import { isBrowser as isBrowser2, isDev as isDev18 } from "@qwik.dev/core/build";
24287
24292
  import { p as preload } from "@qwik.dev/core/preloader";
24288
24293
 
24289
24294
  // packages/qwik/src/core/reactive-primitives/backref.ts
@@ -24297,7 +24302,7 @@ var BackRef = class {
24297
24302
  };
24298
24303
 
24299
24304
  // packages/qwik/src/core/shared/vnode/vnode.ts
24300
- import { isDev as isDev4 } from "@qwik.dev/core/build";
24305
+ import { isDev as isDev5 } from "@qwik.dev/core/build";
24301
24306
  var _a2;
24302
24307
  _a2 = _EFFECT_BACK_REF;
24303
24308
  var VNode = class {
@@ -24315,7 +24320,7 @@ var VNode = class {
24315
24320
  }
24316
24321
  // TODO: this creates debug issues
24317
24322
  toString() {
24318
- if (isDev4) {
24323
+ if (isDev5) {
24319
24324
  return vnode_toString.call(this);
24320
24325
  }
24321
24326
  return Object.prototype.toString.call(this);
@@ -24341,14 +24346,17 @@ var ElementVNode = class extends VirtualVNode {
24341
24346
  }
24342
24347
  };
24343
24348
 
24349
+ // packages/qwik/src/core/shared/serdes/inflate.ts
24350
+ import { isServer as isServer9 } from "@qwik.dev/core/build";
24351
+
24344
24352
  // packages/qwik/src/core/shared/serdes/qrl-to-string.ts
24345
- import { isDev as isDev5 } from "@qwik.dev/core/build";
24353
+ import { isDev as isDev6 } from "@qwik.dev/core/build";
24346
24354
  function qrlToString(serializationContext, qrl, raw) {
24347
24355
  let symbol = qrl.$symbol$;
24348
24356
  let chunk = qrl.$chunk$;
24349
24357
  const platform = getPlatform();
24350
24358
  if (platform) {
24351
- const result2 = isDev5 ? platform.chunkForSymbol(symbol, chunk, qrl.dev?.file) : platform.chunkForSymbol(symbol, chunk);
24359
+ const result2 = isDev6 ? platform.chunkForSymbol(symbol, chunk, qrl.dev?.file) : platform.chunkForSymbol(symbol, chunk);
24352
24360
  if (result2) {
24353
24361
  chunk = result2[1];
24354
24362
  symbol = result2[0];
@@ -24359,7 +24367,7 @@ function qrlToString(serializationContext, qrl, raw) {
24359
24367
  if (!chunk) {
24360
24368
  chunk = serializationContext.$symbolToChunkResolver$(qrl.$hash$);
24361
24369
  }
24362
- if (isDev5) {
24370
+ if (isDev6) {
24363
24371
  const backChannel = globalThis.__qrl_back_channel__ || (globalThis.__qrl_back_channel__ = /* @__PURE__ */ new Map());
24364
24372
  backChannel.set(qrl.$symbol$, qrl.$symbolRef$);
24365
24373
  if (!chunk) {
@@ -24393,9 +24401,9 @@ function qrlToString(serializationContext, qrl, raw) {
24393
24401
  }
24394
24402
  function createQRLWithBackChannel(chunk, symbol, captures) {
24395
24403
  let qrlImporter = null;
24396
- if (isDev5 && chunk === QRL_RUNTIME_CHUNK) {
24404
+ if (isDev6 && chunk === QRL_RUNTIME_CHUNK) {
24397
24405
  const backChannel = globalThis.__qrl_back_channel__;
24398
- isDev5 && assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
24406
+ isDev6 && assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
24399
24407
  const fn = backChannel.get(symbol);
24400
24408
  if (fn) {
24401
24409
  qrlImporter = () => Promise.resolve({ [symbol]: fn });
@@ -24443,9 +24451,9 @@ function runEventHandlerQRL(handler, event, element, ctx = newInvokeContextFromD
24443
24451
  }
24444
24452
 
24445
24453
  // packages/qwik/src/core/client/util-mapArray.ts
24446
- import { isDev as isDev6 } from "@qwik.dev/core/build";
24454
+ import { isDev as isDev7 } from "@qwik.dev/core/build";
24447
24455
  var mapApp_findIndx = (array, key, start) => {
24448
- isDev6 && assertTrue(start % 2 === 0, "Expecting even number.");
24456
+ isDev7 && assertTrue(start % 2 === 0, "Expecting even number.");
24449
24457
  let bottom = start >> 1;
24450
24458
  let top = array.length - 2 >> 1;
24451
24459
  while (bottom <= top) {
@@ -24497,7 +24505,7 @@ var mapArray_has = (array, key, start) => {
24497
24505
  };
24498
24506
 
24499
24507
  // packages/qwik/src/core/reactive-primitives/impl/signal-impl.ts
24500
- import { isDev as isDev7, isServer as isServer3 } from "@qwik.dev/core/build";
24508
+ import { isDev as isDev8, isServer as isServer3 } from "@qwik.dev/core/build";
24501
24509
  var DEBUG = false;
24502
24510
  var log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
24503
24511
  var SignalImpl = class {
@@ -24512,16 +24520,20 @@ var SignalImpl = class {
24512
24520
  DEBUG && log("new", this);
24513
24521
  }
24514
24522
  /**
24515
- * Use this to force running subscribers, for example when the calculated value has mutated but
24523
+ * Use this to trigger running subscribers, for example when the calculated value has mutated but
24516
24524
  * remained the same object
24517
24525
  */
24526
+ trigger() {
24527
+ scheduleEffects(this.$container$, this, this.$effects$);
24528
+ }
24529
+ /** @deprecated Use `trigger()` instead */
24518
24530
  force() {
24519
24531
  scheduleEffects(this.$container$, this, this.$effects$);
24520
24532
  }
24533
+ // We need this to be getter/setter so subclasses can override them
24521
24534
  get untrackedValue() {
24522
24535
  return this.$untrackedValue$;
24523
24536
  }
24524
- // TODO: should we disallow setting the value directly?
24525
24537
  set untrackedValue(value) {
24526
24538
  this.$untrackedValue$ = value;
24527
24539
  }
@@ -24535,7 +24547,7 @@ var SignalImpl = class {
24535
24547
  if (this.$container$ === null) {
24536
24548
  this.$container$ = ctx.$container$;
24537
24549
  } else {
24538
- isDev7 && assertTrue(
24550
+ isDev8 && assertTrue(
24539
24551
  !ctx.$container$ || ctx.$container$ === this.$container$,
24540
24552
  "Do not use signals across containers"
24541
24553
  );
@@ -24572,7 +24584,7 @@ var SignalImpl = class {
24572
24584
  }
24573
24585
  }
24574
24586
  toString() {
24575
- if (isDev7) {
24587
+ if (isDev8) {
24576
24588
  try {
24577
24589
  return `[${this.constructor.name}${this.$flags$ & 1 /* INVALID */ ? " INVALID" : ""} ${this.$untrackedValue$}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e.consumer), " ")).join("\n") || "");
24578
24590
  } catch (e) {
@@ -24589,7 +24601,7 @@ var SignalImpl = class {
24589
24601
  var setupSignalValueAccess = (target, effectsProp, valueProp) => {
24590
24602
  const ctx = tryGetInvokeContext();
24591
24603
  if (ctx && (target.$container$ || (target.$container$ = ctx.$container$ || null))) {
24592
- isDev7 && assertTrue(
24604
+ isDev8 && assertTrue(
24593
24605
  !ctx.$container$ || ctx.$container$ === target.$container$,
24594
24606
  "Do not use signals across containers"
24595
24607
  );
@@ -24608,7 +24620,7 @@ var setupSignalValueAccess = (target, effectsProp, valueProp) => {
24608
24620
  };
24609
24621
 
24610
24622
  // packages/qwik/src/core/shared/jsx/props-proxy.ts
24611
- import { isDev as isDev8 } from "@qwik.dev/core/build";
24623
+ import { isDev as isDev9 } from "@qwik.dev/core/build";
24612
24624
  function createPropsProxy(owner) {
24613
24625
  return new Proxy({}, new PropsProxyHandler(owner));
24614
24626
  }
@@ -24741,7 +24753,7 @@ var addPropsProxyEffect = (propsProxy, prop) => {
24741
24753
  propsProxy.$container$ = ctx.$container$;
24742
24754
  }
24743
24755
  } else {
24744
- isDev8 && assertTrue(
24756
+ isDev9 && assertTrue(
24745
24757
  !ctx.$container$ || ctx.$container$ === propsProxy.$container$,
24746
24758
  "Do not use props across containers"
24747
24759
  );
@@ -24847,7 +24859,7 @@ var cleanupFn = (target, handleError) => {
24847
24859
  };
24848
24860
 
24849
24861
  // packages/qwik/src/core/reactive-primitives/impl/computed-signal-impl.ts
24850
- import { isDev as isDev9 } from "@qwik.dev/core/build";
24862
+ import { isDev as isDev10 } from "@qwik.dev/core/build";
24851
24863
  var DEBUG2 = false;
24852
24864
  var log2 = (...args) => console.log("COMPUTED SIGNAL", ...args.map(qwikDebugToString));
24853
24865
  var _a3, _b;
@@ -24883,9 +24895,12 @@ var ComputedSignalImpl = class extends (_b = SignalImpl, _a3 = _EFFECT_BACK_REF,
24883
24895
  }
24884
24896
  get untrackedValue() {
24885
24897
  this.$computeIfNeeded$();
24886
- isDev9 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
24898
+ isDev10 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
24887
24899
  return this.$untrackedValue$;
24888
24900
  }
24901
+ set untrackedValue(value) {
24902
+ this.$untrackedValue$ = value;
24903
+ }
24889
24904
  $computeIfNeeded$() {
24890
24905
  if (!(this.$flags$ & 1 /* INVALID */)) {
24891
24906
  return;
@@ -24972,25 +24987,55 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a4 = _EFFECT_BAC
24972
24987
  __publicField(this, "$jobs$", []);
24973
24988
  __publicField(this, "$concurrency$", 1);
24974
24989
  __publicField(this, "$interval$", 0);
24975
- __publicField(this, "$pollTimeoutId$");
24976
24990
  __publicField(this, "$timeoutMs$");
24977
- __publicField(this, "$computationTimeoutId$");
24978
24991
  __publicField(this, _a4);
24979
- const interval = options?.interval || 0;
24992
+ const interval = options?.interval;
24980
24993
  const concurrency = options?.concurrency ?? 1;
24981
24994
  const initial = options?.initial;
24982
24995
  const timeout = options?.timeout;
24983
24996
  const eagerCleanup = options?.eagerCleanup;
24997
+ const clientOnly = options?.clientOnly;
24984
24998
  if (initial !== void 0) {
24985
24999
  const initialValue = typeof initial === "function" ? initial() : initial;
24986
25000
  this.$untrackedValue$ = initialValue;
24987
25001
  }
24988
25002
  this.$concurrency$ = concurrency;
24989
- this.$timeoutMs$ = timeout;
25003
+ if (timeout) {
25004
+ this.$timeoutMs$ = timeout;
25005
+ }
24990
25006
  if (eagerCleanup) {
24991
25007
  this.$flags$ |= 32 /* EAGER_CLEANUP */;
24992
25008
  }
24993
- this.interval = interval;
25009
+ if (clientOnly) {
25010
+ this.$flags$ |= 64 /* CLIENT_ONLY */;
25011
+ }
25012
+ if (interval) {
25013
+ this.interval = interval;
25014
+ }
25015
+ }
25016
+ get untrackedValue() {
25017
+ this.$computeIfNeeded$();
25018
+ if (this.$current$?.$promise$) {
25019
+ if (this.$untrackedValue$ === NEEDS_COMPUTATION || (import.meta.env.TEST ? isServerPlatform() : isServer5)) {
25020
+ DEBUG3 && log3("Throwing promise while computing initial value", this);
25021
+ throw this.$current$?.$promise$;
25022
+ }
25023
+ DEBUG3 && log3("Returning stale value", this.$untrackedValue$, "while computing", this.$current$);
25024
+ return this.$untrackedValue$;
25025
+ }
25026
+ if (this.$untrackedError$) {
25027
+ DEBUG3 && log3("Throwing error while reading value", this);
25028
+ throw this.$untrackedError$;
25029
+ }
25030
+ if ((import.meta.env.TEST ? isServerPlatform() : isServer5) && this.$flags$ & 64 /* CLIENT_ONLY */ && this.$untrackedValue$ === NEEDS_COMPUTATION) {
25031
+ throw new Error(
25032
+ "During SSR, cannot read .value from clientOnly async signal without an initial value. Use .loading or provide an initial value."
25033
+ );
25034
+ }
25035
+ return this.$untrackedValue$;
25036
+ }
25037
+ set untrackedValue(value) {
25038
+ this.$untrackedValue$ = value;
24994
25039
  }
24995
25040
  /**
24996
25041
  * Loading is true if the signal is still waiting for the promise to resolve, false if the promise
@@ -25081,6 +25126,11 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a4 = _EFFECT_BAC
25081
25126
  if (!(this.$flags$ & 1 /* INVALID */)) {
25082
25127
  return;
25083
25128
  }
25129
+ if ((import.meta.env.TEST ? isServerPlatform() : isServer5) && this.$flags$ & 64 /* CLIENT_ONLY */) {
25130
+ this.$untrackedLoading$ = true;
25131
+ this.$container$?.serializationCtx.$eagerResume$.add(this);
25132
+ return;
25133
+ }
25084
25134
  this.$clearNextPoll$();
25085
25135
  if (this.$current$) {
25086
25136
  this.$requestCleanups$(this.$current$);
@@ -25152,22 +25202,6 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a4 = _EFFECT_BAC
25152
25202
  }
25153
25203
  await Promise.all(this.$jobs$.map((job) => job.$promise$));
25154
25204
  }
25155
- get untrackedValue() {
25156
- this.$computeIfNeeded$();
25157
- if (this.$current$?.$promise$) {
25158
- if (this.$untrackedValue$ === NEEDS_COMPUTATION || (import.meta.env.TEST ? isServerPlatform() : isServer5)) {
25159
- DEBUG3 && log3("Throwing promise while computing initial value", this);
25160
- throw this.$current$?.$promise$;
25161
- }
25162
- DEBUG3 && log3("Returning stale value", this.$untrackedValue$, "while computing", this.$current$);
25163
- return this.$untrackedValue$;
25164
- }
25165
- if (this.$untrackedError$) {
25166
- DEBUG3 && log3("Throwing error while reading value", this);
25167
- throw this.$untrackedError$;
25168
- }
25169
- return this.$untrackedValue$;
25170
- }
25171
25205
  $clearNextPoll$() {
25172
25206
  if (this.$pollTimeoutId$ !== void 0) {
25173
25207
  clearTimeout(this.$pollTimeoutId$);
@@ -25424,7 +25458,7 @@ function setCursorData(vNode, cursorData) {
25424
25458
  }
25425
25459
 
25426
25460
  // packages/qwik/src/core/client/vnode-diff.ts
25427
- import { isDev as isDev13 } from "@qwik.dev/core/build";
25461
+ import { isDev as isDev14 } from "@qwik.dev/core/build";
25428
25462
 
25429
25463
  // packages/qwik/src/core/reactive-primitives/subscription-data.ts
25430
25464
  var SubscriptionData = class {
@@ -25435,14 +25469,14 @@ var SubscriptionData = class {
25435
25469
  };
25436
25470
 
25437
25471
  // packages/qwik/src/core/shared/component-execution.ts
25438
- import { isDev as isDev11, isServer as isServer6 } from "@qwik.dev/core/build";
25472
+ import { isDev as isDev12, isServer as isServer6 } from "@qwik.dev/core/build";
25439
25473
 
25440
25474
  // packages/qwik/src/core/shared/component.public.ts
25441
- import { isDev as isDev10 } from "@qwik.dev/core/build";
25475
+ import { isDev as isDev11 } from "@qwik.dev/core/build";
25442
25476
  var componentQrl = (componentQrl2) => {
25443
25477
  function QwikComponent(props, key, flags = 0) {
25444
- isDev10 && assertQrl(componentQrl2);
25445
- isDev10 && assertNumber(flags, "The Qwik Component was not invoked correctly");
25478
+ isDev11 && assertQrl(componentQrl2);
25479
+ isDev11 && assertNumber(flags, "The Qwik Component was not invoked correctly");
25446
25480
  const hash3 = qTest ? "sX" : componentQrl2.$hash$.slice(0, 4);
25447
25481
  const finalKey = hash3 + ":" + (key ? key : "");
25448
25482
  const InnerCmp = () => {
@@ -25515,6 +25549,9 @@ var isJSXNode = (n) => {
25515
25549
  return true;
25516
25550
  }
25517
25551
  if (isObject(n) && _hasOwnProperty.call(n, "key") && _hasOwnProperty.call(n, "props") && _hasOwnProperty.call(n, "type")) {
25552
+ if (isPropsProxy(n)) {
25553
+ return false;
25554
+ }
25518
25555
  logWarn(`Duplicate implementations of "JSXNode" found`);
25519
25556
  return true;
25520
25557
  }
@@ -25543,7 +25580,7 @@ var executeComponent = (container, renderHost, subscriptionHost, componentQRL, p
25543
25580
  let isInlineComponent = false;
25544
25581
  if (componentQRL === null) {
25545
25582
  componentQRL = container.getHostProp(renderHost, OnRenderProp);
25546
- isDev11 && assertDefined(componentQRL, "No Component found at this location");
25583
+ isDev12 && assertDefined(componentQRL, "No Component found at this location");
25547
25584
  }
25548
25585
  if (isQrl(componentQRL)) {
25549
25586
  props = props || container.getHostProp(renderHost, ELEMENT_PROPS) || EMPTY_OBJ;
@@ -25622,7 +25659,7 @@ function addUseOnEvents(jsx2, useOnEvents) {
25622
25659
  }
25623
25660
  targetElement = placeholderElement;
25624
25661
  } else {
25625
- if (isDev11) {
25662
+ if (isDev12) {
25626
25663
  logWarn(
25627
25664
  '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 has a valid element node. '
25628
25665
  );
@@ -25633,7 +25670,7 @@ function addUseOnEvents(jsx2, useOnEvents) {
25633
25670
  if (targetElement) {
25634
25671
  if (targetElement.type === "script" && key === qVisibleEvent) {
25635
25672
  eventKey = "q-d:qinit";
25636
- if (isDev11) {
25673
+ if (isDev12) {
25637
25674
  logWarn(
25638
25675
  'You are trying to add an event "' + key + '" using the `useVisibleTask$` hook with the "intersection-observer" strategy, but a node to which you can add an event is not found. Using "document-ready" or "document-idle" instead.'
25639
25676
  );
@@ -25666,7 +25703,6 @@ function addUseOnEvent(jsxElement, key, value) {
25666
25703
  props[key] = void 0;
25667
25704
  }
25668
25705
  }
25669
- var getValue = (o) => o.value;
25670
25706
  function findFirstElementNode(jsx2) {
25671
25707
  const queue2 = [jsx2];
25672
25708
  while (queue2.length) {
@@ -25681,7 +25717,7 @@ function findFirstElementNode(jsx2) {
25681
25717
  } else if (isPromise(jsx3)) {
25682
25718
  return maybeThen(jsx3, (jsx4) => findFirstElementNode(jsx4));
25683
25719
  } else if (isSignal(jsx3)) {
25684
- return findFirstElementNode(untrack(getValue, jsx3));
25720
+ return findFirstElementNode(jsx3.untrackedValue);
25685
25721
  }
25686
25722
  }
25687
25723
  return null;
@@ -25721,9 +25757,9 @@ var SSRRaw = () => null;
25721
25757
  var SSRComment = () => null;
25722
25758
 
25723
25759
  // packages/qwik/src/core/client/vnode-namespace.ts
25724
- import { isDev as isDev12 } from "@qwik.dev/core/build";
25760
+ import { isDev as isDev13 } from "@qwik.dev/core/build";
25725
25761
  var isForeignObjectElement = (elementName) => {
25726
- return isDev12 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
25762
+ return isDev13 ? elementName.toLowerCase() === "foreignobject" : elementName === "foreignObject";
25727
25763
  };
25728
25764
  var isSvgElement = (elementName) => elementName === "svg" || isForeignObjectElement(elementName);
25729
25765
  var isMathElement = (elementName) => elementName === "math";
@@ -26479,7 +26515,6 @@ var SetTextOperation = class {
26479
26515
  constructor(target, text) {
26480
26516
  this.target = target;
26481
26517
  this.text = text;
26482
- __publicField(this, "operationType", 16 /* SetText */);
26483
26518
  }
26484
26519
  };
26485
26520
  var InsertOrMoveOperation = class {
@@ -26578,8 +26613,8 @@ var vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyleId
26578
26613
  }
26579
26614
  };
26580
26615
  function diff(diffContext, jsxNode, vStartNode) {
26581
- isDev13 && assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode");
26582
- isDev13 && assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode");
26616
+ isDev14 && assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode");
26617
+ isDev14 && assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode");
26583
26618
  diffContext.vParent = vStartNode;
26584
26619
  diffContext.vNewNode = null;
26585
26620
  diffContext.vCurrent = vnode_getFirstChild(vStartNode);
@@ -26589,7 +26624,7 @@ function diff(diffContext, jsxNode, vStartNode) {
26589
26624
  }
26590
26625
  while (diffContext.stack.length) {
26591
26626
  while (diffContext.jsxIdx < diffContext.jsxCount) {
26592
- isDev13 && assertFalse(
26627
+ isDev14 && assertFalse(
26593
26628
  diffContext.vParent === diffContext.vCurrent,
26594
26629
  "Parent and current can't be the same"
26595
26630
  );
@@ -26601,7 +26636,7 @@ function diff(diffContext, jsxNode, vStartNode) {
26601
26636
  if (isJSXNode(diffContext.jsxValue)) {
26602
26637
  const type = diffContext.jsxValue.type;
26603
26638
  if (typeof type === "string") {
26604
- expectNoMoreTextNodes(diffContext);
26639
+ expectNoTextNode(diffContext);
26605
26640
  expectElement(diffContext, diffContext.jsxValue, type);
26606
26641
  const hasDangerousInnerHTML = diffContext.jsxValue.constProps && _hasOwnProperty2.call(diffContext.jsxValue.constProps, dangerouslySetInnerHTML) || _hasOwnProperty2.call(diffContext.jsxValue.varProps, dangerouslySetInnerHTML);
26607
26642
  if (hasDangerousInnerHTML) {
@@ -26611,11 +26646,11 @@ function diff(diffContext, jsxNode, vStartNode) {
26611
26646
  }
26612
26647
  } else if (typeof type === "function") {
26613
26648
  if (type === Fragment) {
26614
- expectNoMoreTextNodes(diffContext);
26649
+ expectNoTextNode(diffContext);
26615
26650
  expectVirtual(diffContext, "F" /* Fragment */, diffContext.jsxValue.key);
26616
26651
  descend(diffContext, diffContext.jsxValue.children, true);
26617
26652
  } else if (type === Slot) {
26618
- expectNoMoreTextNodes(diffContext);
26653
+ expectNoTextNode(diffContext);
26619
26654
  if (!expectSlot(diffContext)) {
26620
26655
  descend(diffContext, diffContext.jsxValue.children, true);
26621
26656
  }
@@ -26634,7 +26669,7 @@ function diff(diffContext, jsxNode, vStartNode) {
26634
26669
  } else if (type === SSRRaw) {
26635
26670
  expectNoMore(diffContext);
26636
26671
  } else {
26637
- expectNoMoreTextNodes(diffContext);
26672
+ expectNoTextNode(diffContext);
26638
26673
  expectComponent(diffContext, type);
26639
26674
  }
26640
26675
  }
@@ -26720,7 +26755,7 @@ function descend(diffContext, children, descendVNode, shouldExpectNoChildren = t
26720
26755
  }
26721
26756
  stackPush(diffContext, children, descendVNode);
26722
26757
  if (descendVNode) {
26723
- isDev13 && assertDefined(
26758
+ isDev14 && assertDefined(
26724
26759
  diffContext.vCurrent || diffContext.vNewNode,
26725
26760
  "Expecting vCurrent to be defined."
26726
26761
  );
@@ -26804,11 +26839,10 @@ function descendContentToProject(diffContext, children, host) {
26804
26839
  if (host) {
26805
26840
  const props = host.props;
26806
26841
  if (props) {
26807
- for (const prop of Object.keys(props)) {
26842
+ for (const prop in props) {
26808
26843
  if (isSlotProp(prop)) {
26809
26844
  const slotName = prop;
26810
- projections.push(slotName);
26811
- projections.push(createProjectionJSXNode(slotName));
26845
+ mapArray_set(projections, slotName, createProjectionJSXNode(slotName), 0);
26812
26846
  }
26813
26847
  }
26814
26848
  }
@@ -26849,8 +26883,8 @@ function expectProjection(diffContext) {
26849
26883
  diffContext.vCurrent = diffContext.vCurrent && diffContext.vCurrent.flags & 32 /* Deleted */ ? null : diffContext.vCurrent;
26850
26884
  if (diffContext.vCurrent == null) {
26851
26885
  diffContext.vNewNode = vnode_newVirtual();
26852
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "P" /* Projection */);
26853
- isDev13 && vnode_setProp(diffContext.vNewNode, "q:code", "expectProjection");
26886
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "P" /* Projection */);
26887
+ isDev14 && vnode_setProp(diffContext.vNewNode, "q:code", "expectProjection");
26854
26888
  vnode_setProp(diffContext.vNewNode, QSlot, slotName);
26855
26889
  diffContext.vNewNode.slotParent = diffContext.vParent;
26856
26890
  vnode_setProp(diffContext.vParent, slotName, diffContext.vNewNode);
@@ -26871,7 +26905,7 @@ function expectSlot(diffContext) {
26871
26905
  diffContext.vNewNode = vnode_newVirtual();
26872
26906
  vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey);
26873
26907
  vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode);
26874
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "P" /* Projection */);
26908
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "P" /* Projection */);
26875
26909
  vnode_insertBefore(
26876
26910
  diffContext.journal,
26877
26911
  diffContext.vParent,
@@ -26885,7 +26919,7 @@ function expectSlot(diffContext) {
26885
26919
  diffContext.vNewNode = vProjectedNode;
26886
26920
  vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey);
26887
26921
  vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode);
26888
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "P" /* Projection */);
26922
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "P" /* Projection */);
26889
26923
  vnode_insertBefore(
26890
26924
  diffContext.journal,
26891
26925
  diffContext.vParent,
@@ -26977,7 +27011,7 @@ function expectNoChildren(diffContext, removeDOM = true) {
26977
27011
  }
26978
27012
  }
26979
27013
  function expectNoMore(diffContext) {
26980
- isDev13 && assertFalse(
27014
+ isDev14 && assertFalse(
26981
27015
  diffContext.vParent === diffContext.vCurrent,
26982
27016
  "Parent and current can't be the same"
26983
27017
  );
@@ -26992,9 +27026,8 @@ function expectNoMore(diffContext) {
26992
27026
  }
26993
27027
  }
26994
27028
  }
26995
- function expectNoMoreTextNodes(diffContext) {
26996
- while (diffContext.vCurrent !== null && vnode_isTextVNode(diffContext.vCurrent)) {
26997
- cleanup(diffContext.container, diffContext.journal, diffContext.vCurrent, diffContext.cursor);
27029
+ function expectNoTextNode(diffContext) {
27030
+ if (diffContext.vCurrent !== null && vnode_isTextVNode(diffContext.vCurrent)) {
26998
27031
  const toRemove = diffContext.vCurrent;
26999
27032
  diffContext.vCurrent = peekNextSibling(diffContext.vCurrent);
27000
27033
  vnode_remove(diffContext.journal, diffContext.vParent, toRemove, true);
@@ -27064,7 +27097,7 @@ function createNewElement(diffContext, jsx2, elementName, currentFile) {
27064
27097
  }
27065
27098
  if (elementName === "textarea" && key2 === "value") {
27066
27099
  if (value && typeof value !== "string") {
27067
- if (isDev13) {
27100
+ if (isDev14) {
27068
27101
  throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
27069
27102
  }
27070
27103
  continue;
@@ -27115,7 +27148,9 @@ function registerEventHandlers(key, value, element, vnode, diffContext) {
27115
27148
  handlers.push(runEventHandlerQRL.bind(null, item));
27116
27149
  }
27117
27150
  }
27118
- (element._qDispatch || (element._qDispatch = {}))[scopedKebabName] = handlers;
27151
+ if (handlers.length > 0) {
27152
+ (element._qDispatch || (element._qDispatch = {}))[scopedKebabName] = handlers;
27153
+ }
27119
27154
  } else if (value) {
27120
27155
  (element._qDispatch || (element._qDispatch = {}))[scopedKebabName] = [
27121
27156
  runEventHandlerQRL.bind(null, value)
@@ -27161,7 +27196,7 @@ function expectElement(diffContext, jsx2, elementName) {
27161
27196
  const jsxProps = jsx2.varProps;
27162
27197
  const vNode = diffContext.vNewNode || diffContext.vCurrent;
27163
27198
  if (jsxProps) {
27164
- diffProps(diffContext, vNode, jsxProps, isDev13 && getFileLocationFromJsx(jsx2.dev) || null);
27199
+ diffProps(diffContext, vNode, jsxProps, isDev14 && getFileLocationFromJsx(jsx2.dev) || null);
27165
27200
  }
27166
27201
  }
27167
27202
  function diffProps(diffContext, vnode, newAttrs, currentFile) {
@@ -27425,7 +27460,7 @@ function expectVirtual(diffContext, type, jsxKey) {
27425
27460
  diffContext.vCurrent && getInsertBefore(diffContext)
27426
27461
  );
27427
27462
  diffContext.vNewNode.key = jsxKey;
27428
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, type);
27463
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, type);
27429
27464
  return;
27430
27465
  }
27431
27466
  if (moveOrCreateKeyedNode(
@@ -27443,7 +27478,7 @@ function expectVirtual(diffContext, type, jsxKey) {
27443
27478
  diffContext.vCurrent && getInsertBefore(diffContext)
27444
27479
  );
27445
27480
  diffContext.vNewNode.key = jsxKey;
27446
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, type);
27481
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, type);
27447
27482
  }
27448
27483
  }
27449
27484
  function expectComponent(diffContext, component) {
@@ -27530,7 +27565,7 @@ function expectComponent(diffContext, component) {
27530
27565
  OnRenderProp,
27531
27566
  null
27532
27567
  ) === null : true)) {
27533
- componentHost = componentHost.parent;
27568
+ componentHost = componentHost.parent || vnode_getProjectionParentComponent(componentHost);
27534
27569
  }
27535
27570
  const jsxOutput = executeComponent(
27536
27571
  diffContext.container,
@@ -27554,7 +27589,7 @@ function insertNewComponent(diffContext, host, componentQRL, jsxProps) {
27554
27589
  diffContext.vCurrent && getInsertBefore(diffContext)
27555
27590
  );
27556
27591
  const jsxNode = diffContext.jsxValue;
27557
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "C" /* Component */);
27592
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "C" /* Component */);
27558
27593
  vnode_setProp(diffContext.vNewNode, OnRenderProp, componentQRL);
27559
27594
  vnode_setProp(diffContext.vNewNode, ELEMENT_PROPS, jsxProps);
27560
27595
  diffContext.vNewNode.key = jsxNode.key;
@@ -27567,7 +27602,7 @@ function insertNewInlineComponent(diffContext) {
27567
27602
  diffContext.vCurrent && getInsertBefore(diffContext)
27568
27603
  );
27569
27604
  const jsxNode = diffContext.jsxValue;
27570
- isDev13 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
27605
+ isDev14 && vnode_setProp(diffContext.vNewNode, DEBUG_TYPE, "I" /* InlineComponent */);
27571
27606
  vnode_setProp(diffContext.vNewNode, ELEMENT_PROPS, jsxNode.props);
27572
27607
  if (jsxNode.key) {
27573
27608
  diffContext.vNewNode.key = jsxNode.key;
@@ -28179,7 +28214,7 @@ var createMacroTask = (fn) => {
28179
28214
  };
28180
28215
 
28181
28216
  // packages/qwik/src/core/shared/cursor/cursor-walker.ts
28182
- import { isDev as isDev14, isServer as isServer7 } from "@qwik.dev/core/build";
28217
+ import { isDev as isDev15, isServer as isServer7 } from "@qwik.dev/core/build";
28183
28218
  var DEBUG6 = false;
28184
28219
  var nextMicroTask = createMicroTask(processCursorQueue);
28185
28220
  var nextMacroTask = createMacroTask(processCursorQueue);
@@ -28216,7 +28251,7 @@ function walkCursor(cursor, options) {
28216
28251
  return;
28217
28252
  }
28218
28253
  const container = cursorData.container;
28219
- isDev14 && assertDefined(container, "Cursor container not found");
28254
+ isDev15 && assertDefined(container, "Cursor container not found");
28220
28255
  if (!cursor.dirty) {
28221
28256
  finishWalk(container, cursor, cursorData, isRunningOnServer);
28222
28257
  return;
@@ -28239,6 +28274,12 @@ function walkCursor(cursor, options) {
28239
28274
  if (currentVNode.flags & 32 /* Deleted */) {
28240
28275
  if (currentVNode.dirty & 64 /* CLEANUP */) {
28241
28276
  executeCleanup(currentVNode, container);
28277
+ } else if (currentVNode.dirty & 32 /* CHILDREN */) {
28278
+ const next = tryDescendDirtyChildren(container, cursorData, currentVNode, cursor);
28279
+ if (next !== null) {
28280
+ currentVNode = next;
28281
+ continue;
28282
+ }
28242
28283
  }
28243
28284
  currentVNode.dirty &= ~127 /* DIRTY_MASK */;
28244
28285
  setCursorPosition(container, cursorData, getNextVNode(currentVNode, cursor));
@@ -28257,14 +28298,9 @@ function walkCursor(cursor, options) {
28257
28298
  } else if (currentVNode.dirty & 16 /* COMPUTE */) {
28258
28299
  result2 = executeCompute(currentVNode, container);
28259
28300
  } else if (currentVNode.dirty & 32 /* CHILDREN */) {
28260
- const dirtyChildren = currentVNode.dirtyChildren;
28261
- if (!dirtyChildren || dirtyChildren.length === 0) {
28262
- currentVNode.dirty &= ~32 /* CHILDREN */;
28263
- } else {
28264
- partitionDirtyChildren(dirtyChildren, currentVNode);
28265
- currentVNode.nextDirtyChildIndex = 0;
28266
- currentVNode = getNextVNode(dirtyChildren[0], cursor);
28267
- setCursorPosition(container, cursorData, currentVNode);
28301
+ const next = tryDescendDirtyChildren(container, cursorData, currentVNode, cursor);
28302
+ if (next !== null) {
28303
+ currentVNode = next;
28268
28304
  continue;
28269
28305
  }
28270
28306
  }
@@ -28293,17 +28329,17 @@ function walkCursor(cursor, options) {
28293
28329
  }
28294
28330
  }
28295
28331
  }
28296
- isDev14 && assertFalse(
28332
+ isDev15 && assertFalse(
28297
28333
  !!(cursor.dirty & 127 /* DIRTY_MASK */ && !cursorData.position),
28298
28334
  "Cursor is still dirty and position is not set after walking"
28299
28335
  );
28300
28336
  finishWalk(container, cursor, cursorData, isRunningOnServer);
28301
28337
  }
28302
- function finishWalk(container, cursor, cursorData, isServer12) {
28338
+ function finishWalk(container, cursor, cursorData, isServer13) {
28303
28339
  if (!(cursor.dirty & 127 /* DIRTY_MASK */)) {
28304
28340
  removeCursorFromQueue(cursor, container);
28305
28341
  DEBUG6 && console.warn("walkCursor: cursor done", cursor.toString());
28306
- if (!isServer12) {
28342
+ if (!isServer13) {
28307
28343
  executeFlushPhase(cursor, container);
28308
28344
  }
28309
28345
  if (cursorData.extraPromises) {
@@ -28319,6 +28355,18 @@ function resolveCursor(container) {
28319
28355
  DEBUG6 && console.warn(`walkCursor: cursor resolved, ${container.$pendingCount$} remaining`);
28320
28356
  container.$checkPendingCount$();
28321
28357
  }
28358
+ function tryDescendDirtyChildren(container, cursorData, currentVNode, cursor) {
28359
+ const dirtyChildren = currentVNode.dirtyChildren;
28360
+ if (!dirtyChildren || dirtyChildren.length === 0) {
28361
+ currentVNode.dirty &= ~32 /* CHILDREN */;
28362
+ return null;
28363
+ }
28364
+ partitionDirtyChildren(dirtyChildren, currentVNode);
28365
+ currentVNode.nextDirtyChildIndex = 0;
28366
+ const next = getNextVNode(dirtyChildren[0], cursor);
28367
+ setCursorPosition(container, cursorData, next);
28368
+ return next;
28369
+ }
28322
28370
  function partitionDirtyChildren(dirtyChildren, parent) {
28323
28371
  let writeIndex = 0;
28324
28372
  for (let readIndex = 0; readIndex < dirtyChildren.length; readIndex++) {
@@ -28515,7 +28563,7 @@ function addVNodeOperation(journal, operation) {
28515
28563
  }
28516
28564
 
28517
28565
  // packages/qwik/src/core/reactive-primitives/impl/wrapped-signal-impl.ts
28518
- import { isDev as isDev15 } from "@qwik.dev/core/build";
28566
+ import { isDev as isDev16 } from "@qwik.dev/core/build";
28519
28567
  var _a5, _b3;
28520
28568
  var WrappedSignalImpl = class extends (_b3 = SignalImpl, _a5 = _EFFECT_BACK_REF, _b3) {
28521
28569
  constructor(container, fn, args, fnStr, flags = 1 /* INVALID */ | 4 /* UNWRAP */) {
@@ -28525,6 +28573,8 @@ var WrappedSignalImpl = class extends (_b3 = SignalImpl, _a5 = _EFFECT_BACK_REF,
28525
28573
  __publicField(this, "$funcStr$");
28526
28574
  __publicField(this, "$flags$");
28527
28575
  __publicField(this, "$hostElement$");
28576
+ // important: don't use implemnets BackRef here
28577
+ // it causes v8 optimizations eager bailouts, because of not consistent class shape
28528
28578
  __publicField(this, _a5);
28529
28579
  this.$args$ = args;
28530
28580
  this.$func$ = fn;
@@ -28548,7 +28598,7 @@ var WrappedSignalImpl = class extends (_b3 = SignalImpl, _a5 = _EFFECT_BACK_REF,
28548
28598
  }
28549
28599
  get untrackedValue() {
28550
28600
  this.$computeIfNeeded$();
28551
- isDev15 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
28601
+ isDev16 && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state");
28552
28602
  return this.$untrackedValue$;
28553
28603
  }
28554
28604
  $computeIfNeeded$() {
@@ -28785,27 +28835,42 @@ function _chk(_, element) {
28785
28835
  var version = globalThis.QWIK_VERSION;
28786
28836
 
28787
28837
  // packages/qwik/src/core/shared/serdes/serialize.ts
28788
- import { isDev as isDev16 } from "@qwik.dev/core/build";
28789
- async function serialize(serializationContext) {
28790
- const {
28791
- $writer$,
28792
- $isSsrNode$,
28793
- $isDomRef$,
28794
- $storeProxyMap$,
28795
- $addRoot$,
28796
- $promoteToRoot$,
28797
- getSeenRef,
28798
- $markSeen$
28799
- } = serializationContext;
28800
- let rootIdx = 0;
28801
- const forwardRefs = [];
28802
- let forwardRefsId = 0;
28803
- const promises = /* @__PURE__ */ new Set();
28804
- const s11nWeakRefs = /* @__PURE__ */ new Map();
28805
- let parent;
28806
- const qrlMap = /* @__PURE__ */ new Map();
28807
- const outputArray = (value, keepUndefined, writeFn) => {
28808
- $writer$.write("[");
28838
+ import { isDev as isDev17 } from "@qwik.dev/core/build";
28839
+
28840
+ // packages/qwik/src/core/shared/ssr-const.ts
28841
+ var LT = "<";
28842
+ var GT = ">";
28843
+ var CLOSE_TAG = "</";
28844
+ var ESCAPED_CLOSE_TAG = "<\\/";
28845
+ var SPACE = " ";
28846
+ var ATTR_EQUALS_QUOTE = '="';
28847
+ var QUOTE = '"';
28848
+ var EMPTY_ATTR = '=""';
28849
+ var BRACKET_OPEN = "[";
28850
+ var BRACKET_CLOSE = "]";
28851
+ var PAREN_CLOSE = ")";
28852
+ var COMMA = ",";
28853
+
28854
+ // packages/qwik/src/core/shared/serdes/serialize.ts
28855
+ var Serializer = class {
28856
+ constructor($serializationContext$) {
28857
+ this.$serializationContext$ = $serializationContext$;
28858
+ __publicField(this, "rootIdx", 0);
28859
+ __publicField(this, "forwardRefs", []);
28860
+ __publicField(this, "forwardRefsId", 0);
28861
+ __publicField(this, "promises", /* @__PURE__ */ new Set());
28862
+ __publicField(this, "s11nWeakRefs", /* @__PURE__ */ new Map());
28863
+ __publicField(this, "parent");
28864
+ __publicField(this, "qrlMap", /* @__PURE__ */ new Map());
28865
+ __publicField(this, "$writer$");
28866
+ this.$writer$ = $serializationContext$.$writer$;
28867
+ }
28868
+ async serialize() {
28869
+ await this.outputRoots();
28870
+ }
28871
+ /** Helper to output an array */
28872
+ outputArray(value, keepUndefined, writeFn) {
28873
+ this.$writer$.write(BRACKET_OPEN);
28809
28874
  let separator = false;
28810
28875
  let length;
28811
28876
  if (keepUndefined) {
@@ -28819,165 +28884,183 @@ async function serialize(serializationContext) {
28819
28884
  }
28820
28885
  for (let i = 0; i < length; i++) {
28821
28886
  if (separator) {
28822
- $writer$.write(",");
28887
+ this.$writer$.write(COMMA);
28823
28888
  } else {
28824
28889
  separator = true;
28825
28890
  }
28826
28891
  writeFn(value[i], i);
28827
28892
  }
28828
- $writer$.write("]");
28829
- };
28830
- const output = (type, value, keepUndefined) => {
28831
- $writer$.write(`${type},`);
28893
+ this.$writer$.write(BRACKET_CLOSE);
28894
+ }
28895
+ /** Whether a string needs JSON escaping (quote, backslash, or control chars). */
28896
+ stringNeedsJsonEscape$(str) {
28897
+ for (let i = 0; i < str.length; i++) {
28898
+ const c = str.charCodeAt(i);
28899
+ if (c < 32 || c === 34 || c === 92) {
28900
+ return true;
28901
+ }
28902
+ }
28903
+ return false;
28904
+ }
28905
+ /** Output a type,value pair. If the value is an array, it calls writeValue on each item. */
28906
+ output(type, value, keepUndefined) {
28832
28907
  if (typeof value === "number") {
28833
- $writer$.write(value.toString());
28908
+ this.$writer$.write(type + COMMA + value);
28834
28909
  } else if (typeof value === "string") {
28835
- const s = JSON.stringify(value);
28910
+ const s = this.stringNeedsJsonEscape$(value) ? JSON.stringify(value) : QUOTE + value + QUOTE;
28911
+ this.$writer$.write(type + COMMA);
28836
28912
  let angleBracketIdx = -1;
28837
28913
  let lastIdx = 0;
28838
- while ((angleBracketIdx = s.indexOf("</", lastIdx)) !== -1) {
28839
- $writer$.write(s.slice(lastIdx, angleBracketIdx));
28840
- $writer$.write("<\\/");
28914
+ while ((angleBracketIdx = s.indexOf(CLOSE_TAG, lastIdx)) !== -1) {
28915
+ this.$writer$.write(s.slice(lastIdx, angleBracketIdx));
28916
+ this.$writer$.write(ESCAPED_CLOSE_TAG);
28841
28917
  lastIdx = angleBracketIdx + 2;
28842
28918
  }
28843
- $writer$.write(lastIdx === 0 ? s : s.slice(lastIdx));
28919
+ this.$writer$.write(lastIdx === 0 ? s : s.slice(lastIdx));
28844
28920
  } else {
28845
- outputArray(value, !!keepUndefined, (valueItem, idx) => {
28846
- writeValue(valueItem, idx);
28921
+ this.$writer$.write(type + COMMA);
28922
+ this.outputArray(value, !!keepUndefined, (valueItem, idx) => {
28923
+ this.writeValue(valueItem, idx);
28847
28924
  });
28848
28925
  }
28849
- };
28850
- const getSeenRefOrOutput = (value, index, keepWeak) => {
28851
- let seen = getSeenRef(value);
28852
- const forwardRefIdx = !keepWeak && s11nWeakRefs.get(value);
28926
+ }
28927
+ getSeenRefOrOutput(value, index, keepWeak) {
28928
+ let seen = this.$serializationContext$.getSeenRef(value);
28929
+ const forwardRefIdx = !keepWeak && this.s11nWeakRefs.get(value);
28853
28930
  if (!seen) {
28854
28931
  if (keepWeak) {
28855
28932
  return true;
28856
28933
  }
28857
28934
  if (typeof forwardRefIdx === "number") {
28858
- seen = $addRoot$(value, true);
28935
+ seen = this.$serializationContext$.$addRoot$(value, true);
28859
28936
  } else {
28860
- return $markSeen$(value, parent, index);
28937
+ return this.$serializationContext$.$markSeen$(value, this.parent, index);
28861
28938
  }
28862
28939
  }
28863
28940
  if (seen.$parent$) {
28864
- if (!parent) {
28865
- $promoteToRoot$(seen, index);
28866
- value = serializationContext.$roots$[index];
28941
+ if (!this.parent) {
28942
+ this.$serializationContext$.$promoteToRoot$(seen, index);
28943
+ value = this.$serializationContext$.$roots$[index];
28867
28944
  } else {
28868
- $promoteToRoot$(seen);
28945
+ this.$serializationContext$.$promoteToRoot$(seen);
28869
28946
  }
28870
28947
  }
28871
28948
  if (typeof forwardRefIdx === "number") {
28872
- forwardRefs[forwardRefIdx] = seen.$index$;
28873
- s11nWeakRefs.delete(value);
28949
+ this.forwardRefs[forwardRefIdx] = seen.$index$;
28950
+ this.s11nWeakRefs.delete(value);
28874
28951
  }
28875
- const rootIdx2 = value instanceof SerializationBackRef ? value.$path$ : seen.$index$;
28876
- if (!parent && rootIdx2 === index) {
28952
+ const rootIdx = value instanceof SerializationBackRef ? value.$path$ : seen.$index$;
28953
+ if (!this.parent && rootIdx === index) {
28877
28954
  return seen;
28878
28955
  }
28879
- output(1 /* RootRef */, rootIdx2);
28880
- };
28881
- const writeValue = (value, index) => {
28956
+ this.output(1 /* RootRef */, rootIdx);
28957
+ }
28958
+ // First check for scalars, then do objects with seen checks
28959
+ // Make sure to only get the SeenRef once, it's expensive
28960
+ writeValue(value, index) {
28882
28961
  if (fastSkipSerialize(value)) {
28883
- output(3 /* Constant */, 0 /* Undefined */);
28962
+ this.output(3 /* Constant */, 0 /* Undefined */);
28884
28963
  } else {
28885
28964
  switch (typeof value) {
28886
28965
  case "undefined":
28887
- output(3 /* Constant */, 0 /* Undefined */);
28966
+ this.output(3 /* Constant */, 0 /* Undefined */);
28888
28967
  break;
28889
28968
  case "boolean":
28890
- output(3 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28969
+ this.output(3 /* Constant */, value ? 2 /* True */ : 3 /* False */);
28891
28970
  break;
28892
28971
  case "number":
28893
28972
  if (Number.isNaN(value)) {
28894
- output(3 /* Constant */, 12 /* NaN */);
28973
+ this.output(3 /* Constant */, 12 /* NaN */);
28895
28974
  } else if (!Number.isFinite(value)) {
28896
- output(
28975
+ this.output(
28897
28976
  3 /* Constant */,
28898
28977
  value < 0 ? 14 /* NegativeInfinity */ : 13 /* PositiveInfinity */
28899
28978
  );
28900
28979
  } else if (value === Number.MAX_SAFE_INTEGER) {
28901
- output(3 /* Constant */, 15 /* MaxSafeInt */);
28980
+ this.output(3 /* Constant */, 15 /* MaxSafeInt */);
28902
28981
  } else if (value === Number.MAX_SAFE_INTEGER - 1) {
28903
- output(3 /* Constant */, 16 /* AlmostMaxSafeInt */);
28982
+ this.output(3 /* Constant */, 16 /* AlmostMaxSafeInt */);
28904
28983
  } else if (value === Number.MIN_SAFE_INTEGER) {
28905
- output(3 /* Constant */, 17 /* MinSafeInt */);
28984
+ this.output(3 /* Constant */, 17 /* MinSafeInt */);
28906
28985
  } else {
28907
- output(0 /* Plain */, value);
28986
+ this.output(0 /* Plain */, value);
28908
28987
  }
28909
28988
  break;
28910
28989
  case "string":
28911
28990
  if (value.length === 0) {
28912
- output(3 /* Constant */, 4 /* EmptyString */);
28991
+ this.output(3 /* Constant */, 4 /* EmptyString */);
28913
28992
  } else {
28914
- if (value.length < 4 || getSeenRefOrOutput(value, index)) {
28915
- output(0 /* Plain */, value);
28993
+ if (value.length < 4 || this.getSeenRefOrOutput(value, index)) {
28994
+ this.output(0 /* Plain */, value);
28916
28995
  }
28917
28996
  }
28918
28997
  break;
28919
28998
  case "bigint":
28920
- if (value < 1e4 && value > -1e3 || getSeenRefOrOutput(value, index)) {
28921
- output(12 /* BigInt */, value.toString());
28999
+ if (value < 1e4 && value > -1e3 || this.getSeenRefOrOutput(value, index)) {
29000
+ this.output(12 /* BigInt */, value.toString());
28922
29001
  }
28923
29002
  break;
28924
29003
  case "symbol":
28925
29004
  if (value === NEEDS_COMPUTATION) {
28926
- output(3 /* Constant */, 7 /* NEEDS_COMPUTATION */);
29005
+ this.output(3 /* Constant */, 7 /* NEEDS_COMPUTATION */);
28927
29006
  } else if (value === STORE_ALL_PROPS) {
28928
- output(3 /* Constant */, 8 /* STORE_ALL_PROPS */);
29007
+ this.output(3 /* Constant */, 8 /* STORE_ALL_PROPS */);
28929
29008
  } else if (value === _UNINITIALIZED) {
28930
- output(3 /* Constant */, 9 /* UNINITIALIZED */);
29009
+ this.output(3 /* Constant */, 9 /* UNINITIALIZED */);
28931
29010
  }
28932
29011
  break;
28933
29012
  case "function":
28934
29013
  if (value === Slot) {
28935
- output(3 /* Constant */, 10 /* Slot */);
29014
+ this.output(3 /* Constant */, 10 /* Slot */);
28936
29015
  } else if (value === Fragment) {
28937
- output(3 /* Constant */, 11 /* Fragment */);
29016
+ this.output(3 /* Constant */, 11 /* Fragment */);
28938
29017
  } else if (isQrl(value)) {
28939
- if (getSeenRefOrOutput(value, index)) {
28940
- const [chunk, symbol, captures] = qrlToString(serializationContext, value, true);
29018
+ if (this.getSeenRefOrOutput(value, index)) {
29019
+ const [chunk, symbol, captures] = qrlToString(
29020
+ this.$serializationContext$,
29021
+ value,
29022
+ true
29023
+ );
28941
29024
  let data;
28942
29025
  if (chunk !== "") {
28943
- data = `${$addRoot$(chunk)}#${$addRoot$(symbol)}${captures ? "#" + captures : ""}`;
28944
- const existing = qrlMap.get(data);
29026
+ data = `${this.$serializationContext$.$addRoot$(chunk)}#${this.$serializationContext$.$addRoot$(symbol)}${captures ? "#" + captures : ""}`;
29027
+ const existing = this.qrlMap.get(data);
28945
29028
  if (existing) {
28946
- const ref = $addRoot$(existing);
28947
- output(1 /* RootRef */, ref);
29029
+ const ref = this.$serializationContext$.$addRoot$(existing);
29030
+ this.output(1 /* RootRef */, ref);
28948
29031
  return;
28949
29032
  } else {
28950
- qrlMap.set(data, value);
29033
+ this.qrlMap.set(data, value);
28951
29034
  }
28952
29035
  } else {
28953
29036
  data = Number(symbol);
28954
29037
  }
28955
- output(9 /* QRL */, data);
29038
+ this.output(9 /* QRL */, data);
28956
29039
  }
28957
29040
  } else if (isQwikComponent(value)) {
28958
29041
  const [qrl] = value[SERIALIZABLE_STATE];
28959
- serializationContext.$renderSymbols$.add(qrl.$symbol$);
28960
- output(21 /* Component */, [qrl]);
29042
+ this.$serializationContext$.$renderSymbols$.add(qrl.$symbol$);
29043
+ this.output(21 /* Component */, [qrl]);
28961
29044
  } else {
28962
29045
  throw qError(34 /* serializeErrorCannotSerializeFunction */, [value.toString()]);
28963
29046
  }
28964
29047
  break;
28965
29048
  case "object":
28966
29049
  if (value === EMPTY_ARRAY) {
28967
- output(3 /* Constant */, 5 /* EMPTY_ARRAY */);
29050
+ this.output(3 /* Constant */, 5 /* EMPTY_ARRAY */);
28968
29051
  } else if (value === EMPTY_OBJ) {
28969
- output(3 /* Constant */, 6 /* EMPTY_OBJ */);
29052
+ this.output(3 /* Constant */, 6 /* EMPTY_OBJ */);
28970
29053
  } else if (value === null) {
28971
- output(3 /* Constant */, 1 /* Null */);
29054
+ this.output(3 /* Constant */, 1 /* Null */);
28972
29055
  } else if (value instanceof SerializationBackRef) {
28973
- output(1 /* RootRef */, value.$path$);
29056
+ this.output(1 /* RootRef */, value.$path$);
28974
29057
  } else {
28975
- const newSeenRef = getSeenRefOrOutput(value, index);
29058
+ const newSeenRef = this.getSeenRefOrOutput(value, index);
28976
29059
  if (newSeenRef) {
28977
- const oldParent = parent;
28978
- parent = newSeenRef;
28979
- writeObjectValue(value);
28980
- parent = oldParent;
29060
+ const oldParent = this.parent;
29061
+ this.parent = newSeenRef;
29062
+ this.writeObjectValue(value);
29063
+ this.parent = oldParent;
28981
29064
  }
28982
29065
  }
28983
29066
  break;
@@ -28985,25 +29068,23 @@ async function serialize(serializationContext) {
28985
29068
  throw qError(20 /* serializeErrorUnknownType */, [typeof value]);
28986
29069
  }
28987
29070
  }
28988
- };
28989
- const writeObjectValue = (value) => {
29071
+ }
29072
+ writeObjectValue(value) {
28990
29073
  if (isPropsProxy(value)) {
28991
29074
  const owner = value[_OWNER];
28992
- output(30 /* PropsProxy */, [
29075
+ this.output(30 /* PropsProxy */, [
28993
29076
  _serializationWeakRef(owner),
28994
29077
  owner.varProps,
28995
29078
  owner.constProps,
28996
29079
  value[_PROPS_HANDLER].$effects$
28997
29080
  ]);
28998
29081
  } else if (value instanceof SubscriptionData) {
28999
- output(31 /* SubscriptionData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
29000
- } else if (value instanceof EffectSubscription) {
29001
- output(32 /* EffectSubscription */, [
29002
- value.consumer,
29003
- value.property,
29004
- value.backRef,
29005
- value.data
29082
+ this.output(31 /* SubscriptionData */, [
29083
+ value.data.$scopedStyleIdPrefix$,
29084
+ value.data.$isConst$
29006
29085
  ]);
29086
+ } else if (value instanceof EffectSubscription) {
29087
+ this.output(32 /* EffectSubscription */, [value.consumer, value.property, value.data]);
29007
29088
  } else if (isStore(value)) {
29008
29089
  const storeHandler = getStoreHandler(value);
29009
29090
  const storeTarget = getStoreTarget(value);
@@ -29012,7 +29093,7 @@ async function serialize(serializationContext) {
29012
29093
  const innerStores = [];
29013
29094
  for (const prop in storeTarget) {
29014
29095
  const propValue = storeTarget[prop];
29015
- const innerStore = $storeProxyMap$.get(propValue);
29096
+ const innerStore = this.$serializationContext$.$storeProxyMap$.get(propValue);
29016
29097
  if (innerStore) {
29017
29098
  innerStores.push(innerStore);
29018
29099
  }
@@ -29021,11 +29102,11 @@ async function serialize(serializationContext) {
29021
29102
  while (out[out.length - 1] === void 0) {
29022
29103
  out.pop();
29023
29104
  }
29024
- output(27 /* Store */, out);
29105
+ this.output(27 /* Store */, out);
29025
29106
  } else if (isSerializerObj(value)) {
29026
29107
  const result2 = value[SerializerSymbol](value);
29027
29108
  if (isPromise(result2)) {
29028
- const forwardRef = resolvePromise(result2, $addRoot$, (resolved, resolvedValue) => {
29109
+ const forwardRef = this.resolvePromise(result2, (resolved, resolvedValue) => {
29029
29110
  return new PromiseResult(
29030
29111
  26 /* SerializerSignal */,
29031
29112
  resolved,
@@ -29034,15 +29115,15 @@ async function serialize(serializationContext) {
29034
29115
  void 0
29035
29116
  );
29036
29117
  });
29037
- output(2 /* ForwardRef */, forwardRef);
29118
+ this.output(2 /* ForwardRef */, forwardRef);
29038
29119
  } else {
29039
- const index = parent.$index$;
29040
- parent = parent.$parent$;
29041
- writeValue(result2, index);
29120
+ const index = this.parent.$index$;
29121
+ this.parent = this.parent.$parent$;
29122
+ this.writeValue(result2, index);
29042
29123
  }
29043
29124
  } else if (isObjectLiteral(value)) {
29044
29125
  if (Array.isArray(value)) {
29045
- output(4 /* Array */, value);
29126
+ this.output(4 /* Array */, value);
29046
29127
  } else {
29047
29128
  const out = [];
29048
29129
  for (const key in value) {
@@ -29053,16 +29134,16 @@ async function serialize(serializationContext) {
29053
29134
  }
29054
29135
  }
29055
29136
  }
29056
- output(5 /* Object */, out.length ? out : 0);
29137
+ this.output(5 /* Object */, out.length ? out : 0);
29057
29138
  }
29058
- } else if ($isDomRef$(value)) {
29139
+ } else if (this.$serializationContext$.$isDomRef$(value)) {
29059
29140
  value.$ssrNode$.vnodeData[0] |= 16 /* SERIALIZE */;
29060
- output(11 /* RefVNode */, value.$ssrNode$.id);
29141
+ this.output(11 /* RefVNode */, value.$ssrNode$.id);
29061
29142
  } else if (value instanceof SignalImpl) {
29062
29143
  if (value instanceof SerializerSignalImpl) {
29063
29144
  const maybeValue = getCustomSerializerPromise(value, value.$untrackedValue$);
29064
29145
  if (isPromise(maybeValue)) {
29065
- const forwardRefId = resolvePromise(maybeValue, $addRoot$, (resolved, resolvedValue) => {
29146
+ const forwardRefId = this.resolvePromise(maybeValue, (resolved, resolvedValue) => {
29066
29147
  return new PromiseResult(
29067
29148
  26 /* SerializerSignal */,
29068
29149
  resolved,
@@ -29071,21 +29152,15 @@ async function serialize(serializationContext) {
29071
29152
  value.$computeQrl$
29072
29153
  );
29073
29154
  });
29074
- output(2 /* ForwardRef */, forwardRefId);
29155
+ this.output(2 /* ForwardRef */, forwardRefId);
29075
29156
  } else {
29076
- output(26 /* SerializerSignal */, [
29077
- value.$computeQrl$,
29078
- filterEffectBackRefs(value[_EFFECT_BACK_REF]),
29079
- value.$effects$,
29080
- maybeValue
29081
- ]);
29157
+ this.output(26 /* SerializerSignal */, [value.$computeQrl$, value.$effects$, maybeValue]);
29082
29158
  }
29083
29159
  return;
29084
29160
  }
29085
29161
  if (value instanceof WrappedSignalImpl) {
29086
- output(23 /* WrappedSignal */, [
29087
- ...serializeWrappingFn(serializationContext, value),
29088
- filterEffectBackRefs(value[_EFFECT_BACK_REF]),
29162
+ this.output(23 /* WrappedSignal */, [
29163
+ ...serializeWrappingFn(this.$serializationContext$, value),
29089
29164
  value.$flags$,
29090
29165
  value.$hostElement$,
29091
29166
  ...value.$effects$ || []
@@ -29100,7 +29175,7 @@ async function serialize(serializationContext) {
29100
29175
  const interval = isAsync && value.$interval$ > 0 ? value.$interval$ : void 0;
29101
29176
  const concurrency = isAsync && value.$concurrency$ !== 1 ? value.$concurrency$ : void 0;
29102
29177
  const timeout = isAsync && value.$timeoutMs$ !== 0 ? value.$timeoutMs$ : void 0;
29103
- const eagerCleanup = isAsync && value.$flags$ & 32 /* EAGER_CLEANUP */ ? true : void 0;
29178
+ const asyncFlags = isAsync && value.$flags$ & ~24 /* SERIALIZATION_ALL_STRATEGIES */ || void 0;
29104
29179
  if (isInvalid || isSkippable) {
29105
29180
  v = NEEDS_COMPUTATION;
29106
29181
  } else if (shouldAlwaysSerialize) {
@@ -29108,13 +29183,10 @@ async function serialize(serializationContext) {
29108
29183
  } else if (shouldNeverSerialize) {
29109
29184
  v = NEEDS_COMPUTATION;
29110
29185
  }
29111
- const out = [
29112
- value.$computeQrl$,
29113
- filterEffectBackRefs(value[_EFFECT_BACK_REF]),
29114
- value.$effects$
29115
- ];
29186
+ const out = [value.$computeQrl$, value.$effects$];
29116
29187
  if (isAsync) {
29117
29188
  out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedError$);
29189
+ out.push(asyncFlags || void 0);
29118
29190
  }
29119
29191
  let keepUndefined = false;
29120
29192
  if (v !== NEEDS_COMPUTATION || interval !== void 0 || concurrency !== void 0 || timeout !== void 0) {
@@ -29127,9 +29199,8 @@ async function serialize(serializationContext) {
29127
29199
  out.push(interval);
29128
29200
  out.push(concurrency);
29129
29201
  out.push(timeout);
29130
- out.push(eagerCleanup);
29131
29202
  }
29132
- output(isAsync ? 25 /* AsyncSignal */ : 24 /* ComputedSignal */, out, keepUndefined);
29203
+ this.output(isAsync ? 25 /* AsyncSignal */ : 24 /* ComputedSignal */, out, keepUndefined);
29133
29204
  } else {
29134
29205
  const v = value.$untrackedValue$;
29135
29206
  const keepUndefined = v === void 0;
@@ -29137,39 +29208,45 @@ async function serialize(serializationContext) {
29137
29208
  if (value.$effects$) {
29138
29209
  out.push(...value.$effects$);
29139
29210
  }
29140
- output(22 /* Signal */, out, keepUndefined);
29211
+ this.output(22 /* Signal */, out, keepUndefined);
29141
29212
  }
29142
29213
  } else if (value instanceof URL) {
29143
- output(6 /* URL */, value.href);
29214
+ this.output(6 /* URL */, value.href);
29144
29215
  } else if (value instanceof Date) {
29145
- output(7 /* Date */, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
29216
+ this.output(7 /* Date */, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
29146
29217
  } else if (value instanceof RegExp) {
29147
- output(8 /* Regex */, value.toString());
29218
+ this.output(8 /* Regex */, value.toString());
29148
29219
  } else if (value instanceof Error) {
29149
29220
  const out = [value.message];
29150
29221
  out.push(...Object.entries(value).flat());
29151
- if (isDev16) {
29222
+ if (isDev17) {
29152
29223
  out.push("stack", value.stack);
29153
29224
  }
29154
- output(15 /* Error */, out);
29155
- } else if ($isSsrNode$(value)) {
29156
- const rootIndex = $addRoot$(value);
29157
- serializationContext.$setProp$(value, ELEMENT_ID, String(rootIndex));
29158
- output(10 /* VNode */, value.id);
29225
+ this.output(15 /* Error */, out);
29226
+ } else if (this.$serializationContext$.$isSsrNode$(value)) {
29227
+ const rootIndex = this.$serializationContext$.$addRoot$(value);
29228
+ this.$serializationContext$.$setProp$(value, ELEMENT_ID, String(rootIndex));
29229
+ this.output(10 /* VNode */, value.id);
29159
29230
  const vNodeData = value.vnodeData;
29160
29231
  if (vNodeData) {
29161
- discoverValuesForVNodeData(vNodeData, (vNodeDataValue) => $addRoot$(vNodeDataValue));
29232
+ discoverValuesForVNodeData(
29233
+ vNodeData,
29234
+ (vNodeDataValue) => this.$serializationContext$.$addRoot$(vNodeDataValue)
29235
+ );
29162
29236
  vNodeData[0] |= 16 /* SERIALIZE */;
29163
29237
  }
29164
29238
  if (value.children) {
29165
- for (const child of value.children) {
29239
+ const childrenLength = value.children.length;
29240
+ for (let i = 0; i < childrenLength; i++) {
29241
+ const child = value.children[i];
29166
29242
  const childVNodeData = child.vnodeData;
29167
29243
  if (childVNodeData) {
29168
- for (const value2 of childVNodeData) {
29244
+ for (let i2 = 0; i2 < childVNodeData.length; i2++) {
29245
+ const value2 = childVNodeData[i2];
29169
29246
  if (isSsrAttrs(value2)) {
29170
- const backRefKeyIndex = value2.findIndex((v) => v === QBackRefs);
29171
- if (backRefKeyIndex !== -1) {
29172
- $addRoot$(value2[backRefKeyIndex + 1]);
29247
+ const backRefs = tryGetBackRefs(value2);
29248
+ if (backRefs) {
29249
+ this.$serializationContext$.$addRoot$(backRefs);
29173
29250
  }
29174
29251
  }
29175
29252
  }
@@ -29179,24 +29256,22 @@ async function serialize(serializationContext) {
29179
29256
  }
29180
29257
  } else if (typeof FormData !== "undefined" && value instanceof FormData) {
29181
29258
  const array = [];
29182
- value.forEach((value2, key) => {
29183
- if (typeof value2 === "string") {
29184
- array.push(key, value2);
29185
- } else {
29186
- array.push(key, value2.name);
29259
+ for (const [k, v] of value.entries()) {
29260
+ if (typeof v === "string") {
29261
+ array.push(k, v);
29187
29262
  }
29188
- });
29189
- output(28 /* FormData */, array);
29263
+ }
29264
+ this.output(28 /* FormData */, array);
29190
29265
  } else if (value instanceof URLSearchParams) {
29191
- output(13 /* URLSearchParams */, value.toString());
29266
+ this.output(13 /* URLSearchParams */, value.toString());
29192
29267
  } else if (value instanceof Set) {
29193
- output(17 /* Set */, [...value.values()]);
29268
+ this.output(17 /* Set */, [...value.values()]);
29194
29269
  } else if (value instanceof Map) {
29195
29270
  const combined = [];
29196
29271
  for (const [k, v] of value.entries()) {
29197
29272
  combined.push(k, v);
29198
29273
  }
29199
- output(18 /* Map */, combined);
29274
+ this.output(18 /* Map */, combined);
29200
29275
  } else if (isJSXNode(value)) {
29201
29276
  const out = [
29202
29277
  value.type,
@@ -29209,117 +29284,114 @@ async function serialize(serializationContext) {
29209
29284
  while (out[out.length - 1] === void 0) {
29210
29285
  out.pop();
29211
29286
  }
29212
- output(29 /* JSXNode */, out);
29287
+ this.output(29 /* JSXNode */, out);
29213
29288
  } else if (value instanceof Task) {
29214
- const out = [
29215
- value.$qrl$,
29216
- value.$flags$,
29217
- value.$index$,
29218
- value.$el$,
29219
- value[_EFFECT_BACK_REF],
29220
- value.$state$
29221
- ];
29289
+ const out = [value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$state$];
29222
29290
  while (out[out.length - 1] === void 0) {
29223
29291
  out.pop();
29224
29292
  }
29225
- output(20 /* Task */, out);
29293
+ this.output(20 /* Task */, out);
29226
29294
  } else if (isPromise(value)) {
29227
- const forwardRefId = resolvePromise(value, $addRoot$, (resolved, resolvedValue) => {
29295
+ const forwardRefId = this.resolvePromise(value, (resolved, resolvedValue) => {
29228
29296
  return new PromiseResult(16 /* Promise */, resolved, resolvedValue);
29229
29297
  });
29230
- output(2 /* ForwardRef */, forwardRefId);
29298
+ this.output(2 /* ForwardRef */, forwardRefId);
29231
29299
  } else if (value instanceof PromiseResult) {
29232
29300
  if (value.$type$ === 26 /* SerializerSignal */) {
29233
29301
  if (value.$qrl$) {
29234
- output(26 /* SerializerSignal */, [value.$qrl$, value.$effects$, value.$value$]);
29302
+ this.output(26 /* SerializerSignal */, [value.$qrl$, value.$effects$, value.$value$]);
29235
29303
  } else if (value.$resolved$) {
29236
- const index = parent.$index$;
29237
- parent = parent.$parent$;
29238
- writeValue(value.$value$, index);
29304
+ const index = this.parent.$index$;
29305
+ this.parent = this.parent.$parent$;
29306
+ this.writeValue(value.$value$, index);
29239
29307
  } else {
29240
29308
  console.error(value.$value$);
29241
29309
  throw qError(33 /* serializerSymbolRejectedPromise */);
29242
29310
  }
29243
29311
  } else {
29244
- output(16 /* Promise */, [value.$resolved$, value.$value$]);
29312
+ this.output(16 /* Promise */, [value.$resolved$, value.$value$]);
29245
29313
  }
29246
29314
  } else if (value instanceof Uint8Array) {
29247
29315
  let buf = "";
29248
- for (const c of value) {
29249
- buf += String.fromCharCode(c);
29316
+ const length = value.length;
29317
+ for (let i = 0; i < length; i++) {
29318
+ buf += String.fromCharCode(value[i]);
29250
29319
  }
29251
29320
  const out = btoa(buf).replace(/=+$/, "");
29252
- output(19 /* Uint8Array */, out);
29321
+ this.output(19 /* Uint8Array */, out);
29253
29322
  } else if (value instanceof SerializationWeakRef) {
29254
29323
  const obj = value.$obj$;
29255
- if (getSeenRefOrOutput(obj, parent.$index$, true)) {
29256
- let forwardRefId = s11nWeakRefs.get(obj);
29324
+ if (this.getSeenRefOrOutput(obj, this.parent.$index$, true)) {
29325
+ let forwardRefId = this.s11nWeakRefs.get(obj);
29257
29326
  if (forwardRefId === void 0) {
29258
- forwardRefId = forwardRefsId++;
29259
- s11nWeakRefs.set(obj, forwardRefId);
29260
- forwardRefs[forwardRefId] = -1;
29327
+ forwardRefId = this.forwardRefsId++;
29328
+ this.s11nWeakRefs.set(obj, forwardRefId);
29329
+ this.forwardRefs[forwardRefId] = -1;
29261
29330
  }
29262
- output(2 /* ForwardRef */, forwardRefId);
29331
+ this.output(2 /* ForwardRef */, forwardRefId);
29263
29332
  }
29264
29333
  } else if (vnode_isVNode(value)) {
29265
- output(3 /* Constant */, 0 /* Undefined */);
29334
+ this.output(3 /* Constant */, 0 /* Undefined */);
29266
29335
  } else {
29267
29336
  throw qError(20 /* serializeErrorUnknownType */, [typeof value]);
29268
29337
  }
29269
- };
29270
- function resolvePromise(promise, $addRoot$2, classCreator) {
29271
- const forwardRefId = forwardRefsId++;
29338
+ }
29339
+ resolvePromise(promise, classCreator) {
29340
+ const forwardRefId = this.forwardRefsId++;
29272
29341
  promise.then((resolvedValue) => {
29273
- promises.delete(promise);
29274
- forwardRefs[forwardRefId] = $addRoot$2(classCreator(true, resolvedValue));
29342
+ this.promises.delete(promise);
29343
+ this.forwardRefs[forwardRefId] = this.$serializationContext$.$addRoot$(
29344
+ classCreator(true, resolvedValue)
29345
+ );
29275
29346
  }).catch((err) => {
29276
- promises.delete(promise);
29277
- forwardRefs[forwardRefId] = $addRoot$2(classCreator(false, err));
29347
+ this.promises.delete(promise);
29348
+ this.forwardRefs[forwardRefId] = this.$serializationContext$.$addRoot$(
29349
+ classCreator(false, err)
29350
+ );
29278
29351
  });
29279
- promises.add(promise);
29352
+ this.promises.add(promise);
29280
29353
  return forwardRefId;
29281
29354
  }
29282
- const outputRoots = async () => {
29283
- $writer$.write("[");
29284
- const { $roots$ } = serializationContext;
29285
- while (rootIdx < $roots$.length || promises.size) {
29286
- if (rootIdx !== 0) {
29287
- $writer$.write(",");
29355
+ async outputRoots() {
29356
+ this.$writer$.write(BRACKET_OPEN);
29357
+ const { $roots$ } = this.$serializationContext$;
29358
+ while (this.rootIdx < $roots$.length || this.promises.size) {
29359
+ if (this.rootIdx !== 0) {
29360
+ this.$writer$.write(COMMA);
29288
29361
  }
29289
29362
  let separator = false;
29290
- for (; rootIdx < $roots$.length; rootIdx++) {
29363
+ for (; this.rootIdx < $roots$.length; this.rootIdx++) {
29291
29364
  if (separator) {
29292
- $writer$.write(",");
29365
+ this.$writer$.write(COMMA);
29293
29366
  } else {
29294
29367
  separator = true;
29295
29368
  }
29296
- writeValue($roots$[rootIdx], rootIdx);
29369
+ this.writeValue($roots$[this.rootIdx], this.rootIdx);
29297
29370
  }
29298
- if (promises.size) {
29371
+ if (this.promises.size) {
29299
29372
  try {
29300
- await Promise.race(promises);
29373
+ await Promise.race(this.promises);
29301
29374
  } catch {
29302
29375
  }
29303
29376
  }
29304
29377
  }
29305
- if (forwardRefs.length) {
29306
- let lastIdx = forwardRefs.length - 1;
29307
- while (lastIdx >= 0 && forwardRefs[lastIdx] === -1) {
29378
+ if (this.forwardRefs.length) {
29379
+ let lastIdx = this.forwardRefs.length - 1;
29380
+ while (lastIdx >= 0 && this.forwardRefs[lastIdx] === -1) {
29308
29381
  lastIdx--;
29309
29382
  }
29310
29383
  if (lastIdx >= 0) {
29311
- $writer$.write(",");
29312
- $writer$.write(14 /* ForwardRefs */ + ",");
29313
- const out = lastIdx === forwardRefs.length - 1 ? forwardRefs : forwardRefs.slice(0, lastIdx + 1);
29314
- outputArray(out, true, (value) => {
29315
- $writer$.write(String(value));
29384
+ this.$writer$.write(COMMA);
29385
+ this.$writer$.write(14 /* ForwardRefs */ + COMMA);
29386
+ const out = lastIdx === this.forwardRefs.length - 1 ? this.forwardRefs : this.forwardRefs.slice(0, lastIdx + 1);
29387
+ this.outputArray(out, true, (value) => {
29388
+ this.$writer$.write(String(value));
29316
29389
  });
29317
29390
  }
29318
29391
  }
29319
- $writer$.write("]");
29320
- };
29321
- await outputRoots();
29322
- }
29392
+ this.$writer$.write(BRACKET_CLOSE);
29393
+ }
29394
+ };
29323
29395
  var PromiseResult = class {
29324
29396
  constructor($type$, $resolved$, $value$, $effects$ = void 0, $qrl$ = void 0) {
29325
29397
  this.$type$ = $type$;
@@ -29353,13 +29425,13 @@ function getCustomSerializerPromise(signal, value) {
29353
29425
  );
29354
29426
  }
29355
29427
  var discoverValuesForVNodeData = (vnodeData, callback) => {
29356
- for (const value of vnodeData) {
29428
+ const length = vnodeData.length;
29429
+ for (let i = 0; i < length; i++) {
29430
+ const value = vnodeData[i];
29357
29431
  if (isSsrAttrs(value)) {
29358
- for (let i = 1; i < value.length; i += 2) {
29359
- const keyValue = value[i - 1];
29360
- const attrValue = value[i];
29361
- if (attrValue == null || typeof attrValue === "string" || // skip empty props
29362
- keyValue === ELEMENT_PROPS && Object.keys(attrValue).length === 0) {
29432
+ for (const key in value) {
29433
+ const attrValue = value[key];
29434
+ if (attrValue == null || typeof attrValue === "string" || key === ELEMENT_PROPS && isObjectEmpty(attrValue)) {
29363
29435
  continue;
29364
29436
  }
29365
29437
  callback(attrValue);
@@ -29367,7 +29439,7 @@ var discoverValuesForVNodeData = (vnodeData, callback) => {
29367
29439
  }
29368
29440
  }
29369
29441
  };
29370
- var isSsrAttrs = (value) => Array.isArray(value) && value.length > 0;
29442
+ var isSsrAttrs = (value) => typeof value === "object" && value !== null && !isObjectEmpty(value);
29371
29443
  function isObjectLiteral(obj) {
29372
29444
  const prototype = Object.getPrototypeOf(obj);
29373
29445
  return prototype == null || prototype === Object.prototype || prototype === Array.prototype;
@@ -29383,17 +29455,8 @@ function serializeWrappingFn(serializationContext, value) {
29383
29455
  );
29384
29456
  return [syncFnId, value.$args$];
29385
29457
  }
29386
- function filterEffectBackRefs(effectBackRef) {
29387
- let effectBackRefToSerialize = void 0;
29388
- if (effectBackRef) {
29389
- for (const [effectProp, effect] of effectBackRef) {
29390
- if (effect.backRef) {
29391
- effectBackRefToSerialize || (effectBackRefToSerialize = /* @__PURE__ */ new Map());
29392
- effectBackRefToSerialize.set(effectProp, effect);
29393
- }
29394
- }
29395
- }
29396
- return effectBackRefToSerialize;
29458
+ function tryGetBackRefs(props) {
29459
+ return Object.prototype.hasOwnProperty.call(props, QBackRefs) ? props[QBackRefs] : void 0;
29397
29460
  }
29398
29461
  var SerializationWeakRef = class {
29399
29462
  constructor($obj$) {
@@ -29409,26 +29472,41 @@ var SerializationBackRef = class {
29409
29472
  this.$path$ = $path$;
29410
29473
  }
29411
29474
  };
29412
- var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer) => {
29413
- if (!writer) {
29414
- const buffer = [];
29415
- writer = {
29416
- write: (text) => buffer.push(text),
29417
- toString: () => buffer.join("")
29418
- };
29419
- }
29420
- const seenObjsMap = /* @__PURE__ */ new Map();
29421
- const syncFnMap = /* @__PURE__ */ new Map();
29422
- const syncFns = [];
29423
- const roots = [];
29424
- const eagerResume = /* @__PURE__ */ new Set();
29425
- const getSeenRef = (obj) => seenObjsMap.get(obj);
29426
- const $markSeen$ = (obj, parent, index) => {
29475
+ var SerializationContextImpl = class {
29476
+ constructor(NodeConstructor, DomRefConstructor, $symbolToChunkResolver$, $setProp$, $storeProxyMap$, $writer$) {
29477
+ this.NodeConstructor = NodeConstructor;
29478
+ this.DomRefConstructor = DomRefConstructor;
29479
+ this.$symbolToChunkResolver$ = $symbolToChunkResolver$;
29480
+ this.$setProp$ = $setProp$;
29481
+ this.$storeProxyMap$ = $storeProxyMap$;
29482
+ this.$writer$ = $writer$;
29483
+ __publicField(this, "$seenObjsMap$", /* @__PURE__ */ new Map());
29484
+ __publicField(this, "$syncFnMap$", /* @__PURE__ */ new Map());
29485
+ __publicField(this, "$syncFns$", []);
29486
+ __publicField(this, "$roots$", []);
29487
+ __publicField(this, "$eagerResume$", /* @__PURE__ */ new Set());
29488
+ __publicField(this, "$eventQrls$", /* @__PURE__ */ new Set());
29489
+ __publicField(this, "$eventNames$", /* @__PURE__ */ new Set());
29490
+ __publicField(this, "$renderSymbols$", /* @__PURE__ */ new Set());
29491
+ __publicField(this, "$serializer$");
29492
+ this.$serializer$ = new Serializer(this);
29493
+ }
29494
+ async $serialize$() {
29495
+ return await this.$serializer$.serialize();
29496
+ }
29497
+ getSeenRef(obj) {
29498
+ return this.$seenObjsMap$.get(obj);
29499
+ }
29500
+ $markSeen$(obj, parent, index) {
29427
29501
  const ref = { $index$: index, $parent$: parent };
29428
- seenObjsMap.set(obj, ref);
29502
+ this.$seenObjsMap$.set(obj, ref);
29429
29503
  return ref;
29430
- };
29431
- const $getObjectPath$ = (ref) => {
29504
+ }
29505
+ /**
29506
+ * Returns a path string representing the path from roots through all parents to the object.
29507
+ * Format: "3 2 0" where each number is the index within its parent, from root to leaf.
29508
+ */
29509
+ $getObjectPath$(ref) {
29432
29510
  const path = [];
29433
29511
  while (ref.$parent$) {
29434
29512
  path.unshift(ref.$index$);
@@ -29436,86 +29514,85 @@ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToCh
29436
29514
  }
29437
29515
  path.unshift(ref.$index$);
29438
29516
  return path.join(" ");
29439
- };
29440
- const $promoteToRoot$ = (ref, index) => {
29441
- const path = $getObjectPath$(ref);
29517
+ }
29518
+ $promoteToRoot$(ref, index) {
29519
+ const path = this.$getObjectPath$(ref);
29442
29520
  if (index === void 0) {
29443
- index = roots.length;
29521
+ index = this.$roots$.length;
29444
29522
  }
29445
- roots[index] = new SerializationBackRef(path);
29523
+ this.$roots$[index] = new SerializationBackRef(path);
29446
29524
  ref.$parent$ = null;
29447
29525
  ref.$index$ = index;
29448
- };
29449
- const $addRoot$ = ((obj, returnRef) => {
29450
- let seen = seenObjsMap.get(obj);
29526
+ }
29527
+ $addRoot$(obj, returnRef = false) {
29528
+ let seen = this.$seenObjsMap$.get(obj);
29451
29529
  let index;
29452
29530
  if (!seen) {
29453
- index = roots.length;
29531
+ index = this.$roots$.length;
29454
29532
  seen = {
29455
29533
  $index$: index
29456
29534
  // TODO benchmark with and without $parent$
29457
29535
  // $parent$: undefined
29458
29536
  };
29459
- seenObjsMap.set(obj, seen);
29460
- roots.push(obj);
29537
+ this.$seenObjsMap$.set(obj, seen);
29538
+ this.$roots$.push(obj);
29461
29539
  } else {
29462
29540
  if (seen.$parent$) {
29463
- $promoteToRoot$(seen);
29541
+ this.$promoteToRoot$(seen);
29464
29542
  }
29465
29543
  index = seen.$index$;
29466
29544
  }
29467
29545
  return returnRef ? seen : index;
29468
- });
29469
- const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : (() => false);
29470
- isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : (() => false);
29471
- return {
29472
- async $serialize$() {
29473
- return await serialize(this);
29474
- },
29475
- $isSsrNode$: isSsrNode2,
29476
- $isDomRef$: isDomRef,
29477
- $symbolToChunkResolver$: symbolToChunkResolver,
29478
- getSeenRef,
29479
- $roots$: roots,
29480
- $markSeen$,
29481
- $hasRootId$: (obj) => {
29482
- const id = seenObjsMap.get(obj);
29483
- return id && (id.$parent$ ? void 0 : id.$index$);
29484
- },
29485
- $promoteToRoot$,
29486
- $addRoot$,
29487
- $syncFns$: syncFns,
29488
- $addSyncFn$: (funcStr, argCount, fn) => {
29489
- const isFullFn = funcStr == null;
29546
+ }
29547
+ $isSsrNode$(obj) {
29548
+ return this.NodeConstructor ? obj instanceof this.NodeConstructor : false;
29549
+ }
29550
+ $isDomRef$(obj) {
29551
+ return this.DomRefConstructor ? obj instanceof this.DomRefConstructor : false;
29552
+ }
29553
+ $hasRootId$(obj) {
29554
+ const id = this.$seenObjsMap$.get(obj);
29555
+ return id && (id.$parent$ ? void 0 : id.$index$);
29556
+ }
29557
+ $addSyncFn$(funcStr, argCount, fn) {
29558
+ const isFullFn = funcStr == null;
29559
+ if (isFullFn) {
29560
+ funcStr = fn.serialized || fn.toString();
29561
+ }
29562
+ let id = this.$syncFnMap$.get(funcStr);
29563
+ if (id === void 0) {
29564
+ id = this.$syncFns$.length;
29565
+ this.$syncFnMap$.set(funcStr, id);
29490
29566
  if (isFullFn) {
29491
- funcStr = fn.serialized || fn.toString();
29492
- }
29493
- let id = syncFnMap.get(funcStr);
29494
- if (id === void 0) {
29495
- id = syncFns.length;
29496
- syncFnMap.set(funcStr, id);
29497
- if (isFullFn) {
29498
- syncFns.push(funcStr);
29499
- } else {
29500
- let code2 = "(";
29501
- for (let i = 0; i < argCount; i++) {
29502
- code2 += (i == 0 ? "p" : ",p") + i;
29503
- }
29504
- syncFns.push(code2 += ")=>" + funcStr);
29567
+ this.$syncFns$.push(funcStr);
29568
+ } else {
29569
+ let code2 = "(";
29570
+ for (let i = 0; i < argCount; i++) {
29571
+ code2 += (i == 0 ? "p" : ",p") + i;
29505
29572
  }
29573
+ this.$syncFns$.push(code2 += ")=>" + funcStr);
29506
29574
  }
29507
- return id;
29508
- },
29509
- $writer$: writer,
29510
- $eventQrls$: /* @__PURE__ */ new Set(),
29511
- $eventNames$: /* @__PURE__ */ new Set(),
29512
- $renderSymbols$: /* @__PURE__ */ new Set(),
29513
- $storeProxyMap$: storeProxyMap,
29514
- $eagerResume$: eagerResume,
29515
- $resources$: /* @__PURE__ */ new Set(),
29516
- $getProp$: getProp,
29517
- $setProp$: setProp
29518
- };
29575
+ }
29576
+ return id;
29577
+ }
29578
+ };
29579
+ var createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, setProp, storeProxyMap, writer) => {
29580
+ if (!writer) {
29581
+ const buffer = [];
29582
+ writer = {
29583
+ write: (text) => buffer.push(text),
29584
+ toString: () => buffer.join("")
29585
+ };
29586
+ }
29587
+ isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : (() => false);
29588
+ return new SerializationContextImpl(
29589
+ NodeConstructor,
29590
+ DomRefConstructor,
29591
+ symbolToChunkResolver,
29592
+ setProp,
29593
+ storeProxyMap,
29594
+ writer
29595
+ );
29519
29596
  };
29520
29597
 
29521
29598
  // packages/qwik/src/core/shared/shared-container.ts
@@ -29550,7 +29627,6 @@ var _SharedContainer = class {
29550
29627
  NodeConstructor,
29551
29628
  DomRefConstructor,
29552
29629
  symbolToChunkResolver,
29553
- this.getHostProp.bind(this),
29554
29630
  this.setHostProp.bind(this),
29555
29631
  this.$storeProxyMap$,
29556
29632
  writer
@@ -29723,8 +29799,7 @@ var inflate = (container, target, typeId, data) => {
29723
29799
  task.$flags$ = v[1];
29724
29800
  task.$index$ = v[2];
29725
29801
  task.$el$ = v[3];
29726
- task[_EFFECT_BACK_REF] = v[4];
29727
- task.$state$ = v[5];
29802
+ task.$state$ = v[4];
29728
29803
  break;
29729
29804
  case 21 /* Component */:
29730
29805
  target[SERIALIZABLE_STATE][0] = data[0];
@@ -29740,6 +29815,7 @@ var inflate = (container, target, typeId, data) => {
29740
29815
  const storeHandler = getStoreHandler(target);
29741
29816
  storeHandler.$flags$ = flags;
29742
29817
  storeHandler.$effects$ = effects;
29818
+ restoreEffectBackRefForEffectsMap(storeHandler.$effects$, store);
29743
29819
  break;
29744
29820
  }
29745
29821
  case 22 /* Signal */: {
@@ -29747,6 +29823,7 @@ var inflate = (container, target, typeId, data) => {
29747
29823
  const d2 = data;
29748
29824
  signal.$untrackedValue$ = d2[0];
29749
29825
  signal.$effects$ = new Set(d2.slice(1));
29826
+ restoreEffectBackRefForEffects(signal.$effects$, signal);
29750
29827
  break;
29751
29828
  }
29752
29829
  case 23 /* WrappedSignal */: {
@@ -29754,37 +29831,40 @@ var inflate = (container, target, typeId, data) => {
29754
29831
  const d2 = data;
29755
29832
  signal.$func$ = container.getSyncFn(d2[0]);
29756
29833
  signal.$args$ = d2[1];
29757
- signal[_EFFECT_BACK_REF] = d2[2];
29758
29834
  signal.$untrackedValue$ = NEEDS_COMPUTATION;
29759
- signal.$flags$ = d2[3];
29835
+ signal.$flags$ = d2[2];
29760
29836
  signal.$flags$ |= 1 /* INVALID */;
29761
- signal.$hostElement$ = d2[4];
29762
- signal.$effects$ = new Set(d2.slice(5));
29837
+ signal.$hostElement$ = d2[3];
29838
+ signal.$effects$ = new Set(d2.slice(4));
29763
29839
  inflateWrappedSignalValue(signal);
29840
+ restoreEffectBackRefForEffects(signal.$effects$, signal);
29764
29841
  break;
29765
29842
  }
29766
29843
  case 25 /* AsyncSignal */: {
29767
29844
  const asyncSignal = target;
29768
29845
  const d2 = data;
29769
29846
  asyncSignal.$computeQrl$ = d2[0];
29770
- asyncSignal[_EFFECT_BACK_REF] = d2[1];
29771
- asyncSignal.$effects$ = new Set(d2[2]);
29772
- asyncSignal.$loadingEffects$ = new Set(d2[3]);
29773
- asyncSignal.$errorEffects$ = new Set(d2[4]);
29774
- asyncSignal.$untrackedError$ = d2[5];
29847
+ asyncSignal.$effects$ = new Set(d2[1]);
29848
+ asyncSignal.$loadingEffects$ = new Set(d2[2]);
29849
+ asyncSignal.$errorEffects$ = new Set(d2[3]);
29850
+ asyncSignal.$untrackedError$ = d2[4];
29851
+ asyncSignal.$flags$ = d2[5] ?? 0;
29852
+ if (asyncSignal.$flags$ & 64 /* CLIENT_ONLY */) {
29853
+ asyncSignal.$untrackedLoading$ = true;
29854
+ }
29775
29855
  const hasValue = d2.length > 6;
29776
29856
  if (hasValue) {
29777
29857
  asyncSignal.$untrackedValue$ = d2[6];
29778
29858
  }
29779
- if (asyncSignal.$untrackedValue$ !== NEEDS_COMPUTATION) {
29780
- asyncSignal.$flags$ &= ~1 /* INVALID */;
29859
+ if (asyncSignal.$untrackedValue$ === NEEDS_COMPUTATION) {
29860
+ asyncSignal.$flags$ |= 1 /* INVALID */;
29781
29861
  }
29782
29862
  asyncSignal.interval = d2[7] ?? 0;
29783
29863
  asyncSignal.$concurrency$ = d2[8] ?? 1;
29784
29864
  asyncSignal.$timeoutMs$ = d2[9] ?? 0;
29785
- if (d2[10]) {
29786
- asyncSignal.$flags$ |= 32 /* EAGER_CLEANUP */;
29787
- }
29865
+ restoreEffectBackRefForEffects(asyncSignal.$effects$, asyncSignal);
29866
+ restoreEffectBackRefForEffects(asyncSignal.$loadingEffects$, asyncSignal);
29867
+ restoreEffectBackRefForEffects(asyncSignal.$errorEffects$, asyncSignal);
29788
29868
  break;
29789
29869
  }
29790
29870
  // Inflating a SerializerSignal is the same as inflating a ComputedSignal
@@ -29796,17 +29876,17 @@ var inflate = (container, target, typeId, data) => {
29796
29876
  const p = computed.$computeQrl$.resolve(container).catch(() => {
29797
29877
  });
29798
29878
  loading = loading.finally(() => p);
29799
- computed[_EFFECT_BACK_REF] = d2[1];
29800
- if (d2[2]) {
29801
- computed.$effects$ = new Set(d2[2]);
29879
+ if (d2[1]) {
29880
+ computed.$effects$ = new Set(d2[1]);
29802
29881
  }
29803
- const hasValue = d2.length > 3;
29882
+ const hasValue = d2.length > 2;
29804
29883
  if (hasValue) {
29805
- computed.$untrackedValue$ = d2[3];
29884
+ computed.$untrackedValue$ = d2[2];
29806
29885
  }
29807
29886
  if (typeId !== 26 /* SerializerSignal */ && computed.$untrackedValue$ !== NEEDS_COMPUTATION) {
29808
29887
  computed.$flags$ &= ~1 /* INVALID */;
29809
29888
  }
29889
+ restoreEffectBackRefForEffects(computed.$effects$, computed);
29810
29890
  break;
29811
29891
  }
29812
29892
  case 15 /* Error */: {
@@ -29880,7 +29960,9 @@ var inflate = (container, target, typeId, data) => {
29880
29960
  owner._proxy = propsProxy;
29881
29961
  }
29882
29962
  propsProxy[_OWNER] = owner;
29883
- propsProxy[_PROPS_HANDLER].$effects$ = d[3];
29963
+ const propsHandler = propsProxy[_PROPS_HANDLER];
29964
+ propsHandler.$effects$ = d[3];
29965
+ restoreEffectBackRefForEffectsMap(propsHandler.$effects$, propsProxy);
29884
29966
  break;
29885
29967
  case 31 /* SubscriptionData */: {
29886
29968
  const effectData = target;
@@ -29893,8 +29975,8 @@ var inflate = (container, target, typeId, data) => {
29893
29975
  const d2 = data;
29894
29976
  effectSub.consumer = d2[0];
29895
29977
  effectSub.property = d2[1];
29896
- effectSub.backRef = d2[2];
29897
- effectSub.data = d2[3];
29978
+ effectSub.data = d2[2];
29979
+ restoreEffectBackRefForConsumer(effectSub);
29898
29980
  break;
29899
29981
  }
29900
29982
  default:
@@ -29943,6 +30025,31 @@ function inflateWrappedSignalValue(signal) {
29943
30025
  }
29944
30026
  }
29945
30027
  }
30028
+ function restoreEffectBackRefForConsumer(effect) {
30029
+ var _a6;
30030
+ const isServerSide = import.meta.env.TEST ? isServerPlatform() : isServer9;
30031
+ const consumerBackRef = effect.consumer;
30032
+ if (isServerSide && !consumerBackRef) {
30033
+ return;
30034
+ }
30035
+ consumerBackRef[_a6 = _EFFECT_BACK_REF] || (consumerBackRef[_a6] = /* @__PURE__ */ new Map());
30036
+ consumerBackRef[_EFFECT_BACK_REF].set(effect.property, effect);
30037
+ }
30038
+ function restoreEffectBackRefForEffects(effects, consumer) {
30039
+ if (effects) {
30040
+ for (const effect of effects) {
30041
+ effect.backRef || (effect.backRef = /* @__PURE__ */ new Set());
30042
+ effect.backRef.add(consumer);
30043
+ }
30044
+ }
30045
+ }
30046
+ function restoreEffectBackRefForEffectsMap(effectsMap, consumer) {
30047
+ if (effectsMap) {
30048
+ for (const [, effects] of effectsMap) {
30049
+ restoreEffectBackRefForEffects(effects, consumer);
30050
+ }
30051
+ }
30052
+ }
29946
30053
 
29947
30054
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
29948
30055
  var _captures = null;
@@ -30010,7 +30117,7 @@ var makeResolveFunction = (qrl, symbolFn) => {
30010
30117
  }
30011
30118
  }
30012
30119
  if (qrl.$chunk$ === "") {
30013
- isDev17 && assertDefined(qrl.$container$, "Sync QRL must have container element");
30120
+ isDev18 && assertDefined(qrl.$container$, "Sync QRL must have container element");
30014
30121
  const hash3 = qrl.$container$.$instanceHash$;
30015
30122
  const doc2 = qrl.$container$.element?.ownerDocument || document;
30016
30123
  const qFuncs2 = getQFuncs(doc2, hash3);
@@ -30114,8 +30221,8 @@ var createQRL = (chunk, symbol, symbolRef, symbolFn, captures) => {
30114
30221
  })
30115
30222
  );
30116
30223
  }
30117
- if (isBrowser2 && symbol) {
30118
- preload(symbol, 0.8);
30224
+ if (isBrowser2 && chunk) {
30225
+ preload(chunk, 0.8);
30119
30226
  }
30120
30227
  return qrl;
30121
30228
  };
@@ -30177,6 +30284,10 @@ var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
30177
30284
  constProps[attr] = constProps[k];
30178
30285
  }
30179
30286
  delete constProps[k];
30287
+ } else if (k === BIND_CHECKED) {
30288
+ bindCheckedSignal = constProps[k];
30289
+ } else if (k === BIND_VALUE) {
30290
+ bindValueSignal = constProps[k];
30180
30291
  }
30181
30292
  processedKeys.add(k);
30182
30293
  }
@@ -30202,40 +30313,59 @@ var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
30202
30313
  }
30203
30314
  processedKeys.add(k);
30204
30315
  }
30205
- if (bindCheckedSignal || bindValueSignal) {
30206
- if (!varPropsCopied) {
30207
- varProps = { ...varProps };
30208
- varPropsCopied = true;
30209
- }
30210
- if (bindCheckedSignal) {
30316
+ }
30317
+ if (bindCheckedSignal || bindValueSignal) {
30318
+ if (!varPropsCopied) {
30319
+ varProps = { ...varProps };
30320
+ varPropsCopied = true;
30321
+ }
30322
+ varProps || (varProps = {});
30323
+ if (bindCheckedSignal) {
30324
+ if (varProps && _hasOwnProperty3.call(varProps, BIND_CHECKED)) {
30211
30325
  delete varProps[BIND_CHECKED];
30212
- varProps.checked = bindCheckedSignal;
30213
- const handler = createQRL(null, "_chk", _chk, null, [bindCheckedSignal]);
30214
- if (constProps && _hasOwnProperty3.call(constProps, "q-e:input")) {
30215
- if (!constPropsCopied) {
30216
- constProps = { ...constProps };
30217
- constPropsCopied = true;
30218
- }
30219
- const existingHandler = constProps["q-e:input"];
30220
- delete constProps["q-e:input"];
30221
- toSort = mergeHandlers(varProps, "q-e:input", existingHandler) || toSort;
30222
- }
30223
- toSort = mergeHandlers(varProps, "q-e:input", handler) || toSort;
30224
- } else if (bindValueSignal) {
30326
+ }
30327
+ if (constProps && _hasOwnProperty3.call(constProps, BIND_CHECKED)) {
30328
+ if (!constPropsCopied) {
30329
+ constProps = { ...constProps };
30330
+ constPropsCopied = true;
30331
+ }
30332
+ delete constProps[BIND_CHECKED];
30333
+ }
30334
+ varProps.checked = bindCheckedSignal;
30335
+ const handler = createQRL(null, "_chk", _chk, null, [bindCheckedSignal]);
30336
+ if (constProps && _hasOwnProperty3.call(constProps, "q-e:input")) {
30337
+ if (!constPropsCopied) {
30338
+ constProps = { ...constProps };
30339
+ constPropsCopied = true;
30340
+ }
30341
+ const existingHandler = constProps["q-e:input"];
30342
+ delete constProps["q-e:input"];
30343
+ toSort = mergeHandlers(varProps, "q-e:input", existingHandler) || toSort;
30344
+ }
30345
+ toSort = mergeHandlers(varProps, "q-e:input", handler) || toSort;
30346
+ } else if (bindValueSignal) {
30347
+ if (varProps && _hasOwnProperty3.call(varProps, BIND_VALUE)) {
30225
30348
  delete varProps[BIND_VALUE];
30226
- varProps.value = bindValueSignal;
30227
- const handler = createQRL(null, "_val", _val, null, [bindValueSignal]);
30228
- if (constProps && _hasOwnProperty3.call(constProps, "q-e:input")) {
30229
- if (!constPropsCopied) {
30230
- constProps = { ...constProps };
30231
- constPropsCopied = true;
30232
- }
30233
- const existingHandler = constProps["q-e:input"];
30234
- delete constProps["q-e:input"];
30235
- toSort = mergeHandlers(varProps, "q-e:input", existingHandler) || toSort;
30349
+ }
30350
+ if (constProps && _hasOwnProperty3.call(constProps, BIND_VALUE)) {
30351
+ if (!constPropsCopied) {
30352
+ constProps = { ...constProps };
30353
+ constPropsCopied = true;
30354
+ }
30355
+ delete constProps[BIND_VALUE];
30356
+ }
30357
+ varProps.value = bindValueSignal;
30358
+ const handler = createQRL(null, "_val", _val, null, [bindValueSignal]);
30359
+ if (constProps && _hasOwnProperty3.call(constProps, "q-e:input")) {
30360
+ if (!constPropsCopied) {
30361
+ constProps = { ...constProps };
30362
+ constPropsCopied = true;
30236
30363
  }
30237
- toSort = mergeHandlers(varProps, "q-e:input", handler) || toSort;
30364
+ const existingHandler = constProps["q-e:input"];
30365
+ delete constProps["q-e:input"];
30366
+ toSort = mergeHandlers(varProps, "q-e:input", existingHandler) || toSort;
30238
30367
  }
30368
+ toSort = mergeHandlers(varProps, "q-e:input", handler) || toSort;
30239
30369
  }
30240
30370
  }
30241
30371
  if (varProps && _hasOwnProperty3.call(varProps, "className")) {
@@ -30484,7 +30614,6 @@ function processVNodeData(document2) {
30484
30614
  const getNodeType = getter(prototype, "nodeType");
30485
30615
  const attachVnodeDataAndRefs = (element) => {
30486
30616
  Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script2) => {
30487
- script2.setAttribute("type", "x-qwik/vnode");
30488
30617
  const qContainerElement = script2.closest("[q\\:container]");
30489
30618
  qContainerElement.qVnodeData = script2.textContent;
30490
30619
  qContainerElement.qVNodeRefs = /* @__PURE__ */ new Map();
@@ -30783,9 +30912,14 @@ var DomContainer = class extends _SharedContainer {
30783
30912
  $hoistStyles$() {
30784
30913
  const document2 = this.element.ownerDocument;
30785
30914
  const head = document2.head;
30786
- const styles = document2.querySelectorAll(QStylesAllSelector);
30787
- for (let i = 0; i < styles.length; i++) {
30788
- head.appendChild(styles[i]);
30915
+ const styles = document2.body.querySelectorAll(QStylesAllSelector);
30916
+ const styleTagCount = styles.length;
30917
+ if (styleTagCount) {
30918
+ const fragment = document2.createDocumentFragment();
30919
+ for (let i = 0; i < styleTagCount; i++) {
30920
+ fragment.appendChild(styles[i]);
30921
+ }
30922
+ head.appendChild(fragment);
30789
30923
  }
30790
30924
  }
30791
30925
  $setRawState$(id, vParent) {
@@ -30904,7 +31038,7 @@ var DomContainer = class extends _SharedContainer {
30904
31038
  }
30905
31039
  getSyncFn(id) {
30906
31040
  const fn = this.$qFuncs$[id];
30907
- isDev18 && assertTrue(typeof fn === "function", "Invalid reference: " + id);
31041
+ isDev19 && assertTrue(typeof fn === "function", "Invalid reference: " + id);
30908
31042
  return fn;
30909
31043
  }
30910
31044
  $appendStyle$(content, styleId, host, scoped) {
@@ -30946,11 +31080,283 @@ var DomContainer = class extends _SharedContainer {
30946
31080
  }
30947
31081
  };
30948
31082
 
31083
+ // packages/qwik/src/core/preloader/queue.ts
31084
+ import { isBrowser as isBrowser4 } from "@qwik.dev/core/build";
31085
+
31086
+ // packages/qwik/src/core/preloader/constants.ts
31087
+ import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
31088
+ var doc = isBrowser3 ? document : void 0;
31089
+ var config = {
31090
+ $DEBUG$: false,
31091
+ $maxIdlePreloads$: 25,
31092
+ $invPreloadProbability$: 0.65
31093
+ };
31094
+ var rel = isBrowser3 && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
31095
+ var loadStart = Date.now();
31096
+ var isJSRegex = /\.[mc]?js$/;
31097
+
31098
+ // packages/qwik/src/core/preloader/types.ts
31099
+ var BundleImportState_None = 0;
31100
+ var BundleImportState_Queued = 1;
31101
+ var BundleImportState_Preload = 2;
31102
+ var BundleImportState_Alias = 3;
31103
+ var BundleImportState_Loaded = 4;
31104
+
31105
+ // packages/qwik/src/core/preloader/bundle-graph.ts
31106
+ var base;
31107
+ var graph;
31108
+ var makeBundle = (name, deps) => {
31109
+ return {
31110
+ $name$: name,
31111
+ $state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
31112
+ $deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
31113
+ $inverseProbability$: 1,
31114
+ $createdTs$: Date.now(),
31115
+ $waitedMs$: 0,
31116
+ $loadedMs$: 0
31117
+ };
31118
+ };
31119
+ var parseBundleGraph = (serialized) => {
31120
+ const graph2 = /* @__PURE__ */ new Map();
31121
+ let i = 0;
31122
+ while (i < serialized.length) {
31123
+ const name = serialized[i++];
31124
+ const deps = [];
31125
+ let idx;
31126
+ let probability = 1;
31127
+ while (idx = serialized[i], typeof idx === "number") {
31128
+ if (idx < 0) {
31129
+ probability = -idx / 10;
31130
+ } else {
31131
+ deps.push({
31132
+ $name$: serialized[idx],
31133
+ $importProbability$: probability,
31134
+ $factor$: 1
31135
+ });
31136
+ }
31137
+ i++;
31138
+ }
31139
+ graph2.set(name, deps);
31140
+ }
31141
+ return graph2;
31142
+ };
31143
+ var getBundle = (name) => {
31144
+ let bundle = bundles.get(name);
31145
+ if (!bundle) {
31146
+ let deps;
31147
+ if (graph) {
31148
+ deps = graph.get(name);
31149
+ if (!deps) {
31150
+ return;
31151
+ }
31152
+ if (!deps.length) {
31153
+ deps = void 0;
31154
+ }
31155
+ }
31156
+ bundle = makeBundle(name, deps);
31157
+ bundles.set(name, bundle);
31158
+ }
31159
+ return bundle;
31160
+ };
31161
+ var initPreloader = (serializedBundleGraph, opts) => {
31162
+ if (opts) {
31163
+ if ("debug" in opts) {
31164
+ config.$DEBUG$ = !!opts.debug;
31165
+ }
31166
+ if (typeof opts.preloadProbability === "number") {
31167
+ config.$invPreloadProbability$ = 1 - opts.preloadProbability;
31168
+ }
31169
+ }
31170
+ if (base != null || !serializedBundleGraph) {
31171
+ return;
31172
+ }
31173
+ base = "";
31174
+ graph = parseBundleGraph(serializedBundleGraph);
31175
+ };
31176
+
31177
+ // packages/qwik/src/core/preloader/queue.ts
31178
+ var bundles = /* @__PURE__ */ new Map();
31179
+ var shouldResetFactor;
31180
+ var queueDirty;
31181
+ var preloadCount = 0;
31182
+ var queue = [];
31183
+ var log5 = (...args) => {
31184
+ console.log(
31185
+ `Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
31186
+ ...args
31187
+ );
31188
+ };
31189
+ var resetQueue = () => {
31190
+ bundles.clear();
31191
+ queueDirty = false;
31192
+ shouldResetFactor = true;
31193
+ preloadCount = 0;
31194
+ queue.length = 0;
31195
+ };
31196
+ var sortQueue = () => {
31197
+ if (queueDirty) {
31198
+ queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
31199
+ queueDirty = false;
31200
+ }
31201
+ };
31202
+ var getQueue = () => {
31203
+ sortQueue();
31204
+ let probability = 0.4;
31205
+ const result2 = [];
31206
+ for (const b of queue) {
31207
+ const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
31208
+ if (nextProbability !== probability) {
31209
+ probability = nextProbability;
31210
+ result2.push(probability);
31211
+ }
31212
+ result2.push(b.$name$);
31213
+ }
31214
+ return result2;
31215
+ };
31216
+ var trigger = () => {
31217
+ if (!queue.length) {
31218
+ return;
31219
+ }
31220
+ sortQueue();
31221
+ while (queue.length) {
31222
+ const bundle = queue[0];
31223
+ const inverseProbability = bundle.$inverseProbability$;
31224
+ const probability = 1 - inverseProbability;
31225
+ const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
31226
+ // While the graph is not available, we limit to 5 preloads
31227
+ 5
31228
+ );
31229
+ if (probability >= 0.99 || preloadCount < allowedPreloads) {
31230
+ queue.shift();
31231
+ preloadOne(bundle);
31232
+ } else {
31233
+ break;
31234
+ }
31235
+ }
31236
+ if (config.$DEBUG$ && !queue.length) {
31237
+ const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
31238
+ const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
31239
+ const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
31240
+ log5(
31241
+ `>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
31242
+ );
31243
+ }
31244
+ };
31245
+ var preloadOne = (bundle) => {
31246
+ if (bundle.$state$ >= BundleImportState_Preload) {
31247
+ return;
31248
+ }
31249
+ preloadCount++;
31250
+ const start = Date.now();
31251
+ bundle.$waitedMs$ = start - bundle.$createdTs$;
31252
+ bundle.$state$ = BundleImportState_Preload;
31253
+ config.$DEBUG$ && log5(
31254
+ `<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
31255
+ bundle.$name$
31256
+ );
31257
+ const link = doc.createElement("link");
31258
+ link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
31259
+ link.rel = rel;
31260
+ link.as = "script";
31261
+ link.onload = link.onerror = () => {
31262
+ preloadCount--;
31263
+ const end = Date.now();
31264
+ bundle.$loadedMs$ = end - start;
31265
+ bundle.$state$ = BundleImportState_Loaded;
31266
+ config.$DEBUG$ && log5(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
31267
+ link.remove();
31268
+ trigger();
31269
+ };
31270
+ doc.head.appendChild(link);
31271
+ };
31272
+ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
31273
+ if (seen?.has(bundle)) {
31274
+ return;
31275
+ }
31276
+ const previousInverseProbability = bundle.$inverseProbability$;
31277
+ bundle.$inverseProbability$ = newInverseProbability;
31278
+ if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
31279
+ return;
31280
+ }
31281
+ if (
31282
+ // don't queue until we have initialized the preloader
31283
+ base != null && bundle.$state$ < BundleImportState_Preload
31284
+ ) {
31285
+ if (bundle.$state$ === BundleImportState_None) {
31286
+ bundle.$state$ = BundleImportState_Queued;
31287
+ queue.push(bundle);
31288
+ config.$DEBUG$ && log5(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
31289
+ }
31290
+ queueDirty = true;
31291
+ }
31292
+ if (bundle.$deps$) {
31293
+ seen || (seen = /* @__PURE__ */ new Set());
31294
+ seen.add(bundle);
31295
+ const probability = 1 - bundle.$inverseProbability$;
31296
+ for (const dep of bundle.$deps$) {
31297
+ const depBundle = getBundle(dep.$name$);
31298
+ if (depBundle.$inverseProbability$ === 0) {
31299
+ continue;
31300
+ }
31301
+ let newInverseProbability2;
31302
+ if (probability === 1 || probability >= 0.99 && depsCount < 100) {
31303
+ depsCount++;
31304
+ newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
31305
+ } else {
31306
+ const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
31307
+ const prevAdjust = dep.$factor$;
31308
+ const factor = newInverseImportProbability / prevAdjust;
31309
+ newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
31310
+ dep.$factor$ = factor;
31311
+ }
31312
+ adjustProbabilities(depBundle, newInverseProbability2, seen);
31313
+ }
31314
+ }
31315
+ };
31316
+ var handleBundle = (name, inverseProbability) => {
31317
+ const bundle = getBundle(name);
31318
+ if (bundle && bundle.$inverseProbability$ > inverseProbability) {
31319
+ adjustProbabilities(bundle, inverseProbability);
31320
+ }
31321
+ };
31322
+ var depsCount;
31323
+ var preload2 = (name, probability) => {
31324
+ if (!name?.length) {
31325
+ return;
31326
+ }
31327
+ depsCount = 0;
31328
+ let inverseProbability = probability ? 1 - probability : 0.4;
31329
+ if (Array.isArray(name)) {
31330
+ for (let i = name.length - 1; i >= 0; i--) {
31331
+ const item = name[i];
31332
+ if (typeof item === "number") {
31333
+ inverseProbability = 1 - item / 10;
31334
+ } else {
31335
+ handleBundle(item, inverseProbability);
31336
+ }
31337
+ }
31338
+ } else {
31339
+ handleBundle(name, inverseProbability);
31340
+ }
31341
+ if (isBrowser4) {
31342
+ trigger();
31343
+ }
31344
+ };
31345
+ if (isBrowser4) {
31346
+ document.addEventListener("qsymbol", (ev) => {
31347
+ const { symbol, href } = ev.detail;
31348
+ if (href) {
31349
+ const hash3 = symbol.slice(symbol.lastIndexOf("_") + 1);
31350
+ preload2(hash3, 1);
31351
+ }
31352
+ });
31353
+ }
31354
+
30949
31355
  // packages/qwik/src/core/use/use-locale.ts
30950
- import { isServer as isServer9 } from "@qwik.dev/core/build";
31356
+ import { isServer as isServer10 } from "@qwik.dev/core/build";
30951
31357
  var _locale = void 0;
30952
31358
  var localAsyncStore;
30953
- if (isServer9) {
31359
+ if (isServer10) {
30954
31360
  import("node:async_hooks").then((module) => {
30955
31361
  localAsyncStore = new module.AsyncLocalStorage();
30956
31362
  }).catch(() => {
@@ -30966,14 +31372,7 @@ function setLocale(locale) {
30966
31372
 
30967
31373
  // packages/qwik/src/core/index.ts
30968
31374
  if (globalThis.__qwik) {
30969
- console.error(
30970
- `==============================================
30971
- Qwik version ${globalThis.__qwik} already imported while importing ${version}.
30972
- This can lead to issues due to duplicated shared structures.
30973
- Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude".
30974
- ==============================================
30975
- `
30976
- );
31375
+ qError(30 /* duplicateQwik */, [globalThis.__qwik, version]);
30977
31376
  }
30978
31377
  globalThis.__qwik = version;
30979
31378
  if (import.meta.hot) {
@@ -30992,8 +31391,8 @@ var useInvokeContext = () => {
30992
31391
  if (!ctx || ctx.$event$ !== RenderEvent) {
30993
31392
  throw qError(10 /* useInvokeContext */);
30994
31393
  }
30995
- isDev19 && assertDefined(ctx.$hostElement$, `invoke: $hostElement$ must be defined`, ctx);
30996
- isDev19 && assertDefined(ctx.$effectSubscriber$, `invoke: $effectSubscriber$ must be defined`, ctx);
31394
+ isDev20 && assertDefined(ctx.$hostElement$, `invoke: $hostElement$ must be defined`, ctx);
31395
+ isDev20 && assertDefined(ctx.$effectSubscriber$, `invoke: $effectSubscriber$ must be defined`, ctx);
30997
31396
  return ctx;
30998
31397
  };
30999
31398
  function invoke(context, fn, ...args) {
@@ -31081,9 +31480,9 @@ var trackSignalAndAssignHost = (value, host, property, container, data) => {
31081
31480
  };
31082
31481
 
31083
31482
  // packages/qwik/src/core/reactive-primitives/impl/store.ts
31084
- import { isDev as isDev20, isServer as isServer10 } from "@qwik.dev/core/build";
31483
+ import { isDev as isDev21, isServer as isServer11 } from "@qwik.dev/core/build";
31085
31484
  var DEBUG7 = false;
31086
- var log5 = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
31485
+ var log6 = (...args) => console.log("STORE", ...args.map(qwikDebugToString));
31087
31486
  var getStoreHandler = (value) => {
31088
31487
  return value[STORE_HANDLER];
31089
31488
  };
@@ -31142,7 +31541,7 @@ var StoreHandler2 = class {
31142
31541
  }
31143
31542
  this.$container$ = ctx.$container$;
31144
31543
  } else {
31145
- isDev20 && assertTrue(
31544
+ isDev21 && assertTrue(
31146
31545
  !ctx.$container$ || ctx.$container$ === this.$container$,
31147
31546
  "Do not use signals across containers"
31148
31547
  );
@@ -31176,11 +31575,11 @@ var StoreHandler2 = class {
31176
31575
  if (prop in target) {
31177
31576
  const oldValue = target[prop];
31178
31577
  if (newValue !== oldValue) {
31179
- DEBUG7 && log5("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
31578
+ DEBUG7 && log6("Store.set", oldValue, "->", newValue, pad("\n" + this.toString(), " "));
31180
31579
  setNewValueAndTriggerEffects(prop, newValue, target, this);
31181
31580
  }
31182
31581
  } else {
31183
- DEBUG7 && log5("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
31582
+ DEBUG7 && log6("Store.set", "create property", newValue, pad("\n" + this.toString(), " "));
31184
31583
  setNewValueAndTriggerEffects(prop, newValue, target, this);
31185
31584
  }
31186
31585
  return true;
@@ -31245,8 +31644,8 @@ function addStoreEffect(target, prop, store, effectSubscription) {
31245
31644
  }
31246
31645
  ensureContainsSubscription(effects, effectSubscription);
31247
31646
  ensureContainsBackRef(effectSubscription, target);
31248
- (import.meta.env.TEST ? !isDomContainer(store.$container$) : isServer10) && addQrlToSerializationCtx(effectSubscription, store.$container$);
31249
- DEBUG7 && log5(
31647
+ (import.meta.env.TEST ? !isDomContainer(store.$container$) : isServer11) && addQrlToSerializationCtx(effectSubscription, store.$container$);
31648
+ DEBUG7 && log6(
31250
31649
  "sub",
31251
31650
  pad(
31252
31651
  "\n" + [...store.$effects$?.entries() || []].map(([key, value]) => `${String(key)}: ${String(value)}`).join(","),
@@ -31483,13 +31882,13 @@ function preprocessState(data, container) {
31483
31882
  }
31484
31883
 
31485
31884
  // packages/qwik/src/core/shared/serdes/serdes.public.ts
31486
- import { isDev as isDev21 } from "@qwik.dev/core/build";
31885
+ import { isDev as isDev22 } from "@qwik.dev/core/build";
31487
31886
  function getObjectById(id, stateData) {
31488
31887
  if (typeof id === "string") {
31489
31888
  id = parseInt(id, 10);
31490
31889
  return stateData[id];
31491
31890
  }
31492
- isDev21 && assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`);
31891
+ isDev22 && assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`);
31493
31892
  return stateData[id];
31494
31893
  }
31495
31894
 
@@ -31580,15 +31979,15 @@ var shouldSerialize = (obj) => {
31580
31979
  return true;
31581
31980
  };
31582
31981
  var fastSkipSerialize = (obj) => {
31583
- return !!obj && (isObject(obj) || typeof obj === "function") && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
31982
+ return !!obj && (isObject(obj) || typeof obj === "function") && (noSerializeSet.has(obj) || NoSerializeSymbol in obj);
31584
31983
  };
31585
31984
  var NoSerializeSymbol = /* @__PURE__ */ Symbol("noSerialize");
31586
31985
  var SerializerSymbol = /* @__PURE__ */ Symbol("serialize");
31587
31986
 
31588
31987
  // packages/qwik/src/core/reactive-primitives/utils.ts
31589
- import { isDev as isDev22, isServer as isServer11 } from "@qwik.dev/core/build";
31988
+ import { isDev as isDev23, isServer as isServer12 } from "@qwik.dev/core/build";
31590
31989
  var DEBUG8 = false;
31591
- var log6 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
31990
+ var log7 = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
31592
31991
  var throwIfQRLNotResolved = (qrl) => {
31593
31992
  const resolved = qrl.resolved;
31594
31993
  if (!resolved) {
@@ -31622,12 +32021,12 @@ var addQrlToSerializationCtx = (effectSubscriber, container) => {
31622
32021
  }
31623
32022
  };
31624
32023
  var scheduleEffects = (container, signal, effects) => {
31625
- const isBrowser5 = import.meta.env.TEST ? !isServerPlatform() : !isServer11;
32024
+ const isBrowser5 = import.meta.env.TEST ? !isServerPlatform() : !isServer12;
31626
32025
  if (effects) {
31627
32026
  const scheduleEffect = (effectSubscription) => {
31628
32027
  const consumer = effectSubscription.consumer;
31629
32028
  const property = effectSubscription.property;
31630
- isDev22 && assertDefined(container, "Container must be defined.");
32029
+ isDev23 && assertDefined(container, "Container must be defined.");
31631
32030
  if (isTask(consumer)) {
31632
32031
  consumer.$flags$ |= 4 /* DIRTY */;
31633
32032
  markVNodeDirty(container, consumer.$el$, 1 /* TASKS */);
@@ -31669,7 +32068,7 @@ var scheduleEffects = (container, signal, effects) => {
31669
32068
  scheduleEffect(effect);
31670
32069
  }
31671
32070
  }
31672
- DEBUG8 && log6("done scheduling");
32071
+ DEBUG8 && log7("done scheduling");
31673
32072
  };
31674
32073
  var isSerializerObj = (obj) => {
31675
32074
  return isObject(obj) && typeof obj[SerializerSymbol] === "function";
@@ -31799,7 +32198,7 @@ var fastGetter = (prototype, name) => {
31799
32198
 
31800
32199
  // packages/qwik/src/core/client/vnode-utils.ts
31801
32200
  var vnode_newElement = (element, elementName, key = null) => {
31802
- isDev23 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
32201
+ isDev24 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
31803
32202
  const vnode = new ElementVNode(
31804
32203
  key,
31805
32204
  1 /* Element */ | 8 /* Inflated */ | -1 << 11 /* shift */,
@@ -31817,7 +32216,7 @@ var vnode_newElement = (element, elementName, key = null) => {
31817
32216
  return vnode;
31818
32217
  };
31819
32218
  var vnode_newUnMaterializedElement = (element) => {
31820
- isDev23 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
32219
+ isDev24 && assertEqual(fastNodeType(element), 1, "Expecting element node.");
31821
32220
  const vnode = new ElementVNode(
31822
32221
  null,
31823
32222
  1 /* Element */ | -1 << 11 /* shift */,
@@ -31835,7 +32234,7 @@ var vnode_newUnMaterializedElement = (element) => {
31835
32234
  return vnode;
31836
32235
  };
31837
32236
  var vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
31838
- isDev23 && sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
32237
+ isDev24 && sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
31839
32238
  const vnode = new TextVNode(
31840
32239
  4 /* Text */ | -1 << 11 /* shift */,
31841
32240
  // Flag
@@ -31867,10 +32266,10 @@ var vnode_newText = (textNode, textContent) => {
31867
32266
  textContent
31868
32267
  // Text Content
31869
32268
  );
31870
- isDev23 && assertEqual(fastNodeType(textNode), 3, "Expecting text node.");
31871
- isDev23 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
31872
- isDev23 && assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
31873
- isDev23 && assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
32269
+ isDev24 && assertEqual(fastNodeType(textNode), 3, "Expecting text node.");
32270
+ isDev24 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
32271
+ isDev24 && assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
32272
+ isDev24 && assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
31874
32273
  return vnode;
31875
32274
  };
31876
32275
  var vnode_newVirtual = () => {
@@ -31885,9 +32284,9 @@ var vnode_newVirtual = () => {
31885
32284
  null,
31886
32285
  null
31887
32286
  );
31888
- isDev23 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
31889
- isDev23 && assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
31890
- isDev23 && assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
32287
+ isDev24 && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode.");
32288
+ isDev24 && assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode.");
32289
+ isDev24 && assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode.");
31891
32290
  return vnode;
31892
32291
  };
31893
32292
  var vnode_isVNode = (vNode) => {
@@ -31897,12 +32296,12 @@ var vnode_isElementVNode = (vNode) => {
31897
32296
  return (vNode.flags & 1 /* Element */) === 1 /* Element */;
31898
32297
  };
31899
32298
  var vnode_isElementOrTextVNode = (vNode) => {
31900
- isDev23 && assertDefined(vNode, "Missing vNode");
32299
+ isDev24 && assertDefined(vNode, "Missing vNode");
31901
32300
  const flag = vNode.flags;
31902
32301
  return (flag & 5 /* ELEMENT_OR_TEXT_MASK */) !== 0;
31903
32302
  };
31904
32303
  var vnode_isMaterialized = (vNode) => {
31905
- isDev23 && assertDefined(vNode, "Missing vNode");
32304
+ isDev24 && assertDefined(vNode, "Missing vNode");
31906
32305
  const flag = vNode.flags;
31907
32306
  return (flag & 1 /* Element */) === 1 /* Element */ && vNode.firstChild !== void 0 && vNode.lastChild !== void 0;
31908
32307
  };
@@ -31913,26 +32312,26 @@ var vnode_isVirtualVNode = (vNode) => {
31913
32312
  return (vNode.flags & 2 /* Virtual */) === 2 /* Virtual */;
31914
32313
  };
31915
32314
  var vnode_isProjection = (vNode) => {
31916
- isDev23 && assertDefined(vNode, "Missing vNode");
32315
+ isDev24 && assertDefined(vNode, "Missing vNode");
31917
32316
  const flag = vNode.flags;
31918
32317
  return (flag & 2 /* Virtual */) === 2 /* Virtual */ && vnode_getProp(vNode, QSlot, null) !== null;
31919
32318
  };
31920
32319
  var ensureTextVNode = (vNode) => {
31921
- isDev23 && assertTrue(
32320
+ isDev24 && assertTrue(
31922
32321
  vnode_isTextVNode(vNode),
31923
32322
  "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)
31924
32323
  );
31925
32324
  return vNode;
31926
32325
  };
31927
32326
  var ensureElementOrVirtualVNode = (vNode) => {
31928
- isDev23 && assertDefined(vNode, "Missing vNode");
31929
- isDev23 && assertTrue(
32327
+ isDev24 && assertDefined(vNode, "Missing vNode");
32328
+ isDev24 && assertTrue(
31930
32329
  (vNode.flags & 3 /* ELEMENT_OR_VIRTUAL_MASK */) !== 0,
31931
32330
  "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode)
31932
32331
  );
31933
32332
  };
31934
32333
  var ensureElementVNode = (vNode) => {
31935
- isDev23 && assertTrue(
32334
+ isDev24 && assertTrue(
31936
32335
  vnode_isElementVNode(vNode),
31937
32336
  "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)
31938
32337
  );
@@ -32168,7 +32567,7 @@ var vnode_ensureTextInflated = (journal, vnode) => {
32168
32567
  const flags = textVNode.flags;
32169
32568
  if ((flags & 8 /* Inflated */) === 0) {
32170
32569
  const parentNode = vnode_getDomParent(vnode, true);
32171
- isDev23 && assertDefined(parentNode, "Missing parent node.");
32570
+ isDev24 && assertDefined(parentNode, "Missing parent node.");
32172
32571
  const sharedTextNode = textVNode.node;
32173
32572
  const doc2 = fastOwnerDocument(parentNode);
32174
32573
  let vCursor = vnode_getDomSibling(vnode, false, true);
@@ -32217,7 +32616,7 @@ var vnode_locate = (rootVNode, id) => {
32217
32616
  let elementOffset = -1;
32218
32617
  let refElement;
32219
32618
  if (typeof id === "string") {
32220
- isDev23 && assertDefined(qVNodeRefs, "Missing qVNodeRefs.");
32619
+ isDev24 && assertDefined(qVNodeRefs, "Missing qVNodeRefs.");
32221
32620
  elementOffset = parseInt(id);
32222
32621
  refElement = qVNodeRefs.get(elementOffset);
32223
32622
  } else {
@@ -32227,9 +32626,9 @@ var vnode_locate = (rootVNode, id) => {
32227
32626
  return vNode2;
32228
32627
  }
32229
32628
  }
32230
- isDev23 && assertDefined(refElement, "Missing refElement.");
32629
+ isDev24 && assertDefined(refElement, "Missing refElement.");
32231
32630
  if (!vnode_isVNode(refElement)) {
32232
- isDev23 && assertTrue(
32631
+ isDev24 && assertTrue(
32233
32632
  containerElement2.contains(refElement),
32234
32633
  `Couldn't find the element inside the container while locating the VNode.`
32235
32634
  );
@@ -32273,10 +32672,10 @@ var vnode_locate = (rootVNode, id) => {
32273
32672
  };
32274
32673
  var vnode_getChildWithIdx = (vNode, childIdx) => {
32275
32674
  let child = vnode_getFirstChild(vNode);
32276
- isDev23 && assertDefined(child, "Missing child.");
32675
+ isDev24 && assertDefined(child, "Missing child.");
32277
32676
  while (child.flags >>> 11 /* shift */ !== childIdx) {
32278
32677
  child = child.nextSibling;
32279
- isDev23 && assertDefined(child, "Missing child.");
32678
+ isDev24 && assertDefined(child, "Missing child.");
32280
32679
  }
32281
32680
  return child;
32282
32681
  };
@@ -32284,7 +32683,7 @@ var vNodeStack = [];
32284
32683
  var vnode_getVNodeForChildNode = (vNode, childElement) => {
32285
32684
  ensureElementVNode(vNode);
32286
32685
  let child = vnode_getFirstChild(vNode);
32287
- isDev23 && assertDefined(child, "Missing child.");
32686
+ isDev24 && assertDefined(child, "Missing child.");
32288
32687
  while (child && (child instanceof ElementVNode ? child.node !== childElement : true)) {
32289
32688
  if (vnode_isVirtualVNode(child)) {
32290
32689
  const next = child.nextSibling;
@@ -32303,13 +32702,13 @@ var vnode_getVNodeForChildNode = (vNode, childElement) => {
32303
32702
  child = next || vNodeStack.pop();
32304
32703
  }
32305
32704
  }
32306
- isDev23 && assertDefined(child, "Missing child.");
32705
+ isDev24 && assertDefined(child, "Missing child.");
32307
32706
  }
32308
32707
  while (vNodeStack.length) {
32309
32708
  vNodeStack.pop();
32310
32709
  }
32311
32710
  ensureElementVNode(child);
32312
- isDev23 && assertEqual(child.node, childElement, "Child not found.");
32711
+ isDev24 && assertEqual(child.node, childElement, "Child not found.");
32313
32712
  return child;
32314
32713
  };
32315
32714
  var indexOfAlphanumeric = (id, length) => {
@@ -32551,7 +32950,7 @@ var vnode_getDomParentVNode = (vnode, includeProjection) => {
32551
32950
  return vnode;
32552
32951
  };
32553
32952
  var vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
32554
- isDev23 && assertEqual(vParent, vToRemove.parent, "Parent mismatch.");
32953
+ isDev24 && assertEqual(vParent, vToRemove.parent, "Parent mismatch.");
32555
32954
  if (vnode_isTextVNode(vToRemove)) {
32556
32955
  vnode_ensureTextInflated(journal, vToRemove);
32557
32956
  }
@@ -32584,7 +32983,7 @@ var vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
32584
32983
  vToRemove.nextSibling = null;
32585
32984
  };
32586
32985
  var vnode_truncate = (journal, vParent, vDelete, removeDOM = true) => {
32587
- isDev23 && assertDefined(vDelete, "Missing vDelete.");
32986
+ isDev24 && assertDefined(vDelete, "Missing vDelete.");
32588
32987
  const parent = vnode_getDomParent(vParent, true);
32589
32988
  if (parent && removeDOM) {
32590
32989
  if (vnode_isElementOrTextVNode(vParent)) {
@@ -32678,8 +33077,8 @@ var ensureMaterialized = (vnode) => {
32678
33077
  vFirstChild = vnode_materialize(vParent);
32679
33078
  }
32680
33079
  }
32681
- isDev23 && assertTrue(vParent.firstChild !== void 0, "Did not materialize.");
32682
- isDev23 && assertTrue(vParent.lastChild !== void 0, "Did not materialize.");
33080
+ isDev24 && assertTrue(vParent.firstChild !== void 0, "Did not materialize.");
33081
+ isDev24 && assertTrue(vParent.lastChild !== void 0, "Did not materialize.");
32683
33082
  return vFirstChild;
32684
33083
  };
32685
33084
  var _fastHasAttribute = null;
@@ -32854,7 +33253,7 @@ var materializeFromDOM = (vParent, firstChild, vData) => {
32854
33253
  }
32855
33254
  const id = consumeValue();
32856
33255
  container.$setRawState$(parseInt(id), vParent);
32857
- isDev23 && vnode_setProp(vParent, ELEMENT_ID, id);
33256
+ isDev24 && vnode_setProp(vParent, ELEMENT_ID, id);
32858
33257
  } else if (peek() === VNodeDataChar.BACK_REFS) {
32859
33258
  if (!container) {
32860
33259
  container = getDomContainer(vParent.node);
@@ -33111,6 +33510,15 @@ function materializeFromVNodeData(vParent, vData, element, child) {
33111
33510
  vnode_ensureElementKeyInflated(elementVNode);
33112
33511
  addVNode(elementVNode);
33113
33512
  child = fastNextSibling(child);
33513
+ while (
33514
+ // skip only elements, not text nodes
33515
+ isElement(child) && shouldSkipElement(child)
33516
+ ) {
33517
+ child = fastNextSibling(child);
33518
+ if (!child && value > 0) {
33519
+ throw qError(27 /* materializeVNodeDataError */, [vData, peek(), nextToConsumeIdx]);
33520
+ }
33521
+ }
33114
33522
  }
33115
33523
  } else if (peek() === VNodeDataChar.SCOPED_STYLE) {
33116
33524
  vnode_setProp(vParent, QScopedStyle, consumeValue());
@@ -33123,7 +33531,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
33123
33531
  }
33124
33532
  const id = consumeValue();
33125
33533
  container.$setRawState$(parseInt(id), vParent);
33126
- isDev23 && vnode_setProp(vParent, ELEMENT_ID, id);
33534
+ isDev24 && vnode_setProp(vParent, ELEMENT_ID, id);
33127
33535
  } else if (peek() === VNodeDataChar.PROPS) {
33128
33536
  vnode_setProp(vParent, ELEMENT_PROPS, consumeValue());
33129
33537
  } else if (peek() === VNodeDataChar.KEY) {
@@ -33832,10 +34240,7 @@ function diffJsxVNode(received, expected, path = [], container, isSsr) {
33832
34240
  return [path.join(" > ") + " missing"];
33833
34241
  }
33834
34242
  if (!container.qContainer) {
33835
- try {
33836
- _getDomContainer(container);
33837
- } catch {
33838
- }
34243
+ _getDomContainer(container);
33839
34244
  }
33840
34245
  const diffs = [];
33841
34246
  if (typeof expected === "string") {
@@ -34210,7 +34615,7 @@ var ElementFixture = class {
34210
34615
  }
34211
34616
  }
34212
34617
  };
34213
- async function trigger(root, queryOrElement, eventName, eventPayload = {}, options) {
34618
+ async function trigger2(root, queryOrElement, eventName, eventPayload = {}, options) {
34214
34619
  const waitForIdle = options?.waitForIdle ?? true;
34215
34620
  let scope;
34216
34621
  let kebabName;
@@ -34273,14 +34678,12 @@ var dispatch = async (element, event, scopedKebabName, kebabName) => {
34273
34678
  if ("_qDispatch" in element) {
34274
34679
  const handlers = element._qDispatch?.[scopedKebabName];
34275
34680
  if (handlers) {
34276
- if (Array.isArray(handlers)) {
34277
- for (const handler of handlers.flat(2)) {
34681
+ if (handlers.length) {
34682
+ for (const handler of handlers) {
34278
34683
  if (handler) {
34279
34684
  await handler(event, element);
34280
34685
  }
34281
34686
  }
34282
- } else {
34283
- await handlers(event, element);
34284
34687
  }
34285
34688
  }
34286
34689
  } else if (element.hasAttribute("q-" + scopedKebabName)) {
@@ -34405,7 +34808,7 @@ var createDOM = async function({ html } = {}) {
34405
34808
  },
34406
34809
  screen: host,
34407
34810
  userEvent: async function(queryOrElement, eventNameCamel, eventPayload = {}) {
34408
- return trigger(host, queryOrElement, eventNameCamel, eventPayload);
34811
+ return trigger2(host, queryOrElement, eventNameCamel, eventPayload);
34409
34812
  }
34410
34813
  };
34411
34814
  };
@@ -34434,281 +34837,9 @@ import { join } from "path";
34434
34837
  import { fileURLToPath as fileURLToPath2 } from "url";
34435
34838
  import { expect as expect2 } from "vitest";
34436
34839
 
34437
- // packages/qwik/src/core/preloader/queue.ts
34438
- import { isBrowser as isBrowser4 } from "@qwik.dev/core/build";
34439
-
34440
- // packages/qwik/src/core/preloader/constants.ts
34441
- import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
34442
- var doc = isBrowser3 ? document : void 0;
34443
- var config = {
34444
- $DEBUG$: false,
34445
- $maxIdlePreloads$: 25,
34446
- $invPreloadProbability$: 0.65
34447
- };
34448
- var rel = isBrowser3 && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
34449
- var loadStart = Date.now();
34450
- var isJSRegex = /\.[mc]?js$/;
34451
-
34452
- // packages/qwik/src/core/preloader/types.ts
34453
- var BundleImportState_None = 0;
34454
- var BundleImportState_Queued = 1;
34455
- var BundleImportState_Preload = 2;
34456
- var BundleImportState_Alias = 3;
34457
- var BundleImportState_Loaded = 4;
34458
-
34459
- // packages/qwik/src/core/preloader/bundle-graph.ts
34460
- var base;
34461
- var graph;
34462
- var makeBundle = (name, deps) => {
34463
- return {
34464
- $name$: name,
34465
- $state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
34466
- $deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
34467
- $inverseProbability$: 1,
34468
- $createdTs$: Date.now(),
34469
- $waitedMs$: 0,
34470
- $loadedMs$: 0
34471
- };
34472
- };
34473
- var parseBundleGraph = (serialized) => {
34474
- const graph2 = /* @__PURE__ */ new Map();
34475
- let i = 0;
34476
- while (i < serialized.length) {
34477
- const name = serialized[i++];
34478
- const deps = [];
34479
- let idx;
34480
- let probability = 1;
34481
- while (idx = serialized[i], typeof idx === "number") {
34482
- if (idx < 0) {
34483
- probability = -idx / 10;
34484
- } else {
34485
- deps.push({
34486
- $name$: serialized[idx],
34487
- $importProbability$: probability,
34488
- $factor$: 1
34489
- });
34490
- }
34491
- i++;
34492
- }
34493
- graph2.set(name, deps);
34494
- }
34495
- return graph2;
34496
- };
34497
- var getBundle = (name) => {
34498
- let bundle = bundles.get(name);
34499
- if (!bundle) {
34500
- let deps;
34501
- if (graph) {
34502
- deps = graph.get(name);
34503
- if (!deps) {
34504
- return;
34505
- }
34506
- if (!deps.length) {
34507
- deps = void 0;
34508
- }
34509
- }
34510
- bundle = makeBundle(name, deps);
34511
- bundles.set(name, bundle);
34512
- }
34513
- return bundle;
34514
- };
34515
- var initPreloader = (serializedBundleGraph, opts) => {
34516
- if (opts) {
34517
- if ("debug" in opts) {
34518
- config.$DEBUG$ = !!opts.debug;
34519
- }
34520
- if (typeof opts.preloadProbability === "number") {
34521
- config.$invPreloadProbability$ = 1 - opts.preloadProbability;
34522
- }
34523
- }
34524
- if (base != null || !serializedBundleGraph) {
34525
- return;
34526
- }
34527
- base = "";
34528
- graph = parseBundleGraph(serializedBundleGraph);
34529
- };
34530
-
34531
- // packages/qwik/src/core/preloader/queue.ts
34532
- var bundles = /* @__PURE__ */ new Map();
34533
- var shouldResetFactor;
34534
- var queueDirty;
34535
- var preloadCount = 0;
34536
- var queue = [];
34537
- var log7 = (...args) => {
34538
- console.log(
34539
- `Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
34540
- ...args
34541
- );
34542
- };
34543
- var resetQueue = () => {
34544
- bundles.clear();
34545
- queueDirty = false;
34546
- shouldResetFactor = true;
34547
- preloadCount = 0;
34548
- queue.length = 0;
34549
- };
34550
- var sortQueue = () => {
34551
- if (queueDirty) {
34552
- queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
34553
- queueDirty = false;
34554
- }
34555
- };
34556
- var getQueue = () => {
34557
- sortQueue();
34558
- let probability = 0.4;
34559
- const result2 = [];
34560
- for (const b of queue) {
34561
- const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
34562
- if (nextProbability !== probability) {
34563
- probability = nextProbability;
34564
- result2.push(probability);
34565
- }
34566
- result2.push(b.$name$);
34567
- }
34568
- return result2;
34569
- };
34570
- var trigger2 = () => {
34571
- if (!queue.length) {
34572
- return;
34573
- }
34574
- sortQueue();
34575
- while (queue.length) {
34576
- const bundle = queue[0];
34577
- const inverseProbability = bundle.$inverseProbability$;
34578
- const probability = 1 - inverseProbability;
34579
- const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
34580
- // While the graph is not available, we limit to 5 preloads
34581
- 5
34582
- );
34583
- if (probability >= 0.99 || preloadCount < allowedPreloads) {
34584
- queue.shift();
34585
- preloadOne(bundle);
34586
- } else {
34587
- break;
34588
- }
34589
- }
34590
- if (config.$DEBUG$ && !queue.length) {
34591
- const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
34592
- const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
34593
- const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
34594
- log7(
34595
- `>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
34596
- );
34597
- }
34598
- };
34599
- var preloadOne = (bundle) => {
34600
- if (bundle.$state$ >= BundleImportState_Preload) {
34601
- return;
34602
- }
34603
- preloadCount++;
34604
- const start = Date.now();
34605
- bundle.$waitedMs$ = start - bundle.$createdTs$;
34606
- bundle.$state$ = BundleImportState_Preload;
34607
- config.$DEBUG$ && log7(
34608
- `<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
34609
- bundle.$name$
34610
- );
34611
- const link = doc.createElement("link");
34612
- link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
34613
- link.rel = rel;
34614
- link.as = "script";
34615
- link.onload = link.onerror = () => {
34616
- preloadCount--;
34617
- const end = Date.now();
34618
- bundle.$loadedMs$ = end - start;
34619
- bundle.$state$ = BundleImportState_Loaded;
34620
- config.$DEBUG$ && log7(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
34621
- link.remove();
34622
- trigger2();
34623
- };
34624
- doc.head.appendChild(link);
34625
- };
34626
- var adjustProbabilities = (bundle, newInverseProbability, seen) => {
34627
- if (seen?.has(bundle)) {
34628
- return;
34629
- }
34630
- const previousInverseProbability = bundle.$inverseProbability$;
34631
- bundle.$inverseProbability$ = newInverseProbability;
34632
- if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
34633
- return;
34634
- }
34635
- if (
34636
- // don't queue until we have initialized the preloader
34637
- base != null && bundle.$state$ < BundleImportState_Preload
34638
- ) {
34639
- if (bundle.$state$ === BundleImportState_None) {
34640
- bundle.$state$ = BundleImportState_Queued;
34641
- queue.push(bundle);
34642
- config.$DEBUG$ && log7(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
34643
- }
34644
- queueDirty = true;
34645
- }
34646
- if (bundle.$deps$) {
34647
- seen || (seen = /* @__PURE__ */ new Set());
34648
- seen.add(bundle);
34649
- const probability = 1 - bundle.$inverseProbability$;
34650
- for (const dep of bundle.$deps$) {
34651
- const depBundle = getBundle(dep.$name$);
34652
- if (depBundle.$inverseProbability$ === 0) {
34653
- continue;
34654
- }
34655
- let newInverseProbability2;
34656
- if (probability === 1 || probability >= 0.99 && depsCount < 100) {
34657
- depsCount++;
34658
- newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
34659
- } else {
34660
- const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
34661
- const prevAdjust = dep.$factor$;
34662
- const factor = newInverseImportProbability / prevAdjust;
34663
- newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
34664
- dep.$factor$ = factor;
34665
- }
34666
- adjustProbabilities(depBundle, newInverseProbability2, seen);
34667
- }
34668
- }
34669
- };
34670
- var handleBundle = (name, inverseProbability) => {
34671
- const bundle = getBundle(name);
34672
- if (bundle && bundle.$inverseProbability$ > inverseProbability) {
34673
- adjustProbabilities(bundle, inverseProbability);
34674
- }
34675
- };
34676
- var depsCount;
34677
- var preload2 = (name, probability) => {
34678
- if (!name?.length) {
34679
- return;
34680
- }
34681
- depsCount = 0;
34682
- let inverseProbability = probability ? 1 - probability : 0.4;
34683
- if (Array.isArray(name)) {
34684
- for (let i = name.length - 1; i >= 0; i--) {
34685
- const item = name[i];
34686
- if (typeof item === "number") {
34687
- inverseProbability = 1 - item / 10;
34688
- } else {
34689
- handleBundle(item, inverseProbability);
34690
- }
34691
- }
34692
- } else {
34693
- handleBundle(name, inverseProbability);
34694
- }
34695
- if (isBrowser4) {
34696
- trigger2();
34697
- }
34698
- };
34699
- if (isBrowser4) {
34700
- document.addEventListener("qsymbol", (ev) => {
34701
- const { symbol, href } = ev.detail;
34702
- if (href) {
34703
- const hash3 = symbol.slice(symbol.lastIndexOf("_") + 1);
34704
- preload2(hash3, 1);
34705
- }
34706
- });
34707
- }
34708
-
34709
34840
  // packages/qwik/src/server/platform.ts
34710
34841
  import { setPlatform as setPlatform2 } from "../core.mjs";
34711
- import { isDev as isDev24 } from "@qwik.dev/core/build";
34842
+ import { isDev as isDev25 } from "@qwik.dev/core/build";
34712
34843
  var getDevSegmentPath = (mapper, hash3, symbolName, parent) => {
34713
34844
  const existing = mapper?.[hash3];
34714
34845
  if (existing) {
@@ -34730,9 +34861,9 @@ var getDevSegmentPath = (mapper, hash3, symbolName, parent) => {
34730
34861
  function createPlatform3(opts, resolvedManifest) {
34731
34862
  const mapper = resolvedManifest?.mapper;
34732
34863
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
34733
- if (mapper || isDev24 && import.meta.env.MODE !== "test") {
34864
+ if (mapper || isDev25 && import.meta.env.MODE !== "test") {
34734
34865
  const hash3 = getSymbolHash2(symbolName);
34735
- const result2 = !isDev24 ? mapper[hash3] : getDevSegmentPath(mapper, hash3, symbolName, parent);
34866
+ const result2 = !isDev25 ? mapper[hash3] : getDevSegmentPath(mapper, hash3, symbolName, parent);
34736
34867
  if (!result2) {
34737
34868
  if (hash3 === SYNC_QRL) {
34738
34869
  return [hash3, ""];
@@ -34817,16 +34948,16 @@ var versions = {
34817
34948
  };
34818
34949
 
34819
34950
  // packages/qwik/src/server/ssr-container.ts
34820
- import { isDev as isDev26 } from "@qwik.dev/core/build";
34951
+ import { isDev as isDev27 } from "@qwik.dev/core/build";
34821
34952
  import {
34822
- _createQRL as createQRL2,
34823
- _qrlToString as qrlToString2,
34824
- _res,
34825
34953
  _SubscriptionData as SubscriptionData2,
34826
34954
  _SharedContainer as _SharedContainer2,
34827
34955
  _jsxSorted as _jsxSorted2,
34828
34956
  _jsxSplit as _jsxSplit2,
34957
+ _res,
34958
+ _setEvent,
34829
34959
  _walkJSX,
34960
+ _createQRL as createQRL2,
34830
34961
  isSignal as isSignal3
34831
34962
  } from "@qwik.dev/core/internal";
34832
34963
 
@@ -34957,39 +35088,44 @@ var preloaderPre = (container, options, nonce) => {
34957
35088
  }
34958
35089
  }
34959
35090
  const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
34960
- const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
35091
+ const preloaderLinkAttrs = {
35092
+ rel: "modulepreload",
35093
+ href: preloaderBundle
35094
+ };
34961
35095
  if (nonce) {
34962
- preloaderLinkAttrs.push("nonce", nonce);
35096
+ preloaderLinkAttrs["nonce"] = nonce;
34963
35097
  }
34964
- container.openElement("link", null, preloaderLinkAttrs);
35098
+ container.openElement("link", null, preloaderLinkAttrs, null, null, null);
34965
35099
  container.closeElement();
34966
- container.openElement("link", null, [
34967
- "rel",
34968
- "preload",
34969
- "href",
34970
- bundleGraphPath,
34971
- "as",
34972
- "fetch",
34973
- "crossorigin",
34974
- "anonymous"
34975
- ]);
35100
+ container.openElement(
35101
+ "link",
35102
+ null,
35103
+ { rel: "preload", href: bundleGraphPath, as: "fetch", crossorigin: "anonymous" },
35104
+ null,
35105
+ null,
35106
+ null
35107
+ );
34976
35108
  container.closeElement();
34977
35109
  const script2 = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
34978
- const scriptAttrs = ["type", "module", "async", true, "crossorigin", "anonymous"];
35110
+ const scriptAttrs = {
35111
+ type: "module",
35112
+ async: true,
35113
+ crossorigin: "anonymous"
35114
+ };
34979
35115
  if (nonce) {
34980
- scriptAttrs.push("nonce", nonce);
35116
+ scriptAttrs["nonce"] = nonce;
34981
35117
  }
34982
- container.openElement("script", null, scriptAttrs);
35118
+ container.openElement("script", null, scriptAttrs, null, null, null);
34983
35119
  container.write(script2);
34984
35120
  container.closeElement();
34985
35121
  }
34986
35122
  const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
34987
35123
  if (corePath) {
34988
- const linkAttrs = ["rel", "modulepreload", "href", corePath];
35124
+ const linkAttrs = { rel: "modulepreload", href: corePath };
34989
35125
  if (nonce) {
34990
- linkAttrs.push("nonce", nonce);
35126
+ linkAttrs["nonce"] = nonce;
34991
35127
  }
34992
- container.openElement("link", null, linkAttrs);
35128
+ container.openElement("link", null, linkAttrs, null, null, null);
34993
35129
  container.closeElement();
34994
35130
  }
34995
35131
  };
@@ -35041,11 +35177,11 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
35041
35177
  script2 += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
35042
35178
  }
35043
35179
  if (script2) {
35044
- const attrs = ["type", "module", "async", true, "q:type", "preload"];
35180
+ const attrs = { type: "module", async: "true", "q:type": "preload" };
35045
35181
  if (nonce) {
35046
- attrs.push("nonce", nonce);
35182
+ attrs["nonce"] = nonce;
35047
35183
  }
35048
- container.openElement("script", null, attrs);
35184
+ container.openElement("script", null, attrs, null, null, null);
35049
35185
  container.write(script2);
35050
35186
  container.closeElement();
35051
35187
  }
@@ -35087,8 +35223,12 @@ function getQwikBackpatchExecutorScript(opts = {}) {
35087
35223
  }
35088
35224
 
35089
35225
  // packages/qwik/src/server/ssr-node.ts
35090
- import { _isJSXNode as isJSXNode2, _EMPTY_ARRAY, _EFFECT_BACK_REF as _EFFECT_BACK_REF2 } from "@qwik.dev/core/internal";
35091
- import { isDev as isDev25 } from "@qwik.dev/core/build";
35226
+ import {
35227
+ _isJSXNode as isJSXNode2,
35228
+ _EMPTY_OBJ,
35229
+ _EFFECT_BACK_REF as _EFFECT_BACK_REF2
35230
+ } from "@qwik.dev/core/internal";
35231
+ import { isDev as isDev26 } from "@qwik.dev/core/build";
35092
35232
  var SsrNode = class {
35093
35233
  constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
35094
35234
  this.parentComponent = parentComponent;
@@ -35111,9 +35251,9 @@ var SsrNode = class {
35111
35251
  __publicField(this, "localProps", null);
35112
35252
  this.id = id;
35113
35253
  this.flags = 1 /* Updatable */;
35114
- this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_ARRAY;
35254
+ this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
35115
35255
  this.parentComponent?.addChild(this);
35116
- if (isDev25 && id.indexOf("undefined") != -1) {
35256
+ if (isDev26 && id.indexOf("undefined") != -1) {
35117
35257
  throw new Error(`Invalid SSR node id: ${id}`);
35118
35258
  }
35119
35259
  }
@@ -35121,13 +35261,13 @@ var SsrNode = class {
35121
35261
  return this.getProp(QBackRefs);
35122
35262
  }
35123
35263
  setProp(name, value) {
35124
- if (this.attrs === _EMPTY_ARRAY) {
35264
+ if (this.attrs === _EMPTY_OBJ) {
35125
35265
  this.setEmptyArrayAsVNodeDataAttributes();
35126
35266
  }
35127
35267
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
35128
- mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
35268
+ (this.localProps || (this.localProps = {}))[name] = value;
35129
35269
  } else {
35130
- mapArray_set(this.attrs, name, value, 0);
35270
+ this.attrs[name] = value;
35131
35271
  }
35132
35272
  if (name == ELEMENT_SEQ && value) {
35133
35273
  this.cleanupQueue.push(value);
@@ -35135,29 +35275,29 @@ var SsrNode = class {
35135
35275
  }
35136
35276
  setEmptyArrayAsVNodeDataAttributes() {
35137
35277
  if (this.attributesIndex >= 0) {
35138
- this.vnodeData[this.attributesIndex] = [];
35278
+ this.vnodeData[this.attributesIndex] = {};
35139
35279
  this.attrs = this.vnodeData[this.attributesIndex];
35140
35280
  } else {
35141
35281
  const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
35142
- this.vnodeData.splice(newAttributesIndex, 0, []);
35282
+ this.vnodeData.splice(newAttributesIndex, 0, {});
35143
35283
  this.attributesIndex = newAttributesIndex;
35144
35284
  this.attrs = this.vnodeData[this.attributesIndex];
35145
35285
  }
35146
35286
  }
35147
35287
  getProp(name) {
35148
35288
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
35149
- return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
35289
+ return this.localProps ? this.localProps[name] ?? null : null;
35150
35290
  } else {
35151
- return mapArray_get(this.attrs, name, 0);
35291
+ return this.attrs[name] ?? null;
35152
35292
  }
35153
35293
  }
35154
35294
  removeProp(name) {
35155
35295
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
35156
35296
  if (this.localProps) {
35157
- mapApp_remove(this.localProps, name, 0);
35297
+ delete this.localProps[name];
35158
35298
  }
35159
35299
  } else {
35160
- mapApp_remove(this.attrs, name, 0);
35300
+ delete this.attrs[name];
35161
35301
  }
35162
35302
  }
35163
35303
  addChild(child) {
@@ -35177,16 +35317,13 @@ var SsrNode = class {
35177
35317
  }
35178
35318
  }
35179
35319
  toString() {
35180
- if (isDev25) {
35320
+ if (isDev26) {
35181
35321
  let stringifiedAttrs = "";
35182
- for (let i = 0; i < this.attrs.length; i += 2) {
35183
- const key = this.attrs[i];
35184
- const value = this.attrs[i + 1];
35322
+ for (const key in this.attrs) {
35323
+ const value = this.attrs[key];
35185
35324
  stringifiedAttrs += `${key}=`;
35186
35325
  stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
35187
- if (i < this.attrs.length - 2) {
35188
- stringifiedAttrs += ", ";
35189
- }
35326
+ stringifiedAttrs += ", ";
35190
35327
  }
35191
35328
  return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
35192
35329
  } else {
@@ -35295,7 +35432,7 @@ function vNodeData_closeFragment(vNodeData) {
35295
35432
  vNodeData.push(CLOSE_FRAGMENT);
35296
35433
  }
35297
35434
  function vNodeData_openElement(vNodeData) {
35298
- vNodeData.push([], WRITE_ELEMENT_ATTRS);
35435
+ vNodeData.push({}, WRITE_ELEMENT_ATTRS);
35299
35436
  vNodeData[0] |= 4 /* ELEMENT_NODE */;
35300
35437
  }
35301
35438
  function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
@@ -35304,7 +35441,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
35304
35441
  let attributesIndex = -1;
35305
35442
  for (let i = 1; i < vNodeData.length; i++) {
35306
35443
  const value = vNodeData[i];
35307
- if (Array.isArray(value)) {
35444
+ if (typeof value === "object" && value !== null) {
35308
35445
  attributesIndex = i;
35309
35446
  i++;
35310
35447
  if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
@@ -35320,7 +35457,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
35320
35457
  stack2[stack2.length - 1]++;
35321
35458
  }
35322
35459
  }
35323
- let refId = String(depthFirstElementIdx);
35460
+ let refId = depthFirstElementIdx + "";
35324
35461
  if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
35325
35462
  for (let i = 0; i < stack2.length; i++) {
35326
35463
  const childCount = stack2[i];
@@ -35364,6 +35501,7 @@ function ssrCreateContainer(opts) {
35364
35501
  return new SSRContainer({
35365
35502
  tagName: opts.tagName || "div",
35366
35503
  writer: opts.writer || new StringBufferWriter(),
35504
+ streamHandler: opts.streamHandler,
35367
35505
  locale: opts.locale || "",
35368
35506
  timing: opts.timing || {
35369
35507
  firstFlush: 0,
@@ -35393,12 +35531,17 @@ var StringBufferWriter = class {
35393
35531
  }
35394
35532
  };
35395
35533
  var EMPTY_OBJ2 = {};
35534
+ var QTemplateProps = {
35535
+ hidden: true,
35536
+ "aria-hidden": true
35537
+ };
35396
35538
  var SSRContainer = class extends _SharedContainer2 {
35397
35539
  constructor(opts) {
35398
35540
  super(opts.renderOptions.serverData ?? EMPTY_OBJ2, opts.locale);
35399
35541
  __publicField(this, "tag");
35400
35542
  __publicField(this, "isHtml");
35401
35543
  __publicField(this, "writer");
35544
+ __publicField(this, "streamHandler");
35402
35545
  __publicField(this, "timing");
35403
35546
  __publicField(this, "size", 0);
35404
35547
  __publicField(this, "resolvedManifest");
@@ -35435,6 +35578,7 @@ var SSRContainer = class extends _SharedContainer2 {
35435
35578
  __publicField(this, "vNodeDatas", []);
35436
35579
  __publicField(this, "componentStack", []);
35437
35580
  __publicField(this, "cleanupQueue", []);
35581
+ __publicField(this, "emitContainerDataFrame", null);
35438
35582
  __publicField(this, "$instanceHash$", hash2());
35439
35583
  // Temporary flag to find missing roots after the state was serialized
35440
35584
  __publicField(this, "$noMoreRoots$", false);
@@ -35456,6 +35600,7 @@ var SSRContainer = class extends _SharedContainer2 {
35456
35600
  this.tag = opts.tagName;
35457
35601
  this.isHtml = opts.tagName === "html";
35458
35602
  this.writer = opts.writer;
35603
+ this.streamHandler = opts.streamHandler;
35459
35604
  this.timing = opts.timing;
35460
35605
  this.$buildBase$ = opts.buildBase;
35461
35606
  this.resolvedManifest = opts.resolvedManifest;
@@ -35539,27 +35684,23 @@ var SSRContainer = class extends _SharedContainer2 {
35539
35684
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
35540
35685
  containerAttributes[QRuntimeAttr] = "2";
35541
35686
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
35542
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev26 ? "ssr-dev" : "ssr");
35687
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev27 ? "ssr-dev" : "ssr");
35543
35688
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
35544
35689
  containerAttributes[QLocaleAttr] = this.$locale$;
35545
35690
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
35546
35691
  containerAttributes[QInstanceAttr] = this.$instanceHash$;
35547
35692
  this.$serverData$.containerAttributes = containerAttributes;
35548
- const containerAttributeArray = Object.entries(containerAttributes).reduce(
35549
- (acc, [key, value]) => {
35550
- acc.push(key, value);
35551
- return acc;
35552
- },
35553
- []
35554
- );
35555
- this.openElement(this.tag, null, containerAttributeArray);
35693
+ this.openElement(this.tag, null, containerAttributes);
35694
+ if (!this.isHtml) {
35695
+ this.emitContainerDataFrame = this.currentElementFrame;
35696
+ }
35556
35697
  }
35557
35698
  /** Renders closing tag for current container */
35558
35699
  closeContainer() {
35559
35700
  return this.closeElement();
35560
35701
  }
35561
35702
  /** Renders opening tag for DOM element */
35562
- openElement(elementName, key, varAttrs, constAttrs, currentFile) {
35703
+ openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null) {
35563
35704
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
35564
35705
  if (
35565
35706
  // don't append qwik loader before qwik style elements
@@ -35578,23 +35719,26 @@ var SSRContainer = class extends _SharedContainer2 {
35578
35719
  vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
35579
35720
  }
35580
35721
  this.createAndPushFrame(elementName, this.depthFirstElementCount++, currentFile);
35722
+ if (this.isHtml && elementName === "body" && this.emitContainerDataFrame === null) {
35723
+ this.emitContainerDataFrame = this.currentElementFrame;
35724
+ }
35581
35725
  vNodeData_openElement(this.currentElementFrame.vNodeData);
35582
- this.write("<");
35726
+ this.write(LT);
35583
35727
  this.write(elementName);
35584
35728
  const lastNode = this.getOrCreateLastNode();
35585
35729
  if (varAttrs) {
35586
- innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
35730
+ innerHTML = this.writeAttrs(elementName, varAttrs, false, styleScopedId, currentFile);
35587
35731
  }
35588
35732
  this.write(" " + Q_PROPS_SEPARATOR);
35589
35733
  if (key !== null) {
35590
35734
  this.write(`="${key}"`);
35591
- } else if (isDev26) {
35592
- this.write('=""');
35735
+ } else if (import.meta.env.TEST) {
35736
+ this.write(EMPTY_ATTR);
35593
35737
  }
35594
- if (constAttrs && constAttrs.length) {
35595
- innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
35738
+ if (constAttrs && !isObjectEmpty(constAttrs)) {
35739
+ innerHTML = this.writeAttrs(elementName, constAttrs, true, styleScopedId, currentFile) || innerHTML;
35596
35740
  }
35597
- this.write(">");
35741
+ this.write(GT);
35598
35742
  if (lastNode) {
35599
35743
  lastNode.setTreeNonUpdatable();
35600
35744
  }
@@ -35602,7 +35746,8 @@ var SSRContainer = class extends _SharedContainer2 {
35602
35746
  }
35603
35747
  /** Renders closing tag for DOM element */
35604
35748
  closeElement() {
35605
- if (this.shouldEmitDataBeforeClosingElement()) {
35749
+ if (this.currentElementFrame === this.emitContainerDataFrame) {
35750
+ this.emitContainerDataFrame = null;
35606
35751
  this.onRenderDone();
35607
35752
  const snapshotTimer = createTimer();
35608
35753
  return maybeThen(
@@ -35614,16 +35759,6 @@ var SSRContainer = class extends _SharedContainer2 {
35614
35759
  }
35615
35760
  this._closeElement();
35616
35761
  }
35617
- shouldEmitDataBeforeClosingElement() {
35618
- const currentFrame = this.currentElementFrame;
35619
- return (
35620
- /**
35621
- * - Micro-frontends don't have html tag, emit data before closing custom element
35622
- * - Regular applications should emit data inside body
35623
- */
35624
- currentFrame.parent === null && currentFrame.elementName !== "html" || currentFrame.elementName === "body"
35625
- );
35626
- }
35627
35762
  onRenderDone() {
35628
35763
  this.drainCleanupQueue();
35629
35764
  this.timing.render = this.renderTimer();
@@ -35645,9 +35780,9 @@ var SSRContainer = class extends _SharedContainer2 {
35645
35780
  const currentFrame = this.popFrame();
35646
35781
  const elementName = currentFrame.elementName;
35647
35782
  if (!isSelfClosingTag(elementName)) {
35648
- this.write("</");
35783
+ this.write(CLOSE_TAG);
35649
35784
  this.write(elementName);
35650
- this.write(">");
35785
+ this.write(GT);
35651
35786
  }
35652
35787
  this.lastNode = null;
35653
35788
  if (this.qlInclude === 1 /* Inline */) {
@@ -35718,13 +35853,13 @@ var SSRContainer = class extends _SharedContainer2 {
35718
35853
  if (componentFrame.slots.length === 0) {
35719
35854
  return;
35720
35855
  }
35721
- this.openElement(QTemplate, null, ["hidden", true, "aria-hidden", "true"], null);
35856
+ this.openElement(QTemplate, null, QTemplateProps, null);
35722
35857
  const scopedStyleId = componentFrame.projectionScopedStyle;
35723
35858
  for (let i = 0; i < componentFrame.slots.length; i += 2) {
35724
35859
  const slotName = componentFrame.slots[i];
35725
35860
  const children = componentFrame.slots[i + 1];
35726
35861
  this.openFragment(
35727
- isDev26 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, componentFrame.componentNode.id] : [QSlotParent, componentFrame.componentNode.id]
35862
+ isDev27 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
35728
35863
  );
35729
35864
  const lastNode = this.getOrCreateLastNode();
35730
35865
  if (lastNode.vnodeData) {
@@ -35814,7 +35949,9 @@ var SSRContainer = class extends _SharedContainer2 {
35814
35949
  }
35815
35950
  }
35816
35951
  _styleNode(styleId, content) {
35817
- this.openElement("style", null, [QStyle, styleId]);
35952
+ this.openElement("style", null, {
35953
+ [QStyle]: styleId
35954
+ });
35818
35955
  this.write(content);
35819
35956
  this.closeElement();
35820
35957
  }
@@ -35855,7 +35992,7 @@ var SSRContainer = class extends _SharedContainer2 {
35855
35992
  if (!this.serializationCtx.$roots$.length) {
35856
35993
  return;
35857
35994
  }
35858
- this.openElement("script", null, ["type", "qwik/vnode"]);
35995
+ this.openElement("script", null, { type: "qwik/vnode" });
35859
35996
  const vNodeAttrsStack = [];
35860
35997
  const vNodeData = this.vNodeDatas;
35861
35998
  let lastSerializedIdx = 0;
@@ -35872,7 +36009,7 @@ var SSRContainer = class extends _SharedContainer2 {
35872
36009
  let depth = 0;
35873
36010
  for (let i = 1; i < vNode.length; i++) {
35874
36011
  const value = vNode[i];
35875
- if (Array.isArray(value)) {
36012
+ if (typeof value === "object" && value !== null) {
35876
36013
  vNodeAttrsStack.push(fragmentAttrs);
35877
36014
  fragmentAttrs = value;
35878
36015
  } else if (value === OPEN_FRAGMENT) {
@@ -35886,7 +36023,7 @@ var SSRContainer = class extends _SharedContainer2 {
35886
36023
  depth--;
35887
36024
  this.write(VNodeDataChar.CLOSE_CHAR);
35888
36025
  } else if (value === WRITE_ELEMENT_ATTRS) {
35889
- if (fragmentAttrs && fragmentAttrs.length) {
36026
+ if (fragmentAttrs && !isObjectEmpty(fragmentAttrs)) {
35890
36027
  this.write(VNodeDataChar.SEPARATOR_CHAR);
35891
36028
  this.write(VNodeDataChar.SEPARATOR_CHAR);
35892
36029
  this.writeFragmentAttrs(fragmentAttrs);
@@ -35913,9 +36050,8 @@ var SSRContainer = class extends _SharedContainer2 {
35913
36050
  this.closeElement();
35914
36051
  }
35915
36052
  writeFragmentAttrs(fragmentAttrs) {
35916
- for (let i = 0; i < fragmentAttrs.length; ) {
35917
- const key = fragmentAttrs[i++];
35918
- let value = fragmentAttrs[i++];
36053
+ for (const key in fragmentAttrs) {
36054
+ let value = fragmentAttrs[key];
35919
36055
  let encodeValue = false;
35920
36056
  if (typeof value !== "string") {
35921
36057
  const rootId = this.addRoot(value);
@@ -35990,28 +36126,25 @@ var SSRContainer = class extends _SharedContainer2 {
35990
36126
  }
35991
36127
  /** Add q-d:qidle attribute to eagerly resume some state if needed */
35992
36128
  stateScriptAttrs() {
35993
- const attrs = ["type", "qwik/state"];
36129
+ const attrs = { type: "qwik/state" };
35994
36130
  const eagerResume = this.serializationCtx.$eagerResume$;
35995
36131
  if (eagerResume.size > 0) {
35996
- const qrl = createQRL2(null, "_res", _res, null, [...eagerResume]);
35997
- const qrlStr = qrlToString2(this.serializationCtx, qrl);
35998
- attrs.push("q-d:qidle", qrlStr);
35999
- this.serializationCtx.$eventNames$.add("d:qidle");
36132
+ attrs["q-d:qidle"] = createQRL2(null, "_res", _res, null, [...eagerResume]);
36000
36133
  }
36001
36134
  return attrs;
36002
36135
  }
36003
36136
  emitSyncFnsData() {
36004
36137
  const fns = this.serializationCtx.$syncFns$;
36005
36138
  if (fns.length) {
36006
- const scriptAttrs = ["q:func", "qwik/json"];
36139
+ const scriptAttrs = { "q:func": "qwik/json" };
36007
36140
  if (this.renderOptions.serverData?.nonce) {
36008
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
36141
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
36009
36142
  }
36010
36143
  this.openElement("script", null, scriptAttrs);
36011
36144
  this.write(Q_FUNCS_PREFIX2.replace("HASH", this.$instanceHash$));
36012
- this.write("[");
36013
- this.writeArray(fns, ",");
36014
- this.write("]");
36145
+ this.write(BRACKET_OPEN);
36146
+ this.writeArray(fns, COMMA);
36147
+ this.write(BRACKET_CLOSE);
36015
36148
  this.closeElement();
36016
36149
  }
36017
36150
  }
@@ -36029,9 +36162,9 @@ var SSRContainer = class extends _SharedContainer2 {
36029
36162
  this.backpatchMap.clear();
36030
36163
  if (patches.length > 0) {
36031
36164
  this.isBackpatchExecutorEmitted = true;
36032
- const scriptAttrs = ["type", ELEMENT_BACKPATCH_DATA];
36165
+ const scriptAttrs = { type: ELEMENT_BACKPATCH_DATA };
36033
36166
  if (this.renderOptions.serverData?.nonce) {
36034
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
36167
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
36035
36168
  }
36036
36169
  this.openElement("script", null, scriptAttrs);
36037
36170
  this.write(JSON.stringify(patches));
@@ -36042,12 +36175,12 @@ var SSRContainer = class extends _SharedContainer2 {
36042
36175
  if (!this.isBackpatchExecutorEmitted) {
36043
36176
  return;
36044
36177
  }
36045
- const scriptAttrs = ["type", "text/javascript"];
36178
+ const scriptAttrs = { type: "text/javascript" };
36046
36179
  if (this.renderOptions.serverData?.nonce) {
36047
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
36180
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
36048
36181
  }
36049
36182
  this.openElement("script", null, scriptAttrs);
36050
- const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev26 });
36183
+ const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev27 });
36051
36184
  this.write(backpatchScript);
36052
36185
  this.closeElement();
36053
36186
  }
@@ -36061,16 +36194,20 @@ var SSRContainer = class extends _SharedContainer2 {
36061
36194
  if (this.qlInclude === 0 /* Module */) {
36062
36195
  this.qlInclude = 2 /* Done */;
36063
36196
  const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
36064
- const linkAttrs = ["rel", "modulepreload", "href", qwikLoaderBundle];
36197
+ const linkAttrs = { rel: "modulepreload", href: qwikLoaderBundle };
36065
36198
  const nonce = this.renderOptions.serverData?.nonce;
36066
36199
  if (nonce) {
36067
- linkAttrs.push("nonce", nonce);
36200
+ linkAttrs["nonce"] = nonce;
36068
36201
  }
36069
36202
  this.openElement("link", null, linkAttrs);
36070
36203
  this.closeElement();
36071
- const scriptAttrs = ["async", true, "type", "module", "src", qwikLoaderBundle];
36204
+ const scriptAttrs = {
36205
+ async: true,
36206
+ type: "module",
36207
+ src: qwikLoaderBundle
36208
+ };
36072
36209
  if (nonce) {
36073
- scriptAttrs.push("nonce", nonce);
36210
+ scriptAttrs["nonce"] = nonce;
36074
36211
  }
36075
36212
  this.openElement("script", null, scriptAttrs);
36076
36213
  this.closeElement();
@@ -36079,9 +36216,13 @@ var SSRContainer = class extends _SharedContainer2 {
36079
36216
  emitQwikLoaderInline() {
36080
36217
  this.qlInclude = 2 /* Done */;
36081
36218
  const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
36082
- const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
36219
+ const scriptAttrs = {
36220
+ id: "qwikloader",
36221
+ async: true,
36222
+ type: "module"
36223
+ };
36083
36224
  if (this.renderOptions.serverData?.nonce) {
36084
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
36225
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
36085
36226
  }
36086
36227
  this.openElement("script", null, scriptAttrs);
36087
36228
  this.write(qwikLoaderScript);
@@ -36097,15 +36238,15 @@ var SSRContainer = class extends _SharedContainer2 {
36097
36238
  }
36098
36239
  emitQwikEvents(eventNames) {
36099
36240
  if (eventNames.length > 0) {
36100
- const scriptAttrs = [];
36241
+ const scriptAttrs = {};
36101
36242
  const nonce = this.renderOptions.serverData?.nonce;
36102
36243
  if (nonce) {
36103
- scriptAttrs.push("nonce", nonce);
36244
+ scriptAttrs["nonce"] = nonce;
36104
36245
  }
36105
36246
  this.openElement("script", null, scriptAttrs);
36106
36247
  this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
36107
- this.writeArray(eventNames, ", ");
36108
- this.write(")");
36248
+ this.writeArray(eventNames, COMMA);
36249
+ this.write(PAREN_CLOSE);
36109
36250
  this.closeElement();
36110
36251
  }
36111
36252
  }
@@ -36137,7 +36278,7 @@ var SSRContainer = class extends _SharedContainer2 {
36137
36278
  }
36138
36279
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
36139
36280
  let tagNesting = 10 /* ANYTHING */;
36140
- if (isDev26) {
36281
+ if (isDev27) {
36141
36282
  if (!this.currentElementFrame) {
36142
36283
  tagNesting = initialTag(elementName);
36143
36284
  } else {
@@ -36183,7 +36324,7 @@ var SSRContainer = class extends _SharedContainer2 {
36183
36324
  elementName,
36184
36325
  depthFirstElementIdx,
36185
36326
  vNodeData: [0 /* NONE */],
36186
- currentFile: isDev26 ? currentFile || null : null
36327
+ currentFile: isDev27 ? currentFile || null : null
36187
36328
  };
36188
36329
  this.currentElementFrame = frame;
36189
36330
  this.vNodeDatas.push(frame.vNodeData);
@@ -36207,88 +36348,88 @@ var SSRContainer = class extends _SharedContainer2 {
36207
36348
  this.write(element);
36208
36349
  }
36209
36350
  }
36210
- writeAttrs(tag, attrs, isConst, currentFile) {
36351
+ writeAttrs(tag, attrs, isConst, styleScopedId, currentFile) {
36211
36352
  let innerHTML = void 0;
36212
- if (attrs.length) {
36213
- for (let i = 0; i < attrs.length; i++) {
36214
- let key = attrs[i++];
36215
- let value = attrs[i];
36216
- let styleScopedId = null;
36217
- if (isSSRUnsafeAttr(key)) {
36218
- if (isDev26) {
36219
- throw qError(32 /* unsafeAttr */, [key]);
36220
- }
36221
- continue;
36222
- }
36223
- if (key === "class" && Array.isArray(value)) {
36224
- const [signalValue, styleId] = value;
36225
- value = signalValue;
36226
- styleScopedId = styleId;
36353
+ let isLoopElement = null;
36354
+ for (let key in attrs) {
36355
+ let value = attrs[key];
36356
+ if (isSSRUnsafeAttr(key)) {
36357
+ if (isDev27) {
36358
+ throw qError(32 /* unsafeAttr */, [key]);
36227
36359
  }
36228
- if (key === "ref") {
36229
- const lastNode = this.getOrCreateLastNode();
36230
- if (isSignal3(value)) {
36231
- value.$untrackedValue$ = new DomRef(lastNode);
36232
- continue;
36233
- } else if (typeof value === "function") {
36234
- value(new DomRef(lastNode));
36235
- continue;
36236
- } else if (value == null) {
36237
- continue;
36238
- } else {
36239
- throw qError(15 /* invalidRefValue */, [currentFile]);
36240
- }
36360
+ continue;
36361
+ }
36362
+ if (isHtmlAttributeAnEventName(key)) {
36363
+ if (isLoopElement === null) {
36364
+ isLoopElement = attributesContainsIterationProp(attrs);
36241
36365
  }
36366
+ value = _setEvent(this.serializationCtx, key, value, isLoopElement);
36367
+ } else if (key === "ref") {
36368
+ const lastNode = this.getOrCreateLastNode();
36242
36369
  if (isSignal3(value)) {
36243
- const lastNode = this.getOrCreateLastNode();
36244
- const signalData = new SubscriptionData2({
36245
- $scopedStyleIdPrefix$: styleScopedId,
36246
- $isConst$: isConst
36247
- });
36248
- const signal = value;
36249
- value = retryOnPromise(
36250
- () => this.trackSignalValue(signal, lastNode, key, signalData)
36251
- );
36252
- }
36253
- if (isPromise(value)) {
36254
- const lastNode = this.getOrCreateLastNode();
36255
- this.addPromiseAttribute(value);
36256
- value.then((resolvedValue) => {
36257
- this.addBackpatchEntry(lastNode.id, key, resolvedValue);
36258
- });
36370
+ value.$untrackedValue$ = new DomRef(lastNode);
36259
36371
  continue;
36372
+ } else if (typeof value === "function") {
36373
+ value(new DomRef(lastNode));
36374
+ continue;
36375
+ } else if (value == null) {
36376
+ continue;
36377
+ } else {
36378
+ throw qError(15 /* invalidRefValue */, [currentFile]);
36260
36379
  }
36261
- if (key === dangerouslySetInnerHTML) {
36262
- if (value) {
36263
- innerHTML = String(value);
36264
- key = QContainerAttr;
36265
- value = "html" /* HTML */;
36266
- }
36267
- if (tag === "style") {
36268
- continue;
36269
- }
36270
- }
36271
- if (tag === "textarea" && key === "value") {
36272
- if (value && typeof value !== "string") {
36273
- if (isDev26) {
36274
- throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
36275
- }
36276
- continue;
36277
- }
36278
- innerHTML = escapeHTML(value || "");
36380
+ } else if (key === ITERATION_ITEM_SINGLE || key === ITERATION_ITEM_MULTI) {
36381
+ value = this.serializationCtx.$addRoot$(value);
36382
+ } else if (isSignal3(value)) {
36383
+ const lastNode = this.getOrCreateLastNode();
36384
+ const signalData = new SubscriptionData2({
36385
+ $scopedStyleIdPrefix$: styleScopedId,
36386
+ $isConst$: isConst
36387
+ });
36388
+ const signal = value;
36389
+ value = retryOnPromise(
36390
+ () => this.trackSignalValue(signal, lastNode, key, signalData)
36391
+ );
36392
+ }
36393
+ if (isPromise(value)) {
36394
+ const lastNode = this.getOrCreateLastNode();
36395
+ this.addPromiseAttribute(value);
36396
+ value.then((resolvedValue) => {
36397
+ this.addBackpatchEntry(lastNode.id, key, resolvedValue);
36398
+ });
36399
+ continue;
36400
+ }
36401
+ if (key === dangerouslySetInnerHTML) {
36402
+ if (value) {
36403
+ innerHTML = String(value);
36279
36404
  key = QContainerAttr;
36280
- value = "text" /* TEXT */;
36405
+ value = "html" /* HTML */;
36406
+ }
36407
+ if (tag === "style") {
36408
+ continue;
36281
36409
  }
36282
- const serializedValue = serializeAttribute(key, value, styleScopedId);
36283
- if (serializedValue != null && serializedValue !== false) {
36284
- this.write(" ");
36285
- this.write(key);
36286
- if (serializedValue !== true) {
36287
- this.write('="');
36288
- const strValue = escapeHTML(String(serializedValue));
36289
- this.write(strValue);
36290
- this.write('"');
36410
+ } else if (isPreventDefault(key)) {
36411
+ addPreventDefaultEventToSerializationContext(this.serializationCtx, key);
36412
+ }
36413
+ if (tag === "textarea" && key === "value") {
36414
+ if (value && typeof value !== "string") {
36415
+ if (isDev27) {
36416
+ throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
36291
36417
  }
36418
+ continue;
36419
+ }
36420
+ innerHTML = escapeHTML(value || "");
36421
+ key = QContainerAttr;
36422
+ value = "text" /* TEXT */;
36423
+ }
36424
+ const serializedValue = serializeAttribute(key, value, styleScopedId);
36425
+ if (serializedValue != null && serializedValue !== false) {
36426
+ this.write(SPACE);
36427
+ this.write(key);
36428
+ if (serializedValue !== true) {
36429
+ this.write(ATTR_EQUALS_QUOTE);
36430
+ const strValue = escapeHTML(String(serializedValue));
36431
+ this.write(strValue);
36432
+ this.write(QUOTE);
36292
36433
  }
36293
36434
  }
36294
36435
  }
@@ -36307,15 +36448,13 @@ var SSRContainer = class extends _SharedContainer2 {
36307
36448
  };
36308
36449
  var isQwikStyleElement = (tag, attrs) => {
36309
36450
  if (tag === "style" && attrs != null) {
36310
- for (let i = 0; i < attrs.length; i = i + 2) {
36311
- const attr = attrs[i];
36312
- if (attr === QStyle || attr === QScopedStyle) {
36313
- return true;
36314
- }
36315
- }
36451
+ return Object.prototype.hasOwnProperty.call(attrs, QStyle) || Object.prototype.hasOwnProperty.call(attrs, QScopedStyle);
36316
36452
  }
36317
36453
  return false;
36318
36454
  };
36455
+ var attributesContainsIterationProp = (attrs) => {
36456
+ return Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_SINGLE) || Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_MULTI);
36457
+ };
36319
36458
  function newTagError(text) {
36320
36459
  return qError(12 /* tagError */, [text]);
36321
36460
  }
@@ -36334,9 +36473,125 @@ function isSSRUnsafeAttr(name) {
36334
36473
  function hash2() {
36335
36474
  return Math.random().toString(36).slice(2);
36336
36475
  }
36476
+ function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
36477
+ const eventName = "e" + key.substring(14);
36478
+ if (eventName) {
36479
+ serializationCtx.$eventNames$.add(eventName);
36480
+ }
36481
+ }
36337
36482
 
36338
36483
  // packages/qwik/src/server/ssr-render.ts
36339
36484
  import { manifest as builtManifest } from "@qwik-client-manifest";
36485
+
36486
+ // packages/qwik/src/server/ssr-stream-handler.ts
36487
+ var StreamHandler = class {
36488
+ constructor(opts, timing) {
36489
+ this.opts = opts;
36490
+ this.timing = timing;
36491
+ __publicField(this, "bufferSize", 0);
36492
+ __publicField(this, "buffer", "");
36493
+ __publicField(this, "networkFlushes", 0);
36494
+ __publicField(this, "inOrderStreaming");
36495
+ __publicField(this, "streamBlockDepth", 0);
36496
+ __publicField(this, "streamBlockBuffer", "");
36497
+ __publicField(this, "streamBlockBufferSize", 0);
36498
+ __publicField(this, "nativeStream");
36499
+ __publicField(this, "firstFlushTimer", createTimer());
36500
+ __publicField(this, "stream");
36501
+ this.inOrderStreaming = opts.streaming?.inOrder ?? {
36502
+ strategy: "auto",
36503
+ maximumInitialChunk: 2e4,
36504
+ maximumChunk: 1e4
36505
+ };
36506
+ this.nativeStream = opts.stream;
36507
+ this.stream = this.setupStreamWriter();
36508
+ }
36509
+ setupStreamWriter() {
36510
+ const handler = this;
36511
+ let stream;
36512
+ switch (this.inOrderStreaming.strategy) {
36513
+ case "disabled":
36514
+ stream = {
36515
+ write(chunk) {
36516
+ if (chunk === void 0 || chunk === null) {
36517
+ return;
36518
+ }
36519
+ handler.enqueue(chunk);
36520
+ }
36521
+ };
36522
+ break;
36523
+ case "direct": {
36524
+ const originalStream = this.nativeStream;
36525
+ stream = {
36526
+ write(chunk) {
36527
+ if (chunk === void 0 || chunk === null) {
36528
+ return;
36529
+ }
36530
+ originalStream.write(chunk);
36531
+ }
36532
+ };
36533
+ break;
36534
+ }
36535
+ default:
36536
+ case "auto": {
36537
+ const minimumChunkSize = this.inOrderStreaming.maximumChunk ?? 0;
36538
+ const initialChunkSize = this.inOrderStreaming.maximumInitialChunk ?? 0;
36539
+ stream = {
36540
+ write(chunk) {
36541
+ if (chunk === void 0 || chunk === null) {
36542
+ return;
36543
+ }
36544
+ handler.enqueue(chunk);
36545
+ if (handler.streamBlockDepth === 0) {
36546
+ const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
36547
+ if (handler.bufferSize >= maxBufferSize) {
36548
+ handler.flush();
36549
+ }
36550
+ }
36551
+ }
36552
+ };
36553
+ break;
36554
+ }
36555
+ }
36556
+ return stream;
36557
+ }
36558
+ enqueue(chunk) {
36559
+ const len = chunk.length;
36560
+ if (this.streamBlockDepth > 0) {
36561
+ this.streamBlockBuffer += chunk;
36562
+ this.streamBlockBufferSize += len;
36563
+ } else {
36564
+ this.bufferSize += len;
36565
+ this.buffer += chunk;
36566
+ }
36567
+ }
36568
+ flush() {
36569
+ if (this.buffer) {
36570
+ this.nativeStream.write(this.buffer);
36571
+ this.buffer = "";
36572
+ this.bufferSize = 0;
36573
+ this.networkFlushes++;
36574
+ if (this.networkFlushes === 1) {
36575
+ this.timing.firstFlush = this.firstFlushTimer();
36576
+ }
36577
+ }
36578
+ }
36579
+ streamBlockStart() {
36580
+ this.streamBlockDepth++;
36581
+ }
36582
+ streamBlockEnd() {
36583
+ this.streamBlockDepth--;
36584
+ if (this.streamBlockDepth === 0 && this.streamBlockBuffer) {
36585
+ this.buffer += this.streamBlockBuffer;
36586
+ this.bufferSize += this.streamBlockBufferSize;
36587
+ this.streamBlockBuffer = "";
36588
+ this.streamBlockBufferSize = 0;
36589
+ this.flush();
36590
+ }
36591
+ }
36592
+ };
36593
+
36594
+ // packages/qwik/src/server/ssr-render.ts
36340
36595
  var renderToString = async (jsx2, opts = {}) => {
36341
36596
  const chunks = [];
36342
36597
  const stream = {
@@ -36363,11 +36618,12 @@ var renderToStream = async (jsx2, opts) => {
36363
36618
  const buildBase = getBuildBase(opts);
36364
36619
  const resolvedManifest = resolveManifest(opts.manifest);
36365
36620
  const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
36366
- const { stream, flush, networkFlushes } = handleStreaming(opts, timing);
36621
+ const streamHandler = new StreamHandler(opts, timing);
36367
36622
  const ssrContainer = ssrCreateContainer({
36368
36623
  tagName: containerTagName,
36369
36624
  locale,
36370
- writer: stream,
36625
+ writer: streamHandler.stream,
36626
+ streamHandler,
36371
36627
  timing,
36372
36628
  buildBase,
36373
36629
  resolvedManifest,
@@ -36376,11 +36632,9 @@ var renderToStream = async (jsx2, opts) => {
36376
36632
  await setServerPlatform(opts, resolvedManifest);
36377
36633
  await ssrContainer.render(jsx2);
36378
36634
  await ssrContainer.$renderPromise$;
36379
- flush();
36380
- const snapshotResult = getSnapshotResult(ssrContainer);
36635
+ streamHandler.flush();
36381
36636
  const result2 = {
36382
- snapshotResult,
36383
- flushes: networkFlushes,
36637
+ flushes: streamHandler.networkFlushes,
36384
36638
  manifest: resolvedManifest?.manifest,
36385
36639
  size: ssrContainer.size,
36386
36640
  isStatic: false,
@@ -36388,110 +36642,6 @@ var renderToStream = async (jsx2, opts) => {
36388
36642
  };
36389
36643
  return result2;
36390
36644
  };
36391
- function getSnapshotResult(ssrContainer) {
36392
- const hasListeners = !ssrContainer.isStatic();
36393
- const canRender = false;
36394
- return hasListeners ? {
36395
- funcs: Array.from(ssrContainer.serializationCtx.$syncFns$),
36396
- mode: canRender ? "render" : "listeners",
36397
- qrls: Array.from(ssrContainer.serializationCtx.$eventQrls$),
36398
- resources: Array.from(ssrContainer.serializationCtx.$resources$)
36399
- } : {
36400
- funcs: [],
36401
- mode: "static",
36402
- qrls: [],
36403
- resources: Array.from(ssrContainer.serializationCtx.$resources$)
36404
- };
36405
- }
36406
- function handleStreaming(opts, timing) {
36407
- const firstFlushTimer = createTimer();
36408
- let stream = opts.stream;
36409
- let bufferSize = 0;
36410
- let buffer = "";
36411
- let networkFlushes = 0;
36412
- const inOrderStreaming = opts.streaming?.inOrder ?? {
36413
- strategy: "auto",
36414
- maximumInitialChunk: 2e4,
36415
- maximumChunk: 1e4
36416
- };
36417
- const nativeStream = stream;
36418
- function flush() {
36419
- if (buffer) {
36420
- nativeStream.write(buffer);
36421
- buffer = "";
36422
- bufferSize = 0;
36423
- networkFlushes++;
36424
- if (networkFlushes === 1) {
36425
- timing.firstFlush = firstFlushTimer();
36426
- }
36427
- }
36428
- }
36429
- function enqueue(chunk) {
36430
- const len = chunk.length;
36431
- bufferSize += len;
36432
- buffer += chunk;
36433
- }
36434
- switch (inOrderStreaming.strategy) {
36435
- case "disabled":
36436
- stream = {
36437
- write(chunk) {
36438
- if (shouldSkipChunk(chunk)) {
36439
- return;
36440
- }
36441
- enqueue(chunk);
36442
- }
36443
- };
36444
- break;
36445
- case "direct":
36446
- stream = {
36447
- write(chunk) {
36448
- if (shouldSkipChunk(chunk)) {
36449
- return;
36450
- }
36451
- nativeStream.write(chunk);
36452
- }
36453
- };
36454
- break;
36455
- case "auto":
36456
- let openedSSRStreamBlocks = 0;
36457
- let forceFlush = false;
36458
- const minimumChunkSize = inOrderStreaming.maximumChunk ?? 0;
36459
- const initialChunkSize = inOrderStreaming.maximumInitialChunk ?? 0;
36460
- stream = {
36461
- write(chunk) {
36462
- if (chunk === void 0 || chunk === null) {
36463
- return;
36464
- }
36465
- if (chunk === "<!--" + FLUSH_COMMENT + "-->") {
36466
- forceFlush = true;
36467
- } else if (chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->") {
36468
- openedSSRStreamBlocks++;
36469
- } else if (chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->") {
36470
- openedSSRStreamBlocks--;
36471
- if (openedSSRStreamBlocks === 0) {
36472
- forceFlush = true;
36473
- }
36474
- } else {
36475
- enqueue(chunk);
36476
- }
36477
- const maxBufferSize = networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
36478
- if (openedSSRStreamBlocks === 0 && (forceFlush || bufferSize >= maxBufferSize)) {
36479
- forceFlush = false;
36480
- flush();
36481
- }
36482
- }
36483
- };
36484
- break;
36485
- }
36486
- return {
36487
- stream,
36488
- flush,
36489
- networkFlushes
36490
- };
36491
- }
36492
- function shouldSkipChunk(chunk) {
36493
- return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
36494
- }
36495
36645
  function resolveManifest(manifest) {
36496
36646
  const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
36497
36647
  if (!mergedManifest || "mapper" in mergedManifest) {
@@ -36633,7 +36783,7 @@ async function ssrRenderToDom(jsx2, opts = {}) {
36633
36783
  }
36634
36784
  function isQwikScript(node) {
36635
36785
  const element = node.node;
36636
- return vnode_getElementName(node) === "script" && (vnode_getProp(node, "type", null) === "qwik/state" || vnode_getProp(node, "type", null) === ELEMENT_BACKPATCH_DATA || vnode_getProp(node, "id", null) === "qwikloader" || element.getAttribute("type") === "qwik/state" || element.getAttribute("type") === ELEMENT_BACKPATCH_DATA || element.getAttribute("id") === "qwikloader");
36786
+ return vnode_getElementName(node) === "script" && (vnode_getProp(node, "type", null) === "qwik/state" || vnode_getProp(node, "type", null) === ELEMENT_BACKPATCH_DATA || vnode_getProp(node, "id", null) === "qwikloader" || element.getAttribute("type") === "qwik/state" || element.getAttribute("type") === ELEMENT_BACKPATCH_DATA || element.getAttribute("id") === "qwikloader" || element.innerHTML.includes("window._qwikEv"));
36637
36787
  }
36638
36788
  function vnode_moveToVirtual(parent, newChild, insertBefore) {
36639
36789
  const journal = [];
@@ -36753,7 +36903,7 @@ export {
36753
36903
  expectDOM,
36754
36904
  getTestPlatform,
36755
36905
  ssrRenderToDom,
36756
- trigger,
36906
+ trigger2 as trigger,
36757
36907
  vnode_fromJSX,
36758
36908
  waitForDrain,
36759
36909
  walkJSX