@qwik.dev/core 2.0.0-beta.1 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.win32-x64-msvc.node +0 -0
  5. package/bindings/qwik_wasm_bg.wasm +0 -0
  6. package/dist/backpatch/index.cjs +6 -0
  7. package/dist/backpatch/index.d.ts +2 -0
  8. package/dist/backpatch/index.mjs +5 -0
  9. package/dist/backpatch/package.json +8 -0
  10. package/dist/backpatch-executor.debug.js +34 -0
  11. package/dist/backpatch-executor.js +1 -0
  12. package/dist/build/package.json +1 -1
  13. package/dist/cli.cjs +3031 -763
  14. package/dist/core-internal.d.ts +253 -78
  15. package/dist/core.cjs +1770 -957
  16. package/dist/core.cjs.map +1 -1
  17. package/dist/core.min.mjs +1 -1
  18. package/dist/core.mjs +1745 -955
  19. package/dist/core.mjs.map +1 -1
  20. package/dist/core.prod.cjs +1368 -949
  21. package/dist/core.prod.mjs +1435 -951
  22. package/dist/insights/vite/index.cjs +1 -1
  23. package/dist/insights/vite/index.mjs +10 -10
  24. package/dist/loader/index.cjs +2 -2
  25. package/dist/loader/index.mjs +2 -2
  26. package/dist/loader/package.json +1 -1
  27. package/dist/optimizer.cjs +201 -4016
  28. package/dist/optimizer.d.ts +12 -37
  29. package/dist/optimizer.mjs +2539 -3715
  30. package/dist/preloader.cjs +8 -11
  31. package/dist/preloader.mjs +8 -11
  32. package/dist/qwikloader.debug.js +1 -15
  33. package/dist/qwikloader.js +1 -1
  34. package/dist/server.cjs +309 -116
  35. package/dist/server.d.ts +17 -2
  36. package/dist/server.mjs +291 -103
  37. package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/vite.config.mts +1 -1
  38. package/dist/starters/adapters/aws-lambda/package.json +1 -1
  39. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -6
  40. package/dist/starters/adapters/azure-swa/adapters/azure-swa/vite.config.mts +1 -1
  41. package/dist/starters/adapters/azure-swa/package.json +1 -1
  42. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -3
  43. package/dist/starters/adapters/bun/adapters/bun/vite.config.mts +2 -2
  44. package/dist/starters/adapters/bun/package.json +1 -1
  45. package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
  46. package/dist/starters/adapters/cloud-run/adapters/cloud-run/vite.config.mts +1 -1
  47. package/dist/starters/adapters/cloud-run/package.json +1 -1
  48. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
  49. package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/vite.config.mts +1 -1
  50. package/dist/starters/adapters/cloudflare-pages/package.json +1 -1
  51. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -3
  52. package/dist/starters/adapters/deno/adapters/deno/vite.config.mts +1 -1
  53. package/dist/starters/adapters/deno/package.json +1 -1
  54. package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
  55. package/dist/starters/adapters/express/adapters/express/vite.config.mts +1 -1
  56. package/dist/starters/adapters/express/package.json +1 -1
  57. package/dist/starters/adapters/express/src/entry.express.tsx +1 -3
  58. package/dist/starters/adapters/fastify/adapters/fastify/vite.config.mts +1 -1
  59. package/dist/starters/adapters/fastify/package.json +1 -1
  60. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +1 -1
  61. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
  62. package/dist/starters/adapters/firebase/adapters/firebase/vite.config.mts +1 -1
  63. package/dist/starters/adapters/firebase/package.json +1 -1
  64. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -3
  65. package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/vite.config.mts +1 -1
  66. package/dist/starters/adapters/netlify-edge/package.json +1 -1
  67. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -3
  68. package/dist/starters/adapters/node-server/adapters/node-server/vite.config.mts +1 -1
  69. package/dist/starters/adapters/node-server/package.json +1 -1
  70. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
  71. package/dist/starters/adapters/{static/adapters/static → ssg/adapters/ssg}/vite.config.mts +2 -2
  72. package/dist/starters/adapters/ssg/package.json +19 -0
  73. package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/vite.config.mts +1 -1
  74. package/dist/starters/adapters/vercel-edge/package.json +1 -1
  75. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -3
  76. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  77. package/dist/starters/features/auth/package.json +1 -1
  78. package/dist/starters/features/csr/index.html +23 -0
  79. package/dist/starters/features/csr/package.json +29 -0
  80. package/dist/starters/features/csr/src/root.tsx +15 -0
  81. package/dist/starters/features/csr/vite.config.mts +13 -0
  82. package/dist/starters/features/localize/package.json +3 -3
  83. package/dist/starters/features/localize/src/entry.ssr.tsx +17 -21
  84. package/dist/starters/features/pandacss/package.json +1 -1
  85. package/dist/starters/features/playwright/playwright-report/index.html +953 -911
  86. package/dist/starters/features/postcss/postcss.config.js +1 -1
  87. package/dist/starters/features/tailwind/package.json +2 -2
  88. package/dist/starters/features/tailwind/prettier.config.js +10 -0
  89. package/dist/starters/features/tailwind-v3/package.json +1 -1
  90. package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
  91. package/dist/testing/index.cjs +7556 -5229
  92. package/dist/testing/index.d.ts +972 -1
  93. package/dist/testing/index.mjs +7456 -5140
  94. package/dist/testing/package.json +1 -1
  95. package/package.json +16 -10
  96. package/public.d.ts +1 -0
  97. package/dist/starters/adapters/static/package.json +0 -19
  98. package/dist/starters/features/tailwind/.prettierrc.js +0 -3
  99. /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.1-dev+495e8d9
3
+ * @qwik.dev/core 2.0.0-beta.10-dev+4669425
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
@@ -11,6 +11,8 @@ export { isBrowser, isDev, isServer } from "@qwik.dev/core/build";
11
11
 
12
12
  import { p } from "@qwik.dev/core/preloader";
13
13
 
14
+ const version = "2.0.0-beta.10-dev+4669425";
15
+
14
16
  const qDev = !1;
15
17
 
16
18
  const qInspector = !1;
@@ -50,11 +52,28 @@ const logWarn = () => {
50
52
  const createAndLogError = (asyncThrow, message, ...optionalParams) => {
51
53
  const err = message instanceof Error ? message : new Error(message);
52
54
  return console.error("%cQWIK ERROR", "", err.message, ...optionalParams, err.stack),
53
- asyncThrow && setTimeout((() => {
55
+ asyncThrow && setTimeout(() => {
54
56
  throw err;
55
- }), 0), err;
57
+ }, 0), err;
58
+ };
59
+
60
+ const isSerializableObject = v => {
61
+ const proto = Object.getPrototypeOf(v);
62
+ return proto === Object.prototype || proto === Array.prototype || null === proto;
56
63
  };
57
64
 
65
+ const isObject = v => "object" == typeof v && null !== v;
66
+
67
+ const isArray = v => Array.isArray(v);
68
+
69
+ const isString = v => "string" == typeof v;
70
+
71
+ const isNumber$1 = v => "number" == typeof v;
72
+
73
+ const isFunction = v => "function" == typeof v;
74
+
75
+ const isPrimitive = v => "object" != typeof v && "function" != typeof v && null != v;
76
+
58
77
  const codeToText = code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
59
78
 
60
79
  const qError = (code, errorMessageArgs = []) => {
@@ -137,6 +156,10 @@ const SVG_NS = "http://www.w3.org/2000/svg";
137
156
 
138
157
  const MATH_NS = "http://www.w3.org/1998/Math/MathML";
139
158
 
159
+ const XLINK_NS = "http://www.w3.org/1999/xlink";
160
+
161
+ const XML_NS = "http://www.w3.org/XML/1998/namespace";
162
+
140
163
  const ResourceEvent = "qResource";
141
164
 
142
165
  const RenderEvent = "qRender";
@@ -196,18 +219,13 @@ const createPlatform = () => ({
196
219
  const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
197
220
  const urlCopy = new URL(urlDoc);
198
221
  urlCopy.hash = "";
199
- return import(urlCopy.href).then((mod => mod[symbolName]));
222
+ return import(urlCopy.href).then(mod => mod[symbolName]);
200
223
  },
201
- raf: fn => new Promise((resolve => {
202
- requestAnimationFrame((() => {
203
- resolve(fn());
204
- }));
205
- })),
206
- nextTick: fn => new Promise((resolve => {
207
- setTimeout((() => {
224
+ raf: fn => new Promise(resolve => {
225
+ requestAnimationFrame(() => {
208
226
  resolve(fn());
209
- }));
210
- })),
227
+ });
228
+ }),
211
229
  chunkForSymbol: (symbolName, chunk) => [ symbolName, chunk ?? "_" ]
212
230
  });
213
231
 
@@ -250,9 +268,9 @@ const shouldNotError = reason => {
250
268
  throwErrorAndStop(reason);
251
269
  };
252
270
 
253
- const delay = timeout => new Promise((resolve => {
271
+ const delay = timeout => new Promise(resolve => {
254
272
  setTimeout(resolve, timeout);
255
- }));
273
+ });
256
274
 
257
275
  function retryOnPromise(fn, retryCount = 0) {
258
276
  const retryOrThrow = e => {
@@ -263,7 +281,7 @@ function retryOnPromise(fn, retryCount = 0) {
263
281
  };
264
282
  try {
265
283
  const result = fn();
266
- return isPromise(result) ? result.catch((e => retryOrThrow(e))) : result;
284
+ return isPromise(result) ? result.catch(e => retryOrThrow(e)) : result;
267
285
  } catch (e) {
268
286
  if (isDev && isServer && e instanceof ReferenceError && e.message.includes("window")) {
269
287
  throw e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message,
@@ -273,19 +291,6 @@ function retryOnPromise(fn, retryCount = 0) {
273
291
  }
274
292
  }
275
293
 
276
- const isSerializableObject = v => {
277
- const proto = Object.getPrototypeOf(v);
278
- return proto === Object.prototype || proto === Array.prototype || null === proto;
279
- };
280
-
281
- const isObject = v => !!v && "object" == typeof v;
282
-
283
- const isArray = v => Array.isArray(v);
284
-
285
- const isString = v => "string" == typeof v;
286
-
287
- const isFunction = v => "function" == typeof v;
288
-
289
294
  const ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
290
295
 
291
296
  function assertDefined() {
@@ -354,6 +359,9 @@ class SignalImpl {
354
359
  constructor(container, value) {
355
360
  this.$container$ = container, this.$untrackedValue$ = value;
356
361
  }
362
+ force() {
363
+ this.$container$?.$scheduler$(7, null, this, this.$effects$);
364
+ }
357
365
  get untrackedValue() {
358
366
  return this.$untrackedValue$;
359
367
  }
@@ -361,16 +369,16 @@ class SignalImpl {
361
369
  this.$untrackedValue$ = value;
362
370
  }
363
371
  get value() {
364
- return setupSignalValueAccess(this, (() => this.$effects$ ||= new Set), (() => this.untrackedValue));
372
+ return setupSignalValueAccess(this, () => this.$effects$ ||= new Set, () => this.untrackedValue);
365
373
  }
366
374
  set value(value) {
367
- value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
375
+ value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, this.$container$?.$scheduler$(7, null, this, this.$effects$));
368
376
  }
369
377
  valueOf() {
370
378
  qDev;
371
379
  }
372
380
  toString() {
373
- return isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "") : this.constructor.name;
381
+ return isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map(e => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "") : this.constructor.name;
374
382
  }
375
383
  toJSON() {
376
384
  return {
@@ -407,30 +415,27 @@ class WrappedSignalImpl extends SignalImpl {
407
415
  $funcStr$;
408
416
  $flags$;
409
417
  $hostElement$=null;
410
- $forceRunEffects$=!1;
411
418
  [_EFFECT_BACK_REF]=null;
412
- constructor(container, fn, args, fnStr, flags = 3) {
419
+ constructor(container, fn, args, fnStr, flags = 5) {
413
420
  super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
414
421
  this.$flags$ = flags;
415
422
  }
416
- $invalidate$() {
417
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
423
+ invalidate() {
424
+ this.$flags$ |= 1, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
418
425
  }
419
426
  force() {
420
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
427
+ this.$flags$ |= 2, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
421
428
  }
422
429
  get untrackedValue() {
423
- const didChange = this.$computeIfNeeded$();
424
- return didChange && (this.$forceRunEffects$ = didChange), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
430
+ return this.$computeIfNeeded$(), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
425
431
  this.$untrackedValue$;
426
432
  }
427
433
  $computeIfNeeded$() {
428
434
  if (!(1 & this.$flags$)) {
429
- return !1;
435
+ return;
430
436
  }
431
- const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, ".", this.$container$);
432
- const didChange = untrackedValue !== this.$untrackedValue$;
433
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
437
+ const untrackedValue = trackSignal(() => this.$func$(...this.$args$), this, ".", this.$container$);
438
+ untrackedValue !== this.$untrackedValue$ && (this.$flags$ |= 2, this.$untrackedValue$ = untrackedValue);
434
439
  }
435
440
  set value(_) {
436
441
  throw qError(31);
@@ -524,7 +529,7 @@ const newInvokeContext = (locale, hostElement, element, event, url) => {
524
529
  $event$: event,
525
530
  $qrl$: void 0,
526
531
  $effectSubscriber$: void 0,
527
- $locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
532
+ $locale$: locale || (event && isObject(event) && "locale" in event ? event.locale : void 0),
528
533
  $container$: void 0
529
534
  };
530
535
  return seal(), ctx;
@@ -546,7 +551,7 @@ const trackSignal = (fn, subscriber, property, container, data) => {
546
551
  };
547
552
 
548
553
  const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignalImpl && value.$hostElement$ !== host && host && (value.$hostElement$ = host),
549
- trackSignal((() => value.value), host, property, container, data));
554
+ trackSignal(() => value.value, host, property, container, data));
550
555
 
551
556
  const _getContextElement = () => {
552
557
  const iCtx = tryGetInvokeContext();
@@ -565,15 +570,27 @@ const _getContextEvent = () => {
565
570
  }
566
571
  };
567
572
 
573
+ const _getContextContainer = () => {
574
+ const iCtx = tryGetInvokeContext();
575
+ if (iCtx) {
576
+ return iCtx.$container$;
577
+ }
578
+ };
579
+
568
580
  const _jsxBranch = input => input;
569
581
 
570
582
  const _waitUntilRendered = elm => {
571
- const containerEl = _getQContainerElement(elm);
572
- if (!containerEl) {
573
- return Promise.resolve();
574
- }
575
- const container = containerEl.qContainer;
576
- return container?.renderDone ?? Promise.resolve();
583
+ const container = _getQContainerElement(elm)?.qContainer;
584
+ return container ? (async () => {
585
+ for (;;) {
586
+ await container.$scheduler$(255).$returnValue$;
587
+ const firstEpoch = container.$flushEpoch$ || 0;
588
+ await Promise.resolve();
589
+ if (firstEpoch === (container.$flushEpoch$ || 0)) {
590
+ return;
591
+ }
592
+ }
593
+ })() : Promise.resolve();
577
594
  };
578
595
 
579
596
  const useSequentialScope = () => {
@@ -692,12 +709,18 @@ const validateContext = context => {
692
709
  }
693
710
  };
694
711
 
712
+ const _resolveContextWithoutSequentialScope = context => {
713
+ const iCtx = getInvokeContext();
714
+ const hostElement = iCtx.$hostElement$;
715
+ if (hostElement) {
716
+ return iCtx.$container$?.resolveContext(hostElement, context);
717
+ }
718
+ };
719
+
695
720
  const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
696
721
 
697
722
  const isRecoverable = err => !(err && err instanceof Error && "plugin" in err);
698
723
 
699
- const version = "2.0.0-beta.1-dev+495e8d9";
700
-
701
724
  const EMPTY_ARRAY = [];
702
725
 
703
726
  const EMPTY_OBJ = {};
@@ -727,7 +750,7 @@ const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset =
727
750
  {
728
751
  const ref = "QWIK-SELF";
729
752
  const frames = new Error(ref).stack.split("\n");
730
- const start = frames.findIndex((f => f.includes(ref)));
753
+ const start = frames.findIndex(f => f.includes(ref));
731
754
  match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
732
755
  }
733
756
  }
@@ -778,7 +801,7 @@ const useLexicalScope = () => {
778
801
  return qrl.$captureRef$;
779
802
  };
780
803
 
781
- const queueQRL = (...args) => {
804
+ const _run = (...args) => {
782
805
  const [runQrl] = useLexicalScope();
783
806
  const context = getInvokeContext();
784
807
  const hostElement = context.$hostElement$;
@@ -789,15 +812,45 @@ const queueQRL = (...args) => {
789
812
  if (!scheduler) {
790
813
  throw qError(1);
791
814
  }
792
- return scheduler(2, hostElement, runQrl, args);
815
+ const chore = scheduler(2, hostElement, runQrl, args);
816
+ return getChorePromise(chore);
817
+ };
818
+
819
+ const mapApp_findIndx = (array, key, start) => {
820
+ assertTrue(start % 2 == 0, "Expecting even number.");
821
+ let bottom = start >> 1;
822
+ let top = array.length - 2 >> 1;
823
+ for (;bottom <= top; ) {
824
+ const mid = bottom + (top - bottom >> 1);
825
+ const midKey = array[mid << 1];
826
+ if (midKey === key) {
827
+ return mid << 1;
828
+ }
829
+ midKey < key ? bottom = mid + 1 : top = mid - 1;
830
+ }
831
+ return ~(bottom << 1);
832
+ };
833
+
834
+ const mapArray_set = (array, key, value, start, allowNullValue = !1) => {
835
+ const indx = mapApp_findIndx(array, key, start);
836
+ indx >= 0 ? null != value || allowNullValue ? array[indx + 1] = value : array.splice(indx, 2) : (null != value || allowNullValue) && array.splice(-1 ^ indx, 0, key, value);
837
+ };
838
+
839
+ const mapArray_get = (array, key, start) => {
840
+ const indx = mapApp_findIndx(array, key, start);
841
+ return indx >= 0 ? array[indx + 1] : null;
793
842
  };
794
843
 
844
+ const mapArray_has = (array, key, start) => mapApp_findIndx(array, key, start) >= 0;
845
+
795
846
  const _CONST_PROPS = Symbol("CONST");
796
847
 
797
848
  const _VAR_PROPS = Symbol("VAR");
798
849
 
799
850
  const _IMMUTABLE = Symbol("IMMUTABLE");
800
851
 
852
+ const _UNINITIALIZED = Symbol("UNINITIALIZED");
853
+
801
854
  const implicit$FirstArg = fn => function(first, ...rest) {
802
855
  return fn.call(null, dollar(first), ...rest);
803
856
  };
@@ -809,25 +862,23 @@ const log = (...args) => console.log("COMPUTED SIGNAL", ...args.map(qwikDebugToS
809
862
  class ComputedSignalImpl extends SignalImpl {
810
863
  $computeQrl$;
811
864
  $flags$;
812
- $forceRunEffects$=!1;
813
865
  [_EFFECT_BACK_REF]=null;
814
- constructor(container, fn, flags = 1) {
866
+ constructor(container, fn, flags = 33) {
815
867
  super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
816
868
  }
817
- $invalidate$() {
818
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
869
+ invalidate() {
870
+ this.$flags$ |= 1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
819
871
  }
820
872
  force() {
821
- this.$forceRunEffects$ = !0, this.$container$?.$scheduler$(7, null, this, this.$effects$);
873
+ this.$flags$ |= 2, super.force();
822
874
  }
823
875
  get untrackedValue() {
824
- const didChange = this.$computeIfNeeded$();
825
- return didChange && (this.$forceRunEffects$ = didChange), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
876
+ return this.$computeIfNeeded$(), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
826
877
  this.$untrackedValue$;
827
878
  }
828
879
  $computeIfNeeded$() {
829
880
  if (!(1 & this.$flags$)) {
830
- return !1;
881
+ return;
831
882
  }
832
883
  const computeQrl = this.$computeQrl$;
833
884
  throwIfQRLNotResolved(computeQrl);
@@ -840,8 +891,8 @@ class ComputedSignalImpl extends SignalImpl {
840
891
  throw qError(29, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
841
892
  }
842
893
  this.$flags$ &= -2;
843
- const didChange = untrackedValue !== this.$untrackedValue$;
844
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
894
+ untrackedValue !== this.$untrackedValue$ && (this.$untrackedValue$ !== NEEDS_COMPUTATION && (this.$flags$ |= 2),
895
+ this.$untrackedValue$ = untrackedValue);
845
896
  } finally {
846
897
  ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
847
898
  }
@@ -856,12 +907,12 @@ class ComputedSignalImpl extends SignalImpl {
856
907
 
857
908
  class SerializerSignalImpl extends ComputedSignalImpl {
858
909
  constructor(container, argQrl) {
859
- super(container, argQrl);
910
+ super(container, argQrl, 33);
860
911
  }
861
912
  $didInitialize$=!1;
862
913
  $computeIfNeeded$() {
863
914
  if (!(1 & this.$flags$)) {
864
- return !1;
915
+ return;
865
916
  }
866
917
  throwIfQRLNotResolved(this.$computeQrl$);
867
918
  let arg = this.$computeQrl$.resolved;
@@ -869,10 +920,10 @@ class SerializerSignalImpl extends ComputedSignalImpl {
869
920
  const {deserialize, initial} = arg;
870
921
  const update = arg.update;
871
922
  const currentValue = this.$untrackedValue$ === NEEDS_COMPUTATION ? initial : this.$untrackedValue$;
872
- const untrackedValue = trackSignal((() => this.$didInitialize$ ? update?.(currentValue) : deserialize(currentValue)), this, ".", this.$container$);
923
+ const untrackedValue = trackSignal(() => this.$didInitialize$ ? update?.(currentValue) || currentValue : deserialize(currentValue), this, ".", this.$container$);
873
924
  const didChange = this.$didInitialize$ && "undefined" !== untrackedValue || untrackedValue !== this.$untrackedValue$;
874
- return this.$flags$ &= -2, this.$didInitialize$ = !0, didChange && (this.$untrackedValue$ = untrackedValue),
875
- didChange;
925
+ this.$flags$ &= -2, this.$didInitialize$ = !0, didChange && (this.$flags$ |= 2,
926
+ this.$untrackedValue$ = untrackedValue);
876
927
  }
877
928
  }
878
929
 
@@ -880,6 +931,16 @@ const getStoreHandler = value => value[STORE_HANDLER];
880
931
 
881
932
  const getStoreTarget = value => value?.[STORE_TARGET] || null;
882
933
 
934
+ const forceStoreEffects = (value, prop) => {
935
+ const handler = getStoreHandler(value);
936
+ handler && handler.force(prop);
937
+ };
938
+
939
+ const _hasStoreEffects = (value, prop) => {
940
+ const handler = getStoreHandler(value);
941
+ return !!handler && (handler.$effects$?.get(prop)?.size ?? 0) > 0;
942
+ };
943
+
883
944
  const unwrapStore = value => getStoreTarget(value) || value;
884
945
 
885
946
  const isStore = value => STORE_TARGET in value;
@@ -907,6 +968,10 @@ class StoreHandler {
907
968
  toString() {
908
969
  return "[Store]";
909
970
  }
971
+ force(prop) {
972
+ const target = getStoreTarget(this);
973
+ this.$container$?.$scheduler$(7, null, this, getEffects(target, prop, this.$effects$));
974
+ }
910
975
  get(target, prop) {
911
976
  if ("symbol" == typeof prop) {
912
977
  return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
@@ -928,7 +993,7 @@ class StoreHandler {
928
993
  if ("toString" === prop && value === Object.prototype.toString) {
929
994
  return this.toString;
930
995
  }
931
- return 1 & this.$flags$ && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
996
+ return 1 & this.$flags$ && isObject(value) && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
932
997
  }
933
998
  set(target, prop, value) {
934
999
  if ("symbol" == typeof prop) {
@@ -943,7 +1008,7 @@ class StoreHandler {
943
1008
  return !0;
944
1009
  }
945
1010
  deleteProperty(target, prop) {
946
- return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)),
1011
+ return "string" == typeof prop && delete target[prop] && (Array.isArray(target) || this.$container$?.$scheduler$(7, null, this, getEffects(target, prop, this.$effects$)),
947
1012
  !0);
948
1013
  }
949
1014
  has(target, prop) {
@@ -982,7 +1047,9 @@ function addStoreEffect(target, prop, store, effectSubscription) {
982
1047
  }
983
1048
 
984
1049
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
985
- target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
1050
+ target[prop] = value;
1051
+ const effects = getEffects(target, prop, currentStore.$effects$);
1052
+ effects && currentStore.$container$?.$scheduler$(7, null, currentStore, effects);
986
1053
  }
987
1054
 
988
1055
  function getEffects(target, prop, storeEffects) {
@@ -1012,7 +1079,7 @@ function getEffects(target, prop, storeEffects) {
1012
1079
  const trackFn = (target, container) => (obj, prop) => {
1013
1080
  const ctx = newInvokeContext();
1014
1081
  return ctx.$effectSubscriber$ = getSubscriber(target, ":"), ctx.$container$ = container || void 0,
1015
- invoke(ctx, (() => {
1082
+ invoke(ctx, () => {
1016
1083
  if (isFunction(obj)) {
1017
1084
  return obj();
1018
1085
  }
@@ -1027,21 +1094,21 @@ const trackFn = (target, container) => (obj, prop) => {
1027
1094
  obj;
1028
1095
  }
1029
1096
  throw qError(2);
1030
- }));
1097
+ });
1031
1098
  };
1032
1099
 
1033
1100
  const cleanupFn = (target, handleError) => {
1034
1101
  let cleanupFns = null;
1035
1102
  return [ fn => {
1036
- "function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize((() => {
1037
- target.$destroy$ = null, cleanupFns.forEach((fn => {
1103
+ "function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize(() => {
1104
+ target.$destroy$ = null, cleanupFns.forEach(fn => {
1038
1105
  try {
1039
1106
  fn();
1040
1107
  } catch (err) {
1041
1108
  handleError(err);
1042
1109
  }
1043
- }));
1044
- }))), cleanupFns.push(fn));
1110
+ });
1111
+ })), cleanupFns.push(fn));
1045
1112
  }, cleanupFns ?? [] ];
1046
1113
  };
1047
1114
 
@@ -1051,13 +1118,13 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
1051
1118
  $loadingEffects$=null;
1052
1119
  $errorEffects$=null;
1053
1120
  $destroy$;
1054
- $promiseValue$=null;
1121
+ $promiseValue$=NEEDS_COMPUTATION;
1055
1122
  [_EFFECT_BACK_REF]=null;
1056
1123
  constructor(container, fn, flags = 1) {
1057
1124
  super(container, fn, flags);
1058
1125
  }
1059
1126
  get loading() {
1060
- return setupSignalValueAccess(this, (() => this.$loadingEffects$ ||= new Set), (() => this.untrackedLoading));
1127
+ return setupSignalValueAccess(this, () => this.$loadingEffects$ ||= new Set, () => this.untrackedLoading);
1061
1128
  }
1062
1129
  set untrackedLoading(value) {
1063
1130
  value !== this.$untrackedLoading$ && (this.$untrackedLoading$ = value, this.$container$?.$scheduler$(7, null, this, this.$loadingEffects$));
@@ -1066,7 +1133,7 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
1066
1133
  return this.$untrackedLoading$;
1067
1134
  }
1068
1135
  get error() {
1069
- return setupSignalValueAccess(this, (() => this.$errorEffects$ ||= new Set), (() => this.untrackedError));
1136
+ return setupSignalValueAccess(this, () => this.$errorEffects$ ||= new Set, () => this.untrackedError);
1070
1137
  }
1071
1138
  set untrackedError(value) {
1072
1139
  value !== this.$untrackedError$ && (this.$untrackedError$ = value, this.$container$?.$scheduler$(7, null, this, this.$errorEffects$));
@@ -1074,40 +1141,48 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
1074
1141
  get untrackedError() {
1075
1142
  return this.$untrackedError$;
1076
1143
  }
1144
+ invalidate() {
1145
+ super.invalidate(), this.$promiseValue$ = NEEDS_COMPUTATION;
1146
+ }
1077
1147
  $computeIfNeeded$() {
1078
1148
  if (!(1 & this.$flags$)) {
1079
- return !1;
1149
+ return;
1080
1150
  }
1081
1151
  const computeQrl = this.$computeQrl$;
1082
1152
  throwIfQRLNotResolved(computeQrl);
1083
- const [cleanup] = cleanupFn(this, (err => this.$container$?.handleError(err, null)));
1084
- const untrackedValue = this.$promiseValue$ ?? computeQrl.getFn()({
1153
+ const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
1154
+ const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION ? computeQrl.getFn()({
1085
1155
  track: trackFn(this, this.$container$),
1086
1156
  cleanup
1087
- });
1157
+ }) : this.$promiseValue$;
1088
1158
  if (isPromise(untrackedValue)) {
1089
- throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then((promiseValue => {
1159
+ throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then(promiseValue => {
1090
1160
  this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = null;
1091
- })).catch((err => {
1092
- this.untrackedLoading = !1, this.untrackedError = err;
1093
- }));
1161
+ }).catch(err => {
1162
+ this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err;
1163
+ });
1094
1164
  }
1095
- this.$promiseValue$ = null, this.$flags$ &= -2;
1165
+ this.$promiseValue$ = NEEDS_COMPUTATION, this.$flags$ &= -2;
1096
1166
  const didChange = untrackedValue !== this.$untrackedValue$;
1097
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
1167
+ return didChange && (this.$flags$ |= 2, this.$untrackedValue$ = untrackedValue),
1168
+ didChange;
1098
1169
  }
1099
1170
  }
1100
1171
 
1101
1172
  const createSignal$1 = value => new SignalImpl(null, value);
1102
1173
 
1103
- const createComputedSignal = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignalImpl(null, qrl));
1174
+ const createComputedSignal = (qrl, options) => new ComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "always"));
1104
1175
 
1105
- const createSerializerSignal = arg => (throwIfQRLNotResolved(arg), new SerializerSignalImpl(null, arg));
1176
+ const createAsyncComputedSignal = (qrl, options) => new AsyncComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "never"));
1177
+
1178
+ const createSerializerSignal = arg => new SerializerSignalImpl(null, arg);
1106
1179
 
1107
1180
  const createSignal = createSignal$1;
1108
1181
 
1109
1182
  const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedSignal);
1110
1183
 
1184
+ const createAsyncComputed$ = /*#__PURE__*/ implicit$FirstArg(createAsyncComputedSignal);
1185
+
1111
1186
  const createSerializer$ = implicit$FirstArg(createSerializerSignal);
1112
1187
 
1113
1188
  const getValueProp = p0 => p0.value;
@@ -1124,7 +1199,7 @@ const _wrapProp = (...args) => {
1124
1199
  }
1125
1200
  if (isSignal(obj)) {
1126
1201
  return obj instanceof AsyncComputedSignalImpl || assertEqual(prop, "value", "Left side is a signal, prop must be value"),
1127
- obj instanceof WrappedSignalImpl && 2 & obj.flags ? obj : getWrapped(args);
1202
+ obj instanceof WrappedSignalImpl && 4 & obj.flags ? obj : getWrapped(args);
1128
1203
  }
1129
1204
  if (isPropsProxy(obj)) {
1130
1205
  const constProps = obj[_CONST_PROPS];
@@ -1141,11 +1216,6 @@ const _wrapProp = (...args) => {
1141
1216
  return obj[prop];
1142
1217
  };
1143
1218
 
1144
- const _wrapStore = (obj, prop) => {
1145
- const value = getStoreTarget(obj)[prop];
1146
- return isSignal(value) ? value : new WrappedSignalImpl(null, getProp, [ obj, prop ], null, 1);
1147
- };
1148
-
1149
1219
  const _wrapSignal = (obj, prop) => {
1150
1220
  const r = _wrapProp(obj, prop);
1151
1221
  return r === _IMMUTABLE ? obj[prop] : r;
@@ -1168,7 +1238,7 @@ function isSlotProp(prop) {
1168
1238
  return !prop.startsWith("q:") && !prop.startsWith(":");
1169
1239
  }
1170
1240
 
1171
- const _restProps = (props, omit, target = {}) => {
1241
+ const _restProps = (props, omit = [], target = {}) => {
1172
1242
  let constPropsTarget = null;
1173
1243
  const constProps = props[_CONST_PROPS];
1174
1244
  if (constProps) {
@@ -1410,45 +1480,51 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1410
1480
  const inlineComponent = componentQRL;
1411
1481
  componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
1412
1482
  }
1413
- const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1414
- container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)),
1415
- vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props))), (jsx => {
1483
+ const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1484
+ container.setHostProp(renderHost, ":onIdx", null)), vnode_isVNode(renderHost) && clearAllEffects(container, renderHost),
1485
+ componentFn(props)), jsx => {
1416
1486
  const useOnEvents = container.getHostProp(renderHost, ":on");
1417
1487
  return useOnEvents ? addUseOnEvents(jsx, useOnEvents) : jsx;
1418
- }), (err => {
1488
+ }, err => {
1419
1489
  if (isPromise(err) && retryCount < 100) {
1420
- return err.then((() => executeComponentWithPromiseExceptionRetry(retryCount++)));
1490
+ return err.then(() => executeComponentWithPromiseExceptionRetry(++retryCount));
1491
+ }
1492
+ if (retryCount >= 100) {
1493
+ throw new Error("Max retry count of component execution reached");
1421
1494
  }
1422
1495
  throw err;
1423
- }));
1496
+ });
1424
1497
  return executeComponentWithPromiseExceptionRetry();
1425
1498
  };
1426
1499
 
1427
1500
  function addUseOnEvents(jsx, useOnEvents) {
1428
- const jsxElement = findFirstStringJSX(jsx);
1501
+ const jsxElement = findFirstElementNode(jsx);
1429
1502
  let jsxResult = jsx;
1430
- return maybeThen(jsxElement, (jsxElement => {
1431
- let isInvisibleComponent = !1;
1432
- jsxElement || (isInvisibleComponent = !0);
1503
+ return maybeThen(jsxElement, jsxElement => {
1504
+ const isHeadless = !jsxElement;
1505
+ let placeholderElement = null;
1433
1506
  for (const key in useOnEvents) {
1434
1507
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
1435
- if (isInvisibleComponent) {
1436
- if ("onQvisible$" === key) {
1437
- const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
1438
- jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]);
1439
- } else if (key.startsWith("document:") || key.startsWith("window:")) {
1440
- const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
1441
- jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
1442
- } else {
1508
+ let targetElement = jsxElement;
1509
+ let eventKey = key;
1510
+ if (isHeadless) {
1511
+ if ("onQvisible$" !== key && !key.startsWith("document:on") && !key.startsWith("window:on")) {
1443
1512
  isDev && logWarn('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. ');
1513
+ continue;
1444
1514
  }
1445
- } else {
1446
- jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
1515
+ if (!placeholderElement) {
1516
+ const [createdElement, newJsx] = injectPlaceholderElement(jsxResult);
1517
+ jsxResult = newJsx, placeholderElement = createdElement;
1518
+ }
1519
+ targetElement = placeholderElement;
1447
1520
  }
1521
+ targetElement && ("script" === targetElement.type && "onQvisible$" === key && (eventKey = "document:onQInit$",
1522
+ logWarn('You are trying to add an event "' + key + '" using `useVisibleTask$` hook, but a node to which you can add an event is not found. Using document:onQInit$ instead.')),
1523
+ addUseOnEvent(targetElement, eventKey, useOnEvents[key]));
1448
1524
  }
1449
1525
  }
1450
1526
  return jsxResult;
1451
- }));
1527
+ });
1452
1528
  }
1453
1529
 
1454
1530
  function addUseOnEvent(jsxElement, key, value) {
@@ -1459,7 +1535,7 @@ function addUseOnEvent(jsxElement, key, value) {
1459
1535
  propValue.push(...value), props[key] = propValue;
1460
1536
  }
1461
1537
 
1462
- function findFirstStringJSX(jsx) {
1538
+ function findFirstElementNode(jsx) {
1463
1539
  const queue = [ jsx ];
1464
1540
  for (;queue.length; ) {
1465
1541
  const jsx = queue.shift();
@@ -1468,34 +1544,42 @@ function findFirstStringJSX(jsx) {
1468
1544
  return jsx;
1469
1545
  }
1470
1546
  queue.push(jsx.children);
1471
- } else if (Array.isArray(jsx)) {
1547
+ } else if (isArray(jsx)) {
1472
1548
  queue.push(...jsx);
1473
1549
  } else {
1474
1550
  if (isPromise(jsx)) {
1475
- return maybeThen(jsx, (jsx => findFirstStringJSX(jsx)));
1551
+ return maybeThen(jsx, jsx => findFirstElementNode(jsx));
1476
1552
  }
1477
1553
  if (isSignal(jsx)) {
1478
- return findFirstStringJSX(untrack((() => jsx.value)));
1554
+ return findFirstElementNode(untrack(() => jsx.value));
1479
1555
  }
1480
1556
  }
1481
1557
  }
1482
1558
  return null;
1483
1559
  }
1484
1560
 
1485
- function addScriptNodeForInvisibleComponents(jsx) {
1561
+ function injectPlaceholderElement(jsx) {
1486
1562
  if (isJSXNode(jsx)) {
1487
- const jsxElement = new JSXNodeImpl("script", {}, {
1488
- type: "placeholder",
1489
- hidden: ""
1490
- }, null, 3);
1491
- return jsx.type === Slot ? [ jsxElement, _jsxSorted(Fragment, null, null, [ jsx, jsxElement ], 0, null) ] : (null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
1492
- [ jsxElement, jsx ]);
1563
+ const placeholder = createPlaceholderScriptNode();
1564
+ return jsx.type === Slot ? [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ] : (null == jsx.children ? jsx.children = placeholder : isArray(jsx.children) ? jsx.children.push(placeholder) : jsx.children = [ jsx.children, placeholder ],
1565
+ [ placeholder, jsx ]);
1566
+ }
1567
+ if (isPrimitive(jsx)) {
1568
+ const placeholder = createPlaceholderScriptNode();
1569
+ return [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
1493
1570
  }
1494
- if (Array.isArray(jsx) && jsx.length) {
1495
- const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]);
1496
- return [ jsxElement, jsx ];
1571
+ if (isArray(jsx) && jsx.length > 0) {
1572
+ const [createdElement, _] = injectPlaceholderElement(jsx[0]);
1573
+ return [ createdElement, jsx ];
1497
1574
  }
1498
- return [ null, null ];
1575
+ return [ null, jsx ];
1576
+ }
1577
+
1578
+ function createPlaceholderScriptNode() {
1579
+ return new JSXNodeImpl("script", {}, {
1580
+ type: "placeholder",
1581
+ hidden: ""
1582
+ }, null, 3);
1499
1583
  }
1500
1584
 
1501
1585
  const applyInlineComponent = (ssr, componentHost, inlineComponentFunction, jsx) => {
@@ -1507,10 +1591,10 @@ const applyQwikComponentBody = (ssr, jsx, component) => {
1507
1591
  const host = ssr.getOrCreateLastNode();
1508
1592
  const [componentQrl] = component[SERIALIZABLE_STATE];
1509
1593
  const srcProps = jsx.props;
1510
- srcProps && srcProps.children && delete srcProps.children;
1511
- const scheduler = ssr.$scheduler$;
1512
- return host.setProp("q:renderFn", componentQrl), host.setProp("q:props", srcProps),
1513
- null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(6, host, componentQrl, srcProps);
1594
+ srcProps && srcProps.children && delete srcProps.children, host.setProp("q:renderFn", componentQrl),
1595
+ host.setProp("q:props", srcProps), null !== jsx.key && host.setProp("q:key", jsx.key);
1596
+ const componentChore = ssr.$scheduler$(6, host, componentQrl, srcProps);
1597
+ return getChorePromise(componentChore);
1514
1598
  };
1515
1599
 
1516
1600
  class ParentComponentData {
@@ -1531,7 +1615,12 @@ async function _walkJSX(ssr, value, options) {
1531
1615
  const value = stack.pop();
1532
1616
  if (value instanceof ParentComponentData) {
1533
1617
  options.currentStyleScoped = value.$scopedStyle$, options.parentComponentFrame = value.$componentFrame$;
1534
- } else if (value !== MaybeAsyncSignal) {
1618
+ } else {
1619
+ if (value === MaybeAsyncSignal) {
1620
+ const trackFn = stack.pop();
1621
+ await retryOnPromise(() => stack.push(trackFn()));
1622
+ continue;
1623
+ }
1535
1624
  if ("function" != typeof value) {
1536
1625
  processJSXNode(ssr, enqueue, value, {
1537
1626
  styleScoped: options.currentStyleScoped,
@@ -1544,9 +1633,6 @@ async function _walkJSX(ssr, value, options) {
1544
1633
  }
1545
1634
  await value.apply(ssr);
1546
1635
  }
1547
- } else {
1548
- const trackFn = stack.pop();
1549
- await retryOnPromise((() => stack.push(trackFn())));
1550
1636
  }
1551
1637
  }
1552
1638
  })();
@@ -1569,20 +1655,20 @@ function processJSXNode(ssr, enqueue, value, options) {
1569
1655
  } else if (isSignal(value)) {
1570
1656
  ssr.openFragment(isDev ? [ DEBUG_TYPE, "S" ] : EMPTY_ARRAY);
1571
1657
  const signalNode = ssr.getOrCreateLastNode();
1572
- enqueue(ssr.closeFragment), enqueue((() => trackSignalAndAssignHost(value, signalNode, ".", ssr))),
1658
+ enqueue(ssr.closeFragment), enqueue(() => trackSignalAndAssignHost(value, signalNode, ".", ssr)),
1573
1659
  enqueue(MaybeAsyncSignal);
1574
1660
  } else if (isPromise(value)) {
1575
1661
  ssr.openFragment(isDev ? [ DEBUG_TYPE, "A" ] : EMPTY_ARRAY), enqueue(ssr.closeFragment),
1576
- enqueue(value), enqueue(Promise), enqueue((() => ssr.commentNode("qkssr-f")));
1662
+ enqueue(value), enqueue(Promise), enqueue(() => ssr.commentNode("qkssr-f"));
1577
1663
  } else if (isAsyncGenerator(value)) {
1578
- enqueue((async () => {
1664
+ enqueue(async () => {
1579
1665
  for await (const chunk of value) {
1580
1666
  await _walkJSX(ssr, chunk, {
1581
1667
  currentStyleScoped: options.styleScoped,
1582
1668
  parentComponentFrame: options.parentComponentFrame
1583
1669
  }), ssr.commentNode("qkssr-f");
1584
1670
  }
1585
- }));
1671
+ });
1586
1672
  } else {
1587
1673
  const jsx = value;
1588
1674
  const type = jsx.type;
@@ -1590,7 +1676,14 @@ function processJSXNode(ssr, enqueue, value, options) {
1590
1676
  appendClassIfScopedStyleExists(jsx, options.styleScoped);
1591
1677
  let qwikInspectorAttrValue = null;
1592
1678
  isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = getFileLocationFromJsx(jsx.dev));
1593
- const innerHTML = ssr.openElement(type, varPropsToSsrAttrs(jsx.varProps, jsx.constProps, ssr.serializationCtx, options.styleScoped, jsx.key), constPropsToSsrAttrs(jsx.constProps, jsx.varProps, ssr.serializationCtx, options.styleScoped), qwikInspectorAttrValue);
1679
+ const innerHTML = ssr.openElement(type, varPropsToSsrAttrs(jsx.varProps, jsx.constProps, {
1680
+ serializationCtx: ssr.serializationCtx,
1681
+ styleScopedId: options.styleScoped,
1682
+ key: jsx.key
1683
+ }), constPropsToSsrAttrs(jsx.constProps, jsx.varProps, {
1684
+ serializationCtx: ssr.serializationCtx,
1685
+ styleScopedId: options.styleScoped
1686
+ }), qwikInspectorAttrValue);
1594
1687
  innerHTML && ssr.htmlNode(innerHTML), enqueue(ssr.closeElement), "head" === type ? (ssr.emitQwikLoaderAtTopIfNeeded(),
1595
1688
  ssr.emitPreloaderPre(), enqueue(ssr.additionalHeadNodes)) : "body" === type ? enqueue(ssr.additionalBodyNodes) : ssr.isHtml || ssr._didAddQwikLoader || (ssr.emitQwikLoaderAtTopIfNeeded(),
1596
1689
  ssr.emitPreloaderPre(), ssr._didAddQwikLoader = !0);
@@ -1658,18 +1751,19 @@ function processJSXNode(ssr, enqueue, value, options) {
1658
1751
  }
1659
1752
  }
1660
1753
 
1661
- function varPropsToSsrAttrs(varProps, constProps, serializationCtx, styleScopedId, key) {
1662
- return toSsrAttrs(varProps, constProps, serializationCtx, !0, styleScopedId, key);
1754
+ function varPropsToSsrAttrs(varProps, constProps, options) {
1755
+ return toSsrAttrs(varProps, constProps, !1, options);
1663
1756
  }
1664
1757
 
1665
- function constPropsToSsrAttrs(constProps, varProps, serializationCtx, styleScopedId) {
1666
- return toSsrAttrs(constProps, varProps, serializationCtx, !1, styleScopedId);
1758
+ function constPropsToSsrAttrs(constProps, varProps, options) {
1759
+ return toSsrAttrs(constProps, varProps, !0, options);
1667
1760
  }
1668
1761
 
1669
- function toSsrAttrs(record, anotherRecord, serializationCtx, pushMergedEventProps, styleScopedId, key) {
1762
+ function toSsrAttrs(record, anotherRecord, isConst, options) {
1670
1763
  if (null == record) {
1671
1764
  return null;
1672
1765
  }
1766
+ const pushMergedEventProps = !isConst;
1673
1767
  const ssrAttrs = [];
1674
1768
  for (const key in record) {
1675
1769
  let value = record[key];
@@ -1683,14 +1777,14 @@ function toSsrAttrs(record, anotherRecord, serializationCtx, pushMergedEventProp
1683
1777
  value = getMergedEventPropValues(value, anotherValue);
1684
1778
  }
1685
1779
  }
1686
- const eventValue = setEvent(serializationCtx, key, value);
1780
+ const eventValue = setEvent(options.serializationCtx, key, value);
1687
1781
  eventValue && ssrAttrs.push(jsxEventToHtmlAttribute(key), eventValue);
1688
- } else {
1689
- isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(serializationCtx, key),
1690
- value = serializeAttribute(key, value, styleScopedId), ssrAttrs.push(key, value));
1782
+ continue;
1691
1783
  }
1784
+ isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, options.styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(options.serializationCtx, key),
1785
+ value = serializeAttribute(key, value, options.styleScopedId), ssrAttrs.push(key, value));
1692
1786
  }
1693
- return null != key && ssrAttrs.push("q:key", key), ssrAttrs;
1787
+ return null != options.key && ssrAttrs.push("q:key", options.key), ssrAttrs;
1694
1788
  }
1695
1789
 
1696
1790
  function getMergedEventPropValues(value, anotherValue) {
@@ -1715,7 +1809,7 @@ function setEvent(serializationCtx, key, rawValue) {
1715
1809
  const appendToValue = valueToAppend => {
1716
1810
  value = (null == value ? "" : value + "\n") + valueToAppend;
1717
1811
  };
1718
- const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", queueQRL, null, null, [ qrl ])),
1812
+ const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", _run, null, null, [ qrl ])),
1719
1813
  qrlToString(serializationCtx, qrl));
1720
1814
  if (Array.isArray(qrls)) {
1721
1815
  for (let i = 0; i <= qrls.length; i++) {
@@ -1771,27 +1865,29 @@ const useTaskQrl = qrl => {
1771
1865
  assertQrl(qrl), set(1);
1772
1866
  const task = new Task(10, i, iCtx.$hostElement$, qrl, void 0, null);
1773
1867
  set(task);
1774
- const promise = iCtx.$container$.$scheduler$(3, task);
1775
- isPromise(promise) && promise.catch((() => {}));
1868
+ const result = runTask(task, iCtx.$container$, iCtx.$hostElement$);
1869
+ if (isPromise(result)) {
1870
+ throw result;
1871
+ }
1776
1872
  };
1777
1873
 
1778
1874
  const runTask = (task, container, host) => {
1779
1875
  task.$flags$ &= -9, cleanupTask(task);
1780
1876
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
1781
1877
  iCtx.$container$ = container;
1782
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
1878
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
1783
1879
  const track = trackFn(task, container);
1784
- const [cleanup] = cleanupFn(task, (reason => container.handleError(reason, host)));
1880
+ const [cleanup] = cleanupFn(task, reason => container.handleError(reason, host));
1785
1881
  const taskApi = {
1786
1882
  track,
1787
1883
  cleanup
1788
1884
  };
1789
- return safeCall((() => taskFn(taskApi)), cleanup, (err => {
1885
+ return safeCall(() => taskFn(taskApi), cleanup, err => {
1790
1886
  if (isPromise(err)) {
1791
- return err.then((() => runTask(task, container, host)));
1887
+ return err.then(() => runTask(task, container, host));
1792
1888
  }
1793
1889
  throw err;
1794
- }));
1890
+ });
1795
1891
  };
1796
1892
 
1797
1893
  const cleanupTask = task => {
@@ -1823,7 +1919,7 @@ const isTask = value => value instanceof Task;
1823
1919
 
1824
1920
  const scheduleTask = (_event, element) => {
1825
1921
  const [task] = useLexicalScope();
1826
- const type = 1 & task.$flags$ ? 32 : 3;
1922
+ const type = 1 & task.$flags$ ? 16 : 3;
1827
1923
  getDomContainer(element).$scheduler$(type, task);
1828
1924
  };
1829
1925
 
@@ -1835,11 +1931,11 @@ const _jsxSorted = (type, varProps, constProps, children, flags, key) => {
1835
1931
 
1836
1932
  const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
1837
1933
  let sortedProps;
1838
- return sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
1934
+ return sortedProps = varProps ? Object.fromEntries(untrack(() => Object.entries(varProps)).filter(entry => {
1839
1935
  const attr = entry[0];
1840
1936
  return "children" === attr ? (children ??= entry[1], !1) : "key" === attr ? (key = entry[1],
1841
1937
  !1) : !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
1842
- })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" == typeof type ? EMPTY_OBJ : {},
1938
+ }).sort(([a], [b]) => a < b ? -1 : 1)) : "string" == typeof type ? EMPTY_OBJ : {},
1843
1939
  constProps && "children" in constProps && (children = constProps.children, constProps.children = void 0),
1844
1940
  _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
1845
1941
  };
@@ -1910,10 +2006,10 @@ const Fragment = props => props.children;
1910
2006
 
1911
2007
  const jsxDEV = (type, props, key, _isStatic, opts) => {
1912
2008
  const processed = null == key ? null : String(key);
1913
- const children = untrack((() => {
2009
+ const children = untrack(() => {
1914
2010
  const c = props.children;
1915
2011
  return "string" == typeof type && delete props.children, c;
1916
- }));
2012
+ });
1917
2013
  isString(type) && "className" in props && (props.class = props.className, delete props.className);
1918
2014
  const node = new JSXNodeImpl(type, props, null, children, 0, processed);
1919
2015
  return node.dev = {
@@ -1944,7 +2040,7 @@ class PropsProxyHandler {
1944
2040
  return this.$children$;
1945
2041
  }
1946
2042
  const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
1947
- return value instanceof WrappedSignalImpl && 2 & value.$flags$ ? value.value : value;
2043
+ return value instanceof WrappedSignalImpl && 4 & value.$flags$ ? value.value : value;
1948
2044
  }
1949
2045
  set(_, prop, value) {
1950
2046
  return prop === _CONST_PROPS ? (this.$constProps$ = value, !0) : prop === _VAR_PROPS ? (this.$varProps$ = value,
@@ -1983,30 +2079,12 @@ class PropsProxyHandler {
1983
2079
 
1984
2080
  const directGetPropsProxyProp = (jsx, prop) => jsx.constProps && prop in jsx.constProps ? jsx.constProps[prop] : jsx.varProps[prop];
1985
2081
 
1986
- const mapApp_findIndx = (array, key, start) => {
1987
- assertTrue(start % 2 == 0, "Expecting even number.");
1988
- let bottom = start >> 1;
1989
- let top = array.length - 2 >> 1;
1990
- for (;bottom <= top; ) {
1991
- const mid = bottom + (top - bottom >> 1);
1992
- const midKey = array[mid << 1];
1993
- if (midKey === key) {
1994
- return mid << 1;
1995
- }
1996
- midKey < key ? bottom = mid + 1 : top = mid - 1;
1997
- }
1998
- return ~(bottom << 1);
1999
- };
2000
-
2001
- const mapArray_set = (array, key, value, start) => {
2002
- const indx = mapApp_findIndx(array, key, start);
2003
- indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(~indx, 0, key, value);
2004
- };
2082
+ const _getVarProps = props => props ? _VAR_PROPS in props ? "children" in props ? {
2083
+ ...props[_VAR_PROPS],
2084
+ children: props.children
2085
+ } : props[_VAR_PROPS] : props : null;
2005
2086
 
2006
- const mapArray_get = (array, key, start) => {
2007
- const indx = mapApp_findIndx(array, key, start);
2008
- return indx >= 0 ? array[indx + 1] : null;
2009
- };
2087
+ const _getConstProps = props => props && _CONST_PROPS in props ? props[_CONST_PROPS] : null;
2010
2088
 
2011
2089
  const isForeignObjectElement = elementName => isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
2012
2090
 
@@ -2153,6 +2231,27 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
2153
2231
  };
2154
2232
  }
2155
2233
 
2234
+ function getAttributeNamespace(attributeName) {
2235
+ switch (attributeName) {
2236
+ case "xlink:href":
2237
+ case "xlink:actuate":
2238
+ case "xlink:arcrole":
2239
+ case "xlink:role":
2240
+ case "xlink:show":
2241
+ case "xlink:title":
2242
+ case "xlink:type":
2243
+ return XLINK_NS;
2244
+
2245
+ case "xml:base":
2246
+ case "xml:lang":
2247
+ case "xml:space":
2248
+ return XML_NS;
2249
+
2250
+ default:
2251
+ return null;
2252
+ }
2253
+ }
2254
+
2156
2255
  function escapeHTML(html) {
2157
2256
  let escapedHTML = "";
2158
2257
  const length = html.length;
@@ -2198,42 +2297,44 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2198
2297
  const jsxNode = asyncQueue.shift();
2199
2298
  const vHostNode = asyncQueue.shift();
2200
2299
  if (isPromise(jsxNode)) {
2201
- return jsxNode.then((jsxNode => (diff(jsxNode, vHostNode), drainAsyncQueue())));
2300
+ return jsxNode.then(jsxNode => (diff(jsxNode, vHostNode), drainAsyncQueue()));
2202
2301
  }
2203
2302
  diff(jsxNode, vHostNode);
2204
2303
  }
2205
2304
  }();
2206
2305
  function diff(jsxNode, vStartNode) {
2207
- for (assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"), assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
2306
+ if (assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"), assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
2208
2307
  vParent = vStartNode, vNewNode = null, vCurrent = vnode_getFirstChild(vStartNode),
2209
- stackPush(jsxNode, !0); stack.length; ) {
2210
- for (;jsxIdx < jsxCount; ) {
2211
- if (assertFalse(vParent === vCurrent, "Parent and current can't be the same"), "string" == typeof jsxValue) {
2212
- expectText(jsxValue);
2213
- } else if ("number" == typeof jsxValue) {
2214
- expectText(String(jsxValue));
2215
- } else if (jsxValue && "object" == typeof jsxValue) {
2216
- if (Array.isArray(jsxValue)) {
2217
- descend(jsxValue, !1);
2218
- } else if (isSignal(jsxValue)) {
2219
- vCurrent && clearAllEffects(container, vCurrent), expectVirtual("S", null), descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, ".", container), !0);
2220
- } else if (isPromise(jsxValue)) {
2221
- expectVirtual("A", null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
2222
- } else if (isJSXNode(jsxValue)) {
2223
- const type = jsxValue.type;
2224
- "string" == typeof type ? (expectNoMoreTextNodes(), expectElement(jsxValue, type),
2225
- descend(jsxValue.children, !0)) : "function" == typeof type && (type === Fragment ? (expectNoMoreTextNodes(),
2226
- expectVirtual("F", jsxValue.key), descend(jsxValue.children, !0)) : type === Slot ? (expectNoMoreTextNodes(),
2227
- expectSlot() || descend(jsxValue.children, !0)) : type === Projection ? (expectProjection(),
2228
- descend(jsxValue.children, !0)) : type === SSRComment || type === SSRRaw ? expectNoMore() : (expectNoMoreTextNodes(),
2229
- expectComponent(type)));
2308
+ stackPush(jsxNode, !0), !(32 & vParent[0])) {
2309
+ for (;stack.length; ) {
2310
+ for (;jsxIdx < jsxCount; ) {
2311
+ if (assertFalse(vParent === vCurrent, "Parent and current can't be the same"), "string" == typeof jsxValue) {
2312
+ expectText(jsxValue);
2313
+ } else if ("number" == typeof jsxValue) {
2314
+ expectText(String(jsxValue));
2315
+ } else if (jsxValue && "object" == typeof jsxValue) {
2316
+ if (Array.isArray(jsxValue)) {
2317
+ descend(jsxValue, !1);
2318
+ } else if (isSignal(jsxValue)) {
2319
+ vCurrent && clearAllEffects(container, vCurrent), expectVirtual("S", null), descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, ".", container), !0);
2320
+ } else if (isPromise(jsxValue)) {
2321
+ expectVirtual("A", null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
2322
+ } else if (isJSXNode(jsxValue)) {
2323
+ const type = jsxValue.type;
2324
+ "string" == typeof type ? (expectNoMoreTextNodes(), expectElement(jsxValue, type),
2325
+ descend(jsxValue.children, !0)) : "function" == typeof type && (type === Fragment ? (expectNoMoreTextNodes(),
2326
+ expectVirtual("F", jsxValue.key), descend(jsxValue.children, !0)) : type === Slot ? (expectNoMoreTextNodes(),
2327
+ expectSlot() || descend(jsxValue.children, !0)) : type === Projection ? (expectProjection(),
2328
+ descend(jsxValue.children, !0)) : type === SSRComment || type === SSRRaw ? expectNoMore() : (expectNoMoreTextNodes(),
2329
+ expectComponent(type)));
2330
+ }
2331
+ } else {
2332
+ jsxValue === SkipRender ? journal = [] : expectText("");
2230
2333
  }
2231
- } else {
2232
- jsxValue === SkipRender ? journal = [] : expectText("");
2334
+ advance();
2233
2335
  }
2234
- advance();
2336
+ expectNoMore(), ascend();
2235
2337
  }
2236
- expectNoMore(), ascend();
2237
2338
  }
2238
2339
  }
2239
2340
  function advance() {
@@ -2285,7 +2386,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2285
2386
  }
2286
2387
  function expectProjection() {
2287
2388
  const slotName = jsxValue.key;
2288
- vCurrent = vnode_getProp(vParent, slotName, (id => vnode_locate(container.rootVNode, id))),
2389
+ vCurrent = vnode_getProp(vParent, slotName, id => vnode_locate(container.rootVNode, id)),
2289
2390
  vCurrent = vCurrent && 32 & vCurrent[0] ? null : vCurrent, null == vCurrent && (vNewNode = vnode_newVirtual(),
2290
2391
  isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P"), isDev && vnode_setProp(vNewNode, "q:code", "expectProjection"),
2291
2392
  vnode_setProp(vNewNode, QSlot, slotName), vnode_setProp(vNewNode, "q:sparent", vParent),
@@ -2351,43 +2452,52 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2351
2452
  htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
2352
2453
  }
2353
2454
  needsQDispatchEventPatch = !0;
2354
- } else {
2355
- if ("ref" === key) {
2356
- if (isSignal(value)) {
2357
- value.value = element;
2358
- continue;
2359
- }
2360
- if ("function" == typeof value) {
2361
- value(element);
2362
- continue;
2363
- }
2364
- if (null == value) {
2365
- continue;
2366
- }
2367
- throw qError(15, [ currentFile ]);
2368
- }
2455
+ continue;
2456
+ }
2457
+ if ("ref" === key) {
2369
2458
  if (isSignal(value)) {
2370
- const signalData = new SubscriptionData({
2371
- $scopedStyleIdPrefix$: scopedStyleIdPrefix,
2372
- $isConst$: !0
2373
- });
2374
- value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
2459
+ value.value = element;
2460
+ continue;
2375
2461
  }
2376
- if (key !== dangerouslySetInnerHTML) {
2377
- if ("textarea" !== elementName || "value" !== key) {
2378
- value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && element.setAttribute(key, String(value));
2379
- } else {
2380
- if (value && "string" != typeof value) {
2381
- if (isDev) {
2382
- throw qError(23, [ currentFile, value ]);
2462
+ if ("function" == typeof value) {
2463
+ value(element);
2464
+ continue;
2465
+ }
2466
+ if (null == value) {
2467
+ continue;
2468
+ }
2469
+ throw qError(15, [ currentFile ]);
2470
+ }
2471
+ if (isSignal(value)) {
2472
+ const signalData = new SubscriptionData({
2473
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
2474
+ $isConst$: !0
2475
+ });
2476
+ value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
2477
+ }
2478
+ if (key !== dangerouslySetInnerHTML) {
2479
+ if ("textarea" !== elementName || "value" !== key) {
2480
+ if (value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value) {
2481
+ if (64 & vNewNode[0]) {
2482
+ const namespace = getAttributeNamespace(key);
2483
+ if (namespace) {
2484
+ element.setAttributeNS(namespace, key, String(value));
2485
+ continue;
2383
2486
  }
2384
- continue;
2385
2487
  }
2386
- element.value = escapeHTML(value || "");
2488
+ element.setAttribute(key, String(value));
2387
2489
  }
2388
2490
  } else {
2389
- element.innerHTML = value, element.setAttribute("q:container", "html");
2491
+ if (value && "string" != typeof value) {
2492
+ if (isDev) {
2493
+ throw qError(23, [ currentFile, value ]);
2494
+ }
2495
+ continue;
2496
+ }
2497
+ element.value = escapeHTML(value || "");
2390
2498
  }
2499
+ } else {
2500
+ value && (element.innerHTML = String(value), element.setAttribute("q:container", "html"));
2391
2501
  }
2392
2502
  }
2393
2503
  }
@@ -2484,12 +2594,16 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2484
2594
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
2485
2595
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
2486
2596
  let returnValue = !1;
2487
- return qrls.flat(2).forEach((qrl => {
2597
+ return qrls.flat(2).forEach(qrl => {
2488
2598
  if (qrl) {
2489
- const value = container.$scheduler$(2, vNode, qrl, [ event, element ]);
2490
- returnValue = returnValue || !0 === value;
2599
+ if (isSyncQrl(qrl)) {
2600
+ qrl(event, element);
2601
+ } else {
2602
+ const value = container.$scheduler$(2, vNode, qrl, [ event, element ]);
2603
+ returnValue = returnValue || !0 === value;
2604
+ }
2491
2605
  }
2492
- })), returnValue;
2606
+ }), returnValue;
2493
2607
  }));
2494
2608
  }
2495
2609
  function registerQwikLoaderEvent(eventName) {
@@ -2541,9 +2655,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2541
2655
  host = vNewNode, shouldRender = !0) : (vNewNode = retrieveChildWithKey(null, lookupKey),
2542
2656
  vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : (insertNewComponent(host, componentQRL, jsxProps),
2543
2657
  shouldRender = !0), host = vNewNode), host) {
2544
- const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
2545
- shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps), shouldRender && (host[0] &= -33,
2546
- container.$scheduler$(6, host, componentQRL, jsxProps));
2658
+ let vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
2659
+ const propsAreDifferent = propsDiffer(jsxProps, vNodeProps);
2660
+ shouldRender = shouldRender || propsAreDifferent, shouldRender && (propsAreDifferent && (vNodeProps ? (vNodeProps[_CONST_PROPS] = jsxProps[_CONST_PROPS],
2661
+ vNodeProps[_VAR_PROPS] = jsxProps[_VAR_PROPS]) : jsxProps && (vnode_setProp(host, "q:props", jsxProps),
2662
+ vNodeProps = jsxProps)), vnode_setProp(host, "q:renderFn", componentQRL), host[0] &= -33,
2663
+ container.$scheduler$(6, host, componentQRL, vNodeProps));
2547
2664
  }
2548
2665
  !function(children, host) {
2549
2666
  const projectionChildren = Array.isArray(children) ? children : [ children ];
@@ -2679,7 +2796,7 @@ function cleanup(container, vNode) {
2679
2796
  const obj = seq[i];
2680
2797
  if (isTask(obj)) {
2681
2798
  const task = obj;
2682
- clearAllEffects(container, task), 1 & task.$flags$ ? container.$scheduler$(48, task) : cleanupTask(task);
2799
+ clearAllEffects(container, task), 1 & task.$flags$ ? container.$scheduler$(32, task) : cleanupTask(task);
2683
2800
  }
2684
2801
  }
2685
2802
  }
@@ -2705,7 +2822,9 @@ function cleanup(container, vNode) {
2705
2822
  if (vCursor === vNode) {
2706
2823
  const vFirstChild = vnode_getFirstChild(vCursor);
2707
2824
  if (vFirstChild) {
2708
- return void vnode_walkVNode(vFirstChild);
2825
+ return void vnode_walkVNode(vFirstChild, vNode => {
2826
+ 2 & vNode[0] && vnode_getProp(vNode, "q:sparent", id => vnode_locate(container.rootVNode, id));
2827
+ });
2709
2828
  }
2710
2829
  }
2711
2830
  } else {
@@ -2766,8 +2885,9 @@ const useResourceQrl = (qrl, opts) => {
2766
2885
  assertQrl(qrl);
2767
2886
  const container = iCtx.$container$;
2768
2887
  const resource = createResourceReturn(container, opts);
2769
- const task = new Task(12, i, iCtx.$hostElement$, qrl, resource, null);
2770
- return container.$scheduler$(3, task), set(resource), resource;
2888
+ const el = iCtx.$hostElement$;
2889
+ const task = new Task(12, i, el, qrl, resource, null);
2890
+ return set(resource), runResource(task, container, el), resource;
2771
2891
  };
2772
2892
 
2773
2893
  const Resource = props => _jsxSorted(Fragment, null, null, getResourceValueAsPromise(props), 0, null);
@@ -2775,8 +2895,8 @@ const Resource = props => _jsxSorted(Fragment, null, null, getResourceValueAsPro
2775
2895
  function getResourceValueAsPromise(props) {
2776
2896
  const resource = props.value;
2777
2897
  if (isResourceReturn(resource)) {
2898
+ const state = resource._state;
2778
2899
  if (!isServerPlatform()) {
2779
- const state = resource._state;
2780
2900
  if ("pending" === state && props.onPending) {
2781
2901
  return Promise.resolve().then(useBindInvokeContext(props.onPending));
2782
2902
  }
@@ -2784,16 +2904,22 @@ function getResourceValueAsPromise(props) {
2784
2904
  return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
2785
2905
  }
2786
2906
  {
2787
- const resolvedValue = untrack((() => resource._resolved));
2907
+ const resolvedValue = untrack(() => resource._resolved);
2788
2908
  if (void 0 !== resolvedValue) {
2789
2909
  return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
2790
2910
  }
2791
2911
  }
2792
2912
  }
2793
- const value = resource.value;
2794
- return value ? value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(void 0);
2913
+ return untrack(() => resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
2914
+ }
2915
+ if (isPromise(resource)) {
2916
+ return resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
2795
2917
  }
2796
- return isPromise(resource) ? resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : isSignal(resource) ? Promise.resolve(resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(resource).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
2918
+ if (isSignal(resource)) {
2919
+ const value = retryOnPromise(() => resource.value);
2920
+ return (isPromise(value) ? value : Promise.resolve(value)).then(useBindInvokeContext(props.onResolved));
2921
+ }
2922
+ return Promise.resolve(resource).then(useBindInvokeContext(props.onResolved));
2797
2923
  }
2798
2924
 
2799
2925
  const _createResourceReturn = opts => ({
@@ -2818,11 +2944,11 @@ const runResource = (task, container, host) => {
2818
2944
  task.$flags$ &= -9, cleanupTask(task);
2819
2945
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
2820
2946
  iCtx.$container$ = container;
2821
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
2947
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
2822
2948
  const resource = task.$state$;
2823
2949
  assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
2824
2950
  const track = trackFn(task, container);
2825
- const [cleanup, cleanups] = cleanupFn(task, (reason => container.handleError(reason, host)));
2951
+ const [cleanup, cleanups] = cleanupFn(task, reason => container.handleError(reason, host));
2826
2952
  const resourceTarget = unwrapStore(resource);
2827
2953
  const opts = {
2828
2954
  track,
@@ -2837,36 +2963,34 @@ const runResource = (task, container, host) => {
2837
2963
  let reject;
2838
2964
  let done = !1;
2839
2965
  const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
2840
- resource.loading = !1, resource._state = "resolved", resource._resolved = value,
2841
- resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
2842
- resource._error = value, reject(value)), !0);
2843
- cleanups.push((() => {
2844
- if (!0 === untrack((() => resource.loading))) {
2845
- const value = untrack((() => resource._resolved));
2966
+ resourceTarget.loading = !1, resourceTarget._state = "resolved", resourceTarget._resolved = value,
2967
+ resourceTarget._error = void 0, resolve(value)) : (done = !0, resourceTarget.loading = !1,
2968
+ resourceTarget._state = "rejected", resourceTarget._error = value, reject(value)),
2969
+ isServerPlatform() || forceStoreEffects(resource, "_state"), !0);
2970
+ cleanups.push(() => {
2971
+ if (!0 === untrack(() => resource.loading)) {
2972
+ const value = untrack(() => resource._resolved);
2846
2973
  setState(!0, value);
2847
2974
  }
2848
- })), invoke(iCtx, (() => {
2849
- resource._state = "pending", resource.loading = !isServerPlatform();
2850
- (resource.value = new Promise(((r, re) => {
2975
+ }), invoke(iCtx, () => {
2976
+ resource._state = "pending", resource.loading = !isServerPlatform(), resource.value = new Promise((r, re) => {
2851
2977
  resolve = r, reject = re;
2852
- }))).catch(ignoreErrorToPreventNodeFromCrashing);
2853
- }));
2854
- const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
2978
+ });
2979
+ });
2980
+ const promise = safeCall(() => taskFn(opts), value => {
2855
2981
  setState(!0, value);
2856
- }), (err => {
2982
+ }, err => {
2857
2983
  if (isPromise(err)) {
2858
- return err.then((() => runResource(task, container, host)));
2984
+ return err.then(() => runResource(task, container, host));
2859
2985
  }
2860
2986
  setState(!1, err);
2861
- }));
2987
+ });
2862
2988
  const timeout = resourceTarget._timeout;
2863
- return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
2989
+ return timeout > 0 ? Promise.race([ promise, delay(timeout).then(() => {
2864
2990
  setState(!1, new Error("timeout")) && cleanupTask(task);
2865
- })) ]) : promise;
2991
+ }) ]) : promise;
2866
2992
  };
2867
2993
 
2868
- const ignoreErrorToPreventNodeFromCrashing = () => {};
2869
-
2870
2994
  const aVNodePath = [];
2871
2995
 
2872
2996
  const bVNodePath = [];
@@ -2878,10 +3002,10 @@ const vnode_documentPosition = (a, b, rootVNode) => {
2878
3002
  let aDepth = -1;
2879
3003
  let bDepth = -1;
2880
3004
  for (;a; ) {
2881
- a = (aVNodePath[++aDepth] = a)[1] || rootVNode && vnode_getProp(a, "q:sparent", (id => vnode_locate(rootVNode, id)));
3005
+ a = (aVNodePath[++aDepth] = a)[1] || rootVNode && vnode_getProp(a, "q:sparent", id => vnode_locate(rootVNode, id));
2882
3006
  }
2883
3007
  for (;b; ) {
2884
- b = (bVNodePath[++bDepth] = b)[1] || rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id)));
3008
+ b = (bVNodePath[++bDepth] = b)[1] || rootVNode && vnode_getProp(b, "q:sparent", id => vnode_locate(rootVNode, id));
2885
3009
  }
2886
3010
  for (;aDepth >= 0 && bDepth >= 0; ) {
2887
3011
  if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
@@ -2897,7 +3021,7 @@ const vnode_documentPosition = (a, b, rootVNode) => {
2897
3021
  return -1;
2898
3022
  }
2899
3023
  } while (cursor);
2900
- return rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
3024
+ return rootVNode && vnode_getProp(b, "q:sparent", id => vnode_locate(rootVNode, id)) ? -1 : 1;
2901
3025
  }
2902
3026
  aDepth--, bDepth--;
2903
3027
  }
@@ -2915,10 +3039,10 @@ const ssrNodeDocumentPosition = (a, b) => {
2915
3039
  let aDepth = -1;
2916
3040
  let bDepth = -1;
2917
3041
  for (;a; ) {
2918
- a = (aSsrNodePath[++aDepth] = a).parentSsrNode;
3042
+ a = (aSsrNodePath[++aDepth] = a).parentComponent;
2919
3043
  }
2920
3044
  for (;b; ) {
2921
- b = (bSsrNodePath[++bDepth] = b).parentSsrNode;
3045
+ b = (bSsrNodePath[++bDepth] = b).parentComponent;
2922
3046
  }
2923
3047
  for (;aDepth >= 0 && bDepth >= 0; ) {
2924
3048
  if ((a = aSsrNodePath[aDepth]) !== (b = bSsrNodePath[bDepth])) {
@@ -2929,26 +3053,199 @@ const ssrNodeDocumentPosition = (a, b) => {
2929
3053
  return aDepth < bDepth ? -1 : 1;
2930
3054
  };
2931
3055
 
3056
+ const VISIBLE_BLOCKING_RULES = [ {
3057
+ blockedType: 16,
3058
+ blockingType: 4,
3059
+ match: (blocked, blocking, container) => isDescendant(blocked, blocking, container) || isDescendant(blocking, blocked, container)
3060
+ }, {
3061
+ blockedType: 16,
3062
+ blockingType: 6,
3063
+ match: (blocked, blocking, container) => isDescendant(blocked, blocking, container) || isDescendant(blocking, blocked, container)
3064
+ } ];
3065
+
3066
+ const BLOCKING_RULES = [ {
3067
+ blockedType: 2,
3068
+ blockingType: 1,
3069
+ match: (blocked, blocking) => {
3070
+ const blockedQrl = blocked.$target$;
3071
+ const blockingQrl = blocking.$target$;
3072
+ return isSameHost(blocked, blocking) && isSameQrl(blockedQrl, blockingQrl);
3073
+ }
3074
+ }, {
3075
+ blockedType: 3,
3076
+ blockingType: 1,
3077
+ match: (blocked, blocking) => {
3078
+ const blockedTask = blocked.$payload$;
3079
+ const blockingQrl = blocking.$target$;
3080
+ return isSameHost(blocked, blocking) && isSameQrl(blockedTask.$qrl$, blockingQrl);
3081
+ }
3082
+ }, {
3083
+ blockedType: 16,
3084
+ blockingType: 1,
3085
+ match: (blocked, blocking) => {
3086
+ const blockedTask = blocked.$payload$;
3087
+ const blockingQrl = blocking.$target$;
3088
+ return isSameHost(blocked, blocking) && isSameQrl(blockedTask.$qrl$, blockingQrl);
3089
+ }
3090
+ }, {
3091
+ blockedType: 4,
3092
+ blockingType: 6,
3093
+ match: (blocked, blocking) => blocked.$host$ === blocking.$host$
3094
+ }, {
3095
+ blockedType: 5,
3096
+ blockingType: 6,
3097
+ match: (blocked, blocking) => blocked.$host$ === blocking.$host$
3098
+ }, ...VISIBLE_BLOCKING_RULES, {
3099
+ blockedType: 3,
3100
+ blockingType: 3,
3101
+ match: (blocked, blocking, container) => {
3102
+ if (blocked.$host$ !== blocking.$host$) {
3103
+ return !1;
3104
+ }
3105
+ const blockedIdx = blocked.$idx$;
3106
+ if (!isNumber$1(blockedIdx) || blockedIdx <= 0) {
3107
+ return !1;
3108
+ }
3109
+ return findPreviousTaskInComponent(blocked.$host$, blockedIdx, container) === blocking.$payload$;
3110
+ }
3111
+ } ];
3112
+
3113
+ function isDescendant(descendantChore, ancestorChore, container) {
3114
+ const descendantHost = descendantChore.$host$;
3115
+ const ancestorHost = ancestorChore.$host$;
3116
+ return !(!vnode_isVNode(descendantHost) || !vnode_isVNode(ancestorHost)) && vnode_isDescendantOf(descendantHost, ancestorHost, container.rootVNode);
3117
+ }
3118
+
3119
+ function isSameHost(a, b) {
3120
+ return a.$host$ === b.$host$;
3121
+ }
3122
+
3123
+ function isSameQrl(a, b) {
3124
+ return a.$symbol$ === b.$symbol$;
3125
+ }
3126
+
3127
+ function findBlockingChoreInQueue(chore, choreQueue, container) {
3128
+ for (const candidate of choreQueue) {
3129
+ if (!(candidate.$type$ >= 16 || 3 === candidate.$type$) && isDescendant(chore, candidate, container)) {
3130
+ return candidate;
3131
+ }
3132
+ }
3133
+ return null;
3134
+ }
3135
+
3136
+ function findBlockingChore(chore, choreQueue, blockedChores, runningChores, container) {
3137
+ const blockingChoreInChoreQueue = findBlockingChoreInQueue(chore, choreQueue, container);
3138
+ if (blockingChoreInChoreQueue) {
3139
+ return blockingChoreInChoreQueue;
3140
+ }
3141
+ const blockingChoreInBlockedChores = findBlockingChoreInQueue(chore, Array.from(blockedChores), container);
3142
+ if (blockingChoreInBlockedChores) {
3143
+ return blockingChoreInBlockedChores;
3144
+ }
3145
+ const blockingChoreInRunningChores = findBlockingChoreInQueue(chore, Array.from(runningChores), container);
3146
+ if (blockingChoreInRunningChores) {
3147
+ return blockingChoreInRunningChores;
3148
+ }
3149
+ for (const rule of BLOCKING_RULES) {
3150
+ if (chore.$type$ === rule.blockedType) {
3151
+ for (const candidate of choreQueue) {
3152
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
3153
+ return candidate;
3154
+ }
3155
+ }
3156
+ for (const candidate of blockedChores) {
3157
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
3158
+ return candidate;
3159
+ }
3160
+ }
3161
+ for (const candidate of runningChores) {
3162
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
3163
+ return candidate;
3164
+ }
3165
+ }
3166
+ }
3167
+ }
3168
+ return null;
3169
+ }
3170
+
3171
+ function findPreviousTaskInComponent(host, currentTaskIdx, container) {
3172
+ const elementSeq = container.getHostProp(host, "q:seq");
3173
+ if (!elementSeq || elementSeq.length <= currentTaskIdx) {
3174
+ return null;
3175
+ }
3176
+ for (let i = currentTaskIdx - 1; i >= 0; i--) {
3177
+ const candidate = elementSeq[i];
3178
+ if (candidate instanceof Task && 2 & candidate.$flags$) {
3179
+ return candidate;
3180
+ }
3181
+ }
3182
+ return null;
3183
+ }
3184
+
3185
+ function findBlockingChoreForVisible(chore, runningChores, container) {
3186
+ for (const rule of VISIBLE_BLOCKING_RULES) {
3187
+ if (chore.$type$ === rule.blockedType) {
3188
+ for (const candidate of runningChores) {
3189
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
3190
+ return candidate;
3191
+ }
3192
+ }
3193
+ }
3194
+ }
3195
+ return null;
3196
+ }
3197
+
3198
+ const createNextTick = fn => {
3199
+ let nextTick;
3200
+ if ("function" == typeof setImmediate) {
3201
+ nextTick = () => {
3202
+ setImmediate(fn);
3203
+ };
3204
+ } else if ("undefined" != typeof MessageChannel) {
3205
+ const channel = new MessageChannel;
3206
+ channel.port1.onmessage = () => {
3207
+ fn();
3208
+ }, nextTick = () => {
3209
+ channel.port2.postMessage(null);
3210
+ };
3211
+ } else {
3212
+ nextTick = () => {
3213
+ setTimeout(fn);
3214
+ };
3215
+ }
3216
+ return nextTick;
3217
+ };
3218
+
2932
3219
  const DEBUG = !1;
2933
3220
 
2934
- const getPromise = chore => chore.$promise$ ||= new Promise((resolve => {
2935
- chore.$resolve$ = resolve;
2936
- }));
3221
+ var ChoreState;
3222
+
3223
+ !function(ChoreState) {
3224
+ ChoreState[ChoreState.NONE = 0] = "NONE", ChoreState[ChoreState.RUNNING = 1] = "RUNNING",
3225
+ ChoreState[ChoreState.FAILED = 2] = "FAILED", ChoreState[ChoreState.DONE = 3] = "DONE";
3226
+ }(ChoreState || (ChoreState = {}));
3227
+
3228
+ const getChorePromise = chore => chore.$state$ === ChoreState.NONE ? chore.$returnValue$ ||= new Promise((resolve, reject) => {
3229
+ chore.$resolve$ = resolve, chore.$reject$ = reject;
3230
+ }) : chore.$returnValue$;
2937
3231
 
2938
- const createScheduler = (container, scheduleDrain, journalFlush) => {
2939
- const choreQueue = [];
2940
- const qrlRuns = [];
2941
- let currentChore = null;
3232
+ const createScheduler = (container, journalFlush, choreQueue = [], blockedChores = new Set, runningChores = new Set) => {
3233
+ let drainChore = null;
2942
3234
  let drainScheduled = !1;
2943
- return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
2944
- const isServer = !isDomContainer(container);
2945
- const isComponentSsr = isServer && 6 === type;
2946
- const runLater = 255 !== type && !isComponentSsr && 2 !== type;
2947
- const isTask = 3 === type || 32 === type || 48 === type;
2948
- const isClientOnly = 16 === type || 4 === type || 5 === type || 1 === type || 7 === type;
2949
- if (isServer && isClientOnly) {
2950
- return;
2951
- }
3235
+ let isDraining = !1;
3236
+ let isJournalFlushRunning = !1;
3237
+ let flushBudgetStart = 0;
3238
+ let currentTime = performance.now();
3239
+ const nextTick = createNextTick(drainChoreQueue);
3240
+ function drainInNextTick() {
3241
+ drainScheduled || (drainScheduled = !0, nextTick());
3242
+ }
3243
+ const FREQUENCY_MS = Math.floor(1e3 / 60);
3244
+ return function(type, hostOrTask = null, targetOrQrl = null, payload = null) {
3245
+ if (255 === type && drainChore) {
3246
+ return drainChore;
3247
+ }
3248
+ const isTask = 3 === type || 16 === type || 32 === type;
2952
3249
  isTask && (hostOrTask.$flags$ |= 8);
2953
3250
  let chore = {
2954
3251
  $type$: type,
@@ -2956,183 +3253,218 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
2956
3253
  $host$: isTask ? hostOrTask.$el$ : hostOrTask,
2957
3254
  $target$: targetOrQrl,
2958
3255
  $payload$: isTask ? hostOrTask : payload,
2959
- $resolve$: null,
2960
- $promise$: null,
2961
- $returnValue$: null,
2962
- $executed$: !1
3256
+ $state$: ChoreState.NONE,
3257
+ $blockedChores$: null,
3258
+ $startTime$: void 0,
3259
+ $endTime$: void 0,
3260
+ $resolve$: void 0,
3261
+ $reject$: void 0,
3262
+ $returnValue$: null
2963
3263
  };
2964
- chore = function(sortedArray, value, rootVNode) {
2965
- const idx = function(sortedArray, value, rootVNode) {
2966
- let bottom = 0;
2967
- let top = sortedArray.length;
2968
- for (;bottom < top; ) {
2969
- const middle = bottom + (top - bottom >> 1);
2970
- const comp = choreComparator(value, sortedArray[middle], rootVNode);
2971
- if (comp < 0) {
2972
- top = middle;
2973
- } else {
2974
- if (!(comp > 0)) {
2975
- return middle;
2976
- }
2977
- bottom = middle + 1;
3264
+ if (255 === type) {
3265
+ return getChorePromise(chore), drainChore = chore, drainInNextTick(), chore;
3266
+ }
3267
+ const isServer = isServerPlatform();
3268
+ const isClientOnly = 4 === type || 1 === type;
3269
+ if (isServer && isClientOnly) {
3270
+ return finishChore(chore, void 0), chore;
3271
+ }
3272
+ if (isServer && chore.$host$ && isSsrNode(chore.$host$)) {
3273
+ if (!!!(1 & chore.$host$.flags) && 5 !== chore.$type$ && 7 !== chore.$type$) {
3274
+ const warningMessage = `A '${choreTypeToName(chore.$type$)}' chore was scheduled on a host element that has already been streamed to the client.\nThis can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n\nProblematic chore:\n - Type: ${choreTypeToName(chore.$type$)}\n - Host: ${chore.$host$.toString()}\n - Nearest element location: ${chore.$host$.currentFile}\n\nThis is often caused by modifying a signal in an already rendered component during SSR.`;
3275
+ return logWarn(warningMessage), chore;
3276
+ }
3277
+ }
3278
+ const blockingChore = findBlockingChore(chore, choreQueue, blockedChores, runningChores, container);
3279
+ if (blockingChore) {
3280
+ return addBlockedChore(chore, blockingChore, blockedChores), chore;
3281
+ }
3282
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
3283
+ const runImmediately = isServer && 6 === type || 2 === type;
3284
+ runImmediately && !isDraining ? (drainScheduled = !0, drainChoreQueue()) : drainInNextTick();
3285
+ return chore;
3286
+ };
3287
+ function applyJournalFlush() {
3288
+ isJournalFlushRunning || (isJournalFlushRunning = !0, journalFlush(), isJournalFlushRunning = !1,
3289
+ flushBudgetStart = performance.now());
3290
+ }
3291
+ function shouldApplyJournalFlush(isServer) {
3292
+ return !isServer && currentTime - flushBudgetStart >= FREQUENCY_MS;
3293
+ }
3294
+ function drainChoreQueue() {
3295
+ const isServer = isServerPlatform();
3296
+ if (drainScheduled = !1, isDraining) {
3297
+ return;
3298
+ }
3299
+ if (!choreQueue.length) {
3300
+ return applyJournalFlush(), void (drainChore && !runningChores.size && (drainChore.$resolve$(null),
3301
+ drainChore = null));
3302
+ }
3303
+ isDraining = !0, flushBudgetStart = performance.now();
3304
+ const maybeFinishDrain = () => choreQueue.length ? (drainInNextTick(), !1) : drainChore && runningChores.size ? (shouldApplyJournalFlush(isServer) && applyJournalFlush(),
3305
+ !1) : (currentChore = null, applyJournalFlush(), drainChore?.$resolve$(null), drainChore = null,
3306
+ !0);
3307
+ const scheduleBlockedChoresAndDrainIfNeeded = chore => {
3308
+ let blockedChoresScheduled = !1;
3309
+ if (chore.$blockedChores$) {
3310
+ for (const blockedChore of chore.$blockedChores$) {
3311
+ const blockingChore = findBlockingChore(blockedChore, choreQueue, blockedChores, runningChores, container);
3312
+ blockingChore ? addBlockedChore(blockedChore, blockingChore, blockedChores) : (blockedChores.delete(blockedChore),
3313
+ sortedInsert(choreQueue, blockedChore, container.rootVNode || null), blockedChoresScheduled = !0);
3314
+ }
3315
+ chore.$blockedChores$ = null;
3316
+ }
3317
+ blockedChoresScheduled && !isDraining && drainInNextTick();
3318
+ };
3319
+ let currentChore = null;
3320
+ try {
3321
+ for (;choreQueue.length; ) {
3322
+ currentTime = performance.now();
3323
+ const chore = currentChore = choreQueue.shift();
3324
+ if (chore.$state$ !== ChoreState.NONE) {
3325
+ continue;
3326
+ }
3327
+ if (vNodeAlreadyDeleted(chore) && 32 !== chore.$type$) {
3328
+ continue;
3329
+ }
3330
+ if (16 === chore.$type$) {
3331
+ applyJournalFlush();
3332
+ const blockingChore = findBlockingChoreForVisible(chore, runningChores, container);
3333
+ if (blockingChore && blockingChore.$state$ === ChoreState.RUNNING) {
3334
+ addBlockedChore(chore, blockingChore, blockedChores);
3335
+ continue;
2978
3336
  }
2979
3337
  }
2980
- return ~bottom;
2981
- }(sortedArray, value, rootVNode);
2982
- if (idx < 0) {
2983
- return sortedArray.splice(~idx, 0, value), value;
2984
- }
2985
- const existing = sortedArray[idx];
2986
- 4 === existing.$type$ && (existing.$payload$ = value.$payload$);
2987
- existing.$executed$ && (existing.$executed$ = !1);
2988
- return existing;
2989
- }(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
2990
- schedule(16), scheduleDrain()?.catch?.((() => {})));
2991
- return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
2992
- };
2993
- function drainUpTo(runUptoChore, isServer) {
2994
- let maxRetries = 5e3;
2995
- for (;choreQueue.length; ) {
2996
- if (maxRetries-- < 0) {
2997
- throw new Error("drainUpTo: max retries reached");
2998
- }
2999
- if (currentChore) {
3000
- return getPromise(currentChore).then((() => drainUpTo(runUptoChore, isServer))).catch((e => {
3001
- container.handleError(e, currentChore?.$host$);
3002
- }));
3003
- }
3004
- const nextChore = choreQueue[0];
3005
- if (nextChore.$executed$) {
3006
- if (choreQueue.shift(), nextChore === runUptoChore) {
3007
- break;
3338
+ chore.$startTime$ = performance.now();
3339
+ const result = executeChore(chore, isServer);
3340
+ if (chore.$returnValue$ = result, isPromise(result) ? (runningChores.add(chore),
3341
+ chore.$state$ = ChoreState.RUNNING, result.then(value => {
3342
+ finishChore(chore, value);
3343
+ }).catch(e => {
3344
+ chore.$state$ === ChoreState.RUNNING && handleError(chore, e);
3345
+ }).finally(() => {
3346
+ if (runningChores.delete(chore), scheduleBlockedChoresAndDrainIfNeeded(chore), !runningChores.size) {
3347
+ let finished = !1;
3348
+ drainChore && (finished = maybeFinishDrain()), finished || isDraining || applyJournalFlush();
3349
+ }
3350
+ })) : (finishChore(chore, result), scheduleBlockedChoresAndDrainIfNeeded(chore)),
3351
+ shouldApplyJournalFlush(isServer)) {
3352
+ return applyJournalFlush(), void drainInNextTick();
3008
3353
  }
3009
- } else {
3010
- vNodeAlreadyDeleted(nextChore) && 48 !== nextChore.$type$ ? choreQueue.shift() : executeChore(nextChore, isServer);
3011
3354
  }
3355
+ } catch (e) {
3356
+ handleError(currentChore, e), scheduleBlockedChoresAndDrainIfNeeded(currentChore);
3357
+ } finally {
3358
+ isDraining = !1, maybeFinishDrain();
3012
3359
  }
3013
- return runUptoChore.$returnValue$;
3360
+ }
3361
+ function finishChore(chore, value) {
3362
+ chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.DONE, chore.$returnValue$ = value,
3363
+ chore.$resolve$?.(value);
3364
+ }
3365
+ function handleError(chore, e) {
3366
+ chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.FAILED, chore.$reject$?.(e),
3367
+ container.handleError(e, chore.$host$);
3014
3368
  }
3015
3369
  function executeChore(chore, isServer) {
3016
3370
  const host = chore.$host$;
3017
- assertEqual(currentChore, null, "Chore already running."), currentChore = chore;
3018
- let returnValue = null;
3019
- try {
3020
- switch (chore.$type$) {
3021
- case 255:
3022
- isServer && (drainScheduled = !1);
3023
- break;
3024
-
3025
- case 16:
3026
- returnValue = journalFlush(), drainScheduled = !1;
3027
- break;
3028
-
3029
- case 6:
3030
- returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
3031
- if (isServer) {
3032
- return jsx;
3033
- }
3034
- {
3035
- const styleScopedId = container.getHostProp(host, "q:sstyle");
3036
- return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
3037
- }
3038
- }), (err => container.handleError(err, host)));
3039
- break;
3040
-
3041
- case 2:
3042
- {
3043
- const fn = chore.$target$.getFn();
3044
- const result = retryOnPromise((() => fn(...chore.$payload$)));
3045
- if (isPromise(result)) {
3046
- const handled = result.finally((() => {
3047
- qrlRuns.splice(qrlRuns.indexOf(handled), 1);
3048
- })).catch((error => {
3049
- container.handleError(error, chore.$host$);
3050
- }));
3051
- return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
3052
- currentChore = null, void (chore.$executed$ = !0);
3053
- }
3054
- returnValue = null;
3371
+ let returnValue;
3372
+ switch (chore.$type$) {
3373
+ case 6:
3374
+ returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), jsx => {
3375
+ if (isServer) {
3376
+ return jsx;
3055
3377
  }
3056
- break;
3057
-
3058
- case 3:
3059
- case 32:
3060
3378
  {
3061
- const payload = chore.$payload$;
3062
- if (4 & payload.$flags$) {
3063
- const result = runResource(payload, container, host);
3064
- returnValue = isServer ? result : null;
3065
- } else {
3066
- returnValue = runTask(payload, container, host);
3067
- }
3379
+ const styleScopedId = container.getHostProp(host, "q:sstyle");
3380
+ return retryOnPromise(() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId)));
3068
3381
  }
3069
- break;
3382
+ }, err => {
3383
+ handleError(chore, err);
3384
+ });
3385
+ break;
3070
3386
 
3071
- case 48:
3072
- cleanupTask(chore.$payload$);
3073
- break;
3387
+ case 2:
3388
+ {
3389
+ const fn = chore.$target$.getFn();
3390
+ returnValue = retryOnPromise(() => fn(...chore.$payload$));
3391
+ }
3392
+ break;
3074
3393
 
3075
- case 4:
3076
- {
3077
- const parentVirtualNode = chore.$target$;
3078
- let jsx = chore.$payload$;
3079
- isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
3080
- }
3081
- break;
3394
+ case 3:
3395
+ case 16:
3396
+ {
3397
+ const payload = chore.$payload$;
3398
+ returnValue = 4 & payload.$flags$ ? runResource(payload, container, host) : runTask(payload, container, host);
3399
+ }
3400
+ break;
3082
3401
 
3083
- case 5:
3084
- {
3085
- const virtualNode = chore.$host$;
3086
- const payload = chore.$payload$;
3087
- let value = payload.$value$;
3088
- isSignal(value) && (value = value.value);
3089
- const isConst = payload.$isConst$;
3090
- const journal = container.$journal$;
3091
- const property = chore.$idx$;
3092
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
3402
+ case 32:
3403
+ cleanupTask(chore.$payload$);
3404
+ break;
3405
+
3406
+ case 4:
3407
+ {
3408
+ const parentVirtualNode = chore.$target$;
3409
+ let jsx = chore.$payload$;
3410
+ isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise(() => vnode_diff(container, jsx, parentVirtualNode, null));
3411
+ }
3412
+ break;
3413
+
3414
+ case 5:
3415
+ {
3416
+ const virtualNode = chore.$host$;
3417
+ const payload = chore.$payload$;
3418
+ let value = payload.$value$;
3419
+ isSignal(value) && (value = value.value);
3420
+ const isConst = payload.$isConst$;
3421
+ const journal = container.$journal$;
3422
+ const property = chore.$idx$;
3423
+ const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
3424
+ if (isServer) {
3425
+ container.addBackpatchEntry(chore.$host$.id, property, serializedValue), returnValue = null;
3426
+ } else {
3093
3427
  if (isConst) {
3094
3428
  journal.push(2, virtualNode[6], property, serializedValue);
3095
3429
  } else {
3096
3430
  vnode_setAttr(journal, virtualNode, property, serializedValue);
3097
3431
  }
3432
+ returnValue = void 0;
3098
3433
  }
3099
- break;
3434
+ }
3435
+ break;
3100
3436
 
3101
- case 1:
3102
- {
3103
- const target = chore.$target$;
3104
- returnValue = target.resolved ? null : target.resolve();
3105
- }
3106
- break;
3437
+ case 1:
3438
+ {
3439
+ const target = chore.$target$;
3440
+ returnValue = target.resolved ? null : target.resolve();
3441
+ }
3442
+ break;
3107
3443
 
3108
- case 7:
3109
- {
3110
- const target = chore.$target$;
3111
- const effects = chore.$payload$;
3112
- if (target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl) {
3113
- const forceRunEffects = target.$forceRunEffects$;
3114
- if (target.$forceRunEffects$ = !1, !target.$effects$?.size) {
3115
- break;
3444
+ case 7:
3445
+ {
3446
+ const target = chore.$target$;
3447
+ const effects = chore.$payload$;
3448
+ if (!effects?.size) {
3449
+ break;
3450
+ }
3451
+ let shouldCompute = target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl;
3452
+ if (target instanceof AsyncComputedSignalImpl && effects !== target.$effects$ && (shouldCompute = !1),
3453
+ shouldCompute) {
3454
+ const ctx = newInvokeContext();
3455
+ ctx.$container$ = container, returnValue = maybeThen(retryOnPromise(() => invoke.call(target, ctx, target.$computeIfNeeded$)), () => {
3456
+ if (2 & target.$flags$) {
3457
+ return target.$flags$ &= -3, retryOnPromise(() => triggerEffects(container, target, effects));
3116
3458
  }
3117
- returnValue = retryOnPromise((() => {
3118
- (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, effects);
3119
- }));
3120
- } else {
3121
- returnValue = retryOnPromise((() => {
3122
- triggerEffects(container, target, effects);
3123
- }));
3124
- }
3459
+ });
3460
+ } else {
3461
+ returnValue = retryOnPromise(() => {
3462
+ triggerEffects(container, target, effects);
3463
+ });
3125
3464
  }
3126
3465
  }
3127
- } catch (e) {
3128
- returnValue = Promise.reject(e);
3129
3466
  }
3130
- const after = (value, error) => {
3131
- currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
3132
- chore.$resolve$?.(value));
3133
- };
3134
- isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error => after(void 0, error))),
3135
- chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
3467
+ return returnValue;
3136
3468
  }
3137
3469
  function choreComparator(a, b, rootVNode) {
3138
3470
  const macroTypeDiff = (240 & a.$type$) - (240 & b.$type$);
@@ -3150,8 +3482,6 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
3150
3482
  } else {
3151
3483
  assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode"),
3152
3484
  assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
3153
- const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
3154
- logWarn(errorMessage);
3155
3485
  const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
3156
3486
  if (0 !== hostDiff) {
3157
3487
  return hostDiff;
@@ -3163,7 +3493,39 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
3163
3493
  return microTypeDiff;
3164
3494
  }
3165
3495
  const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
3166
- return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
3496
+ return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ ? isQrl(a.$target$) && isQrl(b.$target$) && a.$target$.$hash$ === b.$target$.$hash$ ? 0 : 1 : 7 === a.$type$ && 7 === b.$type$ && (a.$target$ instanceof StoreHandler && b.$target$ instanceof StoreHandler || a.$target$ instanceof AsyncComputedSignalImpl && b.$target$ instanceof AsyncComputedSignalImpl) && a.$payload$ !== b.$payload$ ? 1 : 0;
3497
+ }
3498
+ function sortedInsert(sortedArray, value, rootVNode) {
3499
+ const idx = function(sortedArray, value, rootVNode) {
3500
+ let bottom = 0;
3501
+ let top = sortedArray.length;
3502
+ for (;bottom < top; ) {
3503
+ const middle = bottom + (top - bottom >> 1);
3504
+ const comp = choreComparator(value, sortedArray[middle], rootVNode);
3505
+ if (comp < 0) {
3506
+ top = middle;
3507
+ } else {
3508
+ if (!(comp > 0)) {
3509
+ return middle;
3510
+ }
3511
+ bottom = middle + 1;
3512
+ }
3513
+ }
3514
+ return ~bottom;
3515
+ }(sortedArray, value, rootVNode);
3516
+ if (idx < 0 && runningChores.size) {
3517
+ for (const chore of runningChores) {
3518
+ if (0 === choreComparator(value, chore, rootVNode)) {
3519
+ return chore;
3520
+ }
3521
+ }
3522
+ }
3523
+ if (idx < 0) {
3524
+ return sortedArray.splice(~idx, 0, value), value;
3525
+ }
3526
+ const existing = sortedArray[idx];
3527
+ return existing.$payload$ !== value.$payload$ && (existing.$payload$ = value.$payload$),
3528
+ existing;
3167
3529
  }
3168
3530
  };
3169
3531
 
@@ -3173,6 +3535,26 @@ function vNodeAlreadyDeleted(chore) {
3173
3535
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$[0]);
3174
3536
  }
3175
3537
 
3538
+ function addBlockedChore(blockedChore, blockingChore, blockedChores) {
3539
+ blockingChore.$blockedChores$ ||= [], blockingChore.$blockedChores$.push(blockedChore),
3540
+ blockedChores.add(blockedChore);
3541
+ }
3542
+
3543
+ function choreTypeToName(type) {
3544
+ return {
3545
+ 1: "Resolve QRL",
3546
+ 2: "Run QRL",
3547
+ 3: "Task",
3548
+ 4: "Changes diffing",
3549
+ 5: "Updating node property",
3550
+ 6: "Component",
3551
+ 7: "Signal recompute",
3552
+ 16: "Visible",
3553
+ 32: "Cleanup visible",
3554
+ 255: "Wait for queue"
3555
+ }[type] || "Unknown: " + type;
3556
+ }
3557
+
3176
3558
  function debugChoreTypeToString(type) {
3177
3559
  return {
3178
3560
  1: "QRL_RESOLVE",
@@ -3182,26 +3564,53 @@ function debugChoreTypeToString(type) {
3182
3564
  5: "NODE_PROP",
3183
3565
  6: "COMPONENT",
3184
3566
  7: "RECOMPUTE_SIGNAL",
3185
- 16: "JOURNAL_FLUSH",
3186
- 32: "VISIBLE",
3187
- 48: "CLEANUP_VISIBLE",
3188
- 255: "WAIT_FOR_ALL"
3567
+ 16: "VISIBLE",
3568
+ 32: "CLEANUP_VISIBLE",
3569
+ 255: "WAIT_FOR_QUEUE"
3189
3570
  }[type] || "UNKNOWN: " + type;
3190
3571
  }
3191
3572
 
3192
- function debugChoreToString(chore) {
3193
- const type = debugChoreTypeToString(chore.$type$);
3194
- const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
3195
- const qrlTarget = chore.$target$?.$symbol$;
3196
- return `Chore(${type} ${1 === chore.$type$ || 2 === chore.$type$ ? qrlTarget : host} ${chore.$idx$})`;
3197
- }
3198
-
3199
- function debugTrace(action, arg, currentChore, queue) {
3200
- const lines = [ "===========================\nScheduler: " + action ];
3201
- arg && !("$type$" in arg) && lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, "")),
3202
- queue && queue.forEach((chore => {
3203
- lines.push(` ${chore === arg ? ">>>" : " "} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore));
3204
- })), console.log(lines.join("\n") + "\n");
3573
+ function debugTrace(action, arg, queue, blockedChores) {
3574
+ const lines = [];
3575
+ if (lines.push(`Scheduler: ${action}`), arg) {
3576
+ if (lines.push(""), arg && "$type$" in arg) {
3577
+ const chore = arg;
3578
+ const type = debugChoreTypeToString(chore.$type$);
3579
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
3580
+ const qrlTarget = chore.$target$?.$symbol$;
3581
+ const targetOrHost = 1 === chore.$type$ || 2 === chore.$type$ ? qrlTarget : host;
3582
+ if (lines.push("🎯 Current Chore:"), lines.push(` Type: ${type}`), lines.push(` Host: ${targetOrHost}`),
3583
+ chore.$startTime$ && chore.$endTime$) {
3584
+ lines.push(` Time: ${(chore.$endTime$ - chore.$startTime$).toFixed(2)}ms`);
3585
+ } else if (chore.$startTime$) {
3586
+ const elapsedTime = performance.now() - chore.$startTime$;
3587
+ lines.push(` Time: ${elapsedTime.toFixed(2)}ms (running)`);
3588
+ }
3589
+ chore.$blockedChores$ && chore.$blockedChores$.length > 0 && (lines.push(" ⛔ Blocked Chores:"),
3590
+ chore.$blockedChores$.forEach((blockedChore, index) => {
3591
+ const blockedType = debugChoreTypeToString(blockedChore.$type$);
3592
+ const blockedTarget = String(blockedChore.$host$).replaceAll(/\n.*/gim, "");
3593
+ lines.push(` ${index + 1}. ${blockedType} ${blockedTarget} ${blockedChore.$idx$}`);
3594
+ }));
3595
+ } else {
3596
+ lines.push(`📝 Argument: ${String(arg).replaceAll(/\n.*/gim, "")}`);
3597
+ }
3598
+ }
3599
+ queue && queue.length > 0 && (lines.push(""), lines.push(`📋 Queue (${queue.length} items):`),
3600
+ queue.forEach(chore => {
3601
+ const activeMarker = chore === arg ? "▶ " : " ";
3602
+ const type = debugChoreTypeToString(chore.$type$);
3603
+ const state = chore.$state$ ? `[${ChoreState[chore.$state$]}]` : "";
3604
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
3605
+ const qrlTarget = chore.$target$?.$symbol$;
3606
+ lines.push(`${activeMarker}${state} ${type} ${1 === chore.$type$ || 2 === chore.$type$ ? qrlTarget : host} ${chore.$idx$}`);
3607
+ })), blockedChores && blockedChores.size > 0 && (lines.push(""), lines.push(`🚫 Blocked Chores (${blockedChores.size} items):`),
3608
+ Array.from(blockedChores).forEach((chore, index) => {
3609
+ const type = debugChoreTypeToString(chore.$type$);
3610
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
3611
+ const qrlTarget = chore.$target$?.$symbol$;
3612
+ lines.push(` ${index + 1}. ${type} ${1 === chore.$type$ || 2 === chore.$type$ ? qrlTarget : host} ${chore.$idx$}`);
3613
+ })), lines.push(""), lines.push("─".repeat(60)), console.log(lines.join("\n") + "\n");
3205
3614
  }
3206
3615
 
3207
3616
  class _SharedContainer {
@@ -3214,11 +3623,12 @@ class _SharedContainer {
3214
3623
  $currentUniqueId$=0;
3215
3624
  $instanceHash$=null;
3216
3625
  $buildBase$=null;
3217
- constructor(scheduleDrain, journalFlush, serverData, locale) {
3626
+ $flushEpoch$=0;
3627
+ constructor(journalFlush, serverData, locale) {
3218
3628
  this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
3219
3629
  this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
3220
3630
  throw Error("Not implemented");
3221
- }, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
3631
+ }, this.$scheduler$ = createScheduler(this, journalFlush);
3222
3632
  }
3223
3633
  trackSignalValue(signal, subscriber, property, data) {
3224
3634
  return trackSignalAndAssignHost(signal, subscriber, property, this, data);
@@ -3266,14 +3676,14 @@ function processVNodeData$1(document) {
3266
3676
  };
3267
3677
  })(prototype, "nodeType");
3268
3678
  const attachVnodeDataAndRefs = element => {
3269
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
3679
+ Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach(script => {
3270
3680
  script.setAttribute("type", "x-qwik/vnode");
3271
3681
  const qContainerElement = script.closest("[q\\:container]");
3272
3682
  qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
3273
- })), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
3683
+ }), element.querySelectorAll("[q\\:shadowroot]").forEach(parent => {
3274
3684
  const shadowRoot = parent.shadowRoot;
3275
3685
  shadowRoot && attachVnodeDataAndRefs(shadowRoot);
3276
- }));
3686
+ });
3277
3687
  };
3278
3688
  attachVnodeDataAndRefs(document);
3279
3689
  const getFastNodeType = node => {
@@ -3296,10 +3706,10 @@ function processVNodeData$1(document) {
3296
3706
  return 16;
3297
3707
  }
3298
3708
  if (nodeValue.startsWith("q:container")) {
3299
- return 5;
3709
+ return 9;
3300
3710
  }
3301
3711
  if (nodeValue.startsWith("/q:container-island")) {
3302
- return 128;
3712
+ return 64;
3303
3713
  }
3304
3714
  if (nodeValue.startsWith("/q:ignore")) {
3305
3715
  return 32;
@@ -3326,10 +3736,6 @@ function processVNodeData$1(document) {
3326
3736
  for (;node && (node = node.nextSibling) && 0 === getFastNodeType(node); ) {}
3327
3737
  return node;
3328
3738
  };
3329
- const firstChild = node => {
3330
- for (;node && (node = node.firstChild) && 0 === getFastNodeType(node); ) {}
3331
- return node;
3332
- };
3333
3739
  const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
3334
3740
  const vData_length = vData.length;
3335
3741
  let elementIdx = 0;
@@ -3366,7 +3772,7 @@ function processVNodeData$1(document) {
3366
3772
  }
3367
3773
  } while (65 !== getFastNodeType(islandNode));
3368
3774
  nextNode = null;
3369
- } else if (128 === nodeType) {
3775
+ } else if (64 === nodeType) {
3370
3776
  nextNode = node;
3371
3777
  do {
3372
3778
  if (nextNode = walker.nextNode(), !nextNode) {
@@ -3374,7 +3780,7 @@ function processVNodeData$1(document) {
3374
3780
  }
3375
3781
  } while (32 !== getFastNodeType(nextNode));
3376
3782
  nextNode = null;
3377
- } else if (5 === nodeType) {
3783
+ } else if (9 === nodeType) {
3378
3784
  nextNode = node;
3379
3785
  do {
3380
3786
  if (nextNode = nextSibling(nextNode), !nextNode) {
@@ -3386,7 +3792,7 @@ function processVNodeData$1(document) {
3386
3792
  nextNode = nextSibling(node);
3387
3793
  const shadowRootContainer = node;
3388
3794
  const shadowRoot = shadowRootContainer?.shadowRoot;
3389
- shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
3795
+ shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, shadowRoot, null, "", null);
3390
3796
  }
3391
3797
  if (!(2 & ~nodeType)) {
3392
3798
  if (vNodeElementIndex < elementIdx) {
@@ -3427,7 +3833,7 @@ function getDomContainerFromQContainerElement(qContainerElement) {
3427
3833
  }
3428
3834
 
3429
3835
  function _getQContainerElement(element) {
3430
- return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
3836
+ return (Array.isArray(element) ? vnode_getDomParent(element, !0) : element).closest(QContainerSelector);
3431
3837
  }
3432
3838
 
3433
3839
  const isDomContainer = container => container instanceof DomContainer;
@@ -3439,20 +3845,20 @@ class DomContainer extends _SharedContainer {
3439
3845
  rootVNode;
3440
3846
  document;
3441
3847
  $journal$;
3442
- renderDone=null;
3443
3848
  $rawStateData$;
3444
3849
  $storeProxyMap$=new WeakMap;
3445
3850
  $qFuncs$;
3446
3851
  $instanceHash$;
3447
3852
  $forwardRefs$=null;
3448
- $initialQRLsIndexes$=null;
3853
+ $initialQRLs$=null;
3449
3854
  vNodeLocate=id => vnode_locate(this.rootVNode, id);
3450
3855
  $stateData$;
3451
3856
  $styleIds$=null;
3452
- $renderCount$=0;
3453
3857
  constructor(element) {
3454
- if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
3455
- this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
3858
+ if (super(() => {
3859
+ this.$flushEpoch$++, vnode_applyJournal(this.$journal$);
3860
+ }, {}, element.getAttribute("q:locale")), this.qContainer = element.getAttribute("q:container"),
3861
+ !this.qContainer) {
3456
3862
  throw qError(25);
3457
3863
  }
3458
3864
  this.$journal$ = [ 3, element.ownerDocument ], this.document = element.ownerDocument,
@@ -3484,16 +3890,13 @@ class DomContainer extends _SharedContainer {
3484
3890
  }
3485
3891
  setContext(host, context, value) {
3486
3892
  let ctx = this.getHostProp(host, "q:ctx");
3487
- ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
3893
+ null == ctx && this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0, !0);
3488
3894
  }
3489
3895
  resolveContext(host, contextId) {
3490
3896
  for (;host; ) {
3491
3897
  const ctx = this.getHostProp(host, "q:ctx");
3492
- if (ctx) {
3493
- const value = mapArray_get(ctx, contextId.id, 0);
3494
- if (value) {
3495
- return value;
3496
- }
3898
+ if (null != ctx && mapArray_has(ctx, contextId.id, 0)) {
3899
+ return mapArray_get(ctx, contextId.id, 0);
3497
3900
  }
3498
3901
  host = this.getParentHost(host);
3499
3902
  }
@@ -3533,26 +3936,6 @@ class DomContainer extends _SharedContainer {
3533
3936
  }
3534
3937
  return vnode_getProp(vNode, name, getObjectById);
3535
3938
  }
3536
- scheduleRender() {
3537
- return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
3538
- this.renderDone.finally((() => emitEvent("qrender", {
3539
- instanceHash: this.$instanceHash$,
3540
- renderCount: this.$renderCount$
3541
- })));
3542
- }
3543
- processChores() {
3544
- let renderCount = this.$renderCount$;
3545
- const result = this.$scheduler$(255);
3546
- if (isPromise(result)) {
3547
- return result.then((async () => {
3548
- for (;renderCount !== this.$renderCount$; ) {
3549
- renderCount = this.$renderCount$, await this.$scheduler$(255);
3550
- }
3551
- this.renderDone = null;
3552
- }));
3553
- }
3554
- renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
3555
- }
3556
3939
  ensureProjectionResolved(vNode) {
3557
3940
  if (!(16 & vNode[0])) {
3558
3941
  vNode[0] |= 16;
@@ -3560,7 +3943,10 @@ class DomContainer extends _SharedContainer {
3560
3943
  for (let i = 0; i < props.length; i += 2) {
3561
3944
  if (isSlotProp(props[i])) {
3562
3945
  const value = props[i + 1];
3563
- "string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
3946
+ if ("string" == typeof value) {
3947
+ const projection = this.vNodeLocate(value);
3948
+ props[i + 1] = projection, vnode_getProp(projection, "q:sparent", id => this.vNodeLocate(id));
3949
+ }
3564
3950
  }
3565
3951
  }
3566
3952
  }
@@ -3576,9 +3962,9 @@ class DomContainer extends _SharedContainer {
3576
3962
  const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
3577
3963
  scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", convertStyleIdsToString(scopedStyleIds));
3578
3964
  }
3579
- if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll(QStyleSelector).forEach((style => {
3965
+ if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll(QStyleSelector).forEach(style => {
3580
3966
  this.$styleIds$.add(style.getAttribute(QStyle));
3581
- }))), !this.$styleIds$.has(styleId)) {
3967
+ })), !this.$styleIds$.has(styleId)) {
3582
3968
  this.$styleIds$.add(styleId);
3583
3969
  const styleElement = this.document.createElement("style");
3584
3970
  styleElement.setAttribute(QStyle, styleId), styleElement.textContent = content,
@@ -3599,11 +3985,12 @@ class DomContainer extends _SharedContainer {
3599
3985
  };
3600
3986
  }
3601
3987
  $scheduleInitialQRLs$() {
3602
- if (this.$initialQRLsIndexes$) {
3603
- for (const index of this.$initialQRLsIndexes$) {
3604
- this.$scheduler$(1, null, this.$getObjectById$(index));
3988
+ if (this.$initialQRLs$) {
3989
+ for (const qrl of this.$initialQRLs$) {
3990
+ const match = /#(.*)_([a-zA-Z0-9]+)(\[|$)/.exec(qrl);
3991
+ match && p(match[2], .3);
3605
3992
  }
3606
- this.$initialQRLsIndexes$ = null;
3993
+ this.$initialQRLs$ = null;
3607
3994
  }
3608
3995
  }
3609
3996
  }
@@ -3635,7 +4022,7 @@ const addQrlToSerializationCtx = (effectSubscriber, container) => {
3635
4022
  };
3636
4023
 
3637
4024
  const triggerEffects = (container, signal, effects) => {
3638
- const isBrowser = isDomContainer(container);
4025
+ const isBrowser = !isServerPlatform();
3639
4026
  if (effects) {
3640
4027
  const scheduleEffect = effectSubscription => {
3641
4028
  const consumer = effectSubscription[0];
@@ -3643,28 +4030,28 @@ const triggerEffects = (container, signal, effects) => {
3643
4030
  if (assertDefined(container, "Container must be defined."), isTask(consumer)) {
3644
4031
  consumer.$flags$ |= 8;
3645
4032
  let choreType = 3;
3646
- 1 & consumer.$flags$ && (choreType = 32), container.$scheduler$(choreType, consumer);
4033
+ 1 & consumer.$flags$ && (choreType = 16), container.$scheduler$(choreType, consumer);
3647
4034
  } else if (consumer instanceof SignalImpl) {
3648
4035
  consumer instanceof ComputedSignalImpl && (consumer.$computeQrl$.resolved || container.$scheduler$(1, null, consumer.$computeQrl$)),
3649
- consumer.$invalidate$();
4036
+ consumer.invalidate();
3650
4037
  } else if (":" === property) {
3651
4038
  const host = consumer;
3652
4039
  const qrl = container.getHostProp(host, "q:renderFn");
3653
4040
  assertDefined(qrl, "Component must have QRL");
3654
4041
  const props = container.getHostProp(host, "q:props");
3655
4042
  container.$scheduler$(6, host, qrl, props);
3656
- } else if (isBrowser) {
3657
- if ("." === property) {
4043
+ } else if ("." === property) {
4044
+ if (isBrowser) {
3658
4045
  container.$scheduler$(4, consumer, consumer, signal);
3659
- } else {
3660
- const effectData = effectSubscription[3];
3661
- if (effectData instanceof SubscriptionData) {
3662
- const payload = {
3663
- ...effectData.data,
3664
- $value$: signal
3665
- };
3666
- container.$scheduler$(5, consumer, property, payload);
3667
- }
4046
+ }
4047
+ } else {
4048
+ const effectData = effectSubscription[3];
4049
+ if (effectData instanceof SubscriptionData) {
4050
+ const payload = {
4051
+ ...effectData.data,
4052
+ $value$: signal
4053
+ };
4054
+ container.$scheduler$(5, consumer, property, payload);
3668
4055
  }
3669
4056
  }
3670
4057
  };
@@ -3674,7 +4061,20 @@ const triggerEffects = (container, signal, effects) => {
3674
4061
  }
3675
4062
  };
3676
4063
 
3677
- const isSerializerObj = obj => "object" == typeof obj && null !== obj && "function" == typeof obj[SerializerSymbol];
4064
+ const isSerializerObj = obj => isObject(obj) && "function" == typeof obj[SerializerSymbol];
4065
+
4066
+ const getComputedSignalFlags = serializationStrategy => {
4067
+ let flags = 1;
4068
+ switch (serializationStrategy) {
4069
+ case "never":
4070
+ flags |= 16;
4071
+ break;
4072
+
4073
+ case "always":
4074
+ flags |= 32;
4075
+ }
4076
+ return flags;
4077
+ };
3678
4078
 
3679
4079
  const stringifyPath = [];
3680
4080
 
@@ -3721,7 +4121,7 @@ function qwikDebugToString(value) {
3721
4121
  return value;
3722
4122
  }
3723
4123
 
3724
- const pad = (text, prefix) => String(text).split("\n").map(((line, idx) => (idx ? prefix : "") + line)).join("\n");
4124
+ const pad = (text, prefix) => String(text).split("\n").map((line, idx) => (idx ? prefix : "") + line).join("\n");
3725
4125
 
3726
4126
  const jsxToString = value => {
3727
4127
  if (isJSXNode(value)) {
@@ -3731,9 +4131,9 @@ const jsxToString = value => {
3731
4131
  str += " " + key + "=" + qwikDebugToString(val);
3732
4132
  }
3733
4133
  const children = value.children;
3734
- null != children ? (str += ">", Array.isArray(children) ? children.forEach((child => {
4134
+ null != children ? (str += ">", Array.isArray(children) ? children.forEach(child => {
3735
4135
  str += jsxToString(child);
3736
- })) : str += jsxToString(children), str += "</" + value.type + ">") : str += "/>";
4136
+ }) : str += jsxToString(children), str += "</" + value.type + ">") : str += "/>";
3737
4137
  }
3738
4138
  return str;
3739
4139
  }
@@ -3865,13 +4265,16 @@ const vnode_ensureElementInflated = vnode => {
3865
4265
  }
3866
4266
  };
3867
4267
 
3868
- function vnode_walkVNode(vNode) {
4268
+ function vnode_walkVNode(vNode, callback) {
3869
4269
  let vCursor = vNode;
3870
4270
  if (vnode_isTextVNode(vNode)) {
3871
4271
  return;
3872
4272
  }
3873
4273
  let vParent = null;
3874
4274
  for (;;) {
4275
+ if (callback?.(vCursor, vParent)) {
4276
+ return;
4277
+ }
3875
4278
  const vFirstChild = vnode_getFirstChild(vCursor);
3876
4279
  if (vFirstChild) {
3877
4280
  vCursor = vFirstChild;
@@ -3970,6 +4373,7 @@ const vnode_ensureTextInflated = (journal, vnode) => {
3970
4373
  const textVNode = ensureTextVNode(vnode);
3971
4374
  if (!(8 & textVNode[0])) {
3972
4375
  const parentNode = vnode_getDomParent(vnode);
4376
+ assertDefined(parentNode, "Missing parent node.");
3973
4377
  const sharedTextNode = textVNode[4];
3974
4378
  const doc = parentNode.ownerDocument;
3975
4379
  let cursor = vnode_getDomSibling(vnode, !1, !0);
@@ -4086,6 +4490,17 @@ const indexOfAlphanumeric = (id, length) => {
4086
4490
  return length;
4087
4491
  };
4088
4492
 
4493
+ const vnode_createErrorDiv = (document, host, err, journal) => {
4494
+ const errorDiv = document.createElement("errored-host");
4495
+ err && err instanceof Error && (errorDiv.props = {
4496
+ error: err
4497
+ }), errorDiv.setAttribute("q:key", "_error_");
4498
+ const vErrorDiv = vnode_newElement(errorDiv, "errored-host");
4499
+ return vnode_getDOMChildNodes(journal, host, !0).forEach(child => {
4500
+ vnode_insertBefore(journal, vErrorDiv, child, null);
4501
+ }), vErrorDiv;
4502
+ };
4503
+
4089
4504
  const parseBoolean = value => "false" !== value && Boolean(value);
4090
4505
 
4091
4506
  const isBooleanAttr = (element, key) => ("allowfullscreen" == key || "async" == key || "autofocus" == key || "autoplay" == key || "checked" == key || "controls" == key || "default" == key || "defer" == key || "disabled" == key || "formnovalidate" == key || "inert" == key || "ismap" == key || "itemscope" == key || "loop" == key || "multiple" == key || "muted" == key || "nomodule" == key || "novalidate" == key || "open" == key || "playsinline" == key || "readonly" == key || "required" == key || "reversed" == key || "selected" == key) && key in element;
@@ -4146,26 +4561,29 @@ const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
4146
4561
  }
4147
4562
  insertBefore = null;
4148
4563
  }
4149
- const domParentVNode = vnode_getDomParentVNode(parent);
4564
+ const domParentVNode = vnode_getDomParentVNode(parent, !1);
4150
4565
  const parentNode = domParentVNode && domParentVNode[6];
4151
4566
  let domChildren = null;
4152
4567
  domParentVNode && (domChildren = vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild)),
4153
4568
  newChildCurrentParent && (newChild[2] || newChild[3] || newChildCurrentParent !== parent) && vnode_remove(journal, newChildCurrentParent, newChild, !1);
4154
- let adjustedInsertBefore = null;
4155
- null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
4156
- adjustedInsertBefore && vnode_ensureInflatedIfText(journal, adjustedInsertBefore),
4157
- domChildren && domChildren.length && journal.push(5, parentNode, vnode_getNode(adjustedInsertBefore), ...domChildren);
4569
+ const parentIsDeleted = 32 & parent[0];
4570
+ if (!parentIsDeleted) {
4571
+ let adjustedInsertBefore = null;
4572
+ null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
4573
+ adjustedInsertBefore && vnode_ensureInflatedIfText(journal, adjustedInsertBefore),
4574
+ domChildren && domChildren.length && journal.push(5, parentNode, vnode_getNode(adjustedInsertBefore), ...domChildren);
4575
+ }
4158
4576
  const vNext = insertBefore;
4159
4577
  const vPrevious = vNext ? vNext[2] : parent[5];
4160
4578
  vNext ? vNext[2] = newChild : parent[5] = newChild, vPrevious ? vPrevious[3] = newChild : parent[4] = newChild,
4161
- newChild[2] = vPrevious, newChild[3] = vNext, newChild[1] = parent;
4579
+ newChild[2] = vPrevious, newChild[3] = vNext, newChild[1] = parent, parentIsDeleted && (newChild[0] |= 32);
4162
4580
  };
4163
4581
 
4164
- const vnode_getDomParent = vnode => (vnode = vnode_getDomParentVNode(vnode)) && vnode[6];
4582
+ const vnode_getDomParent = (vnode, includeProjection = !0) => (vnode = vnode_getDomParentVNode(vnode, includeProjection)) && vnode[6];
4165
4583
 
4166
- const vnode_getDomParentVNode = vnode => {
4584
+ const vnode_getDomParentVNode = (vnode, includeProjection = !0) => {
4167
4585
  for (;vnode && !vnode_isElementVNode(vnode); ) {
4168
- vnode = vnode[1];
4586
+ vnode = vnode[1] || (includeProjection ? vnode_getProp(vnode, "q:sparent", id => vnode_isVNode(id) ? id : null) : null);
4169
4587
  }
4170
4588
  return vnode;
4171
4589
  };
@@ -4173,7 +4591,7 @@ const vnode_getDomParentVNode = vnode => {
4173
4591
  const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
4174
4592
  if (assertEqual(vParent, vnode_getParent(vToRemove), "Parent mismatch."), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove),
4175
4593
  removeDOM) {
4176
- const domParent = vnode_getDomParent(vParent);
4594
+ const domParent = vnode_getDomParent(vParent, !1);
4177
4595
  if (vnode_getAttr(vParent, dangerouslySetInnerHTML)) {
4178
4596
  return;
4179
4597
  }
@@ -4371,7 +4789,7 @@ const materializeFromDOM = (vParent, firstChild, vData) => {
4371
4789
  }
4372
4790
  if (vParent[5] = vChild || null, vParent[4] = vFirstChild, vData) {
4373
4791
  let container = null;
4374
- processVNodeData(vData, ((peek, consumeValue) => {
4792
+ processVNodeData(vData, (peek, consumeValue) => {
4375
4793
  if (peek() === VNodeDataChar.ID) {
4376
4794
  container || (container = getDomContainer(vParent[6]));
4377
4795
  const id = consumeValue();
@@ -4380,18 +4798,30 @@ const materializeFromDOM = (vParent, firstChild, vData) => {
4380
4798
  peek() === VNodeDataChar.BACK_REFS ? (container || (container = getDomContainer(vParent[6])),
4381
4799
  setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
4382
4800
  }
4383
- }));
4801
+ });
4384
4802
  }
4385
4803
  return vFirstChild;
4386
4804
  };
4387
4805
 
4388
4806
  function setEffectBackRefFromVNodeData(vParent, value, container) {
4389
- const deserializedSubMap = container.$getObjectById$(value);
4390
4807
  if (vParent[_EFFECT_BACK_REF]) {
4391
- mergeMaps(vParent[_EFFECT_BACK_REF], deserializedSubMap);
4808
+ mergeMaps(vParent[_EFFECT_BACK_REF], container.$getObjectById$(value));
4392
4809
  } else {
4393
4810
  Object.defineProperty(vParent, _EFFECT_BACK_REF, {
4394
- value: deserializedSubMap
4811
+ get() {
4812
+ const subMap = container.$getObjectById$(value);
4813
+ return vParent[_EFFECT_BACK_REF] = subMap, subMap;
4814
+ },
4815
+ set(value) {
4816
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
4817
+ value,
4818
+ writable: !0,
4819
+ enumerable: !0,
4820
+ configurable: !0
4821
+ });
4822
+ },
4823
+ enumerable: !0,
4824
+ configurable: !0
4395
4825
  });
4396
4826
  }
4397
4827
  }
@@ -4400,7 +4830,8 @@ const processVNodeData = (vData, callback) => {
4400
4830
  let nextToConsumeIdx = 0;
4401
4831
  let ch = 0;
4402
4832
  let peekCh = 0;
4403
- const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
4833
+ const getChar = idx => idx < vData.length ? vData.charCodeAt(idx) : 0;
4834
+ const peek = () => 0 !== peekCh ? peekCh : peekCh = getChar(nextToConsumeIdx);
4404
4835
  const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
4405
4836
  const consumeValue = () => {
4406
4837
  consume();
@@ -4411,7 +4842,7 @@ const processVNodeData = (vData, callback) => {
4411
4842
  return vData.substring(start, nextToConsumeIdx);
4412
4843
  };
4413
4844
  for (;0 !== peek(); ) {
4414
- callback(peek, consumeValue, consume, nextToConsumeIdx);
4845
+ callback(peek, consumeValue, consume, getChar, nextToConsumeIdx);
4415
4846
  }
4416
4847
  };
4417
4848
 
@@ -4444,7 +4875,7 @@ const vnode_setAttr = (journal, vnode, key, value) => {
4444
4875
  journal && journal.push(2, vnode[6], key, value);
4445
4876
  }
4446
4877
  null == value ? props.splice(idx, 2) : props[idx + 1] = value;
4447
- } else if (null != value && (props.splice(~idx, 0, key, value), 1 & type)) {
4878
+ } else if (null != value && (props.splice(-1 ^ idx, 0, key, value), 1 & type)) {
4448
4879
  journal && journal.push(2, vnode[6], key, value);
4449
4880
  }
4450
4881
  }
@@ -4478,7 +4909,7 @@ const vnode_setProp = (vnode, key, value) => {
4478
4909
  ensureElementOrVirtualVNode(vnode);
4479
4910
  const props = vnode_getProps(vnode);
4480
4911
  const idx = mapApp_findIndx(props, key, 0);
4481
- idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
4912
+ idx >= 0 ? props[idx + 1] = value : null != value && props.splice(-1 ^ idx, 0, key, value);
4482
4913
  };
4483
4914
 
4484
4915
  const vnode_getPropStartIndex = vnode => {
@@ -4496,6 +4927,27 @@ const vnode_getProps = vnode => vnode[vnode_getPropStartIndex(vnode)];
4496
4927
 
4497
4928
  const vnode_getParent = vnode => vnode[1] || null;
4498
4929
 
4930
+ const vnode_isDescendantOf = (vnode, ancestor, rootVNode) => {
4931
+ let parent = vnode_getParentOrProjectionParent(vnode, rootVNode);
4932
+ for (;parent; ) {
4933
+ if (parent === ancestor) {
4934
+ return !0;
4935
+ }
4936
+ parent = vnode_getParentOrProjectionParent(parent, rootVNode);
4937
+ }
4938
+ return !1;
4939
+ };
4940
+
4941
+ const vnode_getParentOrProjectionParent = (vnode, rootVNode) => {
4942
+ if (rootVNode) {
4943
+ const parentProjection = vnode_getProp(vnode, "q:sparent", id => vnode_locate(rootVNode, id));
4944
+ if (parentProjection) {
4945
+ return parentProjection;
4946
+ }
4947
+ }
4948
+ return vnode_getParent(vnode);
4949
+ };
4950
+
4499
4951
  const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[6] : (assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node."),
4500
4952
  vnode[4]);
4501
4953
 
@@ -4516,12 +4968,12 @@ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1
4516
4968
  strings.push(qwikDebugToString(vnode_getText(vnode)));
4517
4969
  } else if (vnode_isVirtualVNode(vnode)) {
4518
4970
  const attrs = [ "[" + String(vnode[0] >>> 8) + "]" ];
4519
- vnode_getAttrKeys(vnode).forEach((key => {
4971
+ vnode_getAttrKeys(vnode).forEach(key => {
4520
4972
  if (key !== DEBUG_TYPE) {
4521
4973
  const value = vnode_getAttr(vnode, key);
4522
4974
  attrs.push(" " + key + "=" + qwikDebugToString(value));
4523
4975
  }
4524
- }));
4976
+ });
4525
4977
  const name = (colorize ? "" : "") + (VirtualTypeName[vnode_getAttr(vnode, DEBUG_TYPE) || "V"] || VirtualTypeName.V) + (colorize ? "" : "");
4526
4978
  strings.push("<" + name + attrs.join("") + ">");
4527
4979
  const child = vnode_getFirstChild(vnode);
@@ -4531,10 +4983,10 @@ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1
4531
4983
  const tag = vnode_getElementName(vnode);
4532
4984
  const attrs = [];
4533
4985
  const keys = vnode_getAttrKeys(vnode);
4534
- keys.forEach((key => {
4986
+ keys.forEach(key => {
4535
4987
  const value = vnode_getAttr(vnode, key);
4536
4988
  attrs.push(" " + key + "=" + qwikDebugToString(value));
4537
- }));
4989
+ });
4538
4990
  const node = vnode_getNode(vnode);
4539
4991
  if (node) {
4540
4992
  const vnodeData = node.ownerDocument.qVNodeData?.get(node);
@@ -4576,16 +5028,13 @@ function materializeFromVNodeData(vParent, vData, element, child) {
4576
5028
  let textIdx = 0;
4577
5029
  let combinedText = null;
4578
5030
  let container = null;
4579
- return processVNodeData(vData, ((peek, consumeValue, consume, nextToConsumeIdx) => {
5031
+ return processVNodeData(vData, (peek, consumeValue, consume, getChar, nextToConsumeIdx) => {
4580
5032
  if (isNumber(peek())) {
4581
- for (;!isElement(child); ) {
5033
+ for (;!isElement(child) || isQStyleElement(child); ) {
4582
5034
  if (!(child = fastNextSibling(child))) {
4583
5035
  throw qError(27, [ vData, peek(), nextToConsumeIdx ]);
4584
5036
  }
4585
5037
  }
4586
- for (;isQStyleElement(child); ) {
4587
- child = fastNextSibling(child);
4588
- }
4589
5038
  combinedText = null, previousTextNode = null;
4590
5039
  let value = 0;
4591
5040
  for (;isNumber(peek()); ) {
@@ -4605,7 +5054,9 @@ function materializeFromVNodeData(vParent, vData, element, child) {
4605
5054
  } else if (peek() === VNodeDataChar.PROPS) {
4606
5055
  vnode_setAttr(null, vParent, "q:props", consumeValue());
4607
5056
  } else if (peek() === VNodeDataChar.KEY) {
4608
- vnode_setAttr(null, vParent, "q:key", consumeValue());
5057
+ let value;
5058
+ getChar(nextToConsumeIdx + 1) === VNodeDataChar.SEPARATOR ? (consume(), value = decodeURI(consumeValue()),
5059
+ consume()) : value = consumeValue(), vnode_setAttr(null, vParent, "q:key", value);
4609
5060
  } else if (peek() === VNodeDataChar.SEQ) {
4610
5061
  vnode_setAttr(null, vParent, "q:seq", consumeValue());
4611
5062
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
@@ -4629,6 +5080,9 @@ function materializeFromVNodeData(vParent, vData, element, child) {
4629
5080
  } else if (peek() === VNodeDataChar.SLOT) {
4630
5081
  vnode_setAttr(null, vParent, QSlot, consumeValue());
4631
5082
  } else {
5083
+ for (;isQStyleElement(child); ) {
5084
+ child = fastNextSibling(child);
5085
+ }
4632
5086
  const textNode = child && 3 === fastNodeType(child) ? child : null;
4633
5087
  null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
4634
5088
  let length = 0;
@@ -4640,7 +5094,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
4640
5094
  addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)),
4641
5095
  textIdx += length;
4642
5096
  }
4643
- })), vParent[5] = vLast, vFirst;
5097
+ }), vParent[5] = vLast, vFirst;
4644
5098
  }
4645
5099
 
4646
5100
  const vnode_getType = vnode => {
@@ -4663,7 +5117,7 @@ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
4663
5117
  let projectionDepth = 1;
4664
5118
  for (;projectionDepth--; ) {
4665
5119
  for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
4666
- const qSlotParent = vnode_getProp(vHost, "q:sparent", (id => vnode_locate(rootVNode, id)));
5120
+ const qSlotParent = vnode_getProp(vHost, "q:sparent", id => vnode_locate(rootVNode, id));
4667
5121
  const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
4668
5122
  vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
4669
5123
  }
@@ -4687,9 +5141,11 @@ const VNodeArray = class VNode extends Array {
4687
5141
  }
4688
5142
  };
4689
5143
 
5144
+ const needsInflation = typeId => typeId >= 14 || 4 === typeId || 5 === typeId;
5145
+
4690
5146
  const deserializedProxyMap = new WeakMap;
4691
5147
 
4692
- const isDeserializerProxy = value => "object" == typeof value && null !== value && SERIALIZER_PROXY_UNWRAP in value;
5148
+ const isDeserializerProxy = value => isObject(value) && SERIALIZER_PROXY_UNWRAP in value;
4693
5149
 
4694
5150
  const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
4695
5151
 
@@ -4723,14 +5179,13 @@ class DeserializationHandler {
4723
5179
  const idx = 2 * i;
4724
5180
  const typeId = this.$data$[idx];
4725
5181
  const value = this.$data$[idx + 1];
4726
- if (void 0 === typeId) {
5182
+ if (0 === typeId) {
4727
5183
  return value;
4728
5184
  }
4729
5185
  const container = this.$container$;
4730
- let propValue = allocate(container, typeId, value);
4731
- return typeId >= 14 && (propValue = inflate(container, propValue, typeId, value)),
4732
- Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue,
4733
- propValue;
5186
+ const propValue = allocate(container, typeId, value);
5187
+ return Reflect.set(target, property, propValue), this.$data$[idx] = 0, this.$data$[idx + 1] = propValue,
5188
+ needsInflation(typeId) && inflate(container, propValue, typeId, value), propValue;
4734
5189
  }
4735
5190
  has(target, property) {
4736
5191
  return property === SERIALIZER_PROXY_UNWRAP || Object.prototype.hasOwnProperty.call(target, property);
@@ -4745,7 +5200,7 @@ class DeserializationHandler {
4745
5200
  return out;
4746
5201
  }
4747
5202
  const idx = 2 * i;
4748
- return this.$data$[idx] = void 0, this.$data$[idx + 1] = value, !0;
5203
+ return this.$data$[idx] = 0, this.$data$[idx + 1] = value, !0;
4749
5204
  }
4750
5205
  }
4751
5206
 
@@ -4760,318 +5215,300 @@ const _eagerDeserializeArray = (container, data) => {
4760
5215
  const resolvers = new WeakMap;
4761
5216
 
4762
5217
  const inflate = (container, target, typeId, data) => {
4763
- if (void 0 === typeId) {
4764
- return target;
4765
- }
4766
- switch (15 !== typeId && Array.isArray(data) && (data = _eagerDeserializeArray(container, data)),
4767
- typeId) {
4768
- case 15:
4769
- for (let i = 0; i < data.length; i += 4) {
4770
- const key = deserializeData(container, data[i], data[i + 1]);
4771
- const valType = data[i + 2];
4772
- const valData = data[i + 3];
4773
- 0 === valType || valType >= 14 ? Object.defineProperty(target, key, {
4774
- get() {
4775
- const value = deserializeData(container, valType, valData);
4776
- return target[key] = value, value;
4777
- },
4778
- set(value) {
4779
- Object.defineProperty(target, key, {
4780
- value,
4781
- writable: !0,
4782
- enumerable: !0,
4783
- configurable: !0
4784
- });
4785
- },
4786
- enumerable: !0,
4787
- configurable: !0
4788
- }) : target[key] = deserializeData(container, valType, valData);
4789
- }
4790
- break;
4791
-
4792
- case 20:
4793
- case 21:
4794
- inflateQRL(container, target);
4795
- break;
4796
-
4797
- case 22:
4798
- const task = target;
4799
- const v = data;
4800
- task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
4801
- task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
4802
- break;
4803
-
4804
- case 23:
4805
- const [resolved, result, effects] = data;
4806
- const resource = target;
4807
- resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
4808
- resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
4809
- resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
4810
- break;
4811
-
4812
- case 24:
4813
- target[SERIALIZABLE_STATE][0] = data[0];
4814
- break;
5218
+ if (0 !== typeId) {
5219
+ switch (Array.isArray(data) && (data = _eagerDeserializeArray(container, data)),
5220
+ typeId) {
5221
+ case 4:
5222
+ for (let i = 0; i < target.length; i++) {}
5223
+ break;
4815
5224
 
4816
- case 30:
4817
- case 31:
4818
- {
4819
- const [value, flags, effects] = data;
4820
- const store = getOrCreateStore(value, flags, container);
4821
- getStoreHandler(store).$effects$ = effects, target = store;
5225
+ case 5:
5226
+ for (let i = 0; i < data.length; i += 2) {
5227
+ target[data[i]] = data[i + 1];
5228
+ }
4822
5229
  break;
4823
- }
4824
5230
 
4825
- case 25:
4826
- {
4827
- const signal = target;
4828
- const d = data;
4829
- signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
5231
+ case 19:
5232
+ case 20:
5233
+ inflateQRL(container, target);
4830
5234
  break;
4831
- }
4832
5235
 
4833
- case 26:
4834
- {
4835
- const signal = target;
4836
- const d = data;
4837
- signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
4838
- signal.$untrackedValue$ = NEEDS_COMPUTATION, signal.$flags$ = d[3], signal.$flags$ |= 1,
4839
- signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
5236
+ case 21:
5237
+ const task = target;
5238
+ const v = data;
5239
+ task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
5240
+ task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
4840
5241
  break;
4841
- }
4842
5242
 
4843
- case 28:
4844
- {
4845
- const asyncComputed = target;
4846
- const d = data;
4847
- asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
4848
- asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
4849
- asyncComputed.$untrackedError$ = d[5];
4850
- d.length > 6 ? asyncComputed.$untrackedValue$ = d[6] : asyncComputed.$flags$ |= 1;
5243
+ case 22:
5244
+ const [resolved, result, effects] = data;
5245
+ const resource = target;
5246
+ resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
5247
+ resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
5248
+ resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
4851
5249
  break;
4852
- }
4853
5250
 
4854
- case 29:
4855
- case 27:
4856
- {
4857
- const computed = target;
4858
- const d = data;
4859
- computed.$computeQrl$ = d[0], computed.$effects$ = new Set(d[1]);
4860
- d.length > 2 ? (computed.$untrackedValue$ = d[2], 29 === typeId && (computed.$flags$ |= 1)) : (computed.$flags$ |= 1,
4861
- computed.$computeQrl$.resolve(), container.$scheduler$?.(1, null, computed.$computeQrl$));
5251
+ case 23:
5252
+ target[SERIALIZABLE_STATE][0] = data[0];
4862
5253
  break;
4863
- }
4864
5254
 
4865
- case 14:
4866
- {
4867
- const d = data;
4868
- target.message = d[0];
4869
- for (let i = 1; i < d.length; i += 2) {
4870
- target[d[i]] = d[i + 1];
5255
+ case 29:
5256
+ {
5257
+ const [, flags, effects] = data;
5258
+ const storeHandler = getStoreHandler(target);
5259
+ storeHandler.$flags$ = flags, storeHandler.$effects$ = effects;
5260
+ break;
4871
5261
  }
4872
- break;
4873
- }
4874
5262
 
4875
- case 32:
4876
- {
4877
- const formData = target;
4878
- const d = data;
4879
- for (let i = 0; i < d.length; i++) {
4880
- formData.append(d[i++], d[i]);
5263
+ case 24:
5264
+ {
5265
+ const signal = target;
5266
+ const d = data;
5267
+ signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
5268
+ break;
4881
5269
  }
4882
- break;
4883
- }
4884
5270
 
4885
- case 33:
4886
- {
4887
- const jsx = target;
4888
- const [type, varProps, constProps, children, flags, key] = data;
4889
- jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
4890
- jsx.flags = flags, jsx.key = key;
4891
- break;
4892
- }
5271
+ case 25:
5272
+ {
5273
+ const signal = target;
5274
+ const d = data;
5275
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
5276
+ signal.$untrackedValue$ = NEEDS_COMPUTATION, signal.$flags$ = d[3], signal.$flags$ |= 1,
5277
+ signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
5278
+ break;
5279
+ }
4893
5280
 
4894
- case 17:
4895
- {
4896
- const set = target;
4897
- const d = data;
4898
- for (let i = 0; i < d.length; i++) {
4899
- set.add(d[i]);
5281
+ case 27:
5282
+ {
5283
+ const asyncComputed = target;
5284
+ const d = data;
5285
+ asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
5286
+ asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
5287
+ asyncComputed.$untrackedError$ = d[5];
5288
+ d.length > 6 && (asyncComputed.$untrackedValue$ = d[6]), asyncComputed.$flags$ |= 1;
5289
+ break;
4900
5290
  }
4901
- break;
4902
- }
4903
5291
 
4904
- case 18:
4905
- {
4906
- const map = target;
4907
- const d = data;
4908
- for (let i = 0; i < d.length; i++) {
4909
- map.set(d[i++], d[i]);
5292
+ case 28:
5293
+ case 26:
5294
+ {
5295
+ const computed = target;
5296
+ const d = data;
5297
+ computed.$computeQrl$ = d[0], computed.$effects$ = new Set(d[1]);
5298
+ d.length > 2 ? (computed.$untrackedValue$ = d[2], 28 === typeId && (computed.$flags$ |= 1)) : (computed.$flags$ |= 1,
5299
+ computed.$computeQrl$.resolve(), container.$scheduler$(1, null, computed.$computeQrl$));
5300
+ break;
4910
5301
  }
4911
- break;
4912
- }
4913
5302
 
4914
- case 16:
4915
- {
4916
- const promise = target;
4917
- const [resolved, result] = data;
4918
- const [resolve, reject] = resolvers.get(promise);
4919
- resolved ? resolve(result) : reject(result);
4920
- break;
4921
- }
5303
+ case 14:
5304
+ {
5305
+ const d = data;
5306
+ target.message = d[0];
5307
+ for (let i = 1; i < d.length; i += 2) {
5308
+ target[d[i]] = d[i + 1];
5309
+ }
5310
+ break;
5311
+ }
4922
5312
 
4923
- case 19:
4924
- const bytes = target;
4925
- const buf = atob(data);
4926
- let i = 0;
4927
- for (const s of buf) {
4928
- bytes[i++] = s.charCodeAt(0);
4929
- }
4930
- break;
5313
+ case 30:
5314
+ {
5315
+ const formData = target;
5316
+ const d = data;
5317
+ for (let i = 0; i < d.length; i++) {
5318
+ formData.append(d[i++], d[i]);
5319
+ }
5320
+ break;
5321
+ }
4931
5322
 
4932
- case 34:
4933
- const propsProxy = target;
4934
- propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4935
- break;
5323
+ case 31:
5324
+ {
5325
+ const jsx = target;
5326
+ const [type, varProps, constProps, children, flags, key] = data;
5327
+ jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
5328
+ jsx.flags = flags, jsx.key = key;
5329
+ break;
5330
+ }
4936
5331
 
4937
- case 35:
4938
- {
4939
- const effectData = target;
4940
- effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
5332
+ case 16:
5333
+ {
5334
+ const set = target;
5335
+ const d = data;
5336
+ for (let i = 0; i < d.length; i++) {
5337
+ set.add(d[i]);
5338
+ }
5339
+ break;
5340
+ }
5341
+
5342
+ case 17:
5343
+ {
5344
+ const map = target;
5345
+ const d = data;
5346
+ for (let i = 0; i < d.length; i++) {
5347
+ map.set(d[i++], d[i]);
5348
+ }
5349
+ break;
5350
+ }
5351
+
5352
+ case 15:
5353
+ {
5354
+ const promise = target;
5355
+ const [resolved, result] = data;
5356
+ const [resolve, reject] = resolvers.get(promise);
5357
+ resolved ? resolve(result) : reject(result);
5358
+ break;
5359
+ }
5360
+
5361
+ case 18:
5362
+ const bytes = target;
5363
+ const buf = atob(data);
5364
+ let i = 0;
5365
+ for (const s of buf) {
5366
+ bytes[i++] = s.charCodeAt(0);
5367
+ }
4941
5368
  break;
4942
- }
4943
5369
 
4944
- default:
4945
- throw qError(16, [ typeId ]);
5370
+ case 32:
5371
+ const propsProxy = target;
5372
+ propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
5373
+ break;
5374
+
5375
+ case 33:
5376
+ {
5377
+ const effectData = target;
5378
+ effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
5379
+ break;
5380
+ }
5381
+
5382
+ default:
5383
+ throw qError(16, [ typeId ]);
5384
+ }
4946
5385
  }
4947
- return target;
4948
5386
  };
4949
5387
 
4950
- const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
5388
+ const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, _UNINITIALIZED, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4951
5389
 
4952
- const _constantNames = [ "undefined", "null", "true", "false", "''", "EMPTY_ARRAY", "EMPTY_OBJ", "NEEDS_COMPUTATION", "STORE_ALL_PROPS", "Slot", "Fragment", "NaN", "Infinity", "-Infinity", "MAX_SAFE_INTEGER", "MAX_SAFE_INTEGER-1", "MIN_SAFE_INTEGER" ];
5390
+ const _constantNames = [ "undefined", "null", "true", "false", "''", "EMPTY_ARRAY", "EMPTY_OBJ", "NEEDS_COMPUTATION", "STORE_ALL_PROPS", "_UNINITIALIZED", "Slot", "Fragment", "NaN", "Infinity", "-Infinity", "MAX_SAFE_INTEGER", "MAX_SAFE_INTEGER-1", "MIN_SAFE_INTEGER" ];
4953
5391
 
4954
5392
  const allocate = (container, typeId, value) => {
4955
- if (void 0 === value) {
4956
- return typeId;
5393
+ if (0 === typeId) {
5394
+ return value;
4957
5395
  }
4958
5396
  switch (typeId) {
4959
- case 0:
5397
+ case 1:
4960
5398
  return container.$getObjectById$(value);
4961
5399
 
4962
- case 1:
5400
+ case 2:
4963
5401
  if (!container.$forwardRefs$) {
4964
5402
  throw qError(18, [ "forward ref" ]);
4965
5403
  }
4966
- return container.$getObjectById$(container.$forwardRefs$[value]);
5404
+ const rootRef = container.$forwardRefs$[value];
5405
+ return -1 === rootRef ? _UNINITIALIZED : container.$getObjectById$(rootRef);
4967
5406
 
4968
- case 2:
4969
- case 4:
4970
- case 5:
5407
+ case 13:
4971
5408
  return value;
4972
5409
 
4973
5410
  case 3:
4974
5411
  return _constants[value];
4975
5412
 
4976
- case 6:
5413
+ case 4:
4977
5414
  return wrapDeserializerProxy(container, value);
4978
5415
 
4979
- case 15:
5416
+ case 5:
4980
5417
  return {};
4981
5418
 
5419
+ case 19:
4982
5420
  case 20:
4983
- case 21:
4984
5421
  return parseQRL("number" == typeof value ? container.$getObjectById$(value) : value);
4985
5422
 
4986
- case 22:
5423
+ case 21:
4987
5424
  return new Task(-1, -1, null, null, null, null);
4988
5425
 
4989
- case 23:
5426
+ case 22:
4990
5427
  {
4991
5428
  const res = createResourceReturn(container, void 0, void 0);
4992
5429
  return res.loading = !1, res;
4993
5430
  }
4994
5431
 
4995
- case 7:
5432
+ case 6:
4996
5433
  return new URL(value);
4997
5434
 
4998
- case 8:
5435
+ case 7:
4999
5436
  return new Date(value);
5000
5437
 
5001
- case 9:
5438
+ case 8:
5002
5439
  const idx = value.lastIndexOf("/");
5003
5440
  return new RegExp(value.slice(1, idx), value.slice(idx + 1));
5004
5441
 
5005
5442
  case 14:
5006
5443
  return new Error;
5007
5444
 
5008
- case 24:
5445
+ case 23:
5009
5446
  return componentQrl(null);
5010
5447
 
5011
- case 25:
5448
+ case 24:
5012
5449
  return new SignalImpl(container, 0);
5013
5450
 
5014
- case 26:
5451
+ case 25:
5015
5452
  return new WrappedSignalImpl(container, null, null, null);
5016
5453
 
5017
- case 27:
5454
+ case 26:
5018
5455
  return new ComputedSignalImpl(container, null);
5019
5456
 
5020
- case 28:
5457
+ case 27:
5021
5458
  return new AsyncComputedSignalImpl(container, null);
5022
5459
 
5023
- case 29:
5460
+ case 28:
5024
5461
  return new SerializerSignalImpl(container, null);
5025
5462
 
5026
- case 30:
5027
- case 31:
5028
- return null;
5463
+ case 29:
5464
+ const storeValue = deserializeData(container, value[0], value[1]);
5465
+ return value[0] = 0, value[1] = storeValue, getOrCreateStore(storeValue, 0, container);
5029
5466
 
5030
- case 13:
5467
+ case 12:
5031
5468
  return new URLSearchParams(value);
5032
5469
 
5033
- case 32:
5470
+ case 30:
5034
5471
  return new FormData;
5035
5472
 
5036
- case 33:
5473
+ case 31:
5037
5474
  return new JSXNodeImpl(null, null, null, null, -1, null);
5038
5475
 
5039
- case 12:
5476
+ case 11:
5040
5477
  return BigInt(value);
5041
5478
 
5042
- case 17:
5479
+ case 16:
5043
5480
  return new Set;
5044
5481
 
5045
- case 18:
5482
+ case 17:
5046
5483
  return new Map;
5047
5484
 
5048
- case 16:
5485
+ case 15:
5049
5486
  let resolve;
5050
5487
  let reject;
5051
- const promise = new Promise(((res, rej) => {
5488
+ const promise = new Promise((res, rej) => {
5052
5489
  resolve = res, reject = rej;
5053
- }));
5054
- return resolvers.set(promise, [ resolve, reject ]), promise.catch((() => {})), promise;
5490
+ });
5491
+ return resolvers.set(promise, [ resolve, reject ]), promise.catch(() => {}), promise;
5055
5492
 
5056
- case 19:
5493
+ case 18:
5057
5494
  const encodedLength = value.length;
5058
5495
  const rest = 3 & encodedLength;
5059
5496
  return new Uint8Array(3 * (encodedLength >>> 2) + (rest ? rest - 1 : 0));
5060
5497
 
5061
- case 34:
5498
+ case 32:
5062
5499
  return createPropsProxy(null, null);
5063
5500
 
5064
- case 10:
5501
+ case 9:
5065
5502
  return retrieveVNodeOrDocument(container, value);
5066
5503
 
5067
- case 11:
5504
+ case 10:
5068
5505
  const vNode = retrieveVNodeOrDocument(container, value);
5069
5506
  if (vnode_isVNode(vNode)) {
5070
- return vnode_getNode(vNode);
5507
+ return ensureMaterialized(vNode), vnode_getNode(vNode);
5071
5508
  }
5072
5509
  throw qError(17, [ typeof vNode ]);
5073
5510
 
5074
- case 35:
5511
+ case 33:
5075
5512
  return new SubscriptionData({});
5076
5513
 
5077
5514
  default:
@@ -5089,7 +5526,7 @@ function parseQRL(qrl) {
5089
5526
  const captureEnd = qrl.indexOf("]", captureStart);
5090
5527
  const chunk = qrl.slice(0, hashIdx > -1 ? hashIdx : captureStart);
5091
5528
  const symbol = captureStart > -1 ? qrl.slice(hashIdx + 1, captureStart) : qrl.slice(hashIdx + 1);
5092
- const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter((v => v.length)).map((s => parseInt(s, 10))) : null;
5529
+ const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter(v => v.length).map(s => parseInt(s, 10)) : null;
5093
5530
  let qrlRef = null;
5094
5531
  if (chunk === QRL_RUNTIME_CHUNK) {
5095
5532
  const backChannel = globalThis.__qrl_back_channel__;
@@ -5100,7 +5537,7 @@ function parseQRL(qrl) {
5100
5537
 
5101
5538
  function inflateQRL(container, qrl) {
5102
5539
  const captureIds = qrl.$capture$;
5103
- return qrl.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null,
5540
+ return qrl.$captureRef$ = captureIds ? captureIds.map(id => container.$getObjectById$(id)) : null,
5104
5541
  container.element && qrl.$setContainer$(container.element), qrl;
5105
5542
  }
5106
5543
 
@@ -5115,12 +5552,12 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5115
5552
  };
5116
5553
  }
5117
5554
  const seenObjsMap = new Map;
5118
- const rootsPathMap = new Map;
5555
+ const objectPathStringCache = new Map;
5119
5556
  const syncFnMap = new Map;
5120
5557
  const syncFns = [];
5121
5558
  const roots = [];
5122
5559
  const $addRootPath$ = obj => {
5123
- const rootPath = rootsPathMap.get(obj);
5560
+ const rootPath = objectPathStringCache.get(obj);
5124
5561
  if (rootPath) {
5125
5562
  return rootPath;
5126
5563
  }
@@ -5134,7 +5571,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5134
5571
  current = seenObjsMap.get(current.$parent$);
5135
5572
  }
5136
5573
  const pathStr = path.length > 1 ? path.join(" ") : path.length ? path[0] : seen.$index$;
5137
- return rootsPathMap.set(obj, pathStr), pathStr;
5574
+ return objectPathStringCache.set(obj, pathStr), pathStr;
5138
5575
  };
5139
5576
  const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
5140
5577
  return isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1,
@@ -5197,7 +5634,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5197
5634
  $storeProxyMap$: storeProxyMap,
5198
5635
  $getProp$: getProp,
5199
5636
  $setProp$: setProp,
5200
- $pathMap$: rootsPathMap
5637
+ $objectPathStringCache$: objectPathStringCache
5201
5638
  };
5202
5639
  };
5203
5640
 
@@ -5216,7 +5653,7 @@ const discoverValuesForVNodeData = (vnodeData, callback) => {
5216
5653
  if (isSsrAttrs(value)) {
5217
5654
  for (let i = 1; i < value.length; i += 2) {
5218
5655
  const attrValue = value[i];
5219
- "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
5656
+ null == attrValue || "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
5220
5657
  }
5221
5658
  }
5222
5659
  }
@@ -5234,13 +5671,24 @@ class PromiseResult {
5234
5671
  }
5235
5672
  }
5236
5673
 
5674
+ class SerializationWeakRef {
5675
+ $obj$;
5676
+ constructor($obj$) {
5677
+ this.$obj$ = $obj$;
5678
+ }
5679
+ }
5680
+
5681
+ const _serializationWeakRef = obj => new SerializationWeakRef(obj);
5682
+
5237
5683
  async function serialize(serializationContext) {
5238
- const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $pathMap$, $wasSeen$} = serializationContext;
5684
+ const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $objectPathStringCache$, $wasSeen$} = serializationContext;
5239
5685
  let depth = 0;
5686
+ let rootIdx = 0;
5240
5687
  const forwardRefs = [];
5241
5688
  let forwardRefsId = 0;
5242
5689
  const promises = new Set;
5243
5690
  const preloadQrls = new Set;
5691
+ const s11nWeakRefs = new Map;
5244
5692
  let parent = null;
5245
5693
  const outputArray = (value, writeFn) => {
5246
5694
  $writer$.write("[");
@@ -5262,37 +5710,49 @@ async function serialize(serializationContext) {
5262
5710
  }
5263
5711
  $writer$.write(0 === lastIdx ? s : s.slice(lastIdx));
5264
5712
  } else {
5265
- depth++, outputArray(value, ((valueItem, idx) => {
5713
+ depth++, outputArray(value, (valueItem, idx) => {
5266
5714
  $discoverRoots$(serializationContext, valueItem, parent, idx), writeValue(valueItem);
5267
- })), depth--;
5715
+ }), depth--;
5268
5716
  }
5269
5717
  };
5270
5718
  const addPreloadQrl = qrl => {
5271
- preloadQrls.add(qrl), serializationContext.$addRoot$(qrl, null);
5719
+ preloadQrls.add(qrl), serializationContext.$addRoot$(qrl);
5272
5720
  };
5273
- const outputRootRef = (value, rootDepth = 0) => {
5721
+ const outputAsRootRef = (value, rootDepth = 0) => {
5274
5722
  const seen = $wasSeen$(value);
5275
- const rootRefPath = $pathMap$.get(value);
5276
- return rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath ? (output(0, rootRefPath),
5277
- !0) : !!(depth > rootDepth && seen && -1 !== seen.$rootIndex$) && (output(0, seen.$rootIndex$),
5278
- !0);
5723
+ const rootRefPath = $objectPathStringCache$.get(value);
5724
+ if (rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath) {
5725
+ return output(1, rootRefPath), !0;
5726
+ }
5727
+ if (depth > rootDepth && seen && -1 !== seen.$rootIndex$) {
5728
+ return output(1, seen.$rootIndex$), !0;
5729
+ }
5730
+ if (s11nWeakRefs.has(value)) {
5731
+ const forwardRefId = s11nWeakRefs.get(value);
5732
+ if (rootDepth !== depth) {
5733
+ const rootRef = $addRoot$(value);
5734
+ return output(1, rootRef), forwardRefs[forwardRefId] = rootRef, !0;
5735
+ }
5736
+ forwardRefs[forwardRefId] = rootIdx;
5737
+ }
5738
+ return !1;
5279
5739
  };
5280
5740
  const writeValue = value => {
5281
5741
  if (fastSkipSerialize(value)) {
5282
5742
  output(3, 0);
5283
5743
  } else if ("bigint" == typeof value) {
5284
- output(12, value.toString());
5744
+ output(11, value.toString());
5285
5745
  } else if ("boolean" == typeof value) {
5286
5746
  output(3, value ? 2 : 3);
5287
5747
  } else if ("function" == typeof value) {
5288
5748
  if (value === Slot) {
5289
- output(3, 9);
5290
- } else if (value === Fragment) {
5291
5749
  output(3, 10);
5750
+ } else if (value === Fragment) {
5751
+ output(3, 11);
5292
5752
  } else if (isQrl(value)) {
5293
- if (!outputRootRef(value)) {
5753
+ if (!outputAsRootRef(value)) {
5294
5754
  const qrl = qrlToString(serializationContext, value);
5295
- const type = preloadQrls.has(value) ? 21 : 20;
5755
+ const type = preloadQrls.has(value) ? 20 : 19;
5296
5756
  if (0 === depth) {
5297
5757
  output(type, qrl);
5298
5758
  } else {
@@ -5306,11 +5766,11 @@ async function serialize(serializationContext) {
5306
5766
  }
5307
5767
  {
5308
5768
  const [qrl] = value[SERIALIZABLE_STATE];
5309
- serializationContext.$renderSymbols$.add(qrl.$symbol$), output(24, [ qrl ]);
5769
+ serializationContext.$renderSymbols$.add(qrl.$symbol$), output(23, [ qrl ]);
5310
5770
  }
5311
5771
  }
5312
5772
  } else if ("number" == typeof value) {
5313
- Number.isNaN(value) ? output(3, 11) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(3, 14) : value === Number.MAX_SAFE_INTEGER - 1 ? output(3, 15) : value === Number.MIN_SAFE_INTEGER ? output(3, 16) : output(4, value) : output(3, value < 0 ? 13 : 12);
5773
+ Number.isNaN(value) ? output(3, 12) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(3, 15) : value === Number.MAX_SAFE_INTEGER - 1 ? output(3, 16) : value === Number.MIN_SAFE_INTEGER ? output(3, 17) : output(0, value) : output(3, value < 0 ? 14 : 13);
5314
5774
  } else if ("object" == typeof value) {
5315
5775
  if (value === EMPTY_ARRAY) {
5316
5776
  output(3, 5);
@@ -5324,32 +5784,34 @@ async function serialize(serializationContext) {
5324
5784
  parent = value, writeObjectValue(value), parent = oldParent, depth--;
5325
5785
  }
5326
5786
  } else if ("string" == typeof value) {
5327
- 0 === value.length ? output(3, 4) : outputRootRef(value) || output(5, value);
5787
+ 0 === value.length ? output(3, 4) : outputAsRootRef(value) || output(0, value);
5328
5788
  } else if (void 0 === value) {
5329
5789
  output(3, 0);
5330
5790
  } else if (value === NEEDS_COMPUTATION) {
5331
5791
  output(3, 7);
5792
+ } else if (value === STORE_ALL_PROPS) {
5793
+ output(3, 8);
5332
5794
  } else {
5333
- if (value !== STORE_ALL_PROPS) {
5795
+ if (value !== _UNINITIALIZED) {
5334
5796
  throw qError(20, [ typeof value ]);
5335
5797
  }
5336
- output(3, 8);
5798
+ output(3, 9);
5337
5799
  }
5338
5800
  };
5339
5801
  const writeObjectValue = value => {
5340
- if (!outputRootRef(value, 1)) {
5802
+ if (!outputAsRootRef(value, 1)) {
5341
5803
  if (isPropsProxy(value)) {
5342
5804
  const varProps = value[_VAR_PROPS];
5343
5805
  const constProps = value[_CONST_PROPS];
5344
5806
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
5345
- output(34, out);
5807
+ output(32, out);
5346
5808
  } else if (value instanceof SubscriptionData) {
5347
- output(35, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
5809
+ output(33, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
5348
5810
  } else if (isStore(value)) {
5349
5811
  if (isResource(value)) {
5350
5812
  serializationContext.$resources$.add(value);
5351
- const forwardRefId = $resolvePromise$(value.value, $addRoot$, ((resolved, resolvedValue) => new PromiseResult(23, resolved, resolvedValue, getStoreHandler(value).$effects$)));
5352
- output(1, forwardRefId);
5813
+ const forwardRefId = $resolvePromise$(value.value, $addRoot$, (resolved, resolvedValue) => new PromiseResult(22, resolved, resolvedValue, getStoreHandler(value).$effects$));
5814
+ output(2, forwardRefId);
5353
5815
  } else {
5354
5816
  const storeHandler = getStoreHandler(value);
5355
5817
  const storeTarget = getStoreTarget(value);
@@ -5357,79 +5819,79 @@ async function serialize(serializationContext) {
5357
5819
  const effects = storeHandler.$effects$;
5358
5820
  const innerStores = [];
5359
5821
  for (const prop in storeTarget) {
5360
- const propValue = storeTarget[prop];
5361
- if ($storeProxyMap$.has(propValue)) {
5362
- const innerStore = $storeProxyMap$.get(propValue);
5363
- innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
5364
- }
5822
+ const innerStore = $storeProxyMap$.get(storeTarget[prop]);
5823
+ innerStore && innerStores.push(innerStore);
5365
5824
  }
5366
5825
  const out = [ storeTarget, flags, effects, ...innerStores ];
5367
5826
  for (;null == out[out.length - 1]; ) {
5368
5827
  out.pop();
5369
5828
  }
5370
- output(Array.isArray(storeTarget) ? 31 : 30, out);
5829
+ output(29, out);
5371
5830
  }
5372
5831
  } else if (isSerializerObj(value)) {
5373
5832
  const result = value[SerializerSymbol](value);
5374
5833
  if (isPromise(result)) {
5375
- const forwardRef = $resolvePromise$(result, $addRoot$, ((resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, null, null)));
5376
- output(1, forwardRef);
5834
+ const forwardRef = $resolvePromise$(result, $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, null, null));
5835
+ output(2, forwardRef);
5377
5836
  } else {
5378
5837
  depth--, writeValue(result), depth++;
5379
5838
  }
5380
5839
  } else if (isObjectLiteral(value)) {
5381
5840
  if (Array.isArray(value)) {
5382
- output(6, value);
5841
+ output(4, value);
5383
5842
  } else {
5384
5843
  const out = [];
5385
5844
  for (const key in value) {
5386
5845
  Object.prototype.hasOwnProperty.call(value, key) && !fastSkipSerialize(value[key]) && out.push(key, value[key]);
5387
5846
  }
5388
- output(15, out);
5847
+ output(5, out);
5389
5848
  }
5390
5849
  } else if ($isDomRef$(value)) {
5391
- value.$ssrNode$.vnodeData[0] |= 16, output(11, value.$ssrNode$.id);
5850
+ value.$ssrNode$.vnodeData[0] |= 16, output(10, value.$ssrNode$.id);
5392
5851
  } else if (value instanceof SignalImpl) {
5393
5852
  if (value instanceof SerializerSignalImpl) {
5394
5853
  addPreloadQrl(value.$computeQrl$);
5395
- const forwardRefId = $resolvePromise$($getCustomSerializerPromise$(value, value.$untrackedValue$), $addRoot$, ((resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, value.$effects$, value.$computeQrl$)));
5396
- return void output(1, forwardRefId);
5854
+ const forwardRefId = $resolvePromise$($getCustomSerializerPromise$(value, value.$untrackedValue$), $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, value.$effects$, value.$computeQrl$));
5855
+ return void output(2, forwardRefId);
5397
5856
  }
5398
- const v = value instanceof ComputedSignalImpl && (1 & value.$flags$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
5399
5857
  if (value instanceof WrappedSignalImpl) {
5400
- output(26, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
5401
- } else if (value instanceof AsyncComputedSignalImpl) {
5402
- addPreloadQrl(value.$computeQrl$);
5403
- const out = [ value.$computeQrl$, value.$effects$, value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$ ];
5404
- v !== NEEDS_COMPUTATION && out.push(v), output(28, out);
5858
+ output(25, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
5405
5859
  } else if (value instanceof ComputedSignalImpl) {
5860
+ let v = value.$untrackedValue$;
5861
+ const shouldAlwaysSerialize = 32 & value.$flags$;
5862
+ const shouldNeverSerialize = 16 & value.$flags$;
5863
+ const isInvalid = 1 & value.$flags$;
5864
+ const isSkippable = fastSkipSerialize(value.$untrackedValue$);
5865
+ shouldAlwaysSerialize ? v = value.$untrackedValue$ : (shouldNeverSerialize || isInvalid || isSkippable) && (v = NEEDS_COMPUTATION),
5406
5866
  addPreloadQrl(value.$computeQrl$);
5407
5867
  const out = [ value.$computeQrl$, value.$effects$ ];
5408
- v !== NEEDS_COMPUTATION && out.push(v), output(27, out);
5868
+ const isAsync = value instanceof AsyncComputedSignalImpl;
5869
+ isAsync && out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$),
5870
+ v !== NEEDS_COMPUTATION && out.push(v), output(isAsync ? 27 : 26, out);
5409
5871
  } else {
5410
- output(25, [ v, ...value.$effects$ || [] ]);
5872
+ output(24, [ value.$untrackedValue$, ...value.$effects$ || [] ]);
5411
5873
  }
5412
5874
  } else if (value instanceof URL) {
5413
- output(7, value.href);
5875
+ output(6, value.href);
5414
5876
  } else if (value instanceof Date) {
5415
- output(8, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
5877
+ output(7, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
5416
5878
  } else if (value instanceof RegExp) {
5417
- output(9, value.toString());
5879
+ output(8, value.toString());
5418
5880
  } else if (value instanceof Error) {
5419
5881
  const out = [ value.message ];
5420
5882
  out.push(...Object.entries(value).flat()), out.push("stack", value.stack), output(14, out);
5421
5883
  } else if ($isSsrNode$(value)) {
5422
5884
  const rootIndex = $addRoot$(value);
5423
- serializationContext.$setProp$(value, "q:id", String(rootIndex)), output(10, value.id);
5885
+ serializationContext.$setProp$(value, "q:id", String(rootIndex)), output(9, value.id);
5424
5886
  const vNodeData = value.vnodeData;
5425
- if (vNodeData && (discoverValuesForVNodeData(vNodeData, (vNodeDataValue => $addRoot$(vNodeDataValue))),
5887
+ if (vNodeData && (discoverValuesForVNodeData(vNodeData, vNodeDataValue => $addRoot$(vNodeDataValue)),
5426
5888
  vNodeData[0] |= 16), value.children) {
5427
5889
  for (const child of value.children) {
5428
5890
  const childVNodeData = child.vnodeData;
5429
5891
  if (childVNodeData) {
5430
5892
  for (const value of childVNodeData) {
5431
5893
  if (isSsrAttrs(value)) {
5432
- const backRefKeyIndex = value.findIndex((v => "q:brefs" === v));
5894
+ const backRefKeyIndex = value.findIndex(v => "q:brefs" === v);
5433
5895
  -1 !== backRefKeyIndex && $addRoot$(value[backRefKeyIndex + 1]);
5434
5896
  }
5435
5897
  }
@@ -5439,36 +5901,36 @@ async function serialize(serializationContext) {
5439
5901
  }
5440
5902
  } else if ("undefined" != typeof FormData && value instanceof FormData) {
5441
5903
  const array = [];
5442
- value.forEach(((value, key) => {
5904
+ value.forEach((value, key) => {
5443
5905
  array.push(key, "string" == typeof value ? value : value.name);
5444
- })), output(32, array);
5906
+ }), output(30, array);
5445
5907
  } else if (value instanceof URLSearchParams) {
5446
- output(13, value.toString());
5908
+ output(12, value.toString());
5447
5909
  } else if (value instanceof Set) {
5448
- output(17, [ ...value.values() ]);
5910
+ output(16, [ ...value.values() ]);
5449
5911
  } else if (value instanceof Map) {
5450
5912
  const combined = [];
5451
5913
  for (const [k, v] of value.entries()) {
5452
5914
  combined.push(k, v);
5453
5915
  }
5454
- output(18, combined);
5916
+ output(17, combined);
5455
5917
  } else if (isJSXNode(value)) {
5456
- output(33, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
5918
+ output(31, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
5457
5919
  } else if (value instanceof Task) {
5458
5920
  const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
5459
5921
  for (;null == out[out.length - 1]; ) {
5460
5922
  out.pop();
5461
5923
  }
5462
- output(22, out);
5924
+ output(21, out);
5463
5925
  } else if (isPromise(value)) {
5464
- const forwardRefId = $resolvePromise$(value, $addRoot$, ((resolved, resolvedValue) => new PromiseResult(16, resolved, resolvedValue)));
5465
- output(1, forwardRefId);
5926
+ const forwardRefId = $resolvePromise$(value, $addRoot$, (resolved, resolvedValue) => new PromiseResult(15, resolved, resolvedValue));
5927
+ output(2, forwardRefId);
5466
5928
  } else if (value instanceof PromiseResult) {
5467
- if (23 === value.$type$) {
5468
- output(23, [ value.$resolved$, value.$value$, value.$effects$ ]);
5469
- } else if (29 === value.$type$) {
5929
+ if (22 === value.$type$) {
5930
+ output(22, [ value.$resolved$, value.$value$, value.$effects$ ]);
5931
+ } else if (28 === value.$type$) {
5470
5932
  if (value.$qrl$) {
5471
- output(29, [ value.$qrl$, value.$effects$, value.$value$ ]);
5933
+ output(28, [ value.$qrl$, value.$effects$, value.$value$ ]);
5472
5934
  } else {
5473
5935
  if (!value.$resolved$) {
5474
5936
  throw console.error(value.$value$), qError(33);
@@ -5476,7 +5938,7 @@ async function serialize(serializationContext) {
5476
5938
  writeValue(value.$value$);
5477
5939
  }
5478
5940
  } else {
5479
- output(16, [ value.$resolved$, value.$value$ ]);
5941
+ output(15, [ value.$resolved$, value.$value$ ]);
5480
5942
  }
5481
5943
  } else if (value instanceof Uint8Array) {
5482
5944
  let buf = "";
@@ -5484,7 +5946,10 @@ async function serialize(serializationContext) {
5484
5946
  buf += String.fromCharCode(c);
5485
5947
  }
5486
5948
  const out = btoa(buf).replace(/=+$/, "");
5487
- output(19, out);
5949
+ output(18, out);
5950
+ } else if (value instanceof SerializationWeakRef) {
5951
+ const forwardRefId = forwardRefsId++;
5952
+ s11nWeakRefs.set(value.$obj$, forwardRefId), forwardRefs[forwardRefId] = -1, output(2, forwardRefId);
5488
5953
  } else {
5489
5954
  if (!vnode_isVNode(value)) {
5490
5955
  throw qError(20, [ typeof value ]);
@@ -5495,43 +5960,42 @@ async function serialize(serializationContext) {
5495
5960
  };
5496
5961
  function $resolvePromise$(promise, $addRoot$, classCreator) {
5497
5962
  const forwardRefId = forwardRefsId++;
5498
- return promise.then((resolvedValue => {
5963
+ return promise.then(resolvedValue => {
5499
5964
  promises.delete(promise), forwardRefs[forwardRefId] = $addRoot$(classCreator(!0, resolvedValue));
5500
- })).catch((err => {
5965
+ }).catch(err => {
5501
5966
  promises.delete(promise), forwardRefs[forwardRefId] = $addRoot$(classCreator(!1, err));
5502
- })), promises.add(promise), forwardRefId;
5967
+ }), promises.add(promise), forwardRefId;
5503
5968
  }
5504
5969
  await (async () => {
5505
5970
  $writer$.write("[");
5506
- let lastRootsLength = 0;
5507
5971
  let rootsLength = serializationContext.$roots$.length;
5508
- for (;lastRootsLength < rootsLength || promises.size; ) {
5509
- 0 !== lastRootsLength && $writer$.write(",");
5972
+ for (;rootIdx < rootsLength || promises.size; ) {
5973
+ 0 !== rootIdx && $writer$.write(",");
5510
5974
  let separator = !1;
5511
- for (let i = lastRootsLength; i < rootsLength; i++) {
5512
- separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[i]);
5975
+ for (;rootIdx < rootsLength; rootIdx++) {
5976
+ separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[rootIdx]);
5513
5977
  }
5514
5978
  if (promises.size) {
5515
5979
  try {
5516
5980
  await Promise.race(promises);
5517
5981
  } catch {}
5518
5982
  }
5519
- lastRootsLength = rootsLength, rootsLength = serializationContext.$roots$.length;
5983
+ rootsLength = serializationContext.$roots$.length;
5520
5984
  }
5521
- forwardRefs.length && ($writer$.write(","), $writer$.write("2,"), outputArray(forwardRefs, (value => {
5985
+ forwardRefs.length && ($writer$.write(","), $writer$.write("13,"), outputArray(forwardRefs, value => {
5522
5986
  $writer$.write(String(value));
5523
- }))), $writer$.write("]");
5987
+ })), $writer$.write("]");
5524
5988
  })();
5525
5989
  }
5526
5990
 
5527
5991
  function $getCustomSerializerPromise$(signal, value) {
5528
- return new Promise((resolve => {
5529
- signal.$computeQrl$.resolve().then((arg => {
5992
+ return new Promise(resolve => {
5993
+ signal.$computeQrl$.resolve().then(arg => {
5530
5994
  let data;
5531
5995
  arg.serialize ? data = arg.serialize(value) : SerializerSymbol in value && (data = value[SerializerSymbol](value)),
5532
5996
  void 0 === data && (data = NEEDS_COMPUTATION), resolve(data);
5533
- }));
5534
- }));
5997
+ });
5998
+ });
5535
5999
  }
5536
6000
 
5537
6001
  function filterEffectBackRefs(effectBackRef) {
@@ -5585,7 +6049,7 @@ function qrlToString(serializationContext, value) {
5585
6049
  }
5586
6050
 
5587
6051
  async function _serialize(data) {
5588
- const serializationContext = createSerializationContext(null, null, (() => ""), (() => ""), (() => {}), new WeakMap);
6052
+ const serializationContext = createSerializationContext(null, null, () => "", () => "", () => {}, new WeakMap);
5589
6053
  for (const root of data) {
5590
6054
  serializationContext.$addRoot$(root);
5591
6055
  }
@@ -5610,12 +6074,11 @@ function _deserialize(rawStateData, element) {
5610
6074
  }
5611
6075
 
5612
6076
  function deserializeData(container, typeId, value) {
5613
- if (void 0 === typeId) {
6077
+ if (0 === typeId) {
5614
6078
  return value;
5615
6079
  }
5616
- let propValue = allocate(container, typeId, value);
5617
- return typeId >= 14 && (propValue = inflate(container, propValue, typeId, value)),
5618
- propValue;
6080
+ const propValue = allocate(container, typeId, value);
6081
+ return needsInflation(typeId) && inflate(container, propValue, typeId, value), propValue;
5619
6082
  }
5620
6083
 
5621
6084
  function getObjectById(id, stateData) {
@@ -5631,7 +6094,7 @@ function _createDeserializeContainer(stateData, element) {
5631
6094
  $storeProxyMap$: new WeakMap,
5632
6095
  element: null,
5633
6096
  $forwardRefs$: null,
5634
- $initialQRLsIndexes$: null,
6097
+ $initialQRLs$: null,
5635
6098
  $scheduler$: null
5636
6099
  };
5637
6100
  return preprocessState(stateData, container), state = wrapDeserializerProxy(container, stateData),
@@ -5639,34 +6102,40 @@ function _createDeserializeContainer(stateData, element) {
5639
6102
  }
5640
6103
 
5641
6104
  function preprocessState(data, container) {
5642
- const isForwardRefsMap = type => 2 === type;
5643
- const isPreloadQrlType = type => 21 === type;
6105
+ const isRootDeepRef = (type, value) => 1 === type && "string" == typeof value;
6106
+ const isForwardRefsMap = type => 13 === type;
6107
+ const isPreloadQrlType = type => 20 === type;
5644
6108
  const processRootRef = index => {
5645
6109
  const rootRefPath = data[index + 1].split(" ");
5646
6110
  let object = data;
5647
- let objectType = 0;
6111
+ let objectType = 1;
5648
6112
  let typeIndex = 0;
5649
6113
  let valueIndex = 0;
5650
6114
  let parent = null;
5651
6115
  for (let i = 0; i < rootRefPath.length; i++) {
5652
6116
  if (parent = object, typeIndex = 2 * parseInt(rootRefPath[i], 10), valueIndex = typeIndex + 1,
5653
- objectType = object[typeIndex], object = object[valueIndex], 0 === objectType) {
6117
+ objectType = object[typeIndex], object = object[valueIndex], 1 === objectType) {
5654
6118
  const rootRefTypeIndex = 2 * object;
5655
6119
  objectType = data[rootRefTypeIndex], object = data[rootRefTypeIndex + 1];
5656
6120
  }
5657
6121
  }
5658
- parent && (parent[typeIndex] = 0, parent[valueIndex] = index / 2), data[index] = objectType,
6122
+ parent && (parent[typeIndex] = 1, parent[valueIndex] = index / 2), data[index] = objectType,
5659
6123
  data[index + 1] = object;
5660
6124
  };
5661
6125
  for (let i = 0; i < data.length; i += 2) {
5662
- value = data[i + 1], 0 === data[i] && "string" == typeof value ? processRootRef(i) : isForwardRefsMap(data[i]) ? container.$forwardRefs$ = data[i + 1] : isPreloadQrlType(data[i]) && (container.$initialQRLsIndexes$ ||= [],
5663
- container.$initialQRLsIndexes$.push(i / 2));
6126
+ if (isRootDeepRef(data[i], data[i + 1])) {
6127
+ processRootRef(i);
6128
+ } else if (isForwardRefsMap(data[i])) {
6129
+ container.$forwardRefs$ = data[i + 1];
6130
+ } else if (isPreloadQrlType(data[i])) {
6131
+ const qrl = data[i + 1];
6132
+ (container.$initialQRLs$ ||= []).push(qrl);
6133
+ }
5664
6134
  }
5665
- var value;
5666
6135
  }
5667
6136
 
5668
6137
  function shouldTrackObj(obj) {
5669
- return "object" == typeof obj && null !== obj || "string" == typeof obj && obj.length > 1;
6138
+ return isObject(obj) || "string" == typeof obj && obj.length > 1;
5670
6139
  }
5671
6140
 
5672
6141
  function isObjectLiteral(obj) {
@@ -5678,7 +6147,7 @@ function isResource(value) {
5678
6147
  return "__brand" in value && "resource" === value.__brand;
5679
6148
  }
5680
6149
 
5681
- const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
6150
+ const frameworkType = obj => isObject(obj) && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
5682
6151
 
5683
6152
  const canSerialize = (value, seen = new WeakSet) => {
5684
6153
  if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
@@ -5692,7 +6161,7 @@ const canSerialize = (value, seen = new WeakSet) => {
5692
6161
  const proto = Object.getPrototypeOf(value);
5693
6162
  if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
5694
6163
  for (const key in value) {
5695
- if (!canSerialize(untrack((() => value[key])), seen)) {
6164
+ if (!canSerialize(untrack(() => value[key]), seen)) {
5696
6165
  return !1;
5697
6166
  }
5698
6167
  }
@@ -5748,7 +6217,11 @@ const canSerialize = (value, seen = new WeakSet) => {
5748
6217
  if (isDomRef?.(value)) {
5749
6218
  return !0;
5750
6219
  }
5751
- } else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
6220
+ } else if ("function" == typeof value) {
6221
+ if (isQrl(value) || isQwikComponent(value)) {
6222
+ return !0;
6223
+ }
6224
+ } else if (value === _UNINITIALIZED) {
5752
6225
  return !0;
5753
6226
  }
5754
6227
  return !1;
@@ -5756,19 +6229,19 @@ const canSerialize = (value, seen = new WeakSet) => {
5756
6229
 
5757
6230
  const QRL_RUNTIME_CHUNK = "mock-chunk";
5758
6231
 
5759
- const _typeIdNames = [ "RootRef", "ForwardRef", "ForwardRefs", "Constant", "Number", "String", "Array", "URL", "Date", "Regex", "VNode", "RefVNode", "BigInt", "URLSearchParams", "Error", "Object", "Promise", "Set", "Map", "Uint8Array", "QRL", "PreloadQRL", "Task", "Resource", "Component", "Signal", "WrappedSignal", "ComputedSignal", "AsyncComputedSignal", "SerializerSignal", "Store", "StoreArray", "FormData", "JSXNode", "PropsProxy", "EffectData" ];
6232
+ const _typeIdNames = [ "Plain", "RootRef", "ForwardRef", "Constant", "Array", "Object", "URL", "Date", "Regex", "VNode", "RefVNode", "BigInt", "URLSearchParams", "ForwardRefs", "Error", "Promise", "Set", "Map", "Uint8Array", "QRL", "PreloadQRL", "Task", "Resource", "Component", "Signal", "WrappedSignal", "ComputedSignal", "AsyncComputedSignal", "SerializerSignal", "Store", "FormData", "JSXNode", "PropsProxy", "SubscriptionData" ];
5760
6233
 
5761
6234
  const circularProofJson = (obj, indent) => {
5762
6235
  const seen = new WeakSet;
5763
- return JSON.stringify(obj, ((key, value) => {
5764
- if ("object" == typeof value && null !== value) {
6236
+ return JSON.stringify(obj, (_, value) => {
6237
+ if (isObject(value)) {
5765
6238
  if (seen.has(value)) {
5766
6239
  return `[Circular ${value.constructor.name}]`;
5767
6240
  }
5768
6241
  seen.add(value);
5769
6242
  }
5770
6243
  return value;
5771
- }), indent);
6244
+ }, indent);
5772
6245
  };
5773
6246
 
5774
6247
  const printRaw = (value, prefix) => {
@@ -5791,11 +6264,18 @@ const dumpState = (state, color = !1, prefix = "", limit = 20) => {
5791
6264
  }
5792
6265
  const key = state[i];
5793
6266
  let value = state[++i];
5794
- void 0 === key ? (hasRaw = !0, out.push(`${RED}[raw${"object" == typeof value && value ? ` ${value.constructor.name}` : ""}]${RESET} ${printRaw(value, `${prefix} `)}`)) : (3 === key ? value = constantToName(value) : "string" == typeof value ? (value = JSON.stringify(value),
5795
- value.length > 120 && (value = value.slice(0, 120) + '"...')) : 2 === key ? value = `[\n${prefix} ${value.join(`\n${prefix} `)}\n${prefix}]` : Array.isArray(value) && (value = value.length ? `[\n${dumpState(value, color, `${prefix} `)}\n${prefix}]` : "[]"),
5796
- out.push(`${RED}${typeIdToName(key)}${RESET} ${value}`));
6267
+ if (0 === key) {
6268
+ const isRaw = "number" != typeof value && "string" != typeof value;
6269
+ isRaw && (hasRaw = !0);
6270
+ const type = isRaw ? `[raw${isObject(value) ? ` ${value.constructor.name}` : ""}]` : typeIdToName(key);
6271
+ out.push(`${RED}${type}${RESET} ${printRaw(value, `${prefix} `)}`);
6272
+ } else {
6273
+ 3 === key ? value = constantToName(value) : "string" == typeof value ? (value = JSON.stringify(value),
6274
+ value.length > 120 && (value = value.slice(0, 120) + '"...')) : 13 === key ? value = `[\n${prefix} ${value.join(`\n${prefix} `)}\n${prefix}]` : Array.isArray(value) && (value = value.length ? `[\n${dumpState(value, color, `${prefix} `)}\n${prefix}]` : "[]"),
6275
+ out.push(`${RED}${typeIdToName(key)}${RESET} ${value}`);
6276
+ }
5797
6277
  }
5798
- const result = out.map(((v, i) => `${prefix}${isRoot ? `${i} ` : ""}${v}`)).join("\n");
6278
+ const result = out.map((v, i) => `${prefix}${isRoot ? `${i} ` : ""}${v}`).join("\n");
5799
6279
  if (isRoot) {
5800
6280
  const count = hasRaw ? "" : `(${JSON.stringify(state).length} chars)`;
5801
6281
  return hasRaw = !1, `\n${result}\n${count}`;
@@ -5841,12 +6321,12 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
5841
6321
  }
5842
6322
  if (isArray(unwrapped)) {
5843
6323
  let expectIndex = 0;
5844
- return unwrapped.forEach(((v, i) => {
6324
+ return unwrapped.forEach((v, i) => {
5845
6325
  if (i !== expectIndex) {
5846
6326
  throw qError(3, [ unwrapped ]);
5847
6327
  }
5848
6328
  _verifySerializable(v, seen, ctx + "[" + i + "]"), expectIndex = i + 1;
5849
- })), value;
6329
+ }), value;
5850
6330
  }
5851
6331
  if (isSerializableObject(unwrapped)) {
5852
6332
  for (const [key, item] of Object.entries(unwrapped)) {
@@ -5876,21 +6356,19 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
5876
6356
 
5877
6357
  const noSerializeSet = /*#__PURE__*/ new WeakSet;
5878
6358
 
5879
- const weakSerializeSet = /*#__PURE__*/ new WeakSet;
5880
-
5881
6359
  const shouldSerialize = obj => !isObject(obj) && !isFunction(obj) || !noSerializeSet.has(obj);
5882
6360
 
5883
- const fastSkipSerialize = obj => obj && ("object" == typeof obj || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
6361
+ const fastSkipSerialize = obj => obj && (isObject(obj) || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
5884
6362
 
5885
- const noSerialize = input => (("object" == typeof input && null !== input || "function" == typeof input) && noSerializeSet.add(input),
6363
+ const noSerialize = input => ((isObject(input) && null !== input || "function" == typeof input) && noSerializeSet.add(input),
5886
6364
  input);
5887
6365
 
5888
- const _weakSerialize = input => (weakSerializeSet.add(input), input);
5889
-
5890
6366
  const NoSerializeSymbol = Symbol("noSerialize");
5891
6367
 
5892
6368
  const SerializerSymbol = Symbol("serialize");
5893
6369
 
6370
+ const resolvedSymbol = Symbol("resolved");
6371
+
5894
6372
  const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5895
6373
  let _containerEl;
5896
6374
  const qrl = async function(...args) {
@@ -5901,12 +6379,12 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5901
6379
  function bindFnToContext(currentCtx, beforeFn) {
5902
6380
  const bound = (...args) => {
5903
6381
  if (!qrl.resolved) {
5904
- return retryOnPromise((() => qrl.resolve())).then((fn => {
6382
+ return retryOnPromise(() => qrl.resolve()).then(fn => {
5905
6383
  if (!isFunction(fn)) {
5906
6384
  throw qError(5);
5907
6385
  }
5908
6386
  return bound(...args);
5909
- }));
6387
+ });
5910
6388
  }
5911
6389
  if (beforeFn && !1 === beforeFn()) {
5912
6390
  return;
@@ -5940,7 +6418,8 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5940
6418
  return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
5941
6419
  invoke.call(this, context, fn, ...args);
5942
6420
  };
5943
- const resolve = async containerEl => {
6421
+ symbolFn && resolvedSymbol in symbolFn && (symbolRef = symbolFn[resolvedSymbol]);
6422
+ const resolve = symbolRef ? async () => symbolRef : async containerEl => {
5944
6423
  if (null !== symbolRef) {
5945
6424
  return symbolRef;
5946
6425
  }
@@ -5954,14 +6433,17 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5954
6433
  const start = now();
5955
6434
  const ctx = tryGetInvokeContext();
5956
6435
  if (null !== symbolFn) {
5957
- symbolRef = symbolFn().then((module => qrl.resolved = wrapFn(symbolRef = module[symbol])));
6436
+ symbolRef = symbolFn().then(module => {
6437
+ const resolved = wrapFn(symbolRef = module[symbol]);
6438
+ return symbolFn[resolvedSymbol] = resolved, qrl.resolved = resolved, resolved;
6439
+ });
5958
6440
  } else {
5959
6441
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
5960
- symbolRef = maybeThen(imported, (ref => qrl.resolved = wrapFn(symbolRef = ref)));
6442
+ symbolRef = maybeThen(imported, ref => qrl.resolved = wrapFn(symbolRef = ref));
5961
6443
  }
5962
- return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
6444
+ return isPromise(symbolRef) && symbolRef.then(() => emitUsedSymbol(symbol, ctx?.$element$, start), err => {
5963
6445
  console.error(`qrl ${symbol} failed to load`, err), symbolRef = null;
5964
- })), symbolRef;
6446
+ }), symbolRef;
5965
6447
  };
5966
6448
  const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
5967
6449
  const hash = getSymbolHash(symbol);
@@ -5970,7 +6452,6 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5970
6452
  getHash: () => hash,
5971
6453
  getCaptured: () => captureRef,
5972
6454
  resolve,
5973
- $resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
5974
6455
  $setContainer$: setContainer,
5975
6456
  $chunk$: chunk,
5976
6457
  $symbol$: symbol,
@@ -5980,7 +6461,7 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5980
6461
  $captureRef$: captureRef,
5981
6462
  dev: null,
5982
6463
  resolved: void 0
5983
- }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = wrapFn(symbolRef = resolved)))),
6464
+ }), symbolRef && (symbolRef = maybeThen(symbolRef, resolved => qrl.resolved = wrapFn(symbolRef = resolved))),
5984
6465
  isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
5985
6466
  get: () => symbolRef
5986
6467
  }), isBrowser && symbol && p(symbol, .8), qrl;
@@ -6050,7 +6531,7 @@ const render = async (parent, jsxNode, opts = {}) => {
6050
6531
  const container = getDomContainer(parent);
6051
6532
  container.$serverData$ = opts.serverData || {};
6052
6533
  const host = container.rootVNode;
6053
- return container.$scheduler$(4, host, host, jsxNode), await container.$scheduler$(255),
6534
+ return container.$scheduler$(4, host, host, jsxNode), await container.$scheduler$(255).$returnValue$,
6054
6535
  {
6055
6536
  cleanup: () => {
6056
6537
  cleanup(container, container.rootVNode);
@@ -6295,7 +6776,7 @@ const STRINGS_COMMENTS = [ [ ANY, 39, 14 ], [ ANY, 34, 15 ], [ ANY, 47, 16, "*"
6295
6776
  const STATE_MACHINE = [ [ [ ANY, 42, starSelector ], [ ANY, OPEN_BRACKET, 7 ], [ ANY, COLON, pseudoElement, ":", "before", "after", "first-letter", "first-line" ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, COLON, 3, "has", "host-context", "not", "where", "is", "matches", "any" ], [ ANY, COLON, 4 ], [ ANY, IDENT, 1 ], [ ANY, DOT, 1 ], [ ANY, HASH, 1 ], [ ANY, 64, atRuleSelector, "keyframe" ], [ ANY, 64, atRuleBlock, "media", "supports", "container" ], [ ANY, 64, atRuleInert ], [ ANY, 123, 13 ], [ 47, 42, 16 ], [ ANY, 59, EXIT ], [ ANY, 125, EXIT ], [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, rule ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, 8 ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, rule ], [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, 93, EXIT_INSERT_SCOPE ], [ ANY, 39, 14 ], [ ANY, 34, 15 ] ], [ [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], [ WHITESPACE, IDENT, 1 ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, 123, 13 ], ...STRINGS_COMMENTS ], [ [ ANY, 123, rule ], [ ANY, 59, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 59, EXIT ], [ ANY, 123, 9 ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], [ ANY, 123, 13 ], [ ANY, 40, 8 ], ...STRINGS_COMMENTS ], [ [ ANY, 39, EXIT ] ], [ [ ANY, 34, EXIT ] ], [ [ 42, 47, EXIT ] ] ];
6296
6777
 
6297
6778
  const useStylesQrl = styles => ({
6298
- styleId: _useStyles(styles, (str => str), !1)
6779
+ styleId: _useStyles(styles, str => str, !1)
6299
6780
  });
6300
6781
 
6301
6782
  const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
@@ -6314,13 +6795,10 @@ const _useStyles = (styleQrl, transform, scoped) => {
6314
6795
  }
6315
6796
  const styleId = styleKey(styleQrl, i);
6316
6797
  const host = iCtx.$hostElement$;
6317
- set(styleId);
6318
- const value = styleQrl.$resolveLazy$(iCtx.$element$);
6319
- if (isPromise(value)) {
6320
- throw value.then((val => iCtx.$container$.$appendStyle$(transform(val, styleId), styleId, host, scoped))),
6321
- value;
6798
+ if (set(styleId), !styleQrl.resolved) {
6799
+ throw styleQrl.resolve().then(val => iCtx.$container$.$appendStyle$(transform(val, styleId), styleId, host, scoped));
6322
6800
  }
6323
- return iCtx.$container$.$appendStyle$(transform(value, styleId), styleId, host, scoped),
6801
+ return iCtx.$container$.$appendStyle$(transform(styleQrl.resolved, styleId), styleId, host, scoped),
6324
6802
  styleId;
6325
6803
  };
6326
6804
 
@@ -6346,7 +6824,7 @@ const createEventName = (event, eventScope) => {
6346
6824
 
6347
6825
  const _useOn = (eventName, eventQrl) => {
6348
6826
  const {isAdded, addEvent} = useOnEventsSequentialScope();
6349
- isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach((event => addEvent(event, eventQrl))) : addEvent(eventName, eventQrl));
6827
+ isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach(event => addEvent(event, eventQrl)) : addEvent(eventName, eventQrl));
6350
6828
  };
6351
6829
 
6352
6830
  const useOnEventsSequentialScope = () => {
@@ -6370,31 +6848,31 @@ const useOnEventsSequentialScope = () => {
6370
6848
  };
6371
6849
  };
6372
6850
 
6373
- const useSignal = initialState => useConstant((() => {
6851
+ const useSignal = initialState => useConstant(() => {
6374
6852
  const value = isFunction(initialState) && !isQwikComponent(initialState) ? invoke(void 0, initialState) : initialState;
6375
6853
  return createSignal(value);
6376
- }));
6854
+ });
6377
6855
 
6378
6856
  const useConstant = value => {
6379
6857
  const {val, set} = useSequentialScope();
6380
6858
  return null != val ? val : set(value = isFunction(value) && !isQwikComponent(value) ? value() : value);
6381
6859
  };
6382
6860
 
6383
- const useComputedCommon = (qrl, Class) => {
6861
+ const useComputedCommon = (qrl, createFn, options) => {
6384
6862
  const {val, set} = useSequentialScope();
6385
6863
  if (val) {
6386
6864
  return val;
6387
6865
  }
6388
6866
  assertQrl(qrl);
6389
- const signal = new Class(null, qrl);
6867
+ const signal = createFn(qrl, options);
6390
6868
  return set(signal), throwIfQRLNotResolved(qrl), signal;
6391
6869
  };
6392
6870
 
6393
- const useComputedQrl = qrl => useComputedCommon(qrl, ComputedSignalImpl);
6871
+ const useComputedQrl = (qrl, options) => useComputedCommon(qrl, createComputedSignal, options);
6394
6872
 
6395
6873
  const useComputed$ = implicit$FirstArg(useComputedQrl);
6396
6874
 
6397
- const useSerializerQrl = qrl => useComputedCommon(qrl, SerializerSignalImpl);
6875
+ const useSerializerQrl = qrl => useComputedCommon(qrl, createSerializerSignal);
6398
6876
 
6399
6877
  const useSerializer$ = implicit$FirstArg(useSerializerQrl);
6400
6878
 
@@ -6406,8 +6884,8 @@ const useVisibleTaskQrl = (qrl, opts) => {
6406
6884
  }
6407
6885
  assertQrl(qrl);
6408
6886
  const task = new Task(1, i, iCtx.$hostElement$, qrl, void 0, null);
6409
- set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.$resolveLazy$(iCtx.$element$),
6410
- iCtx.$container$.$scheduler$(32, task));
6887
+ set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.resolve(iCtx.$element$),
6888
+ iCtx.$container$.$scheduler$(16, task));
6411
6889
  };
6412
6890
 
6413
6891
  const useRunTask = (task, eagerness) => {
@@ -6422,7 +6900,7 @@ const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
6422
6900
 
6423
6901
  const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
6424
6902
 
6425
- const useAsyncComputedQrl = qrl => useComputedCommon(qrl, AsyncComputedSignalImpl);
6903
+ const useAsyncComputedQrl = (qrl, options) => useComputedCommon(qrl, createAsyncComputedSignal, options);
6426
6904
 
6427
6905
  const useAsyncComputed$ = implicit$FirstArg(useAsyncComputedQrl);
6428
6906
 
@@ -6445,7 +6923,7 @@ const PrefetchServiceWorker = opts => {
6445
6923
  ...opts
6446
6924
  };
6447
6925
  resolvedOpts.path = opts?.path?.startsWith?.("/") ? opts.path : baseUrl + resolvedOpts.path;
6448
- let code = PREFETCH_CODE.replace("'_URL_'", JSON.stringify(resolvedOpts.path));
6926
+ let code = PREFETCH_CODE.replace('"_URL_"', JSON.stringify(resolvedOpts.path.split("/").pop()));
6449
6927
  isDev || (code = code.replaceAll(/\s\s+/gm, ""));
6450
6928
  const props = {
6451
6929
  dangerouslySetInnerHTML: [ "(" + code + ")(", [ "navigator.serviceWorker" ].join(","), ");" ].join(""),
@@ -6455,13 +6933,19 @@ const PrefetchServiceWorker = opts => {
6455
6933
  };
6456
6934
 
6457
6935
  const PREFETCH_CODE = /*#__PURE__*/ (c => {
6458
- "getRegistrations" in c && c.getRegistrations().then((registrations => {
6459
- registrations.forEach((registration => {
6936
+ "getRegistrations" in c && c.getRegistrations().then(registrations => {
6937
+ registrations.forEach(registration => {
6460
6938
  registration.active && registration.active.scriptURL.endsWith("_URL_") && registration.unregister().catch(console.error);
6461
- }));
6462
- }));
6939
+ });
6940
+ }), "caches" in window && caches.keys().then(names => {
6941
+ const cacheName = names.find(name => name.startsWith("QwikBundles"));
6942
+ cacheName && caches.delete(cacheName).catch(console.error);
6943
+ }).catch(console.error);
6463
6944
  }).toString();
6464
6945
 
6465
6946
  const PrefetchGraph = () => null;
6466
6947
 
6467
- export { $, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _VAR_PROPS, _deserialize, dumpState as _dumpState, _fnSignal, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _weakSerialize, _wrapProp, _wrapSignal, _wrapStore, component$, componentQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsyncComputed$, useAsyncComputedQrl, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useSerializer$, useSerializerQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
6948
+ globalThis.__qwik && console.error(`==============================================\nQwik version ${globalThis.__qwik} already imported while importing ${version}. Verify external vs bundled imports etc. This can lead to issues due to duplicated shared structures.\n==============================================\n`),
6949
+ globalThis.__qwik = version;
6950
+
6951
+ export { $, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _UNINITIALIZED, _VAR_PROPS, _deserialize, dumpState as _dumpState, _fnSignal, _getConstProps, _getContextContainer, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, _getVarProps, _hasStoreEffects, isJSXNode as _isJSXNode, isStore as _isStore, isStringifiable as _isStringifiable, isTask as _isTask, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, mapApp_findIndx as _mapApp_findIndx, mapArray_get as _mapArray_get, mapArray_set as _mapArray_set, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, _regSymbol, _resolveContextWithoutSequentialScope, _restProps, _run, _serializationWeakRef, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, vnode_ensureElementInflated as _vnode_ensureElementInflated, vnode_getAttr as _vnode_getAttr, vnode_getAttrKeys as _vnode_getAttrKeys, vnode_getFirstChild as _vnode_getFirstChild, vnode_getNextSibling as _vnode_getNextSibling, vnode_getPropStartIndex as _vnode_getPropStartIndex, vnode_getProps as _vnode_getProps, vnode_isMaterialized as _vnode_isMaterialized, vnode_isTextVNode as _vnode_isTextVNode, vnode_isVirtualVNode as _vnode_isVirtualVNode, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsyncComputed$, createAsyncComputedSignal as createAsyncComputedQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, forceStoreEffects, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsyncComputed$, useAsyncComputedQrl, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useSerializer$, useSerializerQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };