@qwik.dev/core 2.0.0-beta.17 → 2.0.0-beta.19

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 (51) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.linux-x64-gnu.node +0 -0
  3. package/bindings/qwik.win32-x64-msvc.node +0 -0
  4. package/bindings/qwik_wasm_bg.wasm +0 -0
  5. package/dist/backpatch/package.json +1 -1
  6. package/dist/build/package.json +1 -1
  7. package/dist/cli.mjs +57 -57
  8. package/dist/core-internal.d.ts +32 -32
  9. package/dist/core.min.mjs +1 -1
  10. package/dist/core.mjs +1234 -788
  11. package/dist/core.mjs.map +1 -1
  12. package/dist/core.prod.mjs +815 -553
  13. package/dist/loader/index.mjs +2 -2
  14. package/dist/loader/package.json +1 -1
  15. package/dist/optimizer.mjs +1007 -1000
  16. package/dist/qwikloader.debug.js +1 -1
  17. package/dist/qwikloader.js +1 -1
  18. package/dist/server.mjs +65 -106
  19. package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
  20. package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
  21. package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
  22. package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
  23. package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
  24. package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
  25. package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
  26. package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
  27. package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
  28. package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
  29. package/dist/starters/adapters/express/package.json +1 -1
  30. package/dist/starters/features/compiled-i18n/package.json +37 -0
  31. package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
  32. package/dist/starters/features/{localize → compiled-i18n}/src/entry.ssr.tsx +7 -2
  33. package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
  34. package/dist/starters/features/csr/package.json +1 -1
  35. package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
  36. package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
  37. package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
  38. package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
  39. package/dist/starters/features/playwright/playwright-report/index.html +0 -19
  40. package/dist/testing/index.d.ts +11 -11
  41. package/dist/testing/index.mjs +2966 -2498
  42. package/dist/testing/package.json +1 -1
  43. package/package.json +14 -11
  44. package/bindings/qwik.darwin-x64.node +0 -0
  45. package/bindings/qwik.wasm.cjs +0 -471
  46. package/dist/starters/features/localize/package.json +0 -37
  47. package/dist/starters/features/localize/src/locales/message.en.json +0 -8
  48. package/dist/starters/features/localize/src/locales/message.it.json +0 -8
  49. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
  50. package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
  51. package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.17-dev+c34c237
3
+ * @qwik.dev/core 2.0.0-beta.19-dev+0d046fb
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,7 +11,7 @@ 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.17-dev+c34c237";
14
+ const version = "2.0.0-beta.19-dev+0d046fb";
15
15
 
16
16
  const qDev = !1;
17
17
 
@@ -70,7 +70,7 @@ const isString = v => "string" == typeof v;
70
70
 
71
71
  const isFunction = v => "function" == typeof v;
72
72
 
73
- const isPrimitive = v => "object" != typeof v && "function" != typeof v && null != v;
73
+ const isPrimitiveOrNullUndefined = v => "object" != typeof v && "function" != typeof v || null == v;
74
74
 
75
75
  const codeToText = code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
76
76
 
@@ -176,6 +176,10 @@ const ELEMENT_SEQ = "q:seq";
176
176
 
177
177
  const ELEMENT_SEQ_IDX = "q:seqIdx";
178
178
 
179
+ const ITERATION_ITEM_SINGLE = "q:p";
180
+
181
+ const ITERATION_ITEM_MULTI = "q:ps";
182
+
179
183
  const NON_SERIALIZABLE_MARKER_PREFIX = ":";
180
184
 
181
185
  const USE_ON_LOCAL = ":on";
@@ -196,6 +200,8 @@ const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
196
200
 
197
201
  const qwikInspectorAttr = "data-qwik-inspector";
198
202
 
203
+ const debugStyleScopeIdPrefixAttr = "__scopedStyleIdPrefix__";
204
+
199
205
  const createPlatform = () => ({
200
206
  isServer,
201
207
  importSymbol(containerEl, url, symbolName) {
@@ -258,14 +264,6 @@ const safeCall = (call, thenFn, rejectFn) => {
258
264
  }
259
265
  };
260
266
 
261
- const catchError = (valueOrPromise, rejectFn) => {
262
- try {
263
- return isPromise(valueOrPromise) ? valueOrPromise.catch(rejectFn) : valueOrPromise;
264
- } catch (e) {
265
- return rejectFn(e);
266
- }
267
- };
268
-
269
267
  const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
270
268
 
271
269
  const delay = timeout => new Promise(resolve => {
@@ -313,50 +311,6 @@ function assertNumber() {
313
311
  qDev;
314
312
  }
315
313
 
316
- let _locale;
317
-
318
- let localAsyncStore;
319
-
320
- function getLocale(defaultLocale) {
321
- if (localAsyncStore) {
322
- const locale = localAsyncStore.getStore();
323
- if (locale) {
324
- return locale;
325
- }
326
- }
327
- if (void 0 === _locale) {
328
- const ctx = tryGetInvokeContext();
329
- if (ctx && ctx.$locale$) {
330
- return ctx.$locale$;
331
- }
332
- if (void 0 !== defaultLocale) {
333
- return defaultLocale;
334
- }
335
- throw new Error("Reading `locale` outside of context.");
336
- }
337
- return _locale;
338
- }
339
-
340
- function withLocale(locale, fn) {
341
- if (localAsyncStore) {
342
- return localAsyncStore.run(locale, fn);
343
- }
344
- const previousLang = _locale;
345
- try {
346
- return _locale = locale, fn();
347
- } finally {
348
- _locale = previousLang;
349
- }
350
- }
351
-
352
- function setLocale(locale) {
353
- localAsyncStore ? localAsyncStore.enterWith(locale) : _locale = locale;
354
- }
355
-
356
- isServer && import("node:async_hooks").then(module => {
357
- localAsyncStore = new module.AsyncLocalStorage;
358
- }).catch(() => {});
359
-
360
314
  const DEBUG_TYPE = "q:type";
361
315
 
362
316
  const VirtualTypeName = {
@@ -513,13 +467,10 @@ function vnode_cloneElementWithNamespace(elementVNode, parentVNode, namespace, n
513
467
  return rootElement;
514
468
  }
515
469
 
516
- function isSvg(tagOrVNode) {
517
- return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!(128 & tagOrVNode.flags);
518
- }
519
-
520
- function isMath(tagOrVNode) {
521
- return "string" == typeof tagOrVNode ? isMathElement(tagOrVNode) : !!(256 & tagOrVNode.flags);
522
- }
470
+ const NEW_NAMESPACE_DATA = {
471
+ elementNamespace: HTML_NS,
472
+ elementNamespaceFlag: 0
473
+ };
523
474
 
524
475
  function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
525
476
  const parentIsDefaultNamespace = !domParentVNode || !!vnode_getElementName(domParentVNode) && vnode_isDefaultNamespace(domParentVNode);
@@ -535,10 +486,16 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
535
486
  elementNamespace = !!(128 & domParentVNode.flags) ? SVG_NS : !!(256 & domParentVNode.flags) ? MATH_NS : HTML_NS,
536
487
  elementNamespaceFlag = 384 & domParentVNode.flags;
537
488
  }
538
- return {
539
- elementNamespace,
540
- elementNamespaceFlag
541
- };
489
+ return NEW_NAMESPACE_DATA.elementNamespace = elementNamespace, NEW_NAMESPACE_DATA.elementNamespaceFlag = elementNamespaceFlag,
490
+ NEW_NAMESPACE_DATA;
491
+ }
492
+
493
+ function isSvg(tagOrVNode) {
494
+ return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!vnode_isElementVNode(tagOrVNode) && (isSvgElement(vnode_getElementName(tagOrVNode)) || !!(128 & tagOrVNode.flags));
495
+ }
496
+
497
+ function isMath(tagOrVNode) {
498
+ return "string" == typeof tagOrVNode ? isMathElement(tagOrVNode) : !!vnode_isElementVNode(tagOrVNode) && (isMathElement(vnode_getElementName(tagOrVNode)) || !!(256 & tagOrVNode.flags));
542
499
  }
543
500
 
544
501
  function getAttributeNamespace(attributeName) {
@@ -575,34 +532,42 @@ class BackRef {
575
532
  [_EFFECT_BACK_REF]=void 0;
576
533
  }
577
534
 
578
- class VNode extends BackRef {
535
+ class VNode {
579
536
  flags;
580
537
  parent;
581
538
  previousSibling;
582
539
  nextSibling;
583
540
  props;
541
+ [_EFFECT_BACK_REF]=void 0;
584
542
  slotParent=null;
585
543
  dirty=0;
586
544
  dirtyChildren=null;
587
545
  nextDirtyChildIndex=0;
588
546
  constructor(flags, parent, previousSibling, nextSibling, props) {
589
- super(), this.flags = flags, this.parent = parent, this.previousSibling = previousSibling,
547
+ this.flags = flags, this.parent = parent, this.previousSibling = previousSibling,
590
548
  this.nextSibling = nextSibling, this.props = props;
591
549
  }
592
550
  toString() {
593
- return isDev ? vnode_toString.call(this) : super.toString();
551
+ return isDev ? vnode_toString.call(this) : Object.prototype.toString.call(this);
594
552
  }
595
553
  }
596
554
 
597
- class ElementVNode extends VNode {
555
+ class VirtualVNode extends VNode {
598
556
  key;
599
557
  firstChild;
600
558
  lastChild;
559
+ constructor(key, flags, parent, previousSibling, nextSibling, props, firstChild, lastChild) {
560
+ super(flags, parent, previousSibling, nextSibling, props), this.key = key, this.firstChild = firstChild,
561
+ this.lastChild = lastChild;
562
+ }
563
+ }
564
+
565
+ class ElementVNode extends VirtualVNode {
601
566
  node;
602
567
  elementName;
603
568
  constructor(key, flags, parent, previousSibling, nextSibling, props, firstChild, lastChild, node, elementName) {
604
- super(flags, parent, previousSibling, nextSibling, props), this.key = key, this.firstChild = firstChild,
605
- this.lastChild = lastChild, this.node = node, this.elementName = elementName;
569
+ super(key, flags, parent, previousSibling, nextSibling, props, firstChild, lastChild),
570
+ this.node = node, this.elementName = elementName;
606
571
  }
607
572
  }
608
573
 
@@ -614,16 +579,6 @@ class TextVNode extends VNode {
614
579
  }
615
580
  }
616
581
 
617
- class VirtualVNode extends VNode {
618
- key;
619
- firstChild;
620
- lastChild;
621
- constructor(key, flags, parent, previousSibling, nextSibling, props, firstChild, lastChild) {
622
- super(flags, parent, previousSibling, nextSibling, props), this.key = key, this.firstChild = firstChild,
623
- this.lastChild = lastChild;
624
- }
625
- }
626
-
627
582
  const globalCursorQueue = [];
628
583
 
629
584
  const pausedCursorQueue = [];
@@ -658,7 +613,7 @@ function getHighestPriorityCursor() {
658
613
  }
659
614
 
660
615
  function pauseCursor(cursor, container) {
661
- pausedCursorQueue.push(cursor), removeCursorFromQueue(cursor, container, !0);
616
+ pausedCursorQueue.push(cursor), removeCursorFromQueue(cursor, container, !0), container.$pausedCursorCount$++;
662
617
  }
663
618
 
664
619
  function resumeCursor(cursor, container) {
@@ -666,15 +621,15 @@ function resumeCursor(cursor, container) {
666
621
  if (-1 !== index) {
667
622
  const lastIndex = pausedCursorQueue.length - 1;
668
623
  index !== lastIndex && (pausedCursorQueue[index] = pausedCursorQueue[lastIndex]),
669
- pausedCursorQueue.pop();
624
+ pausedCursorQueue.pop(), container.$pausedCursorCount$--;
670
625
  }
671
626
  addCursorToQueue(container, cursor);
672
627
  }
673
628
 
674
629
  function removeCursorFromQueue(cursor, container, keepCursorFlag) {
675
- container.$cursorCount$ > 0 && container.$cursorCount$--, keepCursorFlag || (cursor.flags &= -65);
630
+ keepCursorFlag || (cursor.flags &= -65);
676
631
  const index = globalCursorQueue.indexOf(cursor);
677
- -1 !== index && globalCursorQueue.splice(index, 1);
632
+ -1 !== index && (globalCursorQueue.splice(index, 1), container.$cursorCount$--);
678
633
  }
679
634
 
680
635
  const cursorDatas = new WeakMap;
@@ -738,7 +693,22 @@ class SignalImpl {
738
693
  this.$untrackedValue$ = value;
739
694
  }
740
695
  get value() {
741
- return setupSignalValueAccess(this, () => this.$effects$ ||= new Set, () => this.untrackedValue);
696
+ const ctx = tryGetInvokeContext();
697
+ if (!ctx) {
698
+ return this.untrackedValue;
699
+ }
700
+ if (null === this.$container$) {
701
+ if (!ctx.$container$) {
702
+ return this.untrackedValue;
703
+ }
704
+ this.$container$ = ctx.$container$;
705
+ } else {
706
+ isDev && assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
707
+ }
708
+ const effectSubscriber = ctx.$effectSubscriber$;
709
+ return effectSubscriber && (ensureContainsSubscription(this.$effects$ ||= new Set, effectSubscriber),
710
+ ensureContainsBackRef(effectSubscriber, this), (import.meta.env.TEST ? !isDomContainer(this.$container$) : isServer) && addQrlToSerializationCtx(effectSubscriber, this.$container$)),
711
+ this.untrackedValue;
742
712
  }
743
713
  set value(value) {
744
714
  value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, scheduleEffects(this.$container$, this, this.$effects$));
@@ -747,7 +717,7 @@ class SignalImpl {
747
717
  qDev;
748
718
  }
749
719
  toString() {
750
- 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;
720
+ return isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map(e => "\n -> " + pad(qwikDebugToString(e.consumer), " ")).join("\n") || "") : this.constructor.name;
751
721
  }
752
722
  toJSON() {
753
723
  return {
@@ -756,26 +726,23 @@ class SignalImpl {
756
726
  }
757
727
  }
758
728
 
759
- const addEffect = (signal, effectSubscriber, effects) => {
760
- ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, signal),
761
- addQrlToSerializationCtx(effectSubscriber, signal.$container$);
762
- };
763
-
764
729
  const setupSignalValueAccess = (target, effectsFn, returnValueFn) => {
765
730
  const ctx = tryGetInvokeContext();
766
- if (ctx) {
767
- if (null === target.$container$) {
768
- if (!ctx.$container$) {
769
- return returnValueFn();
770
- }
771
- target.$container$ = ctx.$container$;
772
- } else {
773
- assertTrue(!ctx.$container$ || ctx.$container$ === target.$container$, "Do not use signals across containers");
731
+ if (!ctx) {
732
+ return returnValueFn();
733
+ }
734
+ if (null === target.$container$) {
735
+ if (!ctx.$container$) {
736
+ return returnValueFn();
774
737
  }
775
- const effectSubscriber = ctx.$effectSubscriber$;
776
- effectSubscriber && addEffect(target, effectSubscriber, effectsFn());
738
+ target.$container$ = ctx.$container$;
739
+ } else {
740
+ isDev && assertTrue(!ctx.$container$ || ctx.$container$ === target.$container$, "Do not use signals across containers");
777
741
  }
778
- return returnValueFn();
742
+ const effectSubscriber = ctx.$effectSubscriber$;
743
+ return effectSubscriber && (ensureContainsSubscription(effectsFn(), effectSubscriber),
744
+ ensureContainsBackRef(effectSubscriber, target), addQrlToSerializationCtx(effectSubscriber, target.$container$)),
745
+ returnValueFn();
779
746
  };
780
747
 
781
748
  const _CONST_PROPS = Symbol("CONST");
@@ -792,7 +759,7 @@ const _UNINITIALIZED = Symbol("UNINITIALIZED");
792
759
 
793
760
  const EVENT_SUFFIX = "$";
794
761
 
795
- const isHtmlAttributeAnEventName = name => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
762
+ const isHtmlAttributeAnEventName = name => 111 === name.charCodeAt(0) && 110 === name.charCodeAt(1) && (58 === name.charCodeAt(2) || (name.startsWith("on-window:") || name.startsWith("on-document:")));
796
763
 
797
764
  function jsxEventToHtmlAttribute(jsxEvent) {
798
765
  if (jsxEvent.endsWith("$")) {
@@ -934,14 +901,15 @@ class PropsProxyHandler {
934
901
 
935
902
  const addPropsProxyEffect = (propsProxy, prop) => {
936
903
  const ctx = tryGetInvokeContext();
937
- ctx && (null === propsProxy.$container$ ? ctx.$container$ && (propsProxy.$container$ = ctx.$container$) : assertTrue(!ctx.$container$ || ctx.$container$ === propsProxy.$container$, "Do not use props across containers"));
904
+ ctx && (null === propsProxy.$container$ ? ctx.$container$ && (propsProxy.$container$ = ctx.$container$) : isDev && assertTrue(!ctx.$container$ || ctx.$container$ === propsProxy.$container$, "Do not use props across containers"));
938
905
  const effectSubscriber = ctx?.$effectSubscriber$;
939
906
  effectSubscriber && addStoreEffect(propsProxy.owner._proxy, prop, propsProxy, effectSubscriber);
940
907
  };
941
908
 
942
909
  const triggerPropsProxyEffect = (propsProxy, prop) => {
943
910
  const effects = getEffects$1(propsProxy.$effects$, prop);
944
- effects && scheduleEffects(propsProxy.$container$, propsProxy, effects);
911
+ return effects && scheduleEffects(propsProxy.$container$, propsProxy, effects),
912
+ !!effects;
945
913
  };
946
914
 
947
915
  function getEffects$1(effects, prop) {
@@ -971,26 +939,36 @@ const cleanupDestroyable = destroyable => {
971
939
  }
972
940
  };
973
941
 
942
+ const NEEDS_COMPUTATION = Symbol("invalid");
943
+
944
+ class EffectSubscription {
945
+ consumer;
946
+ property;
947
+ backRef;
948
+ data;
949
+ constructor(consumer, property, backRef = null, data = null) {
950
+ this.consumer = consumer, this.property = property, this.backRef = backRef, this.data = data;
951
+ }
952
+ }
953
+
954
+ const STORE_TARGET = Symbol("store.target");
955
+
956
+ const STORE_HANDLER = Symbol("store.handler");
957
+
958
+ const STORE_ALL_PROPS = Symbol("store.all");
959
+
974
960
  function getSubscriber(effect, prop, data) {
975
961
  effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
976
962
  const subMap = effect[_EFFECT_BACK_REF];
977
963
  let sub = subMap.get(prop);
978
- return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[3] = data),
979
- sub;
964
+ return sub || (sub = new EffectSubscription(effect, prop), subMap.set(prop, sub)),
965
+ data && (sub.data = data), sub;
980
966
  }
981
967
 
982
968
  function isSsrNode(value) {
983
969
  return "__brand__" in value && "SsrNode" === value.__brand__;
984
970
  }
985
971
 
986
- const NEEDS_COMPUTATION = Symbol("invalid");
987
-
988
- const STORE_TARGET = Symbol("store.target");
989
-
990
- const STORE_HANDLER = Symbol("store.handler");
991
-
992
- const STORE_ALL_PROPS = Symbol("store.all");
993
-
994
972
  const trackFn = (target, container) => (obj, prop) => {
995
973
  const ctx = newInvokeContext();
996
974
  return ctx.$effectSubscriber$ = getSubscriber(target, ":"), ctx.$container$ = container || void 0,
@@ -1050,7 +1028,7 @@ class ComputedSignalImpl extends SignalImpl {
1050
1028
  this.$flags$ |= 2, super.force();
1051
1029
  }
1052
1030
  get untrackedValue() {
1053
- return this.$computeIfNeeded$(), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1031
+ return this.$computeIfNeeded$(), isDev && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1054
1032
  this.$untrackedValue$;
1055
1033
  }
1056
1034
  $computeIfNeeded$() {
@@ -1061,7 +1039,10 @@ class ComputedSignalImpl extends SignalImpl {
1061
1039
  throwIfQRLNotResolved(computeQrl);
1062
1040
  const ctx = tryGetInvokeContext();
1063
1041
  const previousEffectSubscription = ctx?.$effectSubscriber$;
1064
- ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "."));
1042
+ if (ctx) {
1043
+ const effectSubscriber = getSubscriber(this, ".");
1044
+ clearEffectSubscription(this.$container$, effectSubscriber), ctx.$effectSubscriber$ = effectSubscriber;
1045
+ }
1065
1046
  try {
1066
1047
  const untrackedValue = computeQrl.getFn(ctx)();
1067
1048
  if (isPromise(untrackedValue)) {
@@ -1212,16 +1193,16 @@ const _wrapProp = (...args) => {
1212
1193
  return obj[prop];
1213
1194
  }
1214
1195
  if (isSignal(obj)) {
1215
- return obj instanceof AsyncComputedSignalImpl || assertEqual(prop, "value", "Left side is a signal, prop must be value"),
1196
+ return obj instanceof AsyncComputedSignalImpl || isDev && assertEqual(prop, "value", "Left side is a signal, prop must be value"),
1216
1197
  obj instanceof WrappedSignalImpl && 4 & obj.$flags$ ? obj : getWrapped(args);
1217
1198
  }
1218
1199
  if (isPropsProxy(obj)) {
1219
1200
  const constProps = obj[_CONST_PROPS];
1220
1201
  const varProps = obj[_VAR_PROPS];
1221
- if (constProps && prop in constProps) {
1202
+ if (constProps && Object.prototype.hasOwnProperty.call(constProps, prop)) {
1222
1203
  return constProps[prop];
1223
1204
  }
1224
- if (prop in varProps) {
1205
+ if (Object.prototype.hasOwnProperty.call(varProps, prop)) {
1225
1206
  return wrapIfNotSignal(varProps[prop], args);
1226
1207
  }
1227
1208
  } else {
@@ -1266,7 +1247,7 @@ class WrappedSignalImpl extends SignalImpl {
1266
1247
  markVNodeDirty(this.$container$, this.$hostElement$, 16));
1267
1248
  }
1268
1249
  get untrackedValue() {
1269
- return this.$computeIfNeeded$(), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1250
+ return this.$computeIfNeeded$(), isDev && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1270
1251
  this.$untrackedValue$;
1271
1252
  }
1272
1253
  $computeIfNeeded$() {
@@ -1300,13 +1281,13 @@ function clearAllEffects(container, consumer) {
1300
1281
  }
1301
1282
 
1302
1283
  function clearEffectSubscription(container, effect) {
1303
- const backRefs = effect[2];
1284
+ const backRefs = effect.backRef;
1304
1285
  if (backRefs) {
1305
1286
  for (const producer of backRefs) {
1306
- if (producer instanceof SignalImpl) {
1307
- clearSignal(container, producer, effect);
1308
- } else if (producer instanceof AsyncComputedSignalImpl) {
1287
+ if (producer instanceof AsyncComputedSignalImpl) {
1309
1288
  clearAsyncComputedSignal(producer, effect);
1289
+ } else if (producer instanceof SignalImpl) {
1290
+ clearSignal(container, producer, effect);
1310
1291
  } else if (isPropsProxy(producer)) {
1311
1292
  clearStoreOrProps(producer[_PROPS_HANDLER], effect);
1312
1293
  } else if (container.$storeProxyMap$.has(producer)) {
@@ -1320,7 +1301,7 @@ function clearEffectSubscription(container, effect) {
1320
1301
 
1321
1302
  function clearSignal(container, producer, effect) {
1322
1303
  const effects = producer.$effects$;
1323
- effects && effects.has(effect) && effects.delete(effect), producer instanceof WrappedSignalImpl && (producer.$hostElement$ = void 0,
1304
+ effects && effects.has(effect) && effects.delete(effect), producer instanceof WrappedSignalImpl && !effects?.size && (producer.$hostElement$ = void 0,
1324
1305
  clearAllEffects(container, producer));
1325
1306
  }
1326
1307
 
@@ -1351,13 +1332,14 @@ const useLexicalScope = () => {
1351
1332
  const context = getInvokeContext();
1352
1333
  let qrl = context.$qrl$;
1353
1334
  if (qrl) {
1354
- assertQrl(qrl), assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
1335
+ isDev && assertQrl(qrl), isDev && assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
1355
1336
  } else {
1356
1337
  const el = context.$hostElement$ instanceof ElementVNode ? context.$hostElement$.node : void 0;
1357
- assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
1338
+ isDev && assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
1358
1339
  const containerElement = _getQContainerElement(el);
1359
- assertDefined(containerElement, "invoke: cant find parent q:container of", el);
1360
- qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
1340
+ isDev && assertDefined(containerElement, "invoke: cant find parent q:container of", el);
1341
+ const container = getDomContainer(containerElement);
1342
+ context.$container$ ||= container, qrl = container.parseQRL(decodeURIComponent(String(context.$url$)));
1361
1343
  }
1362
1344
  return qrl.$captureRef$;
1363
1345
  };
@@ -1372,39 +1354,20 @@ const _chk = (_, element) => {
1372
1354
  signal.value = element.checked;
1373
1355
  };
1374
1356
 
1375
- const _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1376
-
1377
- const BIND_VALUE = "bind:value";
1378
-
1379
- const BIND_CHECKED = "bind:checked";
1357
+ const _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1380
1358
 
1381
1359
  class JSXNodeImpl {
1382
1360
  type;
1361
+ children;
1383
1362
  toSort;
1384
1363
  key;
1385
1364
  varProps;
1386
1365
  constProps;
1387
- children;
1388
1366
  dev;
1389
1367
  _proxy=null;
1390
1368
  constructor(type, varProps, constProps, children, key, toSort, dev) {
1391
- if (this.type = type, this.toSort = !!toSort, this.key = null == key ? null : String(key),
1369
+ this.type = type, this.children = children, this.toSort = !!toSort, this.key = null == key ? null : "string" == typeof key ? key : "" + key,
1392
1370
  this.varProps = !varProps || isEmpty(varProps) ? EMPTY_OBJ : varProps, this.constProps = !constProps || isEmpty(constProps) ? null : constProps,
1393
- this.children = children, "string" == typeof type) {
1394
- for (const k in this.constProps) {
1395
- const attr = jsxEventToHtmlAttribute(k);
1396
- attr && (mergeHandlers(this.constProps, attr, this.constProps[k]), delete this.constProps[k]);
1397
- }
1398
- for (const k in this.varProps) {
1399
- const attr = jsxEventToHtmlAttribute(k);
1400
- attr && (constProps && _hasOwnProperty$1.call(constProps, k) || (toSort = mergeHandlers(this.varProps, attr, this.varProps[k]) || toSort),
1401
- delete this.varProps[k]);
1402
- }
1403
- _hasOwnProperty$1.call(this.varProps, BIND_CHECKED) ? toSort = handleBindProp(this.varProps, BIND_CHECKED) || toSort : _hasOwnProperty$1.call(this.varProps, BIND_VALUE) ? toSort = handleBindProp(this.varProps, BIND_VALUE) || toSort : this.constProps && (_hasOwnProperty$1.call(this.constProps, BIND_CHECKED) ? handleBindProp(this.constProps, BIND_CHECKED) : _hasOwnProperty$1.call(this.constProps, BIND_VALUE) && handleBindProp(this.constProps, BIND_VALUE)),
1404
- _hasOwnProperty$1.call(this.varProps, "className") && (this.varProps.class = this.varProps.className,
1405
- this.varProps.className = void 0, toSort = !0), this.constProps && _hasOwnProperty$1.call(this.constProps, "className") && (this.constProps.class = this.constProps.className,
1406
- this.constProps.className = void 0);
1407
- }
1408
1371
  seal();
1409
1372
  }
1410
1373
  get props() {
@@ -1422,34 +1385,91 @@ const mergeHandlers = (obj, event, handler) => {
1422
1385
 
1423
1386
  const isJSXNode = n => n instanceof JSXNodeImpl;
1424
1387
 
1425
- const isEmpty = obj => {
1426
- for (const prop in obj) {
1427
- if (void 0 !== obj[prop]) {
1428
- return !1;
1429
- }
1430
- }
1431
- return !0;
1432
- };
1388
+ const isEmpty = obj => 0 === Object.keys(obj).length;
1433
1389
 
1434
- const handleBindProp = (props, prop) => {
1435
- const value = props[prop];
1436
- if (props[prop] = void 0, value) {
1437
- return prop === BIND_CHECKED ? (props.checked = value, props["on:input"] = createQRL(null, "_chk", _chk, null, null, [ value ])) : (props.value = value,
1438
- props["on:input"] = createQRL(null, "_val", _val, null, null, [ value ])), !0;
1439
- }
1440
- };
1390
+ const BIND_VALUE = "bind:value";
1441
1391
 
1442
- const _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => untrack(() => new JSXNodeImpl(type, varProps, constProps, children, key, !1, dev));
1392
+ const BIND_CHECKED = "bind:checked";
1393
+
1394
+ const _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1443
1395
 
1444
- const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => untrack(() => {
1396
+ const _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => new JSXNodeImpl(type, varProps, constProps, children, key, !1, dev);
1397
+
1398
+ const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
1399
+ let toSort = !1;
1400
+ let constPropsCopied = !1;
1401
+ let varPropsCopied = !1;
1402
+ let bindValueSignal = null;
1403
+ let bindCheckedSignal = null;
1404
+ if ("string" == typeof type) {
1405
+ if (constProps) {
1406
+ const processedKeys = new Set;
1407
+ for (const k in constProps) {
1408
+ const attr = jsxEventToHtmlAttribute(k);
1409
+ attr && (constPropsCopied || (constProps = {
1410
+ ...constProps
1411
+ }, constPropsCopied = !0), _hasOwnProperty$1.call(constProps, attr) && !processedKeys.has(attr) || (constProps[attr] = constProps[k]),
1412
+ delete constProps[k]), processedKeys.add(k);
1413
+ }
1414
+ }
1415
+ if (varProps) {
1416
+ const processedKeys = new Set;
1417
+ for (const k in varProps) {
1418
+ const attr = jsxEventToHtmlAttribute(k);
1419
+ attr ? (varPropsCopied || (varProps = {
1420
+ ...varProps
1421
+ }, varPropsCopied = !0), _hasOwnProperty$1.call(varProps, attr) && !processedKeys.has(attr) || (varProps[attr] = varProps[k]),
1422
+ delete varProps[k], toSort = !0) : k === BIND_CHECKED ? bindCheckedSignal = varProps[k] : k === BIND_VALUE && (bindValueSignal = varProps[k]),
1423
+ processedKeys.add(k);
1424
+ }
1425
+ if (bindCheckedSignal || bindValueSignal) {
1426
+ if (varPropsCopied || (varProps = {
1427
+ ...varProps
1428
+ }, varPropsCopied = !0), bindCheckedSignal) {
1429
+ delete varProps[BIND_CHECKED], varProps.checked = bindCheckedSignal;
1430
+ const handler = createQRL(null, "_chk", _chk, null, null, [ bindCheckedSignal ]);
1431
+ if (constProps && _hasOwnProperty$1.call(constProps, "on:input")) {
1432
+ constPropsCopied || (constProps = {
1433
+ ...constProps
1434
+ }, constPropsCopied = !0);
1435
+ const existingHandler = constProps["on:input"];
1436
+ delete constProps["on:input"], toSort = mergeHandlers(varProps, "on:input", existingHandler) || toSort;
1437
+ }
1438
+ toSort = mergeHandlers(varProps, "on:input", handler) || toSort;
1439
+ } else if (bindValueSignal) {
1440
+ delete varProps[BIND_VALUE], varProps.value = bindValueSignal;
1441
+ const handler = createQRL(null, "_val", _val, null, null, [ bindValueSignal ]);
1442
+ if (constProps && _hasOwnProperty$1.call(constProps, "on:input")) {
1443
+ constPropsCopied || (constProps = {
1444
+ ...constProps
1445
+ }, constPropsCopied = !0);
1446
+ const existingHandler = constProps["on:input"];
1447
+ delete constProps["on:input"], toSort = mergeHandlers(varProps, "on:input", existingHandler) || toSort;
1448
+ }
1449
+ toSort = mergeHandlers(varProps, "on:input", handler) || toSort;
1450
+ }
1451
+ }
1452
+ }
1453
+ varProps && _hasOwnProperty$1.call(varProps, "className") && (varPropsCopied || (varProps = {
1454
+ ...varProps
1455
+ }, varPropsCopied = !0), varProps.class = varProps.className, varProps.className = void 0,
1456
+ toSort = !0), constProps && _hasOwnProperty$1.call(constProps, "className") && (constPropsCopied || (constProps = {
1457
+ ...constProps
1458
+ }, constPropsCopied = !0), constProps.class = constProps.className, constProps.className = void 0);
1459
+ }
1445
1460
  if (varProps) {
1446
1461
  for (const k in varProps) {
1447
- "children" === k ? (children ||= varProps.children, delete varProps.children) : "key" === k ? (key ||= varProps.key,
1448
- delete varProps.key) : constProps && k in constProps && delete varProps[k];
1462
+ "children" === k ? (varPropsCopied || (varProps = {
1463
+ ...varProps
1464
+ }, varPropsCopied = !0), children ||= varProps.children, delete varProps.children) : "key" === k ? (varPropsCopied || (varProps = {
1465
+ ...varProps
1466
+ }, varPropsCopied = !0), key ||= varProps.key, delete varProps.key) : (constProps && k in constProps || null === varProps[k]) && (varPropsCopied || (varProps = {
1467
+ ...varProps
1468
+ }, varPropsCopied = !0), delete varProps[k]);
1449
1469
  }
1450
1470
  }
1451
- return new JSXNodeImpl(type, varProps, constProps, children, key, !0, dev);
1452
- });
1471
+ return new JSXNodeImpl(type, varProps, constProps, children, key, toSort || !0, dev);
1472
+ };
1453
1473
 
1454
1474
  const _jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key);
1455
1475
 
@@ -1493,8 +1513,8 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1493
1513
  subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, ":"),
1494
1514
  iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
1495
1515
  let isInlineComponent = !1;
1496
- if (null === componentQRL && assertDefined(componentQRL = container.getHostProp(renderHost, "q:renderFn"), "No Component found at this location"),
1497
- isQrl(componentQRL)) {
1516
+ if (null === componentQRL && (componentQRL = container.getHostProp(renderHost, "q:renderFn"),
1517
+ isDev && assertDefined(componentQRL, "No Component found at this location")), isQrl(componentQRL)) {
1498
1518
  "children" in (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ) && delete props.children,
1499
1519
  componentFn = componentQRL.getFn(iCtx);
1500
1520
  } else if (isQwikComponent(componentQRL)) {
@@ -1505,9 +1525,15 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1505
1525
  const inlineComponent = componentQRL;
1506
1526
  componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
1507
1527
  }
1528
+ const isSsr = import.meta.env.TEST ? isServerPlatform() : isServer;
1508
1529
  const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1509
1530
  container.setHostProp(renderHost, ":onIdx", null)), retryCount > 0 && vnode_isVNode(renderHost) && clearAllEffects(container, renderHost),
1510
1531
  maybeThen(componentFn(props), jsx => maybeThen(iCtx.$waitOn$, () => jsx))), jsx => {
1532
+ if (isSsr && !isInlineComponent) {
1533
+ if (4 & renderHost.dirty && (renderHost.dirty &= -5, retryCount < 100)) {
1534
+ return executeComponentWithPromiseExceptionRetry(retryCount + 1);
1535
+ }
1536
+ }
1511
1537
  const useOnEvents = container.getHostProp(renderHost, ":on");
1512
1538
  return useOnEvents ? addUseOnEvents(jsx, useOnEvents) : jsx;
1513
1539
  }, err => {
@@ -1589,7 +1615,7 @@ function injectPlaceholderElement(jsx) {
1589
1615
  return jsx.type === Fragment || isQwikComponent(jsx.type) ? (null == jsx.children ? jsx.children = placeholder : isArray(jsx.children) ? jsx.children.push(placeholder) : jsx.children = [ jsx.children, placeholder ],
1590
1616
  [ placeholder, jsx ]) : [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
1591
1617
  }
1592
- if (isPrimitive(jsx)) {
1618
+ if (isPrimitiveOrNullUndefined(jsx)) {
1593
1619
  const placeholder = createPlaceholderScriptNode();
1594
1620
  return [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
1595
1621
  }
@@ -1603,7 +1629,7 @@ function injectPlaceholderElement(jsx) {
1603
1629
  function createPlaceholderScriptNode() {
1604
1630
  return new JSXNodeImpl("script", null, {
1605
1631
  hidden: ""
1606
- });
1632
+ }, null, null);
1607
1633
  }
1608
1634
 
1609
1635
  const Slot = props => _jsxSorted(Virtual, null, {
@@ -1687,15 +1713,11 @@ const _restProps = (props, omit = [], target = {}) => {
1687
1713
  for (const key in varProps) {
1688
1714
  omit.includes(key) || (varPropsTarget[key] = varProps[key]);
1689
1715
  }
1690
- return createPropsProxy(new JSXNodeImpl(null, varPropsTarget, constPropsTarget));
1716
+ return createPropsProxy(new JSXNodeImpl(null, varPropsTarget, constPropsTarget, null, null));
1691
1717
  };
1692
1718
 
1693
1719
  const styleContent = styleId => "⚡️" + styleId;
1694
1720
 
1695
- function hasClassAttr(props) {
1696
- return "class" in props;
1697
- }
1698
-
1699
1721
  function isClassAttr(key) {
1700
1722
  return "class" === key;
1701
1723
  }
@@ -1798,79 +1820,8 @@ function isAriaAttribute(prop) {
1798
1820
 
1799
1821
  const styleKey = (qStyles, index) => (assertQrl(qStyles), `${hashCode(qStyles.$hash$)}-${index}`);
1800
1822
 
1801
- const useSequentialScope = () => {
1802
- const iCtx = useInvokeContext();
1803
- const host = iCtx.$hostElement$;
1804
- let seq = iCtx.$container$.getHostProp(host, "q:seq");
1805
- null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
1806
- let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
1807
- for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
1808
- seq.push(void 0);
1809
- }
1810
- return {
1811
- val: seq[seqIdx],
1812
- set: value => seq[seqIdx] = value,
1813
- i: seqIdx,
1814
- iCtx
1815
- };
1816
- };
1817
-
1818
- const useTaskQrl = (qrl, opts) => {
1819
- const {val, set, iCtx, i} = useSequentialScope();
1820
- if (val) {
1821
- return;
1822
- }
1823
- assertQrl(qrl), set(1);
1824
- const task = new Task(10 | (!1 === opts?.deferUpdates ? 0 : 16), i, iCtx.$hostElement$, qrl, void 0, null);
1825
- set(task);
1826
- const container = iCtx.$container$;
1827
- const {$waitOn$: waitOn} = iCtx;
1828
- const result = maybeThen(waitOn, () => runTask(task, container, iCtx.$hostElement$));
1829
- isPromise(result) && (iCtx.$waitOn$ = result);
1830
- };
1831
-
1832
- const runTask = (task, container, host) => {
1833
- task.$flags$ &= -9, cleanupDestroyable(task);
1834
- const iCtx = newInvokeContext(container.$locale$, host, "qTask");
1835
- iCtx.$container$ = container;
1836
- const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
1837
- const track = trackFn(task, container);
1838
- const [cleanup] = cleanupFn(task, reason => container.handleError(reason, host));
1839
- const taskApi = {
1840
- track,
1841
- cleanup
1842
- };
1843
- return safeCall(() => taskFn(taskApi), cleanup, err => {
1844
- if (isPromise(err)) {
1845
- return err.then(() => runTask(task, container, host));
1846
- }
1847
- container.handleError(err, host);
1848
- });
1849
- };
1850
-
1851
- class Task extends BackRef {
1852
- $flags$;
1853
- $index$;
1854
- $el$;
1855
- $qrl$;
1856
- $state$;
1857
- $destroy$;
1858
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
1859
- super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
1860
- this.$state$ = $state$, this.$destroy$ = $destroy$;
1861
- }
1862
- }
1863
-
1864
- const isTask = value => value instanceof Task;
1865
-
1866
- const scheduleTask = (_event, element) => {
1867
- const [task] = useLexicalScope();
1868
- const container = getDomContainer(element);
1869
- task.$flags$ |= 8, markVNodeDirty(container, task.$el$, 1);
1870
- };
1871
-
1872
1823
  const mapApp_findIndx = (array, key, start) => {
1873
- assertTrue(start % 2 == 0, "Expecting even number.");
1824
+ isDev && assertTrue(start % 2 == 0, "Expecting even number.");
1874
1825
  let bottom = start >> 1;
1875
1826
  let top = array.length - 2 >> 1;
1876
1827
  for (;bottom <= top; ) {
@@ -1896,15 +1847,123 @@ const mapArray_get = (array, key, start) => {
1896
1847
 
1897
1848
  const mapArray_has = (array, key, start) => mapApp_findIndx(array, key, start) >= 0;
1898
1849
 
1850
+ class DeleteOperation {
1851
+ target;
1852
+ constructor(target) {
1853
+ this.target = target;
1854
+ }
1855
+ }
1856
+
1857
+ class RemoveAllChildrenOperation {
1858
+ target;
1859
+ constructor(target) {
1860
+ this.target = target;
1861
+ }
1862
+ }
1863
+
1864
+ class SetTextOperation {
1865
+ target;
1866
+ text;
1867
+ operationType=16;
1868
+ constructor(target, text) {
1869
+ this.target = target, this.text = text;
1870
+ }
1871
+ }
1872
+
1873
+ class InsertOrMoveOperation {
1874
+ target;
1875
+ parent;
1876
+ beforeTarget;
1877
+ constructor(target, parent, beforeTarget) {
1878
+ this.target = target, this.parent = parent, this.beforeTarget = beforeTarget;
1879
+ }
1880
+ }
1881
+
1882
+ class SetAttributeOperation {
1883
+ target;
1884
+ attrName;
1885
+ attrValue;
1886
+ scopedStyleIdPrefix;
1887
+ isSvg;
1888
+ constructor(target, attrName, attrValue, scopedStyleIdPrefix, isSvg) {
1889
+ this.target = target, this.attrName = attrName, this.attrValue = attrValue, this.scopedStyleIdPrefix = scopedStyleIdPrefix,
1890
+ this.isSvg = isSvg;
1891
+ }
1892
+ }
1893
+
1894
+ const createDeleteOperation = target => new DeleteOperation(target);
1895
+
1896
+ const createRemoveAllChildrenOperation = target => new RemoveAllChildrenOperation(target);
1897
+
1898
+ const createSetTextOperation = (target, text) => new SetTextOperation(target, text);
1899
+
1900
+ const createInsertOrMoveOperation = (target, parent, beforeTarget) => new InsertOrMoveOperation(target, parent, beforeTarget);
1901
+
1902
+ const createSetAttributeOperation = (target, attrName, attrValue, scopedStyleIdPrefix = null, isSvg = !1) => new SetAttributeOperation(target, attrName, attrValue, scopedStyleIdPrefix, isSvg);
1903
+
1904
+ function callQrl(container, host, qrl, event, element, useGetObjectById) {
1905
+ const getObjectById = useGetObjectById && container?.$getObjectById$ || null;
1906
+ const singleItem = vnode_getProp(host, "q:p", getObjectById);
1907
+ if (null !== singleItem) {
1908
+ return qrl(event, element, singleItem);
1909
+ }
1910
+ const multiItems = vnode_getProp(host, "q:ps", getObjectById);
1911
+ return null !== multiItems ? qrl(event, element, ...multiItems) : qrl(event, element);
1912
+ }
1913
+
1914
+ const _run = (...args) => {
1915
+ const [qrl] = useLexicalScope();
1916
+ const context = getInvokeContext();
1917
+ const hostElement = context.$hostElement$;
1918
+ if (hostElement) {
1919
+ return context.$container$ ||= getDomContainer(hostElement.node), vnode_ensureElementInflated(hostElement),
1920
+ retryOnPromise(() => {
1921
+ if (!(32 & hostElement.flags)) {
1922
+ return callQrl(context.$container$, hostElement, qrl, args[0], args[1], !0).catch(err => {
1923
+ const container = context.$container$;
1924
+ if (!container) {
1925
+ throw err;
1926
+ }
1927
+ container.handleError(err, hostElement);
1928
+ });
1929
+ }
1930
+ });
1931
+ }
1932
+ };
1933
+
1934
+ let _setAttribute = null;
1935
+
1936
+ const fastSetAttribute = (target, name, value) => {
1937
+ _setAttribute || (_setAttribute = target.setAttribute), _setAttribute.call(target, name, value);
1938
+ };
1939
+
1940
+ let _setAttributeNS = null;
1941
+
1942
+ const fastSetAttributeNS = (target, namespace, name, value) => {
1943
+ _setAttributeNS || (_setAttributeNS = target.setAttributeNS), _setAttributeNS.call(target, namespace, name, value);
1944
+ };
1945
+
1946
+ function directSetAttribute(element, attrName, attrValue, isSvg) {
1947
+ if (null != attrValue) {
1948
+ if (isSvg) {
1949
+ const namespace = getAttributeNamespace(attrName);
1950
+ if (namespace) {
1951
+ return void fastSetAttributeNS(element, namespace, attrName, attrValue);
1952
+ }
1953
+ }
1954
+ fastSetAttribute(element, attrName, attrValue);
1955
+ }
1956
+ }
1957
+
1899
1958
  function peekNextSibling(vCurrent) {
1900
1959
  return vCurrent ? vCurrent.nextSibling : null;
1901
1960
  }
1902
1961
 
1903
1962
  const _hasOwnProperty = Object.prototype.hasOwnProperty;
1904
1963
 
1905
- function setAttribute(journal, vnode, key, value, scopedStyleIdPrefix) {
1906
- const serializedValue = null != value ? serializeAttribute(key, value, scopedStyleIdPrefix) : null;
1907
- vnode_setAttr(journal, vnode, key, serializedValue);
1964
+ function setAttribute(journal, vnode, key, value, scopedStyleIdPrefix, originalValue) {
1965
+ import.meta.env.TEST && scopedStyleIdPrefix && vnode_setProp(vnode, "__scopedStyleIdPrefix__", scopedStyleIdPrefix),
1966
+ vnode_setProp(vnode, key, originalValue), addVNodeOperation(journal, createSetAttributeOperation(vnode.node, key, value, scopedStyleIdPrefix, !!(128 & vnode.flags)));
1908
1967
  }
1909
1968
 
1910
1969
  const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyleIdPrefix) => {
@@ -1927,6 +1986,7 @@ const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyle
1927
1986
  jsxIdx: 0,
1928
1987
  jsxCount: 0,
1929
1988
  shouldAdvance: !0,
1989
+ isCreationMode: !1,
1930
1990
  subscriptionData: {
1931
1991
  const: new SubscriptionData({
1932
1992
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
@@ -1949,30 +2009,19 @@ const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyle
1949
2009
  };
1950
2010
 
1951
2011
  function diff(diffContext, jsxNode, vStartNode) {
1952
- if (assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"), assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
2012
+ if (isDev && assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"),
2013
+ isDev && assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
1953
2014
  diffContext.vParent = vStartNode, diffContext.vNewNode = null, diffContext.vCurrent = vnode_getFirstChild(vStartNode),
1954
2015
  stackPush(diffContext, jsxNode, !0), !(32 & diffContext.vParent.flags)) {
1955
2016
  for (;diffContext.stack.length; ) {
1956
2017
  for (;diffContext.jsxIdx < diffContext.jsxCount; ) {
1957
- if (assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
2018
+ if (isDev && assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
1958
2019
  "string" == typeof diffContext.jsxValue) {
1959
2020
  expectText(diffContext, diffContext.jsxValue);
1960
2021
  } else if ("number" == typeof diffContext.jsxValue) {
1961
2022
  expectText(diffContext, String(diffContext.jsxValue));
1962
2023
  } else if (diffContext.jsxValue && "object" == typeof diffContext.jsxValue) {
1963
- if (Array.isArray(diffContext.jsxValue)) {
1964
- descend(diffContext, diffContext.jsxValue, !1);
1965
- } else if (isSignal(diffContext.jsxValue)) {
1966
- expectVirtual(diffContext, "S", null);
1967
- const unwrappedSignal = diffContext.jsxValue instanceof WrappedSignalImpl ? diffContext.jsxValue.$unwrapIfSignal$() : diffContext.jsxValue;
1968
- const hasUnwrappedSignal = diffContext.vCurrent?.[_EFFECT_BACK_REF]?.get(".")?.[2]?.has(unwrappedSignal);
1969
- if (!hasUnwrappedSignal) {
1970
- const vHost = diffContext.vNewNode || diffContext.vCurrent;
1971
- descend(diffContext, resolveSignalAndDescend(diffContext, () => trackSignalAndAssignHost(unwrappedSignal, vHost, ".", diffContext.container)), !0);
1972
- }
1973
- } else if (isPromise(diffContext.jsxValue)) {
1974
- expectVirtual(diffContext, "A", null), diffContext.asyncQueue.push(diffContext.jsxValue, diffContext.vNewNode || diffContext.vCurrent);
1975
- } else if (isJSXNode(diffContext.jsxValue)) {
2024
+ if (isJSXNode(diffContext.jsxValue)) {
1976
2025
  const type = diffContext.jsxValue.type;
1977
2026
  if ("string" == typeof type) {
1978
2027
  expectNoMoreTextNodes(diffContext), expectElement(diffContext, diffContext.jsxValue, type);
@@ -1984,6 +2033,20 @@ function diff(diffContext, jsxNode, vStartNode) {
1984
2033
  descend(diffContext, diffContext.jsxValue.children, !0, !1)) : type === SSRComment || type === SSRRaw ? expectNoMore(diffContext) : (expectNoMoreTextNodes(diffContext),
1985
2034
  expectComponent(diffContext, type)));
1986
2035
  }
2036
+ } else if (Array.isArray(diffContext.jsxValue)) {
2037
+ descend(diffContext, diffContext.jsxValue, !1);
2038
+ } else if (isSignal(diffContext.jsxValue)) {
2039
+ expectVirtual(diffContext, "S", null);
2040
+ const unwrappedSignal = diffContext.jsxValue instanceof WrappedSignalImpl ? diffContext.jsxValue.$unwrapIfSignal$() : diffContext.jsxValue;
2041
+ const signals = diffContext.vCurrent?.[_EFFECT_BACK_REF]?.get(".")?.backRef;
2042
+ let hasUnwrappedSignal = signals?.has(unwrappedSignal);
2043
+ if (signals && unwrappedSignal instanceof WrappedSignalImpl && (hasUnwrappedSignal = containsWrappedSignal(signals, unwrappedSignal)),
2044
+ !hasUnwrappedSignal) {
2045
+ const vHost = diffContext.vNewNode || diffContext.vCurrent;
2046
+ descend(diffContext, resolveSignalAndDescend(diffContext, () => trackSignalAndAssignHost(unwrappedSignal, vHost, ".", diffContext.container)), !0);
2047
+ }
2048
+ } else {
2049
+ isPromise(diffContext.jsxValue) && (expectVirtual(diffContext, "A", null), diffContext.asyncQueue.push(diffContext.jsxValue, diffContext.vNewNode || diffContext.vCurrent));
1987
2050
  }
1988
2051
  } else {
1989
2052
  diffContext.jsxValue === SkipRender || expectText(diffContext, "");
@@ -2022,15 +2085,23 @@ function advance(diffContext) {
2022
2085
  }
2023
2086
 
2024
2087
  function descend(diffContext, children, descendVNode, shouldExpectNoChildren = !0) {
2025
- shouldExpectNoChildren && (null == children || descendVNode && isArray(children) && 0 === children.length) ? expectNoChildren(diffContext) : (stackPush(diffContext, children, descendVNode),
2026
- descendVNode && (assertDefined(diffContext.vCurrent || diffContext.vNewNode, "Expecting vCurrent to be defined."),
2027
- diffContext.vSideBuffer = null, diffContext.vSiblings = null, diffContext.vSiblingsArray = null,
2028
- diffContext.vParent = diffContext.vNewNode || diffContext.vCurrent, diffContext.vCurrent = vnode_getFirstChild(diffContext.vParent),
2029
- diffContext.vNewNode = null), diffContext.shouldAdvance = !1);
2088
+ if (shouldExpectNoChildren && (null == children || descendVNode && isArray(children) && 0 === children.length)) {
2089
+ expectNoChildren(diffContext);
2090
+ } else {
2091
+ if (stackPush(diffContext, children, descendVNode), descendVNode) {
2092
+ isDev && assertDefined(diffContext.vCurrent || diffContext.vNewNode, "Expecting vCurrent to be defined.");
2093
+ const creationMode = diffContext.isCreationMode || !!diffContext.vNewNode || !vnode_getFirstChild(diffContext.vCurrent);
2094
+ diffContext.isCreationMode = creationMode, diffContext.vSideBuffer = null, diffContext.vSiblings = null,
2095
+ diffContext.vSiblingsArray = null, diffContext.vParent = diffContext.vNewNode || diffContext.vCurrent,
2096
+ diffContext.vCurrent = vnode_getFirstChild(diffContext.vParent), diffContext.vNewNode = null;
2097
+ }
2098
+ diffContext.shouldAdvance = !1;
2099
+ }
2030
2100
  }
2031
2101
 
2032
2102
  function ascend(diffContext) {
2033
- diffContext.stack.pop() && (diffContext.vSideBuffer = diffContext.stack.pop(), diffContext.vSiblings = diffContext.stack.pop(),
2103
+ diffContext.stack.pop() && (diffContext.isCreationMode = diffContext.stack.pop(),
2104
+ diffContext.vSideBuffer = diffContext.stack.pop(), diffContext.vSiblings = diffContext.stack.pop(),
2034
2105
  diffContext.vSiblingsArray = diffContext.stack.pop(), diffContext.vNewNode = diffContext.stack.pop(),
2035
2106
  diffContext.vCurrent = diffContext.stack.pop(), diffContext.vParent = diffContext.stack.pop()),
2036
2107
  diffContext.jsxValue = diffContext.stack.pop(), diffContext.jsxCount = diffContext.stack.pop(),
@@ -2040,7 +2111,7 @@ function ascend(diffContext) {
2040
2111
 
2041
2112
  function stackPush(diffContext, children, descendVNode) {
2042
2113
  diffContext.stack.push(diffContext.jsxChildren, diffContext.jsxIdx, diffContext.jsxCount, diffContext.jsxValue),
2043
- descendVNode && diffContext.stack.push(diffContext.vParent, diffContext.vCurrent, diffContext.vNewNode, diffContext.vSiblingsArray, diffContext.vSiblings, diffContext.vSideBuffer),
2114
+ descendVNode && diffContext.stack.push(diffContext.vParent, diffContext.vCurrent, diffContext.vNewNode, diffContext.vSiblingsArray, diffContext.vSiblings, diffContext.vSideBuffer, diffContext.isCreationMode),
2044
2115
  diffContext.stack.push(descendVNode), Array.isArray(children) ? (diffContext.jsxIdx = 0,
2045
2116
  diffContext.jsxCount = children.length, diffContext.jsxChildren = children, diffContext.jsxValue = diffContext.jsxCount > 0 ? children[0] : null) : void 0 === children ? (diffContext.jsxIdx = 0,
2046
2117
  diffContext.jsxValue = null, diffContext.jsxChildren = null, diffContext.jsxCount = 0) : (diffContext.jsxIdx = 0,
@@ -2095,13 +2166,20 @@ function expectSlot(diffContext) {
2095
2166
  const vHost = vnode_getProjectionParentComponent(diffContext.vParent);
2096
2167
  const slotNameKey = getSlotNameKey(diffContext, vHost);
2097
2168
  const vProjectedNode = vHost ? vnode_getProp(vHost, slotNameKey, null) : null;
2098
- return null == vProjectedNode ? (vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2099
- vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode),
2100
- isDev && vnode_setProp(diffContext.vNewNode, "q:type", "P"), isDev && vnode_setProp(diffContext.vNewNode, "q:code", "expectSlot" + count++),
2101
- !1) : (vProjectedNode === diffContext.vCurrent || (vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vProjectedNode, diffContext.vCurrent && getInsertBefore(diffContext)),
2102
- vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode),
2103
- isDev && vnode_setProp(diffContext.vNewNode, "q:type", "P"), isDev && vnode_setProp(diffContext.vNewNode, "q:code", "expectSlot" + count++)),
2104
- !0);
2169
+ if (null == vProjectedNode) {
2170
+ return vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2171
+ vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode),
2172
+ isDev && vnode_setProp(diffContext.vNewNode, "q:type", "P"), isDev && vnode_setProp(diffContext.vNewNode, "q:code", "expectSlot" + count++),
2173
+ !1;
2174
+ }
2175
+ if (vProjectedNode === diffContext.vCurrent) {} else {
2176
+ const oldParent = vProjectedNode.parent;
2177
+ vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vProjectedNode, diffContext.vCurrent && getInsertBefore(diffContext)),
2178
+ vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode),
2179
+ isDev && vnode_setProp(diffContext.vNewNode, "q:type", "P"), isDev && vnode_setProp(diffContext.vNewNode, "q:code", "expectSlot" + count++),
2180
+ oldParent && vnode_isElementVNode(oldParent) && !oldParent.firstChild && vnode_getElementName(oldParent) === QTemplate && vnode_remove(diffContext.journal, oldParent.parent, oldParent, !0);
2181
+ }
2182
+ return !0;
2105
2183
  }
2106
2184
 
2107
2185
  function getSlotNameKey(diffContext, vHost) {
@@ -2160,7 +2238,7 @@ function expectNoChildren(diffContext, removeDOM = !0) {
2160
2238
  }
2161
2239
 
2162
2240
  function expectNoMore(diffContext) {
2163
- if (assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
2241
+ if (isDev && assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
2164
2242
  null !== diffContext.vCurrent) {
2165
2243
  for (;diffContext.vCurrent; ) {
2166
2244
  const toRemove = diffContext.vCurrent;
@@ -2180,17 +2258,6 @@ function expectNoMoreTextNodes(diffContext) {
2180
2258
 
2181
2259
  function createNewElement(diffContext, jsx, elementName, currentFile) {
2182
2260
  const element = createElementWithNamespace(diffContext, elementName);
2183
- function setAttribute(key, value, vHost) {
2184
- if (null != (value = serializeAttribute(key, value, diffContext.scopedStyleIdPrefix))) {
2185
- if (128 & vHost.flags) {
2186
- const namespace = getAttributeNamespace(key);
2187
- if (namespace) {
2188
- return void element.setAttributeNS(namespace, key, value);
2189
- }
2190
- }
2191
- element.setAttribute(key, value);
2192
- }
2193
- }
2194
2261
  const {constProps} = jsx;
2195
2262
  let needsQDispatchEventPatch = !1;
2196
2263
  if (constProps) {
@@ -2229,13 +2296,13 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
2229
2296
  }
2230
2297
  if (isPromise(value)) {
2231
2298
  const vHost = diffContext.vNewNode;
2232
- const attributePromise = value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
2299
+ const attributePromise = value.then(resolvedValue => directSetAttribute(element, key, serializeAttribute(key, resolvedValue, diffContext.scopedStyleIdPrefix), !!(128 & vHost.flags)));
2233
2300
  diffContext.asyncAttributePromises.push(attributePromise);
2234
2301
  continue;
2235
2302
  }
2236
2303
  if (key !== dangerouslySetInnerHTML) {
2237
2304
  if ("textarea" !== elementName || "value" !== key) {
2238
- setAttribute(key, value, diffContext.vNewNode);
2305
+ directSetAttribute(element, key, serializeAttribute(key, value, diffContext.scopedStyleIdPrefix), !!(128 & diffContext.vNewNode.flags));
2239
2306
  } else {
2240
2307
  if (value && "string" != typeof value) {
2241
2308
  if (isDev) {
@@ -2252,35 +2319,39 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
2252
2319
  }
2253
2320
  const key = jsx.key;
2254
2321
  if (key && (diffContext.vNewNode.key = key), diffContext.scopedStyleIdPrefix) {
2255
- hasClassAttr(jsx.varProps) || jsx.constProps && hasClassAttr(jsx.constProps) || element.setAttribute("class", diffContext.scopedStyleIdPrefix);
2322
+ _hasOwnProperty.call(jsx.varProps, "class") || jsx.constProps && _hasOwnProperty.call(jsx.constProps, "class") || element.setAttribute("class", diffContext.scopedStyleIdPrefix);
2256
2323
  }
2257
2324
  return vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode, diffContext.vCurrent),
2258
2325
  needsQDispatchEventPatch;
2259
2326
  }
2260
2327
 
2261
2328
  function createElementWithNamespace(diffContext, elementName) {
2262
- const domParentVNode = vnode_getDomParentVNode(diffContext.vParent, !0);
2263
- const {elementNamespace, elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, elementName);
2264
- const element = diffContext.container.document.createElementNS(elementNamespace, elementName);
2265
- return diffContext.vNewNode = vnode_newElement(element, elementName), diffContext.vNewNode.flags |= elementNamespaceFlag,
2329
+ const namespaceData = getNewElementNamespaceData(vnode_getDomParentVNode(diffContext.vParent, !0), elementName);
2330
+ const currentDocument = import.meta.env.TEST ? diffContext.container.document : document;
2331
+ const element = 0 === namespaceData.elementNamespaceFlag ? currentDocument.createElement(elementName) : currentDocument.createElementNS(namespaceData.elementNamespace, elementName);
2332
+ return diffContext.vNewNode = vnode_newElement(element, elementName), diffContext.vNewNode.flags |= namespaceData.elementNamespaceFlag,
2266
2333
  element;
2267
2334
  }
2268
2335
 
2269
2336
  function expectElement(diffContext, jsx, elementName) {
2270
- const isSameElementName = diffContext.vCurrent && vnode_isElementVNode(diffContext.vCurrent) && elementName === vnode_getElementName(diffContext.vCurrent);
2271
- const jsxKey = jsx.key;
2272
2337
  let needsQDispatchEventPatch = !1;
2273
- const currentKey = getKey(diffContext.vCurrent);
2274
- if (isSameElementName && jsxKey === currentKey) {
2275
- deleteFromSideBuffer(diffContext, elementName, jsxKey);
2338
+ if (diffContext.isCreationMode) {
2339
+ needsQDispatchEventPatch = createNewElement(diffContext, jsx, elementName, null);
2276
2340
  } else {
2277
- const sideBufferKey = getSideBufferKey(elementName, jsxKey);
2278
- moveOrCreateKeyedNode(diffContext, elementName, jsxKey, sideBufferKey, diffContext.vParent) && (needsQDispatchEventPatch = createNewElement(diffContext, jsx, elementName, null));
2341
+ const isElementVNode = diffContext.vCurrent && vnode_isElementVNode(diffContext.vCurrent);
2342
+ const isSameElementName = isElementVNode && elementName === vnode_getElementName(diffContext.vCurrent);
2343
+ const jsxKey = jsx.key;
2344
+ if (isSameElementName && jsxKey === (isElementVNode && diffContext.vCurrent.key)) {
2345
+ deleteFromSideBuffer(diffContext, elementName, jsxKey);
2346
+ } else {
2347
+ const sideBufferKey = getSideBufferKey(elementName, jsxKey);
2348
+ moveOrCreateKeyedNode(diffContext, elementName, jsxKey, sideBufferKey, diffContext.vParent) && (needsQDispatchEventPatch = createNewElement(diffContext, jsx, elementName, null));
2349
+ }
2279
2350
  }
2280
2351
  const jsxProps = jsx.varProps;
2281
2352
  const vNode = diffContext.vNewNode || diffContext.vCurrent;
2282
2353
  const element = vNode.node;
2283
- jsxProps && (needsQDispatchEventPatch = diffProps(diffContext, vNode, jsxProps, vNode.props ||= {}, isDev && getFileLocationFromJsx(jsx.dev) || null) || needsQDispatchEventPatch),
2354
+ jsxProps && (needsQDispatchEventPatch = diffProps(diffContext, vNode, jsxProps, isDev && getFileLocationFromJsx(jsx.dev) || null) || needsQDispatchEventPatch),
2284
2355
  needsQDispatchEventPatch && (element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
2285
2356
  if (32 & vNode.flags) {
2286
2357
  return;
@@ -2289,71 +2360,100 @@ function expectElement(diffContext, jsx, elementName) {
2289
2360
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
2290
2361
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
2291
2362
  for (const qrl of qrls.flat(2)) {
2292
- qrl && catchError(qrl(event, element), e => {
2363
+ qrl && callQrl(diffContext.container, vNode, qrl, event, vNode.node, !1).catch(e => {
2293
2364
  diffContext.container.handleError(e, vNode);
2294
2365
  });
2295
2366
  }
2296
2367
  }));
2297
2368
  }
2298
2369
 
2299
- function diffProps(diffContext, vnode, newAttrs, oldAttrs, currentFile) {
2300
- vnode_ensureElementInflated(vnode);
2370
+ function diffProps(diffContext, vnode, newAttrs, currentFile) {
2371
+ diffContext.isCreationMode || vnode_ensureElementInflated(vnode);
2372
+ const oldAttrs = vnode.props;
2301
2373
  let patchEventDispatch = !1;
2302
- const record = (key, value) => {
2303
- if (key.startsWith(":")) {
2304
- return void vnode_setProp(vnode, key, value);
2305
- }
2306
- if ("ref" === key) {
2307
- const element = vnode.node;
2308
- if (isSignal(value)) {
2309
- return void (value.value = element);
2374
+ for (const key in newAttrs) {
2375
+ const newValue = newAttrs[key];
2376
+ const isEvent = isHtmlAttributeAnEventName(key);
2377
+ if (oldAttrs && _hasOwnProperty.call(oldAttrs, key)) {
2378
+ const oldValue = oldAttrs[key];
2379
+ if (newValue !== oldValue) {
2380
+ if (newValue instanceof WrappedSignalImpl && oldValue instanceof WrappedSignalImpl && areWrappedSignalsEqual(newValue, oldValue)) {
2381
+ continue;
2382
+ }
2383
+ if (isEvent) {
2384
+ const result = recordJsxEvent(diffContext, vnode, key, newValue, currentFile);
2385
+ patchEventDispatch ||= result;
2386
+ } else {
2387
+ patchProperty(diffContext, vnode, key, newValue, currentFile);
2388
+ }
2310
2389
  }
2311
- if ("function" == typeof value) {
2312
- return void value(element);
2390
+ } else if (null != newValue) {
2391
+ if (isEvent) {
2392
+ const result = recordJsxEvent(diffContext, vnode, key, newValue, currentFile);
2393
+ patchEventDispatch ||= result;
2394
+ } else {
2395
+ patchProperty(diffContext, vnode, key, newValue, currentFile);
2313
2396
  }
2314
- throw qError(15, [ currentFile ]);
2315
2397
  }
2316
- const currentEffect = vnode[_EFFECT_BACK_REF]?.get(key);
2398
+ }
2399
+ if (oldAttrs) {
2400
+ for (const key in oldAttrs) {
2401
+ _hasOwnProperty.call(newAttrs, key) || key.startsWith(HANDLER_PREFIX) || isHtmlAttributeAnEventName(key) || patchProperty(diffContext, vnode, key, null, currentFile);
2402
+ }
2403
+ }
2404
+ return patchEventDispatch;
2405
+ }
2406
+
2407
+ const patchProperty = (diffContext, vnode, key, value, currentFile) => {
2408
+ if ("q:p" === key || "q:ps" === key || key.charAt(0) === HANDLER_PREFIX) {
2409
+ return void vnode_setProp(vnode, key, value);
2410
+ }
2411
+ const originalValue = value;
2412
+ if ("ref" === key) {
2413
+ const element = vnode.node;
2317
2414
  if (isSignal(value)) {
2318
- const unwrappedSignal = value instanceof WrappedSignalImpl ? value.$unwrapIfSignal$() : value;
2319
- if (currentEffect?.[2]?.has(unwrappedSignal)) {
2320
- return;
2321
- }
2322
- currentEffect && clearEffectSubscription(diffContext.container, currentEffect);
2323
- const vHost = vnode;
2324
- value = retryOnPromise(() => trackSignalAndAssignHost(unwrappedSignal, vHost, key, diffContext.container, diffContext.subscriptionData.var));
2325
- } else {
2326
- currentEffect && clearEffectSubscription(diffContext.container, currentEffect);
2415
+ return void (value.value = element);
2327
2416
  }
2328
- if (isPromise(value)) {
2329
- const vHost = vnode;
2330
- const attributePromise = value.then(resolvedValue => {
2331
- setAttribute(diffContext.journal, vHost, key, resolvedValue, diffContext.scopedStyleIdPrefix);
2332
- });
2333
- return void diffContext.asyncAttributePromises.push(attributePromise);
2417
+ if ("function" == typeof value) {
2418
+ return void value(element);
2334
2419
  }
2335
- setAttribute(diffContext.journal, vnode, key, value, diffContext.scopedStyleIdPrefix);
2336
- };
2337
- const recordJsxEvent = (key, value) => {
2338
- const data = getEventDataFromHtmlAttribute(key);
2339
- if (data) {
2340
- const [scope, eventName] = data;
2341
- const scopedEvent = getScopedEventName(scope, eventName);
2342
- const loaderScopedEvent = getLoaderScopedEventName(scope, scopedEvent);
2343
- record(":" + scopedEvent, value), registerQwikLoaderEvent(diffContext, loaderScopedEvent),
2344
- patchEventDispatch = !0;
2420
+ throw qError(15, [ currentFile ]);
2421
+ }
2422
+ const currentEffect = vnode[_EFFECT_BACK_REF]?.get(key);
2423
+ if (isSignal(value)) {
2424
+ const unwrappedSignal = value instanceof WrappedSignalImpl ? value.$unwrapIfSignal$() : value;
2425
+ if (currentEffect?.backRef?.has(unwrappedSignal)) {
2426
+ return;
2345
2427
  }
2346
- };
2347
- for (const key of Object.keys(newAttrs)) {
2348
- const newValue = newAttrs[key];
2349
- const isEvent = isHtmlAttributeAnEventName(key);
2350
- _hasOwnProperty.call(oldAttrs, key) ? newValue !== oldAttrs[key] && (isEvent ? recordJsxEvent(key, newValue) : record(key, newValue)) : null != newValue && (isEvent ? recordJsxEvent(key, newValue) : record(key, newValue));
2428
+ currentEffect && clearEffectSubscription(diffContext.container, currentEffect);
2429
+ const vHost = vnode;
2430
+ value = retryOnPromise(() => trackSignalAndAssignHost(unwrappedSignal, vHost, key, diffContext.container, diffContext.subscriptionData.var));
2431
+ } else {
2432
+ currentEffect && clearEffectSubscription(diffContext.container, currentEffect);
2351
2433
  }
2352
- for (const key of Object.keys(oldAttrs)) {
2353
- _hasOwnProperty.call(newAttrs, key) || key.startsWith(HANDLER_PREFIX) || isHtmlAttributeAnEventName(key) || record(key, null);
2434
+ if (isPromise(value)) {
2435
+ const vHost = vnode;
2436
+ const attributePromise = value.then(resolvedValue => {
2437
+ setAttribute(diffContext.journal, vHost, key, resolvedValue, diffContext.scopedStyleIdPrefix, originalValue);
2438
+ });
2439
+ return void diffContext.asyncAttributePromises.push(attributePromise);
2354
2440
  }
2355
- return patchEventDispatch;
2356
- }
2441
+ setAttribute(diffContext.journal, vnode, key, value, diffContext.scopedStyleIdPrefix, originalValue);
2442
+ };
2443
+
2444
+ const recordJsxEvent = (diffContext, vnode, key, value, currentFile) => {
2445
+ const data = getEventDataFromHtmlAttribute(key);
2446
+ if (data) {
2447
+ const props = vnode.props;
2448
+ const [scope, eventName] = data;
2449
+ const scopedEvent = getScopedEventName(scope, eventName);
2450
+ const loaderScopedEvent = getLoaderScopedEventName(scope, scopedEvent);
2451
+ const scopedEventKey = ":" + scopedEvent;
2452
+ return (!props || !_hasOwnProperty.call(props, scopedEventKey)) && (patchProperty(diffContext, vnode, scopedEventKey, value, currentFile),
2453
+ registerQwikLoaderEvent(diffContext, loaderScopedEvent), !0);
2454
+ }
2455
+ return !1;
2456
+ };
2357
2457
 
2358
2458
  function registerQwikLoaderEvent(diffContext, eventName) {
2359
2459
  const qWindow = import.meta.env.TEST ? diffContext.container.document.defaultView : window;
@@ -2363,6 +2463,13 @@ function registerQwikLoaderEvent(diffContext, eventName) {
2363
2463
  function retrieveChildWithKey(diffContext, nodeName, key) {
2364
2464
  let vNodeWithKey = null;
2365
2465
  if (null === diffContext.vSiblings) {
2466
+ const vCurrent = diffContext.vCurrent;
2467
+ if (vCurrent) {
2468
+ const name = vnode_isElementVNode(vCurrent) ? vnode_getElementName(vCurrent) : null;
2469
+ if ((getKey(vCurrent) || getComponentHash(vCurrent, diffContext.container.$getObjectById$)) === key && name === nodeName) {
2470
+ return vCurrent;
2471
+ }
2472
+ }
2366
2473
  diffContext.vSiblings = new Map, diffContext.vSiblingsArray = [];
2367
2474
  let vNode = diffContext.vCurrent;
2368
2475
  for (;vNode; ) {
@@ -2380,8 +2487,8 @@ function retrieveChildWithKey(diffContext, nodeName, key) {
2380
2487
  }
2381
2488
  } else {
2382
2489
  const siblingsKey = getSideBufferKey(nodeName, key);
2383
- diffContext.vSiblings.has(siblingsKey) && (vNodeWithKey = diffContext.vSiblings.get(siblingsKey),
2384
- diffContext.vSiblings.delete(siblingsKey));
2490
+ const sibling = diffContext.vSiblings.get(siblingsKey);
2491
+ sibling && (vNodeWithKey = sibling, diffContext.vSiblings.delete(siblingsKey));
2385
2492
  }
2386
2493
  return collectSideBufferSiblings(diffContext, vNodeWithKey), vNodeWithKey;
2387
2494
  }
@@ -2425,8 +2532,8 @@ function deleteFromSideBuffer(diffContext, nodeName, key) {
2425
2532
  function moveOrCreateKeyedNode(diffContext, nodeName, lookupKey, sideBufferKey, parentForInsert, addCurrentToSideBufferOnSideInsert) {
2426
2533
  if (diffContext.vNewNode = retrieveChildWithKey(diffContext, nodeName, lookupKey),
2427
2534
  diffContext.vNewNode) {
2428
- return diffContext.vCurrent = diffContext.vNewNode, diffContext.vNewNode = null,
2429
- !1;
2535
+ return vnode_insertBefore(diffContext.journal, parentForInsert, diffContext.vNewNode, diffContext.vCurrent),
2536
+ diffContext.vCurrent = diffContext.vNewNode, diffContext.vNewNode = null, !1;
2430
2537
  }
2431
2538
  if (null != sideBufferKey) {
2432
2539
  const buffered = diffContext.vSideBuffer?.get(sideBufferKey) || null;
@@ -2449,7 +2556,7 @@ function expectVirtual(diffContext, type, jsxKey) {
2449
2556
  const checkKey = "F" === type;
2450
2557
  const currentKey = getKey(diffContext.vCurrent);
2451
2558
  if (!diffContext.vCurrent || !vnode_isVirtualVNode(diffContext.vCurrent) || currentKey !== jsxKey || checkKey && !jsxKey) {
2452
- return null === jsxKey ? (vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2559
+ return null === jsxKey || diffContext.isCreationMode ? (vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2453
2560
  diffContext.vNewNode.key = jsxKey, void (isDev && vnode_setProp(diffContext.vNewNode, "q:type", type))) : void (moveOrCreateKeyedNode(diffContext, null, jsxKey, getSideBufferKey(null, jsxKey), diffContext.vParent, !0) && (vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2454
2561
  diffContext.vNewNode.key = jsxKey, isDev && vnode_setProp(diffContext.vNewNode, "q:type", type)));
2455
2562
  }
@@ -2513,7 +2620,7 @@ function expectText(diffContext, text) {
2513
2620
  return text !== vnode_getText(diffContext.vCurrent) ? void vnode_setText(diffContext.journal, diffContext.vCurrent, text) : void 0;
2514
2621
  }
2515
2622
  }
2516
- vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newText(diffContext.container.document.createTextNode(text), text), diffContext.vCurrent);
2623
+ vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newText((import.meta.env.TEST ? diffContext.container.document : document).createTextNode(text), text), diffContext.vCurrent);
2517
2624
  }
2518
2625
 
2519
2626
  function getKey(vNode) {
@@ -2533,10 +2640,10 @@ function Projection() {}
2533
2640
  function handleProps(host, jsxProps, vNodeProps, container) {
2534
2641
  let shouldRender = !1;
2535
2642
  if (vNodeProps) {
2536
- const effects = vNodeProps[_PROPS_HANDLER].$effects$;
2537
2643
  const constPropsDifferent = handleChangedProps(jsxProps[_CONST_PROPS], vNodeProps[_CONST_PROPS], vNodeProps[_PROPS_HANDLER], container, !1);
2538
- shouldRender ||= constPropsDifferent, effects && effects.size > 0 && handleChangedProps(jsxProps[_VAR_PROPS], vNodeProps[_VAR_PROPS], vNodeProps[_PROPS_HANDLER], container, !0),
2539
- vNodeProps[_OWNER] = jsxProps[_OWNER];
2644
+ shouldRender ||= constPropsDifferent;
2645
+ const varPropsDifferent = handleChangedProps(jsxProps[_VAR_PROPS], vNodeProps[_VAR_PROPS], vNodeProps[_PROPS_HANDLER], container, !0);
2646
+ shouldRender ||= varPropsDifferent, vNodeProps[_OWNER] = jsxProps[_OWNER];
2540
2647
  } else {
2541
2648
  jsxProps && (vnode_setProp(host, "q:props", jsxProps), vNodeProps = jsxProps);
2542
2649
  }
@@ -2552,17 +2659,20 @@ function handleChangedProps(src, dst, propsHandler, container, triggerEffects =
2552
2659
  if (src) {
2553
2660
  for (const key in src) {
2554
2661
  if ("children" !== key && "q:brefs" !== key && (!dst || src[key] !== dst[key])) {
2555
- if (changed = !0, !triggerEffects) {
2662
+ if (!triggerEffects) {
2556
2663
  return !0;
2557
2664
  }
2558
- dst && (dst[key] = src[key]), triggerPropsProxyEffect(propsHandler, key);
2665
+ dst && (dst[key] = src[key]);
2666
+ triggerPropsProxyEffect(propsHandler, key) || (changed = !0);
2559
2667
  }
2560
2668
  }
2561
2669
  }
2562
2670
  if (dst) {
2563
2671
  for (const key in dst) {
2564
- "children" !== key && "q:brefs" !== key && (src && _hasOwnProperty.call(src, key) || (changed = !0,
2565
- triggerEffects && (delete dst[key], triggerPropsProxyEffect(propsHandler, key))));
2672
+ if ("children" !== key && "q:brefs" !== key && (!src || !_hasOwnProperty.call(src, key)) && triggerEffects) {
2673
+ delete dst[key];
2674
+ triggerPropsProxyEffect(propsHandler, key) || (changed = !0);
2675
+ }
2566
2676
  }
2567
2677
  }
2568
2678
  return changed;
@@ -2669,10 +2779,58 @@ function markVNodeAsDeleted(vCursor) {
2669
2779
  vCursor.flags |= 32;
2670
2780
  }
2671
2781
 
2782
+ function areWrappedSignalsEqual(oldSignal, newSignal) {
2783
+ return oldSignal === newSignal || newSignal.$func$ === oldSignal.$func$ && areArgumentsEqual(newSignal.$args$, oldSignal.$args$);
2784
+ }
2785
+
2786
+ function areArgumentsEqual(oldArgs, newArgs) {
2787
+ if (oldArgs === newArgs) {
2788
+ return !0;
2789
+ }
2790
+ if (!oldArgs || !newArgs || oldArgs.length !== newArgs.length) {
2791
+ return !1;
2792
+ }
2793
+ for (let i = 0; i < oldArgs.length; i++) {
2794
+ if (oldArgs[i] !== newArgs[i]) {
2795
+ return !1;
2796
+ }
2797
+ }
2798
+ return !0;
2799
+ }
2800
+
2801
+ function containsWrappedSignal(data, signal) {
2802
+ if (!(signal instanceof WrappedSignalImpl)) {
2803
+ return !1;
2804
+ }
2805
+ for (const item of data) {
2806
+ if (item instanceof WrappedSignalImpl && areWrappedSignalsEqual(item, signal)) {
2807
+ return !0;
2808
+ }
2809
+ }
2810
+ return !1;
2811
+ }
2812
+
2672
2813
  const HANDLER_PREFIX = ":";
2673
2814
 
2674
2815
  let count = 0;
2675
2816
 
2817
+ const useSequentialScope = () => {
2818
+ const iCtx = useInvokeContext();
2819
+ const host = iCtx.$hostElement$;
2820
+ let seq = iCtx.$container$.getHostProp(host, "q:seq");
2821
+ null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
2822
+ let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
2823
+ for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
2824
+ seq.push(void 0);
2825
+ }
2826
+ return {
2827
+ val: seq[seqIdx],
2828
+ set: value => seq[seqIdx] = value,
2829
+ i: seqIdx,
2830
+ iCtx
2831
+ };
2832
+ };
2833
+
2676
2834
  const useResourceQrl = (qrl, opts) => {
2677
2835
  const {val, set, i, iCtx} = useSequentialScope();
2678
2836
  if (null != val) {
@@ -2694,7 +2852,7 @@ function getResourceValueAsPromise(props) {
2694
2852
  const state = resource._state;
2695
2853
  if (!isServerPlatform()) {
2696
2854
  if ("pending" === state && props.onPending) {
2697
- return Promise.resolve().then(useBindInvokeContext(props.onPending));
2855
+ return resource.value.catch(() => {}), Promise.resolve().then(useBindInvokeContext(props.onPending));
2698
2856
  }
2699
2857
  if ("rejected" === state && props.onRejected) {
2700
2858
  return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
@@ -2743,7 +2901,7 @@ const runResource = (task, container, host) => {
2743
2901
  iCtx.$container$ = container;
2744
2902
  const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
2745
2903
  const resource = task.$state$;
2746
- assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
2904
+ isDev && assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
2747
2905
  const track = trackFn(task, container);
2748
2906
  const [cleanup, cleanups] = cleanupFn(task, reason => container.handleError(reason, host));
2749
2907
  const resourceTarget = unwrapStore(resource);
@@ -2789,36 +2947,6 @@ const runResource = (task, container, host) => {
2789
2947
  }) ]) : promise;
2790
2948
  };
2791
2949
 
2792
- const createDeleteOperation = target => ({
2793
- operationType: 1,
2794
- target
2795
- });
2796
-
2797
- const createRemoveAllChildrenOperation = target => ({
2798
- operationType: 4,
2799
- target
2800
- });
2801
-
2802
- const createSetTextOperation = (target, text) => ({
2803
- operationType: 16,
2804
- target,
2805
- text
2806
- });
2807
-
2808
- const createInsertOrMoveOperation = (target, parent, beforeTarget) => ({
2809
- operationType: 2,
2810
- target,
2811
- parent,
2812
- beforeTarget
2813
- });
2814
-
2815
- const createSetAttributeOperation = (target, attrName, attrValue) => ({
2816
- operationType: 8,
2817
- target,
2818
- attrName,
2819
- attrValue
2820
- });
2821
-
2822
2950
  function executeTasks(vNode, container, cursorData) {
2823
2951
  vNode.dirty &= -2;
2824
2952
  const elementSeq = container.getHostProp(vNode, "q:seq");
@@ -2895,8 +3023,9 @@ function clearNodePropData(vNode) {
2895
3023
  delete (vNode.props ||= {})[":nodeProps"];
2896
3024
  }
2897
3025
 
2898
- function setNodeProp(domVNode, journal, property, value, isConst) {
2899
- journal.push(createSetAttributeOperation(domVNode.node, property, value)), isConst || (domVNode.props && null == value ? delete domVNode.props[property] : (domVNode.props ||= {})[property] = value);
3026
+ function setNodeProp(domVNode, journal, property, value, isConst, scopedStyleIdPrefix = null) {
3027
+ journal.push(createSetAttributeOperation(domVNode.node, property, value, scopedStyleIdPrefix, !!(128 & domVNode.flags))),
3028
+ isConst || (domVNode.props && null == value ? delete domVNode.props[property] : (domVNode.props ||= {})[property] = value);
2900
3029
  }
2901
3030
 
2902
3031
  function executeNodeProps(vNode, journal) {
@@ -2911,7 +3040,7 @@ function executeNodeProps(vNode, journal) {
2911
3040
  for (const [property, nodeProp] of allPropData.entries()) {
2912
3041
  let value = nodeProp.value;
2913
3042
  isSignal(value) && (value = value.value);
2914
- setNodeProp(domVNode, journal, property, serializeAttribute(property, value, nodeProp.scopedStyleIdPrefix), nodeProp.isConst);
3043
+ setNodeProp(domVNode, journal, property, value, nodeProp.isConst, nodeProp.scopedStyleIdPrefix);
2915
3044
  }
2916
3045
  clearNodePropData(vNode);
2917
3046
  }
@@ -2958,39 +3087,69 @@ const fastInsertBefore = (insertBeforeParent, target, insertBefore) => {
2958
3087
  };
2959
3088
 
2960
3089
  function _flushJournal(journal) {
3090
+ let batchParent = null;
3091
+ let batchBefore = null;
3092
+ let batchNodes = null;
3093
+ const batchSet = new Set;
3094
+ const flush = () => {
3095
+ if (batchNodes) {
3096
+ if (1 === batchNodes.length) {
3097
+ fastInsertBefore(batchParent, batchNodes[0], batchBefore);
3098
+ } else {
3099
+ const fragment = (batchParent.ownerDocument || batchParent).createDocumentFragment();
3100
+ for (const node of batchNodes) {
3101
+ fragment.appendChild(node);
3102
+ }
3103
+ fastInsertBefore(batchParent, fragment, batchBefore);
3104
+ }
3105
+ batchNodes = null, batchParent = null, batchBefore = null, batchSet.clear();
3106
+ }
3107
+ };
2961
3108
  for (const operation of journal) {
2962
- switch (operation.operationType) {
2963
- case 2:
3109
+ if (operation instanceof InsertOrMoveOperation) {
3110
+ if (batchParent === operation.parent && batchBefore === operation.beforeTarget) {
3111
+ batchNodes || (batchNodes = []), batchNodes.push(operation.target), batchSet.add(operation.target);
3112
+ continue;
3113
+ }
3114
+ if (!batchNodes) {
3115
+ batchParent = operation.parent, batchBefore = operation.beforeTarget, batchNodes = [ operation.target ],
3116
+ batchSet.add(operation.target);
3117
+ continue;
3118
+ }
3119
+ if (batchParent === operation.parent) {
3120
+ flush(), batchParent = operation.parent, batchBefore = operation.beforeTarget, batchNodes = [ operation.target ],
3121
+ batchSet.add(operation.target);
3122
+ continue;
3123
+ }
3124
+ if (batchSet.has(operation.target) || batchBefore && operation.target === batchBefore || batchParent && operation.target === batchParent) {
3125
+ flush(), batchParent = operation.parent, batchBefore = operation.beforeTarget, batchNodes = [ operation.target ],
3126
+ batchSet.add(operation.target);
3127
+ continue;
3128
+ }
2964
3129
  fastInsertBefore(operation.parent, operation.target, operation.beforeTarget);
2965
- break;
2966
-
2967
- case 1:
3130
+ } else if (operation instanceof DeleteOperation) {
3131
+ (batchSet.has(operation.target) || batchBefore && operation.target === batchBefore || batchParent && operation.target === batchParent) && flush(),
2968
3132
  operation.target.remove();
2969
- break;
2970
-
2971
- case 16:
2972
- operation.target.nodeValue = operation.text;
2973
- break;
2974
-
2975
- case 8:
2976
- {
3133
+ } else {
3134
+ if (operation instanceof RemoveAllChildrenOperation) {
3135
+ (batchSet.has(operation.target) || batchBefore && operation.target === batchBefore || batchParent && operation.target === batchParent) && flush();
3136
+ operation.target.textContent = "";
3137
+ continue;
3138
+ }
3139
+ if (operation instanceof SetTextOperation) {
3140
+ operation.target.nodeValue = operation.text;
3141
+ } else if (operation instanceof SetAttributeOperation) {
2977
3142
  const element = operation.target;
2978
3143
  const attrName = operation.attrName;
2979
- const attrValue = operation.attrValue;
3144
+ const rawValue = operation.attrValue;
3145
+ const attrValue = null != rawValue ? serializeAttribute(attrName, rawValue, operation.scopedStyleIdPrefix) : null;
2980
3146
  const shouldRemove = null == attrValue || !1 === attrValue;
2981
- isBooleanAttr(element, attrName) ? element[attrName] = parseBoolean(attrValue) : attrName === dangerouslySetInnerHTML ? (element.innerHTML = attrValue,
2982
- element.setAttribute("q:container", "html")) : shouldRemove ? element.removeAttribute(attrName) : "value" === attrName && attrName in element ? element.value = attrValue : element.setAttribute(attrName, attrValue);
2983
- break;
2984
- }
2985
-
2986
- case 4:
2987
- {
2988
- const removeParent = operation.target;
2989
- removeParent.replaceChildren ? removeParent.replaceChildren() : removeParent.textContent = "";
2990
- break;
3147
+ isBooleanAttr(element, attrName) ? element[attrName] = parseBoolean(attrValue) : attrName === dangerouslySetInnerHTML ? (batchParent === element && flush(),
3148
+ element.innerHTML = attrValue, element.setAttribute("q:container", "html")) : shouldRemove ? element.removeAttribute(attrName) : "value" === attrName && attrName in element ? element.value = attrValue : directSetAttribute(element, attrName, attrValue, operation.isSvg);
2991
3149
  }
2992
3150
  }
2993
3151
  }
3152
+ flush();
2994
3153
  }
2995
3154
 
2996
3155
  function executeAfterFlush(container, cursorData) {
@@ -3050,20 +3209,20 @@ function processCursorQueue(options = {
3050
3209
 
3051
3210
  function walkCursor(cursor, options) {
3052
3211
  const {timeBudget} = options;
3053
- const isServer = isServerPlatform();
3212
+ const isRunningOnServer = import.meta.env.TEST ? isServerPlatform() : isServer;
3054
3213
  const startTime = performance.now();
3055
3214
  const cursorData = getCursorData(cursor);
3056
3215
  if (cursorData.promise) {
3057
3216
  return;
3058
3217
  }
3059
3218
  const container = cursorData.container;
3060
- if (assertDefined(container, "Cursor container not found"), !cursor.dirty) {
3061
- return void finishWalk(container, cursor, cursorData, isServer);
3219
+ if (isDev && assertDefined(container, "Cursor container not found"), !cursor.dirty) {
3220
+ return void finishWalk(container, cursor, cursorData, isRunningOnServer);
3062
3221
  }
3063
3222
  const journal = cursorData.journal ||= [];
3064
3223
  let currentVNode = null;
3065
3224
  for (;currentVNode = cursorData.position; ) {
3066
- if (!isServer && !import.meta.env.TEST) {
3225
+ if (!isRunningOnServer && !import.meta.env.TEST) {
3067
3226
  if (performance.now() - startTime >= timeBudget) {
3068
3227
  return void scheduleYield();
3069
3228
  }
@@ -3114,8 +3273,8 @@ function walkCursor(cursor, options) {
3114
3273
  });
3115
3274
  }
3116
3275
  }
3117
- assertFalse(!(!(127 & cursor.dirty) || cursorData.position), "Cursor is still dirty and position is not set after walking"),
3118
- finishWalk(container, cursor, cursorData, isServer);
3276
+ isDev && assertFalse(!(!(127 & cursor.dirty) || cursorData.position), "Cursor is still dirty and position is not set after walking"),
3277
+ finishWalk(container, cursor, cursorData, isRunningOnServer);
3119
3278
  }
3120
3279
 
3121
3280
  function finishWalk(container, cursor, cursorData, isServer) {
@@ -3131,7 +3290,8 @@ function finishWalk(container, cursor, cursorData, isServer) {
3131
3290
  }
3132
3291
 
3133
3292
  function resolveCursor(container) {
3134
- 0 === container.$cursorCount$ && (container.$resolveRenderPromise$(), container.$renderPromise$ = null);
3293
+ 0 === container.$cursorCount$ && 0 === container.$pausedCursorCount$ && (container.$resolveRenderPromise$(),
3294
+ container.$renderPromise$ = null);
3135
3295
  }
3136
3296
 
3137
3297
  function partitionDirtyChildren(dirtyChildren, parent) {
@@ -3168,7 +3328,8 @@ function getNextVNode(vNode, cursor) {
3168
3328
  }
3169
3329
  index++, index === len && (index = 0);
3170
3330
  }
3171
- return parent.dirty &= -33, parent.dirtyChildren = null, getNextVNode(parent, cursor);
3331
+ return parent.dirty &= -33, parent.dirtyChildren = null, parent.nextDirtyChildIndex = 0,
3332
+ getNextVNode(parent, cursor);
3172
3333
  }
3173
3334
 
3174
3335
  function addCursor(container, root, priority) {
@@ -3214,7 +3375,7 @@ function _executeSsrChores(container, ssrNode) {
3214
3375
  const result = executeTasksChore(container, ssrNode);
3215
3376
  isPromise(result) && (promise = result);
3216
3377
  }
3217
- if (ssrNode.dirty &= -128, promise) {
3378
+ if (ssrNode.dirty &= -124, promise) {
3218
3379
  return promise;
3219
3380
  }
3220
3381
  }
@@ -3298,7 +3459,7 @@ function findAndPropagateToBlockingCursor(vNode) {
3298
3459
  }
3299
3460
 
3300
3461
  function isSsrNodeGuard() {
3301
- return isServerPlatform();
3462
+ return import.meta.env.TEST ? isServerPlatform() : isServer;
3302
3463
  }
3303
3464
 
3304
3465
  function markVNodeDirty(container, vNode, bits, cursorRoot = null) {
@@ -3351,67 +3512,70 @@ const fastGetter = (prototype, name) => {
3351
3512
  };
3352
3513
 
3353
3514
  const vnode_newElement = (element, elementName, key = null) => {
3354
- assertEqual(fastNodeType(element), 1, "Expecting element node.");
3515
+ isDev && assertEqual(fastNodeType(element), 1, "Expecting element node.");
3355
3516
  const vnode = new ElementVNode(key, -503, null, null, null, null, null, null, element, elementName);
3356
3517
  return element.vNode = vnode, vnode;
3357
3518
  };
3358
3519
 
3359
3520
  const vnode_newUnMaterializedElement = element => {
3360
- assertEqual(fastNodeType(element), 1, "Expecting element node.");
3521
+ isDev && assertEqual(fastNodeType(element), 1, "Expecting element node.");
3361
3522
  const vnode = new ElementVNode(null, -511, null, null, null, null, void 0, void 0, element, void 0);
3362
3523
  return element.vNode = vnode, vnode;
3363
3524
  };
3364
3525
 
3365
3526
  const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
3366
- sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
3527
+ isDev && sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
3367
3528
  return new TextVNode(-508, null, previousTextNode, null, null, sharedTextNode, textContent);
3368
3529
  };
3369
3530
 
3370
3531
  const vnode_newText = (textNode, textContent) => {
3371
3532
  const vnode = new TextVNode(-500, null, null, null, null, textNode, textContent);
3372
- return assertEqual(fastNodeType(textNode), 3, "Expecting text node."), assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode."),
3373
- assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode."), assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode."),
3533
+ return isDev && assertEqual(fastNodeType(textNode), 3, "Expecting text node."),
3534
+ isDev && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode."),
3535
+ isDev && assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode."),
3536
+ isDev && assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode."),
3374
3537
  vnode;
3375
3538
  };
3376
3539
 
3377
3540
  const vnode_newVirtual = () => {
3378
3541
  const vnode = new VirtualVNode(null, -510, null, null, null, null, null, null);
3379
- return assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode."),
3380
- assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode."), assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode."),
3542
+ return isDev && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode."),
3543
+ isDev && assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode."),
3544
+ isDev && assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode."),
3381
3545
  vnode;
3382
3546
  };
3383
3547
 
3384
3548
  const vnode_isVNode = vNode => vNode instanceof VNode;
3385
3549
 
3386
- const vnode_isElementVNode = vNode => vNode instanceof ElementVNode;
3550
+ const vnode_isElementVNode = vNode => !(1 & ~vNode.flags);
3387
3551
 
3388
3552
  const vnode_isElementOrTextVNode = vNode => {
3389
- assertDefined(vNode, "Missing vNode");
3553
+ isDev && assertDefined(vNode, "Missing vNode");
3390
3554
  return !!(5 & vNode.flags);
3391
3555
  };
3392
3556
 
3393
3557
  const vnode_isMaterialized = vNode => {
3394
- assertDefined(vNode, "Missing vNode");
3558
+ isDev && assertDefined(vNode, "Missing vNode");
3395
3559
  return !(1 & ~vNode.flags) && void 0 !== vNode.firstChild && void 0 !== vNode.lastChild;
3396
3560
  };
3397
3561
 
3398
- const vnode_isTextVNode = vNode => vNode instanceof TextVNode;
3562
+ const vnode_isTextVNode = vNode => !(4 & ~vNode.flags);
3399
3563
 
3400
- const vnode_isVirtualVNode = vNode => vNode instanceof VirtualVNode;
3564
+ const vnode_isVirtualVNode = vNode => !(2 & ~vNode.flags);
3401
3565
 
3402
3566
  const vnode_isProjection = vNode => {
3403
- assertDefined(vNode, "Missing vNode");
3567
+ isDev && assertDefined(vNode, "Missing vNode");
3404
3568
  return !(2 & ~vNode.flags) && null !== vnode_getProp(vNode, QSlot, null);
3405
3569
  };
3406
3570
 
3407
- const ensureTextVNode = vNode => (assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)),
3571
+ const ensureTextVNode = vNode => (isDev && assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)),
3408
3572
  vNode);
3409
3573
 
3410
3574
  const ensureElementOrVirtualVNode = vNode => {
3411
- assertDefined(vNode, "Missing vNode"), assertTrue(!!(3 & vNode.flags), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
3575
+ isDev && assertDefined(vNode, "Missing vNode"), isDev && assertTrue(!!(3 & vNode.flags), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
3412
3576
  };
3413
3577
 
3414
- const ensureElementVNode = vNode => (assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)),
3578
+ const ensureElementVNode = vNode => (isDev && assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)),
3415
3579
  vNode);
3416
3580
 
3417
3581
  const vnode_getNodeTypeName = vNode => {
@@ -3443,12 +3607,12 @@ const vnode_getProp = (vNode, key, getObject) => {
3443
3607
  };
3444
3608
 
3445
3609
  const vnode_setProp = (vNode, key, value) => {
3446
- (vnode_isElementVNode(vNode) || vnode_isVirtualVNode(vNode)) && (null == value && vNode.props ? delete vNode.props[key] : (vNode.props ||= {},
3447
- vNode.props[key] = value));
3610
+ null == value && vNode.props ? delete vNode.props[key] : (vNode.props ||= {}, vNode.props[key] = value);
3448
3611
  };
3449
3612
 
3450
- const vnode_setAttr = (journal, vNode, key, value) => {
3451
- vnode_isElementVNode(vNode) && (vnode_setProp(vNode, key, value), addVNodeOperation(journal, createSetAttributeOperation(vNode.node, key, value)));
3613
+ const vnode_setAttr = (journal, vNode, key, value, scopedStyleIdPrefix = null) => {
3614
+ vnode_isElementVNode(vNode) && (import.meta.env.TEST && scopedStyleIdPrefix && vnode_setProp(vNode, "__scopedStyleIdPrefix__", scopedStyleIdPrefix),
3615
+ vnode_setProp(vNode, key, value), addVNodeOperation(journal, createSetAttributeOperation(vNode.node, key, value, scopedStyleIdPrefix, !!(128 & vNode.flags))));
3452
3616
  };
3453
3617
 
3454
3618
  const vnode_ensureElementKeyInflated = vnode => {
@@ -3589,12 +3753,12 @@ const vnode_ensureTextInflated = (journal, vnode) => {
3589
3753
  const textVNode = ensureTextVNode(vnode);
3590
3754
  if (!(8 & textVNode.flags)) {
3591
3755
  const parentNode = vnode_getDomParent(vnode, !0);
3592
- assertDefined(parentNode, "Missing parent node.");
3756
+ isDev && assertDefined(parentNode, "Missing parent node.");
3593
3757
  const sharedTextNode = textVNode.node;
3594
3758
  const doc = fastOwnerDocument(parentNode);
3595
3759
  let vCursor = vnode_getDomSibling(vnode, !1, !0);
3596
3760
  const node = vnode_getDomSibling(vnode, !0, !0);
3597
- const insertBeforeNode = sharedTextNode || (node instanceof ElementVNode ? node.node : node?.node) || null;
3761
+ const insertBeforeNode = sharedTextNode || (node && vnode_isElementVNode(node) ? node.node : node?.node) || null;
3598
3762
  let lastPreviousTextNode = insertBeforeNode;
3599
3763
  for (;vCursor && vnode_isTextVNode(vCursor); ) {
3600
3764
  if (!(8 & vCursor.flags)) {
@@ -3630,7 +3794,7 @@ const vnode_locate = (rootVNode, id) => {
3630
3794
  let elementOffset = -1;
3631
3795
  let refElement;
3632
3796
  if ("string" == typeof id) {
3633
- assertDefined(qVNodeRefs, "Missing qVNodeRefs."), elementOffset = parseInt(id),
3797
+ isDev && assertDefined(qVNodeRefs, "Missing qVNodeRefs."), elementOffset = parseInt(id),
3634
3798
  refElement = qVNodeRefs.get(elementOffset);
3635
3799
  } else {
3636
3800
  refElement = id;
@@ -3639,10 +3803,10 @@ const vnode_locate = (rootVNode, id) => {
3639
3803
  return vNode;
3640
3804
  }
3641
3805
  }
3642
- if (assertDefined(refElement, "Missing refElement."), vnode_isVNode(refElement)) {
3806
+ if (isDev && assertDefined(refElement, "Missing refElement."), vnode_isVNode(refElement)) {
3643
3807
  vNode = refElement;
3644
3808
  } else {
3645
- assertTrue(containerElement.contains(refElement), "Couldn't find the element inside the container while locating the VNode.");
3809
+ isDev && assertTrue(containerElement.contains(refElement), "Couldn't find the element inside the container while locating the VNode.");
3646
3810
  let parent = refElement;
3647
3811
  const elementPath = [ refElement ];
3648
3812
  for (;parent && parent !== containerElement && !parent.vNode; ) {
@@ -3669,8 +3833,8 @@ const vnode_locate = (rootVNode, id) => {
3669
3833
 
3670
3834
  const vnode_getChildWithIdx = (vNode, childIdx) => {
3671
3835
  let child = vnode_getFirstChild(vNode);
3672
- for (assertDefined(child, "Missing child."); child.flags >>> 9 !== childIdx; ) {
3673
- child = child.nextSibling, assertDefined(child, "Missing child.");
3836
+ for (isDev && assertDefined(child, "Missing child."); child.flags >>> 9 !== childIdx; ) {
3837
+ child = child.nextSibling, isDev && assertDefined(child, "Missing child.");
3674
3838
  }
3675
3839
  return child;
3676
3840
  };
@@ -3680,7 +3844,7 @@ const vNodeStack = [];
3680
3844
  const vnode_getVNodeForChildNode = (vNode, childElement) => {
3681
3845
  ensureElementVNode(vNode);
3682
3846
  let child = vnode_getFirstChild(vNode);
3683
- for (assertDefined(child, "Missing child."); child && (!(child instanceof ElementVNode) || child.node !== childElement); ) {
3847
+ for (isDev && assertDefined(child, "Missing child."); child && (!(child instanceof ElementVNode) || child.node !== childElement); ) {
3684
3848
  if (vnode_isVirtualVNode(child)) {
3685
3849
  const next = child.nextSibling;
3686
3850
  const firstChild = vnode_getFirstChild(child);
@@ -3689,12 +3853,12 @@ const vnode_getVNodeForChildNode = (vNode, childElement) => {
3689
3853
  const next = child.nextSibling;
3690
3854
  child = next || (next || vNodeStack.pop());
3691
3855
  }
3692
- assertDefined(child, "Missing child.");
3856
+ isDev && assertDefined(child, "Missing child.");
3693
3857
  }
3694
3858
  for (;vNodeStack.length; ) {
3695
3859
  vNodeStack.pop();
3696
3860
  }
3697
- return ensureElementVNode(child), assertEqual(child.node, childElement, "Child not found."),
3861
+ return ensureElementVNode(child), isDev && assertEqual(child.node, childElement, "Child not found."),
3698
3862
  child;
3699
3863
  };
3700
3864
 
@@ -3760,7 +3924,7 @@ const vnode_getDomParentVNode = (vnode, includeProjection) => {
3760
3924
  };
3761
3925
 
3762
3926
  const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
3763
- if (assertEqual(vParent, vToRemove.parent, "Parent mismatch."), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove),
3927
+ if (isDev && assertEqual(vParent, vToRemove.parent, "Parent mismatch."), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove),
3764
3928
  removeDOM) {
3765
3929
  const domParent = vnode_getDomParent(vParent, !1);
3766
3930
  if (null !== vnode_getProp(vParent, dangerouslySetInnerHTML, null)) {
@@ -3780,7 +3944,7 @@ const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
3780
3944
  };
3781
3945
 
3782
3946
  const vnode_truncate = (journal, vParent, vDelete, removeDOM = !0) => {
3783
- assertDefined(vDelete, "Missing vDelete.");
3947
+ isDev && assertDefined(vDelete, "Missing vDelete.");
3784
3948
  if (vnode_getDomParent(vParent, !0) && removeDOM) {
3785
3949
  if (vnode_isElementVNode(vParent)) {
3786
3950
  addVNodeOperation(journal, createRemoveAllChildrenOperation(vParent.node));
@@ -3861,8 +4025,8 @@ const ensureMaterialized = vnode => {
3861
4025
  if (void 0 === vFirstChild) {
3862
4026
  vFirstChild = vParent.parent && shouldIgnoreChildren(vParent.node) ? vParent.firstChild = vParent.lastChild = null : vnode_materialize(vParent);
3863
4027
  }
3864
- return assertTrue(void 0 !== vParent.firstChild, "Did not materialize."), assertTrue(void 0 !== vParent.lastChild, "Did not materialize."),
3865
- vFirstChild;
4028
+ return isDev && assertTrue(void 0 !== vParent.firstChild, "Did not materialize."),
4029
+ isDev && assertTrue(void 0 !== vParent.lastChild, "Did not materialize."), vFirstChild;
3866
4030
  };
3867
4031
 
3868
4032
  let _fastHasAttribute = null;
@@ -4081,8 +4245,8 @@ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1
4081
4245
  strings.push(qwikDebugToString(vnode_getText(vnode)));
4082
4246
  } else if (vnode_isVirtualVNode(vnode)) {
4083
4247
  const attrs = [ "[" + String(vnode.flags >>> 9) + "]" ];
4084
- vnode_getAttrKeys(vnode).forEach(key => {
4085
- if ("q:type" !== key) {
4248
+ vnode.dirty && attrs.push(` dirty:${vnode.dirty}`), vnode_getAttrKeys(vnode).forEach(key => {
4249
+ if ("q:type" !== key && "__scopedStyleIdPrefix__" !== key) {
4086
4250
  const value = vnode_getProp(vnode, key, null);
4087
4251
  attrs.push(" " + key + "=" + qwikDebugToString(value));
4088
4252
  }
@@ -4260,8 +4424,52 @@ const vnode_getProjectionParentComponent = vHost => {
4260
4424
  return vHost;
4261
4425
  };
4262
4426
 
4427
+ let _locale;
4428
+
4429
+ let localAsyncStore;
4430
+
4431
+ function getLocale(defaultLocale) {
4432
+ if (localAsyncStore) {
4433
+ const locale = localAsyncStore.getStore();
4434
+ if (locale) {
4435
+ return locale;
4436
+ }
4437
+ }
4438
+ if (void 0 === _locale) {
4439
+ const ctx = tryGetInvokeContext();
4440
+ if (ctx && ctx.$locale$) {
4441
+ return ctx.$locale$;
4442
+ }
4443
+ if (void 0 !== defaultLocale) {
4444
+ return defaultLocale;
4445
+ }
4446
+ throw new Error("Reading `locale` outside of context.");
4447
+ }
4448
+ return _locale;
4449
+ }
4450
+
4451
+ function withLocale(locale, fn) {
4452
+ if (localAsyncStore) {
4453
+ return localAsyncStore.run(locale, fn);
4454
+ }
4455
+ const previousLang = _locale;
4456
+ try {
4457
+ return _locale = locale, fn();
4458
+ } finally {
4459
+ _locale = previousLang;
4460
+ }
4461
+ }
4462
+
4463
+ function setLocale(locale) {
4464
+ localAsyncStore ? localAsyncStore.enterWith(locale) : _locale = locale;
4465
+ }
4466
+
4263
4467
  let _context;
4264
4468
 
4469
+ isServer && import("node:async_hooks").then(module => {
4470
+ localAsyncStore = new module.AsyncLocalStorage;
4471
+ }).catch(() => {});
4472
+
4265
4473
  const tryGetInvokeContext = () => {
4266
4474
  if (!_context) {
4267
4475
  const context = "undefined" != typeof document && document && document.__q_context__;
@@ -4286,8 +4494,8 @@ const useInvokeContext = () => {
4286
4494
  if (!ctx || "qRender" !== ctx.$event$) {
4287
4495
  throw qError(10);
4288
4496
  }
4289
- return assertDefined(ctx.$hostElement$, "invoke: $hostElement$ must be defined", ctx),
4290
- assertDefined(ctx.$effectSubscriber$, "invoke: $effectSubscriber$ must be defined", ctx),
4497
+ return isDev && assertDefined(ctx.$hostElement$, "invoke: $hostElement$ must be defined", ctx),
4498
+ isDev && assertDefined(ctx.$effectSubscriber$, "invoke: $effectSubscriber$ must be defined", ctx),
4291
4499
  ctx;
4292
4500
  };
4293
4501
 
@@ -4350,18 +4558,21 @@ function newInvokeContext(locale, hostElement, event, url) {
4350
4558
  return seal(), ctx;
4351
4559
  }
4352
4560
 
4353
- const untrack = fn => {
4354
- if (!_context) {
4355
- return fn();
4356
- }
4357
- {
4358
- const sub = _context.$effectSubscriber$;
4359
- try {
4360
- return _context.$effectSubscriber$ = void 0, fn();
4361
- } finally {
4362
- _context.$effectSubscriber$ = sub;
4561
+ const untrack = (expr, ...args) => {
4562
+ if ("function" == typeof expr) {
4563
+ if (!_context) {
4564
+ return expr(...args);
4565
+ }
4566
+ {
4567
+ const sub = _context.$effectSubscriber$;
4568
+ try {
4569
+ return _context.$effectSubscriber$ = void 0, expr(...args);
4570
+ } finally {
4571
+ _context.$effectSubscriber$ = sub;
4572
+ }
4363
4573
  }
4364
4574
  }
4575
+ return isSignal(expr) ? expr.untrackedValue : unwrapStore(expr);
4365
4576
  };
4366
4577
 
4367
4578
  const trackInvocation = /*#__PURE__*/ newRenderInvokeContext(void 0, void 0, void 0);
@@ -4412,7 +4623,7 @@ const _waitUntilRendered = elm => {
4412
4623
  return promise || Promise.resolve();
4413
4624
  };
4414
4625
 
4415
- const createContextId = name => (assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9,_,.,-", name),
4626
+ const createContextId = name => (isDev && assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9,_,.,-", name),
4416
4627
  /*#__PURE__*/ Object.freeze({
4417
4628
  id: fromCamelToKebabCase(name)
4418
4629
  }));
@@ -4463,7 +4674,7 @@ const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COM
4463
4674
 
4464
4675
  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" ];
4465
4676
 
4466
- 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" ];
4677
+ 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", "EffectSubscription" ];
4467
4678
 
4468
4679
  function qrlToString(serializationContext, value, raw) {
4469
4680
  let symbol = value.$symbol$;
@@ -4497,12 +4708,16 @@ function qrlToString(serializationContext, value, raw) {
4497
4708
  }
4498
4709
 
4499
4710
  function createQRLWithBackChannel(chunk, symbol, captureIds) {
4500
- let qrlRef = null;
4711
+ let qrlImporter = null;
4501
4712
  if (isDev && chunk === QRL_RUNTIME_CHUNK) {
4502
4713
  const backChannel = globalThis.__qrl_back_channel__;
4503
- assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK"), qrlRef = backChannel.get(symbol);
4714
+ isDev && assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
4715
+ const fn = backChannel.get(symbol);
4716
+ fn && (qrlImporter = () => Promise.resolve({
4717
+ [symbol]: fn
4718
+ }));
4504
4719
  }
4505
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
4720
+ return createQRL(chunk, symbol, null, qrlImporter, captureIds, null);
4506
4721
  }
4507
4722
 
4508
4723
  function parseQRL(qrl) {
@@ -4611,7 +4826,7 @@ const allocate = (container, typeId, value) => {
4611
4826
  return new FormData;
4612
4827
 
4613
4828
  case 31:
4614
- return new JSXNodeImpl(null);
4829
+ return new JSXNodeImpl(null, null, null, null, null);
4615
4830
 
4616
4831
  case 11:
4617
4832
  return BigInt(value);
@@ -4651,6 +4866,9 @@ const allocate = (container, typeId, value) => {
4651
4866
  case 33:
4652
4867
  return new SubscriptionData({});
4653
4868
 
4869
+ case 34:
4870
+ return new EffectSubscription(null, null, null, null);
4871
+
4654
4872
  default:
4655
4873
  throw qError(18, [ typeId ]);
4656
4874
  }
@@ -4719,25 +4937,6 @@ const inlinedQrlDEV = (symbol, symbolName, opts, lexicalScopeCapture = EMPTY_ARR
4719
4937
  const _regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
4720
4938
  globalThis.__qwik_reg_symbols.set(hash, symbol), symbol);
4721
4939
 
4722
- const _run = (...args) => {
4723
- const [runQrl] = useLexicalScope();
4724
- const context = getInvokeContext();
4725
- const hostElement = context.$hostElement$;
4726
- if (hostElement) {
4727
- return retryOnPromise(() => {
4728
- if (!(32 & hostElement.flags)) {
4729
- return catchError(runQrl(...args), err => {
4730
- const container = context.$container$ ||= getDomContainer(hostElement.node);
4731
- if (!container) {
4732
- throw err;
4733
- }
4734
- container.handleError(err, hostElement);
4735
- });
4736
- }
4737
- });
4738
- }
4739
- };
4740
-
4741
4940
  function isStringifiable(value) {
4742
4941
  return null === value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value;
4743
4942
  }
@@ -4904,6 +5103,8 @@ async function serialize(serializationContext) {
4904
5103
  output(32, [ _serializationWeakRef(owner), owner.varProps, owner.constProps, value[_PROPS_HANDLER].$effects$ ]);
4905
5104
  } else if (value instanceof SubscriptionData) {
4906
5105
  output(33, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
5106
+ } else if (value instanceof EffectSubscription) {
5107
+ output(34, [ value.consumer, value.property, value.backRef, value.data ]);
4907
5108
  } else if (isStore(value)) {
4908
5109
  if (isResource(value)) {
4909
5110
  serializationContext.$resources$.add(value);
@@ -5172,7 +5373,7 @@ function filterEffectBackRefs(effectBackRef) {
5172
5373
  let effectBackRefToSerialize;
5173
5374
  if (effectBackRef) {
5174
5375
  for (const [effectProp, effect] of effectBackRef) {
5175
- effect[2] && (effectBackRefToSerialize ||= new Map, effectBackRefToSerialize.set(effectProp, effect));
5376
+ effect.backRef && (effectBackRefToSerialize ||= new Map, effectBackRefToSerialize.set(effectProp, effect));
5176
5377
  }
5177
5378
  }
5178
5379
  return effectBackRefToSerialize;
@@ -5291,6 +5492,7 @@ class _SharedContainer {
5291
5492
  $renderPromise$=null;
5292
5493
  $resolveRenderPromise$=null;
5293
5494
  $cursorCount$=0;
5495
+ $pausedCursorCount$=0;
5294
5496
  constructor(serverData, locale) {
5295
5497
  this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
5296
5498
  this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
@@ -5423,7 +5625,7 @@ function processJSXNode(ssr, enqueue, value, options) {
5423
5625
  const children = jsx.children;
5424
5626
  null != children && enqueue(children);
5425
5627
  } else if (type === Slot) {
5426
- const componentFrame = options.parentComponentFrame || ssr.unclaimedProjectionComponentFrameQueue.shift();
5628
+ const componentFrame = options.parentComponentFrame;
5427
5629
  if (componentFrame) {
5428
5630
  const projectionAttrs = isDev ? [ "q:type", "P" ] : [];
5429
5631
  projectionAttrs.push("q:sparent", componentFrame.componentNode.id || ""), ssr.openProjection(projectionAttrs);
@@ -5497,7 +5699,7 @@ function toSsrAttrs(record, options) {
5497
5699
  const eventValue = setEvent(options.serializationCtx, key, value);
5498
5700
  return void (eventValue && ssrAttrs.push(key, eventValue));
5499
5701
  }
5500
- isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, options.styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(options.serializationCtx, key),
5702
+ isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, options.styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) ? addPreventDefaultEventToSerializationContext(options.serializationCtx, key) : "q:p" !== key && "q:ps" !== key || (value = options.serializationCtx.$addRoot$(value)),
5501
5703
  value = serializeAttribute(key, value, options.styleScopedId), ssrAttrs.push(key, value));
5502
5704
  }
5503
5705
  };
@@ -5737,8 +5939,8 @@ const inflate = (container, target, typeId, data) => {
5737
5939
  const propsProxy = target;
5738
5940
  const d = data;
5739
5941
  let owner = d[0];
5740
- owner === _UNINITIALIZED && (owner = new JSXNodeImpl(Fragment, d[1], d[2]), owner._proxy = propsProxy),
5741
- propsProxy[_OWNER] = owner, propsProxy[_PROPS_HANDLER].$effects$ = d[3];
5942
+ owner === _UNINITIALIZED && (owner = new JSXNodeImpl(Fragment, d[1], d[2], null, null),
5943
+ owner._proxy = propsProxy), propsProxy[_OWNER] = owner, propsProxy[_PROPS_HANDLER].$effects$ = d[3];
5742
5944
  break;
5743
5945
 
5744
5946
  case 33:
@@ -5748,6 +5950,15 @@ const inflate = (container, target, typeId, data) => {
5748
5950
  break;
5749
5951
  }
5750
5952
 
5953
+ case 34:
5954
+ {
5955
+ const effectSub = target;
5956
+ const d = data;
5957
+ effectSub.consumer = d[0], effectSub.property = d[1], effectSub.backRef = d[2],
5958
+ effectSub.data = d[3];
5959
+ break;
5960
+ }
5961
+
5751
5962
  default:
5752
5963
  throw qError(16, [ typeId ]);
5753
5964
  }
@@ -5785,7 +5996,8 @@ function inflateWrappedSignalValue(signal) {
5785
5996
  const effects = signal.$effects$;
5786
5997
  let hasAttrValue = !1;
5787
5998
  if (effects) {
5788
- for (const [_, key] of effects) {
5999
+ for (const effect of effects) {
6000
+ const key = effect.property;
5789
6001
  if (isString(key)) {
5790
6002
  const attrValue = vnode_getProp(hostVNode, key, null);
5791
6003
  if (null !== attrValue) {
@@ -6172,7 +6384,8 @@ class DomContainer extends _SharedContainer {
6172
6384
  $getObjectById$=id => getObjectById(id, this.$stateData$);
6173
6385
  getSyncFn(id) {
6174
6386
  const fn = this.$qFuncs$[id];
6175
- return assertTrue("function" == typeof fn, "Invalid reference: " + id), fn;
6387
+ return isDev && assertTrue("function" == typeof fn, "Invalid reference: " + id),
6388
+ fn;
6176
6389
  }
6177
6390
  $appendStyle$(content, styleId, host, scoped) {
6178
6391
  if (scoped) {
@@ -6204,6 +6417,60 @@ class DomContainer extends _SharedContainer {
6204
6417
  }
6205
6418
  }
6206
6419
 
6420
+ const useTaskQrl = (qrl, opts) => {
6421
+ const {val, set, iCtx, i} = useSequentialScope();
6422
+ if (val) {
6423
+ return;
6424
+ }
6425
+ assertQrl(qrl), set(1);
6426
+ const task = new Task(10 | (!1 === opts?.deferUpdates ? 0 : 16), i, iCtx.$hostElement$, qrl, void 0, null);
6427
+ set(task);
6428
+ const container = iCtx.$container$;
6429
+ const {$waitOn$: waitOn} = iCtx;
6430
+ const result = maybeThen(waitOn, () => runTask(task, container, iCtx.$hostElement$));
6431
+ isPromise(result) && (iCtx.$waitOn$ = result);
6432
+ };
6433
+
6434
+ const runTask = (task, container, host) => {
6435
+ task.$flags$ &= -9, cleanupDestroyable(task);
6436
+ const iCtx = newInvokeContext(container.$locale$, host, "qTask");
6437
+ iCtx.$container$ = container;
6438
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
6439
+ const track = trackFn(task, container);
6440
+ const [cleanup] = cleanupFn(task, reason => container.handleError(reason, host));
6441
+ const taskApi = {
6442
+ track,
6443
+ cleanup
6444
+ };
6445
+ return safeCall(() => taskFn(taskApi), cleanup, err => {
6446
+ if (isPromise(err)) {
6447
+ return err.then(() => runTask(task, container, host));
6448
+ }
6449
+ container.handleError(err, host);
6450
+ });
6451
+ };
6452
+
6453
+ class Task extends BackRef {
6454
+ $flags$;
6455
+ $index$;
6456
+ $el$;
6457
+ $qrl$;
6458
+ $state$;
6459
+ $destroy$;
6460
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
6461
+ super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
6462
+ this.$state$ = $state$, this.$destroy$ = $destroy$;
6463
+ }
6464
+ }
6465
+
6466
+ const isTask = value => value instanceof Task;
6467
+
6468
+ const scheduleTask = (_event, element) => {
6469
+ const [task] = useLexicalScope();
6470
+ const container = getDomContainer(element);
6471
+ task.$flags$ |= 8, markVNodeDirty(container, task.$el$, 1);
6472
+ };
6473
+
6207
6474
  const throwIfQRLNotResolved = qrl => {
6208
6475
  if (!qrl.resolved) {
6209
6476
  throw qrl.resolve();
@@ -6213,17 +6480,17 @@ const throwIfQRLNotResolved = qrl => {
6213
6480
  const isSignal = value => value instanceof SignalImpl;
6214
6481
 
6215
6482
  const ensureContainsSubscription = (array, effectSubscription) => {
6216
- !array.has(effectSubscription) && array.add(effectSubscription);
6483
+ array.add(effectSubscription);
6217
6484
  };
6218
6485
 
6219
6486
  const ensureContainsBackRef = (array, value) => {
6220
- array[2] ||= new Set, !array[2].has(value) && array[2].add(value);
6487
+ (array.backRef ||= new Set).add(value);
6221
6488
  };
6222
6489
 
6223
6490
  const addQrlToSerializationCtx = (effectSubscriber, container) => {
6224
- if (container && !isDomContainer(container)) {
6225
- const effect = effectSubscriber[0];
6226
- const property = effectSubscriber[1];
6491
+ if (container) {
6492
+ const effect = effectSubscriber.consumer;
6493
+ const property = effectSubscriber.property;
6227
6494
  let qrl = null;
6228
6495
  isTask(effect) ? qrl = effect.$qrl$ : effect instanceof ComputedSignalImpl ? qrl = effect.$computeQrl$ : ":" === property && (qrl = container.getHostProp(effect, "q:renderFn")),
6229
6496
  qrl && container.serializationCtx.$eventQrls$.add(qrl);
@@ -6231,14 +6498,13 @@ const addQrlToSerializationCtx = (effectSubscriber, container) => {
6231
6498
  };
6232
6499
 
6233
6500
  const scheduleEffects = (container, signal, effects) => {
6234
- const isBrowser = !isServerPlatform();
6501
+ const isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer;
6235
6502
  if (effects) {
6236
- let tasksToTrigger = null;
6237
6503
  const scheduleEffect = effectSubscription => {
6238
- const consumer = effectSubscription[0];
6239
- const property = effectSubscription[1];
6240
- if (assertDefined(container, "Container must be defined."), isTask(consumer)) {
6241
- consumer.$flags$ |= 8, isBrowser ? markVNodeDirty(container, consumer.$el$, 1) : (tasksToTrigger ||= []).push(consumer);
6504
+ const consumer = effectSubscription.consumer;
6505
+ const property = effectSubscription.property;
6506
+ if (isDev && assertDefined(container, "Container must be defined."), isTask(consumer)) {
6507
+ consumer.$flags$ |= 8, markVNodeDirty(container, consumer.$el$, 1);
6242
6508
  } else if (consumer instanceof SignalImpl) {
6243
6509
  consumer.invalidate();
6244
6510
  } else if (":" === property) {
@@ -6246,7 +6512,7 @@ const scheduleEffects = (container, signal, effects) => {
6246
6512
  } else if ("." === property) {
6247
6513
  isBrowser && (setNodeDiffPayload(consumer, signal), markVNodeDirty(container, consumer, 2));
6248
6514
  } else {
6249
- const effectData = effectSubscription[3];
6515
+ const effectData = effectSubscription.data;
6250
6516
  if (effectData instanceof SubscriptionData) {
6251
6517
  const data = effectData.data;
6252
6518
  const payload = {
@@ -6265,14 +6531,10 @@ const scheduleEffects = (container, signal, effects) => {
6265
6531
  }
6266
6532
  }
6267
6533
  };
6268
- for (const effect of effects) {
6534
+ const effectsSnapshot = Array.from(effects);
6535
+ for (const effect of effectsSnapshot) {
6269
6536
  scheduleEffect(effect);
6270
6537
  }
6271
- if (!isBrowser && container && tasksToTrigger) {
6272
- for (const task of tasksToTrigger) {
6273
- markVNodeDirty(container, task.$el$, 1);
6274
- }
6275
- }
6276
6538
  }
6277
6539
  };
6278
6540
 
@@ -6428,7 +6690,7 @@ class StoreHandler {
6428
6690
  }
6429
6691
  this.$container$ = ctx.$container$;
6430
6692
  } else {
6431
- assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
6693
+ isDev && assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
6432
6694
  }
6433
6695
  const effectSubscriber = ctx.$effectSubscriber$;
6434
6696
  effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
@@ -6486,7 +6748,7 @@ function addStoreEffect(target, prop, store, effectSubscription) {
6486
6748
  const effectsMap = store.$effects$ ||= new Map;
6487
6749
  let effects = effectsMap.get(prop);
6488
6750
  effects || (effects = new Set, effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription),
6489
- ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
6751
+ ensureContainsBackRef(effectSubscription, target), (import.meta.env.TEST ? !isDomContainer(store.$container$) : isServer) && addQrlToSerializationCtx(effectSubscription, store.$container$);
6490
6752
  }
6491
6753
 
6492
6754
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
@@ -6730,7 +6992,7 @@ function _deserialize(rawStateData, element) {
6730
6992
  }
6731
6993
 
6732
6994
  function getObjectById(id, stateData) {
6733
- return "string" == typeof id && (id = parseInt(id, 10)), assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`),
6995
+ return "string" == typeof id && (id = parseInt(id, 10)), isDev && assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`),
6734
6996
  stateData[id];
6735
6997
  }
6736
6998
 
@@ -6877,7 +7139,7 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
6877
7139
  return symbolRef;
6878
7140
  }
6879
7141
  if (containerEl && setContainer(containerEl), "" === chunk) {
6880
- assertDefined(_containerEl, "Sync QRL must have container element");
7142
+ isDev && assertDefined(_containerEl, "Sync QRL must have container element");
6881
7143
  const hash = _containerEl.getAttribute("q:instance");
6882
7144
  const qFuncs = getQFuncs(_containerEl.ownerDocument, hash);
6883
7145
  return qrl.resolved = symbolRef = qFuncs[Number(symbol)];
@@ -6954,7 +7216,7 @@ const _qrlSync = function(fn, serializedFn) {
6954
7216
 
6955
7217
  const componentQrl = componentQrl => {
6956
7218
  function QwikComponent(props, key, flags = 0) {
6957
- assertQrl(componentQrl), assertNumber(flags, "The Qwik Component was not invoked correctly");
7219
+ isDev && assertQrl(componentQrl), isDev && assertNumber(flags, "The Qwik Component was not invoked correctly");
6958
7220
  const finalKey = componentQrl.$hash$.slice(0, 4) + ":" + (key || "");
6959
7221
  const InnerCmp = () => {};
6960
7222
  return InnerCmp[SERIALIZABLE_STATE] = [ componentQrl ], _jsxSplit(InnerCmp, props, null, props.children, 0, finalKey);
@@ -7333,10 +7595,10 @@ const useVisibleTaskQrl = (qrl, opts) => {
7333
7595
  if (val) {
7334
7596
  return void (64 & val.$flags$ || isServerPlatform() || (val.$flags$ |= 64, useRegisterTaskEvents(val, eagerness)));
7335
7597
  }
7336
- assertQrl(qrl);
7337
- const task = new Task(9, i, iCtx.$hostElement$, qrl, void 0, null);
7338
- set(task), useRegisterTaskEvents(task, eagerness), isServerPlatform() || (qrl.resolved || qrl.resolve(),
7339
- markVNodeDirty(iCtx.$container$, iCtx.$hostElement$, 1));
7598
+ let flags;
7599
+ assertQrl(qrl), isServerPlatform() ? flags = 1 : (flags = 9, qrl.resolve(), markVNodeDirty(iCtx.$container$, iCtx.$hostElement$, 1));
7600
+ const task = new Task(flags, i, iCtx.$hostElement$, qrl, void 0, null);
7601
+ set(task), useRegisterTaskEvents(task, eagerness);
7340
7602
  };
7341
7603
 
7342
7604
  const useRegisterTaskEvents = (task, eagerness) => {