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

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-alpha.4-dev+374e0d6
3
+ * @qwik.dev/core 2.0.0-alpha.6-dev+d848ba5
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
@@ -104,10 +104,9 @@ var QError;
104
104
  QError[QError.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError[QError.wrongTextareaValue = 40] = "wrongTextareaValue",
105
105
  QError[QError.containerNotFound = 41] = "containerNotFound", QError[QError.elementWithoutContainer = 42] = "elementWithoutContainer",
106
106
  QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
107
- QError[QError.serverHostMismatch = 45] = "serverHostMismatch", QError[QError.cannotCoerceSignal = 46] = "cannotCoerceSignal",
108
- QError[QError.computedNotSync = 47] = "computedNotSync", QError[QError.computedReadOnly = 48] = "computedReadOnly",
109
- QError[QError.wrappedReadOnly = 49] = "wrappedReadOnly", QError[QError.promisesNotExpected = 50] = "promisesNotExpected",
110
- QError[QError.unsafeAttr = 51] = "unsafeAttr";
107
+ QError[QError.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError[QError.computedNotSync = 46] = "computedNotSync",
108
+ QError[QError.computedReadOnly = 47] = "computedReadOnly", QError[QError.wrappedReadOnly = 48] = "wrappedReadOnly",
109
+ QError[QError.promisesNotExpected = 49] = "promisesNotExpected", QError[QError.unsafeAttr = 50] = "unsafeAttr";
111
110
  }(QError || (QError = {}));
112
111
 
113
112
  const qError = (code, errorMessageArgs = []) => {
@@ -115,117 +114,6 @@ const qError = (code, errorMessageArgs = []) => {
115
114
  return logErrorAndStop(text, ...errorMessageArgs);
116
115
  };
117
116
 
118
- const createPlatform = () => ({
119
- isServer,
120
- importSymbol(containerEl, url, symbolName) {
121
- if (isServer) {
122
- const hash = getSymbolHash(symbolName);
123
- const regSym = globalThis.__qwik_reg_symbols?.get(hash);
124
- if (regSym) {
125
- return regSym;
126
- }
127
- }
128
- if (!url) {
129
- throw qError(QError.qrlMissingChunk, [ symbolName ]);
130
- }
131
- if (!containerEl) {
132
- throw qError(QError.qrlMissingContainer, [ url, symbolName ]);
133
- }
134
- const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
135
- const urlCopy = new URL(urlDoc);
136
- urlCopy.hash = "";
137
- return import(urlCopy.href).then((mod => mod[symbolName]));
138
- },
139
- raf: fn => new Promise((resolve => {
140
- requestAnimationFrame((() => {
141
- resolve(fn());
142
- }));
143
- })),
144
- nextTick: fn => new Promise((resolve => {
145
- setTimeout((() => {
146
- resolve(fn());
147
- }));
148
- })),
149
- chunkForSymbol: (symbolName, chunk) => [ symbolName, chunk ?? "_" ]
150
- });
151
-
152
- const toUrl = (doc, containerEl, url) => {
153
- const baseURI = doc.baseURI;
154
- const base = new URL(containerEl.getAttribute("q:base") ?? baseURI, baseURI);
155
- return new URL(url, base);
156
- };
157
-
158
- let _platform = /*#__PURE__ */ createPlatform();
159
-
160
- const setPlatform = plt => _platform = plt;
161
-
162
- const getPlatform = () => _platform;
163
-
164
- const isServerPlatform = () => _platform.isServer;
165
-
166
- const isNode = value => value && "number" == typeof value.nodeType;
167
-
168
- const isDocument = value => 9 === value.nodeType;
169
-
170
- const isElement$1 = value => 1 === value.nodeType;
171
-
172
- const MAX_RETRY_ON_PROMISE_COUNT = 100;
173
-
174
- const isPromise = value => !!value && "object" == typeof value && "function" == typeof value.then;
175
-
176
- const safeCall = (call, thenFn, rejectFn) => {
177
- try {
178
- const result = call();
179
- return isPromise(result) ? result.then(thenFn, rejectFn) : thenFn(result);
180
- } catch (e) {
181
- return rejectFn(e);
182
- }
183
- };
184
-
185
- const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
186
-
187
- const maybeThenPassError = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
188
-
189
- const shouldNotError = reason => {
190
- throwErrorAndStop(reason);
191
- };
192
-
193
- const delay = timeout => new Promise((resolve => {
194
- setTimeout(resolve, timeout);
195
- }));
196
-
197
- function retryOnPromise(fn, retryCount = 0) {
198
- try {
199
- return fn();
200
- } catch (e) {
201
- if (isPromise(e) && retryCount < 100) {
202
- return e.then(retryOnPromise.bind(null, fn, retryCount++));
203
- }
204
- throw e;
205
- }
206
- }
207
-
208
- const isSerializableObject = v => {
209
- const proto = Object.getPrototypeOf(v);
210
- return proto === Object.prototype || proto === Array.prototype || null === proto;
211
- };
212
-
213
- const isObject = v => !!v && "object" == typeof v;
214
-
215
- const isArray = v => Array.isArray(v);
216
-
217
- const isString = v => "string" == typeof v;
218
-
219
- const isFunction = v => "function" == typeof v;
220
-
221
- var VNodeDataFlag;
222
-
223
- !function(VNodeDataFlag) {
224
- VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
225
- VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.ELEMENT_NODE = 4] = "ELEMENT_NODE",
226
- VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
227
- }(VNodeDataFlag || (VNodeDataFlag = {}));
228
-
229
117
  const DEBUG_TYPE = "q:type";
230
118
 
231
119
  var VirtualType;
@@ -357,6 +245,115 @@ const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
357
245
 
358
246
  const qwikInspectorAttr = "data-qwik-inspector";
359
247
 
248
+ const createPlatform = () => ({
249
+ isServer,
250
+ importSymbol(containerEl, url, symbolName) {
251
+ if (isServer) {
252
+ const hash = getSymbolHash(symbolName);
253
+ const regSym = globalThis.__qwik_reg_symbols?.get(hash);
254
+ if (regSym) {
255
+ return regSym;
256
+ }
257
+ }
258
+ if (!url) {
259
+ throw qError(QError.qrlMissingChunk, [ symbolName ]);
260
+ }
261
+ if (!containerEl) {
262
+ throw qError(QError.qrlMissingContainer, [ url, symbolName ]);
263
+ }
264
+ const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
265
+ const urlCopy = new URL(urlDoc);
266
+ urlCopy.hash = "";
267
+ return import(urlCopy.href).then((mod => mod[symbolName]));
268
+ },
269
+ raf: fn => new Promise((resolve => {
270
+ requestAnimationFrame((() => {
271
+ resolve(fn());
272
+ }));
273
+ })),
274
+ nextTick: fn => new Promise((resolve => {
275
+ setTimeout((() => {
276
+ resolve(fn());
277
+ }));
278
+ })),
279
+ chunkForSymbol: (symbolName, chunk) => [ symbolName, chunk ?? "_" ]
280
+ });
281
+
282
+ const toUrl = (doc, containerEl, url) => {
283
+ const baseURI = doc.baseURI;
284
+ const base = new URL(containerEl.getAttribute("q:base") ?? baseURI, baseURI);
285
+ return new URL(url, base);
286
+ };
287
+
288
+ let _platform = /*#__PURE__ */ createPlatform();
289
+
290
+ const setPlatform = plt => _platform = plt;
291
+
292
+ const getPlatform = () => _platform;
293
+
294
+ const isServerPlatform = () => _platform.isServer;
295
+
296
+ const isNode = value => value && "number" == typeof value.nodeType;
297
+
298
+ const isDocument = value => 9 === value.nodeType;
299
+
300
+ const isElement$1 = value => 1 === value.nodeType;
301
+
302
+ const MAX_RETRY_ON_PROMISE_COUNT = 100;
303
+
304
+ const isPromise = value => !!value && "object" == typeof value && "function" == typeof value.then;
305
+
306
+ const safeCall = (call, thenFn, rejectFn) => {
307
+ try {
308
+ const result = call();
309
+ return isPromise(result) ? result.then(thenFn, rejectFn) : thenFn(result);
310
+ } catch (e) {
311
+ return rejectFn(e);
312
+ }
313
+ };
314
+
315
+ const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
316
+
317
+ const maybeThenPassError = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
318
+
319
+ const shouldNotError = reason => {
320
+ throwErrorAndStop(reason);
321
+ };
322
+
323
+ const delay = timeout => new Promise((resolve => {
324
+ setTimeout(resolve, timeout);
325
+ }));
326
+
327
+ function retryOnPromise(fn, retryCount = 0) {
328
+ const retryOrThrow = e => {
329
+ if (isPromise(e) && retryCount < 100) {
330
+ return e.then(retryOnPromise.bind(null, fn, retryCount++));
331
+ }
332
+ throw e;
333
+ };
334
+ try {
335
+ const result = fn();
336
+ return isPromise(result) ? result.catch((e => retryOrThrow(e))) : result;
337
+ } catch (e) {
338
+ return retryOrThrow(e);
339
+ }
340
+ }
341
+
342
+ const isSerializableObject = v => {
343
+ const proto = Object.getPrototypeOf(v);
344
+ return proto === Object.prototype || proto === Array.prototype || null === proto;
345
+ };
346
+
347
+ const isObject = v => !!v && "object" == typeof v;
348
+
349
+ const isArray = v => Array.isArray(v);
350
+
351
+ const isString = v => "string" == typeof v;
352
+
353
+ const isFunction = v => "function" == typeof v;
354
+
355
+ var VNodeDataFlag;
356
+
360
357
  let _locale;
361
358
 
362
359
  function getLocale(defaultLocale) {
@@ -386,6 +383,12 @@ function setLocale(locale) {
386
383
  _locale = locale;
387
384
  }
388
385
 
386
+ !function(VNodeDataFlag) {
387
+ VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
388
+ VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.ELEMENT_NODE = 4] = "ELEMENT_NODE",
389
+ VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
390
+ }(VNodeDataFlag || (VNodeDataFlag = {}));
391
+
389
392
  const isQrl$1 = value => "function" == typeof value && "function" == typeof value.getSymbol;
390
393
 
391
394
  const EMPTY_ARRAY = [];
@@ -717,7 +720,7 @@ class StoreHandler {
717
720
  return this.$flags$ & StoreFlags.RECURSIVE && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
718
721
  }
719
722
  set(target, prop, value) {
720
- if (target = unwrapDeserializerProxy(target), "symbol" == typeof prop) {
723
+ if ("symbol" == typeof prop) {
721
724
  return target[prop] = value, !0;
722
725
  }
723
726
  const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
@@ -762,7 +765,8 @@ class StoreHandler {
762
765
  function addEffect(target, prop, store, effectSubscriber) {
763
766
  const effectsMap = store.$effects$ ||= {};
764
767
  const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
765
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target);
768
+ ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target),
769
+ ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], target, store.$container$);
766
770
  }
767
771
 
768
772
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
@@ -806,26 +810,35 @@ function clearVNodeEffectDependencies(container, value) {
806
810
  const effects = vnode_getProp(value, "q:subs", container.$getObjectById$);
807
811
  if (effects) {
808
812
  for (let i = effects.length - 1; i >= 0; i--) {
809
- clearEffects(effects[i], value) && effects.splice(i, 1);
813
+ clearEffects(effects[i], value, effects, i, container);
810
814
  }
815
+ 0 === effects.length && vnode_setProp(value, "q:subs", null);
811
816
  }
812
817
  }
813
818
 
814
- function clearSubscriberEffectDependencies(value) {
819
+ function clearSubscriberEffectDependencies(container, value) {
815
820
  if (value.$effectDependencies$) {
816
821
  for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
817
- clearEffects(value.$effectDependencies$[i], value) && value.$effectDependencies$.splice(i, 1);
822
+ clearEffects(value.$effectDependencies$[i], value, value.$effectDependencies$, i, container);
818
823
  }
824
+ 0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
819
825
  }
820
826
  }
821
827
 
822
- function clearEffects(subscriber, value) {
823
- if (!isSignal(subscriber)) {
824
- return !1;
825
- }
828
+ function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
829
+ let subscriptionRemoved = !1;
830
+ const seenSet = new Set;
831
+ if (subscriber instanceof WrappedSignal) {
832
+ subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
833
+ } else if (container.$storeProxyMap$.has(subscriber)) {
834
+ const store = container.$storeProxyMap$.get(subscriber);
835
+ subscriptionRemoved = clearStoreEffects(getStoreHandler(store), value);
836
+ }
837
+ subscriptionRemoved && effectArray.splice(indexToRemove, 1);
838
+ }
839
+
840
+ function clearSignalEffects(subscriber, value, seenSet) {
826
841
  const effectSubscriptions = subscriber.$effects$;
827
- const hostElement = subscriber.$hostElement$;
828
- hostElement && hostElement === value && (subscriber.$hostElement$ = null);
829
842
  let subscriptionRemoved = !1;
830
843
  if (effectSubscriptions) {
831
844
  for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
@@ -833,15 +846,66 @@ function clearEffects(subscriber, value) {
833
846
  subscriptionRemoved = !0);
834
847
  }
835
848
  }
836
- const args = subscriber.$args$;
837
- if (args) {
838
- for (let i = args.length - 1; i >= 0; i--) {
839
- clearEffects(args[i], subscriber);
849
+ if (subscriber instanceof WrappedSignal) {
850
+ const hostElement = subscriber.$hostElement$;
851
+ hostElement && hostElement === value && (subscriber.$hostElement$ = null);
852
+ const args = subscriber.$args$;
853
+ args && clearArgsEffects(args, subscriber, seenSet);
854
+ }
855
+ return subscriptionRemoved;
856
+ }
857
+
858
+ function clearStoreEffects(storeHandler, value) {
859
+ const effectSubscriptions = storeHandler.$effects$;
860
+ if (!effectSubscriptions) {
861
+ return !1;
862
+ }
863
+ let subscriptionRemoved = !1;
864
+ for (const key in effectSubscriptions) {
865
+ const effects = effectSubscriptions[key];
866
+ for (let i = effects.length - 1; i >= 0; i--) {
867
+ effects[i][EffectSubscriptionsProp.EFFECT] === value && (effects.splice(i, 1), subscriptionRemoved = !0);
840
868
  }
869
+ 0 === effects.length && delete effectSubscriptions[key];
841
870
  }
842
871
  return subscriptionRemoved;
843
872
  }
844
873
 
874
+ function clearArgsEffects(args, subscriber, seenSet) {
875
+ for (let i = args.length - 1; i >= 0; i--) {
876
+ clearArgEffect(args[i], subscriber, seenSet);
877
+ }
878
+ }
879
+
880
+ function clearArgEffect(arg, subscriber, seenSet) {
881
+ if (!seenSet.has(arg)) {
882
+ if (seenSet.add(arg), isSignal(arg)) {
883
+ clearSignalEffects(arg, subscriber, seenSet);
884
+ } else if ("object" == typeof arg && null !== arg) {
885
+ if (isStore(arg)) {
886
+ clearStoreEffects(getStoreHandler(arg), subscriber);
887
+ } else if (isPropsProxy(arg)) {
888
+ const constProps = arg[_CONST_PROPS];
889
+ const varProps = arg[_VAR_PROPS];
890
+ if (constProps) {
891
+ for (const key in constProps) {
892
+ clearArgEffect(constProps[key], subscriber, seenSet);
893
+ }
894
+ }
895
+ for (const key in varProps) {
896
+ clearArgEffect(varProps[key], subscriber, seenSet);
897
+ }
898
+ } else {
899
+ for (const key in arg) {
900
+ clearArgEffect(arg[key], subscriber, seenSet);
901
+ }
902
+ }
903
+ } else {
904
+ Array.isArray(arg) && clearArgsEffects(arg, subscriber, seenSet);
905
+ }
906
+ }
907
+ }
908
+
845
909
  const useResourceQrl = (qrl, opts) => {
846
910
  const {val, set, i, iCtx} = useSequentialScope();
847
911
  if (null != val) {
@@ -861,7 +925,18 @@ function getResourceValueAsPromise(props) {
861
925
  if (isResourceReturn(resource)) {
862
926
  if (!isServerPlatform()) {
863
927
  const state = resource._state;
864
- return "pending" === state && props.onPending ? Promise.resolve(props.onPending()) : "rejected" === state && props.onRejected ? Promise.resolve(resource._error).then(props.onRejected) : Promise.resolve(untrack((() => resource._resolved))).then(props.onResolved);
928
+ if ("pending" === state && props.onPending) {
929
+ return Promise.resolve().then(useBindInvokeContext(props.onPending));
930
+ }
931
+ if ("rejected" === state && props.onRejected) {
932
+ return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
933
+ }
934
+ {
935
+ const resolvedValue = untrack((() => resource._resolved));
936
+ if (void 0 !== resolvedValue) {
937
+ return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
938
+ }
939
+ }
865
940
  }
866
941
  return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
867
942
  }
@@ -890,7 +965,7 @@ const runResource = (task, container, host) => {
890
965
  task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
891
966
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
892
967
  iCtx.$container$ = container;
893
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
968
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
894
969
  const resource = task.$state$;
895
970
  assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
896
971
  const cleanups = [];
@@ -1299,6 +1374,14 @@ function escapeHTML(html) {
1299
1374
  return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
1300
1375
  }
1301
1376
 
1377
+ function getFileLocationFromJsx(jsxDev) {
1378
+ if (!jsxDev) {
1379
+ return null;
1380
+ }
1381
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
1382
+ return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
1383
+ }
1384
+
1302
1385
  const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1303
1386
  let journal = container.$journal$;
1304
1387
  const stack = [];
@@ -1459,7 +1542,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1459
1542
  advanceToNextSibling(), vnode_remove(journal, vParent, toRemove, !0);
1460
1543
  }
1461
1544
  }
1462
- function createNewElement(jsx, elementName) {
1545
+ function createNewElement(jsx, elementName, currentFile) {
1463
1546
  const element = function(elementName) {
1464
1547
  const domParentVNode = vnode_getDomParentVNode(vParent);
1465
1548
  const {elementNamespace, elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, elementName);
@@ -1487,6 +1570,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1487
1570
  value(element);
1488
1571
  continue;
1489
1572
  }
1573
+ throw qError(QError.invalidRefValue, [ currentFile ]);
1490
1574
  }
1491
1575
  if (isSignal(value)) {
1492
1576
  const signalData = new EffectPropData({
@@ -1499,13 +1583,13 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1499
1583
  if ("textarea" !== elementName || "value" !== key) {
1500
1584
  value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && element.setAttribute(key, String(value));
1501
1585
  } else {
1502
- if ("string" != typeof value) {
1586
+ if (value && "string" != typeof value) {
1503
1587
  if (isDev) {
1504
- throw qError(QError.wrongTextareaValue);
1588
+ throw qError(QError.wrongTextareaValue, [ currentFile, value ]);
1505
1589
  }
1506
1590
  continue;
1507
1591
  }
1508
- element.value = escapeHTML(value);
1592
+ element.value = escapeHTML(value || "");
1509
1593
  }
1510
1594
  } else {
1511
1595
  element.innerHTML = value, element.setAttribute("q:container", QContainerValue.HTML);
@@ -1522,17 +1606,19 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1522
1606
  const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
1523
1607
  const jsxKey = jsx.key;
1524
1608
  let needsQDispatchEventPatch = !1;
1609
+ const currentFile = getFileLocationFromJsx(jsx.dev);
1525
1610
  isSameElementName && jsxKey === getKey(vCurrent) || (vNewNode = retrieveChildWithKey(elementName, jsxKey),
1526
- null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx, elementName) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent));
1611
+ null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx, elementName) : (vnode_insertBefore(journal, vParent, vNewNode, vCurrent),
1612
+ vCurrent = vNewNode, vNewNode = null, null !== vSiblings && (vSiblingsIdx -= SiblingsArray.Size)));
1527
1613
  const jsxAttrs = [];
1528
1614
  const props = jsx.varProps;
1529
1615
  for (const key in props) {
1530
- let value = props[key];
1531
- value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && mapArray_set(jsxAttrs, key, value, 0);
1616
+ const value = props[key];
1617
+ null != value && mapArray_set(jsxAttrs, key, value, 0);
1532
1618
  }
1533
1619
  null !== jsxKey && mapArray_set(jsxAttrs, "q:key", jsxKey, 0);
1534
1620
  const vNode = vNewNode || vCurrent;
1535
- if (needsQDispatchEventPatch = function(vnode, srcAttrs) {
1621
+ if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile) {
1536
1622
  vnode_ensureElementInflated(vnode);
1537
1623
  const dstAttrs = vnode;
1538
1624
  let srcIdx = 0;
@@ -1554,8 +1640,16 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1554
1640
  if ("function" == typeof value) {
1555
1641
  return void value(element);
1556
1642
  }
1643
+ throw qError(QError.invalidRefValue, [ currentFile ]);
1644
+ }
1645
+ if (isSignal(value)) {
1646
+ const signalData = new EffectPropData({
1647
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1648
+ $isConst$: !1
1649
+ });
1650
+ value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
1557
1651
  }
1558
- isSignal(value) && (value = untrack((() => value.value))), vnode_setAttr(journal, vnode, key, value),
1652
+ vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix)),
1559
1653
  null === value && (dstLength = dstAttrs.length);
1560
1654
  }
1561
1655
  };
@@ -1576,7 +1670,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1576
1670
  dstIdx--), dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1577
1671
  } else if (null == dstKey) {
1578
1672
  isJsxPropertyAnEventName(srcKey) ? (patchEventDispatch = !0, recordJsxEvent(srcKey, srcAttrs[srcIdx])) : record(srcKey, srcAttrs[srcIdx]),
1579
- srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
1673
+ srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1580
1674
  } else if (srcKey == dstKey) {
1581
1675
  const srcValue = srcAttrs[srcIdx++];
1582
1676
  srcValue !== dstAttrs[dstIdx++] && record(dstKey, srcValue), srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null,
@@ -1589,7 +1683,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1589
1683
  }
1590
1684
  }
1591
1685
  return patchEventDispatch;
1592
- }(vNode, jsxAttrs) || needsQDispatchEventPatch, needsQDispatchEventPatch) {
1686
+ }(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch, needsQDispatchEventPatch) {
1593
1687
  const element = vnode_getNode(vNode);
1594
1688
  element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
1595
1689
  const eventName = event.type;
@@ -1633,7 +1727,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1633
1727
  function expectVirtual(type, jsxKey) {
1634
1728
  vCurrent && vnode_isVirtualVNode(vCurrent) && getKey(vCurrent) === jsxKey || (null === jsxKey || (vNewNode = retrieveChildWithKey(null, jsxKey),
1635
1729
  null == vNewNode) ? (vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()),
1636
- vnode_setProp(vNewNode, "q:key", jsxKey), isDev && vnode_setProp(vNewNode || vCurrent, "q:type", type)) : vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()));
1730
+ vnode_setProp(vNewNode, "q:key", jsxKey), isDev && vnode_setProp(vNewNode || vCurrent, "q:type", type)) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent && getInsertBefore()));
1637
1731
  }
1638
1732
  function expectComponent(component) {
1639
1733
  const componentMeta = component[SERIALIZABLE_STATE];
@@ -1775,7 +1869,7 @@ function cleanup(container, vNode) {
1775
1869
  const obj = seq[i];
1776
1870
  if (isTask(obj)) {
1777
1871
  const task = obj;
1778
- clearSubscriberEffectDependencies(task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1872
+ clearSubscriberEffectDependencies(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1779
1873
  }
1780
1874
  }
1781
1875
  }
@@ -1875,6 +1969,68 @@ const createComputedQrl = createComputedSignal;
1875
1969
 
1876
1970
  const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
1877
1971
 
1972
+ const aVNodePath = [];
1973
+
1974
+ const bVNodePath = [];
1975
+
1976
+ const vnode_documentPosition = (a, b, rootVNode) => {
1977
+ if (a === b) {
1978
+ return 0;
1979
+ }
1980
+ let aDepth = -1;
1981
+ let bDepth = -1;
1982
+ for (;a; ) {
1983
+ a = (aVNodePath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, ":", (id => vnode_locate(rootVNode, id)));
1984
+ }
1985
+ for (;b; ) {
1986
+ b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id)));
1987
+ }
1988
+ for (;aDepth >= 0 && bDepth >= 0; ) {
1989
+ if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
1990
+ let cursor = b;
1991
+ do {
1992
+ if (cursor = vnode_getNextSibling(cursor), cursor === a) {
1993
+ return 1;
1994
+ }
1995
+ } while (cursor);
1996
+ cursor = b;
1997
+ do {
1998
+ if (cursor = vnode_getPreviousSibling(cursor), cursor === a) {
1999
+ return -1;
2000
+ }
2001
+ } while (cursor);
2002
+ return rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
2003
+ }
2004
+ aDepth--, bDepth--;
2005
+ }
2006
+ return aDepth < bDepth ? -1 : 1;
2007
+ };
2008
+
2009
+ const aSsrNodePath = [];
2010
+
2011
+ const bSsrNodePath = [];
2012
+
2013
+ const ssrNodeDocumentPosition = (a, b) => {
2014
+ if (a === b) {
2015
+ return 0;
2016
+ }
2017
+ let aDepth = -1;
2018
+ let bDepth = -1;
2019
+ for (;a; ) {
2020
+ a = (aSsrNodePath[++aDepth] = a).currentComponentNode;
2021
+ }
2022
+ for (;b; ) {
2023
+ b = (bSsrNodePath[++bDepth] = b).currentComponentNode;
2024
+ }
2025
+ for (;aDepth >= 0 && bDepth >= 0; ) {
2026
+ if ((a = aSsrNodePath[aDepth]) !== (b = bSsrNodePath[bDepth])) {
2027
+ return 1;
2028
+ }
2029
+ aDepth--, bDepth--;
2030
+ }
2031
+ return aDepth < bDepth ? -1 : 1;
2032
+ };
2033
+
1878
2034
  var ChoreType;
1879
2035
 
1880
2036
  !function(ChoreType) {
@@ -1906,12 +2062,12 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
1906
2062
  $returnValue$: null,
1907
2063
  $executed$: !1
1908
2064
  };
1909
- chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve)), chore = sortedInsert(choreQueue, chore),
2065
+ chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve)), chore = sortedInsert(choreQueue, chore, container.rootVNode || null),
1910
2066
  !journalFlushScheduled && runLater && (journalFlushScheduled = !0, schedule(ChoreType.JOURNAL_FLUSH),
1911
2067
  scheduleDrain());
1912
- return runLater ? chore.$promise$ : drainUpTo(chore);
2068
+ return runLater ? chore.$promise$ : drainUpTo(chore, container.rootVNode || null);
1913
2069
  };
1914
- function drainUpTo(runUptoChore) {
2070
+ function drainUpTo(runUptoChore, rootVNode) {
1915
2071
  if (runUptoChore.$executed$) {
1916
2072
  return runUptoChore.$returnValue$;
1917
2073
  }
@@ -1920,7 +2076,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
1920
2076
  }
1921
2077
  for (;choreQueue.length; ) {
1922
2078
  const nextChore = choreQueue.shift();
1923
- const order = choreComparator(nextChore, runUptoChore, !1);
2079
+ const order = choreComparator(nextChore, runUptoChore, rootVNode);
1924
2080
  if (null === order) {
1925
2081
  continue;
1926
2082
  }
@@ -1932,7 +2088,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
1932
2088
  }
1933
2089
  const returnValue = executeChore(nextChore);
1934
2090
  if (isPromise(returnValue)) {
1935
- return returnValue.then((() => drainUpTo(runUptoChore)));
2091
+ return returnValue.then((() => drainUpTo(runUptoChore, rootVNode)));
1936
2092
  }
1937
2093
  }
1938
2094
  return runUptoChore.$returnValue$;
@@ -1951,7 +2107,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
1951
2107
  returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
1952
2108
  if (chore.$type$ === ChoreType.COMPONENT) {
1953
2109
  const styleScopedId = container.getHostProp(host, "q:sstyle");
1954
- return vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId));
2110
+ return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
1955
2111
  }
1956
2112
  return jsx;
1957
2113
  }), (err => container.handleError(err, host)));
@@ -1974,7 +2130,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
1974
2130
  case ChoreType.NODE_DIFF:
1975
2131
  const parentVirtualNode = chore.$target$;
1976
2132
  let jsx = chore.$payload$;
1977
- isSignal(jsx) && (jsx = jsx.value), returnValue = vnode_diff(container, jsx, parentVirtualNode, null);
2133
+ isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
1978
2134
  break;
1979
2135
 
1980
2136
  case ChoreType.NODE_PROP:
@@ -2028,7 +2184,7 @@ function vNodeAlreadyDeleted(chore) {
2028
2184
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
2029
2185
  }
2030
2186
 
2031
- function choreComparator(a, b, shouldThrowOnHostMismatch) {
2187
+ function choreComparator(a, b, rootVNode) {
2032
2188
  const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
2033
2189
  if (0 !== macroTypeDiff) {
2034
2190
  return macroTypeDiff;
@@ -2037,15 +2193,15 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
2037
2193
  const aHost = a.$host$;
2038
2194
  const bHost = b.$host$;
2039
2195
  if (aHost !== bHost && null !== aHost && null !== bHost) {
2040
- if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
2041
- const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
2042
- if (shouldThrowOnHostMismatch) {
2043
- throw qError(QError.serverHostMismatch, [ errorMessage ]);
2196
+ if (vnode_isVNode(aHost) && vnode_isVNode(bHost)) {
2197
+ const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
2198
+ if (0 !== hostDiff) {
2199
+ return hostDiff;
2044
2200
  }
2045
- return logWarn(errorMessage), null;
2046
- }
2047
- {
2048
- const hostDiff = vnode_documentPosition(aHost, bHost);
2201
+ } else {
2202
+ const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
2203
+ logWarn(errorMessage);
2204
+ const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
2049
2205
  if (0 !== hostDiff) {
2050
2206
  return hostDiff;
2051
2207
  }
@@ -2066,12 +2222,12 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
2066
2222
  return 0;
2067
2223
  }
2068
2224
 
2069
- function sortedFindIndex(sortedArray, value) {
2225
+ function sortedFindIndex(sortedArray, value, rootVNode) {
2070
2226
  let bottom = 0;
2071
2227
  let top = sortedArray.length;
2072
2228
  for (;bottom < top; ) {
2073
2229
  const middle = bottom + (top - bottom >> 1);
2074
- const comp = choreComparator(value, sortedArray[middle], !0);
2230
+ const comp = choreComparator(value, sortedArray[middle], rootVNode);
2075
2231
  if (comp < 0) {
2076
2232
  top = middle;
2077
2233
  } else {
@@ -2084,8 +2240,8 @@ function sortedFindIndex(sortedArray, value) {
2084
2240
  return ~bottom;
2085
2241
  }
2086
2242
 
2087
- function sortedInsert(sortedArray, value) {
2088
- const idx = sortedFindIndex(sortedArray, value);
2243
+ function sortedInsert(sortedArray, value, rootVNode) {
2244
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
2089
2245
  if (idx < 0) {
2090
2246
  return sortedArray.splice(~idx, 0, value), value;
2091
2247
  }
@@ -2135,7 +2291,7 @@ const runTask = (task, container, host) => {
2135
2291
  task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
2136
2292
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
2137
2293
  iCtx.$container$ = container;
2138
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
2294
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
2139
2295
  const handleError = reason => container.handleError(reason, host);
2140
2296
  let cleanupFns = null;
2141
2297
  const cleanup = fn => {
@@ -2552,7 +2708,7 @@ function processJSXNode(ssr, enqueue, value, options) {
2552
2708
  if ("string" == typeof type) {
2553
2709
  appendClassIfScopedStyleExists(jsx, options.styleScoped);
2554
2710
  let qwikInspectorAttrValue = null;
2555
- isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = getQwikInspectorAttributeValue(jsx.dev));
2711
+ isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = getFileLocationFromJsx(jsx.dev));
2556
2712
  const innerHTML = ssr.openElement(type, varPropsToSsrAttrs(jsx.varProps, jsx.constProps, ssr.serializationCtx, options.styleScoped, jsx.key), constPropsToSsrAttrs(jsx.constProps, jsx.varProps, ssr.serializationCtx, options.styleScoped), qwikInspectorAttrValue);
2557
2713
  innerHTML && ssr.htmlNode(innerHTML), enqueue(ssr.closeElement), "head" === type ? (enqueue(ssr.additionalHeadNodes),
2558
2714
  enqueue(ssr.emitQwikLoaderAtTopIfNeeded)) : "body" === type && enqueue(ssr.additionalBodyNodes);
@@ -2716,11 +2872,6 @@ function getSlotName(host, jsx, ssr) {
2716
2872
  return directGetPropsProxyProp(jsx, "name") || "";
2717
2873
  }
2718
2874
 
2719
- function getQwikInspectorAttributeValue(jsxDev) {
2720
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
2721
- return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
2722
- }
2723
-
2724
2875
  function appendQwikInspectorAttribute(jsx, qwikInspectorAttrValue) {
2725
2876
  !qwikInspectorAttrValue || jsx.constProps && qwikInspectorAttr in jsx.constProps || ((jsx.constProps ||= {})[qwikInspectorAttr] = qwikInspectorAttrValue);
2726
2877
  }
@@ -2730,7 +2881,7 @@ function appendClassIfScopedStyleExists(jsx, styleScoped) {
2730
2881
  jsx.constProps.class = "");
2731
2882
  }
2732
2883
 
2733
- const version = "2.0.0-alpha.4-dev+374e0d6";
2884
+ const version = "2.0.0-alpha.6-dev+d848ba5";
2734
2885
 
2735
2886
  class _SharedContainer {
2736
2887
  $version$;
@@ -3827,7 +3978,7 @@ const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
3827
3978
  const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node."),
3828
3979
  vnode[TextVNodeProps.node]);
3829
3980
 
3830
- function vnode_toString(depth = 10, offset = "", materialize = !1, siblings = !1) {
3981
+ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1) {
3831
3982
  let vnode = this;
3832
3983
  if (0 === depth) {
3833
3984
  return "...";
@@ -3989,49 +4140,11 @@ const vnode_getType = vnode => {
3989
4140
 
3990
4141
  const isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
3991
4142
 
3992
- const aPath = [];
3993
-
3994
- const bPath = [];
3995
-
3996
- const vnode_documentPosition = (a, b) => {
3997
- if (a === b) {
3998
- return 0;
3999
- }
4000
- let aDepth = -1;
4001
- let bDepth = -1;
4002
- for (;a; ) {
4003
- a = (aPath[++aDepth] = a)[VNodeProps.parent];
4004
- }
4005
- for (;b; ) {
4006
- b = (bPath[++bDepth] = b)[VNodeProps.parent];
4007
- }
4008
- for (;aDepth >= 0 && bDepth >= 0; ) {
4009
- if ((a = aPath[aDepth]) !== (b = bPath[bDepth])) {
4010
- let cursor = b;
4011
- do {
4012
- if (cursor = vnode_getNextSibling(cursor), cursor === a) {
4013
- return 1;
4014
- }
4015
- } while (cursor);
4016
- cursor = b;
4017
- do {
4018
- if (cursor = vnode_getPreviousSibling(cursor), cursor === a) {
4019
- return -1;
4020
- }
4021
- } while (cursor);
4022
- return 1;
4023
- }
4024
- aDepth--, bDepth--;
4025
- }
4026
- return aDepth < bDepth ? -1 : 1;
4027
- };
4028
-
4029
4143
  const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
4030
4144
  let projectionDepth = 1;
4031
4145
  for (;projectionDepth--; ) {
4032
4146
  for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
4033
- const qSlotParentProp = vnode_getProp(vHost, ":", null);
4034
- const qSlotParent = qSlotParentProp && ("string" == typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
4147
+ const qSlotParent = vnode_getProp(vHost, ":", (id => vnode_locate(rootVNode, id)));
4035
4148
  const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
4036
4149
  vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
4037
4150
  }
@@ -4497,13 +4610,10 @@ class DomContainer extends _SharedContainer {
4497
4610
  if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
4498
4611
  return vNode;
4499
4612
  }
4500
- const parent = vnode_getProp(vNode, ":", this.$vnodeLocate$);
4501
- if (parent) {
4502
- vNode = parent;
4503
- continue;
4504
- }
4613
+ vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.$vnodeLocate$);
4614
+ } else {
4615
+ vNode = vnode_getParent(vNode);
4505
4616
  }
4506
- vNode = vnode_getParent(vNode);
4507
4617
  }
4508
4618
  return null;
4509
4619
  }
@@ -4581,11 +4691,6 @@ class DomContainer extends _SharedContainer {
4581
4691
 
4582
4692
  const deserializedProxyMap = new WeakMap;
4583
4693
 
4584
- const unwrapDeserializerProxy = value => {
4585
- const unwrapped = "object" == typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
4586
- return unwrapped || value;
4587
- };
4588
-
4589
4694
  const isDeserializerProxy = value => "object" == typeof value && null !== value && SERIALIZER_PROXY_UNWRAP in value;
4590
4695
 
4591
4696
  const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
@@ -4624,9 +4729,10 @@ class DeserializationHandler {
4624
4729
  return value;
4625
4730
  }
4626
4731
  const container = this.$container$;
4627
- const propValue = allocate(container, typeId, value);
4628
- return Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue,
4629
- typeId >= TypeIds.Error && inflate(container, propValue, typeId, value), propValue;
4732
+ let propValue = allocate(container, typeId, value);
4733
+ return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)),
4734
+ Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue,
4735
+ propValue;
4630
4736
  }
4631
4737
  has(target, property) {
4632
4738
  return property === SERIALIZER_PROXY_UNWRAP || Object.prototype.hasOwnProperty.call(target, property);
@@ -4656,181 +4762,184 @@ const _eagerDeserializeArray = (container, data) => {
4656
4762
  const resolvers = new WeakMap;
4657
4763
 
4658
4764
  const inflate = (container, target, typeId, data) => {
4659
- if (void 0 !== typeId) {
4660
- switch (typeId !== TypeIds.Object && Array.isArray(data) && (data = _eagerDeserializeArray(container, data)),
4661
- typeId) {
4662
- case TypeIds.Object:
4663
- for (let i = 0; i < data.length; i += 4) {
4664
- const key = deserializeData(container, data[i], data[i + 1]);
4665
- const valType = data[i + 2];
4666
- const valData = data[i + 3];
4667
- valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
4668
- get() {
4669
- const value = deserializeData(container, valType, valData);
4670
- return target[key] = value, value;
4671
- },
4672
- set(value) {
4673
- Object.defineProperty(target, key, {
4674
- value,
4675
- writable: !0,
4676
- enumerable: !0,
4677
- configurable: !0
4678
- });
4679
- },
4680
- enumerable: !0,
4681
- configurable: !0
4682
- }) : target[key] = deserializeData(container, valType, valData);
4683
- }
4684
- break;
4685
-
4686
- case TypeIds.QRL:
4687
- inflateQRL(container, target);
4688
- break;
4765
+ if (void 0 === typeId) {
4766
+ return target;
4767
+ }
4768
+ switch (typeId !== TypeIds.Object && Array.isArray(data) && (data = _eagerDeserializeArray(container, data)),
4769
+ typeId) {
4770
+ case TypeIds.Object:
4771
+ for (let i = 0; i < data.length; i += 4) {
4772
+ const key = deserializeData(container, data[i], data[i + 1]);
4773
+ const valType = data[i + 2];
4774
+ const valData = data[i + 3];
4775
+ valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
4776
+ get() {
4777
+ const value = deserializeData(container, valType, valData);
4778
+ return target[key] = value, value;
4779
+ },
4780
+ set(value) {
4781
+ Object.defineProperty(target, key, {
4782
+ value,
4783
+ writable: !0,
4784
+ enumerable: !0,
4785
+ configurable: !0
4786
+ });
4787
+ },
4788
+ enumerable: !0,
4789
+ configurable: !0
4790
+ }) : target[key] = deserializeData(container, valType, valData);
4791
+ }
4792
+ break;
4689
4793
 
4690
- case TypeIds.Task:
4691
- const task = target;
4692
- const v = data;
4693
- task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
4694
- task.$el$ = v[3], task.$effectDependencies$ = v[4], task.$state$ = v[5];
4695
- break;
4794
+ case TypeIds.QRL:
4795
+ inflateQRL(container, target);
4796
+ break;
4696
4797
 
4697
- case TypeIds.Resource:
4698
- const [resolved, result, effects] = data;
4699
- const resource = target;
4700
- resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
4701
- resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
4702
- resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
4703
- break;
4798
+ case TypeIds.Task:
4799
+ const task = target;
4800
+ const v = data;
4801
+ task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
4802
+ task.$el$ = v[3], task.$effectDependencies$ = v[4], task.$state$ = v[5];
4803
+ break;
4704
4804
 
4705
- case TypeIds.Component:
4706
- target[SERIALIZABLE_STATE][0] = data[0];
4707
- break;
4805
+ case TypeIds.Resource:
4806
+ const [resolved, result, effects] = data;
4807
+ const resource = target;
4808
+ resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
4809
+ resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
4810
+ resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
4811
+ break;
4708
4812
 
4709
- case TypeIds.Store:
4710
- case TypeIds.StoreArray:
4711
- {
4712
- const [value, flags, effects, storeEffect] = data;
4713
- const handler = getStoreHandler(target);
4714
- handler.$flags$ = flags, Object.assign(getStoreTarget(target), value), storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect),
4715
- handler.$effects$ = effects, container.$storeProxyMap$.set(value, target);
4716
- break;
4717
- }
4813
+ case TypeIds.Component:
4814
+ target[SERIALIZABLE_STATE][0] = data[0];
4815
+ break;
4718
4816
 
4719
- case TypeIds.Signal:
4720
- {
4721
- const signal = target;
4722
- const d = data;
4723
- signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
4724
- break;
4725
- }
4817
+ case TypeIds.Store:
4818
+ case TypeIds.StoreArray:
4819
+ {
4820
+ const [value, flags, effects, storeEffect] = data;
4821
+ const store = getOrCreateStore(value, flags, container);
4822
+ const storeHandler = getStoreHandler(store);
4823
+ storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect), storeHandler.$effects$ = effects,
4824
+ target = store;
4825
+ break;
4826
+ }
4726
4827
 
4727
- case TypeIds.WrappedSignal:
4728
- {
4729
- const signal = target;
4730
- const d = data;
4731
- signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
4732
- signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
4733
- break;
4734
- }
4828
+ case TypeIds.Signal:
4829
+ {
4830
+ const signal = target;
4831
+ const d = data;
4832
+ signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
4833
+ break;
4834
+ }
4735
4835
 
4736
- case TypeIds.ComputedSignal:
4737
- {
4738
- const computed = target;
4739
- const d = data;
4740
- computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$invalid$ = !0,
4741
- computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
4742
- break;
4743
- }
4836
+ case TypeIds.WrappedSignal:
4837
+ {
4838
+ const signal = target;
4839
+ const d = data;
4840
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
4841
+ signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
4842
+ break;
4843
+ }
4744
4844
 
4745
- case TypeIds.Error:
4746
- {
4747
- const d = data;
4748
- target.message = d[0];
4749
- const second = d[1];
4750
- if (second && Array.isArray(second)) {
4751
- for (let i = 0; i < second.length; i++) {
4752
- target[second[i++]] = d[i];
4753
- }
4754
- target.stack = d[2];
4755
- } else {
4756
- target.stack = second;
4757
- }
4758
- break;
4759
- }
4845
+ case TypeIds.ComputedSignal:
4846
+ {
4847
+ const computed = target;
4848
+ const d = data;
4849
+ computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$invalid$ = !0,
4850
+ computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
4851
+ break;
4852
+ }
4760
4853
 
4761
- case TypeIds.FormData:
4762
- {
4763
- const formData = target;
4764
- const d = data;
4765
- for (let i = 0; i < d.length; i++) {
4766
- formData.append(d[i++], d[i]);
4854
+ case TypeIds.Error:
4855
+ {
4856
+ const d = data;
4857
+ target.message = d[0];
4858
+ const second = d[1];
4859
+ if (second && Array.isArray(second)) {
4860
+ for (let i = 0; i < second.length; i++) {
4861
+ target[second[i++]] = d[i];
4767
4862
  }
4768
- break;
4769
- }
4770
-
4771
- case TypeIds.JSXNode:
4772
- {
4773
- const jsx = target;
4774
- const [type, varProps, constProps, children, flags, key] = data;
4775
- jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
4776
- jsx.flags = flags, jsx.key = key;
4777
- break;
4863
+ target.stack = d[2];
4864
+ } else {
4865
+ target.stack = second;
4778
4866
  }
4867
+ break;
4868
+ }
4779
4869
 
4780
- case TypeIds.Set:
4781
- {
4782
- const set = target;
4783
- const d = data;
4784
- for (let i = 0; i < d.length; i++) {
4785
- set.add(d[i]);
4786
- }
4787
- break;
4870
+ case TypeIds.FormData:
4871
+ {
4872
+ const formData = target;
4873
+ const d = data;
4874
+ for (let i = 0; i < d.length; i++) {
4875
+ formData.append(d[i++], d[i]);
4788
4876
  }
4877
+ break;
4878
+ }
4789
4879
 
4790
- case TypeIds.Map:
4791
- {
4792
- const map = target;
4793
- const d = data;
4794
- for (let i = 0; i < d.length; i++) {
4795
- map.set(d[i++], d[i]);
4796
- }
4797
- break;
4798
- }
4880
+ case TypeIds.JSXNode:
4881
+ {
4882
+ const jsx = target;
4883
+ const [type, varProps, constProps, children, flags, key] = data;
4884
+ jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
4885
+ jsx.flags = flags, jsx.key = key;
4886
+ break;
4887
+ }
4799
4888
 
4800
- case TypeIds.Promise:
4801
- {
4802
- const promise = target;
4803
- const [resolved, result] = data;
4804
- const [resolve, reject] = resolvers.get(promise);
4805
- resolved ? resolve(result) : reject(result);
4806
- break;
4889
+ case TypeIds.Set:
4890
+ {
4891
+ const set = target;
4892
+ const d = data;
4893
+ for (let i = 0; i < d.length; i++) {
4894
+ set.add(d[i]);
4807
4895
  }
4896
+ break;
4897
+ }
4808
4898
 
4809
- case TypeIds.Uint8Array:
4810
- const bytes = target;
4811
- const buf = atob(data);
4812
- let i = 0;
4813
- for (const s of buf) {
4814
- bytes[i++] = s.charCodeAt(0);
4899
+ case TypeIds.Map:
4900
+ {
4901
+ const map = target;
4902
+ const d = data;
4903
+ for (let i = 0; i < d.length; i++) {
4904
+ map.set(d[i++], d[i]);
4815
4905
  }
4816
4906
  break;
4907
+ }
4817
4908
 
4818
- case TypeIds.PropsProxy:
4819
- const propsProxy = target;
4820
- propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4909
+ case TypeIds.Promise:
4910
+ {
4911
+ const promise = target;
4912
+ const [resolved, result] = data;
4913
+ const [resolve, reject] = resolvers.get(promise);
4914
+ resolved ? resolve(result) : reject(result);
4821
4915
  break;
4916
+ }
4822
4917
 
4823
- case TypeIds.EffectData:
4824
- {
4825
- const effectData = target;
4826
- effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
4827
- break;
4828
- }
4918
+ case TypeIds.Uint8Array:
4919
+ const bytes = target;
4920
+ const buf = atob(data);
4921
+ let i = 0;
4922
+ for (const s of buf) {
4923
+ bytes[i++] = s.charCodeAt(0);
4924
+ }
4925
+ break;
4829
4926
 
4830
- default:
4831
- throw qError(QError.serializeErrorNotImplemented, [ typeId ]);
4927
+ case TypeIds.PropsProxy:
4928
+ const propsProxy = target;
4929
+ propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4930
+ break;
4931
+
4932
+ case TypeIds.EffectData:
4933
+ {
4934
+ const effectData = target;
4935
+ effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
4936
+ break;
4832
4937
  }
4938
+
4939
+ default:
4940
+ throw qError(QError.serializeErrorNotImplemented, [ typeId ]);
4833
4941
  }
4942
+ return target;
4834
4943
  };
4835
4944
 
4836
4945
  const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
@@ -4893,10 +5002,8 @@ const allocate = (container, typeId, value) => {
4893
5002
  return new ComputedSignal(container, null);
4894
5003
 
4895
5004
  case TypeIds.Store:
4896
- return createStore(container, {}, 0);
4897
-
4898
5005
  case TypeIds.StoreArray:
4899
- return createStore(container, [], 0);
5006
+ return null;
4900
5007
 
4901
5008
  case TypeIds.URLSearchParams:
4902
5009
  return new URLSearchParams(value);
@@ -5424,13 +5531,13 @@ function _deserialize(rawStateData, element) {
5424
5531
  return output;
5425
5532
  }
5426
5533
 
5427
- function deserializeData(container, typeId, propValue) {
5534
+ function deserializeData(container, typeId, value) {
5428
5535
  if (void 0 === typeId) {
5429
- return propValue;
5536
+ return value;
5430
5537
  }
5431
- const value = allocate(container, typeId, propValue);
5432
- return typeId >= TypeIds.Error && inflate(container, value, typeId, propValue),
5433
- value;
5538
+ let propValue = allocate(container, typeId, value);
5539
+ return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)),
5540
+ propValue;
5434
5541
  }
5435
5542
 
5436
5543
  function getObjectById(id, stateData) {