@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/core.cjs CHANGED
@@ -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.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
@@ -152,7 +152,7 @@
152
152
  'SsrError(tag): {{0}}', // 29
153
153
  'QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.', // 30
154
154
  'QRLs can not be dynamically resolved, because it does not have a chunk path', // 31
155
- 'The JSX ref attribute must be a Signal', // 32
155
+ '{{0}}\nThe JSX ref attribute must be a Signal', // 32
156
156
  'Serialization Error: Deserialization of data type {{0}} is not implemented', // 33
157
157
  'Serialization Error: Expected vnode for ref prop, but got {{0}}', // 34
158
158
  'Serialization Error: Cannot allocate data type {{0}}', // 35
@@ -160,7 +160,7 @@
160
160
  'Serialization Error: Serialization of data type {{0}} is not implemented', // 37
161
161
  'Serialization Error: Unvisited {{0}}', // 38
162
162
  'Serialization Error: Missing QRL chunk for {{0}}', // 39
163
- 'The value of the textarea must be a string', // 40
163
+ '{{0}}\nThe value of the textarea must be a string found {{1}}', // 40
164
164
  'Unable to find q:container', // 41
165
165
  "Element must have 'q:container' attribute.", // 42
166
166
  'Unknown vnode type {{0}}.', // 43
@@ -1138,7 +1138,6 @@
1138
1138
  }
1139
1139
  /** In the case of oldValue and value are the same, the effects are not triggered. */
1140
1140
  set(target, prop, value) {
1141
- target = unwrapDeserializerProxy(target);
1142
1141
  if (typeof prop === 'symbol') {
1143
1142
  target[prop] = value;
1144
1143
  return true;
@@ -1207,6 +1206,8 @@
1207
1206
  // to unsubscribe from. So we need to store the reference from the effect back
1208
1207
  // to this signal.
1209
1208
  ensureContains(effectSubscriber, target);
1209
+ // We need to add the subscriber to the effect so that we can clean it up later
1210
+ ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], target, store.$container$);
1210
1211
  }
1211
1212
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
1212
1213
  target[prop] = value;
@@ -1277,32 +1278,40 @@
1277
1278
  }
1278
1279
  for (let i = effects.length - 1; i >= 0; i--) {
1279
1280
  const subscriber = effects[i];
1280
- const subscriptionRemoved = clearEffects(subscriber, value);
1281
- if (subscriptionRemoved) {
1282
- effects.splice(i, 1);
1283
- }
1281
+ clearEffects(subscriber, value, effects, i, container);
1282
+ }
1283
+ if (effects.length === 0) {
1284
+ vnode_setProp(value, QSubscribers, null);
1284
1285
  }
1285
1286
  }
1286
- function clearSubscriberEffectDependencies(value) {
1287
+ function clearSubscriberEffectDependencies(container, value) {
1287
1288
  if (value.$effectDependencies$) {
1288
1289
  for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
1289
1290
  const subscriber = value.$effectDependencies$[i];
1290
- const subscriptionRemoved = clearEffects(subscriber, value);
1291
- if (subscriptionRemoved) {
1292
- value.$effectDependencies$.splice(i, 1);
1293
- }
1291
+ clearEffects(subscriber, value, value.$effectDependencies$, i, container);
1292
+ }
1293
+ if (value.$effectDependencies$.length === 0) {
1294
+ value.$effectDependencies$ = null;
1294
1295
  }
1295
1296
  }
1296
1297
  }
1297
- function clearEffects(subscriber, value) {
1298
- if (!isSignal(subscriber)) {
1299
- return false;
1298
+ function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
1299
+ let subscriptionRemoved = false;
1300
+ const seenSet = new Set();
1301
+ if (subscriber instanceof WrappedSignal) {
1302
+ subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
1300
1303
  }
1301
- const effectSubscriptions = subscriber.$effects$;
1302
- const hostElement = subscriber.$hostElement$;
1303
- if (hostElement && hostElement === value) {
1304
- subscriber.$hostElement$ = null;
1304
+ else if (container.$storeProxyMap$.has(subscriber)) {
1305
+ const store = container.$storeProxyMap$.get(subscriber);
1306
+ const handler = getStoreHandler(store);
1307
+ subscriptionRemoved = clearStoreEffects(handler, value);
1308
+ }
1309
+ if (subscriptionRemoved) {
1310
+ effectArray.splice(indexToRemove, 1);
1305
1311
  }
1312
+ }
1313
+ function clearSignalEffects(subscriber, value, seenSet) {
1314
+ const effectSubscriptions = subscriber.$effects$;
1306
1315
  let subscriptionRemoved = false;
1307
1316
  if (effectSubscriptions) {
1308
1317
  for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
@@ -1313,15 +1322,69 @@
1313
1322
  }
1314
1323
  }
1315
1324
  }
1316
- // clear the effects of the arguments
1317
- const args = subscriber.$args$;
1318
- if (args) {
1319
- for (let i = args.length - 1; i >= 0; i--) {
1320
- clearEffects(args[i], subscriber);
1325
+ if (subscriber instanceof WrappedSignal) {
1326
+ const hostElement = subscriber.$hostElement$;
1327
+ if (hostElement && hostElement === value) {
1328
+ subscriber.$hostElement$ = null;
1329
+ }
1330
+ // clear the effects of the arguments
1331
+ const args = subscriber.$args$;
1332
+ if (args) {
1333
+ clearArgsEffects(args, subscriber, seenSet);
1321
1334
  }
1322
1335
  }
1323
1336
  return subscriptionRemoved;
1324
1337
  }
1338
+ function clearStoreEffects(storeHandler, value) {
1339
+ const effectSubscriptions = storeHandler.$effects$;
1340
+ if (!effectSubscriptions) {
1341
+ return false;
1342
+ }
1343
+ let subscriptionRemoved = false;
1344
+ for (const key in effectSubscriptions) {
1345
+ const effects = effectSubscriptions[key];
1346
+ for (let i = effects.length - 1; i >= 0; i--) {
1347
+ const effect = effects[i];
1348
+ if (effect[EffectSubscriptionsProp.EFFECT] === value) {
1349
+ effects.splice(i, 1);
1350
+ subscriptionRemoved = true;
1351
+ }
1352
+ }
1353
+ if (effects.length === 0) {
1354
+ delete effectSubscriptions[key];
1355
+ }
1356
+ }
1357
+ return subscriptionRemoved;
1358
+ }
1359
+ function clearArgsEffects(args, subscriber, seenSet) {
1360
+ for (let i = args.length - 1; i >= 0; i--) {
1361
+ const arg = args[i];
1362
+ clearArgEffect(arg, subscriber, seenSet);
1363
+ }
1364
+ }
1365
+ function clearArgEffect(arg, subscriber, seenSet) {
1366
+ if (seenSet.has(arg)) {
1367
+ return;
1368
+ }
1369
+ seenSet.add(arg);
1370
+ if (isSignal(arg)) {
1371
+ clearSignalEffects(arg, subscriber, seenSet);
1372
+ }
1373
+ else if (typeof arg === 'object' && arg !== null) {
1374
+ if (isStore(arg)) {
1375
+ clearStoreEffects(getStoreHandler(arg), subscriber);
1376
+ }
1377
+ else {
1378
+ for (const key in arg) {
1379
+ clearArgEffect(arg[key], subscriber, seenSet);
1380
+ }
1381
+ }
1382
+ }
1383
+ else if (Array.isArray(arg)) {
1384
+ clearArgsEffects(arg, subscriber, seenSet);
1385
+ }
1386
+ else ;
1387
+ }
1325
1388
 
1326
1389
  /** @internal */
1327
1390
  const useResourceQrl = (qrl, opts) => {
@@ -1408,14 +1471,17 @@
1408
1471
  // create a subscription for the resource._state changes
1409
1472
  const state = resource._state;
1410
1473
  if (state === 'pending' && props.onPending) {
1411
- return Promise.resolve(props.onPending());
1474
+ return Promise.resolve().then(useBindInvokeContext(props.onPending));
1412
1475
  }
1413
1476
  else if (state === 'rejected' && props.onRejected) {
1414
- return Promise.resolve(resource._error).then(props.onRejected);
1477
+ return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
1415
1478
  }
1416
1479
  else {
1417
- // resolved, pending without onPending prop or rejected with onRejected prop
1418
- return Promise.resolve(untrack(() => resource._resolved)).then(props.onResolved);
1480
+ const resolvedValue = untrack(() => resource._resolved);
1481
+ if (resolvedValue !== undefined) {
1482
+ // resolved, pending without onPending prop or rejected without onRejected prop
1483
+ return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
1484
+ }
1419
1485
  }
1420
1486
  }
1421
1487
  return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
@@ -1456,7 +1522,7 @@
1456
1522
  cleanupTask(task);
1457
1523
  const iCtx = newInvokeContext(container.$locale$, host, undefined, ResourceEvent);
1458
1524
  iCtx.$container$ = container;
1459
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(task));
1525
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
1460
1526
  const resource = task.$state$;
1461
1527
  assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
1462
1528
  const track = (obj, prop) => {
@@ -2257,6 +2323,17 @@
2257
2323
  }
2258
2324
  }
2259
2325
 
2326
+ function getFileLocationFromJsx(jsxDev) {
2327
+ if (!jsxDev) {
2328
+ return null;
2329
+ }
2330
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, '/');
2331
+ if (sanitizedFileName) {
2332
+ return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
2333
+ }
2334
+ return null;
2335
+ }
2336
+
2260
2337
  const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
2261
2338
  let journal = container.$journal$;
2262
2339
  /**
@@ -2700,7 +2777,7 @@
2700
2777
  *
2701
2778
  * @returns {boolean}
2702
2779
  */
2703
- function createNewElement(jsx, elementName) {
2780
+ function createNewElement(jsx, elementName, currentFile) {
2704
2781
  const element = createElementWithNamespace(elementName);
2705
2782
  const { constProps } = jsx;
2706
2783
  let needsQDispatchEventPatch = false;
@@ -2731,6 +2808,9 @@
2731
2808
  value(element);
2732
2809
  continue;
2733
2810
  }
2811
+ else {
2812
+ throw qError(QError.invalidRefValue, [currentFile]);
2813
+ }
2734
2814
  }
2735
2815
  if (isSignal(value)) {
2736
2816
  const signalData = new EffectPropData({
@@ -2745,13 +2825,13 @@
2745
2825
  continue;
2746
2826
  }
2747
2827
  if (elementName === 'textarea' && key === 'value') {
2748
- if (typeof value !== 'string') {
2828
+ if (value && typeof value !== 'string') {
2749
2829
  if (build.isDev) {
2750
- throw qError(QError.wrongTextareaValue);
2830
+ throw qError(QError.wrongTextareaValue, [currentFile, value]);
2751
2831
  }
2752
2832
  continue;
2753
2833
  }
2754
- element.value = escapeHTML(value);
2834
+ element.value = escapeHTML(value || '');
2755
2835
  continue;
2756
2836
  }
2757
2837
  value = serializeAttribute(key, value, scopedStyleIdPrefix);
@@ -2785,6 +2865,7 @@
2785
2865
  const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
2786
2866
  const jsxKey = jsx.key;
2787
2867
  let needsQDispatchEventPatch = false;
2868
+ const currentFile = getFileLocationFromJsx(jsx.dev);
2788
2869
  if (!isSameElementName || jsxKey !== getKey(vCurrent)) {
2789
2870
  // So we have a key and it does not match the current node.
2790
2871
  // We need to do a forward search to find it.
@@ -2797,14 +2878,21 @@
2797
2878
  else {
2798
2879
  // Existing keyed node
2799
2880
  vnode_insertBefore(journal, vParent, vNewNode, vCurrent);
2881
+ // We are here, so jsx is different from the vCurrent, so now we want to point to the moved node.
2882
+ vCurrent = vNewNode;
2883
+ // We need to clean up the vNewNode, because we don't want to skip advance to next sibling (see `advance` function).
2884
+ vNewNode = null;
2885
+ // We need also to go back to the previous sibling, because we assigned previous sibling to the vCurrent.
2886
+ if (vSiblings !== null) {
2887
+ vSiblingsIdx -= SiblingsArray.Size;
2888
+ }
2800
2889
  }
2801
2890
  }
2802
2891
  // reconcile attributes
2803
2892
  const jsxAttrs = [];
2804
2893
  const props = jsx.varProps;
2805
2894
  for (const key in props) {
2806
- let value = props[key];
2807
- value = serializeAttribute(key, value, scopedStyleIdPrefix);
2895
+ const value = props[key];
2808
2896
  if (value != null) {
2809
2897
  mapArray_set(jsxAttrs, key, value, 0);
2810
2898
  }
@@ -2813,7 +2901,8 @@
2813
2901
  mapArray_set(jsxAttrs, ELEMENT_KEY, jsxKey, 0);
2814
2902
  }
2815
2903
  const vNode = (vNewNode || vCurrent);
2816
- needsQDispatchEventPatch = setBulkProps(vNode, jsxAttrs) || needsQDispatchEventPatch;
2904
+ needsQDispatchEventPatch =
2905
+ setBulkProps(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch;
2817
2906
  if (needsQDispatchEventPatch) {
2818
2907
  // Event handler needs to be patched onto the element.
2819
2908
  const element = vnode_getNode(vNode);
@@ -2838,7 +2927,7 @@
2838
2927
  }
2839
2928
  }
2840
2929
  /** @param tag Returns true if `qDispatchEvent` needs patching */
2841
- function setBulkProps(vnode, srcAttrs) {
2930
+ function setBulkProps(vnode, srcAttrs, currentFile) {
2842
2931
  vnode_ensureElementInflated(vnode);
2843
2932
  const dstAttrs = vnode;
2844
2933
  let srcIdx = 0;
@@ -2863,11 +2952,18 @@
2863
2952
  value(element);
2864
2953
  return;
2865
2954
  }
2955
+ else {
2956
+ throw qError(QError.invalidRefValue, [currentFile]);
2957
+ }
2866
2958
  }
2867
2959
  if (isSignal(value)) {
2868
- value = untrack(() => value.value);
2960
+ const signalData = new EffectPropData({
2961
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
2962
+ $isConst$: false,
2963
+ });
2964
+ value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
2869
2965
  }
2870
- vnode_setAttr(journal, vnode, key, value);
2966
+ vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix));
2871
2967
  if (value === null) {
2872
2968
  // if we set `null` than attribute was removed and we need to shorten the dstLength
2873
2969
  dstLength = dstAttrs.length;
@@ -2923,6 +3019,10 @@
2923
3019
  }
2924
3020
  srcIdx++;
2925
3021
  srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
3022
+ // we need to increment dstIdx too, because we added destination key and value to the VNode
3023
+ // and dstAttrs is a reference to the VNode
3024
+ dstIdx++;
3025
+ dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
2926
3026
  }
2927
3027
  else if (srcKey == dstKey) {
2928
3028
  const srcValue = srcAttrs[srcIdx++];
@@ -3040,7 +3140,7 @@
3040
3140
  vNewNode = retrieveChildWithKey(null, jsxKey);
3041
3141
  if (vNewNode != null) {
3042
3142
  // We found it, move it up.
3043
- vnode_insertBefore(journal, vParent, (vNewNode = vnode_newVirtual()), vCurrent && getInsertBefore());
3143
+ vnode_insertBefore(journal, vParent, vNewNode, vCurrent && getInsertBefore());
3044
3144
  return;
3045
3145
  }
3046
3146
  }
@@ -3282,7 +3382,7 @@
3282
3382
  const obj = seq[i];
3283
3383
  if (isTask(obj)) {
3284
3384
  const task = obj;
3285
- clearSubscriberEffectDependencies(task);
3385
+ clearSubscriberEffectDependencies(container, task);
3286
3386
  if (task.$flags$ & TaskFlags.VISIBLE_TASK) {
3287
3387
  container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task);
3288
3388
  }
@@ -3615,7 +3715,7 @@
3615
3715
  $executed$: false,
3616
3716
  };
3617
3717
  chore.$promise$ = new Promise((resolve) => (chore.$resolve$ = resolve));
3618
- chore = sortedInsert(choreQueue, chore);
3718
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
3619
3719
  if (!journalFlushScheduled && runLater) {
3620
3720
  // If we are not currently draining, we need to schedule a drain.
3621
3721
  journalFlushScheduled = true;
@@ -3626,7 +3726,7 @@
3626
3726
  return chore.$promise$;
3627
3727
  }
3628
3728
  else {
3629
- return drainUpTo(chore);
3729
+ return drainUpTo(chore, container.rootVNode || null);
3630
3730
  }
3631
3731
  }
3632
3732
  /**
@@ -3634,7 +3734,7 @@
3634
3734
  *
3635
3735
  * @param runUptoChore
3636
3736
  */
3637
- function drainUpTo(runUptoChore) {
3737
+ function drainUpTo(runUptoChore, rootVNode) {
3638
3738
  // If it already ran, it's not in the queue
3639
3739
  if (runUptoChore.$executed$) {
3640
3740
  return runUptoChore.$returnValue$;
@@ -3645,7 +3745,7 @@
3645
3745
  }
3646
3746
  while (choreQueue.length) {
3647
3747
  const nextChore = choreQueue.shift();
3648
- const order = choreComparator(nextChore, runUptoChore, false);
3748
+ const order = choreComparator(nextChore, runUptoChore, rootVNode, false);
3649
3749
  if (order === null) {
3650
3750
  continue;
3651
3751
  }
@@ -3661,7 +3761,7 @@
3661
3761
  }
3662
3762
  const returnValue = executeChore(nextChore);
3663
3763
  if (isPromise(returnValue)) {
3664
- const promise = returnValue.then(() => drainUpTo(runUptoChore));
3764
+ const promise = returnValue.then(() => drainUpTo(runUptoChore, rootVNode));
3665
3765
  return promise;
3666
3766
  }
3667
3767
  }
@@ -3782,7 +3882,7 @@
3782
3882
  vnode_isVNode(chore.$host$) &&
3783
3883
  chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
3784
3884
  }
3785
- function choreComparator(a, b, shouldThrowOnHostMismatch) {
3885
+ function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
3786
3886
  const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
3787
3887
  if (macroTypeDiff !== 0) {
3788
3888
  return macroTypeDiff;
@@ -3795,7 +3895,7 @@
3795
3895
  if (aHost !== bHost && aHost !== null && bHost !== null) {
3796
3896
  if (vnode_isVNode(aHost) && vnode_isVNode(bHost)) {
3797
3897
  // we are running on the client.
3798
- const hostDiff = vnode_documentPosition(aHost, bHost);
3898
+ const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
3799
3899
  if (hostDiff !== 0) {
3800
3900
  return hostDiff;
3801
3901
  }
@@ -3836,7 +3936,7 @@
3836
3936
  }
3837
3937
  return 0;
3838
3938
  }
3839
- function sortedFindIndex(sortedArray, value) {
3939
+ function sortedFindIndex(sortedArray, value, rootVNode) {
3840
3940
  /// We need to ensure that the `queue` is sorted by priority.
3841
3941
  /// 1. Find a place where to insert into.
3842
3942
  let bottom = 0;
@@ -3844,7 +3944,7 @@
3844
3944
  while (bottom < top) {
3845
3945
  const middle = bottom + ((top - bottom) >> 1);
3846
3946
  const midChore = sortedArray[middle];
3847
- const comp = choreComparator(value, midChore, true);
3947
+ const comp = choreComparator(value, midChore, rootVNode, true);
3848
3948
  if (comp < 0) {
3849
3949
  top = middle;
3850
3950
  }
@@ -3858,10 +3958,10 @@
3858
3958
  }
3859
3959
  return ~bottom;
3860
3960
  }
3861
- function sortedInsert(sortedArray, value) {
3961
+ function sortedInsert(sortedArray, value, rootVNode) {
3862
3962
  /// We need to ensure that the `queue` is sorted by priority.
3863
3963
  /// 1. Find a place where to insert into.
3864
- const idx = sortedFindIndex(sortedArray, value);
3964
+ const idx = sortedFindIndex(sortedArray, value, rootVNode);
3865
3965
  if (idx < 0) {
3866
3966
  /// 2. Insert the chore into the queue.
3867
3967
  sortedArray.splice(~idx, 0, value);
@@ -3939,7 +4039,7 @@
3939
4039
  cleanupTask(task);
3940
4040
  const iCtx = newInvokeContext(container.$locale$, host, undefined, TaskEvent);
3941
4041
  iCtx.$container$ = container;
3942
- const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(task));
4042
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearSubscriberEffectDependencies(container, task));
3943
4043
  const track = (obj, prop) => {
3944
4044
  const ctx = newInvokeContext();
3945
4045
  ctx.$effectSubscriber$ = [task, EffectProperty.COMPONENT];
@@ -4571,7 +4671,7 @@
4571
4671
  appendClassIfScopedStyleExists(jsx, options.styleScoped);
4572
4672
  let qwikInspectorAttrValue = null;
4573
4673
  if (build.isDev && jsx.dev && jsx.type !== 'head') {
4574
- qwikInspectorAttrValue = getQwikInspectorAttributeValue(jsx.dev);
4674
+ qwikInspectorAttrValue = getFileLocationFromJsx(jsx.dev);
4575
4675
  if (qInspector) {
4576
4676
  appendQwikInspectorAttribute(jsx, qwikInspectorAttrValue);
4577
4677
  }
@@ -4845,13 +4945,6 @@
4845
4945
  }
4846
4946
  return directGetPropsProxyProp(jsx, 'name') || QDefaultSlot;
4847
4947
  }
4848
- function getQwikInspectorAttributeValue(jsxDev) {
4849
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, '/');
4850
- if (sanitizedFileName) {
4851
- return `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}`;
4852
- }
4853
- return null;
4854
- }
4855
4948
  function appendQwikInspectorAttribute(jsx, qwikInspectorAttrValue) {
4856
4949
  if (qwikInspectorAttrValue && (!jsx.constProps || !(qwikInspectorAttr in jsx.constProps))) {
4857
4950
  (jsx.constProps ||= {})[qwikInspectorAttr] = qwikInspectorAttrValue;
@@ -4873,7 +4966,7 @@
4873
4966
  *
4874
4967
  * @public
4875
4968
  */
4876
- const version = "2.0.0-alpha.4-dev+374e0d6";
4969
+ const version = "2.0.0-alpha.5-dev+cb53bbd";
4877
4970
 
4878
4971
  /** @internal */
4879
4972
  class _SharedContainer {
@@ -6764,7 +6857,7 @@
6764
6857
  assertTrue(vnode_isTextVNode(vnode), 'Expecting Text Node.');
6765
6858
  return vnode[TextVNodeProps.node];
6766
6859
  };
6767
- function vnode_toString(depth = 10, offset = '', materialize = false, siblings = false) {
6860
+ function vnode_toString(depth = 20, offset = '', materialize = false, siblings = false) {
6768
6861
  let vnode = this;
6769
6862
  if (depth === 0) {
6770
6863
  return '...';
@@ -6981,20 +7074,24 @@
6981
7074
  throw qError(QError.invalidVNodeType, [type]);
6982
7075
  };
6983
7076
  const isElement = (node) => node && typeof node == 'object' && fastNodeType(node) === /** Node.ELEMENT_NODE* */ 1;
6984
- /// These global variables are used to avoid creating new arrays for each call to `vnode_getPathToClosestDomNode`.
7077
+ /// These global variables are used to avoid creating new arrays for each call to `vnode_documentPosition`.
6985
7078
  const aPath = [];
6986
7079
  const bPath = [];
6987
- const vnode_documentPosition = (a, b) => {
7080
+ const vnode_documentPosition = (a, b, rootVNode) => {
6988
7081
  if (a === b) {
6989
7082
  return 0;
6990
7083
  }
6991
7084
  let aDepth = -1;
6992
7085
  let bDepth = -1;
6993
7086
  while (a) {
6994
- a = (aPath[++aDepth] = a)[VNodeProps.parent];
7087
+ const vNode = (aPath[++aDepth] = a);
7088
+ a = (vNode[VNodeProps.parent] ||
7089
+ (rootVNode && vnode_getProp(a, QSlotParent, (id) => vnode_locate(rootVNode, id))));
6995
7090
  }
6996
7091
  while (b) {
6997
- b = (bPath[++bDepth] = b)[VNodeProps.parent];
7092
+ const vNode = (bPath[++bDepth] = b);
7093
+ b = (vNode[VNodeProps.parent] ||
7094
+ (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))));
6998
7095
  }
6999
7096
  while (aDepth >= 0 && bDepth >= 0) {
7000
7097
  a = aPath[aDepth];
@@ -7020,6 +7117,11 @@
7020
7117
  return -1;
7021
7118
  }
7022
7119
  } while (cursor);
7120
+ if (rootVNode && vnode_getProp(b, QSlotParent, (id) => vnode_locate(rootVNode, id))) {
7121
+ // The "b" node is a projection, so we need to set it after "a" node,
7122
+ // because the "a" node could be a context provider.
7123
+ return -1;
7124
+ }
7023
7125
  // The node is not in the list of siblings, that means it must be disconnected.
7024
7126
  return 1;
7025
7127
  }
@@ -7052,11 +7154,7 @@
7052
7154
  while (projectionDepth--) {
7053
7155
  while (vHost &&
7054
7156
  (vnode_isVirtualVNode(vHost) ? vnode_getProp(vHost, OnRenderProp, null) === null : true)) {
7055
- const qSlotParentProp = vnode_getProp(vHost, QSlotParent, null);
7056
- const qSlotParent = qSlotParentProp &&
7057
- (typeof qSlotParentProp === 'string'
7058
- ? vnode_locate(rootVNode, qSlotParentProp)
7059
- : qSlotParentProp);
7157
+ const qSlotParent = vnode_getProp(vHost, QSlotParent, (id) => vnode_locate(rootVNode, id));
7060
7158
  const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
7061
7159
  if (vProjectionParent) {
7062
7160
  // We found a projection, so we need to go up one more level.
@@ -7965,14 +8063,14 @@
7965
8063
  if (vnode_getProp(vNode, OnRenderProp, null) !== null) {
7966
8064
  return vNode;
7967
8065
  }
7968
- // If virtual node, than it could be a slot so we need to read its parent.
7969
- const parent = vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
7970
- if (parent) {
7971
- vNode = parent;
7972
- continue;
7973
- }
8066
+ vNode =
8067
+ vnode_getParent(vNode) ||
8068
+ // If virtual node, than it could be a slot so we need to read its parent.
8069
+ vnode_getProp(vNode, QSlotParent, this.$vnodeLocate$);
8070
+ }
8071
+ else {
8072
+ vNode = vnode_getParent(vNode);
7974
8073
  }
7975
- vNode = vnode_getParent(vNode);
7976
8074
  }
7977
8075
  return null;
7978
8076
  }
@@ -8072,12 +8170,6 @@
8072
8170
 
8073
8171
  /** There's [documentation](./serialization.md) */
8074
8172
  const deserializedProxyMap = new WeakMap();
8075
- const unwrapDeserializerProxy = (value) => {
8076
- const unwrapped = typeof value === 'object' &&
8077
- value !== null &&
8078
- value[SERIALIZER_PROXY_UNWRAP];
8079
- return unwrapped ? unwrapped : value;
8080
- };
8081
8173
  const isDeserializerProxy = (value) => {
8082
8174
  return typeof value === 'object' && value !== null && SERIALIZER_PROXY_UNWRAP in value;
8083
8175
  };
@@ -8130,14 +8222,14 @@
8130
8222
  return value;
8131
8223
  }
8132
8224
  const container = this.$container$;
8133
- const propValue = allocate(container, typeId, value);
8134
- Reflect.set(target, property, propValue);
8135
- this.$data$[idx] = undefined;
8136
- this.$data$[idx + 1] = propValue;
8225
+ let propValue = allocate(container, typeId, value);
8137
8226
  /** We stored the reference, so now we can inflate, allowing cycles. */
8138
8227
  if (typeId >= TypeIds.Error) {
8139
- inflate(container, propValue, typeId, value);
8228
+ propValue = inflate(container, propValue, typeId, value);
8140
8229
  }
8230
+ Reflect.set(target, property, propValue);
8231
+ this.$data$[idx] = undefined;
8232
+ this.$data$[idx + 1] = propValue;
8141
8233
  return propValue;
8142
8234
  }
8143
8235
  has(target, property) {
@@ -8176,7 +8268,7 @@
8176
8268
  const inflate = (container, target, typeId, data) => {
8177
8269
  if (typeId === undefined) {
8178
8270
  // Already processed
8179
- return;
8271
+ return target;
8180
8272
  }
8181
8273
  // restore the complex data, except for plain objects
8182
8274
  if (typeId !== TypeIds.Object && Array.isArray(data)) {
@@ -8248,16 +8340,13 @@
8248
8340
  case TypeIds.Store:
8249
8341
  case TypeIds.StoreArray: {
8250
8342
  const [value, flags, effects, storeEffect] = data;
8251
- const handler = getStoreHandler(target);
8252
- handler.$flags$ = flags;
8253
- // First assign so it sets up the deep stores
8254
- Object.assign(getStoreTarget(target), value);
8255
- // Afterwards restore the effects so they don't get triggered
8343
+ const store = getOrCreateStore(value, flags, container);
8344
+ const storeHandler = getStoreHandler(store);
8256
8345
  if (storeEffect) {
8257
8346
  effects[STORE_ARRAY_PROP] = storeEffect;
8258
8347
  }
8259
- handler.$effects$ = effects;
8260
- container.$storeProxyMap$.set(value, target);
8348
+ storeHandler.$effects$ = effects;
8349
+ target = store;
8261
8350
  break;
8262
8351
  }
8263
8352
  case TypeIds.Signal: {
@@ -8384,6 +8473,7 @@
8384
8473
  default:
8385
8474
  throw qError(QError.serializeErrorNotImplemented, [typeId]);
8386
8475
  }
8476
+ return target;
8387
8477
  };
8388
8478
  const _constants = [
8389
8479
  undefined,
@@ -8449,9 +8539,9 @@
8449
8539
  case TypeIds.ComputedSignal:
8450
8540
  return new ComputedSignal(container, null);
8451
8541
  case TypeIds.Store:
8452
- return createStore(container, {}, 0);
8453
8542
  case TypeIds.StoreArray:
8454
- return createStore(container, [], 0);
8543
+ // ignore allocate, we need to assign target while creating store
8544
+ return null;
8455
8545
  case TypeIds.URLSearchParams:
8456
8546
  return new URLSearchParams(value);
8457
8547
  case TypeIds.FormData:
@@ -9313,15 +9403,15 @@
9313
9403
  }
9314
9404
  return output;
9315
9405
  }
9316
- function deserializeData(container, typeId, propValue) {
9406
+ function deserializeData(container, typeId, value) {
9317
9407
  if (typeId === undefined) {
9318
- return propValue;
9408
+ return value;
9319
9409
  }
9320
- const value = allocate(container, typeId, propValue);
9410
+ let propValue = allocate(container, typeId, value);
9321
9411
  if (typeId >= TypeIds.Error) {
9322
- inflate(container, value, typeId, propValue);
9412
+ propValue = inflate(container, propValue, typeId, value);
9323
9413
  }
9324
- return value;
9414
+ return propValue;
9325
9415
  }
9326
9416
  function getObjectById(id, stateData) {
9327
9417
  if (typeof id === 'string') {