@qwik.dev/core 2.0.0-alpha.4 → 2.0.0-alpha.5

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.
package/dist/server.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/server 2.0.0-alpha.4-dev+374e0d6
3
+ * @qwik.dev/core/server 2.0.0-alpha.5-dev+cb53bbd
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
@@ -243,7 +243,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
243
243
  // 30
244
244
  "QRLs can not be dynamically resolved, because it does not have a chunk path",
245
245
  // 31
246
- "The JSX ref attribute must be a Signal",
246
+ "{{0}}\nThe JSX ref attribute must be a Signal",
247
247
  // 32
248
248
  "Serialization Error: Deserialization of data type {{0}} is not implemented",
249
249
  // 33
@@ -259,7 +259,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
259
259
  // 38
260
260
  "Serialization Error: Missing QRL chunk for {{0}}",
261
261
  // 39
262
- "The value of the textarea must be a string",
262
+ "{{0}}\nThe value of the textarea must be a string found {{1}}",
263
263
  // 40
264
264
  "Unable to find q:container",
265
265
  // 41
@@ -775,7 +775,7 @@ function getBuildBase(opts) {
775
775
  return `${import_meta.env.BASE_URL}build/`;
776
776
  }
777
777
  var versions = {
778
- qwik: "2.0.0-alpha.4-dev+374e0d6",
778
+ qwik: "2.0.0-alpha.5-dev+cb53bbd",
779
779
  qwikDom: "2.1.19"
780
780
  };
781
781
 
@@ -941,7 +941,6 @@ var StoreHandler = class {
941
941
  }
942
942
  /** In the case of oldValue and value are the same, the effects are not triggered. */
943
943
  set(target, prop, value) {
944
- target = unwrapDeserializerProxy(target);
945
944
  if (typeof prop === "symbol") {
946
945
  target[prop] = value;
947
946
  return true;
@@ -1009,6 +1008,11 @@ function addEffect(target, prop, store, effectSubscriber) {
1009
1008
  const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
1010
1009
  ensureContainsEffect(effects, effectSubscriber);
1011
1010
  ensureContains(effectSubscriber, target);
1011
+ ensureEffectContainsSubscriber(
1012
+ effectSubscriber[0 /* EFFECT */],
1013
+ target,
1014
+ store.$container$
1015
+ );
1012
1016
  DEBUG && log("sub", pad("\n" + store.$effects$.toString(), " "));
1013
1017
  }
1014
1018
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
@@ -1046,32 +1050,39 @@ function clearVNodeEffectDependencies(container, value) {
1046
1050
  }
1047
1051
  for (let i = effects.length - 1; i >= 0; i--) {
1048
1052
  const subscriber = effects[i];
1049
- const subscriptionRemoved = clearEffects(subscriber, value);
1050
- if (subscriptionRemoved) {
1051
- effects.splice(i, 1);
1052
- }
1053
+ clearEffects(subscriber, value, effects, i, container);
1054
+ }
1055
+ if (effects.length === 0) {
1056
+ vnode_setProp(value, QSubscribers, null);
1053
1057
  }
1054
1058
  }
1055
- function clearSubscriberEffectDependencies(value) {
1059
+ function clearSubscriberEffectDependencies(container, value) {
1056
1060
  if (value.$effectDependencies$) {
1057
1061
  for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
1058
1062
  const subscriber = value.$effectDependencies$[i];
1059
- const subscriptionRemoved = clearEffects(subscriber, value);
1060
- if (subscriptionRemoved) {
1061
- value.$effectDependencies$.splice(i, 1);
1062
- }
1063
+ clearEffects(subscriber, value, value.$effectDependencies$, i, container);
1064
+ }
1065
+ if (value.$effectDependencies$.length === 0) {
1066
+ value.$effectDependencies$ = null;
1063
1067
  }
1064
1068
  }
1065
1069
  }
1066
- function clearEffects(subscriber, value) {
1067
- if (!isSignal(subscriber)) {
1068
- return false;
1070
+ function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
1071
+ let subscriptionRemoved = false;
1072
+ const seenSet = /* @__PURE__ */ new Set();
1073
+ if (subscriber instanceof WrappedSignal) {
1074
+ subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
1075
+ } else if (container.$storeProxyMap$.has(subscriber)) {
1076
+ const store = container.$storeProxyMap$.get(subscriber);
1077
+ const handler = getStoreHandler(store);
1078
+ subscriptionRemoved = clearStoreEffects(handler, value);
1069
1079
  }
1070
- const effectSubscriptions = subscriber.$effects$;
1071
- const hostElement = subscriber.$hostElement$;
1072
- if (hostElement && hostElement === value) {
1073
- subscriber.$hostElement$ = null;
1080
+ if (subscriptionRemoved) {
1081
+ effectArray.splice(indexToRemove, 1);
1074
1082
  }
1083
+ }
1084
+ function clearSignalEffects(subscriber, value, seenSet) {
1085
+ const effectSubscriptions = subscriber.$effects$;
1075
1086
  let subscriptionRemoved = false;
1076
1087
  if (effectSubscriptions) {
1077
1088
  for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
@@ -1082,14 +1093,65 @@ function clearEffects(subscriber, value) {
1082
1093
  }
1083
1094
  }
1084
1095
  }
1085
- const args = subscriber.$args$;
1086
- if (args) {
1087
- for (let i = args.length - 1; i >= 0; i--) {
1088
- clearEffects(args[i], subscriber);
1096
+ if (subscriber instanceof WrappedSignal) {
1097
+ const hostElement = subscriber.$hostElement$;
1098
+ if (hostElement && hostElement === value) {
1099
+ subscriber.$hostElement$ = null;
1100
+ }
1101
+ const args = subscriber.$args$;
1102
+ if (args) {
1103
+ clearArgsEffects(args, subscriber, seenSet);
1089
1104
  }
1090
1105
  }
1091
1106
  return subscriptionRemoved;
1092
1107
  }
1108
+ function clearStoreEffects(storeHandler, value) {
1109
+ const effectSubscriptions = storeHandler.$effects$;
1110
+ if (!effectSubscriptions) {
1111
+ return false;
1112
+ }
1113
+ let subscriptionRemoved = false;
1114
+ for (const key in effectSubscriptions) {
1115
+ const effects = effectSubscriptions[key];
1116
+ for (let i = effects.length - 1; i >= 0; i--) {
1117
+ const effect = effects[i];
1118
+ if (effect[0 /* EFFECT */] === value) {
1119
+ effects.splice(i, 1);
1120
+ subscriptionRemoved = true;
1121
+ }
1122
+ }
1123
+ if (effects.length === 0) {
1124
+ delete effectSubscriptions[key];
1125
+ }
1126
+ }
1127
+ return subscriptionRemoved;
1128
+ }
1129
+ function clearArgsEffects(args, subscriber, seenSet) {
1130
+ for (let i = args.length - 1; i >= 0; i--) {
1131
+ const arg = args[i];
1132
+ clearArgEffect(arg, subscriber, seenSet);
1133
+ }
1134
+ }
1135
+ function clearArgEffect(arg, subscriber, seenSet) {
1136
+ if (seenSet.has(arg)) {
1137
+ return;
1138
+ }
1139
+ seenSet.add(arg);
1140
+ if (isSignal(arg)) {
1141
+ clearSignalEffects(arg, subscriber, seenSet);
1142
+ } else if (typeof arg === "object" && arg !== null) {
1143
+ if (isStore(arg)) {
1144
+ clearStoreEffects(getStoreHandler(arg), subscriber);
1145
+ } else {
1146
+ for (const key in arg) {
1147
+ clearArgEffect(arg[key], subscriber, seenSet);
1148
+ }
1149
+ }
1150
+ } else if (Array.isArray(arg)) {
1151
+ clearArgsEffects(arg, subscriber, seenSet);
1152
+ } else {
1153
+ }
1154
+ }
1093
1155
 
1094
1156
  // packages/qwik/src/core/use/use-resource.ts
1095
1157
  var _createResourceReturn = (opts) => {
@@ -1115,7 +1177,7 @@ var runResource = (task, container, host) => {
1115
1177
  cleanupTask(task);
1116
1178
  const iCtx = newInvokeContext(container.$locale$, host, void 0, ResourceEvent);
1117
1179
  iCtx.$container$ = container;
1118
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(task));
1180
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
1119
1181
  const resource = task.$state$;
1120
1182
  assertDefined(
1121
1183
  resource,
@@ -1603,6 +1665,19 @@ function escapeHTML(html) {
1603
1665
  }
1604
1666
  }
1605
1667
 
1668
+ // packages/qwik/src/core/shared/utils/jsx-filename.ts
1669
+ function getFileLocationFromJsx(jsxDev) {
1670
+ var _a;
1671
+ if (!jsxDev) {
1672
+ return null;
1673
+ }
1674
+ const sanitizedFileName = (_a = jsxDev.fileName) == null ? void 0 : _a.replace(/\\/g, "/");
1675
+ if (sanitizedFileName) {
1676
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
1677
+ }
1678
+ return null;
1679
+ }
1680
+
1606
1681
  // packages/qwik/src/core/client/vnode-diff.ts
1607
1682
  var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1608
1683
  let journal = container.$journal$;
@@ -1943,7 +2018,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1943
2018
  vnode_remove(journal, vParent, toRemove, true);
1944
2019
  }
1945
2020
  }
1946
- function createNewElement(jsx2, elementName) {
2021
+ function createNewElement(jsx2, elementName, currentFile) {
1947
2022
  const element = createElementWithNamespace(elementName);
1948
2023
  const { constProps } = jsx2;
1949
2024
  let needsQDispatchEventPatch = false;
@@ -1971,6 +2046,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1971
2046
  } else if (typeof value === "function") {
1972
2047
  value(element);
1973
2048
  continue;
2049
+ } else {
2050
+ throw qError(32 /* invalidRefValue */, [currentFile]);
1974
2051
  }
1975
2052
  }
1976
2053
  if (isSignal(value)) {
@@ -1992,13 +2069,13 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1992
2069
  continue;
1993
2070
  }
1994
2071
  if (elementName === "textarea" && key2 === "value") {
1995
- if (typeof value !== "string") {
2072
+ if (value && typeof value !== "string") {
1996
2073
  if (import_build4.isDev) {
1997
- throw qError(40 /* wrongTextareaValue */);
2074
+ throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
1998
2075
  }
1999
2076
  continue;
2000
2077
  }
2001
- element.value = escapeHTML(value);
2078
+ element.value = escapeHTML(value || "");
2002
2079
  continue;
2003
2080
  }
2004
2081
  value = serializeAttribute(key2, value, scopedStyleIdPrefix);
@@ -2034,19 +2111,24 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2034
2111
  const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
2035
2112
  const jsxKey = jsx2.key;
2036
2113
  let needsQDispatchEventPatch = false;
2114
+ const currentFile = getFileLocationFromJsx(jsx2.dev);
2037
2115
  if (!isSameElementName || jsxKey !== getKey(vCurrent)) {
2038
2116
  vNewNode = retrieveChildWithKey(elementName, jsxKey);
2039
2117
  if (vNewNode === null) {
2040
2118
  needsQDispatchEventPatch = createNewElement(jsx2, elementName);
2041
2119
  } else {
2042
2120
  vnode_insertBefore(journal, vParent, vNewNode, vCurrent);
2121
+ vCurrent = vNewNode;
2122
+ vNewNode = null;
2123
+ if (vSiblings !== null) {
2124
+ vSiblingsIdx -= 3 /* Size */;
2125
+ }
2043
2126
  }
2044
2127
  }
2045
2128
  const jsxAttrs = [];
2046
2129
  const props = jsx2.varProps;
2047
2130
  for (const key in props) {
2048
- let value = props[key];
2049
- value = serializeAttribute(key, value, scopedStyleIdPrefix);
2131
+ const value = props[key];
2050
2132
  if (value != null) {
2051
2133
  mapArray_set(jsxAttrs, key, value, 0);
2052
2134
  }
@@ -2055,7 +2137,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2055
2137
  mapArray_set(jsxAttrs, ELEMENT_KEY, jsxKey, 0);
2056
2138
  }
2057
2139
  const vNode = vNewNode || vCurrent;
2058
- needsQDispatchEventPatch = setBulkProps(vNode, jsxAttrs) || needsQDispatchEventPatch;
2140
+ needsQDispatchEventPatch = setBulkProps(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch;
2059
2141
  if (needsQDispatchEventPatch) {
2060
2142
  const element = vnode_getNode(vNode);
2061
2143
  if (!element.qDispatchEvent) {
@@ -2078,7 +2160,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2078
2160
  }
2079
2161
  }
2080
2162
  }
2081
- function setBulkProps(vnode, srcAttrs) {
2163
+ function setBulkProps(vnode, srcAttrs, currentFile) {
2082
2164
  vnode_ensureElementInflated(vnode);
2083
2165
  const dstAttrs = vnode;
2084
2166
  let srcIdx = 0;
@@ -2101,12 +2183,18 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2101
2183
  } else if (typeof value === "function") {
2102
2184
  value(element);
2103
2185
  return;
2186
+ } else {
2187
+ throw qError(32 /* invalidRefValue */, [currentFile]);
2104
2188
  }
2105
2189
  }
2106
2190
  if (isSignal(value)) {
2107
- value = untrack(() => value.value);
2191
+ const signalData = new EffectPropData({
2192
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
2193
+ $isConst$: false
2194
+ });
2195
+ value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
2108
2196
  }
2109
- vnode_setAttr(journal, vnode, key, value);
2197
+ vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix));
2110
2198
  if (value === null) {
2111
2199
  dstLength = dstAttrs.length;
2112
2200
  }
@@ -2148,6 +2236,8 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2148
2236
  }
2149
2237
  srcIdx++;
2150
2238
  srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
2239
+ dstIdx++;
2240
+ dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
2151
2241
  } else if (srcKey == dstKey) {
2152
2242
  const srcValue = srcAttrs[srcIdx++];
2153
2243
  const dstValue = dstAttrs[dstIdx++];
@@ -2224,7 +2314,7 @@ var vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2224
2314
  vnode_insertBefore(
2225
2315
  journal,
2226
2316
  vParent,
2227
- vNewNode = vnode_newVirtual(),
2317
+ vNewNode,
2228
2318
  vCurrent && getInsertBefore()
2229
2319
  );
2230
2320
  return;
@@ -2422,7 +2512,7 @@ function cleanup(container, vNode) {
2422
2512
  const obj = seq[i];
2423
2513
  if (isTask(obj)) {
2424
2514
  const task = obj;
2425
- clearSubscriberEffectDependencies(task);
2515
+ clearSubscriberEffectDependencies(container, task);
2426
2516
  if (task.$flags$ & 1 /* VISIBLE_TASK */) {
2427
2517
  container.$scheduler$(48 /* CLEANUP_VISIBLE */, task);
2428
2518
  } else {
@@ -2533,7 +2623,7 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
2533
2623
  };
2534
2624
  chore.$promise$ = new Promise((resolve) => chore.$resolve$ = resolve);
2535
2625
  DEBUG2 && debugTrace("schedule", chore, currentChore, choreQueue);
2536
- chore = sortedInsert(choreQueue, chore);
2626
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
2537
2627
  if (!journalFlushScheduled && runLater) {
2538
2628
  journalFlushScheduled = true;
2539
2629
  schedule(16 /* JOURNAL_FLUSH */);
@@ -2542,10 +2632,10 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
2542
2632
  if (runLater) {
2543
2633
  return chore.$promise$;
2544
2634
  } else {
2545
- return drainUpTo(chore);
2635
+ return drainUpTo(chore, container.rootVNode || null);
2546
2636
  }
2547
2637
  }
2548
- function drainUpTo(runUptoChore) {
2638
+ function drainUpTo(runUptoChore, rootVNode) {
2549
2639
  if (runUptoChore.$executed$) {
2550
2640
  return runUptoChore.$returnValue$;
2551
2641
  }
@@ -2554,7 +2644,7 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
2554
2644
  }
2555
2645
  while (choreQueue.length) {
2556
2646
  const nextChore = choreQueue.shift();
2557
- const order = choreComparator(nextChore, runUptoChore, false);
2647
+ const order = choreComparator(nextChore, runUptoChore, rootVNode, false);
2558
2648
  if (order === null) {
2559
2649
  continue;
2560
2650
  }
@@ -2569,7 +2659,7 @@ var createScheduler = (container, scheduleDrain, journalFlush) => {
2569
2659
  }
2570
2660
  const returnValue = executeChore(nextChore);
2571
2661
  if (isPromise(returnValue)) {
2572
- const promise = returnValue.then(() => drainUpTo(runUptoChore));
2662
+ const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
2573
2663
  return promise;
2574
2664
  }
2575
2665
  }
@@ -2696,7 +2786,7 @@ var choreUpdate = (existing, newChore) => {
2696
2786
  function vNodeAlreadyDeleted(chore) {
2697
2787
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[0 /* flags */] & 32 /* Deleted */);
2698
2788
  }
2699
- function choreComparator(a, b, shouldThrowOnHostMismatch) {
2789
+ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
2700
2790
  const macroTypeDiff = (a.$type$ & 240 /* MACRO */) - (b.$type$ & 240 /* MACRO */);
2701
2791
  if (macroTypeDiff !== 0) {
2702
2792
  return macroTypeDiff;
@@ -2706,7 +2796,7 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
2706
2796
  const bHost = b.$host$;
2707
2797
  if (aHost !== bHost && aHost !== null && bHost !== null) {
2708
2798
  if (vnode_isVNode(aHost) && vnode_isVNode(bHost)) {
2709
- const hostDiff = vnode_documentPosition(aHost, bHost);
2799
+ const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
2710
2800
  if (hostDiff !== 0) {
2711
2801
  return hostDiff;
2712
2802
  }
@@ -2736,13 +2826,13 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
2736
2826
  }
2737
2827
  return 0;
2738
2828
  }
2739
- function sortedFindIndex(sortedArray, value) {
2829
+ function sortedFindIndex(sortedArray, value, rootVNode) {
2740
2830
  let bottom = 0;
2741
2831
  let top = sortedArray.length;
2742
2832
  while (bottom < top) {
2743
2833
  const middle = bottom + (top - bottom >> 1);
2744
2834
  const midChore = sortedArray[middle];
2745
- const comp = choreComparator(value, midChore, true);
2835
+ const comp = choreComparator(value, midChore, rootVNode, true);
2746
2836
  if (comp < 0) {
2747
2837
  top = middle;
2748
2838
  } else if (comp > 0) {
@@ -2753,8 +2843,8 @@ function sortedFindIndex(sortedArray, value) {
2753
2843
  }
2754
2844
  return ~bottom;
2755
2845
  }
2756
- function sortedInsert(sortedArray, value) {
2757
- const idx = sortedFindIndex(sortedArray, value);
2846
+ function sortedInsert(sortedArray, value, rootVNode) {
2847
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
2758
2848
  if (idx < 0) {
2759
2849
  sortedArray.splice(~idx, 0, value);
2760
2850
  return value;
@@ -2807,7 +2897,10 @@ var runTask = (task, container, host) => {
2807
2897
  cleanupTask(task);
2808
2898
  const iCtx = newInvokeContext(container.$locale$, host, void 0, TaskEvent);
2809
2899
  iCtx.$container$ = container;
2810
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(task));
2900
+ const taskFn = task.$qrl$.getFn(
2901
+ iCtx,
2902
+ () => clearSubscriberEffectDependencies(container, task)
2903
+ );
2811
2904
  const track = (obj, prop) => {
2812
2905
  const ctx = newInvokeContext();
2813
2906
  ctx.$effectSubscriber$ = [task, ":" /* COMPONENT */];
@@ -3226,7 +3319,7 @@ var WrappedSignal = class extends Signal {
3226
3319
  };
3227
3320
 
3228
3321
  // packages/qwik/src/core/version.ts
3229
- var version = "2.0.0-alpha.4-dev+374e0d6";
3322
+ var version = "2.0.0-alpha.5-dev+cb53bbd";
3230
3323
 
3231
3324
  // packages/qwik/src/core/shared/shared-container.ts
3232
3325
  var _SharedContainer = class {
@@ -4873,7 +4966,7 @@ var vnode_getNode = (vnode) => {
4873
4966
  assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node.");
4874
4967
  return vnode[4 /* node */];
4875
4968
  };
4876
- function vnode_toString(depth = 10, offset = "", materialize2 = false, siblings = false) {
4969
+ function vnode_toString(depth = 20, offset = "", materialize2 = false, siblings = false) {
4877
4970
  var _a;
4878
4971
  let vnode = this;
4879
4972
  if (depth === 0) {
@@ -5072,17 +5165,19 @@ var isElement = (node) => node && typeof node == "object" && fastNodeType(node)
5072
5165
  1;
5073
5166
  var aPath = [];
5074
5167
  var bPath = [];
5075
- var vnode_documentPosition = (a, b) => {
5168
+ var vnode_documentPosition = (a, b, rootVNode) => {
5076
5169
  if (a === b) {
5077
5170
  return 0;
5078
5171
  }
5079
5172
  let aDepth = -1;
5080
5173
  let bDepth = -1;
5081
5174
  while (a) {
5082
- a = (aPath[++aDepth] = a)[1 /* parent */];
5175
+ const vNode = aPath[++aDepth] = a;
5176
+ a = vNode[1 /* parent */] || rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id));
5083
5177
  }
5084
5178
  while (b) {
5085
- b = (bPath[++bDepth] = b)[1 /* parent */];
5179
+ const vNode = bPath[++bDepth] = b;
5180
+ b = vNode[1 /* parent */] || rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id));
5086
5181
  }
5087
5182
  while (aDepth >= 0 && bDepth >= 0) {
5088
5183
  a = aPath[aDepth];
@@ -5105,6 +5200,9 @@ var vnode_documentPosition = (a, b) => {
5105
5200
  return -1;
5106
5201
  }
5107
5202
  } while (cursor);
5203
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
5204
+ return -1;
5205
+ }
5108
5206
  return 1;
5109
5207
  }
5110
5208
  }
@@ -5114,8 +5212,11 @@ var vnode_getProjectionParentComponent = (vHost, rootVNode) => {
5114
5212
  let projectionDepth = 1;
5115
5213
  while (projectionDepth--) {
5116
5214
  while (vHost && (vnode_isVirtualVNode(vHost) ? vnode_getProp(vHost, OnRenderProp, null) === null : true)) {
5117
- const qSlotParentProp = vnode_getProp(vHost, QSlotParent, null);
5118
- const qSlotParent = qSlotParentProp && (typeof qSlotParentProp === "string" ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
5215
+ const qSlotParent = vnode_getProp(
5216
+ vHost,
5217
+ QSlotParent,
5218
+ (id) => vnode_locate(rootVNode, id)
5219
+ );
5119
5220
  const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
5120
5221
  if (vProjectionParent) {
5121
5222
  projectionDepth++;
@@ -5665,13 +5766,11 @@ var DomContainer = class extends _SharedContainer {
5665
5766
  if (vnode_getProp(vNode, OnRenderProp, null) !== null) {
5666
5767
  return vNode;
5667
5768
  }
5668
- const parent = vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
5669
- if (parent) {
5670
- vNode = parent;
5671
- continue;
5672
- }
5769
+ vNode = vnode_getParent(vNode) || // If virtual node, than it could be a slot so we need to read its parent.
5770
+ vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
5771
+ } else {
5772
+ vNode = vnode_getParent(vNode);
5673
5773
  }
5674
- vNode = vnode_getParent(vNode);
5675
5774
  }
5676
5775
  return null;
5677
5776
  }
@@ -5774,10 +5873,6 @@ var DomContainer = class extends _SharedContainer {
5774
5873
 
5775
5874
  // packages/qwik/src/core/shared/shared-serialization.ts
5776
5875
  var deserializedProxyMap = /* @__PURE__ */ new WeakMap();
5777
- var unwrapDeserializerProxy = (value) => {
5778
- const unwrapped = typeof value === "object" && value !== null && value[SERIALIZER_PROXY_UNWRAP];
5779
- return unwrapped ? unwrapped : value;
5780
- };
5781
5876
  var isDeserializerProxy = (value) => {
5782
5877
  return typeof value === "object" && value !== null && SERIALIZER_PROXY_UNWRAP in value;
5783
5878
  };
@@ -5819,13 +5914,13 @@ var DeserializationHandler = class {
5819
5914
  return value;
5820
5915
  }
5821
5916
  const container = this.$container$;
5822
- const propValue = allocate(container, typeId, value);
5917
+ let propValue = allocate(container, typeId, value);
5918
+ if (typeId >= 12 /* Error */) {
5919
+ propValue = inflate(container, propValue, typeId, value);
5920
+ }
5823
5921
  Reflect.set(target, property, propValue);
5824
5922
  this.$data$[idx] = void 0;
5825
5923
  this.$data$[idx + 1] = propValue;
5826
- if (typeId >= 12 /* Error */) {
5827
- inflate(container, propValue, typeId, value);
5828
- }
5829
5924
  return propValue;
5830
5925
  }
5831
5926
  has(target, property) {
@@ -5860,7 +5955,7 @@ var resolvers = /* @__PURE__ */ new WeakMap();
5860
5955
  var inflate = (container, target, typeId, data) => {
5861
5956
  var _a;
5862
5957
  if (typeId === void 0) {
5863
- return;
5958
+ return target;
5864
5959
  }
5865
5960
  if (typeId !== 13 /* Object */ && Array.isArray(data)) {
5866
5961
  data = _eagerDeserializeArray(container, data);
@@ -5931,14 +6026,13 @@ var inflate = (container, target, typeId, data) => {
5931
6026
  case 25 /* Store */:
5932
6027
  case 26 /* StoreArray */: {
5933
6028
  const [value, flags, effects2, storeEffect] = data;
5934
- const handler = getStoreHandler(target);
5935
- handler.$flags$ = flags;
5936
- Object.assign(getStoreTarget(target), value);
6029
+ const store = getOrCreateStore(value, flags, container);
6030
+ const storeHandler = getStoreHandler(store);
5937
6031
  if (storeEffect) {
5938
6032
  effects2[STORE_ARRAY_PROP] = storeEffect;
5939
6033
  }
5940
- handler.$effects$ = effects2;
5941
- container.$storeProxyMap$.set(value, target);
6034
+ storeHandler.$effects$ = effects2;
6035
+ target = store;
5942
6036
  break;
5943
6037
  }
5944
6038
  case 22 /* Signal */: {
@@ -6060,6 +6154,7 @@ var inflate = (container, target, typeId, data) => {
6060
6154
  default:
6061
6155
  throw qError(33 /* serializeErrorNotImplemented */, [typeId]);
6062
6156
  }
6157
+ return target;
6063
6158
  };
6064
6159
  var _constants = [
6065
6160
  void 0,
@@ -6127,9 +6222,8 @@ var allocate = (container, typeId, value) => {
6127
6222
  case 24 /* ComputedSignal */:
6128
6223
  return new ComputedSignal(container, null);
6129
6224
  case 25 /* Store */:
6130
- return createStore(container, {}, 0);
6131
6225
  case 26 /* StoreArray */:
6132
- return createStore(container, [], 0);
6226
+ return null;
6133
6227
  case 11 /* URLSearchParams */:
6134
6228
  return new URLSearchParams(value);
6135
6229
  case 27 /* FormData */:
@@ -6781,15 +6875,15 @@ function qrlToString(serializationContext, value) {
6781
6875
  }
6782
6876
  return qrlStringInline;
6783
6877
  }
6784
- function deserializeData(container, typeId, propValue) {
6878
+ function deserializeData(container, typeId, value) {
6785
6879
  if (typeId === void 0) {
6786
- return propValue;
6880
+ return value;
6787
6881
  }
6788
- const value = allocate(container, typeId, propValue);
6882
+ let propValue = allocate(container, typeId, value);
6789
6883
  if (typeId >= 12 /* Error */) {
6790
- inflate(container, value, typeId, propValue);
6884
+ propValue = inflate(container, propValue, typeId, value);
6791
6885
  }
6792
- return value;
6886
+ return propValue;
6793
6887
  }
6794
6888
  function shouldTrackObj(obj) {
6795
6889
  return (
@@ -7533,7 +7627,7 @@ var SsrComponentFrame = class {
7533
7627
  if ((0, import_core2._isJSXNode)(children)) {
7534
7628
  const slotName = this.getSlotName(children);
7535
7629
  mapArray_set(this.slots, slotName, children, 0);
7536
- } else if (Array.isArray(children)) {
7630
+ } else if (Array.isArray(children) && children.length > 0) {
7537
7631
  const defaultSlot = [];
7538
7632
  for (let i = 0; i < children.length; i++) {
7539
7633
  const child = children[i];
@@ -7548,7 +7642,7 @@ var SsrComponentFrame = class {
7548
7642
  defaultSlot.push(child);
7549
7643
  }
7550
7644
  }
7551
- defaultSlot.length && mapArray_set(this.slots, QDefaultSlot, defaultSlot, 0);
7645
+ defaultSlot.length > 0 && mapArray_set(this.slots, QDefaultSlot, defaultSlot, 0);
7552
7646
  } else {
7553
7647
  mapArray_set(this.slots, QDefaultSlot, children, 0);
7554
7648
  }
@@ -8165,12 +8259,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
8165
8259
  this.write("<");
8166
8260
  this.write(elementName);
8167
8261
  if (varAttrs) {
8168
- innerHTML = this.writeAttrs(elementName, varAttrs, false);
8262
+ innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
8169
8263
  }
8170
8264
  this.write(" " + Q_PROPS_SEPARATOR);
8171
8265
  import_build10.isDev && this.write('=""');
8172
8266
  if (constAttrs && constAttrs.length) {
8173
- innerHTML = this.writeAttrs(elementName, constAttrs, true) || innerHTML;
8267
+ innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
8174
8268
  }
8175
8269
  this.write(">");
8176
8270
  this.lastNode = null;
@@ -8245,14 +8339,10 @@ var SSRContainer = class extends import_core4._SharedContainer {
8245
8339
  }
8246
8340
  }
8247
8341
  openProjection(attrs) {
8248
- var _a;
8249
8342
  this.openFragment(attrs);
8250
- const vNode = (_a = this.currentElementFrame) == null ? void 0 : _a.vNodeData;
8251
- if (vNode) {
8252
- vNode[0] |= 16 /* SERIALIZE */;
8253
- }
8254
8343
  const componentFrame = this.getComponentFrame();
8255
8344
  if (componentFrame) {
8345
+ this.serializationCtx.$addRoot$(componentFrame.componentNode);
8256
8346
  componentFrame.projectionDepth++;
8257
8347
  }
8258
8348
  }
@@ -8818,7 +8908,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
8818
8908
  this.write(element);
8819
8909
  }
8820
8910
  }
8821
- writeAttrs(tag, attrs, isConst) {
8911
+ writeAttrs(tag, attrs, isConst, currentFile) {
8822
8912
  let innerHTML = void 0;
8823
8913
  if (attrs.length) {
8824
8914
  for (let i = 0; i < attrs.length; i++) {
@@ -8845,7 +8935,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
8845
8935
  value(new DomRef(lastNode));
8846
8936
  continue;
8847
8937
  } else {
8848
- throw qError(32 /* invalidRefValue */);
8938
+ throw qError(32 /* invalidRefValue */, [currentFile]);
8849
8939
  }
8850
8940
  }
8851
8941
  if ((0, import_core4.isSignal)(value)) {
@@ -8865,13 +8955,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
8865
8955
  }
8866
8956
  }
8867
8957
  if (tag === "textarea" && key === "value") {
8868
- if (typeof value !== "string") {
8958
+ if (value && typeof value !== "string") {
8869
8959
  if (import_build10.isDev) {
8870
- throw qError(40 /* wrongTextareaValue */);
8960
+ throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
8871
8961
  }
8872
8962
  continue;
8873
8963
  }
8874
- innerHTML = escapeHTML(value);
8964
+ innerHTML = escapeHTML(value || "");
8875
8965
  key = QContainerAttr;
8876
8966
  value = "text" /* TEXT */;
8877
8967
  }