@qwik.dev/core 2.0.0-alpha.7 → 2.0.0-alpha.8
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/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +16 -3
- package/dist/core.cjs +132 -78
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +132 -79
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +112 -85
- package/dist/core.prod.mjs +121 -94
- package/dist/insights/index.qwik.cjs +96 -82
- package/dist/insights/index.qwik.mjs +96 -82
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +20 -3
- package/dist/optimizer.mjs +19 -3
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +32 -32
- package/dist/server.mjs +32 -32
- package/dist/testing/index.cjs +111 -91
- package/dist/testing/index.mjs +118 -97
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
package/dist/core.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core 2.0.0-alpha.8-dev+66037b5
|
|
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
|
|
@@ -313,8 +313,7 @@ const OnRenderProp = 'q:renderFn';
|
|
|
313
313
|
const ComponentStylesPrefixContent = '⚡️';
|
|
314
314
|
/** `<some-element q:slot="...">` */
|
|
315
315
|
const QSlot = 'q:slot';
|
|
316
|
-
const QSlotParent = ':';
|
|
317
|
-
const QSlotRef = 'q:sref';
|
|
316
|
+
const QSlotParent = 'q:sparent';
|
|
318
317
|
const QSlotS = 'q:s';
|
|
319
318
|
const QStyle = 'q:style';
|
|
320
319
|
const QStyleSelector = 'style[q\\:style]';
|
|
@@ -351,6 +350,7 @@ const MATH_NS = 'http://www.w3.org/1998/Math/MathML';
|
|
|
351
350
|
const ResourceEvent = 'qResource';
|
|
352
351
|
const RenderEvent = 'qRender';
|
|
353
352
|
const TaskEvent = 'qTask';
|
|
353
|
+
/** `<q:slot name="...">` */
|
|
354
354
|
const QDefaultSlot = '';
|
|
355
355
|
/**
|
|
356
356
|
* Attribute to mark that this VNode has a pointer to itself from the `qwik/json` state.
|
|
@@ -1150,7 +1150,7 @@ const styleKey = (qStyles, index) => {
|
|
|
1150
1150
|
|
|
1151
1151
|
const STORE_TARGET = Symbol('store.target');
|
|
1152
1152
|
const STORE_HANDLER = Symbol('store.handler');
|
|
1153
|
-
const
|
|
1153
|
+
const STORE_ALL_PROPS = Symbol('store.all');
|
|
1154
1154
|
var StoreFlags;
|
|
1155
1155
|
(function (StoreFlags) {
|
|
1156
1156
|
StoreFlags[StoreFlags["NONE"] = 0] = "NONE";
|
|
@@ -1225,7 +1225,7 @@ class StoreHandler {
|
|
|
1225
1225
|
}
|
|
1226
1226
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1227
1227
|
if (effectSubscriber) {
|
|
1228
|
-
|
|
1228
|
+
addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
|
|
1229
1229
|
}
|
|
1230
1230
|
}
|
|
1231
1231
|
if (prop === 'toString' && value === Object.prototype.toString) {
|
|
@@ -1276,7 +1276,7 @@ class StoreHandler {
|
|
|
1276
1276
|
if (ctx) {
|
|
1277
1277
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1278
1278
|
if (effectSubscriber) {
|
|
1279
|
-
|
|
1279
|
+
addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
|
|
1280
1280
|
}
|
|
1281
1281
|
}
|
|
1282
1282
|
}
|
|
@@ -1286,7 +1286,7 @@ class StoreHandler {
|
|
|
1286
1286
|
const ctx = tryGetInvokeContext();
|
|
1287
1287
|
const effectSubscriber = ctx?.$effectSubscriber$;
|
|
1288
1288
|
if (effectSubscriber) {
|
|
1289
|
-
|
|
1289
|
+
addStoreEffect(target, STORE_ALL_PROPS, this, effectSubscriber);
|
|
1290
1290
|
}
|
|
1291
1291
|
return Reflect.ownKeys(target);
|
|
1292
1292
|
}
|
|
@@ -1304,7 +1304,7 @@ class StoreHandler {
|
|
|
1304
1304
|
};
|
|
1305
1305
|
}
|
|
1306
1306
|
}
|
|
1307
|
-
function
|
|
1307
|
+
function addStoreEffect(target, prop, store, effectSubscription) {
|
|
1308
1308
|
const effectsMap = (store.$effects$ ||= new Map());
|
|
1309
1309
|
let effects = effectsMap.get(prop);
|
|
1310
1310
|
if (!effects) {
|
|
@@ -1340,7 +1340,7 @@ function getEffects(target, prop, storeEffects) {
|
|
|
1340
1340
|
effectsToTrigger = storeEffects.get(prop);
|
|
1341
1341
|
}
|
|
1342
1342
|
}
|
|
1343
|
-
const storeArrayValue = storeEffects?.get(
|
|
1343
|
+
const storeArrayValue = storeEffects?.get(STORE_ALL_PROPS);
|
|
1344
1344
|
if (storeArrayValue) {
|
|
1345
1345
|
effectsToTrigger ||= new Set();
|
|
1346
1346
|
for (const effect of storeArrayValue) {
|
|
@@ -1589,6 +1589,11 @@ const runTask = (task, container, host) => {
|
|
|
1589
1589
|
else if (isSignal(obj)) {
|
|
1590
1590
|
return obj.value;
|
|
1591
1591
|
}
|
|
1592
|
+
else if (isStore(obj)) {
|
|
1593
|
+
// track whole store
|
|
1594
|
+
addStoreEffect(getStoreTarget(obj), STORE_ALL_PROPS, getStoreHandler(obj), ctx.$effectSubscriber$);
|
|
1595
|
+
return obj;
|
|
1596
|
+
}
|
|
1592
1597
|
else {
|
|
1593
1598
|
throw qError(QError.trackObjectWithoutProp);
|
|
1594
1599
|
}
|
|
@@ -1746,13 +1751,13 @@ var VirtualVNodeProps;
|
|
|
1746
1751
|
VirtualVNodeProps[VirtualVNodeProps["PROPS_OFFSET"] = 6] = "PROPS_OFFSET";
|
|
1747
1752
|
})(VirtualVNodeProps || (VirtualVNodeProps = {}));
|
|
1748
1753
|
|
|
1749
|
-
const mapApp_findIndx = (
|
|
1754
|
+
const mapApp_findIndx = (array, key, start) => {
|
|
1750
1755
|
assertTrue(start % 2 === 0, 'Expecting even number.');
|
|
1751
1756
|
let bottom = start >> 1;
|
|
1752
|
-
let top = (
|
|
1757
|
+
let top = (array.length - 2) >> 1;
|
|
1753
1758
|
while (bottom <= top) {
|
|
1754
1759
|
const mid = bottom + ((top - bottom) >> 1);
|
|
1755
|
-
const midKey =
|
|
1760
|
+
const midKey = array[mid << 1];
|
|
1756
1761
|
if (midKey === key) {
|
|
1757
1762
|
return mid << 1;
|
|
1758
1763
|
}
|
|
@@ -1765,24 +1770,24 @@ const mapApp_findIndx = (elementVNode, key, start) => {
|
|
|
1765
1770
|
}
|
|
1766
1771
|
return (bottom << 1) ^ -1;
|
|
1767
1772
|
};
|
|
1768
|
-
const mapArray_set = (
|
|
1769
|
-
const indx = mapApp_findIndx(
|
|
1773
|
+
const mapArray_set = (array, key, value, start) => {
|
|
1774
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
1770
1775
|
if (indx >= 0) {
|
|
1771
1776
|
if (value == null) {
|
|
1772
|
-
|
|
1777
|
+
array.splice(indx, 2);
|
|
1773
1778
|
}
|
|
1774
1779
|
else {
|
|
1775
|
-
|
|
1780
|
+
array[indx + 1] = value;
|
|
1776
1781
|
}
|
|
1777
1782
|
}
|
|
1778
1783
|
else if (value != null) {
|
|
1779
|
-
|
|
1784
|
+
array.splice(indx ^ -1, 0, key, value);
|
|
1780
1785
|
}
|
|
1781
1786
|
};
|
|
1782
|
-
const mapArray_get = (
|
|
1783
|
-
const indx = mapApp_findIndx(
|
|
1787
|
+
const mapArray_get = (array, key, start) => {
|
|
1788
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
1784
1789
|
if (indx >= 0) {
|
|
1785
|
-
return
|
|
1790
|
+
return array[indx + 1];
|
|
1786
1791
|
}
|
|
1787
1792
|
else {
|
|
1788
1793
|
return null;
|
|
@@ -2350,9 +2355,6 @@ const _IMMUTABLE = Symbol('IMMUTABLE');
|
|
|
2350
2355
|
function isSlotProp(prop) {
|
|
2351
2356
|
return !prop.startsWith('q:') && !prop.startsWith(NON_SERIALIZABLE_MARKER_PREFIX);
|
|
2352
2357
|
}
|
|
2353
|
-
function isParentSlotProp(prop) {
|
|
2354
|
-
return prop.startsWith(QSlotParent);
|
|
2355
|
-
}
|
|
2356
2358
|
/** @internal */
|
|
2357
2359
|
const _restProps = (props, omit, target = {}) => {
|
|
2358
2360
|
let constPropsTarget = null;
|
|
@@ -2746,6 +2748,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2746
2748
|
// console.log('expectProjection', JSON.stringify(slotName));
|
|
2747
2749
|
vCurrent = vnode_getProp(vParent, // The parent is the component and it should have our portal.
|
|
2748
2750
|
slotName, (id) => vnode_locate(container.rootVNode, id));
|
|
2751
|
+
// if projection is marked as deleted then we need to create a new one
|
|
2752
|
+
vCurrent = vCurrent && vCurrent[VNodeProps.flags] & VNodeFlags.Deleted ? null : vCurrent;
|
|
2749
2753
|
if (vCurrent == null) {
|
|
2750
2754
|
vNewNode = vnode_newVirtual();
|
|
2751
2755
|
// you may be tempted to add the projection into the current parent, but
|
|
@@ -2782,6 +2786,19 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2782
2786
|
}
|
|
2783
2787
|
else if (vProjectedNode === vCurrent) ;
|
|
2784
2788
|
else {
|
|
2789
|
+
const parent = vnode_getParent(vProjectedNode);
|
|
2790
|
+
const isAlreadyProjected = !!parent && !(vnode_isElementVNode(parent) && vnode_getElementName(parent) === QTemplate);
|
|
2791
|
+
if (isAlreadyProjected && vParent !== parent) {
|
|
2792
|
+
/**
|
|
2793
|
+
* The node is already projected, but structure has been changed. In next steps we will
|
|
2794
|
+
* insert the vProjectedNode at the end. However we will find existing projection elements
|
|
2795
|
+
* (from already projected THE SAME projection as vProjectedNode!) during
|
|
2796
|
+
* vnode_insertBefore. We need to remove vnode from the vnode tree to avoid referencing it
|
|
2797
|
+
* to self and cause infinite loop. Don't remove it from DOM to avoid additional operations
|
|
2798
|
+
* and flickering.
|
|
2799
|
+
*/
|
|
2800
|
+
vnode_remove(journal, parent, vProjectedNode, false);
|
|
2801
|
+
}
|
|
2785
2802
|
// move from q:template to the target node
|
|
2786
2803
|
vnode_insertBefore(journal, vParent, (vNewNode = vProjectedNode), vCurrent && getInsertBefore());
|
|
2787
2804
|
vnode_setProp(vNewNode, QSlot, slotNameKey);
|
|
@@ -2835,8 +2852,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2835
2852
|
while (vCurrent) {
|
|
2836
2853
|
const toRemove = vCurrent;
|
|
2837
2854
|
advanceToNextSibling();
|
|
2838
|
-
cleanup(container, toRemove);
|
|
2839
2855
|
if (vParent === vnode_getParent(toRemove)) {
|
|
2856
|
+
cleanup(container, toRemove);
|
|
2840
2857
|
// If we are diffing projection than the parent is not the parent of the node.
|
|
2841
2858
|
// If that is the case we don't want to remove the node from the parent.
|
|
2842
2859
|
vnode_remove(journal, vParent, toRemove, true);
|
|
@@ -3276,10 +3293,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3276
3293
|
}
|
|
3277
3294
|
else if (!hashesAreEqual) {
|
|
3278
3295
|
insertNewComponent(host, componentQRL, jsxProps);
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
shouldRender = true;
|
|
3282
|
-
}
|
|
3296
|
+
host = vNewNode;
|
|
3297
|
+
shouldRender = true;
|
|
3283
3298
|
}
|
|
3284
3299
|
if (host) {
|
|
3285
3300
|
const vNodeProps = vnode_getProp(host, ELEMENT_PROPS, container.$getObjectById$);
|
|
@@ -3300,6 +3315,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3300
3315
|
const lookupKey = jsxNode.key;
|
|
3301
3316
|
const vNodeLookupKey = getKey(host);
|
|
3302
3317
|
const lookupKeysAreEqual = lookupKey === vNodeLookupKey;
|
|
3318
|
+
const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
|
|
3303
3319
|
if (!lookupKeysAreEqual) {
|
|
3304
3320
|
// See if we already have this inline component later on.
|
|
3305
3321
|
vNewNode = retrieveChildWithKey(null, lookupKey);
|
|
@@ -3313,6 +3329,11 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3313
3329
|
}
|
|
3314
3330
|
host = vNewNode;
|
|
3315
3331
|
}
|
|
3332
|
+
// inline components don't have component hash - q:renderFn prop, so it should be null
|
|
3333
|
+
else if (vNodeComponentHash != null) {
|
|
3334
|
+
insertNewInlineComponent();
|
|
3335
|
+
host = vNewNode;
|
|
3336
|
+
}
|
|
3316
3337
|
if (host) {
|
|
3317
3338
|
let componentHost = host;
|
|
3318
3339
|
// Find the closest component host which has `OnRender` prop. This is need for subscriptions context.
|
|
@@ -3457,6 +3478,7 @@ function cleanup(container, vNode) {
|
|
|
3457
3478
|
let vCursor = vNode;
|
|
3458
3479
|
// Depth first traversal
|
|
3459
3480
|
if (vnode_isTextVNode(vNode)) {
|
|
3481
|
+
markVNodeAsDeleted(vCursor);
|
|
3460
3482
|
// Text nodes don't have subscriptions or children;
|
|
3461
3483
|
return;
|
|
3462
3484
|
}
|
|
@@ -3492,7 +3514,7 @@ function cleanup(container, vNode) {
|
|
|
3492
3514
|
const attrs = vnode_getProps(vCursor);
|
|
3493
3515
|
for (let i = 0; i < attrs.length; i = i + 2) {
|
|
3494
3516
|
const key = attrs[i];
|
|
3495
|
-
if (
|
|
3517
|
+
if (isSlotProp(key)) {
|
|
3496
3518
|
const value = attrs[i + 1];
|
|
3497
3519
|
if (value) {
|
|
3498
3520
|
attrs[i + 1] = null; // prevent infinite loop
|
|
@@ -3509,7 +3531,7 @@ function cleanup(container, vNode) {
|
|
|
3509
3531
|
}
|
|
3510
3532
|
}
|
|
3511
3533
|
}
|
|
3512
|
-
const isProjection =
|
|
3534
|
+
const isProjection = vnode_isProjection(vCursor);
|
|
3513
3535
|
// Descend into children
|
|
3514
3536
|
if (!isProjection) {
|
|
3515
3537
|
// Only if it is not a projection
|
|
@@ -3532,6 +3554,9 @@ function cleanup(container, vNode) {
|
|
|
3532
3554
|
}
|
|
3533
3555
|
}
|
|
3534
3556
|
}
|
|
3557
|
+
else if (type & VNodeFlags.Text) {
|
|
3558
|
+
markVNodeAsDeleted(vCursor);
|
|
3559
|
+
}
|
|
3535
3560
|
// Out of children
|
|
3536
3561
|
if (vCursor === vNode) {
|
|
3537
3562
|
// we are where we started, this means that vNode has no children, so we are done.
|
|
@@ -4470,6 +4495,15 @@ function debugTrace(action, arg, currentChore, queue) {
|
|
|
4470
4495
|
const DEBUG = false;
|
|
4471
4496
|
// eslint-disable-next-line no-console
|
|
4472
4497
|
const log = (...args) => console.log('SIGNAL', ...args.map(qwikDebugToString));
|
|
4498
|
+
var SignalFlags;
|
|
4499
|
+
(function (SignalFlags) {
|
|
4500
|
+
SignalFlags[SignalFlags["INVALID"] = 1] = "INVALID";
|
|
4501
|
+
})(SignalFlags || (SignalFlags = {}));
|
|
4502
|
+
var WrappedSignalFlags;
|
|
4503
|
+
(function (WrappedSignalFlags) {
|
|
4504
|
+
// should subscribe to value and be unwrapped for PropsProxy
|
|
4505
|
+
WrappedSignalFlags[WrappedSignalFlags["UNWRAP"] = 2] = "UNWRAP";
|
|
4506
|
+
})(WrappedSignalFlags || (WrappedSignalFlags = {}));
|
|
4473
4507
|
const throwIfQRLNotResolved = (qrl) => {
|
|
4474
4508
|
const resolved = qrl.resolved;
|
|
4475
4509
|
if (!resolved) {
|
|
@@ -4562,7 +4596,7 @@ class Signal {
|
|
|
4562
4596
|
}
|
|
4563
4597
|
}
|
|
4564
4598
|
toString() {
|
|
4565
|
-
return (`[${this.constructor.name}${this.$
|
|
4599
|
+
return (`[${this.constructor.name}${this.$flags$ & SignalFlags.INVALID ? ' INVALID' : ''} ${String(this.$untrackedValue$)}]` +
|
|
4566
4600
|
(Array.from(this.$effects$ || [])
|
|
4567
4601
|
.map((e) => '\n -> ' + pad(qwikDebugToString(e[0]), ' '))
|
|
4568
4602
|
.join('\n') || ''));
|
|
@@ -4669,18 +4703,21 @@ class ComputedSignal extends Signal {
|
|
|
4669
4703
|
* resolve the QRL during the mark dirty phase so that any call to it will be synchronous). )
|
|
4670
4704
|
*/
|
|
4671
4705
|
$computeQrl$;
|
|
4706
|
+
$flags$;
|
|
4707
|
+
$forceRunEffects$ = false;
|
|
4708
|
+
[_EFFECT_BACK_REF] = null;
|
|
4709
|
+
constructor(container, fn,
|
|
4672
4710
|
// We need a separate flag to know when the computation needs running because
|
|
4673
4711
|
// we need the old value to know if effects need running after computation
|
|
4674
|
-
|
|
4675
|
-
$forceRunEffects$ = false;
|
|
4676
|
-
constructor(container, fn) {
|
|
4712
|
+
flags = SignalFlags.INVALID) {
|
|
4677
4713
|
// The value is used for comparison when signals trigger, which can only happen
|
|
4678
4714
|
// when it was calculated before. Therefore we can pass whatever we like.
|
|
4679
4715
|
super(container, NEEDS_COMPUTATION);
|
|
4680
4716
|
this.$computeQrl$ = fn;
|
|
4717
|
+
this.$flags$ = flags;
|
|
4681
4718
|
}
|
|
4682
4719
|
$invalidate$() {
|
|
4683
|
-
this.$
|
|
4720
|
+
this.$flags$ |= SignalFlags.INVALID;
|
|
4684
4721
|
this.$forceRunEffects$ = false;
|
|
4685
4722
|
// We should only call subscribers if the calculation actually changed.
|
|
4686
4723
|
// Therefore, we need to calculate the value now.
|
|
@@ -4691,7 +4728,7 @@ class ComputedSignal extends Signal {
|
|
|
4691
4728
|
* remained the same object
|
|
4692
4729
|
*/
|
|
4693
4730
|
force() {
|
|
4694
|
-
this.$
|
|
4731
|
+
this.$flags$ |= SignalFlags.INVALID;
|
|
4695
4732
|
this.$forceRunEffects$ = false;
|
|
4696
4733
|
triggerEffects(this.$container$, this, this.$effects$);
|
|
4697
4734
|
}
|
|
@@ -4704,7 +4741,7 @@ class ComputedSignal extends Signal {
|
|
|
4704
4741
|
return this.$untrackedValue$;
|
|
4705
4742
|
}
|
|
4706
4743
|
$computeIfNeeded$() {
|
|
4707
|
-
if (!this.$
|
|
4744
|
+
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
4708
4745
|
return false;
|
|
4709
4746
|
}
|
|
4710
4747
|
const computeQrl = this.$computeQrl$;
|
|
@@ -4721,7 +4758,7 @@ class ComputedSignal extends Signal {
|
|
|
4721
4758
|
]);
|
|
4722
4759
|
}
|
|
4723
4760
|
DEBUG && log('Signal.$compute$', untrackedValue);
|
|
4724
|
-
this.$
|
|
4761
|
+
this.$flags$ &= ~SignalFlags.INVALID;
|
|
4725
4762
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
4726
4763
|
if (didChange) {
|
|
4727
4764
|
this.$untrackedValue$ = untrackedValue;
|
|
@@ -4746,20 +4783,22 @@ class WrappedSignal extends Signal {
|
|
|
4746
4783
|
$args$;
|
|
4747
4784
|
$func$;
|
|
4748
4785
|
$funcStr$;
|
|
4749
|
-
|
|
4750
|
-
// we need the old value to know if effects need running after computation
|
|
4751
|
-
$invalid$ = true;
|
|
4786
|
+
$flags$;
|
|
4752
4787
|
$hostElement$ = null;
|
|
4753
4788
|
$forceRunEffects$ = false;
|
|
4754
4789
|
[_EFFECT_BACK_REF] = null;
|
|
4755
|
-
constructor(container, fn, args, fnStr
|
|
4790
|
+
constructor(container, fn, args, fnStr,
|
|
4791
|
+
// We need a separate flag to know when the computation needs running because
|
|
4792
|
+
// we need the old value to know if effects need running after computation
|
|
4793
|
+
flags = SignalFlags.INVALID | WrappedSignalFlags.UNWRAP) {
|
|
4756
4794
|
super(container, NEEDS_COMPUTATION);
|
|
4757
4795
|
this.$args$ = args;
|
|
4758
4796
|
this.$func$ = fn;
|
|
4759
4797
|
this.$funcStr$ = fnStr;
|
|
4798
|
+
this.$flags$ = flags;
|
|
4760
4799
|
}
|
|
4761
4800
|
$invalidate$() {
|
|
4762
|
-
this.$
|
|
4801
|
+
this.$flags$ |= SignalFlags.INVALID;
|
|
4763
4802
|
this.$forceRunEffects$ = false;
|
|
4764
4803
|
// We should only call subscribers if the calculation actually changed.
|
|
4765
4804
|
// Therefore, we need to calculate the value now.
|
|
@@ -4770,7 +4809,7 @@ class WrappedSignal extends Signal {
|
|
|
4770
4809
|
* remained the same object
|
|
4771
4810
|
*/
|
|
4772
4811
|
force() {
|
|
4773
|
-
this.$
|
|
4812
|
+
this.$flags$ |= SignalFlags.INVALID;
|
|
4774
4813
|
this.$forceRunEffects$ = false;
|
|
4775
4814
|
triggerEffects(this.$container$, this, this.$effects$);
|
|
4776
4815
|
}
|
|
@@ -4783,10 +4822,12 @@ class WrappedSignal extends Signal {
|
|
|
4783
4822
|
return this.$untrackedValue$;
|
|
4784
4823
|
}
|
|
4785
4824
|
$computeIfNeeded$() {
|
|
4786
|
-
if (!this.$
|
|
4825
|
+
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
4787
4826
|
return false;
|
|
4788
4827
|
}
|
|
4789
4828
|
const untrackedValue = trackSignal(() => this.$func$(...this.$args$), this, EffectProperty.VNODE, this.$container$);
|
|
4829
|
+
// TODO: we should remove invalid flag here
|
|
4830
|
+
// this.$flags$ &= ~SignalFlags.INVALID;
|
|
4790
4831
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
4791
4832
|
if (didChange) {
|
|
4792
4833
|
this.$untrackedValue$ = untrackedValue;
|
|
@@ -4948,7 +4989,7 @@ function processJSXNode(ssr, enqueue, value, options) {
|
|
|
4948
4989
|
if (componentFrame) {
|
|
4949
4990
|
const compId = componentFrame.componentNode.id || '';
|
|
4950
4991
|
const projectionAttrs = isDev ? [DEBUG_TYPE, VirtualType.Projection] : [];
|
|
4951
|
-
projectionAttrs.push(
|
|
4992
|
+
projectionAttrs.push(QSlotParent, compId);
|
|
4952
4993
|
ssr.openProjection(projectionAttrs);
|
|
4953
4994
|
const host = componentFrame.componentNode;
|
|
4954
4995
|
const node = ssr.getLastNode();
|
|
@@ -5216,7 +5257,7 @@ function appendClassIfScopedStyleExists(jsx, styleScoped) {
|
|
|
5216
5257
|
*
|
|
5217
5258
|
* @public
|
|
5218
5259
|
*/
|
|
5219
|
-
const version = "2.0.0-alpha.
|
|
5260
|
+
const version = "2.0.0-alpha.8-dev+66037b5";
|
|
5220
5261
|
|
|
5221
5262
|
/** @internal */
|
|
5222
5263
|
class _SharedContainer {
|
|
@@ -5271,7 +5312,7 @@ const _wrapProp = (...args) => {
|
|
|
5271
5312
|
}
|
|
5272
5313
|
if (isSignal(obj)) {
|
|
5273
5314
|
assertEqual(prop, 'value', 'Left side is a signal, prop must be value');
|
|
5274
|
-
if (obj instanceof WrappedSignal) {
|
|
5315
|
+
if (obj instanceof WrappedSignal && obj.flags & WrappedSignalFlags.UNWRAP) {
|
|
5275
5316
|
return obj;
|
|
5276
5317
|
}
|
|
5277
5318
|
return getWrapped(args);
|
|
@@ -5297,6 +5338,17 @@ const _wrapProp = (...args) => {
|
|
|
5297
5338
|
// We need to forward the access to the original object
|
|
5298
5339
|
return getWrapped(args);
|
|
5299
5340
|
};
|
|
5341
|
+
/** @internal */
|
|
5342
|
+
const _wrapStore = (obj, prop) => {
|
|
5343
|
+
const target = getStoreTarget(obj);
|
|
5344
|
+
const value = target[prop];
|
|
5345
|
+
if (isSignal(value)) {
|
|
5346
|
+
return value;
|
|
5347
|
+
}
|
|
5348
|
+
else {
|
|
5349
|
+
return new WrappedSignal(null, getProp, [obj, prop], null, SignalFlags.INVALID);
|
|
5350
|
+
}
|
|
5351
|
+
};
|
|
5300
5352
|
/** @internal @deprecated v1 compat */
|
|
5301
5353
|
const _wrapSignal = (obj, prop) => {
|
|
5302
5354
|
const r = _wrapProp(obj, prop);
|
|
@@ -5567,7 +5619,9 @@ class PropsProxyHandler {
|
|
|
5567
5619
|
? this.$constProps$[prop]
|
|
5568
5620
|
: this.$varProps$[prop];
|
|
5569
5621
|
// a proxied value that the optimizer made
|
|
5570
|
-
return value instanceof WrappedSignal
|
|
5622
|
+
return value instanceof WrappedSignal && value.$flags$ & WrappedSignalFlags.UNWRAP
|
|
5623
|
+
? value.value
|
|
5624
|
+
: value;
|
|
5571
5625
|
}
|
|
5572
5626
|
set(_, prop, value) {
|
|
5573
5627
|
if (prop === _CONST_PROPS) {
|
|
@@ -5801,8 +5855,8 @@ const VNodeDataChar = {
|
|
|
5801
5855
|
ID_CHAR: /* ********* */ '=',
|
|
5802
5856
|
PROPS: /* ************** */ 62, // `>` - `q:props' - Component Props
|
|
5803
5857
|
PROPS_CHAR: /* ****** */ '>',
|
|
5804
|
-
|
|
5805
|
-
|
|
5858
|
+
SLOT_PARENT: /* ******** */ 63, // `?` - `q:sparent` - Slot parent.
|
|
5859
|
+
SLOT_PARENT_CHAR: /* */ '?',
|
|
5806
5860
|
KEY: /* **************** */ 64, // `@` - `q:key` - Element key.
|
|
5807
5861
|
KEY_CHAR: /* ******** */ '@',
|
|
5808
5862
|
SEQ: /* **************** */ 91, // `[` - `q:seq' - Seq value from `useSequentialScope()`
|
|
@@ -6050,6 +6104,12 @@ const vnode_isVirtualVNode = (vNode) => {
|
|
|
6050
6104
|
const flag = vNode[VNodeProps.flags];
|
|
6051
6105
|
return (flag & VNodeFlags.Virtual) === VNodeFlags.Virtual;
|
|
6052
6106
|
};
|
|
6107
|
+
const vnode_isProjection = (vNode) => {
|
|
6108
|
+
assertDefined(vNode, 'Missing vNode');
|
|
6109
|
+
const flag = vNode[VNodeProps.flags];
|
|
6110
|
+
return ((flag & VNodeFlags.Virtual) === VNodeFlags.Virtual &&
|
|
6111
|
+
vnode_getProp(vNode, QSlot, null) !== null);
|
|
6112
|
+
};
|
|
6053
6113
|
const ensureTextVNode = (vNode) => {
|
|
6054
6114
|
assertTrue(vnode_isTextVNode(vNode), 'Expecting TextVNode was: ' + vnode_getNodeTypeName(vNode));
|
|
6055
6115
|
return vNode;
|
|
@@ -6494,7 +6554,7 @@ const vnode_applyJournal = (journal) => {
|
|
|
6494
6554
|
element[key] = parseBoolean(value);
|
|
6495
6555
|
}
|
|
6496
6556
|
else if (key === 'value' && key in element) {
|
|
6497
|
-
element.value =
|
|
6557
|
+
element.value = String(value);
|
|
6498
6558
|
}
|
|
6499
6559
|
else if (key === dangerouslySetInnerHTML) {
|
|
6500
6560
|
element.innerHTML = value;
|
|
@@ -7246,9 +7306,6 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
7246
7306
|
else if (peek() === VNodeDataChar.PROPS) {
|
|
7247
7307
|
vnode_setAttr(null, vParent, ELEMENT_PROPS, consumeValue());
|
|
7248
7308
|
}
|
|
7249
|
-
else if (peek() === VNodeDataChar.SLOT_REF) {
|
|
7250
|
-
vnode_setAttr(null, vParent, QSlotRef, consumeValue());
|
|
7251
|
-
}
|
|
7252
7309
|
else if (peek() === VNodeDataChar.KEY) {
|
|
7253
7310
|
vnode_setAttr(null, vParent, ELEMENT_KEY, consumeValue());
|
|
7254
7311
|
}
|
|
@@ -7264,6 +7321,9 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
7264
7321
|
}
|
|
7265
7322
|
setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
|
|
7266
7323
|
}
|
|
7324
|
+
else if (peek() === VNodeDataChar.SLOT_PARENT) {
|
|
7325
|
+
vnode_setProp(vParent, QSlotParent, consumeValue());
|
|
7326
|
+
}
|
|
7267
7327
|
else if (peek() === VNodeDataChar.CONTEXT) {
|
|
7268
7328
|
vnode_setAttr(null, vParent, QCtxAttr, consumeValue());
|
|
7269
7329
|
}
|
|
@@ -8166,7 +8226,7 @@ class DomContainer extends _SharedContainer {
|
|
|
8166
8226
|
$styleIds$ = null;
|
|
8167
8227
|
$renderCount$ = 0;
|
|
8168
8228
|
constructor(element) {
|
|
8169
|
-
super(() => this.scheduleRender(), () => vnode_applyJournal(this.$journal$), {}, element.getAttribute(
|
|
8229
|
+
super(() => this.scheduleRender(), () => vnode_applyJournal(this.$journal$), {}, element.getAttribute(QLocaleAttr));
|
|
8170
8230
|
this.qContainer = element.getAttribute(QContainerAttr);
|
|
8171
8231
|
if (!this.qContainer) {
|
|
8172
8232
|
throw qError(QError.elementWithoutContainer);
|
|
@@ -8566,8 +8626,9 @@ const inflate = (container, target, typeId, data) => {
|
|
|
8566
8626
|
signal.$args$ = d[1];
|
|
8567
8627
|
signal[_EFFECT_BACK_REF] = d[2];
|
|
8568
8628
|
signal.$untrackedValue$ = d[3];
|
|
8569
|
-
signal.$
|
|
8570
|
-
signal.$
|
|
8629
|
+
signal.$flags$ = d[4];
|
|
8630
|
+
signal.$hostElement$ = d[5];
|
|
8631
|
+
signal.$effects$ = new Set(d.slice(6));
|
|
8571
8632
|
break;
|
|
8572
8633
|
}
|
|
8573
8634
|
case TypeIds.ComputedSignal: {
|
|
@@ -8579,7 +8640,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
8579
8640
|
computed.$untrackedValue$ = d[2];
|
|
8580
8641
|
}
|
|
8581
8642
|
else {
|
|
8582
|
-
computed.$
|
|
8643
|
+
computed.$flags$ |= SignalFlags.INVALID;
|
|
8583
8644
|
/**
|
|
8584
8645
|
* If we try to compute value and the qrl is not resolved, then system throws an error with
|
|
8585
8646
|
* qrl promise. To prevent that we should early resolve computed qrl while computed
|
|
@@ -8687,7 +8748,7 @@ const _constants = [
|
|
|
8687
8748
|
EMPTY_ARRAY,
|
|
8688
8749
|
EMPTY_OBJ,
|
|
8689
8750
|
NEEDS_COMPUTATION,
|
|
8690
|
-
|
|
8751
|
+
STORE_ALL_PROPS,
|
|
8691
8752
|
Slot,
|
|
8692
8753
|
Fragment,
|
|
8693
8754
|
NaN,
|
|
@@ -8992,14 +9053,15 @@ prepVNodeData) => {
|
|
|
8992
9053
|
*/
|
|
8993
9054
|
const v = obj instanceof WrappedSignal
|
|
8994
9055
|
? obj.untrackedValue
|
|
8995
|
-
: obj instanceof ComputedSignal &&
|
|
9056
|
+
: obj instanceof ComputedSignal &&
|
|
9057
|
+
(obj.$flags$ & SignalFlags.INVALID || fastSkipSerialize(obj))
|
|
8996
9058
|
? NEEDS_COMPUTATION
|
|
8997
9059
|
: obj.$untrackedValue$;
|
|
8998
9060
|
if (v !== NEEDS_COMPUTATION) {
|
|
8999
9061
|
discoveredValues.push(v);
|
|
9000
9062
|
}
|
|
9001
9063
|
if (obj.$effects$) {
|
|
9002
|
-
discoveredValues.push(
|
|
9064
|
+
discoveredValues.push(obj.$effects$);
|
|
9003
9065
|
}
|
|
9004
9066
|
// WrappedSignal uses syncQrl which has no captured refs
|
|
9005
9067
|
if (obj instanceof WrappedSignal) {
|
|
@@ -9012,6 +9074,7 @@ prepVNodeData) => {
|
|
|
9012
9074
|
}
|
|
9013
9075
|
}
|
|
9014
9076
|
else if (obj instanceof ComputedSignal) {
|
|
9077
|
+
discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
|
|
9015
9078
|
discoveredValues.push(obj.$computeQrl$);
|
|
9016
9079
|
}
|
|
9017
9080
|
}
|
|
@@ -9108,18 +9171,7 @@ const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
|
|
|
9108
9171
|
};
|
|
9109
9172
|
const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
|
|
9110
9173
|
if (effectsBackRefs) {
|
|
9111
|
-
|
|
9112
|
-
let hasBackRefs = false;
|
|
9113
|
-
for (const [, effect] of effectsBackRefs) {
|
|
9114
|
-
const backRefs = effect[EffectSubscriptionProp.BACK_REF];
|
|
9115
|
-
if (backRefs) {
|
|
9116
|
-
hasBackRefs = true;
|
|
9117
|
-
break;
|
|
9118
|
-
}
|
|
9119
|
-
}
|
|
9120
|
-
if (hasBackRefs) {
|
|
9121
|
-
discoveredValues.push(effectsBackRefs);
|
|
9122
|
-
}
|
|
9174
|
+
discoveredValues.push(effectsBackRefs);
|
|
9123
9175
|
}
|
|
9124
9176
|
};
|
|
9125
9177
|
const promiseResults = new WeakMap();
|
|
@@ -9268,8 +9320,8 @@ function serialize(serializationContext) {
|
|
|
9268
9320
|
else if (value === NEEDS_COMPUTATION) {
|
|
9269
9321
|
output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
|
|
9270
9322
|
}
|
|
9271
|
-
else if (value ===
|
|
9272
|
-
output(TypeIds.Constant, Constants.
|
|
9323
|
+
else if (value === STORE_ALL_PROPS) {
|
|
9324
|
+
output(TypeIds.Constant, Constants.STORE_ALL_PROPS);
|
|
9273
9325
|
}
|
|
9274
9326
|
else {
|
|
9275
9327
|
throw qError(QError.serializeErrorUnknownType, [typeof value]);
|
|
@@ -9368,7 +9420,7 @@ function serialize(serializationContext) {
|
|
|
9368
9420
|
* It can never be meant to become a vNode, because vNodes are internal only.
|
|
9369
9421
|
*/
|
|
9370
9422
|
const v = value instanceof ComputedSignal &&
|
|
9371
|
-
(value.$
|
|
9423
|
+
(value.$flags$ & SignalFlags.INVALID || fastSkipSerialize(value.$untrackedValue$))
|
|
9372
9424
|
? NEEDS_COMPUTATION
|
|
9373
9425
|
: value.$untrackedValue$;
|
|
9374
9426
|
if (value instanceof WrappedSignal) {
|
|
@@ -9376,6 +9428,7 @@ function serialize(serializationContext) {
|
|
|
9376
9428
|
...serializeWrappingFn(serializationContext, value),
|
|
9377
9429
|
filterEffectBackRefs(value[_EFFECT_BACK_REF]),
|
|
9378
9430
|
v,
|
|
9431
|
+
value.$flags$,
|
|
9379
9432
|
value.$hostElement$,
|
|
9380
9433
|
...(value.$effects$ || []),
|
|
9381
9434
|
]);
|
|
@@ -9853,7 +9906,7 @@ var Constants;
|
|
|
9853
9906
|
Constants[Constants["EMPTY_ARRAY"] = 5] = "EMPTY_ARRAY";
|
|
9854
9907
|
Constants[Constants["EMPTY_OBJ"] = 6] = "EMPTY_OBJ";
|
|
9855
9908
|
Constants[Constants["NEEDS_COMPUTATION"] = 7] = "NEEDS_COMPUTATION";
|
|
9856
|
-
Constants[Constants["
|
|
9909
|
+
Constants[Constants["STORE_ALL_PROPS"] = 8] = "STORE_ALL_PROPS";
|
|
9857
9910
|
Constants[Constants["Slot"] = 9] = "Slot";
|
|
9858
9911
|
Constants[Constants["Fragment"] = 10] = "Fragment";
|
|
9859
9912
|
Constants[Constants["NaN"] = 11] = "NaN";
|
|
@@ -11346,5 +11399,5 @@ const PrefetchGraph = (opts = {}) => {
|
|
|
11346
11399
|
return _jsxSorted('script', null, props, null, 0, 'prefetch-graph');
|
|
11347
11400
|
};
|
|
11348
11401
|
|
|
11349
|
-
export { $, Fragment, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, SubscriptionData as _EffectData, _IMMUTABLE, _SharedContainer, _VAR_PROPS, _deserialize, _fnSignal, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, _waitUntilRendered, _walkJSX, _weakSerialize, _wrapProp, _wrapSignal, component$, componentQrl, createComputed$, createComputedQrl, createContextId, h as createElement, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
|
|
11402
|
+
export { $, Fragment, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, SubscriptionData as _EffectData, _IMMUTABLE, _SharedContainer, _VAR_PROPS, _deserialize, _fnSignal, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, _waitUntilRendered, _walkJSX, _weakSerialize, _wrapProp, _wrapSignal, _wrapStore, component$, componentQrl, createComputed$, createComputedQrl, createContextId, h as createElement, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
|
|
11350
11403
|
//# sourceMappingURL=core.mjs.map
|