@qwik.dev/core 2.0.0-alpha.5 → 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.5-dev+cb53bbd
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
@@ -64,15 +64,41 @@
64
64
  QError[QError.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError[QError.wrongTextareaValue = 40] = "wrongTextareaValue",
65
65
  QError[QError.containerNotFound = 41] = "containerNotFound", QError[QError.elementWithoutContainer = 42] = "elementWithoutContainer",
66
66
  QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
67
- QError[QError.serverHostMismatch = 45] = "serverHostMismatch", QError[QError.cannotCoerceSignal = 46] = "cannotCoerceSignal",
68
- QError[QError.computedNotSync = 47] = "computedNotSync", QError[QError.computedReadOnly = 48] = "computedReadOnly",
69
- QError[QError.wrappedReadOnly = 49] = "wrappedReadOnly", QError[QError.promisesNotExpected = 50] = "promisesNotExpected",
70
- QError[QError.unsafeAttr = 51] = "unsafeAttr";
67
+ QError[QError.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError[QError.computedNotSync = 46] = "computedNotSync",
68
+ QError[QError.computedReadOnly = 47] = "computedReadOnly", QError[QError.wrappedReadOnly = 48] = "wrappedReadOnly",
69
+ QError[QError.promisesNotExpected = 49] = "promisesNotExpected", QError[QError.unsafeAttr = 50] = "unsafeAttr";
71
70
  }(QError || (QError = {}));
72
71
  const qError = (code, errorMessageArgs = []) => {
73
72
  const text = (code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...errorMessageArgs);
74
73
  return ((message, ...optionalParams) => createAndLogError(!0, message, ...optionalParams))(text, ...errorMessageArgs);
75
74
  };
75
+ var VirtualType;
76
+ !function(VirtualType) {
77
+ VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
78
+ VirtualType.Awaited = "A", VirtualType.Component = "C", VirtualType.InlineComponent = "I",
79
+ VirtualType.Projection = "P";
80
+ }(VirtualType || (VirtualType = {}));
81
+ const VirtualTypeName = {
82
+ [VirtualType.Virtual]: "Virtual",
83
+ [VirtualType.Fragment]: "Fragment",
84
+ [VirtualType.WrappedSignal]: "Signal",
85
+ [VirtualType.Awaited]: "Awaited",
86
+ [VirtualType.Component]: "Component",
87
+ [VirtualType.InlineComponent]: "InlineComponent",
88
+ [VirtualType.Projection]: "Projection"
89
+ };
90
+ var QContainerValue;
91
+ !function(QContainerValue) {
92
+ QContainerValue.PAUSED = "paused", QContainerValue.RESUMED = "resumed", QContainerValue.HTML = "html",
93
+ QContainerValue.TEXT = "text";
94
+ }(QContainerValue || (QContainerValue = {}));
95
+ const QSlot = "q:slot";
96
+ const QSlotS = "q:s";
97
+ const getQFuncs = (document, hash) => document["qFuncs_" + hash] || [];
98
+ const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
99
+ const HTML_NS = "http://www.w3.org/1999/xhtml";
100
+ const SVG_NS = "http://www.w3.org/2000/svg";
101
+ const MATH_NS = "http://www.w3.org/1998/Math/MathML";
76
102
  const createPlatform = () => ({
77
103
  isServer: build.isServer,
78
104
  importSymbol(containerEl, url, symbolName) {
@@ -133,13 +159,17 @@
133
159
  setTimeout(resolve, timeout);
134
160
  }));
135
161
  function retryOnPromise(fn, retryCount = 0) {
136
- try {
137
- return fn();
138
- } catch (e) {
162
+ const retryOrThrow = e => {
139
163
  if (isPromise(e) && retryCount < 100) {
140
164
  return e.then(retryOnPromise.bind(null, fn, retryCount++));
141
165
  }
142
166
  throw e;
167
+ };
168
+ try {
169
+ const result = fn();
170
+ return isPromise(result) ? result.catch((e => retryOrThrow(e))) : result;
171
+ } catch (e) {
172
+ return retryOrThrow(e);
143
173
  }
144
174
  }
145
175
  const isSerializableObject = v => {
@@ -151,39 +181,12 @@
151
181
  const isString = v => "string" == typeof v;
152
182
  const isFunction = v => "function" == typeof v;
153
183
  var VNodeDataFlag;
184
+ let _locale;
154
185
  !function(VNodeDataFlag) {
155
186
  VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
156
187
  VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.ELEMENT_NODE = 4] = "ELEMENT_NODE",
157
188
  VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
158
189
  }(VNodeDataFlag || (VNodeDataFlag = {}));
159
- var VirtualType;
160
- !function(VirtualType) {
161
- VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
162
- VirtualType.Awaited = "A", VirtualType.Component = "C", VirtualType.InlineComponent = "I",
163
- VirtualType.Projection = "P";
164
- }(VirtualType || (VirtualType = {}));
165
- const VirtualTypeName = {
166
- [VirtualType.Virtual]: "Virtual",
167
- [VirtualType.Fragment]: "Fragment",
168
- [VirtualType.WrappedSignal]: "Signal",
169
- [VirtualType.Awaited]: "Awaited",
170
- [VirtualType.Component]: "Component",
171
- [VirtualType.InlineComponent]: "InlineComponent",
172
- [VirtualType.Projection]: "Projection"
173
- };
174
- var QContainerValue;
175
- !function(QContainerValue) {
176
- QContainerValue.PAUSED = "paused", QContainerValue.RESUMED = "resumed", QContainerValue.HTML = "html",
177
- QContainerValue.TEXT = "text";
178
- }(QContainerValue || (QContainerValue = {}));
179
- const QSlot = "q:slot";
180
- const QSlotS = "q:s";
181
- const getQFuncs = (document, hash) => document["qFuncs_" + hash] || [];
182
- const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
183
- const HTML_NS = "http://www.w3.org/1999/xhtml";
184
- const SVG_NS = "http://www.w3.org/2000/svg";
185
- const MATH_NS = "http://www.w3.org/1998/Math/MathML";
186
- let _locale;
187
190
  const EMPTY_ARRAY = [];
188
191
  const EMPTY_OBJ = {};
189
192
  Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
@@ -569,6 +572,17 @@
569
572
  } else if ("object" == typeof arg && null !== arg) {
570
573
  if (isStore(arg)) {
571
574
  clearStoreEffects(getStoreHandler(arg), subscriber);
575
+ } else if (isPropsProxy(arg)) {
576
+ const constProps = arg[_CONST_PROPS];
577
+ const varProps = arg[_VAR_PROPS];
578
+ if (constProps) {
579
+ for (const key in constProps) {
580
+ clearArgEffect(constProps[key], subscriber, seenSet);
581
+ }
582
+ }
583
+ for (const key in varProps) {
584
+ clearArgEffect(varProps[key], subscriber, seenSet);
585
+ }
572
586
  } else {
573
587
  for (const key in arg) {
574
588
  clearArgEffect(arg[key], subscriber, seenSet);
@@ -1516,6 +1530,10 @@
1516
1530
  const createSignal = value => new Signal(null, value);
1517
1531
  const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
1518
1532
  const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
1533
+ const aVNodePath = [];
1534
+ const bVNodePath = [];
1535
+ const aSsrNodePath = [];
1536
+ const bSsrNodePath = [];
1519
1537
  var ChoreType;
1520
1538
  !function(ChoreType) {
1521
1539
  ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
@@ -1551,7 +1569,7 @@
1551
1569
  let top = sortedArray.length;
1552
1570
  for (;bottom < top; ) {
1553
1571
  const middle = bottom + (top - bottom >> 1);
1554
- const comp = choreComparator(value, sortedArray[middle], rootVNode, !0);
1572
+ const comp = choreComparator(value, sortedArray[middle], rootVNode);
1555
1573
  if (comp < 0) {
1556
1574
  top = middle;
1557
1575
  } else {
@@ -1581,7 +1599,7 @@
1581
1599
  }
1582
1600
  for (;choreQueue.length; ) {
1583
1601
  const nextChore = choreQueue.shift();
1584
- const order = choreComparator(nextChore, runUptoChore, rootVNode, !1);
1602
+ const order = choreComparator(nextChore, runUptoChore, rootVNode);
1585
1603
  if (null === order) {
1586
1604
  continue;
1587
1605
  }
@@ -1613,7 +1631,7 @@
1613
1631
  returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
1614
1632
  if (chore.$type$ === ChoreType.COMPONENT) {
1615
1633
  const styleScopedId = container.getHostProp(host, "q:sstyle");
1616
- return vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId));
1634
+ return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
1617
1635
  }
1618
1636
  return jsx;
1619
1637
  }), (err => container.handleError(err, host)));
@@ -1636,7 +1654,7 @@
1636
1654
  case ChoreType.NODE_DIFF:
1637
1655
  const parentVirtualNode = chore.$target$;
1638
1656
  let jsx = chore.$payload$;
1639
- isSignal(jsx) && (jsx = jsx.value), returnValue = vnode_diff(container, jsx, parentVirtualNode, null);
1657
+ isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
1640
1658
  break;
1641
1659
 
1642
1660
  case ChoreType.NODE_PROP:
@@ -1684,7 +1702,7 @@
1684
1702
  const choreUpdate = (existing, newChore) => {
1685
1703
  existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = newChore.$payload$);
1686
1704
  };
1687
- function choreComparator(a, b, rootVNode, shouldThrowOnHostMismatch) {
1705
+ function choreComparator(a, b, rootVNode) {
1688
1706
  const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
1689
1707
  if (0 !== macroTypeDiff) {
1690
1708
  return macroTypeDiff;
@@ -1693,15 +1711,65 @@
1693
1711
  const aHost = a.$host$;
1694
1712
  const bHost = b.$host$;
1695
1713
  if (aHost !== bHost && null !== aHost && null !== bHost) {
1696
- if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
1697
- 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()}`;
1698
- if (shouldThrowOnHostMismatch) {
1699
- throw qError(QError.serverHostMismatch, [ errorMessage ]);
1714
+ if (vnode_isVNode(aHost) && vnode_isVNode(bHost)) {
1715
+ const hostDiff = ((a, b, rootVNode) => {
1716
+ if (a === b) {
1717
+ return 0;
1718
+ }
1719
+ let aDepth = -1;
1720
+ let bDepth = -1;
1721
+ for (;a; ) {
1722
+ a = (aVNodePath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, ":", (id => vnode_locate(rootVNode, id)));
1723
+ }
1724
+ for (;b; ) {
1725
+ b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id)));
1726
+ }
1727
+ for (;aDepth >= 0 && bDepth >= 0; ) {
1728
+ if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
1729
+ let cursor = b;
1730
+ do {
1731
+ if (cursor = vnode_getNextSibling(cursor), cursor === a) {
1732
+ return 1;
1733
+ }
1734
+ } while (cursor);
1735
+ cursor = b;
1736
+ do {
1737
+ if (cursor = vnode_getPreviousSibling(cursor), cursor === a) {
1738
+ return -1;
1739
+ }
1740
+ } while (cursor);
1741
+ return rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
1742
+ }
1743
+ aDepth--, bDepth--;
1744
+ }
1745
+ return aDepth < bDepth ? -1 : 1;
1746
+ })(aHost, bHost, rootVNode);
1747
+ if (0 !== hostDiff) {
1748
+ return hostDiff;
1700
1749
  }
1701
- return logWarn(errorMessage), null;
1702
- }
1703
- {
1704
- const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
1750
+ } else {
1751
+ 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()}`;
1752
+ logWarn(errorMessage);
1753
+ const hostDiff = ((a, b) => {
1754
+ if (a === b) {
1755
+ return 0;
1756
+ }
1757
+ let aDepth = -1;
1758
+ let bDepth = -1;
1759
+ for (;a; ) {
1760
+ a = (aSsrNodePath[++aDepth] = a).currentComponentNode;
1761
+ }
1762
+ for (;b; ) {
1763
+ b = (bSsrNodePath[++bDepth] = b).currentComponentNode;
1764
+ }
1765
+ for (;aDepth >= 0 && bDepth >= 0; ) {
1766
+ if ((a = aSsrNodePath[aDepth]) !== (b = bSsrNodePath[bDepth])) {
1767
+ return 1;
1768
+ }
1769
+ aDepth--, bDepth--;
1770
+ }
1771
+ return aDepth < bDepth ? -1 : 1;
1772
+ })(aHost, bHost);
1705
1773
  if (0 !== hostDiff) {
1706
1774
  return hostDiff;
1707
1775
  }
@@ -2299,7 +2367,7 @@
2299
2367
  const eventName = key.substring(15);
2300
2368
  eventName && serializationCtx.$eventNames$.add(eventName);
2301
2369
  }
2302
- const version = "2.0.0-alpha.5-dev+cb53bbd";
2370
+ const version = "2.0.0-alpha.6-dev+d848ba5";
2303
2371
  class _SharedContainer {
2304
2372
  $version$;
2305
2373
  $scheduler$;
@@ -3222,6 +3290,7 @@
3222
3290
  }
3223
3291
  };
3224
3292
  const vnode_getNextSibling = vnode => vnode[VNodeProps.nextSibling];
3293
+ const vnode_getPreviousSibling = vnode => vnode[VNodeProps.previousSibling];
3225
3294
  const vnode_getAttrKeys = vnode => {
3226
3295
  if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3227
3296
  vnode_ensureElementInflated(vnode);
@@ -3357,40 +3426,6 @@
3357
3426
  throw qError(QError.invalidVNodeType, [ type ]);
3358
3427
  };
3359
3428
  const isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
3360
- const aPath = [];
3361
- const bPath = [];
3362
- const vnode_documentPosition = (a, b, rootVNode) => {
3363
- if (a === b) {
3364
- return 0;
3365
- }
3366
- let aDepth = -1;
3367
- let bDepth = -1;
3368
- for (;a; ) {
3369
- a = (aPath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, ":", (id => vnode_locate(rootVNode, id)));
3370
- }
3371
- for (;b; ) {
3372
- b = (bPath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id)));
3373
- }
3374
- for (;aDepth >= 0 && bDepth >= 0; ) {
3375
- if ((a = aPath[aDepth]) !== (b = bPath[bDepth])) {
3376
- let cursor = b;
3377
- do {
3378
- if (cursor = vnode_getNextSibling(cursor), cursor === a) {
3379
- return 1;
3380
- }
3381
- } while (cursor);
3382
- cursor = b;
3383
- do {
3384
- if (cursor = cursor[VNodeProps.previousSibling], cursor === a) {
3385
- return -1;
3386
- }
3387
- } while (cursor);
3388
- return rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
3389
- }
3390
- aDepth--, bDepth--;
3391
- }
3392
- return aDepth < bDepth ? -1 : 1;
3393
- };
3394
3429
  const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
3395
3430
  let projectionDepth = 1;
3396
3431
  for (;projectionDepth--; ) {