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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.17-dev+c34c237
3
+ * @qwik.dev/core 2.0.0-beta.18-dev+a8081d4
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.18-dev+a8081d4";
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 => {
@@ -513,13 +511,10 @@ function vnode_cloneElementWithNamespace(elementVNode, parentVNode, namespace, n
513
511
  return rootElement;
514
512
  }
515
513
 
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
- }
514
+ const NEW_NAMESPACE_DATA = {
515
+ elementNamespace: HTML_NS,
516
+ elementNamespaceFlag: 0
517
+ };
523
518
 
524
519
  function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
525
520
  const parentIsDefaultNamespace = !domParentVNode || !!vnode_getElementName(domParentVNode) && vnode_isDefaultNamespace(domParentVNode);
@@ -535,10 +530,16 @@ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
535
530
  elementNamespace = !!(128 & domParentVNode.flags) ? SVG_NS : !!(256 & domParentVNode.flags) ? MATH_NS : HTML_NS,
536
531
  elementNamespaceFlag = 384 & domParentVNode.flags;
537
532
  }
538
- return {
539
- elementNamespace,
540
- elementNamespaceFlag
541
- };
533
+ return NEW_NAMESPACE_DATA.elementNamespace = elementNamespace, NEW_NAMESPACE_DATA.elementNamespaceFlag = elementNamespaceFlag,
534
+ NEW_NAMESPACE_DATA;
535
+ }
536
+
537
+ function isSvg(tagOrVNode) {
538
+ return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!vnode_isElementVNode(tagOrVNode) && (isSvgElement(vnode_getElementName(tagOrVNode)) || !!(128 & tagOrVNode.flags));
539
+ }
540
+
541
+ function isMath(tagOrVNode) {
542
+ return "string" == typeof tagOrVNode ? isMathElement(tagOrVNode) : !!vnode_isElementVNode(tagOrVNode) && (isMathElement(vnode_getElementName(tagOrVNode)) || !!(256 & tagOrVNode.flags));
542
543
  }
543
544
 
544
545
  function getAttributeNamespace(attributeName) {
@@ -575,34 +576,42 @@ class BackRef {
575
576
  [_EFFECT_BACK_REF]=void 0;
576
577
  }
577
578
 
578
- class VNode extends BackRef {
579
+ class VNode {
579
580
  flags;
580
581
  parent;
581
582
  previousSibling;
582
583
  nextSibling;
583
584
  props;
585
+ [_EFFECT_BACK_REF]=void 0;
584
586
  slotParent=null;
585
587
  dirty=0;
586
588
  dirtyChildren=null;
587
589
  nextDirtyChildIndex=0;
588
590
  constructor(flags, parent, previousSibling, nextSibling, props) {
589
- super(), this.flags = flags, this.parent = parent, this.previousSibling = previousSibling,
591
+ this.flags = flags, this.parent = parent, this.previousSibling = previousSibling,
590
592
  this.nextSibling = nextSibling, this.props = props;
591
593
  }
592
594
  toString() {
593
- return isDev ? vnode_toString.call(this) : super.toString();
595
+ return isDev ? vnode_toString.call(this) : Object.prototype.toString.call(this);
594
596
  }
595
597
  }
596
598
 
597
- class ElementVNode extends VNode {
599
+ class VirtualVNode extends VNode {
598
600
  key;
599
601
  firstChild;
600
602
  lastChild;
603
+ constructor(key, flags, parent, previousSibling, nextSibling, props, firstChild, lastChild) {
604
+ super(flags, parent, previousSibling, nextSibling, props), this.key = key, this.firstChild = firstChild,
605
+ this.lastChild = lastChild;
606
+ }
607
+ }
608
+
609
+ class ElementVNode extends VirtualVNode {
601
610
  node;
602
611
  elementName;
603
612
  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;
613
+ super(key, flags, parent, previousSibling, nextSibling, props, firstChild, lastChild),
614
+ this.node = node, this.elementName = elementName;
606
615
  }
607
616
  }
608
617
 
@@ -614,16 +623,6 @@ class TextVNode extends VNode {
614
623
  }
615
624
  }
616
625
 
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
626
  const globalCursorQueue = [];
628
627
 
629
628
  const pausedCursorQueue = [];
@@ -658,7 +657,7 @@ function getHighestPriorityCursor() {
658
657
  }
659
658
 
660
659
  function pauseCursor(cursor, container) {
661
- pausedCursorQueue.push(cursor), removeCursorFromQueue(cursor, container, !0);
660
+ pausedCursorQueue.push(cursor), removeCursorFromQueue(cursor, container, !0), container.$pausedCursorCount$++;
662
661
  }
663
662
 
664
663
  function resumeCursor(cursor, container) {
@@ -666,15 +665,15 @@ function resumeCursor(cursor, container) {
666
665
  if (-1 !== index) {
667
666
  const lastIndex = pausedCursorQueue.length - 1;
668
667
  index !== lastIndex && (pausedCursorQueue[index] = pausedCursorQueue[lastIndex]),
669
- pausedCursorQueue.pop();
668
+ pausedCursorQueue.pop(), container.$pausedCursorCount$--;
670
669
  }
671
670
  addCursorToQueue(container, cursor);
672
671
  }
673
672
 
674
673
  function removeCursorFromQueue(cursor, container, keepCursorFlag) {
675
- container.$cursorCount$ > 0 && container.$cursorCount$--, keepCursorFlag || (cursor.flags &= -65);
674
+ keepCursorFlag || (cursor.flags &= -65);
676
675
  const index = globalCursorQueue.indexOf(cursor);
677
- -1 !== index && globalCursorQueue.splice(index, 1);
676
+ -1 !== index && (globalCursorQueue.splice(index, 1), container.$cursorCount$--);
678
677
  }
679
678
 
680
679
  const cursorDatas = new WeakMap;
@@ -738,7 +737,22 @@ class SignalImpl {
738
737
  this.$untrackedValue$ = value;
739
738
  }
740
739
  get value() {
741
- return setupSignalValueAccess(this, () => this.$effects$ ||= new Set, () => this.untrackedValue);
740
+ const ctx = tryGetInvokeContext();
741
+ if (!ctx) {
742
+ return this.untrackedValue;
743
+ }
744
+ if (null === this.$container$) {
745
+ if (!ctx.$container$) {
746
+ return this.untrackedValue;
747
+ }
748
+ this.$container$ = ctx.$container$;
749
+ } else {
750
+ isDev && assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
751
+ }
752
+ const effectSubscriber = ctx.$effectSubscriber$;
753
+ return effectSubscriber && (ensureContainsSubscription(this.$effects$ ||= new Set, effectSubscriber),
754
+ ensureContainsBackRef(effectSubscriber, this), (import.meta.env.TEST ? !isDomContainer(this.$container$) : isServer) && addQrlToSerializationCtx(effectSubscriber, this.$container$)),
755
+ this.untrackedValue;
742
756
  }
743
757
  set value(value) {
744
758
  value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, scheduleEffects(this.$container$, this, this.$effects$));
@@ -747,7 +761,7 @@ class SignalImpl {
747
761
  qDev;
748
762
  }
749
763
  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;
764
+ 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
765
  }
752
766
  toJSON() {
753
767
  return {
@@ -756,26 +770,23 @@ class SignalImpl {
756
770
  }
757
771
  }
758
772
 
759
- const addEffect = (signal, effectSubscriber, effects) => {
760
- ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, signal),
761
- addQrlToSerializationCtx(effectSubscriber, signal.$container$);
762
- };
763
-
764
773
  const setupSignalValueAccess = (target, effectsFn, returnValueFn) => {
765
774
  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");
775
+ if (!ctx) {
776
+ return returnValueFn();
777
+ }
778
+ if (null === target.$container$) {
779
+ if (!ctx.$container$) {
780
+ return returnValueFn();
774
781
  }
775
- const effectSubscriber = ctx.$effectSubscriber$;
776
- effectSubscriber && addEffect(target, effectSubscriber, effectsFn());
782
+ target.$container$ = ctx.$container$;
783
+ } else {
784
+ isDev && assertTrue(!ctx.$container$ || ctx.$container$ === target.$container$, "Do not use signals across containers");
777
785
  }
778
- return returnValueFn();
786
+ const effectSubscriber = ctx.$effectSubscriber$;
787
+ return effectSubscriber && (ensureContainsSubscription(effectsFn(), effectSubscriber),
788
+ ensureContainsBackRef(effectSubscriber, target), addQrlToSerializationCtx(effectSubscriber, target.$container$)),
789
+ returnValueFn();
779
790
  };
780
791
 
781
792
  const _CONST_PROPS = Symbol("CONST");
@@ -792,7 +803,7 @@ const _UNINITIALIZED = Symbol("UNINITIALIZED");
792
803
 
793
804
  const EVENT_SUFFIX = "$";
794
805
 
795
- const isHtmlAttributeAnEventName = name => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
806
+ const isHtmlAttributeAnEventName = name => 111 === name.charCodeAt(0) && 110 === name.charCodeAt(1) && (58 === name.charCodeAt(2) || (name.startsWith("on-window:") || name.startsWith("on-document:")));
796
807
 
797
808
  function jsxEventToHtmlAttribute(jsxEvent) {
798
809
  if (jsxEvent.endsWith("$")) {
@@ -934,14 +945,15 @@ class PropsProxyHandler {
934
945
 
935
946
  const addPropsProxyEffect = (propsProxy, prop) => {
936
947
  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"));
948
+ 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
949
  const effectSubscriber = ctx?.$effectSubscriber$;
939
950
  effectSubscriber && addStoreEffect(propsProxy.owner._proxy, prop, propsProxy, effectSubscriber);
940
951
  };
941
952
 
942
953
  const triggerPropsProxyEffect = (propsProxy, prop) => {
943
954
  const effects = getEffects$1(propsProxy.$effects$, prop);
944
- effects && scheduleEffects(propsProxy.$container$, propsProxy, effects);
955
+ return effects && scheduleEffects(propsProxy.$container$, propsProxy, effects),
956
+ !!effects;
945
957
  };
946
958
 
947
959
  function getEffects$1(effects, prop) {
@@ -971,26 +983,36 @@ const cleanupDestroyable = destroyable => {
971
983
  }
972
984
  };
973
985
 
986
+ const NEEDS_COMPUTATION = Symbol("invalid");
987
+
988
+ class EffectSubscription {
989
+ consumer;
990
+ property;
991
+ backRef;
992
+ data;
993
+ constructor(consumer, property, backRef = null, data = null) {
994
+ this.consumer = consumer, this.property = property, this.backRef = backRef, this.data = data;
995
+ }
996
+ }
997
+
998
+ const STORE_TARGET = Symbol("store.target");
999
+
1000
+ const STORE_HANDLER = Symbol("store.handler");
1001
+
1002
+ const STORE_ALL_PROPS = Symbol("store.all");
1003
+
974
1004
  function getSubscriber(effect, prop, data) {
975
1005
  effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
976
1006
  const subMap = effect[_EFFECT_BACK_REF];
977
1007
  let sub = subMap.get(prop);
978
- return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[3] = data),
979
- sub;
1008
+ return sub || (sub = new EffectSubscription(effect, prop), subMap.set(prop, sub)),
1009
+ data && (sub.data = data), sub;
980
1010
  }
981
1011
 
982
1012
  function isSsrNode(value) {
983
1013
  return "__brand__" in value && "SsrNode" === value.__brand__;
984
1014
  }
985
1015
 
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
1016
  const trackFn = (target, container) => (obj, prop) => {
995
1017
  const ctx = newInvokeContext();
996
1018
  return ctx.$effectSubscriber$ = getSubscriber(target, ":"), ctx.$container$ = container || void 0,
@@ -1050,7 +1072,7 @@ class ComputedSignalImpl extends SignalImpl {
1050
1072
  this.$flags$ |= 2, super.force();
1051
1073
  }
1052
1074
  get untrackedValue() {
1053
- return this.$computeIfNeeded$(), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1075
+ return this.$computeIfNeeded$(), isDev && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1054
1076
  this.$untrackedValue$;
1055
1077
  }
1056
1078
  $computeIfNeeded$() {
@@ -1061,7 +1083,10 @@ class ComputedSignalImpl extends SignalImpl {
1061
1083
  throwIfQRLNotResolved(computeQrl);
1062
1084
  const ctx = tryGetInvokeContext();
1063
1085
  const previousEffectSubscription = ctx?.$effectSubscriber$;
1064
- ctx && (ctx.$effectSubscriber$ = getSubscriber(this, "."));
1086
+ if (ctx) {
1087
+ const effectSubscriber = getSubscriber(this, ".");
1088
+ clearEffectSubscription(this.$container$, effectSubscriber), ctx.$effectSubscriber$ = effectSubscriber;
1089
+ }
1065
1090
  try {
1066
1091
  const untrackedValue = computeQrl.getFn(ctx)();
1067
1092
  if (isPromise(untrackedValue)) {
@@ -1212,16 +1237,16 @@ const _wrapProp = (...args) => {
1212
1237
  return obj[prop];
1213
1238
  }
1214
1239
  if (isSignal(obj)) {
1215
- return obj instanceof AsyncComputedSignalImpl || assertEqual(prop, "value", "Left side is a signal, prop must be value"),
1240
+ return obj instanceof AsyncComputedSignalImpl || isDev && assertEqual(prop, "value", "Left side is a signal, prop must be value"),
1216
1241
  obj instanceof WrappedSignalImpl && 4 & obj.$flags$ ? obj : getWrapped(args);
1217
1242
  }
1218
1243
  if (isPropsProxy(obj)) {
1219
1244
  const constProps = obj[_CONST_PROPS];
1220
1245
  const varProps = obj[_VAR_PROPS];
1221
- if (constProps && prop in constProps) {
1246
+ if (constProps && Object.prototype.hasOwnProperty.call(constProps, prop)) {
1222
1247
  return constProps[prop];
1223
1248
  }
1224
- if (prop in varProps) {
1249
+ if (Object.prototype.hasOwnProperty.call(varProps, prop)) {
1225
1250
  return wrapIfNotSignal(varProps[prop], args);
1226
1251
  }
1227
1252
  } else {
@@ -1266,7 +1291,7 @@ class WrappedSignalImpl extends SignalImpl {
1266
1291
  markVNodeDirty(this.$container$, this.$hostElement$, 16));
1267
1292
  }
1268
1293
  get untrackedValue() {
1269
- return this.$computeIfNeeded$(), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1294
+ return this.$computeIfNeeded$(), isDev && assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION, "Invalid state"),
1270
1295
  this.$untrackedValue$;
1271
1296
  }
1272
1297
  $computeIfNeeded$() {
@@ -1300,7 +1325,7 @@ function clearAllEffects(container, consumer) {
1300
1325
  }
1301
1326
 
1302
1327
  function clearEffectSubscription(container, effect) {
1303
- const backRefs = effect[2];
1328
+ const backRefs = effect.backRef;
1304
1329
  if (backRefs) {
1305
1330
  for (const producer of backRefs) {
1306
1331
  if (producer instanceof SignalImpl) {
@@ -1351,13 +1376,14 @@ const useLexicalScope = () => {
1351
1376
  const context = getInvokeContext();
1352
1377
  let qrl = context.$qrl$;
1353
1378
  if (qrl) {
1354
- assertQrl(qrl), assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
1379
+ isDev && assertQrl(qrl), isDev && assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
1355
1380
  } else {
1356
1381
  const el = context.$hostElement$ instanceof ElementVNode ? context.$hostElement$.node : void 0;
1357
- assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
1382
+ isDev && assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
1358
1383
  const containerElement = _getQContainerElement(el);
1359
- assertDefined(containerElement, "invoke: cant find parent q:container of", el);
1360
- qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
1384
+ isDev && assertDefined(containerElement, "invoke: cant find parent q:container of", el);
1385
+ const container = getDomContainer(containerElement);
1386
+ context.$container$ ||= container, qrl = container.parseQRL(decodeURIComponent(String(context.$url$)));
1361
1387
  }
1362
1388
  return qrl.$captureRef$;
1363
1389
  };
@@ -1372,39 +1398,20 @@ const _chk = (_, element) => {
1372
1398
  signal.value = element.checked;
1373
1399
  };
1374
1400
 
1375
- const _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1376
-
1377
- const BIND_VALUE = "bind:value";
1378
-
1379
- const BIND_CHECKED = "bind:checked";
1401
+ const _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1380
1402
 
1381
1403
  class JSXNodeImpl {
1382
1404
  type;
1405
+ children;
1383
1406
  toSort;
1384
1407
  key;
1385
1408
  varProps;
1386
1409
  constProps;
1387
- children;
1388
1410
  dev;
1389
1411
  _proxy=null;
1390
1412
  constructor(type, varProps, constProps, children, key, toSort, dev) {
1391
- if (this.type = type, this.toSort = !!toSort, this.key = null == key ? null : String(key),
1413
+ this.type = type, this.children = children, this.toSort = !!toSort, this.key = null == key ? null : "string" == typeof key ? key : "" + key,
1392
1414
  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
1415
  seal();
1409
1416
  }
1410
1417
  get props() {
@@ -1422,34 +1429,91 @@ const mergeHandlers = (obj, event, handler) => {
1422
1429
 
1423
1430
  const isJSXNode = n => n instanceof JSXNodeImpl;
1424
1431
 
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
- };
1432
+ const isEmpty = obj => 0 === Object.keys(obj).length;
1433
1433
 
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
- };
1434
+ const BIND_VALUE = "bind:value";
1441
1435
 
1442
- const _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => untrack(() => new JSXNodeImpl(type, varProps, constProps, children, key, !1, dev));
1436
+ const BIND_CHECKED = "bind:checked";
1443
1437
 
1444
- const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => untrack(() => {
1438
+ const _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1439
+
1440
+ const _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => new JSXNodeImpl(type, varProps, constProps, children, key, !1, dev);
1441
+
1442
+ const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
1443
+ let toSort = !1;
1444
+ let constPropsCopied = !1;
1445
+ let varPropsCopied = !1;
1446
+ let bindValueSignal = null;
1447
+ let bindCheckedSignal = null;
1448
+ if ("string" == typeof type) {
1449
+ if (constProps) {
1450
+ const processedKeys = new Set;
1451
+ for (const k in constProps) {
1452
+ const attr = jsxEventToHtmlAttribute(k);
1453
+ attr && (constPropsCopied || (constProps = {
1454
+ ...constProps
1455
+ }, constPropsCopied = !0), _hasOwnProperty$1.call(constProps, attr) && !processedKeys.has(attr) || (constProps[attr] = constProps[k]),
1456
+ delete constProps[k]), processedKeys.add(k);
1457
+ }
1458
+ }
1459
+ if (varProps) {
1460
+ const processedKeys = new Set;
1461
+ for (const k in varProps) {
1462
+ const attr = jsxEventToHtmlAttribute(k);
1463
+ attr ? (varPropsCopied || (varProps = {
1464
+ ...varProps
1465
+ }, varPropsCopied = !0), _hasOwnProperty$1.call(varProps, attr) && !processedKeys.has(attr) || (varProps[attr] = varProps[k]),
1466
+ delete varProps[k], toSort = !0) : k === BIND_CHECKED ? bindCheckedSignal = varProps[k] : k === BIND_VALUE && (bindValueSignal = varProps[k]),
1467
+ processedKeys.add(k);
1468
+ }
1469
+ if (bindCheckedSignal || bindValueSignal) {
1470
+ if (varPropsCopied || (varProps = {
1471
+ ...varProps
1472
+ }, varPropsCopied = !0), bindCheckedSignal) {
1473
+ delete varProps[BIND_CHECKED], varProps.checked = bindCheckedSignal;
1474
+ const handler = createQRL(null, "_chk", _chk, null, null, [ bindCheckedSignal ]);
1475
+ if (constProps && _hasOwnProperty$1.call(constProps, "on:input")) {
1476
+ constPropsCopied || (constProps = {
1477
+ ...constProps
1478
+ }, constPropsCopied = !0);
1479
+ const existingHandler = constProps["on:input"];
1480
+ delete constProps["on:input"], toSort = mergeHandlers(varProps, "on:input", existingHandler) || toSort;
1481
+ }
1482
+ toSort = mergeHandlers(varProps, "on:input", handler) || toSort;
1483
+ } else if (bindValueSignal) {
1484
+ delete varProps[BIND_VALUE], varProps.value = bindValueSignal;
1485
+ const handler = createQRL(null, "_val", _val, null, null, [ bindValueSignal ]);
1486
+ if (constProps && _hasOwnProperty$1.call(constProps, "on:input")) {
1487
+ constPropsCopied || (constProps = {
1488
+ ...constProps
1489
+ }, constPropsCopied = !0);
1490
+ const existingHandler = constProps["on:input"];
1491
+ delete constProps["on:input"], toSort = mergeHandlers(varProps, "on:input", existingHandler) || toSort;
1492
+ }
1493
+ toSort = mergeHandlers(varProps, "on:input", handler) || toSort;
1494
+ }
1495
+ }
1496
+ }
1497
+ varProps && _hasOwnProperty$1.call(varProps, "className") && (varPropsCopied || (varProps = {
1498
+ ...varProps
1499
+ }, varPropsCopied = !0), varProps.class = varProps.className, varProps.className = void 0,
1500
+ toSort = !0), constProps && _hasOwnProperty$1.call(constProps, "className") && (constPropsCopied || (constProps = {
1501
+ ...constProps
1502
+ }, constPropsCopied = !0), constProps.class = constProps.className, constProps.className = void 0);
1503
+ }
1445
1504
  if (varProps) {
1446
1505
  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];
1506
+ "children" === k ? (varPropsCopied || (varProps = {
1507
+ ...varProps
1508
+ }, varPropsCopied = !0), children ||= varProps.children, delete varProps.children) : "key" === k ? (varPropsCopied || (varProps = {
1509
+ ...varProps
1510
+ }, varPropsCopied = !0), key ||= varProps.key, delete varProps.key) : (constProps && k in constProps || null === varProps[k]) && (varPropsCopied || (varProps = {
1511
+ ...varProps
1512
+ }, varPropsCopied = !0), delete varProps[k]);
1449
1513
  }
1450
1514
  }
1451
- return new JSXNodeImpl(type, varProps, constProps, children, key, !0, dev);
1452
- });
1515
+ return new JSXNodeImpl(type, varProps, constProps, children, key, toSort || !0, dev);
1516
+ };
1453
1517
 
1454
1518
  const _jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key);
1455
1519
 
@@ -1493,8 +1557,8 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1493
1557
  subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, ":"),
1494
1558
  iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
1495
1559
  let isInlineComponent = !1;
1496
- if (null === componentQRL && assertDefined(componentQRL = container.getHostProp(renderHost, "q:renderFn"), "No Component found at this location"),
1497
- isQrl(componentQRL)) {
1560
+ if (null === componentQRL && (componentQRL = container.getHostProp(renderHost, "q:renderFn"),
1561
+ isDev && assertDefined(componentQRL, "No Component found at this location")), isQrl(componentQRL)) {
1498
1562
  "children" in (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ) && delete props.children,
1499
1563
  componentFn = componentQRL.getFn(iCtx);
1500
1564
  } else if (isQwikComponent(componentQRL)) {
@@ -1505,9 +1569,15 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1505
1569
  const inlineComponent = componentQRL;
1506
1570
  componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
1507
1571
  }
1572
+ const isSsr = import.meta.env.TEST ? isServerPlatform() : isServer;
1508
1573
  const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1509
1574
  container.setHostProp(renderHost, ":onIdx", null)), retryCount > 0 && vnode_isVNode(renderHost) && clearAllEffects(container, renderHost),
1510
1575
  maybeThen(componentFn(props), jsx => maybeThen(iCtx.$waitOn$, () => jsx))), jsx => {
1576
+ if (isSsr && !isInlineComponent) {
1577
+ if (4 & renderHost.dirty && (renderHost.dirty &= -5, retryCount < 100)) {
1578
+ return executeComponentWithPromiseExceptionRetry(retryCount + 1);
1579
+ }
1580
+ }
1511
1581
  const useOnEvents = container.getHostProp(renderHost, ":on");
1512
1582
  return useOnEvents ? addUseOnEvents(jsx, useOnEvents) : jsx;
1513
1583
  }, err => {
@@ -1589,7 +1659,7 @@ function injectPlaceholderElement(jsx) {
1589
1659
  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
1660
  [ placeholder, jsx ]) : [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
1591
1661
  }
1592
- if (isPrimitive(jsx)) {
1662
+ if (isPrimitiveOrNullUndefined(jsx)) {
1593
1663
  const placeholder = createPlaceholderScriptNode();
1594
1664
  return [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
1595
1665
  }
@@ -1603,7 +1673,7 @@ function injectPlaceholderElement(jsx) {
1603
1673
  function createPlaceholderScriptNode() {
1604
1674
  return new JSXNodeImpl("script", null, {
1605
1675
  hidden: ""
1606
- });
1676
+ }, null, null);
1607
1677
  }
1608
1678
 
1609
1679
  const Slot = props => _jsxSorted(Virtual, null, {
@@ -1687,15 +1757,11 @@ const _restProps = (props, omit = [], target = {}) => {
1687
1757
  for (const key in varProps) {
1688
1758
  omit.includes(key) || (varPropsTarget[key] = varProps[key]);
1689
1759
  }
1690
- return createPropsProxy(new JSXNodeImpl(null, varPropsTarget, constPropsTarget));
1760
+ return createPropsProxy(new JSXNodeImpl(null, varPropsTarget, constPropsTarget, null, null));
1691
1761
  };
1692
1762
 
1693
1763
  const styleContent = styleId => "⚡️" + styleId;
1694
1764
 
1695
- function hasClassAttr(props) {
1696
- return "class" in props;
1697
- }
1698
-
1699
1765
  function isClassAttr(key) {
1700
1766
  return "class" === key;
1701
1767
  }
@@ -1798,79 +1864,8 @@ function isAriaAttribute(prop) {
1798
1864
 
1799
1865
  const styleKey = (qStyles, index) => (assertQrl(qStyles), `${hashCode(qStyles.$hash$)}-${index}`);
1800
1866
 
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
1867
  const mapApp_findIndx = (array, key, start) => {
1873
- assertTrue(start % 2 == 0, "Expecting even number.");
1868
+ isDev && assertTrue(start % 2 == 0, "Expecting even number.");
1874
1869
  let bottom = start >> 1;
1875
1870
  let top = array.length - 2 >> 1;
1876
1871
  for (;bottom <= top; ) {
@@ -1896,15 +1891,123 @@ const mapArray_get = (array, key, start) => {
1896
1891
 
1897
1892
  const mapArray_has = (array, key, start) => mapApp_findIndx(array, key, start) >= 0;
1898
1893
 
1894
+ class DeleteOperation {
1895
+ target;
1896
+ constructor(target) {
1897
+ this.target = target;
1898
+ }
1899
+ }
1900
+
1901
+ class RemoveAllChildrenOperation {
1902
+ target;
1903
+ constructor(target) {
1904
+ this.target = target;
1905
+ }
1906
+ }
1907
+
1908
+ class SetTextOperation {
1909
+ target;
1910
+ text;
1911
+ operationType=16;
1912
+ constructor(target, text) {
1913
+ this.target = target, this.text = text;
1914
+ }
1915
+ }
1916
+
1917
+ class InsertOrMoveOperation {
1918
+ target;
1919
+ parent;
1920
+ beforeTarget;
1921
+ constructor(target, parent, beforeTarget) {
1922
+ this.target = target, this.parent = parent, this.beforeTarget = beforeTarget;
1923
+ }
1924
+ }
1925
+
1926
+ class SetAttributeOperation {
1927
+ target;
1928
+ attrName;
1929
+ attrValue;
1930
+ scopedStyleIdPrefix;
1931
+ isSvg;
1932
+ constructor(target, attrName, attrValue, scopedStyleIdPrefix, isSvg) {
1933
+ this.target = target, this.attrName = attrName, this.attrValue = attrValue, this.scopedStyleIdPrefix = scopedStyleIdPrefix,
1934
+ this.isSvg = isSvg;
1935
+ }
1936
+ }
1937
+
1938
+ const createDeleteOperation = target => new DeleteOperation(target);
1939
+
1940
+ const createRemoveAllChildrenOperation = target => new RemoveAllChildrenOperation(target);
1941
+
1942
+ const createSetTextOperation = (target, text) => new SetTextOperation(target, text);
1943
+
1944
+ const createInsertOrMoveOperation = (target, parent, beforeTarget) => new InsertOrMoveOperation(target, parent, beforeTarget);
1945
+
1946
+ const createSetAttributeOperation = (target, attrName, attrValue, scopedStyleIdPrefix = null, isSvg = !1) => new SetAttributeOperation(target, attrName, attrValue, scopedStyleIdPrefix, isSvg);
1947
+
1948
+ function callQrl(container, host, qrl, event, element, useGetObjectById) {
1949
+ const getObjectById = useGetObjectById && container?.$getObjectById$ || null;
1950
+ const singleItem = vnode_getProp(host, "q:p", getObjectById);
1951
+ if (null !== singleItem) {
1952
+ return qrl(event, element, singleItem);
1953
+ }
1954
+ const multiItems = vnode_getProp(host, "q:ps", getObjectById);
1955
+ return null !== multiItems ? qrl(event, element, ...multiItems) : qrl(event, element);
1956
+ }
1957
+
1958
+ const _run = (...args) => {
1959
+ const [qrl] = useLexicalScope();
1960
+ const context = getInvokeContext();
1961
+ const hostElement = context.$hostElement$;
1962
+ if (hostElement) {
1963
+ return context.$container$ ||= getDomContainer(hostElement.node), vnode_ensureElementInflated(hostElement),
1964
+ retryOnPromise(() => {
1965
+ if (!(32 & hostElement.flags)) {
1966
+ return callQrl(context.$container$, hostElement, qrl, args[0], args[1], !0).catch(err => {
1967
+ const container = context.$container$;
1968
+ if (!container) {
1969
+ throw err;
1970
+ }
1971
+ container.handleError(err, hostElement);
1972
+ });
1973
+ }
1974
+ });
1975
+ }
1976
+ };
1977
+
1978
+ let _setAttribute = null;
1979
+
1980
+ const fastSetAttribute = (target, name, value) => {
1981
+ _setAttribute || (_setAttribute = target.setAttribute), _setAttribute.call(target, name, value);
1982
+ };
1983
+
1984
+ let _setAttributeNS = null;
1985
+
1986
+ const fastSetAttributeNS = (target, namespace, name, value) => {
1987
+ _setAttributeNS || (_setAttributeNS = target.setAttributeNS), _setAttributeNS.call(target, namespace, name, value);
1988
+ };
1989
+
1990
+ function directSetAttribute(element, attrName, attrValue, isSvg) {
1991
+ if (null != attrValue) {
1992
+ if (isSvg) {
1993
+ const namespace = getAttributeNamespace(attrName);
1994
+ if (namespace) {
1995
+ return void fastSetAttributeNS(element, namespace, attrName, attrValue);
1996
+ }
1997
+ }
1998
+ fastSetAttribute(element, attrName, attrValue);
1999
+ }
2000
+ }
2001
+
1899
2002
  function peekNextSibling(vCurrent) {
1900
2003
  return vCurrent ? vCurrent.nextSibling : null;
1901
2004
  }
1902
2005
 
1903
2006
  const _hasOwnProperty = Object.prototype.hasOwnProperty;
1904
2007
 
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);
2008
+ function setAttribute(journal, vnode, key, value, scopedStyleIdPrefix, originalValue) {
2009
+ import.meta.env.TEST && scopedStyleIdPrefix && vnode_setProp(vnode, "__scopedStyleIdPrefix__", scopedStyleIdPrefix),
2010
+ vnode_setProp(vnode, key, originalValue), addVNodeOperation(journal, createSetAttributeOperation(vnode.node, key, value, scopedStyleIdPrefix, !!(128 & vnode.flags)));
1908
2011
  }
1909
2012
 
1910
2013
  const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyleIdPrefix) => {
@@ -1927,6 +2030,7 @@ const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyle
1927
2030
  jsxIdx: 0,
1928
2031
  jsxCount: 0,
1929
2032
  shouldAdvance: !0,
2033
+ isCreationMode: !1,
1930
2034
  subscriptionData: {
1931
2035
  const: new SubscriptionData({
1932
2036
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
@@ -1949,30 +2053,19 @@ const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyle
1949
2053
  };
1950
2054
 
1951
2055
  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"),
2056
+ if (isDev && assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"),
2057
+ isDev && assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
1953
2058
  diffContext.vParent = vStartNode, diffContext.vNewNode = null, diffContext.vCurrent = vnode_getFirstChild(vStartNode),
1954
2059
  stackPush(diffContext, jsxNode, !0), !(32 & diffContext.vParent.flags)) {
1955
2060
  for (;diffContext.stack.length; ) {
1956
2061
  for (;diffContext.jsxIdx < diffContext.jsxCount; ) {
1957
- if (assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
2062
+ if (isDev && assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
1958
2063
  "string" == typeof diffContext.jsxValue) {
1959
2064
  expectText(diffContext, diffContext.jsxValue);
1960
2065
  } else if ("number" == typeof diffContext.jsxValue) {
1961
2066
  expectText(diffContext, String(diffContext.jsxValue));
1962
2067
  } 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)) {
2068
+ if (isJSXNode(diffContext.jsxValue)) {
1976
2069
  const type = diffContext.jsxValue.type;
1977
2070
  if ("string" == typeof type) {
1978
2071
  expectNoMoreTextNodes(diffContext), expectElement(diffContext, diffContext.jsxValue, type);
@@ -1984,6 +2077,20 @@ function diff(diffContext, jsxNode, vStartNode) {
1984
2077
  descend(diffContext, diffContext.jsxValue.children, !0, !1)) : type === SSRComment || type === SSRRaw ? expectNoMore(diffContext) : (expectNoMoreTextNodes(diffContext),
1985
2078
  expectComponent(diffContext, type)));
1986
2079
  }
2080
+ } else if (Array.isArray(diffContext.jsxValue)) {
2081
+ descend(diffContext, diffContext.jsxValue, !1);
2082
+ } else if (isSignal(diffContext.jsxValue)) {
2083
+ expectVirtual(diffContext, "S", null);
2084
+ const unwrappedSignal = diffContext.jsxValue instanceof WrappedSignalImpl ? diffContext.jsxValue.$unwrapIfSignal$() : diffContext.jsxValue;
2085
+ const signals = diffContext.vCurrent?.[_EFFECT_BACK_REF]?.get(".")?.backRef;
2086
+ let hasUnwrappedSignal = signals?.has(unwrappedSignal);
2087
+ if (signals && unwrappedSignal instanceof WrappedSignalImpl && (hasUnwrappedSignal = containsWrappedSignal(signals, unwrappedSignal)),
2088
+ !hasUnwrappedSignal) {
2089
+ const vHost = diffContext.vNewNode || diffContext.vCurrent;
2090
+ descend(diffContext, resolveSignalAndDescend(diffContext, () => trackSignalAndAssignHost(unwrappedSignal, vHost, ".", diffContext.container)), !0);
2091
+ }
2092
+ } else {
2093
+ isPromise(diffContext.jsxValue) && (expectVirtual(diffContext, "A", null), diffContext.asyncQueue.push(diffContext.jsxValue, diffContext.vNewNode || diffContext.vCurrent));
1987
2094
  }
1988
2095
  } else {
1989
2096
  diffContext.jsxValue === SkipRender || expectText(diffContext, "");
@@ -2022,15 +2129,23 @@ function advance(diffContext) {
2022
2129
  }
2023
2130
 
2024
2131
  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);
2132
+ if (shouldExpectNoChildren && (null == children || descendVNode && isArray(children) && 0 === children.length)) {
2133
+ expectNoChildren(diffContext);
2134
+ } else {
2135
+ if (stackPush(diffContext, children, descendVNode), descendVNode) {
2136
+ isDev && assertDefined(diffContext.vCurrent || diffContext.vNewNode, "Expecting vCurrent to be defined.");
2137
+ const creationMode = diffContext.isCreationMode || !!diffContext.vNewNode || !vnode_getFirstChild(diffContext.vCurrent);
2138
+ diffContext.isCreationMode = creationMode, diffContext.vSideBuffer = null, diffContext.vSiblings = null,
2139
+ diffContext.vSiblingsArray = null, diffContext.vParent = diffContext.vNewNode || diffContext.vCurrent,
2140
+ diffContext.vCurrent = vnode_getFirstChild(diffContext.vParent), diffContext.vNewNode = null;
2141
+ }
2142
+ diffContext.shouldAdvance = !1;
2143
+ }
2030
2144
  }
2031
2145
 
2032
2146
  function ascend(diffContext) {
2033
- diffContext.stack.pop() && (diffContext.vSideBuffer = diffContext.stack.pop(), diffContext.vSiblings = diffContext.stack.pop(),
2147
+ diffContext.stack.pop() && (diffContext.isCreationMode = diffContext.stack.pop(),
2148
+ diffContext.vSideBuffer = diffContext.stack.pop(), diffContext.vSiblings = diffContext.stack.pop(),
2034
2149
  diffContext.vSiblingsArray = diffContext.stack.pop(), diffContext.vNewNode = diffContext.stack.pop(),
2035
2150
  diffContext.vCurrent = diffContext.stack.pop(), diffContext.vParent = diffContext.stack.pop()),
2036
2151
  diffContext.jsxValue = diffContext.stack.pop(), diffContext.jsxCount = diffContext.stack.pop(),
@@ -2040,7 +2155,7 @@ function ascend(diffContext) {
2040
2155
 
2041
2156
  function stackPush(diffContext, children, descendVNode) {
2042
2157
  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),
2158
+ descendVNode && diffContext.stack.push(diffContext.vParent, diffContext.vCurrent, diffContext.vNewNode, diffContext.vSiblingsArray, diffContext.vSiblings, diffContext.vSideBuffer, diffContext.isCreationMode),
2044
2159
  diffContext.stack.push(descendVNode), Array.isArray(children) ? (diffContext.jsxIdx = 0,
2045
2160
  diffContext.jsxCount = children.length, diffContext.jsxChildren = children, diffContext.jsxValue = diffContext.jsxCount > 0 ? children[0] : null) : void 0 === children ? (diffContext.jsxIdx = 0,
2046
2161
  diffContext.jsxValue = null, diffContext.jsxChildren = null, diffContext.jsxCount = 0) : (diffContext.jsxIdx = 0,
@@ -2095,13 +2210,20 @@ function expectSlot(diffContext) {
2095
2210
  const vHost = vnode_getProjectionParentComponent(diffContext.vParent);
2096
2211
  const slotNameKey = getSlotNameKey(diffContext, vHost);
2097
2212
  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);
2213
+ if (null == vProjectedNode) {
2214
+ return vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2215
+ vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode),
2216
+ isDev && vnode_setProp(diffContext.vNewNode, "q:type", "P"), isDev && vnode_setProp(diffContext.vNewNode, "q:code", "expectSlot" + count++),
2217
+ !1;
2218
+ }
2219
+ if (vProjectedNode === diffContext.vCurrent) {} else {
2220
+ const oldParent = vProjectedNode.parent;
2221
+ vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vProjectedNode, diffContext.vCurrent && getInsertBefore(diffContext)),
2222
+ vnode_setProp(diffContext.vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, diffContext.vNewNode),
2223
+ isDev && vnode_setProp(diffContext.vNewNode, "q:type", "P"), isDev && vnode_setProp(diffContext.vNewNode, "q:code", "expectSlot" + count++),
2224
+ oldParent && vnode_isElementVNode(oldParent) && !oldParent.firstChild && vnode_getElementName(oldParent) === QTemplate && vnode_remove(diffContext.journal, oldParent.parent, oldParent, !0);
2225
+ }
2226
+ return !0;
2105
2227
  }
2106
2228
 
2107
2229
  function getSlotNameKey(diffContext, vHost) {
@@ -2160,7 +2282,7 @@ function expectNoChildren(diffContext, removeDOM = !0) {
2160
2282
  }
2161
2283
 
2162
2284
  function expectNoMore(diffContext) {
2163
- if (assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
2285
+ if (isDev && assertFalse(diffContext.vParent === diffContext.vCurrent, "Parent and current can't be the same"),
2164
2286
  null !== diffContext.vCurrent) {
2165
2287
  for (;diffContext.vCurrent; ) {
2166
2288
  const toRemove = diffContext.vCurrent;
@@ -2180,17 +2302,6 @@ function expectNoMoreTextNodes(diffContext) {
2180
2302
 
2181
2303
  function createNewElement(diffContext, jsx, elementName, currentFile) {
2182
2304
  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
2305
  const {constProps} = jsx;
2195
2306
  let needsQDispatchEventPatch = !1;
2196
2307
  if (constProps) {
@@ -2229,13 +2340,13 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
2229
2340
  }
2230
2341
  if (isPromise(value)) {
2231
2342
  const vHost = diffContext.vNewNode;
2232
- const attributePromise = value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
2343
+ const attributePromise = value.then(resolvedValue => directSetAttribute(element, key, serializeAttribute(key, resolvedValue, diffContext.scopedStyleIdPrefix), !!(128 & vHost.flags)));
2233
2344
  diffContext.asyncAttributePromises.push(attributePromise);
2234
2345
  continue;
2235
2346
  }
2236
2347
  if (key !== dangerouslySetInnerHTML) {
2237
2348
  if ("textarea" !== elementName || "value" !== key) {
2238
- setAttribute(key, value, diffContext.vNewNode);
2349
+ directSetAttribute(element, key, serializeAttribute(key, value, diffContext.scopedStyleIdPrefix), !!(128 & diffContext.vNewNode.flags));
2239
2350
  } else {
2240
2351
  if (value && "string" != typeof value) {
2241
2352
  if (isDev) {
@@ -2252,35 +2363,39 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
2252
2363
  }
2253
2364
  const key = jsx.key;
2254
2365
  if (key && (diffContext.vNewNode.key = key), diffContext.scopedStyleIdPrefix) {
2255
- hasClassAttr(jsx.varProps) || jsx.constProps && hasClassAttr(jsx.constProps) || element.setAttribute("class", diffContext.scopedStyleIdPrefix);
2366
+ _hasOwnProperty.call(jsx.varProps, "class") || jsx.constProps && _hasOwnProperty.call(jsx.constProps, "class") || element.setAttribute("class", diffContext.scopedStyleIdPrefix);
2256
2367
  }
2257
2368
  return vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode, diffContext.vCurrent),
2258
2369
  needsQDispatchEventPatch;
2259
2370
  }
2260
2371
 
2261
2372
  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,
2373
+ const namespaceData = getNewElementNamespaceData(vnode_getDomParentVNode(diffContext.vParent, !0), elementName);
2374
+ const currentDocument = import.meta.env.TEST ? diffContext.container.document : document;
2375
+ const element = 0 === namespaceData.elementNamespaceFlag ? currentDocument.createElement(elementName) : currentDocument.createElementNS(namespaceData.elementNamespace, elementName);
2376
+ return diffContext.vNewNode = vnode_newElement(element, elementName), diffContext.vNewNode.flags |= namespaceData.elementNamespaceFlag,
2266
2377
  element;
2267
2378
  }
2268
2379
 
2269
2380
  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
2381
  let needsQDispatchEventPatch = !1;
2273
- const currentKey = getKey(diffContext.vCurrent);
2274
- if (isSameElementName && jsxKey === currentKey) {
2275
- deleteFromSideBuffer(diffContext, elementName, jsxKey);
2382
+ if (diffContext.isCreationMode) {
2383
+ needsQDispatchEventPatch = createNewElement(diffContext, jsx, elementName, null);
2276
2384
  } else {
2277
- const sideBufferKey = getSideBufferKey(elementName, jsxKey);
2278
- moveOrCreateKeyedNode(diffContext, elementName, jsxKey, sideBufferKey, diffContext.vParent) && (needsQDispatchEventPatch = createNewElement(diffContext, jsx, elementName, null));
2385
+ const isElementVNode = diffContext.vCurrent && vnode_isElementVNode(diffContext.vCurrent);
2386
+ const isSameElementName = isElementVNode && elementName === vnode_getElementName(diffContext.vCurrent);
2387
+ const jsxKey = jsx.key;
2388
+ if (isSameElementName && jsxKey === (isElementVNode && diffContext.vCurrent.key)) {
2389
+ deleteFromSideBuffer(diffContext, elementName, jsxKey);
2390
+ } else {
2391
+ const sideBufferKey = getSideBufferKey(elementName, jsxKey);
2392
+ moveOrCreateKeyedNode(diffContext, elementName, jsxKey, sideBufferKey, diffContext.vParent) && (needsQDispatchEventPatch = createNewElement(diffContext, jsx, elementName, null));
2393
+ }
2279
2394
  }
2280
2395
  const jsxProps = jsx.varProps;
2281
2396
  const vNode = diffContext.vNewNode || diffContext.vCurrent;
2282
2397
  const element = vNode.node;
2283
- jsxProps && (needsQDispatchEventPatch = diffProps(diffContext, vNode, jsxProps, vNode.props ||= {}, isDev && getFileLocationFromJsx(jsx.dev) || null) || needsQDispatchEventPatch),
2398
+ jsxProps && (needsQDispatchEventPatch = diffProps(diffContext, vNode, jsxProps, isDev && getFileLocationFromJsx(jsx.dev) || null) || needsQDispatchEventPatch),
2284
2399
  needsQDispatchEventPatch && (element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
2285
2400
  if (32 & vNode.flags) {
2286
2401
  return;
@@ -2289,71 +2404,100 @@ function expectElement(diffContext, jsx, elementName) {
2289
2404
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
2290
2405
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
2291
2406
  for (const qrl of qrls.flat(2)) {
2292
- qrl && catchError(qrl(event, element), e => {
2407
+ qrl && callQrl(diffContext.container, vNode, qrl, event, vNode.node, !1).catch(e => {
2293
2408
  diffContext.container.handleError(e, vNode);
2294
2409
  });
2295
2410
  }
2296
2411
  }));
2297
2412
  }
2298
2413
 
2299
- function diffProps(diffContext, vnode, newAttrs, oldAttrs, currentFile) {
2300
- vnode_ensureElementInflated(vnode);
2414
+ function diffProps(diffContext, vnode, newAttrs, currentFile) {
2415
+ diffContext.isCreationMode || vnode_ensureElementInflated(vnode);
2416
+ const oldAttrs = vnode.props;
2301
2417
  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);
2418
+ for (const key in newAttrs) {
2419
+ const newValue = newAttrs[key];
2420
+ const isEvent = isHtmlAttributeAnEventName(key);
2421
+ if (oldAttrs && _hasOwnProperty.call(oldAttrs, key)) {
2422
+ const oldValue = oldAttrs[key];
2423
+ if (newValue !== oldValue) {
2424
+ if (newValue instanceof WrappedSignalImpl && oldValue instanceof WrappedSignalImpl && areWrappedSignalsEqual(newValue, oldValue)) {
2425
+ continue;
2426
+ }
2427
+ if (isEvent) {
2428
+ const result = recordJsxEvent(diffContext, vnode, key, newValue, currentFile);
2429
+ patchEventDispatch ||= result;
2430
+ } else {
2431
+ patchProperty(diffContext, vnode, key, newValue, currentFile);
2432
+ }
2310
2433
  }
2311
- if ("function" == typeof value) {
2312
- return void value(element);
2434
+ } else if (null != newValue) {
2435
+ if (isEvent) {
2436
+ const result = recordJsxEvent(diffContext, vnode, key, newValue, currentFile);
2437
+ patchEventDispatch ||= result;
2438
+ } else {
2439
+ patchProperty(diffContext, vnode, key, newValue, currentFile);
2313
2440
  }
2314
- throw qError(15, [ currentFile ]);
2315
2441
  }
2316
- const currentEffect = vnode[_EFFECT_BACK_REF]?.get(key);
2442
+ }
2443
+ if (oldAttrs) {
2444
+ for (const key in oldAttrs) {
2445
+ _hasOwnProperty.call(newAttrs, key) || key.startsWith(HANDLER_PREFIX) || isHtmlAttributeAnEventName(key) || patchProperty(diffContext, vnode, key, null, currentFile);
2446
+ }
2447
+ }
2448
+ return patchEventDispatch;
2449
+ }
2450
+
2451
+ const patchProperty = (diffContext, vnode, key, value, currentFile) => {
2452
+ if ("q:p" === key || "q:ps" === key || key.charAt(0) === HANDLER_PREFIX) {
2453
+ return void vnode_setProp(vnode, key, value);
2454
+ }
2455
+ const originalValue = value;
2456
+ if ("ref" === key) {
2457
+ const element = vnode.node;
2317
2458
  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);
2459
+ return void (value.value = element);
2327
2460
  }
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);
2461
+ if ("function" == typeof value) {
2462
+ return void value(element);
2334
2463
  }
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;
2464
+ throw qError(15, [ currentFile ]);
2465
+ }
2466
+ const currentEffect = vnode[_EFFECT_BACK_REF]?.get(key);
2467
+ if (isSignal(value)) {
2468
+ const unwrappedSignal = value instanceof WrappedSignalImpl ? value.$unwrapIfSignal$() : value;
2469
+ if (currentEffect?.backRef?.has(unwrappedSignal)) {
2470
+ return;
2345
2471
  }
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));
2472
+ currentEffect && clearEffectSubscription(diffContext.container, currentEffect);
2473
+ const vHost = vnode;
2474
+ value = retryOnPromise(() => trackSignalAndAssignHost(unwrappedSignal, vHost, key, diffContext.container, diffContext.subscriptionData.var));
2475
+ } else {
2476
+ currentEffect && clearEffectSubscription(diffContext.container, currentEffect);
2351
2477
  }
2352
- for (const key of Object.keys(oldAttrs)) {
2353
- _hasOwnProperty.call(newAttrs, key) || key.startsWith(HANDLER_PREFIX) || isHtmlAttributeAnEventName(key) || record(key, null);
2478
+ if (isPromise(value)) {
2479
+ const vHost = vnode;
2480
+ const attributePromise = value.then(resolvedValue => {
2481
+ setAttribute(diffContext.journal, vHost, key, resolvedValue, diffContext.scopedStyleIdPrefix, originalValue);
2482
+ });
2483
+ return void diffContext.asyncAttributePromises.push(attributePromise);
2354
2484
  }
2355
- return patchEventDispatch;
2356
- }
2485
+ setAttribute(diffContext.journal, vnode, key, value, diffContext.scopedStyleIdPrefix, originalValue);
2486
+ };
2487
+
2488
+ const recordJsxEvent = (diffContext, vnode, key, value, currentFile) => {
2489
+ const data = getEventDataFromHtmlAttribute(key);
2490
+ if (data) {
2491
+ const props = vnode.props;
2492
+ const [scope, eventName] = data;
2493
+ const scopedEvent = getScopedEventName(scope, eventName);
2494
+ const loaderScopedEvent = getLoaderScopedEventName(scope, scopedEvent);
2495
+ const scopedEventKey = ":" + scopedEvent;
2496
+ return (!props || !_hasOwnProperty.call(props, scopedEventKey)) && (patchProperty(diffContext, vnode, scopedEventKey, value, currentFile),
2497
+ registerQwikLoaderEvent(diffContext, loaderScopedEvent), !0);
2498
+ }
2499
+ return !1;
2500
+ };
2357
2501
 
2358
2502
  function registerQwikLoaderEvent(diffContext, eventName) {
2359
2503
  const qWindow = import.meta.env.TEST ? diffContext.container.document.defaultView : window;
@@ -2363,6 +2507,13 @@ function registerQwikLoaderEvent(diffContext, eventName) {
2363
2507
  function retrieveChildWithKey(diffContext, nodeName, key) {
2364
2508
  let vNodeWithKey = null;
2365
2509
  if (null === diffContext.vSiblings) {
2510
+ const vCurrent = diffContext.vCurrent;
2511
+ if (vCurrent) {
2512
+ const name = vnode_isElementVNode(vCurrent) ? vnode_getElementName(vCurrent) : null;
2513
+ if ((getKey(vCurrent) || getComponentHash(vCurrent, diffContext.container.$getObjectById$)) === key && name === nodeName) {
2514
+ return vCurrent;
2515
+ }
2516
+ }
2366
2517
  diffContext.vSiblings = new Map, diffContext.vSiblingsArray = [];
2367
2518
  let vNode = diffContext.vCurrent;
2368
2519
  for (;vNode; ) {
@@ -2380,8 +2531,8 @@ function retrieveChildWithKey(diffContext, nodeName, key) {
2380
2531
  }
2381
2532
  } else {
2382
2533
  const siblingsKey = getSideBufferKey(nodeName, key);
2383
- diffContext.vSiblings.has(siblingsKey) && (vNodeWithKey = diffContext.vSiblings.get(siblingsKey),
2384
- diffContext.vSiblings.delete(siblingsKey));
2534
+ const sibling = diffContext.vSiblings.get(siblingsKey);
2535
+ sibling && (vNodeWithKey = sibling, diffContext.vSiblings.delete(siblingsKey));
2385
2536
  }
2386
2537
  return collectSideBufferSiblings(diffContext, vNodeWithKey), vNodeWithKey;
2387
2538
  }
@@ -2425,8 +2576,8 @@ function deleteFromSideBuffer(diffContext, nodeName, key) {
2425
2576
  function moveOrCreateKeyedNode(diffContext, nodeName, lookupKey, sideBufferKey, parentForInsert, addCurrentToSideBufferOnSideInsert) {
2426
2577
  if (diffContext.vNewNode = retrieveChildWithKey(diffContext, nodeName, lookupKey),
2427
2578
  diffContext.vNewNode) {
2428
- return diffContext.vCurrent = diffContext.vNewNode, diffContext.vNewNode = null,
2429
- !1;
2579
+ return vnode_insertBefore(diffContext.journal, parentForInsert, diffContext.vNewNode, diffContext.vCurrent),
2580
+ diffContext.vCurrent = diffContext.vNewNode, diffContext.vNewNode = null, !1;
2430
2581
  }
2431
2582
  if (null != sideBufferKey) {
2432
2583
  const buffered = diffContext.vSideBuffer?.get(sideBufferKey) || null;
@@ -2449,7 +2600,7 @@ function expectVirtual(diffContext, type, jsxKey) {
2449
2600
  const checkKey = "F" === type;
2450
2601
  const currentKey = getKey(diffContext.vCurrent);
2451
2602
  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)),
2603
+ return null === jsxKey || diffContext.isCreationMode ? (vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newVirtual(), diffContext.vCurrent && getInsertBefore(diffContext)),
2453
2604
  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
2605
  diffContext.vNewNode.key = jsxKey, isDev && vnode_setProp(diffContext.vNewNode, "q:type", type)));
2455
2606
  }
@@ -2513,7 +2664,7 @@ function expectText(diffContext, text) {
2513
2664
  return text !== vnode_getText(diffContext.vCurrent) ? void vnode_setText(diffContext.journal, diffContext.vCurrent, text) : void 0;
2514
2665
  }
2515
2666
  }
2516
- vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newText(diffContext.container.document.createTextNode(text), text), diffContext.vCurrent);
2667
+ vnode_insertBefore(diffContext.journal, diffContext.vParent, diffContext.vNewNode = vnode_newText((import.meta.env.TEST ? diffContext.container.document : document).createTextNode(text), text), diffContext.vCurrent);
2517
2668
  }
2518
2669
 
2519
2670
  function getKey(vNode) {
@@ -2533,10 +2684,10 @@ function Projection() {}
2533
2684
  function handleProps(host, jsxProps, vNodeProps, container) {
2534
2685
  let shouldRender = !1;
2535
2686
  if (vNodeProps) {
2536
- const effects = vNodeProps[_PROPS_HANDLER].$effects$;
2537
2687
  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];
2688
+ shouldRender ||= constPropsDifferent;
2689
+ const varPropsDifferent = handleChangedProps(jsxProps[_VAR_PROPS], vNodeProps[_VAR_PROPS], vNodeProps[_PROPS_HANDLER], container, !0);
2690
+ shouldRender ||= varPropsDifferent, vNodeProps[_OWNER] = jsxProps[_OWNER];
2540
2691
  } else {
2541
2692
  jsxProps && (vnode_setProp(host, "q:props", jsxProps), vNodeProps = jsxProps);
2542
2693
  }
@@ -2552,17 +2703,20 @@ function handleChangedProps(src, dst, propsHandler, container, triggerEffects =
2552
2703
  if (src) {
2553
2704
  for (const key in src) {
2554
2705
  if ("children" !== key && "q:brefs" !== key && (!dst || src[key] !== dst[key])) {
2555
- if (changed = !0, !triggerEffects) {
2706
+ if (!triggerEffects) {
2556
2707
  return !0;
2557
2708
  }
2558
- dst && (dst[key] = src[key]), triggerPropsProxyEffect(propsHandler, key);
2709
+ dst && (dst[key] = src[key]);
2710
+ triggerPropsProxyEffect(propsHandler, key) || (changed = !0);
2559
2711
  }
2560
2712
  }
2561
2713
  }
2562
2714
  if (dst) {
2563
2715
  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))));
2716
+ if ("children" !== key && "q:brefs" !== key && (!src || !_hasOwnProperty.call(src, key)) && triggerEffects) {
2717
+ delete dst[key];
2718
+ triggerPropsProxyEffect(propsHandler, key) || (changed = !0);
2719
+ }
2566
2720
  }
2567
2721
  }
2568
2722
  return changed;
@@ -2669,10 +2823,58 @@ function markVNodeAsDeleted(vCursor) {
2669
2823
  vCursor.flags |= 32;
2670
2824
  }
2671
2825
 
2826
+ function areWrappedSignalsEqual(oldSignal, newSignal) {
2827
+ return oldSignal === newSignal || newSignal.$func$ === oldSignal.$func$ && areArgumentsEqual(newSignal.$args$, oldSignal.$args$);
2828
+ }
2829
+
2830
+ function areArgumentsEqual(oldArgs, newArgs) {
2831
+ if (oldArgs === newArgs) {
2832
+ return !0;
2833
+ }
2834
+ if (!oldArgs || !newArgs || oldArgs.length !== newArgs.length) {
2835
+ return !1;
2836
+ }
2837
+ for (let i = 0; i < oldArgs.length; i++) {
2838
+ if (oldArgs[i] !== newArgs[i]) {
2839
+ return !1;
2840
+ }
2841
+ }
2842
+ return !0;
2843
+ }
2844
+
2845
+ function containsWrappedSignal(data, signal) {
2846
+ if (!(signal instanceof WrappedSignalImpl)) {
2847
+ return !1;
2848
+ }
2849
+ for (const item of data) {
2850
+ if (item instanceof WrappedSignalImpl && areWrappedSignalsEqual(item, signal)) {
2851
+ return !0;
2852
+ }
2853
+ }
2854
+ return !1;
2855
+ }
2856
+
2672
2857
  const HANDLER_PREFIX = ":";
2673
2858
 
2674
2859
  let count = 0;
2675
2860
 
2861
+ const useSequentialScope = () => {
2862
+ const iCtx = useInvokeContext();
2863
+ const host = iCtx.$hostElement$;
2864
+ let seq = iCtx.$container$.getHostProp(host, "q:seq");
2865
+ null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
2866
+ let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
2867
+ for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
2868
+ seq.push(void 0);
2869
+ }
2870
+ return {
2871
+ val: seq[seqIdx],
2872
+ set: value => seq[seqIdx] = value,
2873
+ i: seqIdx,
2874
+ iCtx
2875
+ };
2876
+ };
2877
+
2676
2878
  const useResourceQrl = (qrl, opts) => {
2677
2879
  const {val, set, i, iCtx} = useSequentialScope();
2678
2880
  if (null != val) {
@@ -2743,7 +2945,7 @@ const runResource = (task, container, host) => {
2743
2945
  iCtx.$container$ = container;
2744
2946
  const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
2745
2947
  const resource = task.$state$;
2746
- assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
2948
+ isDev && assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
2747
2949
  const track = trackFn(task, container);
2748
2950
  const [cleanup, cleanups] = cleanupFn(task, reason => container.handleError(reason, host));
2749
2951
  const resourceTarget = unwrapStore(resource);
@@ -2789,36 +2991,6 @@ const runResource = (task, container, host) => {
2789
2991
  }) ]) : promise;
2790
2992
  };
2791
2993
 
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
2994
  function executeTasks(vNode, container, cursorData) {
2823
2995
  vNode.dirty &= -2;
2824
2996
  const elementSeq = container.getHostProp(vNode, "q:seq");
@@ -2895,8 +3067,9 @@ function clearNodePropData(vNode) {
2895
3067
  delete (vNode.props ||= {})[":nodeProps"];
2896
3068
  }
2897
3069
 
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);
3070
+ function setNodeProp(domVNode, journal, property, value, isConst, scopedStyleIdPrefix = null) {
3071
+ journal.push(createSetAttributeOperation(domVNode.node, property, value, scopedStyleIdPrefix, !!(128 & domVNode.flags))),
3072
+ isConst || (domVNode.props && null == value ? delete domVNode.props[property] : (domVNode.props ||= {})[property] = value);
2900
3073
  }
2901
3074
 
2902
3075
  function executeNodeProps(vNode, journal) {
@@ -2911,7 +3084,7 @@ function executeNodeProps(vNode, journal) {
2911
3084
  for (const [property, nodeProp] of allPropData.entries()) {
2912
3085
  let value = nodeProp.value;
2913
3086
  isSignal(value) && (value = value.value);
2914
- setNodeProp(domVNode, journal, property, serializeAttribute(property, value, nodeProp.scopedStyleIdPrefix), nodeProp.isConst);
3087
+ setNodeProp(domVNode, journal, property, value, nodeProp.isConst, nodeProp.scopedStyleIdPrefix);
2915
3088
  }
2916
3089
  clearNodePropData(vNode);
2917
3090
  }
@@ -2958,39 +3131,69 @@ const fastInsertBefore = (insertBeforeParent, target, insertBefore) => {
2958
3131
  };
2959
3132
 
2960
3133
  function _flushJournal(journal) {
3134
+ let batchParent = null;
3135
+ let batchBefore = null;
3136
+ let batchNodes = null;
3137
+ const batchSet = new Set;
3138
+ const flush = () => {
3139
+ if (batchNodes) {
3140
+ if (1 === batchNodes.length) {
3141
+ fastInsertBefore(batchParent, batchNodes[0], batchBefore);
3142
+ } else {
3143
+ const fragment = (batchParent.ownerDocument || batchParent).createDocumentFragment();
3144
+ for (const node of batchNodes) {
3145
+ fragment.appendChild(node);
3146
+ }
3147
+ fastInsertBefore(batchParent, fragment, batchBefore);
3148
+ }
3149
+ batchNodes = null, batchParent = null, batchBefore = null, batchSet.clear();
3150
+ }
3151
+ };
2961
3152
  for (const operation of journal) {
2962
- switch (operation.operationType) {
2963
- case 2:
3153
+ if (operation instanceof InsertOrMoveOperation) {
3154
+ if (batchParent === operation.parent && batchBefore === operation.beforeTarget) {
3155
+ batchNodes || (batchNodes = []), batchNodes.push(operation.target), batchSet.add(operation.target);
3156
+ continue;
3157
+ }
3158
+ if (!batchNodes) {
3159
+ batchParent = operation.parent, batchBefore = operation.beforeTarget, batchNodes = [ operation.target ],
3160
+ batchSet.add(operation.target);
3161
+ continue;
3162
+ }
3163
+ if (batchParent === operation.parent) {
3164
+ flush(), batchParent = operation.parent, batchBefore = operation.beforeTarget, batchNodes = [ operation.target ],
3165
+ batchSet.add(operation.target);
3166
+ continue;
3167
+ }
3168
+ if (batchSet.has(operation.target) || batchBefore && operation.target === batchBefore || batchParent && operation.target === batchParent) {
3169
+ flush(), batchParent = operation.parent, batchBefore = operation.beforeTarget, batchNodes = [ operation.target ],
3170
+ batchSet.add(operation.target);
3171
+ continue;
3172
+ }
2964
3173
  fastInsertBefore(operation.parent, operation.target, operation.beforeTarget);
2965
- break;
2966
-
2967
- case 1:
3174
+ } else if (operation instanceof DeleteOperation) {
3175
+ (batchSet.has(operation.target) || batchBefore && operation.target === batchBefore || batchParent && operation.target === batchParent) && flush(),
2968
3176
  operation.target.remove();
2969
- break;
2970
-
2971
- case 16:
2972
- operation.target.nodeValue = operation.text;
2973
- break;
2974
-
2975
- case 8:
2976
- {
3177
+ } else {
3178
+ if (operation instanceof RemoveAllChildrenOperation) {
3179
+ (batchSet.has(operation.target) || batchBefore && operation.target === batchBefore || batchParent && operation.target === batchParent) && flush();
3180
+ operation.target.textContent = "";
3181
+ continue;
3182
+ }
3183
+ if (operation instanceof SetTextOperation) {
3184
+ operation.target.nodeValue = operation.text;
3185
+ } else if (operation instanceof SetAttributeOperation) {
2977
3186
  const element = operation.target;
2978
3187
  const attrName = operation.attrName;
2979
- const attrValue = operation.attrValue;
3188
+ const rawValue = operation.attrValue;
3189
+ const attrValue = null != rawValue ? serializeAttribute(attrName, rawValue, operation.scopedStyleIdPrefix) : null;
2980
3190
  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;
3191
+ isBooleanAttr(element, attrName) ? element[attrName] = parseBoolean(attrValue) : attrName === dangerouslySetInnerHTML ? (batchParent === element && flush(),
3192
+ 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
3193
  }
2992
3194
  }
2993
3195
  }
3196
+ flush();
2994
3197
  }
2995
3198
 
2996
3199
  function executeAfterFlush(container, cursorData) {
@@ -3050,20 +3253,20 @@ function processCursorQueue(options = {
3050
3253
 
3051
3254
  function walkCursor(cursor, options) {
3052
3255
  const {timeBudget} = options;
3053
- const isServer = isServerPlatform();
3256
+ const isRunningOnServer = import.meta.env.TEST ? isServerPlatform() : isServer;
3054
3257
  const startTime = performance.now();
3055
3258
  const cursorData = getCursorData(cursor);
3056
3259
  if (cursorData.promise) {
3057
3260
  return;
3058
3261
  }
3059
3262
  const container = cursorData.container;
3060
- if (assertDefined(container, "Cursor container not found"), !cursor.dirty) {
3061
- return void finishWalk(container, cursor, cursorData, isServer);
3263
+ if (isDev && assertDefined(container, "Cursor container not found"), !cursor.dirty) {
3264
+ return void finishWalk(container, cursor, cursorData, isRunningOnServer);
3062
3265
  }
3063
3266
  const journal = cursorData.journal ||= [];
3064
3267
  let currentVNode = null;
3065
3268
  for (;currentVNode = cursorData.position; ) {
3066
- if (!isServer && !import.meta.env.TEST) {
3269
+ if (!isRunningOnServer && !import.meta.env.TEST) {
3067
3270
  if (performance.now() - startTime >= timeBudget) {
3068
3271
  return void scheduleYield();
3069
3272
  }
@@ -3114,8 +3317,8 @@ function walkCursor(cursor, options) {
3114
3317
  });
3115
3318
  }
3116
3319
  }
3117
- assertFalse(!(!(127 & cursor.dirty) || cursorData.position), "Cursor is still dirty and position is not set after walking"),
3118
- finishWalk(container, cursor, cursorData, isServer);
3320
+ isDev && assertFalse(!(!(127 & cursor.dirty) || cursorData.position), "Cursor is still dirty and position is not set after walking"),
3321
+ finishWalk(container, cursor, cursorData, isRunningOnServer);
3119
3322
  }
3120
3323
 
3121
3324
  function finishWalk(container, cursor, cursorData, isServer) {
@@ -3131,7 +3334,8 @@ function finishWalk(container, cursor, cursorData, isServer) {
3131
3334
  }
3132
3335
 
3133
3336
  function resolveCursor(container) {
3134
- 0 === container.$cursorCount$ && (container.$resolveRenderPromise$(), container.$renderPromise$ = null);
3337
+ 0 === container.$cursorCount$ && 0 === container.$pausedCursorCount$ && (container.$resolveRenderPromise$(),
3338
+ container.$renderPromise$ = null);
3135
3339
  }
3136
3340
 
3137
3341
  function partitionDirtyChildren(dirtyChildren, parent) {
@@ -3168,7 +3372,8 @@ function getNextVNode(vNode, cursor) {
3168
3372
  }
3169
3373
  index++, index === len && (index = 0);
3170
3374
  }
3171
- return parent.dirty &= -33, parent.dirtyChildren = null, getNextVNode(parent, cursor);
3375
+ return parent.dirty &= -33, parent.dirtyChildren = null, parent.nextDirtyChildIndex = 0,
3376
+ getNextVNode(parent, cursor);
3172
3377
  }
3173
3378
 
3174
3379
  function addCursor(container, root, priority) {
@@ -3214,7 +3419,7 @@ function _executeSsrChores(container, ssrNode) {
3214
3419
  const result = executeTasksChore(container, ssrNode);
3215
3420
  isPromise(result) && (promise = result);
3216
3421
  }
3217
- if (ssrNode.dirty &= -128, promise) {
3422
+ if (ssrNode.dirty &= -124, promise) {
3218
3423
  return promise;
3219
3424
  }
3220
3425
  }
@@ -3298,7 +3503,7 @@ function findAndPropagateToBlockingCursor(vNode) {
3298
3503
  }
3299
3504
 
3300
3505
  function isSsrNodeGuard() {
3301
- return isServerPlatform();
3506
+ return import.meta.env.TEST ? isServerPlatform() : isServer;
3302
3507
  }
3303
3508
 
3304
3509
  function markVNodeDirty(container, vNode, bits, cursorRoot = null) {
@@ -3351,67 +3556,70 @@ const fastGetter = (prototype, name) => {
3351
3556
  };
3352
3557
 
3353
3558
  const vnode_newElement = (element, elementName, key = null) => {
3354
- assertEqual(fastNodeType(element), 1, "Expecting element node.");
3559
+ isDev && assertEqual(fastNodeType(element), 1, "Expecting element node.");
3355
3560
  const vnode = new ElementVNode(key, -503, null, null, null, null, null, null, element, elementName);
3356
3561
  return element.vNode = vnode, vnode;
3357
3562
  };
3358
3563
 
3359
3564
  const vnode_newUnMaterializedElement = element => {
3360
- assertEqual(fastNodeType(element), 1, "Expecting element node.");
3565
+ isDev && assertEqual(fastNodeType(element), 1, "Expecting element node.");
3361
3566
  const vnode = new ElementVNode(null, -511, null, null, null, null, void 0, void 0, element, void 0);
3362
3567
  return element.vNode = vnode, vnode;
3363
3568
  };
3364
3569
 
3365
3570
  const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
3366
- sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
3571
+ isDev && sharedTextNode && assertEqual(fastNodeType(sharedTextNode), 3, "Expecting text node.");
3367
3572
  return new TextVNode(-508, null, previousTextNode, null, null, sharedTextNode, textContent);
3368
3573
  };
3369
3574
 
3370
3575
  const vnode_newText = (textNode, textContent) => {
3371
3576
  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."),
3577
+ return isDev && assertEqual(fastNodeType(textNode), 3, "Expecting text node."),
3578
+ isDev && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode."),
3579
+ isDev && assertTrue(vnode_isTextVNode(vnode), "Incorrect format of TextVNode."),
3580
+ isDev && assertFalse(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode."),
3374
3581
  vnode;
3375
3582
  };
3376
3583
 
3377
3584
  const vnode_newVirtual = () => {
3378
3585
  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."),
3586
+ return isDev && assertFalse(vnode_isElementVNode(vnode), "Incorrect format of TextVNode."),
3587
+ isDev && assertFalse(vnode_isTextVNode(vnode), "Incorrect format of TextVNode."),
3588
+ isDev && assertTrue(vnode_isVirtualVNode(vnode), "Incorrect format of TextVNode."),
3381
3589
  vnode;
3382
3590
  };
3383
3591
 
3384
3592
  const vnode_isVNode = vNode => vNode instanceof VNode;
3385
3593
 
3386
- const vnode_isElementVNode = vNode => vNode instanceof ElementVNode;
3594
+ const vnode_isElementVNode = vNode => !(1 & ~vNode.flags);
3387
3595
 
3388
3596
  const vnode_isElementOrTextVNode = vNode => {
3389
- assertDefined(vNode, "Missing vNode");
3597
+ isDev && assertDefined(vNode, "Missing vNode");
3390
3598
  return !!(5 & vNode.flags);
3391
3599
  };
3392
3600
 
3393
3601
  const vnode_isMaterialized = vNode => {
3394
- assertDefined(vNode, "Missing vNode");
3602
+ isDev && assertDefined(vNode, "Missing vNode");
3395
3603
  return !(1 & ~vNode.flags) && void 0 !== vNode.firstChild && void 0 !== vNode.lastChild;
3396
3604
  };
3397
3605
 
3398
- const vnode_isTextVNode = vNode => vNode instanceof TextVNode;
3606
+ const vnode_isTextVNode = vNode => !(4 & ~vNode.flags);
3399
3607
 
3400
- const vnode_isVirtualVNode = vNode => vNode instanceof VirtualVNode;
3608
+ const vnode_isVirtualVNode = vNode => !(2 & ~vNode.flags);
3401
3609
 
3402
3610
  const vnode_isProjection = vNode => {
3403
- assertDefined(vNode, "Missing vNode");
3611
+ isDev && assertDefined(vNode, "Missing vNode");
3404
3612
  return !(2 & ~vNode.flags) && null !== vnode_getProp(vNode, QSlot, null);
3405
3613
  };
3406
3614
 
3407
- const ensureTextVNode = vNode => (assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)),
3615
+ const ensureTextVNode = vNode => (isDev && assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)),
3408
3616
  vNode);
3409
3617
 
3410
3618
  const ensureElementOrVirtualVNode = vNode => {
3411
- assertDefined(vNode, "Missing vNode"), assertTrue(!!(3 & vNode.flags), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
3619
+ isDev && assertDefined(vNode, "Missing vNode"), isDev && assertTrue(!!(3 & vNode.flags), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
3412
3620
  };
3413
3621
 
3414
- const ensureElementVNode = vNode => (assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)),
3622
+ const ensureElementVNode = vNode => (isDev && assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)),
3415
3623
  vNode);
3416
3624
 
3417
3625
  const vnode_getNodeTypeName = vNode => {
@@ -3443,12 +3651,12 @@ const vnode_getProp = (vNode, key, getObject) => {
3443
3651
  };
3444
3652
 
3445
3653
  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));
3654
+ null == value && vNode.props ? delete vNode.props[key] : (vNode.props ||= {}, vNode.props[key] = value);
3448
3655
  };
3449
3656
 
3450
- const vnode_setAttr = (journal, vNode, key, value) => {
3451
- vnode_isElementVNode(vNode) && (vnode_setProp(vNode, key, value), addVNodeOperation(journal, createSetAttributeOperation(vNode.node, key, value)));
3657
+ const vnode_setAttr = (journal, vNode, key, value, scopedStyleIdPrefix = null) => {
3658
+ vnode_isElementVNode(vNode) && (import.meta.env.TEST && scopedStyleIdPrefix && vnode_setProp(vNode, "__scopedStyleIdPrefix__", scopedStyleIdPrefix),
3659
+ vnode_setProp(vNode, key, value), addVNodeOperation(journal, createSetAttributeOperation(vNode.node, key, value, scopedStyleIdPrefix, !!(128 & vNode.flags))));
3452
3660
  };
3453
3661
 
3454
3662
  const vnode_ensureElementKeyInflated = vnode => {
@@ -3589,12 +3797,12 @@ const vnode_ensureTextInflated = (journal, vnode) => {
3589
3797
  const textVNode = ensureTextVNode(vnode);
3590
3798
  if (!(8 & textVNode.flags)) {
3591
3799
  const parentNode = vnode_getDomParent(vnode, !0);
3592
- assertDefined(parentNode, "Missing parent node.");
3800
+ isDev && assertDefined(parentNode, "Missing parent node.");
3593
3801
  const sharedTextNode = textVNode.node;
3594
3802
  const doc = fastOwnerDocument(parentNode);
3595
3803
  let vCursor = vnode_getDomSibling(vnode, !1, !0);
3596
3804
  const node = vnode_getDomSibling(vnode, !0, !0);
3597
- const insertBeforeNode = sharedTextNode || (node instanceof ElementVNode ? node.node : node?.node) || null;
3805
+ const insertBeforeNode = sharedTextNode || (node && vnode_isElementVNode(node) ? node.node : node?.node) || null;
3598
3806
  let lastPreviousTextNode = insertBeforeNode;
3599
3807
  for (;vCursor && vnode_isTextVNode(vCursor); ) {
3600
3808
  if (!(8 & vCursor.flags)) {
@@ -3630,7 +3838,7 @@ const vnode_locate = (rootVNode, id) => {
3630
3838
  let elementOffset = -1;
3631
3839
  let refElement;
3632
3840
  if ("string" == typeof id) {
3633
- assertDefined(qVNodeRefs, "Missing qVNodeRefs."), elementOffset = parseInt(id),
3841
+ isDev && assertDefined(qVNodeRefs, "Missing qVNodeRefs."), elementOffset = parseInt(id),
3634
3842
  refElement = qVNodeRefs.get(elementOffset);
3635
3843
  } else {
3636
3844
  refElement = id;
@@ -3639,10 +3847,10 @@ const vnode_locate = (rootVNode, id) => {
3639
3847
  return vNode;
3640
3848
  }
3641
3849
  }
3642
- if (assertDefined(refElement, "Missing refElement."), vnode_isVNode(refElement)) {
3850
+ if (isDev && assertDefined(refElement, "Missing refElement."), vnode_isVNode(refElement)) {
3643
3851
  vNode = refElement;
3644
3852
  } else {
3645
- assertTrue(containerElement.contains(refElement), "Couldn't find the element inside the container while locating the VNode.");
3853
+ isDev && assertTrue(containerElement.contains(refElement), "Couldn't find the element inside the container while locating the VNode.");
3646
3854
  let parent = refElement;
3647
3855
  const elementPath = [ refElement ];
3648
3856
  for (;parent && parent !== containerElement && !parent.vNode; ) {
@@ -3669,8 +3877,8 @@ const vnode_locate = (rootVNode, id) => {
3669
3877
 
3670
3878
  const vnode_getChildWithIdx = (vNode, childIdx) => {
3671
3879
  let child = vnode_getFirstChild(vNode);
3672
- for (assertDefined(child, "Missing child."); child.flags >>> 9 !== childIdx; ) {
3673
- child = child.nextSibling, assertDefined(child, "Missing child.");
3880
+ for (isDev && assertDefined(child, "Missing child."); child.flags >>> 9 !== childIdx; ) {
3881
+ child = child.nextSibling, isDev && assertDefined(child, "Missing child.");
3674
3882
  }
3675
3883
  return child;
3676
3884
  };
@@ -3680,7 +3888,7 @@ const vNodeStack = [];
3680
3888
  const vnode_getVNodeForChildNode = (vNode, childElement) => {
3681
3889
  ensureElementVNode(vNode);
3682
3890
  let child = vnode_getFirstChild(vNode);
3683
- for (assertDefined(child, "Missing child."); child && (!(child instanceof ElementVNode) || child.node !== childElement); ) {
3891
+ for (isDev && assertDefined(child, "Missing child."); child && (!(child instanceof ElementVNode) || child.node !== childElement); ) {
3684
3892
  if (vnode_isVirtualVNode(child)) {
3685
3893
  const next = child.nextSibling;
3686
3894
  const firstChild = vnode_getFirstChild(child);
@@ -3689,12 +3897,12 @@ const vnode_getVNodeForChildNode = (vNode, childElement) => {
3689
3897
  const next = child.nextSibling;
3690
3898
  child = next || (next || vNodeStack.pop());
3691
3899
  }
3692
- assertDefined(child, "Missing child.");
3900
+ isDev && assertDefined(child, "Missing child.");
3693
3901
  }
3694
3902
  for (;vNodeStack.length; ) {
3695
3903
  vNodeStack.pop();
3696
3904
  }
3697
- return ensureElementVNode(child), assertEqual(child.node, childElement, "Child not found."),
3905
+ return ensureElementVNode(child), isDev && assertEqual(child.node, childElement, "Child not found."),
3698
3906
  child;
3699
3907
  };
3700
3908
 
@@ -3760,7 +3968,7 @@ const vnode_getDomParentVNode = (vnode, includeProjection) => {
3760
3968
  };
3761
3969
 
3762
3970
  const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
3763
- if (assertEqual(vParent, vToRemove.parent, "Parent mismatch."), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove),
3971
+ if (isDev && assertEqual(vParent, vToRemove.parent, "Parent mismatch."), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove),
3764
3972
  removeDOM) {
3765
3973
  const domParent = vnode_getDomParent(vParent, !1);
3766
3974
  if (null !== vnode_getProp(vParent, dangerouslySetInnerHTML, null)) {
@@ -3780,7 +3988,7 @@ const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
3780
3988
  };
3781
3989
 
3782
3990
  const vnode_truncate = (journal, vParent, vDelete, removeDOM = !0) => {
3783
- assertDefined(vDelete, "Missing vDelete.");
3991
+ isDev && assertDefined(vDelete, "Missing vDelete.");
3784
3992
  if (vnode_getDomParent(vParent, !0) && removeDOM) {
3785
3993
  if (vnode_isElementVNode(vParent)) {
3786
3994
  addVNodeOperation(journal, createRemoveAllChildrenOperation(vParent.node));
@@ -3861,8 +4069,8 @@ const ensureMaterialized = vnode => {
3861
4069
  if (void 0 === vFirstChild) {
3862
4070
  vFirstChild = vParent.parent && shouldIgnoreChildren(vParent.node) ? vParent.firstChild = vParent.lastChild = null : vnode_materialize(vParent);
3863
4071
  }
3864
- return assertTrue(void 0 !== vParent.firstChild, "Did not materialize."), assertTrue(void 0 !== vParent.lastChild, "Did not materialize."),
3865
- vFirstChild;
4072
+ return isDev && assertTrue(void 0 !== vParent.firstChild, "Did not materialize."),
4073
+ isDev && assertTrue(void 0 !== vParent.lastChild, "Did not materialize."), vFirstChild;
3866
4074
  };
3867
4075
 
3868
4076
  let _fastHasAttribute = null;
@@ -4081,8 +4289,8 @@ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1
4081
4289
  strings.push(qwikDebugToString(vnode_getText(vnode)));
4082
4290
  } else if (vnode_isVirtualVNode(vnode)) {
4083
4291
  const attrs = [ "[" + String(vnode.flags >>> 9) + "]" ];
4084
- vnode_getAttrKeys(vnode).forEach(key => {
4085
- if ("q:type" !== key) {
4292
+ vnode.dirty && attrs.push(` dirty:${vnode.dirty}`), vnode_getAttrKeys(vnode).forEach(key => {
4293
+ if ("q:type" !== key && "__scopedStyleIdPrefix__" !== key) {
4086
4294
  const value = vnode_getProp(vnode, key, null);
4087
4295
  attrs.push(" " + key + "=" + qwikDebugToString(value));
4088
4296
  }
@@ -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
 
@@ -4412,7 +4620,7 @@ const _waitUntilRendered = elm => {
4412
4620
  return promise || Promise.resolve();
4413
4621
  };
4414
4622
 
4415
- const createContextId = name => (assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9,_,.,-", name),
4623
+ const createContextId = name => (isDev && assertTrue(/^[\w/.-]+$/.test(name), "Context name must only contain A-Z,a-z,0-9,_,.,-", name),
4416
4624
  /*#__PURE__*/ Object.freeze({
4417
4625
  id: fromCamelToKebabCase(name)
4418
4626
  }));
@@ -4463,7 +4671,7 @@ const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COM
4463
4671
 
4464
4672
  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
4673
 
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" ];
4674
+ 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
4675
 
4468
4676
  function qrlToString(serializationContext, value, raw) {
4469
4677
  let symbol = value.$symbol$;
@@ -4497,12 +4705,16 @@ function qrlToString(serializationContext, value, raw) {
4497
4705
  }
4498
4706
 
4499
4707
  function createQRLWithBackChannel(chunk, symbol, captureIds) {
4500
- let qrlRef = null;
4708
+ let qrlImporter = null;
4501
4709
  if (isDev && chunk === QRL_RUNTIME_CHUNK) {
4502
4710
  const backChannel = globalThis.__qrl_back_channel__;
4503
- assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK"), qrlRef = backChannel.get(symbol);
4711
+ isDev && assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK");
4712
+ const fn = backChannel.get(symbol);
4713
+ fn && (qrlImporter = () => Promise.resolve({
4714
+ [symbol]: fn
4715
+ }));
4504
4716
  }
4505
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
4717
+ return createQRL(chunk, symbol, null, qrlImporter, captureIds, null);
4506
4718
  }
4507
4719
 
4508
4720
  function parseQRL(qrl) {
@@ -4611,7 +4823,7 @@ const allocate = (container, typeId, value) => {
4611
4823
  return new FormData;
4612
4824
 
4613
4825
  case 31:
4614
- return new JSXNodeImpl(null);
4826
+ return new JSXNodeImpl(null, null, null, null, null);
4615
4827
 
4616
4828
  case 11:
4617
4829
  return BigInt(value);
@@ -4651,6 +4863,9 @@ const allocate = (container, typeId, value) => {
4651
4863
  case 33:
4652
4864
  return new SubscriptionData({});
4653
4865
 
4866
+ case 34:
4867
+ return new EffectSubscription(null, null, null, null);
4868
+
4654
4869
  default:
4655
4870
  throw qError(18, [ typeId ]);
4656
4871
  }
@@ -4719,25 +4934,6 @@ const inlinedQrlDEV = (symbol, symbolName, opts, lexicalScopeCapture = EMPTY_ARR
4719
4934
  const _regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
4720
4935
  globalThis.__qwik_reg_symbols.set(hash, symbol), symbol);
4721
4936
 
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
4937
  function isStringifiable(value) {
4742
4938
  return null === value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value;
4743
4939
  }
@@ -4904,6 +5100,8 @@ async function serialize(serializationContext) {
4904
5100
  output(32, [ _serializationWeakRef(owner), owner.varProps, owner.constProps, value[_PROPS_HANDLER].$effects$ ]);
4905
5101
  } else if (value instanceof SubscriptionData) {
4906
5102
  output(33, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
5103
+ } else if (value instanceof EffectSubscription) {
5104
+ output(34, [ value.consumer, value.property, value.backRef, value.data ]);
4907
5105
  } else if (isStore(value)) {
4908
5106
  if (isResource(value)) {
4909
5107
  serializationContext.$resources$.add(value);
@@ -5172,7 +5370,7 @@ function filterEffectBackRefs(effectBackRef) {
5172
5370
  let effectBackRefToSerialize;
5173
5371
  if (effectBackRef) {
5174
5372
  for (const [effectProp, effect] of effectBackRef) {
5175
- effect[2] && (effectBackRefToSerialize ||= new Map, effectBackRefToSerialize.set(effectProp, effect));
5373
+ effect.backRef && (effectBackRefToSerialize ||= new Map, effectBackRefToSerialize.set(effectProp, effect));
5176
5374
  }
5177
5375
  }
5178
5376
  return effectBackRefToSerialize;
@@ -5291,6 +5489,7 @@ class _SharedContainer {
5291
5489
  $renderPromise$=null;
5292
5490
  $resolveRenderPromise$=null;
5293
5491
  $cursorCount$=0;
5492
+ $pausedCursorCount$=0;
5294
5493
  constructor(serverData, locale) {
5295
5494
  this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
5296
5495
  this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
@@ -5423,7 +5622,7 @@ function processJSXNode(ssr, enqueue, value, options) {
5423
5622
  const children = jsx.children;
5424
5623
  null != children && enqueue(children);
5425
5624
  } else if (type === Slot) {
5426
- const componentFrame = options.parentComponentFrame || ssr.unclaimedProjectionComponentFrameQueue.shift();
5625
+ const componentFrame = options.parentComponentFrame;
5427
5626
  if (componentFrame) {
5428
5627
  const projectionAttrs = isDev ? [ "q:type", "P" ] : [];
5429
5628
  projectionAttrs.push("q:sparent", componentFrame.componentNode.id || ""), ssr.openProjection(projectionAttrs);
@@ -5497,7 +5696,7 @@ function toSsrAttrs(record, options) {
5497
5696
  const eventValue = setEvent(options.serializationCtx, key, value);
5498
5697
  return void (eventValue && ssrAttrs.push(key, eventValue));
5499
5698
  }
5500
- isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, options.styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(options.serializationCtx, key),
5699
+ 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
5700
  value = serializeAttribute(key, value, options.styleScopedId), ssrAttrs.push(key, value));
5502
5701
  }
5503
5702
  };
@@ -5737,8 +5936,8 @@ const inflate = (container, target, typeId, data) => {
5737
5936
  const propsProxy = target;
5738
5937
  const d = data;
5739
5938
  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];
5939
+ owner === _UNINITIALIZED && (owner = new JSXNodeImpl(Fragment, d[1], d[2], null, null),
5940
+ owner._proxy = propsProxy), propsProxy[_OWNER] = owner, propsProxy[_PROPS_HANDLER].$effects$ = d[3];
5742
5941
  break;
5743
5942
 
5744
5943
  case 33:
@@ -5748,6 +5947,15 @@ const inflate = (container, target, typeId, data) => {
5748
5947
  break;
5749
5948
  }
5750
5949
 
5950
+ case 34:
5951
+ {
5952
+ const effectSub = target;
5953
+ const d = data;
5954
+ effectSub.consumer = d[0], effectSub.property = d[1], effectSub.backRef = d[2],
5955
+ effectSub.data = d[3];
5956
+ break;
5957
+ }
5958
+
5751
5959
  default:
5752
5960
  throw qError(16, [ typeId ]);
5753
5961
  }
@@ -5785,7 +5993,8 @@ function inflateWrappedSignalValue(signal) {
5785
5993
  const effects = signal.$effects$;
5786
5994
  let hasAttrValue = !1;
5787
5995
  if (effects) {
5788
- for (const [_, key] of effects) {
5996
+ for (const effect of effects) {
5997
+ const key = effect.property;
5789
5998
  if (isString(key)) {
5790
5999
  const attrValue = vnode_getProp(hostVNode, key, null);
5791
6000
  if (null !== attrValue) {
@@ -6172,7 +6381,8 @@ class DomContainer extends _SharedContainer {
6172
6381
  $getObjectById$=id => getObjectById(id, this.$stateData$);
6173
6382
  getSyncFn(id) {
6174
6383
  const fn = this.$qFuncs$[id];
6175
- return assertTrue("function" == typeof fn, "Invalid reference: " + id), fn;
6384
+ return isDev && assertTrue("function" == typeof fn, "Invalid reference: " + id),
6385
+ fn;
6176
6386
  }
6177
6387
  $appendStyle$(content, styleId, host, scoped) {
6178
6388
  if (scoped) {
@@ -6204,6 +6414,60 @@ class DomContainer extends _SharedContainer {
6204
6414
  }
6205
6415
  }
6206
6416
 
6417
+ const useTaskQrl = (qrl, opts) => {
6418
+ const {val, set, iCtx, i} = useSequentialScope();
6419
+ if (val) {
6420
+ return;
6421
+ }
6422
+ assertQrl(qrl), set(1);
6423
+ const task = new Task(10 | (!1 === opts?.deferUpdates ? 0 : 16), i, iCtx.$hostElement$, qrl, void 0, null);
6424
+ set(task);
6425
+ const container = iCtx.$container$;
6426
+ const {$waitOn$: waitOn} = iCtx;
6427
+ const result = maybeThen(waitOn, () => runTask(task, container, iCtx.$hostElement$));
6428
+ isPromise(result) && (iCtx.$waitOn$ = result);
6429
+ };
6430
+
6431
+ const runTask = (task, container, host) => {
6432
+ task.$flags$ &= -9, cleanupDestroyable(task);
6433
+ const iCtx = newInvokeContext(container.$locale$, host, "qTask");
6434
+ iCtx.$container$ = container;
6435
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
6436
+ const track = trackFn(task, container);
6437
+ const [cleanup] = cleanupFn(task, reason => container.handleError(reason, host));
6438
+ const taskApi = {
6439
+ track,
6440
+ cleanup
6441
+ };
6442
+ return safeCall(() => taskFn(taskApi), cleanup, err => {
6443
+ if (isPromise(err)) {
6444
+ return err.then(() => runTask(task, container, host));
6445
+ }
6446
+ container.handleError(err, host);
6447
+ });
6448
+ };
6449
+
6450
+ class Task extends BackRef {
6451
+ $flags$;
6452
+ $index$;
6453
+ $el$;
6454
+ $qrl$;
6455
+ $state$;
6456
+ $destroy$;
6457
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
6458
+ super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
6459
+ this.$state$ = $state$, this.$destroy$ = $destroy$;
6460
+ }
6461
+ }
6462
+
6463
+ const isTask = value => value instanceof Task;
6464
+
6465
+ const scheduleTask = (_event, element) => {
6466
+ const [task] = useLexicalScope();
6467
+ const container = getDomContainer(element);
6468
+ task.$flags$ |= 8, markVNodeDirty(container, task.$el$, 1);
6469
+ };
6470
+
6207
6471
  const throwIfQRLNotResolved = qrl => {
6208
6472
  if (!qrl.resolved) {
6209
6473
  throw qrl.resolve();
@@ -6213,17 +6477,17 @@ const throwIfQRLNotResolved = qrl => {
6213
6477
  const isSignal = value => value instanceof SignalImpl;
6214
6478
 
6215
6479
  const ensureContainsSubscription = (array, effectSubscription) => {
6216
- !array.has(effectSubscription) && array.add(effectSubscription);
6480
+ array.add(effectSubscription);
6217
6481
  };
6218
6482
 
6219
6483
  const ensureContainsBackRef = (array, value) => {
6220
- array[2] ||= new Set, !array[2].has(value) && array[2].add(value);
6484
+ (array.backRef ||= new Set).add(value);
6221
6485
  };
6222
6486
 
6223
6487
  const addQrlToSerializationCtx = (effectSubscriber, container) => {
6224
- if (container && !isDomContainer(container)) {
6225
- const effect = effectSubscriber[0];
6226
- const property = effectSubscriber[1];
6488
+ if (container) {
6489
+ const effect = effectSubscriber.consumer;
6490
+ const property = effectSubscriber.property;
6227
6491
  let qrl = null;
6228
6492
  isTask(effect) ? qrl = effect.$qrl$ : effect instanceof ComputedSignalImpl ? qrl = effect.$computeQrl$ : ":" === property && (qrl = container.getHostProp(effect, "q:renderFn")),
6229
6493
  qrl && container.serializationCtx.$eventQrls$.add(qrl);
@@ -6231,14 +6495,13 @@ const addQrlToSerializationCtx = (effectSubscriber, container) => {
6231
6495
  };
6232
6496
 
6233
6497
  const scheduleEffects = (container, signal, effects) => {
6234
- const isBrowser = !isServerPlatform();
6498
+ const isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer;
6235
6499
  if (effects) {
6236
- let tasksToTrigger = null;
6237
6500
  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);
6501
+ const consumer = effectSubscription.consumer;
6502
+ const property = effectSubscription.property;
6503
+ if (isDev && assertDefined(container, "Container must be defined."), isTask(consumer)) {
6504
+ consumer.$flags$ |= 8, markVNodeDirty(container, consumer.$el$, 1);
6242
6505
  } else if (consumer instanceof SignalImpl) {
6243
6506
  consumer.invalidate();
6244
6507
  } else if (":" === property) {
@@ -6246,7 +6509,7 @@ const scheduleEffects = (container, signal, effects) => {
6246
6509
  } else if ("." === property) {
6247
6510
  isBrowser && (setNodeDiffPayload(consumer, signal), markVNodeDirty(container, consumer, 2));
6248
6511
  } else {
6249
- const effectData = effectSubscription[3];
6512
+ const effectData = effectSubscription.data;
6250
6513
  if (effectData instanceof SubscriptionData) {
6251
6514
  const data = effectData.data;
6252
6515
  const payload = {
@@ -6265,14 +6528,10 @@ const scheduleEffects = (container, signal, effects) => {
6265
6528
  }
6266
6529
  }
6267
6530
  };
6268
- for (const effect of effects) {
6531
+ const effectsSnapshot = Array.from(effects);
6532
+ for (const effect of effectsSnapshot) {
6269
6533
  scheduleEffect(effect);
6270
6534
  }
6271
- if (!isBrowser && container && tasksToTrigger) {
6272
- for (const task of tasksToTrigger) {
6273
- markVNodeDirty(container, task.$el$, 1);
6274
- }
6275
- }
6276
6535
  }
6277
6536
  };
6278
6537
 
@@ -6428,7 +6687,7 @@ class StoreHandler {
6428
6687
  }
6429
6688
  this.$container$ = ctx.$container$;
6430
6689
  } else {
6431
- assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
6690
+ isDev && assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
6432
6691
  }
6433
6692
  const effectSubscriber = ctx.$effectSubscriber$;
6434
6693
  effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
@@ -6486,7 +6745,7 @@ function addStoreEffect(target, prop, store, effectSubscription) {
6486
6745
  const effectsMap = store.$effects$ ||= new Map;
6487
6746
  let effects = effectsMap.get(prop);
6488
6747
  effects || (effects = new Set, effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription),
6489
- ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
6748
+ ensureContainsBackRef(effectSubscription, target), (import.meta.env.TEST ? !isDomContainer(store.$container$) : isServer) && addQrlToSerializationCtx(effectSubscription, store.$container$);
6490
6749
  }
6491
6750
 
6492
6751
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
@@ -6730,7 +6989,7 @@ function _deserialize(rawStateData, element) {
6730
6989
  }
6731
6990
 
6732
6991
  function getObjectById(id, stateData) {
6733
- return "string" == typeof id && (id = parseInt(id, 10)), assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`),
6992
+ return "string" == typeof id && (id = parseInt(id, 10)), isDev && assertTrue(id < stateData.length, `Invalid reference ${id} >= ${stateData.length}`),
6734
6993
  stateData[id];
6735
6994
  }
6736
6995
 
@@ -6877,7 +7136,7 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
6877
7136
  return symbolRef;
6878
7137
  }
6879
7138
  if (containerEl && setContainer(containerEl), "" === chunk) {
6880
- assertDefined(_containerEl, "Sync QRL must have container element");
7139
+ isDev && assertDefined(_containerEl, "Sync QRL must have container element");
6881
7140
  const hash = _containerEl.getAttribute("q:instance");
6882
7141
  const qFuncs = getQFuncs(_containerEl.ownerDocument, hash);
6883
7142
  return qrl.resolved = symbolRef = qFuncs[Number(symbol)];
@@ -6954,7 +7213,7 @@ const _qrlSync = function(fn, serializedFn) {
6954
7213
 
6955
7214
  const componentQrl = componentQrl => {
6956
7215
  function QwikComponent(props, key, flags = 0) {
6957
- assertQrl(componentQrl), assertNumber(flags, "The Qwik Component was not invoked correctly");
7216
+ isDev && assertQrl(componentQrl), isDev && assertNumber(flags, "The Qwik Component was not invoked correctly");
6958
7217
  const finalKey = componentQrl.$hash$.slice(0, 4) + ":" + (key || "");
6959
7218
  const InnerCmp = () => {};
6960
7219
  return InnerCmp[SERIALIZABLE_STATE] = [ componentQrl ], _jsxSplit(InnerCmp, props, null, props.children, 0, finalKey);
@@ -7333,10 +7592,10 @@ const useVisibleTaskQrl = (qrl, opts) => {
7333
7592
  if (val) {
7334
7593
  return void (64 & val.$flags$ || isServerPlatform() || (val.$flags$ |= 64, useRegisterTaskEvents(val, eagerness)));
7335
7594
  }
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));
7595
+ let flags;
7596
+ assertQrl(qrl), isServerPlatform() ? flags = 1 : (flags = 9, qrl.resolve(), markVNodeDirty(iCtx.$container$, iCtx.$hostElement$, 1));
7597
+ const task = new Task(flags, i, iCtx.$hostElement$, qrl, void 0, null);
7598
+ set(task), useRegisterTaskEvents(task, eagerness);
7340
7599
  };
7341
7600
 
7342
7601
  const useRegisterTaskEvents = (task, eagerness) => {