@qwik.dev/core 2.0.0-alpha.6 → 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/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +65 -42
- package/dist/core-internal.d.ts +92 -78
- package/dist/core.cjs +1603 -1374
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +1600 -1374
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +963 -834
- package/dist/core.prod.mjs +1093 -927
- package/dist/insights/index.qwik.cjs +3679 -167
- package/dist/insights/index.qwik.mjs +3679 -167
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +228 -5715
- package/dist/optimizer.mjs +208 -6038
- package/dist/prefetch/package.json +1 -1
- package/dist/qwikloader.debug.js +12 -15
- package/dist/qwikloader.js +2 -2
- package/dist/server.cjs +787 -7152
- package/dist/server.mjs +805 -7148
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +2 -0
- package/dist/starters/features/cypress/package.json +1 -1
- package/dist/starters/features/drizzle/drizzle/schema.ts +6 -18
- package/dist/starters/features/drizzle/drizzle.config.ts +5 -4
- package/dist/starters/features/drizzle/package.json +14 -11
- package/dist/starters/features/pandacss/package.json +1 -1
- package/dist/starters/features/partytown/package.json +1 -1
- package/dist/starters/features/postcss/package.json +1 -1
- package/dist/starters/features/prisma/package.json +1 -1
- package/dist/starters/features/react/package.json +1 -1
- package/dist/starters/features/storybook/package.json +1 -1
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +15 -9
- package/dist/starters/features/tailwind/src/global.css +1 -7
- package/dist/starters/features/turso/package.json +1 -1
- package/dist/starters/features/vitest/package.json +1 -1
- package/dist/testing/index.cjs +1341 -1180
- package/dist/testing/index.mjs +1354 -1186
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +9 -0
- package/package.json +6 -4
- package/public.d.ts +2 -0
- package/dist/starters/features/tailwind/.vscode/settings.json +0 -3
- package/dist/starters/features/tailwind/postcss.config.cjs +0 -6
- package/dist/starters/features/tailwind/tailwind.config.js +0 -8
package/dist/core.prod.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { isDev, isServer } from "@qwik.dev/core/build";
|
|
9
9
|
|
|
10
10
|
export { isBrowser, isDev, isServer } from "@qwik.dev/core/build";
|
|
11
11
|
|
|
@@ -80,8 +80,8 @@ const codeToText = code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/
|
|
|
80
80
|
var QError;
|
|
81
81
|
|
|
82
82
|
!function(QError) {
|
|
83
|
-
QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.
|
|
84
|
-
QError[QError.
|
|
83
|
+
QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.schedulerNotFound = 1] = "schedulerNotFound",
|
|
84
|
+
QError[QError.trackObjectWithoutProp = 2] = "trackObjectWithoutProp", QError[QError.verifySerializable = 3] = "verifySerializable",
|
|
85
85
|
QError[QError.UNUSED_4 = 4] = "UNUSED_4", QError[QError.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer",
|
|
86
86
|
QError[QError.UNUSED_6 = 6] = "UNUSED_6", QError[QError.UNUSED_7 = 7] = "UNUSED_7",
|
|
87
87
|
QError[QError.UNUSED_8 = 8] = "UNUSED_8", QError[QError.UNUSED_9 = 9] = "UNUSED_9",
|
|
@@ -106,7 +106,7 @@ var QError;
|
|
|
106
106
|
QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
|
|
107
107
|
QError[QError.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError[QError.computedNotSync = 46] = "computedNotSync",
|
|
108
108
|
QError[QError.computedReadOnly = 47] = "computedReadOnly", QError[QError.wrappedReadOnly = 48] = "wrappedReadOnly",
|
|
109
|
-
QError[QError.
|
|
109
|
+
QError[QError.unsafeAttr = 49] = "unsafeAttr";
|
|
110
110
|
}(QError || (QError = {}));
|
|
111
111
|
|
|
112
112
|
const qError = (code, errorMessageArgs = []) => {
|
|
@@ -114,6 +114,23 @@ const qError = (code, errorMessageArgs = []) => {
|
|
|
114
114
|
return logErrorAndStop(text, ...errorMessageArgs);
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
+
const SYNC_QRL = "<sync>";
|
|
118
|
+
|
|
119
|
+
const isSyncQrl = value => isQrl$1(value) && "<sync>" == value.$symbol$;
|
|
120
|
+
|
|
121
|
+
const isQrl$1 = value => "function" == typeof value && "function" == typeof value.getSymbol;
|
|
122
|
+
|
|
123
|
+
function assertQrl(qrl) {
|
|
124
|
+
if (isDev && !isQrl$1(qrl)) {
|
|
125
|
+
throw new Error("Not a QRL");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const getSymbolHash = symbolName => {
|
|
130
|
+
const index = symbolName.lastIndexOf("_");
|
|
131
|
+
return index > -1 ? symbolName.slice(index + 1) : symbolName;
|
|
132
|
+
};
|
|
133
|
+
|
|
117
134
|
const DEBUG_TYPE = "q:type";
|
|
118
135
|
|
|
119
136
|
var VirtualType;
|
|
@@ -147,13 +164,11 @@ var QContainerValue;
|
|
|
147
164
|
|
|
148
165
|
const OnRenderProp = "q:renderFn";
|
|
149
166
|
|
|
150
|
-
const ComponentStylesPrefixContent = "
|
|
167
|
+
const ComponentStylesPrefixContent = "⚡️";
|
|
151
168
|
|
|
152
169
|
const QSlot = "q:slot";
|
|
153
170
|
|
|
154
|
-
const QSlotParent = ":";
|
|
155
|
-
|
|
156
|
-
const QSlotRef = "q:sref";
|
|
171
|
+
const QSlotParent = "q:sparent";
|
|
157
172
|
|
|
158
173
|
const QSlotS = "q:s";
|
|
159
174
|
|
|
@@ -169,7 +184,7 @@ const QScopedStyle = "q:sstyle";
|
|
|
169
184
|
|
|
170
185
|
const QCtxAttr = "q:ctx";
|
|
171
186
|
|
|
172
|
-
const
|
|
187
|
+
const QBackRefs = "q:brefs";
|
|
173
188
|
|
|
174
189
|
const QFuncsPrefix = "qFuncs_";
|
|
175
190
|
|
|
@@ -314,8 +329,6 @@ const safeCall = (call, thenFn, rejectFn) => {
|
|
|
314
329
|
|
|
315
330
|
const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
|
|
316
331
|
|
|
317
|
-
const maybeThenPassError = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
318
|
-
|
|
319
332
|
const shouldNotError = reason => {
|
|
320
333
|
throwErrorAndStop(reason);
|
|
321
334
|
};
|
|
@@ -389,7 +402,7 @@ function setLocale(locale) {
|
|
|
389
402
|
VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
|
|
390
403
|
}(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
391
404
|
|
|
392
|
-
const isQrl
|
|
405
|
+
const isQrl = value => "function" == typeof value && "function" == typeof value.getSymbol;
|
|
393
406
|
|
|
394
407
|
const EMPTY_ARRAY = [];
|
|
395
408
|
|
|
@@ -434,14 +447,14 @@ const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset =
|
|
|
434
447
|
chunk = chunkOrFn;
|
|
435
448
|
}
|
|
436
449
|
return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
|
|
437
|
-
symbols: [
|
|
450
|
+
symbols: [ symbol ],
|
|
438
451
|
bundles: chunk && [ chunk ]
|
|
439
|
-
})), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture
|
|
452
|
+
})), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture);
|
|
440
453
|
};
|
|
441
454
|
|
|
442
|
-
const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture
|
|
455
|
+
const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
|
|
443
456
|
|
|
444
|
-
const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture
|
|
457
|
+
const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture);
|
|
445
458
|
|
|
446
459
|
const _noopQrlDEV = (symbolName, opts, lexicalScopeCapture = EMPTY_ARRAY) => {
|
|
447
460
|
const newQrl = _noopQrl(symbolName, lexicalScopeCapture);
|
|
@@ -461,6 +474,43 @@ const inlinedQrlDEV = (symbol, symbolName, opts, lexicalScopeCapture = EMPTY_ARR
|
|
|
461
474
|
const _regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
|
|
462
475
|
globalThis.__qwik_reg_symbols.set(hash, symbol), symbol);
|
|
463
476
|
|
|
477
|
+
var ChoreType;
|
|
478
|
+
|
|
479
|
+
!function(ChoreType) {
|
|
480
|
+
ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
|
|
481
|
+
ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RUN_QRL = 2] = "RUN_QRL",
|
|
482
|
+
ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
|
|
483
|
+
ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT = 6] = "COMPONENT",
|
|
484
|
+
ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 7] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
|
|
485
|
+
ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
|
|
486
|
+
ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
|
|
487
|
+
}(ChoreType || (ChoreType = {}));
|
|
488
|
+
|
|
489
|
+
const useLexicalScope = () => {
|
|
490
|
+
const context = getInvokeContext();
|
|
491
|
+
let qrl = context.$qrl$;
|
|
492
|
+
if (qrl) {
|
|
493
|
+
assertQrl(qrl), assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
|
|
494
|
+
} else {
|
|
495
|
+
const el = context.$element$;
|
|
496
|
+
assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
|
|
497
|
+
const containerElement = _getQContainerElement(el);
|
|
498
|
+
assertDefined(containerElement, "invoke: cant find parent q:container of", el);
|
|
499
|
+
qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
|
|
500
|
+
}
|
|
501
|
+
return qrl.$captureRef$;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
const queueQRL = (...args) => {
|
|
505
|
+
const [runQrl] = useLexicalScope();
|
|
506
|
+
const hostElement = getInvokeContext().$hostElement$;
|
|
507
|
+
const scheduler = getDomContainer(hostElement).$scheduler$;
|
|
508
|
+
if (!scheduler) {
|
|
509
|
+
throw qError(QError.schedulerNotFound);
|
|
510
|
+
}
|
|
511
|
+
return scheduler(ChoreType.RUN_QRL, hostElement, runQrl, args);
|
|
512
|
+
};
|
|
513
|
+
|
|
464
514
|
const Slot = props => _jsxSorted(Virtual, null, {
|
|
465
515
|
[QSlotS]: ""
|
|
466
516
|
}, props.children, 0, props.name ?? "");
|
|
@@ -539,6 +589,47 @@ function isPreventDefault(key) {
|
|
|
539
589
|
return key.startsWith("preventdefault:");
|
|
540
590
|
}
|
|
541
591
|
|
|
592
|
+
function getFileLocationFromJsx(jsxDev) {
|
|
593
|
+
if (!jsxDev) {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
|
|
597
|
+
return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
const styleContent = styleId => "⚡️" + styleId;
|
|
601
|
+
|
|
602
|
+
function hasClassAttr(props) {
|
|
603
|
+
for (const key in props) {
|
|
604
|
+
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
605
|
+
return !0;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return !1;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
function isClassAttr(key) {
|
|
612
|
+
return "class" === key || "className" === key;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function convertScopedStyleIdsToArray(scopedStyleIds) {
|
|
616
|
+
return scopedStyleIds?.split(" ") ?? null;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function convertStyleIdsToString(scopedStyleIds) {
|
|
620
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
const addComponentStylePrefix = styleId => {
|
|
624
|
+
if (styleId) {
|
|
625
|
+
let idx = 0;
|
|
626
|
+
do {
|
|
627
|
+
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
628
|
+
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
629
|
+
}
|
|
630
|
+
return styleId || null;
|
|
631
|
+
};
|
|
632
|
+
|
|
542
633
|
const unitlessNumbers = new Set([ "animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexShrink", "gridArea", "gridRow", "gridRowEnd", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "MozAnimationIterationCount", "MozBoxFlex", "msFlex", "msFlexPositive", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexShrink", "WebkitLineClamp" ]);
|
|
543
634
|
|
|
544
635
|
const isUnitlessNumber = name => unitlessNumbers.has(name);
|
|
@@ -619,44 +710,11 @@ function isAriaAttribute(prop) {
|
|
|
619
710
|
|
|
620
711
|
const styleKey = (qStyles, index) => (assertQrl(qStyles), `${hashCode(qStyles.$hash$)}-${index}`);
|
|
621
712
|
|
|
622
|
-
const styleContent = styleId => "⭐️" + styleId;
|
|
623
|
-
|
|
624
|
-
function hasClassAttr(props) {
|
|
625
|
-
for (const key in props) {
|
|
626
|
-
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
627
|
-
return !0;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
return !1;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
function isClassAttr(key) {
|
|
634
|
-
return "class" === key || "className" === key;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
function convertScopedStyleIdsToArray(scopedStyleIds) {
|
|
638
|
-
return scopedStyleIds?.split(" ") ?? null;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
function convertStyleIdsToString(scopedStyleIds) {
|
|
642
|
-
return Array.from(scopedStyleIds).join(" ");
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
const addComponentStylePrefix = styleId => {
|
|
646
|
-
if (styleId) {
|
|
647
|
-
let idx = 0;
|
|
648
|
-
do {
|
|
649
|
-
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
650
|
-
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
651
|
-
}
|
|
652
|
-
return styleId || null;
|
|
653
|
-
};
|
|
654
|
-
|
|
655
713
|
const STORE_TARGET = Symbol("store.target");
|
|
656
714
|
|
|
657
715
|
const STORE_HANDLER = Symbol("store.handler");
|
|
658
716
|
|
|
659
|
-
const
|
|
717
|
+
const STORE_ALL_PROPS = Symbol("store.all");
|
|
660
718
|
|
|
661
719
|
var StoreFlags;
|
|
662
720
|
|
|
@@ -712,7 +770,7 @@ class StoreHandler {
|
|
|
712
770
|
assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, "Do not use signals across containers");
|
|
713
771
|
}
|
|
714
772
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
715
|
-
effectSubscriber &&
|
|
773
|
+
effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
|
|
716
774
|
}
|
|
717
775
|
if ("toString" === prop && value === Object.prototype.toString) {
|
|
718
776
|
return this.toString;
|
|
@@ -743,7 +801,7 @@ class StoreHandler {
|
|
|
743
801
|
const ctx = tryGetInvokeContext();
|
|
744
802
|
if (ctx) {
|
|
745
803
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
746
|
-
effectSubscriber &&
|
|
804
|
+
effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
|
|
747
805
|
}
|
|
748
806
|
}
|
|
749
807
|
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
@@ -751,22 +809,23 @@ class StoreHandler {
|
|
|
751
809
|
ownKeys(target) {
|
|
752
810
|
const ctx = tryGetInvokeContext();
|
|
753
811
|
const effectSubscriber = ctx?.$effectSubscriber$;
|
|
754
|
-
return effectSubscriber &&
|
|
812
|
+
return effectSubscriber && addStoreEffect(target, STORE_ALL_PROPS, this, effectSubscriber),
|
|
755
813
|
Reflect.ownKeys(target);
|
|
756
814
|
}
|
|
757
815
|
getOwnPropertyDescriptor(target, prop) {
|
|
758
|
-
|
|
816
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
817
|
+
return Array.isArray(target) || "symbol" == typeof prop || descriptor && !descriptor.configurable ? descriptor : {
|
|
759
818
|
enumerable: !0,
|
|
760
819
|
configurable: !0
|
|
761
820
|
};
|
|
762
821
|
}
|
|
763
822
|
}
|
|
764
823
|
|
|
765
|
-
function
|
|
766
|
-
const effectsMap = store.$effects$ ||=
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
824
|
+
function addStoreEffect(target, prop, store, effectSubscription) {
|
|
825
|
+
const effectsMap = store.$effects$ ||= new Map;
|
|
826
|
+
let effects = effectsMap.get(prop);
|
|
827
|
+
effects || (effects = new Set, effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription),
|
|
828
|
+
ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
|
|
770
829
|
}
|
|
771
830
|
|
|
772
831
|
function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
|
|
@@ -774,259 +833,215 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
|
|
|
774
833
|
}
|
|
775
834
|
|
|
776
835
|
function getEffects(target, prop, storeEffects) {
|
|
777
|
-
let effectsToTrigger
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
836
|
+
let effectsToTrigger;
|
|
837
|
+
if (storeEffects) {
|
|
838
|
+
if (Array.isArray(target)) {
|
|
839
|
+
for (const effects of storeEffects.values()) {
|
|
840
|
+
effectsToTrigger ||= new Set;
|
|
841
|
+
for (const effect of effects) {
|
|
842
|
+
effectsToTrigger.add(effect);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
} else {
|
|
846
|
+
effectsToTrigger = storeEffects.get(prop);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
const storeArrayValue = storeEffects?.get(STORE_ALL_PROPS);
|
|
850
|
+
if (storeArrayValue) {
|
|
851
|
+
effectsToTrigger ||= new Set;
|
|
852
|
+
for (const effect of storeArrayValue) {
|
|
853
|
+
effectsToTrigger.add(effect);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
return effectsToTrigger || null;
|
|
781
857
|
}
|
|
782
858
|
|
|
783
|
-
const
|
|
784
|
-
const iCtx = useInvokeContext();
|
|
785
|
-
const host = iCtx.$hostElement$;
|
|
786
|
-
let seq = iCtx.$container$.getHostProp(host, "q:seq");
|
|
787
|
-
null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
|
|
788
|
-
let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
|
|
789
|
-
for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
|
|
790
|
-
seq.push(void 0);
|
|
791
|
-
}
|
|
792
|
-
return {
|
|
793
|
-
val: seq[seqIdx],
|
|
794
|
-
set: value => seq[seqIdx] = value,
|
|
795
|
-
i: seqIdx,
|
|
796
|
-
iCtx
|
|
797
|
-
};
|
|
798
|
-
};
|
|
859
|
+
const NEEDS_COMPUTATION = Symbol("invalid");
|
|
799
860
|
|
|
800
|
-
|
|
801
|
-
$effectDependencies$=null;
|
|
802
|
-
}
|
|
861
|
+
const _EFFECT_BACK_REF = Symbol("backRef");
|
|
803
862
|
|
|
804
|
-
|
|
805
|
-
|
|
863
|
+
class BackRef {
|
|
864
|
+
[_EFFECT_BACK_REF]=null;
|
|
806
865
|
}
|
|
807
866
|
|
|
808
|
-
function
|
|
809
|
-
vnode_isElementVNode(
|
|
810
|
-
const effects =
|
|
867
|
+
function clearAllEffects(container, consumer) {
|
|
868
|
+
vnode_isVNode(consumer) && vnode_isElementVNode(consumer) && ensureMaterialized(consumer);
|
|
869
|
+
const effects = consumer[_EFFECT_BACK_REF];
|
|
811
870
|
if (effects) {
|
|
812
|
-
for (
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
871
|
+
for (const [, effect] of effects) {
|
|
872
|
+
const backRefs = effect[EffectSubscriptionProp.BACK_REF];
|
|
873
|
+
if (!backRefs) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
for (const producer of backRefs) {
|
|
877
|
+
if (producer instanceof Signal) {
|
|
878
|
+
clearSignal(container, producer, effect);
|
|
879
|
+
} else if (container.$storeProxyMap$.has(producer)) {
|
|
880
|
+
const target = container.$storeProxyMap$.get(producer);
|
|
881
|
+
clearStore(getStoreHandler(target), effect);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
823
884
|
}
|
|
824
|
-
0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
|
|
825
885
|
}
|
|
826
886
|
}
|
|
827
887
|
|
|
828
|
-
function
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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);
|
|
888
|
+
function clearSignal(container, producer, effect) {
|
|
889
|
+
const effects = producer.$effects$;
|
|
890
|
+
effects && effects.delete(effect), producer instanceof WrappedSignal && (producer.$hostElement$ = null,
|
|
891
|
+
clearAllEffects(container, producer));
|
|
838
892
|
}
|
|
839
893
|
|
|
840
|
-
function
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
|
|
846
|
-
subscriptionRemoved = !0);
|
|
894
|
+
function clearStore(producer, effect) {
|
|
895
|
+
const effects = producer?.$effects$;
|
|
896
|
+
if (effects) {
|
|
897
|
+
for (const propEffects of effects.values()) {
|
|
898
|
+
propEffects.delete(effect);
|
|
847
899
|
}
|
|
848
900
|
}
|
|
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
901
|
}
|
|
857
902
|
|
|
858
|
-
function
|
|
859
|
-
|
|
860
|
-
|
|
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);
|
|
868
|
-
}
|
|
869
|
-
0 === effects.length && delete effectSubscriptions[key];
|
|
870
|
-
}
|
|
871
|
-
return subscriptionRemoved;
|
|
872
|
-
}
|
|
903
|
+
const implicit$FirstArg = fn => function(first, ...rest) {
|
|
904
|
+
return fn.call(null, dollar(first), ...rest);
|
|
905
|
+
};
|
|
873
906
|
|
|
874
|
-
|
|
875
|
-
for (let i = args.length - 1; i >= 0; i--) {
|
|
876
|
-
clearArgEffect(args[i], subscriber, seenSet);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
907
|
+
const createSignal$1 = value => new Signal(null, value);
|
|
879
908
|
|
|
880
|
-
|
|
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
|
-
}
|
|
909
|
+
const createComputedSignal = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
|
|
908
910
|
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
911
|
+
const createSignal = createSignal$1;
|
|
912
|
+
|
|
913
|
+
const createComputedQrl = createComputedSignal;
|
|
914
|
+
|
|
915
|
+
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
|
|
916
|
+
|
|
917
|
+
const useSequentialScope = () => {
|
|
918
|
+
const iCtx = useInvokeContext();
|
|
919
|
+
const host = iCtx.$hostElement$;
|
|
920
|
+
let seq = iCtx.$container$.getHostProp(host, "q:seq");
|
|
921
|
+
null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
|
|
922
|
+
let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
|
|
923
|
+
for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
|
|
924
|
+
seq.push(void 0);
|
|
913
925
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
926
|
+
return {
|
|
927
|
+
val: seq[seqIdx],
|
|
928
|
+
set: value => seq[seqIdx] = value,
|
|
929
|
+
i: seqIdx,
|
|
930
|
+
iCtx
|
|
931
|
+
};
|
|
919
932
|
};
|
|
920
933
|
|
|
921
|
-
|
|
934
|
+
function getSubscriber(effect, prop, data) {
|
|
935
|
+
effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
|
|
936
|
+
const subMap = effect[_EFFECT_BACK_REF];
|
|
937
|
+
let sub = subMap.get(prop);
|
|
938
|
+
return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[EffectSubscriptionProp.DATA] = data),
|
|
939
|
+
sub;
|
|
940
|
+
}
|
|
922
941
|
|
|
923
|
-
function
|
|
924
|
-
|
|
925
|
-
if (isResourceReturn(resource)) {
|
|
926
|
-
if (!isServerPlatform()) {
|
|
927
|
-
const state = resource._state;
|
|
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
|
-
}
|
|
940
|
-
}
|
|
941
|
-
return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
|
|
942
|
-
}
|
|
943
|
-
return isPromise(resource) ? resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : isSignal(resource) ? Promise.resolve(resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(resource).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
|
|
942
|
+
function isSsrNode(value) {
|
|
943
|
+
return "__brand__" in value && "currentComponentNode" in value;
|
|
944
944
|
}
|
|
945
945
|
|
|
946
|
-
|
|
947
|
-
__brand: "resource",
|
|
948
|
-
value: void 0,
|
|
949
|
-
loading: !isServerPlatform(),
|
|
950
|
-
_resolved: void 0,
|
|
951
|
-
_error: void 0,
|
|
952
|
-
_state: "pending",
|
|
953
|
-
_timeout: opts?.timeout ?? -1,
|
|
954
|
-
_cache: 0
|
|
955
|
-
});
|
|
946
|
+
var TaskFlags;
|
|
956
947
|
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
};
|
|
948
|
+
!function(TaskFlags) {
|
|
949
|
+
TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
|
|
950
|
+
TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
|
|
951
|
+
}(TaskFlags || (TaskFlags = {}));
|
|
961
952
|
|
|
962
|
-
const
|
|
953
|
+
const useTaskQrl = qrl => {
|
|
954
|
+
const {val, set, iCtx, i} = useSequentialScope();
|
|
955
|
+
if (val) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
assertQrl(qrl), set(1);
|
|
959
|
+
const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
960
|
+
set(task);
|
|
961
|
+
const promise = iCtx.$container$.$scheduler$(ChoreType.TASK, task);
|
|
962
|
+
isPromise(promise) && promise.catch((() => {}));
|
|
963
|
+
};
|
|
963
964
|
|
|
964
|
-
const
|
|
965
|
+
const runTask = (task, container, host) => {
|
|
965
966
|
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
966
|
-
const iCtx = newInvokeContext(container.$locale$, host, void 0, "
|
|
967
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
967
968
|
iCtx.$container$ = container;
|
|
968
|
-
const taskFn = task.$qrl$.getFn(iCtx, (() =>
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
}
|
|
979
|
-
})),
|
|
980
|
-
}
|
|
981
|
-
const
|
|
982
|
-
const opts = {
|
|
969
|
+
const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
|
|
970
|
+
let cleanupFns = null;
|
|
971
|
+
const cleanup = fn => {
|
|
972
|
+
"function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
|
|
973
|
+
task.$destroy$ = null, cleanupFns.forEach((fn => {
|
|
974
|
+
try {
|
|
975
|
+
fn();
|
|
976
|
+
} catch (err) {
|
|
977
|
+
container.handleError(err, host);
|
|
978
|
+
}
|
|
979
|
+
}));
|
|
980
|
+
}))), cleanupFns.push(fn));
|
|
981
|
+
};
|
|
982
|
+
const taskApi = {
|
|
983
983
|
track: (obj, prop) => {
|
|
984
984
|
const ctx = newInvokeContext();
|
|
985
|
-
return ctx.$effectSubscriber$ =
|
|
986
|
-
invoke(ctx, (() =>
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
985
|
+
return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
|
|
986
|
+
invoke(ctx, (() => {
|
|
987
|
+
if (isFunction(obj)) {
|
|
988
|
+
return obj();
|
|
989
|
+
}
|
|
990
|
+
if (prop) {
|
|
991
|
+
return obj[prop];
|
|
992
|
+
}
|
|
993
|
+
if (isSignal(obj)) {
|
|
994
|
+
return obj.value;
|
|
995
|
+
}
|
|
996
|
+
if (isStore(obj)) {
|
|
997
|
+
return addStoreEffect(getStoreTarget(obj), STORE_ALL_PROPS, getStoreHandler(obj), ctx.$effectSubscriber$),
|
|
998
|
+
obj;
|
|
999
|
+
}
|
|
1000
|
+
throw qError(QError.trackObjectWithoutProp);
|
|
1001
|
+
}));
|
|
994
1002
|
},
|
|
995
|
-
|
|
1003
|
+
cleanup
|
|
996
1004
|
};
|
|
997
|
-
|
|
998
|
-
let reject;
|
|
999
|
-
let done = !1;
|
|
1000
|
-
const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
|
|
1001
|
-
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
1002
|
-
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
1003
|
-
resource._error = value, reject(value)), !0);
|
|
1004
|
-
cleanups.push((() => {
|
|
1005
|
-
if (!0 === untrack((() => resource.loading))) {
|
|
1006
|
-
const value = untrack((() => resource._resolved));
|
|
1007
|
-
setState(!0, value);
|
|
1008
|
-
}
|
|
1009
|
-
})), invoke(iCtx, (() => {
|
|
1010
|
-
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
1011
|
-
(resource.value = new Promise(((r, re) => {
|
|
1012
|
-
resolve = r, reject = re;
|
|
1013
|
-
}))).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
1014
|
-
}));
|
|
1015
|
-
const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
|
|
1016
|
-
setState(!0, value);
|
|
1017
|
-
}), (err => {
|
|
1005
|
+
return safeCall((() => taskFn(taskApi)), cleanup, (err => {
|
|
1018
1006
|
if (isPromise(err)) {
|
|
1019
|
-
return err.then((() =>
|
|
1007
|
+
return err.then((() => runTask(task, container, host)));
|
|
1020
1008
|
}
|
|
1021
|
-
|
|
1009
|
+
throw err;
|
|
1022
1010
|
}));
|
|
1023
|
-
const timeout = resourceTarget._timeout;
|
|
1024
|
-
return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
|
|
1025
|
-
setState(!1, new Error("timeout")) && cleanupTask(task);
|
|
1026
|
-
})) ]) : promise;
|
|
1027
1011
|
};
|
|
1028
1012
|
|
|
1029
|
-
const
|
|
1013
|
+
const cleanupTask = task => {
|
|
1014
|
+
const destroy = task.$destroy$;
|
|
1015
|
+
if (destroy) {
|
|
1016
|
+
task.$destroy$ = null;
|
|
1017
|
+
try {
|
|
1018
|
+
destroy();
|
|
1019
|
+
} catch (err) {
|
|
1020
|
+
logError(err);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1025
|
+
class Task extends BackRef {
|
|
1026
|
+
$flags$;
|
|
1027
|
+
$index$;
|
|
1028
|
+
$el$;
|
|
1029
|
+
$qrl$;
|
|
1030
|
+
$state$;
|
|
1031
|
+
$destroy$;
|
|
1032
|
+
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
1033
|
+
super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
|
|
1034
|
+
this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
const isTask = value => value instanceof Task;
|
|
1039
|
+
|
|
1040
|
+
const scheduleTask = (_event, element) => {
|
|
1041
|
+
const [task] = useLexicalScope();
|
|
1042
|
+
const type = task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK;
|
|
1043
|
+
getDomContainer(element).$scheduler$(type, task);
|
|
1044
|
+
};
|
|
1030
1045
|
|
|
1031
1046
|
var VNodeFlags;
|
|
1032
1047
|
|
|
@@ -1067,7 +1082,32 @@ var VirtualVNodeProps;
|
|
|
1067
1082
|
VirtualVNodeProps[VirtualVNodeProps.PROPS_OFFSET = 6] = "PROPS_OFFSET";
|
|
1068
1083
|
}(VirtualVNodeProps || (VirtualVNodeProps = {}));
|
|
1069
1084
|
|
|
1070
|
-
const
|
|
1085
|
+
const mapApp_findIndx = (array, key, start) => {
|
|
1086
|
+
assertTrue(start % 2 == 0, "Expecting even number.");
|
|
1087
|
+
let bottom = start >> 1;
|
|
1088
|
+
let top = array.length - 2 >> 1;
|
|
1089
|
+
for (;bottom <= top; ) {
|
|
1090
|
+
const mid = bottom + (top - bottom >> 1);
|
|
1091
|
+
const midKey = array[mid << 1];
|
|
1092
|
+
if (midKey === key) {
|
|
1093
|
+
return mid << 1;
|
|
1094
|
+
}
|
|
1095
|
+
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
1096
|
+
}
|
|
1097
|
+
return ~(bottom << 1);
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
const mapArray_set = (array, key, value, start) => {
|
|
1101
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
1102
|
+
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(~indx, 0, key, value);
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
const mapArray_get = (array, key, start) => {
|
|
1106
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
1107
|
+
return indx >= 0 ? array[indx + 1] : null;
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
const isForeignObjectElement = elementName => isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
|
|
1071
1111
|
|
|
1072
1112
|
const isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
|
|
1073
1113
|
|
|
@@ -1075,7 +1115,18 @@ const isMathElement = elementName => "math" === elementName;
|
|
|
1075
1115
|
|
|
1076
1116
|
const vnode_isDefaultNamespace = vnode => !(vnode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK);
|
|
1077
1117
|
|
|
1078
|
-
const vnode_getElementNamespaceFlags =
|
|
1118
|
+
const vnode_getElementNamespaceFlags = element => {
|
|
1119
|
+
switch (fastNamespaceURI(element)) {
|
|
1120
|
+
case SVG_NS:
|
|
1121
|
+
return VNodeFlags.NS_svg;
|
|
1122
|
+
|
|
1123
|
+
case MATH_NS:
|
|
1124
|
+
return VNodeFlags.NS_math;
|
|
1125
|
+
|
|
1126
|
+
default:
|
|
1127
|
+
return VNodeFlags.NS_html;
|
|
1128
|
+
}
|
|
1129
|
+
};
|
|
1079
1130
|
|
|
1080
1131
|
function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
|
|
1081
1132
|
const {elementNamespace, elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, newChild);
|
|
@@ -1246,14 +1297,14 @@ const useOnEventsSequentialScope = () => {
|
|
|
1246
1297
|
};
|
|
1247
1298
|
|
|
1248
1299
|
const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
|
|
1249
|
-
const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, "qRender");
|
|
1300
|
+
const iCtx = newInvokeContext(container.$locale$, subscriptionHost || void 0, void 0, "qRender");
|
|
1250
1301
|
let componentFn;
|
|
1251
|
-
iCtx.$effectSubscriber$ =
|
|
1252
|
-
container.ensureProjectionResolved(renderHost);
|
|
1302
|
+
subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, EffectProperty.COMPONENT),
|
|
1303
|
+
iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
|
|
1253
1304
|
let isInlineComponent = !1;
|
|
1254
|
-
if (null === componentQRL && assertDefined(componentQRL =
|
|
1255
|
-
isQrl(componentQRL)) {
|
|
1256
|
-
(props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ)
|
|
1305
|
+
if (null === componentQRL && assertDefined(componentQRL = container.getHostProp(renderHost, "q:renderFn"), "No Component found at this location"),
|
|
1306
|
+
isQrl$1(componentQRL)) {
|
|
1307
|
+
(props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ).children && delete props.children,
|
|
1257
1308
|
componentFn = componentQRL.getFn(iCtx);
|
|
1258
1309
|
} else if (isQwikComponent(componentQRL)) {
|
|
1259
1310
|
const qComponentFn = componentQRL;
|
|
@@ -1264,11 +1315,10 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
|
|
|
1264
1315
|
componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
|
|
1265
1316
|
}
|
|
1266
1317
|
const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
|
|
1267
|
-
container.setHostProp(renderHost, ":onIdx", null), container.
|
|
1268
|
-
vnode_isVNode(renderHost) &&
|
|
1269
|
-
componentFn(props))), (jsx => {
|
|
1318
|
+
container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)),
|
|
1319
|
+
vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props))), (jsx => {
|
|
1270
1320
|
const useOnEvents = container.getHostProp(renderHost, ":on");
|
|
1271
|
-
return useOnEvents ?
|
|
1321
|
+
return useOnEvents ? addUseOnEvents(jsx, useOnEvents) : jsx;
|
|
1272
1322
|
}), (err => {
|
|
1273
1323
|
if (isPromise(err) && retryCount < 100) {
|
|
1274
1324
|
return err.then((() => executeComponentWithPromiseExceptionRetry(retryCount++)));
|
|
@@ -1280,13 +1330,28 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
|
|
|
1280
1330
|
|
|
1281
1331
|
function addUseOnEvents(jsx, useOnEvents) {
|
|
1282
1332
|
const jsxElement = findFirstStringJSX(jsx);
|
|
1333
|
+
let jsxResult = jsx;
|
|
1283
1334
|
return maybeThen(jsxElement, (jsxElement => {
|
|
1284
1335
|
let isInvisibleComponent = !1;
|
|
1285
1336
|
jsxElement || (isInvisibleComponent = !0);
|
|
1286
1337
|
for (const key in useOnEvents) {
|
|
1287
|
-
Object.prototype.hasOwnProperty.call(useOnEvents, key)
|
|
1338
|
+
if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
|
|
1339
|
+
if (isInvisibleComponent) {
|
|
1340
|
+
if ("onQvisible$" === key) {
|
|
1341
|
+
const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
1342
|
+
jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]);
|
|
1343
|
+
} else if (key.startsWith("document:") || key.startsWith("window:")) {
|
|
1344
|
+
const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
1345
|
+
jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
|
|
1346
|
+
} else {
|
|
1347
|
+
isDev && logWarn('You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. ');
|
|
1348
|
+
}
|
|
1349
|
+
} else {
|
|
1350
|
+
jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1288
1353
|
}
|
|
1289
|
-
return
|
|
1354
|
+
return jsxResult;
|
|
1290
1355
|
}));
|
|
1291
1356
|
}
|
|
1292
1357
|
|
|
@@ -1327,25 +1392,40 @@ function addScriptNodeForInvisibleComponents(jsx) {
|
|
|
1327
1392
|
type: "placeholder",
|
|
1328
1393
|
hidden: ""
|
|
1329
1394
|
}, null, 3);
|
|
1330
|
-
return null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
|
|
1331
|
-
jsxElement;
|
|
1395
|
+
return jsx.type === Slot ? [ jsxElement, _jsxSorted(Fragment, null, null, [ jsx, jsxElement ], 0, null) ] : (null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
|
|
1396
|
+
[ jsxElement, jsx ]);
|
|
1397
|
+
}
|
|
1398
|
+
if (Array.isArray(jsx) && jsx.length) {
|
|
1399
|
+
const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]);
|
|
1400
|
+
return [ jsxElement, jsx ];
|
|
1332
1401
|
}
|
|
1333
|
-
return
|
|
1402
|
+
return [ null, null ];
|
|
1334
1403
|
}
|
|
1335
1404
|
|
|
1405
|
+
const _CONST_PROPS = Symbol("CONST");
|
|
1406
|
+
|
|
1407
|
+
const _VAR_PROPS = Symbol("VAR");
|
|
1408
|
+
|
|
1409
|
+
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
1410
|
+
|
|
1336
1411
|
function isSlotProp(prop) {
|
|
1337
1412
|
return !prop.startsWith("q:") && !prop.startsWith(":");
|
|
1338
1413
|
}
|
|
1339
1414
|
|
|
1340
|
-
function isParentSlotProp(prop) {
|
|
1341
|
-
return prop.startsWith(":");
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1415
|
const _restProps = (props, omit, target = {}) => {
|
|
1345
|
-
|
|
1346
|
-
|
|
1416
|
+
let constPropsTarget = null;
|
|
1417
|
+
const constProps = props[_CONST_PROPS];
|
|
1418
|
+
if (constProps) {
|
|
1419
|
+
for (const key in constProps) {
|
|
1420
|
+
omit.includes(key) || (constPropsTarget ||= {}, constPropsTarget[key] = constProps[key]);
|
|
1421
|
+
}
|
|
1347
1422
|
}
|
|
1348
|
-
|
|
1423
|
+
const varPropsTarget = target;
|
|
1424
|
+
const varProps = props[_VAR_PROPS];
|
|
1425
|
+
for (const key in varProps) {
|
|
1426
|
+
omit.includes(key) || (varPropsTarget[key] = varProps[key]);
|
|
1427
|
+
}
|
|
1428
|
+
return createPropsProxy(varPropsTarget, constPropsTarget);
|
|
1349
1429
|
};
|
|
1350
1430
|
|
|
1351
1431
|
function escapeHTML(html) {
|
|
@@ -1374,14 +1454,6 @@ function escapeHTML(html) {
|
|
|
1374
1454
|
return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
|
|
1375
1455
|
}
|
|
1376
1456
|
|
|
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
|
-
|
|
1385
1457
|
const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
1386
1458
|
let journal = container.$journal$;
|
|
1387
1459
|
const stack = [];
|
|
@@ -1419,7 +1491,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1419
1491
|
if (Array.isArray(jsxValue)) {
|
|
1420
1492
|
descend(jsxValue, !1);
|
|
1421
1493
|
} else if (isSignal(jsxValue)) {
|
|
1422
|
-
vCurrent &&
|
|
1494
|
+
vCurrent && clearAllEffects(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
|
|
1423
1495
|
descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
|
|
1424
1496
|
} else if (isPromise(jsxValue)) {
|
|
1425
1497
|
expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
|
|
@@ -1501,9 +1573,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1501
1573
|
function expectProjection() {
|
|
1502
1574
|
const slotName = jsxValue.key;
|
|
1503
1575
|
vCurrent = vnode_getProp(vParent, slotName, (id => vnode_locate(container.rootVNode, id))),
|
|
1576
|
+
vCurrent = vCurrent && vCurrent[VNodeProps.flags] & VNodeFlags.Deleted ? null : vCurrent,
|
|
1504
1577
|
null == vCurrent && (vNewNode = vnode_newVirtual(), isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection),
|
|
1505
1578
|
isDev && vnode_setProp(vNewNode, "q:code", "expectProjection"), vnode_setProp(vNewNode, QSlot, slotName),
|
|
1506
|
-
vnode_setProp(vNewNode, ":", vParent), vnode_setProp(vParent, slotName, vNewNode));
|
|
1579
|
+
vnode_setProp(vNewNode, "q:sparent", vParent), vnode_setProp(vParent, slotName, vNewNode));
|
|
1507
1580
|
}
|
|
1508
1581
|
function expectSlot() {
|
|
1509
1582
|
const vHost = vnode_getProjectionParentComponent(vParent, container.rootVNode);
|
|
@@ -1519,19 +1592,27 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1519
1592
|
return directGetPropsProxyProp(jsxNode, "name") || "";
|
|
1520
1593
|
}(vHost);
|
|
1521
1594
|
const vProjectedNode = vHost ? vnode_getProp(vHost, slotNameKey, null) : null;
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1595
|
+
if (null == vProjectedNode) {
|
|
1596
|
+
return vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()),
|
|
1597
|
+
vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode),
|
|
1598
|
+
isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection), isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++),
|
|
1599
|
+
!1;
|
|
1600
|
+
}
|
|
1601
|
+
if (vProjectedNode === vCurrent) {} else {
|
|
1602
|
+
const parent = vnode_getParent(vProjectedNode);
|
|
1603
|
+
!(!parent || vnode_isElementVNode(parent) && vnode_getElementName(parent) === QTemplate) && vParent !== parent && vnode_remove(journal, parent, vProjectedNode, !1),
|
|
1604
|
+
vnode_insertBefore(journal, vParent, vNewNode = vProjectedNode, vCurrent && getInsertBefore()),
|
|
1605
|
+
vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode),
|
|
1606
|
+
isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection), isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
|
|
1607
|
+
}
|
|
1608
|
+
return !0;
|
|
1529
1609
|
}
|
|
1530
1610
|
function expectNoMore() {
|
|
1531
1611
|
if (assertFalse(vParent === vCurrent, "Parent and current can't be the same"), null !== vCurrent) {
|
|
1532
1612
|
for (;vCurrent; ) {
|
|
1533
1613
|
const toRemove = vCurrent;
|
|
1534
|
-
advanceToNextSibling(),
|
|
1614
|
+
advanceToNextSibling(), vParent === vnode_getParent(toRemove) && (cleanup(container, toRemove),
|
|
1615
|
+
vnode_remove(journal, vParent, toRemove, !0));
|
|
1535
1616
|
}
|
|
1536
1617
|
}
|
|
1537
1618
|
}
|
|
@@ -1558,8 +1639,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1558
1639
|
if (isJsxPropertyAnEventName(key)) {
|
|
1559
1640
|
const eventName = getEventNameFromJsxProp(key);
|
|
1560
1641
|
const scope = getEventNameScopeFromJsxProp(key);
|
|
1561
|
-
vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
|
|
1562
|
-
|
|
1642
|
+
if (eventName && (vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
|
|
1643
|
+
registerQwikLoaderEvent(eventName)), scope) {
|
|
1644
|
+
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1645
|
+
htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
|
|
1646
|
+
}
|
|
1647
|
+
needsQDispatchEventPatch = !0;
|
|
1563
1648
|
} else {
|
|
1564
1649
|
if ("ref" === key) {
|
|
1565
1650
|
if (isSignal(value)) {
|
|
@@ -1570,10 +1655,13 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1570
1655
|
value(element);
|
|
1571
1656
|
continue;
|
|
1572
1657
|
}
|
|
1658
|
+
if (null == value) {
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1573
1661
|
throw qError(QError.invalidRefValue, [ currentFile ]);
|
|
1574
1662
|
}
|
|
1575
1663
|
if (isSignal(value)) {
|
|
1576
|
-
const signalData = new
|
|
1664
|
+
const signalData = new SubscriptionData({
|
|
1577
1665
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1578
1666
|
$isConst$: !0
|
|
1579
1667
|
});
|
|
@@ -1620,10 +1708,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1620
1708
|
const vNode = vNewNode || vCurrent;
|
|
1621
1709
|
if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile) {
|
|
1622
1710
|
vnode_ensureElementInflated(vnode);
|
|
1623
|
-
const dstAttrs = vnode;
|
|
1711
|
+
const dstAttrs = vnode_getProps(vnode);
|
|
1624
1712
|
let srcIdx = 0;
|
|
1625
1713
|
const srcLength = srcAttrs.length;
|
|
1626
|
-
let dstIdx =
|
|
1714
|
+
let dstIdx = 0;
|
|
1627
1715
|
let dstLength = dstAttrs.length;
|
|
1628
1716
|
let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
|
|
1629
1717
|
let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
@@ -1640,10 +1728,13 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1640
1728
|
if ("function" == typeof value) {
|
|
1641
1729
|
return void value(element);
|
|
1642
1730
|
}
|
|
1731
|
+
if (null == value) {
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1643
1734
|
throw qError(QError.invalidRefValue, [ currentFile ]);
|
|
1644
1735
|
}
|
|
1645
1736
|
if (isSignal(value)) {
|
|
1646
|
-
const signalData = new
|
|
1737
|
+
const signalData = new SubscriptionData({
|
|
1647
1738
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1648
1739
|
$isConst$: !1
|
|
1649
1740
|
});
|
|
@@ -1655,12 +1746,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1655
1746
|
};
|
|
1656
1747
|
const recordJsxEvent = (key, value) => {
|
|
1657
1748
|
const eventName = getEventNameFromJsxProp(key);
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1749
|
+
const scope = getEventNameScopeFromJsxProp(key);
|
|
1750
|
+
if (eventName && (record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)),
|
|
1751
|
+
scope) {
|
|
1752
|
+
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1753
|
+
htmlEvent && record(htmlEvent, "");
|
|
1661
1754
|
}
|
|
1662
|
-
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1663
|
-
htmlEvent && record(htmlEvent, ""), eventName && registerQwikLoaderEvent(eventName);
|
|
1664
1755
|
};
|
|
1665
1756
|
for (;null !== srcKey || null !== dstKey; ) {
|
|
1666
1757
|
if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
|
|
@@ -1692,7 +1783,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1692
1783
|
let returnValue = !1;
|
|
1693
1784
|
return qrls.flat(2).forEach((qrl => {
|
|
1694
1785
|
if (qrl) {
|
|
1695
|
-
const value = qrl
|
|
1786
|
+
const value = container.$scheduler$(ChoreType.RUN_QRL, vNode, qrl, [ event, element ]);
|
|
1696
1787
|
returnValue = returnValue || !0 === value;
|
|
1697
1788
|
}
|
|
1698
1789
|
})), returnValue;
|
|
@@ -1741,8 +1832,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1741
1832
|
const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
|
|
1742
1833
|
const lookupKey = jsxNode.key || componentHash;
|
|
1743
1834
|
if (lookupKey === (getKey(host) || vNodeComponentHash) ? componentHash === vNodeComponentHash || (insertNewComponent(host, componentQRL, jsxProps),
|
|
1744
|
-
|
|
1745
|
-
|
|
1835
|
+
host = vNewNode, shouldRender = !0) : (vNewNode = retrieveChildWithKey(null, lookupKey),
|
|
1836
|
+
vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps),
|
|
1746
1837
|
host = vNewNode, shouldRender = !0), host) {
|
|
1747
1838
|
const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
|
|
1748
1839
|
shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps), shouldRender && (host[VNodeProps.flags] &= ~VNodeFlags.Deleted,
|
|
@@ -1753,8 +1844,9 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1753
1844
|
const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
|
|
1754
1845
|
const projections = [];
|
|
1755
1846
|
if (host) {
|
|
1756
|
-
|
|
1757
|
-
|
|
1847
|
+
const props = vnode_getProps(host);
|
|
1848
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
1849
|
+
const prop = props[i];
|
|
1758
1850
|
if (isSlotProp(prop)) {
|
|
1759
1851
|
const slotName = prop;
|
|
1760
1852
|
projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
|
|
@@ -1778,13 +1870,11 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1778
1870
|
}(jsxNode.children, host);
|
|
1779
1871
|
} else {
|
|
1780
1872
|
const lookupKey = jsxNode.key;
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
jsxNode.key && vnode_setProp(vNewNode, "q:key", jsxNode.key);
|
|
1787
|
-
}(), host = vNewNode), host) {
|
|
1873
|
+
const lookupKeysAreEqual = lookupKey === getKey(host);
|
|
1874
|
+
const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
|
|
1875
|
+
if (lookupKeysAreEqual ? null != vNodeComponentHash && (insertNewInlineComponent(),
|
|
1876
|
+
host = vNewNode) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewInlineComponent(),
|
|
1877
|
+
host = vNewNode), host) {
|
|
1788
1878
|
let componentHost = host;
|
|
1789
1879
|
for (;componentHost && (!vnode_isVirtualVNode(componentHost) || null === vnode_getProp(componentHost, "q:renderFn", null)); ) {
|
|
1790
1880
|
componentHost = vnode_getParent(componentHost);
|
|
@@ -1795,11 +1885,17 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
1795
1885
|
}
|
|
1796
1886
|
}
|
|
1797
1887
|
function insertNewComponent(host, componentQRL, jsxProps) {
|
|
1798
|
-
host &&
|
|
1888
|
+
host && clearAllEffects(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1799
1889
|
const jsxNode = jsxValue;
|
|
1800
1890
|
isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
|
|
1801
1891
|
container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
|
|
1802
1892
|
}
|
|
1893
|
+
function insertNewInlineComponent() {
|
|
1894
|
+
vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1895
|
+
const jsxNode = jsxValue;
|
|
1896
|
+
isDev && vnode_setProp(vNewNode, "q:type", VirtualType.InlineComponent), vnode_setProp(vNewNode, "q:props", jsxNode.props),
|
|
1897
|
+
jsxNode.key && vnode_setProp(vNewNode, "q:key", jsxNode.key);
|
|
1898
|
+
}
|
|
1803
1899
|
function expectText(text) {
|
|
1804
1900
|
if (null !== vCurrent) {
|
|
1805
1901
|
if (3 === vnode_getType(vCurrent)) {
|
|
@@ -1828,8 +1924,8 @@ function propsDiffer(src, dst) {
|
|
|
1828
1924
|
if (!src || !dst) {
|
|
1829
1925
|
return !0;
|
|
1830
1926
|
}
|
|
1831
|
-
let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:
|
|
1832
|
-
let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:
|
|
1927
|
+
let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:brefs" ]);
|
|
1928
|
+
let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:brefs" ]);
|
|
1833
1929
|
if (srcKeys.length !== dstKeys.length) {
|
|
1834
1930
|
return !0;
|
|
1835
1931
|
}
|
|
@@ -1855,30 +1951,28 @@ function removePropsKeys(keys, propKeys) {
|
|
|
1855
1951
|
function cleanup(container, vNode) {
|
|
1856
1952
|
let vCursor = vNode;
|
|
1857
1953
|
if (vnode_isTextVNode(vNode)) {
|
|
1858
|
-
return;
|
|
1954
|
+
return void markVNodeAsDeleted(vCursor);
|
|
1859
1955
|
}
|
|
1860
1956
|
let vParent = null;
|
|
1861
1957
|
for (;;) {
|
|
1862
1958
|
const type = vCursor[VNodeProps.flags];
|
|
1863
1959
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
1864
|
-
if (
|
|
1865
|
-
type & VNodeFlags.Virtual) {
|
|
1960
|
+
if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), type & VNodeFlags.Virtual) {
|
|
1866
1961
|
const seq = container.getHostProp(vCursor, "q:seq");
|
|
1867
1962
|
if (seq) {
|
|
1868
1963
|
for (let i = 0; i < seq.length; i++) {
|
|
1869
1964
|
const obj = seq[i];
|
|
1870
1965
|
if (isTask(obj)) {
|
|
1871
1966
|
const task = obj;
|
|
1872
|
-
|
|
1967
|
+
clearAllEffects(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
|
|
1873
1968
|
}
|
|
1874
1969
|
}
|
|
1875
1970
|
}
|
|
1876
1971
|
}
|
|
1877
1972
|
if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, "q:renderFn", null)) {
|
|
1878
|
-
const attrs = vCursor;
|
|
1879
|
-
for (let i =
|
|
1880
|
-
|
|
1881
|
-
if (!isParentSlotProp(key) && isSlotProp(key)) {
|
|
1973
|
+
const attrs = vnode_getProps(vCursor);
|
|
1974
|
+
for (let i = 0; i < attrs.length; i += 2) {
|
|
1975
|
+
if (isSlotProp(attrs[i])) {
|
|
1882
1976
|
const value = attrs[i + 1];
|
|
1883
1977
|
if (value) {
|
|
1884
1978
|
attrs[i + 1] = null;
|
|
@@ -1892,7 +1986,7 @@ function cleanup(container, vNode) {
|
|
|
1892
1986
|
}
|
|
1893
1987
|
}
|
|
1894
1988
|
}
|
|
1895
|
-
if (
|
|
1989
|
+
if (vnode_isProjection(vCursor)) {
|
|
1896
1990
|
if (vCursor === vNode) {
|
|
1897
1991
|
const vFirstChild = vnode_getFirstChild(vCursor);
|
|
1898
1992
|
if (vFirstChild) {
|
|
@@ -1906,6 +2000,8 @@ function cleanup(container, vNode) {
|
|
|
1906
2000
|
continue;
|
|
1907
2001
|
}
|
|
1908
2002
|
}
|
|
2003
|
+
} else {
|
|
2004
|
+
type & VNodeFlags.Text && markVNodeAsDeleted(vCursor);
|
|
1909
2005
|
}
|
|
1910
2006
|
if (vCursor === vNode) {
|
|
1911
2007
|
return;
|
|
@@ -1955,19 +2051,127 @@ var SiblingsArray;
|
|
|
1955
2051
|
SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
|
|
1956
2052
|
}(SiblingsArray || (SiblingsArray = {}));
|
|
1957
2053
|
|
|
1958
|
-
const
|
|
1959
|
-
|
|
2054
|
+
const useResourceQrl = (qrl, opts) => {
|
|
2055
|
+
const {val, set, i, iCtx} = useSequentialScope();
|
|
2056
|
+
if (null != val) {
|
|
2057
|
+
return val;
|
|
2058
|
+
}
|
|
2059
|
+
assertQrl(qrl);
|
|
2060
|
+
const container = iCtx.$container$;
|
|
2061
|
+
const resource = createResourceReturn(container, opts);
|
|
2062
|
+
const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
|
|
2063
|
+
return container.$scheduler$(ChoreType.TASK, task), set(resource), resource;
|
|
1960
2064
|
};
|
|
1961
2065
|
|
|
1962
|
-
const
|
|
2066
|
+
const Resource = props => _jsxSorted(Fragment, null, null, getResourceValueAsPromise(props), 0, null);
|
|
1963
2067
|
|
|
1964
|
-
|
|
2068
|
+
function getResourceValueAsPromise(props) {
|
|
2069
|
+
const resource = props.value;
|
|
2070
|
+
if (isResourceReturn(resource) && resource.value) {
|
|
2071
|
+
if (!isServerPlatform()) {
|
|
2072
|
+
const state = resource._state;
|
|
2073
|
+
if ("pending" === state && props.onPending) {
|
|
2074
|
+
return Promise.resolve().then(useBindInvokeContext(props.onPending));
|
|
2075
|
+
}
|
|
2076
|
+
if ("rejected" === state && props.onRejected) {
|
|
2077
|
+
return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
|
|
2078
|
+
}
|
|
2079
|
+
{
|
|
2080
|
+
const resolvedValue = untrack((() => resource._resolved));
|
|
2081
|
+
if (void 0 !== resolvedValue) {
|
|
2082
|
+
return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
|
|
2087
|
+
}
|
|
2088
|
+
return isPromise(resource) ? resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : isSignal(resource) ? Promise.resolve(resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(resource).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
|
|
2089
|
+
}
|
|
1965
2090
|
|
|
1966
|
-
const
|
|
2091
|
+
const _createResourceReturn = opts => ({
|
|
2092
|
+
__brand: "resource",
|
|
2093
|
+
value: void 0,
|
|
2094
|
+
loading: !isServerPlatform(),
|
|
2095
|
+
_resolved: void 0,
|
|
2096
|
+
_error: void 0,
|
|
2097
|
+
_state: "pending",
|
|
2098
|
+
_timeout: opts?.timeout ?? -1,
|
|
2099
|
+
_cache: 0
|
|
2100
|
+
});
|
|
1967
2101
|
|
|
1968
|
-
const
|
|
2102
|
+
const createResourceReturn = (container, opts, initialPromise) => {
|
|
2103
|
+
const result = _createResourceReturn(opts);
|
|
2104
|
+
return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
|
|
2105
|
+
};
|
|
1969
2106
|
|
|
1970
|
-
const
|
|
2107
|
+
const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
|
|
2108
|
+
|
|
2109
|
+
const runResource = (task, container, host) => {
|
|
2110
|
+
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
2111
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
2112
|
+
iCtx.$container$ = container;
|
|
2113
|
+
const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
|
|
2114
|
+
const resource = task.$state$;
|
|
2115
|
+
assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
|
|
2116
|
+
const cleanups = [];
|
|
2117
|
+
task.$destroy$ = noSerialize((() => {
|
|
2118
|
+
cleanups.forEach((fn => {
|
|
2119
|
+
try {
|
|
2120
|
+
fn();
|
|
2121
|
+
} catch (err) {
|
|
2122
|
+
container.handleError(err, host);
|
|
2123
|
+
}
|
|
2124
|
+
})), done = !0;
|
|
2125
|
+
}));
|
|
2126
|
+
const resourceTarget = unwrapStore(resource);
|
|
2127
|
+
const opts = {
|
|
2128
|
+
track: (obj, prop) => {
|
|
2129
|
+
const ctx = newInvokeContext();
|
|
2130
|
+
return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
|
|
2131
|
+
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
2132
|
+
},
|
|
2133
|
+
cleanup(fn) {
|
|
2134
|
+
"function" == typeof fn && cleanups.push(fn);
|
|
2135
|
+
},
|
|
2136
|
+
cache(policy) {
|
|
2137
|
+
let milliseconds = 0;
|
|
2138
|
+
milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
|
|
2139
|
+
},
|
|
2140
|
+
previous: resourceTarget._resolved
|
|
2141
|
+
};
|
|
2142
|
+
let resolve;
|
|
2143
|
+
let reject;
|
|
2144
|
+
let done = !1;
|
|
2145
|
+
const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
|
|
2146
|
+
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
2147
|
+
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
2148
|
+
resource._error = value, reject(value)), !0);
|
|
2149
|
+
cleanups.push((() => {
|
|
2150
|
+
if (!0 === untrack((() => resource.loading))) {
|
|
2151
|
+
const value = untrack((() => resource._resolved));
|
|
2152
|
+
setState(!0, value);
|
|
2153
|
+
}
|
|
2154
|
+
})), invoke(iCtx, (() => {
|
|
2155
|
+
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
2156
|
+
(resource.value = new Promise(((r, re) => {
|
|
2157
|
+
resolve = r, reject = re;
|
|
2158
|
+
}))).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
2159
|
+
}));
|
|
2160
|
+
const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
|
|
2161
|
+
setState(!0, value);
|
|
2162
|
+
}), (err => {
|
|
2163
|
+
if (isPromise(err)) {
|
|
2164
|
+
return err.then((() => runResource(task, container, host)));
|
|
2165
|
+
}
|
|
2166
|
+
setState(!1, err);
|
|
2167
|
+
}));
|
|
2168
|
+
const timeout = resourceTarget._timeout;
|
|
2169
|
+
return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
|
|
2170
|
+
setState(!1, new Error("timeout")) && cleanupTask(task);
|
|
2171
|
+
})) ]) : promise;
|
|
2172
|
+
};
|
|
2173
|
+
|
|
2174
|
+
const ignoreErrorToPreventNodeFromCrashing = () => {};
|
|
1971
2175
|
|
|
1972
2176
|
const aVNodePath = [];
|
|
1973
2177
|
|
|
@@ -1980,10 +2184,10 @@ const vnode_documentPosition = (a, b, rootVNode) => {
|
|
|
1980
2184
|
let aDepth = -1;
|
|
1981
2185
|
let bDepth = -1;
|
|
1982
2186
|
for (;a; ) {
|
|
1983
|
-
a = (aVNodePath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, ":", (id => vnode_locate(rootVNode, id)));
|
|
2187
|
+
a = (aVNodePath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, "q:sparent", (id => vnode_locate(rootVNode, id)));
|
|
1984
2188
|
}
|
|
1985
2189
|
for (;b; ) {
|
|
1986
|
-
b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id)));
|
|
2190
|
+
b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id)));
|
|
1987
2191
|
}
|
|
1988
2192
|
for (;aDepth >= 0 && bDepth >= 0; ) {
|
|
1989
2193
|
if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
|
|
@@ -1999,7 +2203,7 @@ const vnode_documentPosition = (a, b, rootVNode) => {
|
|
|
1999
2203
|
return -1;
|
|
2000
2204
|
}
|
|
2001
2205
|
} while (cursor);
|
|
2002
|
-
return rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
|
|
2206
|
+
return rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
|
|
2003
2207
|
}
|
|
2004
2208
|
aDepth--, bDepth--;
|
|
2005
2209
|
}
|
|
@@ -2031,25 +2235,26 @@ const ssrNodeDocumentPosition = (a, b) => {
|
|
|
2031
2235
|
return aDepth < bDepth ? -1 : 1;
|
|
2032
2236
|
};
|
|
2033
2237
|
|
|
2034
|
-
|
|
2238
|
+
const DEBUG$1 = !1;
|
|
2035
2239
|
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
|
|
2040
|
-
ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
|
|
2041
|
-
ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
|
|
2042
|
-
ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
|
|
2043
|
-
ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
|
|
2044
|
-
}(ChoreType || (ChoreType = {}));
|
|
2240
|
+
const getPromise = chore => chore.$promise$ ||= new Promise((resolve => {
|
|
2241
|
+
chore.$resolve$ = resolve;
|
|
2242
|
+
}));
|
|
2045
2243
|
|
|
2046
2244
|
const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
2047
2245
|
const choreQueue = [];
|
|
2246
|
+
const qrlRuns = [];
|
|
2048
2247
|
let currentChore = null;
|
|
2049
|
-
let
|
|
2248
|
+
let drainScheduled = !1;
|
|
2050
2249
|
return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
|
|
2051
|
-
const
|
|
2052
|
-
const
|
|
2250
|
+
const isServer = !isDomContainer(container);
|
|
2251
|
+
const isComponentSsr = isServer && type === ChoreType.COMPONENT;
|
|
2252
|
+
const runLater = type !== ChoreType.WAIT_FOR_ALL && !isComponentSsr && type !== ChoreType.RUN_QRL;
|
|
2253
|
+
const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
|
|
2254
|
+
const isClientOnly = type === ChoreType.JOURNAL_FLUSH || type === ChoreType.NODE_DIFF || type === ChoreType.NODE_PROP;
|
|
2255
|
+
if (isServer && isClientOnly) {
|
|
2256
|
+
return;
|
|
2257
|
+
}
|
|
2053
2258
|
isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
|
|
2054
2259
|
let chore = {
|
|
2055
2260
|
$type$: type,
|
|
@@ -2062,134 +2267,177 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
2062
2267
|
$returnValue$: null,
|
|
2063
2268
|
$executed$: !1
|
|
2064
2269
|
};
|
|
2065
|
-
chore
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2270
|
+
chore = function(sortedArray, value, rootVNode) {
|
|
2271
|
+
const idx = function(sortedArray, value, rootVNode) {
|
|
2272
|
+
let bottom = 0;
|
|
2273
|
+
let top = sortedArray.length;
|
|
2274
|
+
for (;bottom < top; ) {
|
|
2275
|
+
const middle = bottom + (top - bottom >> 1);
|
|
2276
|
+
const comp = choreComparator(value, sortedArray[middle], rootVNode);
|
|
2277
|
+
if (comp < 0) {
|
|
2278
|
+
top = middle;
|
|
2279
|
+
} else {
|
|
2280
|
+
if (!(comp > 0)) {
|
|
2281
|
+
return middle;
|
|
2282
|
+
}
|
|
2283
|
+
bottom = middle + 1;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
return ~bottom;
|
|
2287
|
+
}(sortedArray, value, rootVNode);
|
|
2288
|
+
if (idx < 0) {
|
|
2289
|
+
return sortedArray.splice(~idx, 0, value), value;
|
|
2290
|
+
}
|
|
2291
|
+
const existing = sortedArray[idx];
|
|
2292
|
+
existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = value.$payload$);
|
|
2293
|
+
existing.$executed$ && (existing.$executed$ = !1);
|
|
2294
|
+
return existing;
|
|
2295
|
+
}(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
|
|
2296
|
+
schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain()?.catch?.((() => {})));
|
|
2297
|
+
return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
|
|
2069
2298
|
};
|
|
2070
|
-
function drainUpTo(runUptoChore,
|
|
2071
|
-
|
|
2072
|
-
return runUptoChore.$returnValue$;
|
|
2073
|
-
}
|
|
2074
|
-
if (currentChore) {
|
|
2075
|
-
return runUptoChore.$promise$;
|
|
2076
|
-
}
|
|
2299
|
+
function drainUpTo(runUptoChore, isServer) {
|
|
2300
|
+
let maxRetries = 5e3;
|
|
2077
2301
|
for (;choreQueue.length; ) {
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
if (null === order) {
|
|
2081
|
-
continue;
|
|
2082
|
-
}
|
|
2083
|
-
if (order > 0) {
|
|
2084
|
-
break;
|
|
2302
|
+
if (maxRetries-- < 0) {
|
|
2303
|
+
throw new Error("drainUpTo: max retries reached");
|
|
2085
2304
|
}
|
|
2086
|
-
if (
|
|
2087
|
-
|
|
2305
|
+
if (currentChore) {
|
|
2306
|
+
return getPromise(currentChore).then((() => drainUpTo(runUptoChore, isServer))).catch((e => {
|
|
2307
|
+
container.handleError(e, currentChore?.$host$);
|
|
2308
|
+
}));
|
|
2088
2309
|
}
|
|
2089
|
-
const
|
|
2090
|
-
if (
|
|
2091
|
-
|
|
2310
|
+
const nextChore = choreQueue[0];
|
|
2311
|
+
if (nextChore.$executed$) {
|
|
2312
|
+
if (choreQueue.shift(), nextChore === runUptoChore) {
|
|
2313
|
+
break;
|
|
2314
|
+
}
|
|
2315
|
+
} else {
|
|
2316
|
+
vNodeAlreadyDeleted(nextChore) && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE ? choreQueue.shift() : executeChore(nextChore, isServer);
|
|
2092
2317
|
}
|
|
2093
2318
|
}
|
|
2094
2319
|
return runUptoChore.$returnValue$;
|
|
2095
2320
|
}
|
|
2096
|
-
function executeChore(chore) {
|
|
2321
|
+
function executeChore(chore, isServer) {
|
|
2097
2322
|
const host = chore.$host$;
|
|
2098
2323
|
assertEqual(currentChore, null, "Chore already running."), currentChore = chore;
|
|
2099
2324
|
let returnValue = null;
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2325
|
+
try {
|
|
2326
|
+
switch (chore.$type$) {
|
|
2327
|
+
case ChoreType.WAIT_FOR_ALL:
|
|
2328
|
+
isServer && (drainScheduled = !1);
|
|
2329
|
+
break;
|
|
2104
2330
|
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
if (chore.$type$ === ChoreType.COMPONENT) {
|
|
2109
|
-
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
2110
|
-
return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
|
|
2111
|
-
}
|
|
2112
|
-
return jsx;
|
|
2113
|
-
}), (err => container.handleError(err, host)));
|
|
2114
|
-
break;
|
|
2331
|
+
case ChoreType.JOURNAL_FLUSH:
|
|
2332
|
+
returnValue = journalFlush(), drainScheduled = !1;
|
|
2333
|
+
break;
|
|
2115
2334
|
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2335
|
+
case ChoreType.COMPONENT:
|
|
2336
|
+
returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
|
|
2337
|
+
if (isServer) {
|
|
2338
|
+
return jsx;
|
|
2339
|
+
}
|
|
2340
|
+
{
|
|
2341
|
+
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
2342
|
+
return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
|
|
2343
|
+
}
|
|
2344
|
+
}), (err => container.handleError(err, host)));
|
|
2345
|
+
break;
|
|
2120
2346
|
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2347
|
+
case ChoreType.RUN_QRL:
|
|
2348
|
+
{
|
|
2349
|
+
const fn = chore.$target$.getFn();
|
|
2350
|
+
const result = retryOnPromise((() => fn(...chore.$payload$)));
|
|
2351
|
+
if (isPromise(result)) {
|
|
2352
|
+
const handled = result.finally((() => {
|
|
2353
|
+
qrlRuns.splice(qrlRuns.indexOf(handled), 1);
|
|
2354
|
+
})).catch((error => {
|
|
2355
|
+
container.handleError(error, chore.$host$);
|
|
2356
|
+
}));
|
|
2357
|
+
return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
|
|
2358
|
+
currentChore = null, void (chore.$executed$ = !0);
|
|
2359
|
+
}
|
|
2360
|
+
returnValue = null;
|
|
2361
|
+
}
|
|
2362
|
+
break;
|
|
2125
2363
|
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2364
|
+
case ChoreType.TASK:
|
|
2365
|
+
case ChoreType.VISIBLE:
|
|
2366
|
+
{
|
|
2367
|
+
const payload = chore.$payload$;
|
|
2368
|
+
if (payload.$flags$ & TaskFlags.RESOURCE) {
|
|
2369
|
+
const result = runResource(payload, container, host);
|
|
2370
|
+
returnValue = isServer ? result : null;
|
|
2371
|
+
} else {
|
|
2372
|
+
returnValue = runTask(payload, container, host);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
break;
|
|
2129
2376
|
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
|
|
2134
|
-
break;
|
|
2377
|
+
case ChoreType.CLEANUP_VISIBLE:
|
|
2378
|
+
cleanupTask(chore.$payload$);
|
|
2379
|
+
break;
|
|
2135
2380
|
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
const property = chore.$idx$;
|
|
2144
|
-
const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
|
|
2145
|
-
if (isConst) {
|
|
2146
|
-
journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
|
|
2147
|
-
} else {
|
|
2148
|
-
vnode_setAttr(journal, virtualNode, property, serializedValue);
|
|
2149
|
-
}
|
|
2150
|
-
break;
|
|
2381
|
+
case ChoreType.NODE_DIFF:
|
|
2382
|
+
{
|
|
2383
|
+
const parentVirtualNode = chore.$target$;
|
|
2384
|
+
let jsx = chore.$payload$;
|
|
2385
|
+
isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
|
|
2386
|
+
}
|
|
2387
|
+
break;
|
|
2151
2388
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2389
|
+
case ChoreType.NODE_PROP:
|
|
2390
|
+
{
|
|
2391
|
+
const virtualNode = chore.$host$;
|
|
2392
|
+
const payload = chore.$payload$;
|
|
2393
|
+
let value = payload.$value$;
|
|
2394
|
+
isSignal(value) && (value = value.value);
|
|
2395
|
+
const isConst = payload.$isConst$;
|
|
2396
|
+
const journal = container.$journal$;
|
|
2397
|
+
const property = chore.$idx$;
|
|
2398
|
+
const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
|
|
2399
|
+
if (isConst) {
|
|
2400
|
+
journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
|
|
2401
|
+
} else {
|
|
2402
|
+
vnode_setAttr(journal, virtualNode, property, serializedValue);
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2156
2405
|
break;
|
|
2157
|
-
}
|
|
2158
2406
|
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
if (target.$forceRunEffects$ = !1, !target.$effects$?.length) {
|
|
2164
|
-
break;
|
|
2407
|
+
case ChoreType.QRL_RESOLVE:
|
|
2408
|
+
{
|
|
2409
|
+
const target = chore.$target$;
|
|
2410
|
+
returnValue = target.resolved ? null : target.resolve();
|
|
2165
2411
|
}
|
|
2166
|
-
returnValue = retryOnPromise((() => {
|
|
2167
|
-
(target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
|
|
2168
|
-
}));
|
|
2169
2412
|
break;
|
|
2413
|
+
|
|
2414
|
+
case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
|
|
2415
|
+
{
|
|
2416
|
+
const target = chore.$target$;
|
|
2417
|
+
const forceRunEffects = target.$forceRunEffects$;
|
|
2418
|
+
if (target.$forceRunEffects$ = !1, !target.$effects$?.size) {
|
|
2419
|
+
break;
|
|
2420
|
+
}
|
|
2421
|
+
returnValue = retryOnPromise((() => {
|
|
2422
|
+
(target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
|
|
2423
|
+
}));
|
|
2424
|
+
}
|
|
2170
2425
|
}
|
|
2426
|
+
} catch (e) {
|
|
2427
|
+
returnValue = Promise.reject(e);
|
|
2171
2428
|
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
};
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
const choreUpdate = (existing, newChore) => {
|
|
2180
|
-
existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = newChore.$payload$);
|
|
2181
|
-
};
|
|
2182
|
-
|
|
2183
|
-
function vNodeAlreadyDeleted(chore) {
|
|
2184
|
-
return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
function choreComparator(a, b, rootVNode) {
|
|
2188
|
-
const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
|
|
2189
|
-
if (0 !== macroTypeDiff) {
|
|
2190
|
-
return macroTypeDiff;
|
|
2429
|
+
const after = (value, error) => {
|
|
2430
|
+
currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
|
|
2431
|
+
chore.$resolve$?.(value));
|
|
2432
|
+
};
|
|
2433
|
+
isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error => after(void 0, error))),
|
|
2434
|
+
chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
|
|
2191
2435
|
}
|
|
2192
|
-
|
|
2436
|
+
function choreComparator(a, b, rootVNode) {
|
|
2437
|
+
const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
|
|
2438
|
+
if (0 !== macroTypeDiff) {
|
|
2439
|
+
return macroTypeDiff;
|
|
2440
|
+
}
|
|
2193
2441
|
const aHost = a.$host$;
|
|
2194
2442
|
const bHost = b.$host$;
|
|
2195
2443
|
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
@@ -2199,6 +2447,8 @@ function choreComparator(a, b, rootVNode) {
|
|
|
2199
2447
|
return hostDiff;
|
|
2200
2448
|
}
|
|
2201
2449
|
} else {
|
|
2450
|
+
assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode"),
|
|
2451
|
+
assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
|
|
2202
2452
|
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
2453
|
logWarn(errorMessage);
|
|
2204
2454
|
const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
|
|
@@ -2212,157 +2462,60 @@ function choreComparator(a, b, rootVNode) {
|
|
|
2212
2462
|
return microTypeDiff;
|
|
2213
2463
|
}
|
|
2214
2464
|
const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
|
|
2215
|
-
|
|
2216
|
-
return idxDiff;
|
|
2217
|
-
}
|
|
2218
|
-
if (a.$target$ !== b.$target$ && (a.$type$ === ChoreType.QRL_RESOLVE && b.$type$ === ChoreType.QRL_RESOLVE || a.$type$ === ChoreType.NODE_PROP && b.$type$ === ChoreType.NODE_PROP || a.$type$ === ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS && b.$type$ === ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS)) {
|
|
2219
|
-
return 1;
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
return 0;
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
function sortedFindIndex(sortedArray, value, rootVNode) {
|
|
2226
|
-
let bottom = 0;
|
|
2227
|
-
let top = sortedArray.length;
|
|
2228
|
-
for (;bottom < top; ) {
|
|
2229
|
-
const middle = bottom + (top - bottom >> 1);
|
|
2230
|
-
const comp = choreComparator(value, sortedArray[middle], rootVNode);
|
|
2231
|
-
if (comp < 0) {
|
|
2232
|
-
top = middle;
|
|
2233
|
-
} else {
|
|
2234
|
-
if (!(comp > 0)) {
|
|
2235
|
-
return middle;
|
|
2236
|
-
}
|
|
2237
|
-
bottom = middle + 1;
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
return ~bottom;
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
function sortedInsert(sortedArray, value, rootVNode) {
|
|
2244
|
-
const idx = sortedFindIndex(sortedArray, value, rootVNode);
|
|
2245
|
-
if (idx < 0) {
|
|
2246
|
-
return sortedArray.splice(~idx, 0, value), value;
|
|
2247
|
-
}
|
|
2248
|
-
const existing = sortedArray[idx];
|
|
2249
|
-
return choreUpdate(existing, value), existing;
|
|
2250
|
-
}
|
|
2251
|
-
|
|
2252
|
-
const useLexicalScope = () => {
|
|
2253
|
-
const context = getInvokeContext();
|
|
2254
|
-
let qrl = context.$qrl$;
|
|
2255
|
-
if (qrl) {
|
|
2256
|
-
assertQrl(qrl), assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
|
|
2257
|
-
} else {
|
|
2258
|
-
const el = context.$element$;
|
|
2259
|
-
assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
|
|
2260
|
-
const containerElement = _getQContainerElement(el);
|
|
2261
|
-
assertDefined(containerElement, "invoke: cant find parent q:container of", el);
|
|
2262
|
-
qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
|
|
2263
|
-
}
|
|
2264
|
-
return qrl.$captureRef$;
|
|
2265
|
-
};
|
|
2266
|
-
|
|
2267
|
-
var TaskFlags;
|
|
2268
|
-
|
|
2269
|
-
!function(TaskFlags) {
|
|
2270
|
-
TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
|
|
2271
|
-
TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
|
|
2272
|
-
}(TaskFlags || (TaskFlags = {}));
|
|
2273
|
-
|
|
2274
|
-
const useTaskQrl = (qrl, opts) => {
|
|
2275
|
-
const {val, set, iCtx, i} = useSequentialScope();
|
|
2276
|
-
if (val) {
|
|
2277
|
-
return;
|
|
2278
|
-
}
|
|
2279
|
-
assertQrl(qrl), set(1);
|
|
2280
|
-
const host = iCtx.$hostElement$;
|
|
2281
|
-
const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
2282
|
-
set(task);
|
|
2283
|
-
const result = runTask(task, iCtx.$container$, host);
|
|
2284
|
-
if (isPromise(result)) {
|
|
2285
|
-
throw result;
|
|
2465
|
+
return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
|
|
2286
2466
|
}
|
|
2287
|
-
qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
|
|
2288
2467
|
};
|
|
2289
2468
|
|
|
2290
|
-
const
|
|
2291
|
-
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
2292
|
-
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
2293
|
-
iCtx.$container$ = container;
|
|
2294
|
-
const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
|
|
2295
|
-
const handleError = reason => container.handleError(reason, host);
|
|
2296
|
-
let cleanupFns = null;
|
|
2297
|
-
const cleanup = fn => {
|
|
2298
|
-
"function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
|
|
2299
|
-
task.$destroy$ = null, cleanupFns.forEach((fn => {
|
|
2300
|
-
try {
|
|
2301
|
-
fn();
|
|
2302
|
-
} catch (err) {
|
|
2303
|
-
handleError(err);
|
|
2304
|
-
}
|
|
2305
|
-
}));
|
|
2306
|
-
}))), cleanupFns.push(fn));
|
|
2307
|
-
};
|
|
2308
|
-
const taskApi = {
|
|
2309
|
-
track: (obj, prop) => {
|
|
2310
|
-
const ctx = newInvokeContext();
|
|
2311
|
-
return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
|
|
2312
|
-
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
2313
|
-
},
|
|
2314
|
-
cleanup
|
|
2315
|
-
};
|
|
2316
|
-
return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
|
|
2317
|
-
};
|
|
2469
|
+
const toNumber = value => "number" == typeof value ? value : -1;
|
|
2318
2470
|
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
task.$destroy$ = null;
|
|
2323
|
-
try {
|
|
2324
|
-
destroy();
|
|
2325
|
-
} catch (err) {
|
|
2326
|
-
logError(err);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
};
|
|
2471
|
+
function vNodeAlreadyDeleted(chore) {
|
|
2472
|
+
return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
|
|
2473
|
+
}
|
|
2330
2474
|
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2475
|
+
function debugChoreTypeToString(type) {
|
|
2476
|
+
return {
|
|
2477
|
+
[ChoreType.QRL_RESOLVE]: "QRL_RESOLVE",
|
|
2478
|
+
[ChoreType.RUN_QRL]: "RUN_QRL",
|
|
2479
|
+
[ChoreType.TASK]: "TASK",
|
|
2480
|
+
[ChoreType.NODE_DIFF]: "NODE_DIFF",
|
|
2481
|
+
[ChoreType.NODE_PROP]: "NODE_PROP",
|
|
2482
|
+
[ChoreType.COMPONENT]: "COMPONENT",
|
|
2483
|
+
[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS]: "RECOMPUTE_SIGNAL",
|
|
2484
|
+
[ChoreType.JOURNAL_FLUSH]: "JOURNAL_FLUSH",
|
|
2485
|
+
[ChoreType.VISIBLE]: "VISIBLE",
|
|
2486
|
+
[ChoreType.CLEANUP_VISIBLE]: "CLEANUP_VISIBLE",
|
|
2487
|
+
[ChoreType.WAIT_FOR_ALL]: "WAIT_FOR_ALL"
|
|
2488
|
+
}[type] || "UNKNOWN: " + type;
|
|
2489
|
+
}
|
|
2334
2490
|
|
|
2335
|
-
|
|
2336
|
-
const
|
|
2337
|
-
const
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2491
|
+
function debugChoreToString(chore) {
|
|
2492
|
+
const type = debugChoreTypeToString(chore.$type$);
|
|
2493
|
+
const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
|
|
2494
|
+
const qrlTarget = chore.$target$?.$symbol$;
|
|
2495
|
+
return `Chore(${type} ${chore.$type$ === ChoreType.QRL_RESOLVE || chore.$type$ === ChoreType.RUN_QRL ? qrlTarget : host} ${chore.$idx$})`;
|
|
2496
|
+
}
|
|
2340
2497
|
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
$
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
$destroy$;
|
|
2348
|
-
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
2349
|
-
super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
|
|
2350
|
-
this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
2351
|
-
}
|
|
2498
|
+
function debugTrace(action, arg, currentChore, queue) {
|
|
2499
|
+
const lines = [ "===========================\nScheduler: " + action ];
|
|
2500
|
+
arg && !("$type$" in arg) && lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, "")),
|
|
2501
|
+
queue && queue.forEach((chore => {
|
|
2502
|
+
lines.push(` ${chore === arg ? ">>>" : " "} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore));
|
|
2503
|
+
})), console.log(lines.join("\n") + "\n");
|
|
2352
2504
|
}
|
|
2353
2505
|
|
|
2354
|
-
const
|
|
2506
|
+
const DEBUG = !1;
|
|
2355
2507
|
|
|
2356
|
-
const
|
|
2357
|
-
const [task] = useLexicalScope();
|
|
2358
|
-
getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
|
|
2359
|
-
};
|
|
2508
|
+
const log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
|
|
2360
2509
|
|
|
2361
|
-
|
|
2510
|
+
var SignalFlags;
|
|
2362
2511
|
|
|
2363
|
-
|
|
2512
|
+
var WrappedSignalFlags;
|
|
2364
2513
|
|
|
2365
|
-
|
|
2514
|
+
!function(SignalFlags) {
|
|
2515
|
+
SignalFlags[SignalFlags.INVALID = 1] = "INVALID";
|
|
2516
|
+
}(SignalFlags || (SignalFlags = {})), function(WrappedSignalFlags) {
|
|
2517
|
+
WrappedSignalFlags[WrappedSignalFlags.UNWRAP = 2] = "UNWRAP";
|
|
2518
|
+
}(WrappedSignalFlags || (WrappedSignalFlags = {}));
|
|
2366
2519
|
|
|
2367
2520
|
const throwIfQRLNotResolved = qrl => {
|
|
2368
2521
|
if (!qrl.resolved) {
|
|
@@ -2372,21 +2525,21 @@ const throwIfQRLNotResolved = qrl => {
|
|
|
2372
2525
|
|
|
2373
2526
|
const isSignal = value => value instanceof Signal;
|
|
2374
2527
|
|
|
2375
|
-
class
|
|
2528
|
+
class SubscriptionData {
|
|
2376
2529
|
data;
|
|
2377
2530
|
constructor(data) {
|
|
2378
2531
|
this.data = data;
|
|
2379
2532
|
}
|
|
2380
2533
|
}
|
|
2381
2534
|
|
|
2382
|
-
var
|
|
2535
|
+
var EffectSubscriptionProp;
|
|
2383
2536
|
|
|
2384
2537
|
var EffectProperty;
|
|
2385
2538
|
|
|
2386
|
-
!function(
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
}(
|
|
2539
|
+
!function(EffectSubscriptionProp) {
|
|
2540
|
+
EffectSubscriptionProp[EffectSubscriptionProp.CONSUMER = 0] = "CONSUMER", EffectSubscriptionProp[EffectSubscriptionProp.PROPERTY = 1] = "PROPERTY",
|
|
2541
|
+
EffectSubscriptionProp[EffectSubscriptionProp.BACK_REF = 2] = "BACK_REF", EffectSubscriptionProp[EffectSubscriptionProp.DATA = 3] = "DATA";
|
|
2542
|
+
}(EffectSubscriptionProp || (EffectSubscriptionProp = {})), function(EffectProperty) {
|
|
2390
2543
|
EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
|
|
2391
2544
|
}(EffectProperty || (EffectProperty = {}));
|
|
2392
2545
|
|
|
@@ -2416,9 +2569,9 @@ class Signal {
|
|
|
2416
2569
|
}
|
|
2417
2570
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
2418
2571
|
if (effectSubscriber) {
|
|
2419
|
-
const effects = this.$effects$ ||=
|
|
2420
|
-
|
|
2421
|
-
|
|
2572
|
+
const effects = this.$effects$ ||= new Set;
|
|
2573
|
+
ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this),
|
|
2574
|
+
addQrlToSerializationCtx(effectSubscriber, this.$container$);
|
|
2422
2575
|
}
|
|
2423
2576
|
}
|
|
2424
2577
|
return this.untrackedValue;
|
|
@@ -2430,7 +2583,7 @@ class Signal {
|
|
|
2430
2583
|
qDev;
|
|
2431
2584
|
}
|
|
2432
2585
|
toString() {
|
|
2433
|
-
return `[${this.constructor.name}${this.$
|
|
2586
|
+
return `[${this.constructor.name}${this.$flags$ & SignalFlags.INVALID ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
|
|
2434
2587
|
}
|
|
2435
2588
|
toJSON() {
|
|
2436
2589
|
return {
|
|
@@ -2439,100 +2592,77 @@ class Signal {
|
|
|
2439
2592
|
}
|
|
2440
2593
|
}
|
|
2441
2594
|
|
|
2442
|
-
const
|
|
2443
|
-
|
|
2444
|
-
};
|
|
2445
|
-
|
|
2446
|
-
const ensureContainsEffect = (array, effectSubscriptions) => {
|
|
2447
|
-
for (let i = 0; i < array.length; i++) {
|
|
2448
|
-
const existingEffect = array[i];
|
|
2449
|
-
if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
|
|
2450
|
-
return;
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
array.push(effectSubscriptions);
|
|
2595
|
+
const ensureContainsSubscription = (array, effectSubscription) => {
|
|
2596
|
+
array.add(effectSubscription);
|
|
2454
2597
|
};
|
|
2455
2598
|
|
|
2456
|
-
const
|
|
2457
|
-
|
|
2458
|
-
if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
|
|
2459
|
-
return;
|
|
2460
|
-
}
|
|
2461
|
-
effect.$effectDependencies$.push(subscriber);
|
|
2462
|
-
} else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
|
|
2463
|
-
let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
|
|
2464
|
-
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
2465
|
-
return;
|
|
2466
|
-
}
|
|
2467
|
-
subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
|
|
2468
|
-
} else if (isSSRNode(effect)) {
|
|
2469
|
-
let subscribers = effect.getProp("q:subs");
|
|
2470
|
-
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
2471
|
-
return;
|
|
2472
|
-
}
|
|
2473
|
-
subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
|
|
2474
|
-
}
|
|
2599
|
+
const ensureContainsBackRef = (array, value) => {
|
|
2600
|
+
array[EffectSubscriptionProp.BACK_REF] ||= new Set, array[EffectSubscriptionProp.BACK_REF].add(value);
|
|
2475
2601
|
};
|
|
2476
2602
|
|
|
2477
|
-
const
|
|
2478
|
-
|
|
2479
|
-
const
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2603
|
+
const addQrlToSerializationCtx = (effectSubscriber, container) => {
|
|
2604
|
+
if (container && !isDomContainer(container)) {
|
|
2605
|
+
const effect = effectSubscriber[EffectSubscriptionProp.CONSUMER];
|
|
2606
|
+
const property = effectSubscriber[EffectSubscriptionProp.PROPERTY];
|
|
2607
|
+
let qrl = null;
|
|
2608
|
+
isTask(effect) ? qrl = effect.$qrl$ : effect instanceof ComputedSignal ? qrl = effect.$computeQrl$ : property === EffectProperty.COMPONENT && (qrl = container.getHostProp(effect, "q:renderFn")),
|
|
2609
|
+
qrl && container.serializationCtx.$eventQrls$.add(qrl);
|
|
2484
2610
|
}
|
|
2485
|
-
return !1;
|
|
2486
2611
|
};
|
|
2487
2612
|
|
|
2488
2613
|
const triggerEffects = (container, signal, effects) => {
|
|
2614
|
+
const isBrowser = isDomContainer(container);
|
|
2489
2615
|
if (effects) {
|
|
2490
|
-
const scheduleEffect =
|
|
2491
|
-
const
|
|
2492
|
-
const property =
|
|
2493
|
-
if (assertDefined(container, "Container must be defined."), isTask(
|
|
2494
|
-
|
|
2616
|
+
const scheduleEffect = effectSubscription => {
|
|
2617
|
+
const consumer = effectSubscription[EffectSubscriptionProp.CONSUMER];
|
|
2618
|
+
const property = effectSubscription[EffectSubscriptionProp.PROPERTY];
|
|
2619
|
+
if (assertDefined(container, "Container must be defined."), isTask(consumer)) {
|
|
2620
|
+
consumer.$flags$ |= TaskFlags.DIRTY;
|
|
2495
2621
|
let choreType = ChoreType.TASK;
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
effect.$invalidate$();
|
|
2622
|
+
consumer.$flags$ & TaskFlags.VISIBLE_TASK && (choreType = ChoreType.VISIBLE), container.$scheduler$(choreType, consumer);
|
|
2623
|
+
} else if (consumer instanceof Signal) {
|
|
2624
|
+
consumer instanceof ComputedSignal && (consumer.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, consumer.$computeQrl$)),
|
|
2625
|
+
consumer.$invalidate$();
|
|
2501
2626
|
} else if (property === EffectProperty.COMPONENT) {
|
|
2502
|
-
const host =
|
|
2627
|
+
const host = consumer;
|
|
2503
2628
|
const qrl = container.getHostProp(host, "q:renderFn");
|
|
2504
2629
|
assertDefined(qrl, "Component must have QRL");
|
|
2505
2630
|
const props = container.getHostProp(host, "q:props");
|
|
2506
2631
|
container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
|
|
2507
|
-
} else if (
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2632
|
+
} else if (isBrowser) {
|
|
2633
|
+
if (property === EffectProperty.VNODE) {
|
|
2634
|
+
container.$scheduler$(ChoreType.NODE_DIFF, consumer, consumer, signal);
|
|
2635
|
+
} else {
|
|
2636
|
+
const effectData = effectSubscription[EffectSubscriptionProp.DATA];
|
|
2637
|
+
if (effectData instanceof SubscriptionData) {
|
|
2638
|
+
const payload = {
|
|
2639
|
+
...effectData.data,
|
|
2640
|
+
$value$: signal
|
|
2641
|
+
};
|
|
2642
|
+
container.$scheduler$(ChoreType.NODE_PROP, consumer, property, payload);
|
|
2643
|
+
}
|
|
2517
2644
|
}
|
|
2518
2645
|
}
|
|
2519
2646
|
};
|
|
2520
|
-
effects
|
|
2647
|
+
for (const effect of effects) {
|
|
2648
|
+
scheduleEffect(effect);
|
|
2649
|
+
}
|
|
2521
2650
|
}
|
|
2522
2651
|
};
|
|
2523
2652
|
|
|
2524
2653
|
class ComputedSignal extends Signal {
|
|
2525
2654
|
$computeQrl$;
|
|
2526
|
-
$
|
|
2655
|
+
$flags$;
|
|
2527
2656
|
$forceRunEffects$=!1;
|
|
2528
|
-
|
|
2529
|
-
|
|
2657
|
+
[_EFFECT_BACK_REF]=null;
|
|
2658
|
+
constructor(container, fn, flags = SignalFlags.INVALID) {
|
|
2659
|
+
super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
|
|
2530
2660
|
}
|
|
2531
2661
|
$invalidate$() {
|
|
2532
|
-
this.$
|
|
2662
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
|
|
2533
2663
|
}
|
|
2534
2664
|
force() {
|
|
2535
|
-
this.$
|
|
2665
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
|
|
2536
2666
|
}
|
|
2537
2667
|
get untrackedValue() {
|
|
2538
2668
|
const didChange = this.$computeIfNeeded$();
|
|
@@ -2540,20 +2670,20 @@ class ComputedSignal extends Signal {
|
|
|
2540
2670
|
this.$untrackedValue$;
|
|
2541
2671
|
}
|
|
2542
2672
|
$computeIfNeeded$() {
|
|
2543
|
-
if (!this.$
|
|
2673
|
+
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
2544
2674
|
return !1;
|
|
2545
2675
|
}
|
|
2546
2676
|
const computeQrl = this.$computeQrl$;
|
|
2547
2677
|
throwIfQRLNotResolved(computeQrl);
|
|
2548
2678
|
const ctx = tryGetInvokeContext();
|
|
2549
2679
|
const previousEffectSubscription = ctx?.$effectSubscriber$;
|
|
2550
|
-
ctx && (ctx.$effectSubscriber$ =
|
|
2680
|
+
ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
|
|
2551
2681
|
try {
|
|
2552
2682
|
const untrackedValue = computeQrl.getFn(ctx)();
|
|
2553
2683
|
if (isPromise(untrackedValue)) {
|
|
2554
2684
|
throw qError(QError.computedNotSync, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
|
|
2555
2685
|
}
|
|
2556
|
-
this.$
|
|
2686
|
+
this.$flags$ &= ~SignalFlags.INVALID;
|
|
2557
2687
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
2558
2688
|
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
2559
2689
|
} finally {
|
|
@@ -2572,18 +2702,19 @@ class WrappedSignal extends Signal {
|
|
|
2572
2702
|
$args$;
|
|
2573
2703
|
$func$;
|
|
2574
2704
|
$funcStr$;
|
|
2575
|
-
$
|
|
2576
|
-
$effectDependencies$=null;
|
|
2705
|
+
$flags$;
|
|
2577
2706
|
$hostElement$=null;
|
|
2578
2707
|
$forceRunEffects$=!1;
|
|
2579
|
-
|
|
2580
|
-
|
|
2708
|
+
[_EFFECT_BACK_REF]=null;
|
|
2709
|
+
constructor(container, fn, args, fnStr, flags = SignalFlags.INVALID | WrappedSignalFlags.UNWRAP) {
|
|
2710
|
+
super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
|
|
2711
|
+
this.$flags$ = flags;
|
|
2581
2712
|
}
|
|
2582
2713
|
$invalidate$() {
|
|
2583
|
-
this.$
|
|
2714
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
|
|
2584
2715
|
}
|
|
2585
2716
|
force() {
|
|
2586
|
-
this.$
|
|
2717
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
|
|
2587
2718
|
}
|
|
2588
2719
|
get untrackedValue() {
|
|
2589
2720
|
const didChange = this.$computeIfNeeded$();
|
|
@@ -2591,7 +2722,7 @@ class WrappedSignal extends Signal {
|
|
|
2591
2722
|
this.$untrackedValue$;
|
|
2592
2723
|
}
|
|
2593
2724
|
$computeIfNeeded$() {
|
|
2594
|
-
if (!this.$
|
|
2725
|
+
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
2595
2726
|
return !1;
|
|
2596
2727
|
}
|
|
2597
2728
|
const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, EffectProperty.VNODE, this.$container$);
|
|
@@ -2618,7 +2749,7 @@ const applyQwikComponentBody = (ssr, jsx, component) => {
|
|
|
2618
2749
|
srcProps && srcProps.children && delete srcProps.children;
|
|
2619
2750
|
const scheduler = ssr.$scheduler$;
|
|
2620
2751
|
return host.setProp("q:renderFn", componentQrl), host.setProp("q:props", srcProps),
|
|
2621
|
-
null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.
|
|
2752
|
+
null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.COMPONENT, host, componentQrl, srcProps);
|
|
2622
2753
|
};
|
|
2623
2754
|
|
|
2624
2755
|
class ParentComponentData {
|
|
@@ -2629,18 +2760,10 @@ class ParentComponentData {
|
|
|
2629
2760
|
}
|
|
2630
2761
|
}
|
|
2631
2762
|
|
|
2632
|
-
function _walkJSX(ssr, value, options) {
|
|
2763
|
+
async function _walkJSX(ssr, value, options) {
|
|
2633
2764
|
const stack = [ value ];
|
|
2634
|
-
let resolveDrain;
|
|
2635
|
-
let rejectDrain;
|
|
2636
|
-
const drained = options.allowPromises && new Promise(((res, rej) => {
|
|
2637
|
-
resolveDrain = res, rejectDrain = rej;
|
|
2638
|
-
}));
|
|
2639
2765
|
const enqueue = value => stack.push(value);
|
|
2640
|
-
|
|
2641
|
-
stack.push(value), drain();
|
|
2642
|
-
};
|
|
2643
|
-
const drain = () => {
|
|
2766
|
+
await (async () => {
|
|
2644
2767
|
for (;stack.length; ) {
|
|
2645
2768
|
const value = stack.pop();
|
|
2646
2769
|
if (value instanceof ParentComponentData) {
|
|
@@ -2652,23 +2775,13 @@ function _walkJSX(ssr, value, options) {
|
|
|
2652
2775
|
});
|
|
2653
2776
|
} else {
|
|
2654
2777
|
if (value === Promise) {
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
}
|
|
2658
|
-
return void stack.pop().then(resolveValue, rejectDrain);
|
|
2659
|
-
}
|
|
2660
|
-
const waitOn = value.apply(ssr);
|
|
2661
|
-
if (waitOn) {
|
|
2662
|
-
if (!options.allowPromises) {
|
|
2663
|
-
throw qError(QError.promisesNotExpected);
|
|
2664
|
-
}
|
|
2665
|
-
return void waitOn.then(drain, rejectDrain);
|
|
2778
|
+
stack.push(await stack.pop());
|
|
2779
|
+
continue;
|
|
2666
2780
|
}
|
|
2781
|
+
await value.apply(ssr);
|
|
2667
2782
|
}
|
|
2668
2783
|
}
|
|
2669
|
-
|
|
2670
|
-
};
|
|
2671
|
-
return drain(), drained;
|
|
2784
|
+
})();
|
|
2672
2785
|
}
|
|
2673
2786
|
|
|
2674
2787
|
function processJSXNode(ssr, enqueue, value, options) {
|
|
@@ -2696,7 +2809,6 @@ function processJSXNode(ssr, enqueue, value, options) {
|
|
|
2696
2809
|
enqueue((async () => {
|
|
2697
2810
|
for await (const chunk of value) {
|
|
2698
2811
|
await _walkJSX(ssr, chunk, {
|
|
2699
|
-
allowPromises: !0,
|
|
2700
2812
|
currentStyleScoped: options.styleScoped,
|
|
2701
2813
|
parentComponentFrame: options.parentComponentFrame
|
|
2702
2814
|
}), ssr.commentNode("qkssr-f");
|
|
@@ -2725,7 +2837,7 @@ function processJSXNode(ssr, enqueue, value, options) {
|
|
|
2725
2837
|
const componentFrame = options.parentComponentFrame || ssr.unclaimedProjectionComponentFrameQueue.shift();
|
|
2726
2838
|
if (componentFrame) {
|
|
2727
2839
|
const projectionAttrs = isDev ? [ "q:type", VirtualType.Projection ] : [];
|
|
2728
|
-
projectionAttrs.push(":", componentFrame.componentNode.id || ""), ssr.openProjection(projectionAttrs);
|
|
2840
|
+
projectionAttrs.push("q:sparent", componentFrame.componentNode.id || ""), ssr.openProjection(projectionAttrs);
|
|
2729
2841
|
const host = componentFrame.componentNode;
|
|
2730
2842
|
const node = ssr.getLastNode();
|
|
2731
2843
|
const slotName = getSlotName(host, jsx, ssr);
|
|
@@ -2747,7 +2859,6 @@ function processJSXNode(ssr, enqueue, value, options) {
|
|
|
2747
2859
|
value = isFunction(generator) ? generator({
|
|
2748
2860
|
async write(chunk) {
|
|
2749
2861
|
await _walkJSX(ssr, chunk, {
|
|
2750
|
-
allowPromises: !0,
|
|
2751
2862
|
currentStyleScoped: options.styleScoped,
|
|
2752
2863
|
parentComponentFrame: options.parentComponentFrame
|
|
2753
2864
|
}), ssr.commentNode("qkssr-f");
|
|
@@ -2835,18 +2946,20 @@ function setEvent(serializationCtx, key, rawValue) {
|
|
|
2835
2946
|
const appendToValue = valueToAppend => {
|
|
2836
2947
|
value = (null == value ? "" : value + "\n") + valueToAppend;
|
|
2837
2948
|
};
|
|
2949
|
+
const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", queueQRL, null, null, [ qrl ])),
|
|
2950
|
+
qrlToString(serializationCtx, qrl));
|
|
2838
2951
|
if (Array.isArray(qrls)) {
|
|
2839
2952
|
for (let i = 0; i <= qrls.length; i++) {
|
|
2840
2953
|
const qrl = qrls[i];
|
|
2841
|
-
if (isQrl(qrl)) {
|
|
2842
|
-
appendToValue(
|
|
2954
|
+
if (isQrl$1(qrl)) {
|
|
2955
|
+
appendToValue(getQrlString(qrl)), addQwikEventToSerializationContext(serializationCtx, key, qrl);
|
|
2843
2956
|
} else if (null != qrl) {
|
|
2844
2957
|
const nestedValue = setEvent(serializationCtx, key, qrl);
|
|
2845
2958
|
nestedValue && appendToValue(nestedValue);
|
|
2846
2959
|
}
|
|
2847
2960
|
}
|
|
2848
2961
|
} else {
|
|
2849
|
-
isQrl(qrls) && (value =
|
|
2962
|
+
isQrl$1(qrls) && (value = getQrlString(qrls), addQwikEventToSerializationContext(serializationCtx, key, qrls));
|
|
2850
2963
|
}
|
|
2851
2964
|
return value;
|
|
2852
2965
|
}
|
|
@@ -2881,7 +2994,7 @@ function appendClassIfScopedStyleExists(jsx, styleScoped) {
|
|
|
2881
2994
|
jsx.constProps.class = "");
|
|
2882
2995
|
}
|
|
2883
2996
|
|
|
2884
|
-
const version = "2.0.0-alpha.
|
|
2997
|
+
const version = "2.0.0-alpha.8-dev+66037b5";
|
|
2885
2998
|
|
|
2886
2999
|
class _SharedContainer {
|
|
2887
3000
|
$version$;
|
|
@@ -2906,12 +3019,6 @@ class _SharedContainer {
|
|
|
2906
3019
|
}
|
|
2907
3020
|
}
|
|
2908
3021
|
|
|
2909
|
-
const _CONST_PROPS = Symbol("CONST");
|
|
2910
|
-
|
|
2911
|
-
const _VAR_PROPS = Symbol("VAR");
|
|
2912
|
-
|
|
2913
|
-
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
2914
|
-
|
|
2915
3022
|
const getValueProp = p0 => p0.value;
|
|
2916
3023
|
|
|
2917
3024
|
const getProp = (p0, p1) => p0[p1];
|
|
@@ -2926,7 +3033,7 @@ const _wrapProp = (...args) => {
|
|
|
2926
3033
|
}
|
|
2927
3034
|
if (isSignal(obj)) {
|
|
2928
3035
|
return assertEqual(prop, "value", "Left side is a signal, prop must be value"),
|
|
2929
|
-
obj instanceof WrappedSignal ? obj : getWrapped(args);
|
|
3036
|
+
obj instanceof WrappedSignal && obj.flags & WrappedSignalFlags.UNWRAP ? obj : getWrapped(args);
|
|
2930
3037
|
}
|
|
2931
3038
|
if (isPropsProxy(obj)) {
|
|
2932
3039
|
const constProps = obj[_CONST_PROPS];
|
|
@@ -2943,6 +3050,11 @@ const _wrapProp = (...args) => {
|
|
|
2943
3050
|
return getWrapped(args);
|
|
2944
3051
|
};
|
|
2945
3052
|
|
|
3053
|
+
const _wrapStore = (obj, prop) => {
|
|
3054
|
+
const value = getStoreTarget(obj)[prop];
|
|
3055
|
+
return isSignal(value) ? value : new WrappedSignal(null, getProp, [ obj, prop ], null, SignalFlags.INVALID);
|
|
3056
|
+
};
|
|
3057
|
+
|
|
2946
3058
|
const _wrapSignal = (obj, prop) => {
|
|
2947
3059
|
const r = _wrapProp(obj, prop);
|
|
2948
3060
|
return r === _IMMUTABLE ? obj[prop] : r;
|
|
@@ -3071,7 +3183,7 @@ class PropsProxyHandler {
|
|
|
3071
3183
|
return this.$children$;
|
|
3072
3184
|
}
|
|
3073
3185
|
const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
|
|
3074
|
-
return value instanceof WrappedSignal ? value.value : value;
|
|
3186
|
+
return value instanceof WrappedSignal && value.$flags$ & WrappedSignalFlags.UNWRAP ? value.value : value;
|
|
3075
3187
|
}
|
|
3076
3188
|
set(_, prop, value) {
|
|
3077
3189
|
return prop === _CONST_PROPS ? (this.$constProps$ = value, !0) : prop === _VAR_PROPS ? (this.$varProps$ = value,
|
|
@@ -3128,7 +3240,7 @@ function qwikDebugToString(value) {
|
|
|
3128
3240
|
if (isTask(value)) {
|
|
3129
3241
|
return `Task(${qwikDebugToString(value.$qrl$)})`;
|
|
3130
3242
|
}
|
|
3131
|
-
if (isQrl
|
|
3243
|
+
if (isQrl(value)) {
|
|
3132
3244
|
return `Qrl(${value.$symbol$})`;
|
|
3133
3245
|
}
|
|
3134
3246
|
if ("object" == typeof value || "function" == typeof value) {
|
|
@@ -3222,8 +3334,8 @@ const VNodeDataChar = {
|
|
|
3222
3334
|
ID_CHAR: "=",
|
|
3223
3335
|
PROPS: 62,
|
|
3224
3336
|
PROPS_CHAR: ">",
|
|
3225
|
-
|
|
3226
|
-
|
|
3337
|
+
SLOT_PARENT: 63,
|
|
3338
|
+
SLOT_PARENT_CHAR: "?",
|
|
3227
3339
|
KEY: 64,
|
|
3228
3340
|
KEY_CHAR: "@",
|
|
3229
3341
|
SEQ: 91,
|
|
@@ -3234,14 +3346,21 @@ const VNodeDataChar = {
|
|
|
3234
3346
|
CONTEXT_CHAR: "]",
|
|
3235
3347
|
SEQ_IDX: 94,
|
|
3236
3348
|
SEQ_IDX_CHAR: "^",
|
|
3237
|
-
|
|
3238
|
-
|
|
3349
|
+
BACK_REFS: 96,
|
|
3350
|
+
BACK_REFS_CHAR: "`",
|
|
3239
3351
|
SEPARATOR: 124,
|
|
3240
3352
|
SEPARATOR_CHAR: "|",
|
|
3241
3353
|
SLOT: 126,
|
|
3242
3354
|
SLOT_CHAR: "~"
|
|
3243
3355
|
};
|
|
3244
3356
|
|
|
3357
|
+
const mergeMaps = (map1, map2) => {
|
|
3358
|
+
for (const [k, v] of map2) {
|
|
3359
|
+
map1.set(k, v);
|
|
3360
|
+
}
|
|
3361
|
+
return map1;
|
|
3362
|
+
};
|
|
3363
|
+
|
|
3245
3364
|
var VNodeJournalOpCode;
|
|
3246
3365
|
|
|
3247
3366
|
!function(VNodeJournalOpCode) {
|
|
@@ -3315,6 +3434,11 @@ const vnode_isVirtualVNode = vNode => {
|
|
|
3315
3434
|
return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual;
|
|
3316
3435
|
};
|
|
3317
3436
|
|
|
3437
|
+
const vnode_isProjection = vNode => {
|
|
3438
|
+
assertDefined(vNode, "Missing vNode");
|
|
3439
|
+
return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual && null !== vnode_getProp(vNode, QSlot, null);
|
|
3440
|
+
};
|
|
3441
|
+
|
|
3318
3442
|
const ensureTextVNode = vNode => (assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)),
|
|
3319
3443
|
vNode);
|
|
3320
3444
|
|
|
@@ -3347,6 +3471,7 @@ const vnode_ensureElementInflated = vnode => {
|
|
|
3347
3471
|
elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
|
|
3348
3472
|
const element = elementVNode[ElementVNodeProps.element];
|
|
3349
3473
|
const attributes = element.attributes;
|
|
3474
|
+
const props = vnode_getProps(elementVNode);
|
|
3350
3475
|
for (let idx = 0; idx < attributes.length; idx++) {
|
|
3351
3476
|
const attr = attributes[idx];
|
|
3352
3477
|
const key = attr.name;
|
|
@@ -3354,9 +3479,9 @@ const vnode_ensureElementInflated = vnode => {
|
|
|
3354
3479
|
break;
|
|
3355
3480
|
}
|
|
3356
3481
|
if (key.startsWith("q:container")) {
|
|
3357
|
-
attr.value === QContainerValue.HTML ? mapArray_set(
|
|
3482
|
+
attr.value === QContainerValue.HTML ? mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0) : attr.value === QContainerValue.TEXT && "value" in element && mapArray_set(props, "value", element.value, 0);
|
|
3358
3483
|
} else if (!key.startsWith("on:")) {
|
|
3359
|
-
mapArray_set(
|
|
3484
|
+
mapArray_set(props, key, attr.value, 0);
|
|
3360
3485
|
}
|
|
3361
3486
|
}
|
|
3362
3487
|
}
|
|
@@ -3594,7 +3719,7 @@ const vnode_applyJournal = journal => {
|
|
|
3594
3719
|
let key = journal[idx++];
|
|
3595
3720
|
"className" === key && (key = "class");
|
|
3596
3721
|
const value = journal[idx++];
|
|
3597
|
-
isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value =
|
|
3722
|
+
isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value = String(value) : key === dangerouslySetInnerHTML ? element.innerHTML = value : null == value || !1 === value ? element.removeAttribute(key) : element.setAttribute(key, String(value));
|
|
3598
3723
|
break;
|
|
3599
3724
|
|
|
3600
3725
|
case VNodeJournalOpCode.HoistStyles:
|
|
@@ -3626,33 +3751,9 @@ const vnode_applyJournal = journal => {
|
|
|
3626
3751
|
journal.length = 0;
|
|
3627
3752
|
};
|
|
3628
3753
|
|
|
3629
|
-
const mapApp_findIndx = (elementVNode, key, start) => {
|
|
3630
|
-
assertTrue(start % 2 == 0, "Expecting even number.");
|
|
3631
|
-
let bottom = start >> 1;
|
|
3632
|
-
let top = elementVNode.length - 2 >> 1;
|
|
3633
|
-
for (;bottom <= top; ) {
|
|
3634
|
-
const mid = bottom + (top - bottom >> 1);
|
|
3635
|
-
const midKey = elementVNode[mid << 1];
|
|
3636
|
-
if (midKey === key) {
|
|
3637
|
-
return mid << 1;
|
|
3638
|
-
}
|
|
3639
|
-
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
3640
|
-
}
|
|
3641
|
-
return ~(bottom << 1);
|
|
3642
|
-
};
|
|
3643
|
-
|
|
3644
|
-
const mapArray_set = (elementVNode, key, value, start) => {
|
|
3645
|
-
const indx = mapApp_findIndx(elementVNode, key, start);
|
|
3646
|
-
indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
|
|
3647
|
-
};
|
|
3648
|
-
|
|
3649
|
-
const mapArray_get = (elementVNode, key, start) => {
|
|
3650
|
-
const indx = mapApp_findIndx(elementVNode, key, start);
|
|
3651
|
-
return indx >= 0 ? elementVNode[indx + 1] : null;
|
|
3652
|
-
};
|
|
3653
|
-
|
|
3654
3754
|
const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
|
|
3655
|
-
ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent)
|
|
3755
|
+
ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent),
|
|
3756
|
+
newChild === insertBefore && (insertBefore = null);
|
|
3656
3757
|
let adjustedInsertBefore = null;
|
|
3657
3758
|
null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
|
|
3658
3759
|
adjustedInsertBefore && vnode_ensureInflatedIfText(journal, adjustedInsertBefore);
|
|
@@ -3711,9 +3812,12 @@ const vnode_truncate = (journal, vParent, vDelete) => {
|
|
|
3711
3812
|
const vnode_getElementName = vnode => {
|
|
3712
3813
|
const elementVNode = ensureElementVNode(vnode);
|
|
3713
3814
|
let elementName = elementVNode[ElementVNodeProps.elementName];
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3815
|
+
if (void 0 === elementName) {
|
|
3816
|
+
const element = elementVNode[ElementVNodeProps.element];
|
|
3817
|
+
const nodeName = isDev ? fastNodeName(element).toLowerCase() : fastNodeName(element);
|
|
3818
|
+
elementName = elementVNode[ElementVNodeProps.elementName] = nodeName, elementVNode[VNodeProps.flags] |= vnode_getElementNamespaceFlags(element);
|
|
3819
|
+
}
|
|
3820
|
+
return elementName;
|
|
3717
3821
|
};
|
|
3718
3822
|
|
|
3719
3823
|
const vnode_getText = vnode => {
|
|
@@ -3841,6 +3945,16 @@ const fastFirstChild = node => {
|
|
|
3841
3945
|
return node;
|
|
3842
3946
|
};
|
|
3843
3947
|
|
|
3948
|
+
let _fastNamespaceURI = null;
|
|
3949
|
+
|
|
3950
|
+
const fastNamespaceURI = element => (_fastNamespaceURI || (_fastNamespaceURI = fastGetter(element, "namespaceURI")),
|
|
3951
|
+
_fastNamespaceURI.call(element));
|
|
3952
|
+
|
|
3953
|
+
let _fastNodeName = null;
|
|
3954
|
+
|
|
3955
|
+
const fastNodeName = element => (_fastNodeName || (_fastNodeName = fastGetter(element, "nodeName")),
|
|
3956
|
+
_fastNodeName.call(element));
|
|
3957
|
+
|
|
3844
3958
|
const fastGetter = (prototype, name) => {
|
|
3845
3959
|
let getter;
|
|
3846
3960
|
for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
|
|
@@ -3880,13 +3994,25 @@ const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
|
3880
3994
|
const id = consumeValue();
|
|
3881
3995
|
container.$setRawState$(parseInt(id), vParent), isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
3882
3996
|
} else {
|
|
3883
|
-
peek() === VNodeDataChar.
|
|
3997
|
+
peek() === VNodeDataChar.BACK_REFS ? (container || (container = getDomContainer(vParent[ElementVNodeProps.element])),
|
|
3998
|
+
setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
|
|
3884
3999
|
}
|
|
3885
4000
|
}));
|
|
3886
4001
|
}
|
|
3887
4002
|
return vFirstChild;
|
|
3888
4003
|
};
|
|
3889
4004
|
|
|
4005
|
+
function setEffectBackRefFromVNodeData(vParent, value, container) {
|
|
4006
|
+
const deserializedSubMap = container.$getObjectById$(value);
|
|
4007
|
+
if (vParent[_EFFECT_BACK_REF]) {
|
|
4008
|
+
mergeMaps(vParent[_EFFECT_BACK_REF], deserializedSubMap);
|
|
4009
|
+
} else {
|
|
4010
|
+
Object.defineProperty(vParent, _EFFECT_BACK_REF, {
|
|
4011
|
+
value: deserializedSubMap
|
|
4012
|
+
});
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
|
|
3890
4016
|
const processVNodeData$1 = (vData, callback) => {
|
|
3891
4017
|
let nextToConsumeIdx = 0;
|
|
3892
4018
|
let ch = 0;
|
|
@@ -3914,8 +4040,9 @@ const vnode_getAttrKeys = vnode => {
|
|
|
3914
4040
|
if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3915
4041
|
vnode_ensureElementInflated(vnode);
|
|
3916
4042
|
const keys = [];
|
|
3917
|
-
|
|
3918
|
-
|
|
4043
|
+
const props = vnode_getProps(vnode);
|
|
4044
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
4045
|
+
const key = props[i];
|
|
3919
4046
|
key.startsWith(":") || keys.push(key);
|
|
3920
4047
|
}
|
|
3921
4048
|
return keys;
|
|
@@ -3927,29 +4054,37 @@ const vnode_setAttr = (journal, vnode, key, value) => {
|
|
|
3927
4054
|
const type = vnode[VNodeProps.flags];
|
|
3928
4055
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3929
4056
|
vnode_ensureElementInflated(vnode);
|
|
3930
|
-
const
|
|
4057
|
+
const props = vnode_getProps(vnode);
|
|
4058
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
3931
4059
|
if (idx >= 0) {
|
|
3932
|
-
if (
|
|
4060
|
+
if (props[idx + 1] != value && type & VNodeFlags.Element) {
|
|
3933
4061
|
journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
|
|
3934
4062
|
}
|
|
3935
|
-
null == value ?
|
|
3936
|
-
} else if (null != value && (
|
|
4063
|
+
null == value ? props.splice(idx, 2) : props[idx + 1] = value;
|
|
4064
|
+
} else if (null != value && (props.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
|
|
3937
4065
|
journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
|
|
3938
4066
|
}
|
|
3939
4067
|
}
|
|
3940
4068
|
};
|
|
3941
4069
|
|
|
3942
|
-
const vnode_getAttr = (vnode, key) =>
|
|
3943
|
-
|
|
4070
|
+
const vnode_getAttr = (vnode, key) => {
|
|
4071
|
+
if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
4072
|
+
vnode_ensureElementInflated(vnode);
|
|
4073
|
+
const props = vnode_getProps(vnode);
|
|
4074
|
+
return mapArray_get(props, key, 0);
|
|
4075
|
+
}
|
|
4076
|
+
return null;
|
|
4077
|
+
};
|
|
3944
4078
|
|
|
3945
4079
|
const vnode_getProp = (vnode, key, getObject) => {
|
|
3946
4080
|
const type = vnode[VNodeProps.flags];
|
|
3947
4081
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3948
4082
|
type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
|
|
3949
|
-
const
|
|
4083
|
+
const props = vnode_getProps(vnode);
|
|
4084
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
3950
4085
|
if (idx >= 0) {
|
|
3951
|
-
let value =
|
|
3952
|
-
return "string" == typeof value && getObject && (
|
|
4086
|
+
let value = props[idx + 1];
|
|
4087
|
+
return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)),
|
|
3953
4088
|
value;
|
|
3954
4089
|
}
|
|
3955
4090
|
}
|
|
@@ -3958,8 +4093,9 @@ const vnode_getProp = (vnode, key, getObject) => {
|
|
|
3958
4093
|
|
|
3959
4094
|
const vnode_setProp = (vnode, key, value) => {
|
|
3960
4095
|
ensureElementOrVirtualVNode(vnode);
|
|
3961
|
-
const
|
|
3962
|
-
|
|
4096
|
+
const props = vnode_getProps(vnode);
|
|
4097
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
4098
|
+
idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
|
|
3963
4099
|
};
|
|
3964
4100
|
|
|
3965
4101
|
const vnode_getPropStartIndex = vnode => {
|
|
@@ -3973,6 +4109,8 @@ const vnode_getPropStartIndex = vnode => {
|
|
|
3973
4109
|
throw qError(QError.invalidVNodeType, [ type ]);
|
|
3974
4110
|
};
|
|
3975
4111
|
|
|
4112
|
+
const vnode_getProps = vnode => vnode[vnode_getPropStartIndex(vnode)];
|
|
4113
|
+
|
|
3976
4114
|
const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
|
|
3977
4115
|
|
|
3978
4116
|
const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node."),
|
|
@@ -4085,16 +4223,16 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
4085
4223
|
container.$setRawState$(parseInt(id), vParent), isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
4086
4224
|
} else if (peek() === VNodeDataChar.PROPS) {
|
|
4087
4225
|
vnode_setAttr(null, vParent, "q:props", consumeValue());
|
|
4088
|
-
} else if (peek() === VNodeDataChar.SLOT_REF) {
|
|
4089
|
-
vnode_setAttr(null, vParent, "q:sref", consumeValue());
|
|
4090
4226
|
} else if (peek() === VNodeDataChar.KEY) {
|
|
4091
4227
|
vnode_setAttr(null, vParent, "q:key", consumeValue());
|
|
4092
4228
|
} else if (peek() === VNodeDataChar.SEQ) {
|
|
4093
4229
|
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
4094
4230
|
} else if (peek() === VNodeDataChar.SEQ_IDX) {
|
|
4095
4231
|
vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
|
|
4096
|
-
} else if (peek() === VNodeDataChar.
|
|
4097
|
-
|
|
4232
|
+
} else if (peek() === VNodeDataChar.BACK_REFS) {
|
|
4233
|
+
container || (container = getDomContainer(element)), setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
|
|
4234
|
+
} else if (peek() === VNodeDataChar.SLOT_PARENT) {
|
|
4235
|
+
vnode_setProp(vParent, "q:sparent", consumeValue());
|
|
4098
4236
|
} else if (peek() === VNodeDataChar.CONTEXT) {
|
|
4099
4237
|
vnode_setAttr(null, vParent, "q:ctx", consumeValue());
|
|
4100
4238
|
} else if (peek() === VNodeDataChar.OPEN) {
|
|
@@ -4144,7 +4282,7 @@ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
|
|
|
4144
4282
|
let projectionDepth = 1;
|
|
4145
4283
|
for (;projectionDepth--; ) {
|
|
4146
4284
|
for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
|
|
4147
|
-
const qSlotParent = vnode_getProp(vHost, ":", (id => vnode_locate(rootVNode, id)));
|
|
4285
|
+
const qSlotParent = vnode_getProp(vHost, "q:sparent", (id => vnode_locate(rootVNode, id)));
|
|
4148
4286
|
const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
|
|
4149
4287
|
vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
|
|
4150
4288
|
}
|
|
@@ -4155,19 +4293,16 @@ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
|
|
|
4155
4293
|
|
|
4156
4294
|
const VNodeArray = class VNode extends Array {
|
|
4157
4295
|
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
4158
|
-
|
|
4159
|
-
return vnode.push(firstChild, lastChild, element, elementName), vnode;
|
|
4296
|
+
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
|
|
4160
4297
|
}
|
|
4161
4298
|
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
4162
|
-
|
|
4163
|
-
return vnode.push(textNode, text), vnode;
|
|
4299
|
+
return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
|
|
4164
4300
|
}
|
|
4165
4301
|
static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
|
|
4166
|
-
|
|
4167
|
-
return vnode.push(firstChild, lastChild), vnode;
|
|
4302
|
+
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
|
|
4168
4303
|
}
|
|
4169
|
-
constructor(flags, parent, previousSibling, nextSibling) {
|
|
4170
|
-
super(
|
|
4304
|
+
constructor(flags, parent, previousSibling, nextSibling, ...rest) {
|
|
4305
|
+
super(flags, parent, previousSibling, nextSibling, ...rest), isDev && (this.toString = vnode_toString);
|
|
4171
4306
|
}
|
|
4172
4307
|
};
|
|
4173
4308
|
|
|
@@ -4228,9 +4363,11 @@ function invokeApply(context, fn, args) {
|
|
|
4228
4363
|
}
|
|
4229
4364
|
|
|
4230
4365
|
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
4231
|
-
const
|
|
4366
|
+
const domContainer = getDomContainer(element);
|
|
4367
|
+
const container = domContainer.element;
|
|
4368
|
+
const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
|
|
4232
4369
|
const locale = container?.getAttribute("q:locale") || void 0;
|
|
4233
|
-
return locale && setLocale(locale), newInvokeContext(locale,
|
|
4370
|
+
return locale && setLocale(locale), newInvokeContext(locale, vNode, element, event, url);
|
|
4234
4371
|
};
|
|
4235
4372
|
|
|
4236
4373
|
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
@@ -4256,7 +4393,7 @@ const trackSignal = (fn, subscriber, property, container, data) => {
|
|
|
4256
4393
|
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
4257
4394
|
const previousContainer = trackInvocation.$container$;
|
|
4258
4395
|
try {
|
|
4259
|
-
return trackInvocation.$effectSubscriber$ =
|
|
4396
|
+
return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data),
|
|
4260
4397
|
trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
4261
4398
|
} finally {
|
|
4262
4399
|
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
@@ -4271,7 +4408,7 @@ const _getContextElement = () => {
|
|
|
4271
4408
|
if (iCtx) {
|
|
4272
4409
|
const hostElement = iCtx.$hostElement$;
|
|
4273
4410
|
let element = null;
|
|
4274
|
-
return vnode_isVNode(hostElement)
|
|
4411
|
+
return null != hostElement && (vnode_isVNode(hostElement) ? vnode_isElementVNode(hostElement) && (element = vnode_getNode(hostElement)) : element = hostElement),
|
|
4275
4412
|
element ?? iCtx.$qrl$?.$setContainer$(void 0);
|
|
4276
4413
|
}
|
|
4277
4414
|
};
|
|
@@ -4552,9 +4689,9 @@ class DomContainer extends _SharedContainer {
|
|
|
4552
4689
|
$storeProxyMap$=new WeakMap;
|
|
4553
4690
|
$qFuncs$;
|
|
4554
4691
|
$instanceHash$;
|
|
4555
|
-
|
|
4692
|
+
vNodeLocate=id => vnode_locate(this.rootVNode, id);
|
|
4693
|
+
$stateData$;
|
|
4556
4694
|
$styleIds$=null;
|
|
4557
|
-
$vnodeLocate$=id => vnode_locate(this.rootVNode, id);
|
|
4558
4695
|
$renderCount$=0;
|
|
4559
4696
|
constructor(element) {
|
|
4560
4697
|
if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
|
|
@@ -4564,24 +4701,24 @@ class DomContainer extends _SharedContainer {
|
|
|
4564
4701
|
this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
|
|
4565
4702
|
this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
|
|
4566
4703
|
this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
|
|
4567
|
-
this.$rawStateData$ = null, this
|
|
4704
|
+
this.$rawStateData$ = null, this.$stateData$ = null;
|
|
4568
4705
|
const document = this.element.ownerDocument;
|
|
4569
|
-
document.qVNodeData || processVNodeData(document), this.$rawStateData$ = [], this
|
|
4706
|
+
document.qVNodeData || processVNodeData(document), this.$rawStateData$ = [], this.$stateData$ = [];
|
|
4570
4707
|
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
4571
4708
|
if (0 !== qwikStates.length) {
|
|
4572
4709
|
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
|
|
4573
|
-
this
|
|
4710
|
+
this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
|
|
4574
4711
|
}
|
|
4575
4712
|
this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
|
|
4576
4713
|
}
|
|
4577
4714
|
$setRawState$(id, vParent) {
|
|
4578
|
-
this
|
|
4715
|
+
this.$stateData$[id] = vParent;
|
|
4579
4716
|
}
|
|
4580
4717
|
parseQRL(qrl) {
|
|
4581
4718
|
return inflateQRL(this, parseQRL(qrl));
|
|
4582
4719
|
}
|
|
4583
4720
|
handleError(err, host) {
|
|
4584
|
-
const errorStore = this.resolveContext(host, ERROR_CONTEXT);
|
|
4721
|
+
const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
|
|
4585
4722
|
if (!errorStore) {
|
|
4586
4723
|
throw err;
|
|
4587
4724
|
}
|
|
@@ -4610,7 +4747,7 @@ class DomContainer extends _SharedContainer {
|
|
|
4610
4747
|
if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
|
|
4611
4748
|
return vNode;
|
|
4612
4749
|
}
|
|
4613
|
-
vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this
|
|
4750
|
+
vNode = vnode_getParent(vNode) || vnode_getProp(vNode, "q:sparent", this.vNodeLocate);
|
|
4614
4751
|
} else {
|
|
4615
4752
|
vNode = vnode_getParent(vNode);
|
|
4616
4753
|
}
|
|
@@ -4628,7 +4765,7 @@ class DomContainer extends _SharedContainer {
|
|
|
4628
4765
|
case "q:props":
|
|
4629
4766
|
case "q:renderFn":
|
|
4630
4767
|
case "q:ctx":
|
|
4631
|
-
case "q:
|
|
4768
|
+
case "q:brefs":
|
|
4632
4769
|
getObjectById = this.$getObjectById$;
|
|
4633
4770
|
break;
|
|
4634
4771
|
|
|
@@ -4640,7 +4777,10 @@ class DomContainer extends _SharedContainer {
|
|
|
4640
4777
|
}
|
|
4641
4778
|
scheduleRender() {
|
|
4642
4779
|
return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
|
|
4643
|
-
this.renderDone
|
|
4780
|
+
this.renderDone.finally((() => emitEvent("qrender", {
|
|
4781
|
+
instanceHash: this.$instanceHash$,
|
|
4782
|
+
renderCount: this.$renderCount$
|
|
4783
|
+
})));
|
|
4644
4784
|
}
|
|
4645
4785
|
processChores() {
|
|
4646
4786
|
let renderCount = this.$renderCount$;
|
|
@@ -4658,16 +4798,17 @@ class DomContainer extends _SharedContainer {
|
|
|
4658
4798
|
ensureProjectionResolved(vNode) {
|
|
4659
4799
|
if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
|
|
4660
4800
|
vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4801
|
+
const props = vnode_getProps(vNode);
|
|
4802
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
4803
|
+
if (isSlotProp(props[i])) {
|
|
4804
|
+
const value = props[i + 1];
|
|
4805
|
+
"string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
|
|
4665
4806
|
}
|
|
4666
4807
|
}
|
|
4667
4808
|
}
|
|
4668
4809
|
}
|
|
4669
4810
|
$getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`),
|
|
4670
|
-
this
|
|
4811
|
+
this.$stateData$[id]);
|
|
4671
4812
|
getSyncFn(id) {
|
|
4672
4813
|
const fn = this.$qFuncs$[id];
|
|
4673
4814
|
return assertTrue("function" == typeof fn, "Invalid reference: " + id), fn;
|
|
@@ -4799,7 +4940,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4799
4940
|
const task = target;
|
|
4800
4941
|
const v = data;
|
|
4801
4942
|
task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
|
|
4802
|
-
task.$el$ = v[3], task
|
|
4943
|
+
task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
|
|
4803
4944
|
break;
|
|
4804
4945
|
|
|
4805
4946
|
case TypeIds.Resource:
|
|
@@ -4817,11 +4958,9 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4817
4958
|
case TypeIds.Store:
|
|
4818
4959
|
case TypeIds.StoreArray:
|
|
4819
4960
|
{
|
|
4820
|
-
const [value, flags, effects
|
|
4961
|
+
const [value, flags, effects] = data;
|
|
4821
4962
|
const store = getOrCreateStore(value, flags, container);
|
|
4822
|
-
|
|
4823
|
-
storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect), storeHandler.$effects$ = effects,
|
|
4824
|
-
target = store;
|
|
4963
|
+
getStoreHandler(store).$effects$ = effects, target = store;
|
|
4825
4964
|
break;
|
|
4826
4965
|
}
|
|
4827
4966
|
|
|
@@ -4829,7 +4968,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4829
4968
|
{
|
|
4830
4969
|
const signal = target;
|
|
4831
4970
|
const d = data;
|
|
4832
|
-
signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
|
|
4971
|
+
signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
|
|
4833
4972
|
break;
|
|
4834
4973
|
}
|
|
4835
4974
|
|
|
@@ -4837,8 +4976,9 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4837
4976
|
{
|
|
4838
4977
|
const signal = target;
|
|
4839
4978
|
const d = data;
|
|
4840
|
-
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal
|
|
4841
|
-
signal.$untrackedValue$ = d[3], signal.$
|
|
4979
|
+
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
|
|
4980
|
+
signal.$untrackedValue$ = d[3], signal.$flags$ = d[4], signal.$hostElement$ = d[5],
|
|
4981
|
+
signal.$effects$ = new Set(d.slice(6));
|
|
4842
4982
|
break;
|
|
4843
4983
|
}
|
|
4844
4984
|
|
|
@@ -4846,7 +4986,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4846
4986
|
{
|
|
4847
4987
|
const computed = target;
|
|
4848
4988
|
const d = data;
|
|
4849
|
-
computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$
|
|
4989
|
+
computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$flags$ |= SignalFlags.INVALID,
|
|
4850
4990
|
computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
|
|
4851
4991
|
break;
|
|
4852
4992
|
}
|
|
@@ -4942,7 +5082,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4942
5082
|
return target;
|
|
4943
5083
|
};
|
|
4944
5084
|
|
|
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 ];
|
|
5085
|
+
const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
|
|
4946
5086
|
|
|
4947
5087
|
const allocate = (container, typeId, value) => {
|
|
4948
5088
|
if (void 0 === value) {
|
|
@@ -5032,7 +5172,7 @@ const allocate = (container, typeId, value) => {
|
|
|
5032
5172
|
const promise = new Promise(((res, rej) => {
|
|
5033
5173
|
resolve = res, reject = rej;
|
|
5034
5174
|
}));
|
|
5035
|
-
return resolvers.set(promise, [ resolve, reject ]), promise;
|
|
5175
|
+
return resolvers.set(promise, [ resolve, reject ]), promise.catch((() => {})), promise;
|
|
5036
5176
|
|
|
5037
5177
|
case TypeIds.Uint8Array:
|
|
5038
5178
|
const encodedLength = value.length;
|
|
@@ -5042,12 +5182,10 @@ const allocate = (container, typeId, value) => {
|
|
|
5042
5182
|
case TypeIds.PropsProxy:
|
|
5043
5183
|
return createPropsProxy(null, null);
|
|
5044
5184
|
|
|
5045
|
-
case TypeIds.RefVNode:
|
|
5046
5185
|
case TypeIds.VNode:
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
}
|
|
5186
|
+
return retrieveVNodeOrDocument(container, value);
|
|
5187
|
+
|
|
5188
|
+
case TypeIds.RefVNode:
|
|
5051
5189
|
const vNode = retrieveVNodeOrDocument(container, value);
|
|
5052
5190
|
if (vnode_isVNode(vNode)) {
|
|
5053
5191
|
return vnode_getNode(vNode);
|
|
@@ -5055,7 +5193,7 @@ const allocate = (container, typeId, value) => {
|
|
|
5055
5193
|
throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
|
|
5056
5194
|
|
|
5057
5195
|
case TypeIds.EffectData:
|
|
5058
|
-
return new
|
|
5196
|
+
return new SubscriptionData({});
|
|
5059
5197
|
|
|
5060
5198
|
default:
|
|
5061
5199
|
throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
|
|
@@ -5078,7 +5216,7 @@ function parseQRL(qrl) {
|
|
|
5078
5216
|
const backChannel = globalThis[QRL_RUNTIME_CHUNK];
|
|
5079
5217
|
assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK"), qrlRef = backChannel.get(symbol);
|
|
5080
5218
|
}
|
|
5081
|
-
return createQRL(chunk, symbol, qrlRef, null, captureIds, null
|
|
5219
|
+
return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
|
|
5082
5220
|
}
|
|
5083
5221
|
|
|
5084
5222
|
function inflateQRL(container, qrl) {
|
|
@@ -5156,18 +5294,18 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5156
5294
|
const promises = [];
|
|
5157
5295
|
const visit = obj => {
|
|
5158
5296
|
if ("function" == typeof obj) {
|
|
5159
|
-
if (isQrl(obj)) {
|
|
5297
|
+
if (isQrl$1(obj)) {
|
|
5160
5298
|
obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
|
|
5161
5299
|
} else if (isQwikComponent(obj)) {
|
|
5162
5300
|
const [qrl] = obj[SERIALIZABLE_STATE];
|
|
5163
5301
|
discoveredValues.push(qrl);
|
|
5164
5302
|
}
|
|
5165
|
-
} else if ("object" != typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || "undefined" != typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) {} else if (obj instanceof Error) {
|
|
5303
|
+
} else if ("object" != typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || "undefined" != typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) {} else if (obj instanceof Error) {
|
|
5166
5304
|
discoveredValues.push(...Object.values(obj));
|
|
5167
5305
|
} else if (isStore(obj)) {
|
|
5168
5306
|
const target = getStoreTarget(obj);
|
|
5169
5307
|
const effects = getStoreHandler(obj).$effects$;
|
|
5170
|
-
discoveredValues.push(target, effects
|
|
5308
|
+
discoveredValues.push(target, effects);
|
|
5171
5309
|
for (const prop in target) {
|
|
5172
5310
|
const propValue = target[prop];
|
|
5173
5311
|
storeProxyMap.has(propValue) && discoveredValues.push(prop, storeProxyMap.get(propValue));
|
|
@@ -5179,12 +5317,13 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5179
5317
|
discoveredValues.push(k, v);
|
|
5180
5318
|
}));
|
|
5181
5319
|
} else if (obj instanceof Signal) {
|
|
5182
|
-
const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$
|
|
5183
|
-
v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(
|
|
5184
|
-
obj instanceof WrappedSignal ? (obj
|
|
5185
|
-
obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal &&
|
|
5320
|
+
const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$flags$ & SignalFlags.INVALID || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
|
|
5321
|
+
v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(obj.$effects$),
|
|
5322
|
+
obj instanceof WrappedSignal ? (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues),
|
|
5323
|
+
obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues),
|
|
5324
|
+
discoveredValues.push(obj.$computeQrl$));
|
|
5186
5325
|
} else if (obj instanceof Task) {
|
|
5187
|
-
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state
|
|
5326
|
+
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$), discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
|
|
5188
5327
|
} else if (isSsrNode(obj)) {
|
|
5189
5328
|
if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
|
|
5190
5329
|
for (const data of obj.childrenVNodeData) {
|
|
@@ -5197,7 +5336,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5197
5336
|
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
5198
5337
|
} else if (Array.isArray(obj)) {
|
|
5199
5338
|
discoveredValues.push(...obj);
|
|
5200
|
-
} else if (isQrl(obj)) {
|
|
5339
|
+
} else if (isQrl$1(obj)) {
|
|
5201
5340
|
obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
|
|
5202
5341
|
} else if (isPropsProxy(obj)) {
|
|
5203
5342
|
discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
|
|
@@ -5207,7 +5346,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5207
5346
|
}), (error => {
|
|
5208
5347
|
promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
|
|
5209
5348
|
})), promises.push(obj);
|
|
5210
|
-
} else if (obj instanceof
|
|
5349
|
+
} else if (obj instanceof SubscriptionData) {
|
|
5211
5350
|
discoveredValues.push(obj.data);
|
|
5212
5351
|
} else {
|
|
5213
5352
|
if (!isObjectLiteral(obj)) {
|
|
@@ -5250,15 +5389,17 @@ const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
|
|
|
5250
5389
|
for (const value of vnodeData) {
|
|
5251
5390
|
if (isSsrAttrs(value)) {
|
|
5252
5391
|
for (let i = 1; i < value.length; i += 2) {
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
}
|
|
5256
|
-
discoveredValues.push(value[i]);
|
|
5392
|
+
const attrValue = value[i];
|
|
5393
|
+
"string" != typeof attrValue && discoveredValues.push(attrValue);
|
|
5257
5394
|
}
|
|
5258
5395
|
}
|
|
5259
5396
|
}
|
|
5260
5397
|
};
|
|
5261
5398
|
|
|
5399
|
+
const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
|
|
5400
|
+
effectsBackRefs && discoveredValues.push(effectsBackRefs);
|
|
5401
|
+
};
|
|
5402
|
+
|
|
5262
5403
|
const promiseResults = new WeakMap;
|
|
5263
5404
|
|
|
5264
5405
|
function serialize(serializationContext) {
|
|
@@ -5297,7 +5438,7 @@ function serialize(serializationContext) {
|
|
|
5297
5438
|
output(TypeIds.Constant, Constants.Slot);
|
|
5298
5439
|
} else if (value === Fragment) {
|
|
5299
5440
|
output(TypeIds.Constant, Constants.Fragment);
|
|
5300
|
-
} else if (isQrl(value)) {
|
|
5441
|
+
} else if (isQrl$1(value)) {
|
|
5301
5442
|
const qrl = qrlToString(serializationContext, value);
|
|
5302
5443
|
const id = serializationContext.$addRoot$(qrl);
|
|
5303
5444
|
output(TypeIds.QRL, id);
|
|
@@ -5323,11 +5464,13 @@ function serialize(serializationContext) {
|
|
|
5323
5464
|
}
|
|
5324
5465
|
} else if (void 0 === value) {
|
|
5325
5466
|
output(TypeIds.Constant, Constants.Undefined);
|
|
5467
|
+
} else if (value === NEEDS_COMPUTATION) {
|
|
5468
|
+
output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
|
|
5326
5469
|
} else {
|
|
5327
|
-
if (value !==
|
|
5470
|
+
if (value !== STORE_ALL_PROPS) {
|
|
5328
5471
|
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
5329
5472
|
}
|
|
5330
|
-
output(TypeIds.Constant, Constants.
|
|
5473
|
+
output(TypeIds.Constant, Constants.STORE_ALL_PROPS);
|
|
5331
5474
|
}
|
|
5332
5475
|
};
|
|
5333
5476
|
const writeObjectValue = (value, idx) => {
|
|
@@ -5343,7 +5486,7 @@ function serialize(serializationContext) {
|
|
|
5343
5486
|
const constProps = value[_CONST_PROPS];
|
|
5344
5487
|
const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
|
|
5345
5488
|
output(TypeIds.PropsProxy, out);
|
|
5346
|
-
} else if (value instanceof
|
|
5489
|
+
} else if (value instanceof SubscriptionData) {
|
|
5347
5490
|
output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
|
|
5348
5491
|
} else if (isStore(value)) {
|
|
5349
5492
|
if (isResource(value)) {
|
|
@@ -5358,7 +5501,6 @@ function serialize(serializationContext) {
|
|
|
5358
5501
|
const storeTarget = getStoreTarget(value);
|
|
5359
5502
|
const flags = storeHandler.$flags$;
|
|
5360
5503
|
const effects = storeHandler.$effects$;
|
|
5361
|
-
const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
|
|
5362
5504
|
const innerStores = [];
|
|
5363
5505
|
for (const prop in storeTarget) {
|
|
5364
5506
|
const propValue = storeTarget[prop];
|
|
@@ -5367,7 +5509,7 @@ function serialize(serializationContext) {
|
|
|
5367
5509
|
innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
|
|
5368
5510
|
}
|
|
5369
5511
|
}
|
|
5370
|
-
const out = [ storeTarget, flags, effects,
|
|
5512
|
+
const out = [ storeTarget, flags, effects, ...innerStores ];
|
|
5371
5513
|
for (;null == out[out.length - 1]; ) {
|
|
5372
5514
|
out.pop();
|
|
5373
5515
|
}
|
|
@@ -5386,9 +5528,9 @@ function serialize(serializationContext) {
|
|
|
5386
5528
|
} else if ($isDomRef$(value)) {
|
|
5387
5529
|
value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE, output(TypeIds.RefVNode, value.$ssrNode$.id);
|
|
5388
5530
|
} else if (value instanceof Signal) {
|
|
5389
|
-
const v = value instanceof ComputedSignal && (value.$
|
|
5531
|
+
const v = value instanceof ComputedSignal && (value.$flags$ & SignalFlags.INVALID || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
5390
5532
|
if (value instanceof WrappedSignal) {
|
|
5391
|
-
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value
|
|
5533
|
+
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), v, value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
|
|
5392
5534
|
} else if (value instanceof ComputedSignal) {
|
|
5393
5535
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
5394
5536
|
v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
|
|
@@ -5436,7 +5578,7 @@ function serialize(serializationContext) {
|
|
|
5436
5578
|
} else if (isJSXNode(value)) {
|
|
5437
5579
|
output(TypeIds.JSXNode, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
|
|
5438
5580
|
} else if (value instanceof Task) {
|
|
5439
|
-
const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value
|
|
5581
|
+
const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
|
|
5440
5582
|
for (;null == out[out.length - 1]; ) {
|
|
5441
5583
|
out.pop();
|
|
5442
5584
|
}
|
|
@@ -5447,23 +5589,34 @@ function serialize(serializationContext) {
|
|
|
5447
5589
|
throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
|
|
5448
5590
|
}
|
|
5449
5591
|
output(TypeIds.Promise, res);
|
|
5592
|
+
} else if (value instanceof Uint8Array) {
|
|
5593
|
+
let buf = "";
|
|
5594
|
+
for (const c of value) {
|
|
5595
|
+
buf += String.fromCharCode(c);
|
|
5596
|
+
}
|
|
5597
|
+
const out = btoa(buf).replace(/=+$/, "");
|
|
5598
|
+
output(TypeIds.Uint8Array, out);
|
|
5450
5599
|
} else {
|
|
5451
|
-
if (!(value
|
|
5600
|
+
if (!vnode_isVNode(value)) {
|
|
5452
5601
|
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
5453
5602
|
}
|
|
5454
|
-
|
|
5455
|
-
let buf = "";
|
|
5456
|
-
for (const c of value) {
|
|
5457
|
-
buf += String.fromCharCode(c);
|
|
5458
|
-
}
|
|
5459
|
-
const out = btoa(buf).replace(/=+$/, "");
|
|
5460
|
-
output(TypeIds.Uint8Array, out);
|
|
5461
|
-
}
|
|
5603
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
5462
5604
|
}
|
|
5463
5605
|
};
|
|
5464
5606
|
writeValue(serializationContext.$roots$, -1);
|
|
5465
5607
|
}
|
|
5466
5608
|
|
|
5609
|
+
function filterEffectBackRefs(effectBackRef) {
|
|
5610
|
+
let effectBackRefToSerialize = null;
|
|
5611
|
+
if (effectBackRef) {
|
|
5612
|
+
for (const [effectProp, effect] of effectBackRef) {
|
|
5613
|
+
effect[EffectSubscriptionProp.BACK_REF] && (effectBackRefToSerialize ||= new Map,
|
|
5614
|
+
effectBackRefToSerialize.set(effectProp, effect));
|
|
5615
|
+
}
|
|
5616
|
+
}
|
|
5617
|
+
return effectBackRefToSerialize;
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5467
5620
|
function serializeWrappingFn(serializationContext, value) {
|
|
5468
5621
|
value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
|
|
5469
5622
|
return [ serializationContext.$addSyncFn$(value.$funcStr$, value.$args$.length, value.$func$), value.$args$ ];
|
|
@@ -5472,11 +5625,10 @@ function serializeWrappingFn(serializationContext, value) {
|
|
|
5472
5625
|
function qrlToString(serializationContext, value) {
|
|
5473
5626
|
let symbol = value.$symbol$;
|
|
5474
5627
|
let chunk = value.$chunk$;
|
|
5475
|
-
const refSymbol = value.$refSymbol$ ?? symbol;
|
|
5476
5628
|
const platform = getPlatform();
|
|
5477
5629
|
if (platform) {
|
|
5478
|
-
const result = platform.chunkForSymbol(
|
|
5479
|
-
result && (chunk = result[1],
|
|
5630
|
+
const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
|
|
5631
|
+
result && (chunk = result[1], symbol = result[0]);
|
|
5480
5632
|
}
|
|
5481
5633
|
if (isSyncQrl(value)) {
|
|
5482
5634
|
chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
|
|
@@ -5570,17 +5722,21 @@ function isResource(value) {
|
|
|
5570
5722
|
return "__brand" in value && "resource" === value.__brand;
|
|
5571
5723
|
}
|
|
5572
5724
|
|
|
5573
|
-
const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
|
|
5725
|
+
const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl$1(obj);
|
|
5574
5726
|
|
|
5575
|
-
const canSerialize = value => {
|
|
5727
|
+
const canSerialize = (value, seen = new WeakSet) => {
|
|
5576
5728
|
if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
|
|
5577
5729
|
return !0;
|
|
5578
5730
|
}
|
|
5579
5731
|
if ("object" == typeof value) {
|
|
5732
|
+
if (seen.has(value)) {
|
|
5733
|
+
return !0;
|
|
5734
|
+
}
|
|
5735
|
+
seen.add(value);
|
|
5580
5736
|
const proto = Object.getPrototypeOf(value);
|
|
5581
5737
|
if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
|
|
5582
5738
|
for (const key in value) {
|
|
5583
|
-
if (!canSerialize(untrack((() => value[key])))) {
|
|
5739
|
+
if (!canSerialize(untrack((() => value[key])), seen)) {
|
|
5584
5740
|
return !1;
|
|
5585
5741
|
}
|
|
5586
5742
|
}
|
|
@@ -5588,7 +5744,7 @@ const canSerialize = value => {
|
|
|
5588
5744
|
}
|
|
5589
5745
|
if (proto == Array.prototype) {
|
|
5590
5746
|
for (let i = 0; i < value.length; i++) {
|
|
5591
|
-
if (!canSerialize(value[i])) {
|
|
5747
|
+
if (!canSerialize(value[i], seen)) {
|
|
5592
5748
|
return !1;
|
|
5593
5749
|
}
|
|
5594
5750
|
}
|
|
@@ -5636,7 +5792,7 @@ const canSerialize = value => {
|
|
|
5636
5792
|
if (isDomRef?.(value)) {
|
|
5637
5793
|
return !0;
|
|
5638
5794
|
}
|
|
5639
|
-
} else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
|
|
5795
|
+
} else if ("function" == typeof value && (isQrl$1(value) || isQwikComponent(value))) {
|
|
5640
5796
|
return !0;
|
|
5641
5797
|
}
|
|
5642
5798
|
return !1;
|
|
@@ -5668,14 +5824,15 @@ var Constants;
|
|
|
5668
5824
|
Constants[Constants.True = 2] = "True", Constants[Constants.False = 3] = "False",
|
|
5669
5825
|
Constants[Constants.EmptyString = 4] = "EmptyString", Constants[Constants.EMPTY_ARRAY = 5] = "EMPTY_ARRAY",
|
|
5670
5826
|
Constants[Constants.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants[Constants.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION",
|
|
5671
|
-
Constants[Constants.
|
|
5672
|
-
Constants[Constants.
|
|
5673
|
-
Constants[Constants.
|
|
5674
|
-
Constants[Constants.
|
|
5827
|
+
Constants[Constants.STORE_ALL_PROPS = 8] = "STORE_ALL_PROPS", Constants[Constants.Slot = 9] = "Slot",
|
|
5828
|
+
Constants[Constants.Fragment = 10] = "Fragment", Constants[Constants.NaN = 11] = "NaN",
|
|
5829
|
+
Constants[Constants.PositiveInfinity = 12] = "PositiveInfinity", Constants[Constants.NegativeInfinity = 13] = "NegativeInfinity",
|
|
5830
|
+
Constants[Constants.MaxSafeInt = 14] = "MaxSafeInt", Constants[Constants.AlmostMaxSafeInt = 15] = "AlmostMaxSafeInt",
|
|
5831
|
+
Constants[Constants.MinSafeInt = 16] = "MinSafeInt";
|
|
5675
5832
|
}(Constants || (Constants = {}));
|
|
5676
5833
|
|
|
5677
5834
|
const verifySerializable = (value, preMessage) => {
|
|
5678
|
-
const seen = new
|
|
5835
|
+
const seen = new WeakSet;
|
|
5679
5836
|
return _verifySerializable(value, seen, "_", preMessage);
|
|
5680
5837
|
};
|
|
5681
5838
|
|
|
@@ -5685,10 +5842,13 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
|
|
|
5685
5842
|
return value;
|
|
5686
5843
|
}
|
|
5687
5844
|
if (shouldSerialize(unwrapped)) {
|
|
5688
|
-
if (
|
|
5689
|
-
|
|
5845
|
+
if ("object" == typeof unwrapped) {
|
|
5846
|
+
if (seen.has(unwrapped)) {
|
|
5847
|
+
return value;
|
|
5848
|
+
}
|
|
5849
|
+
seen.add(unwrapped);
|
|
5690
5850
|
}
|
|
5691
|
-
if (
|
|
5851
|
+
if (isSignal(unwrapped)) {
|
|
5692
5852
|
return value;
|
|
5693
5853
|
}
|
|
5694
5854
|
if (canSerialize(unwrapped)) {
|
|
@@ -5750,13 +5910,7 @@ const noSerialize = input => (null != input && noSerializeSet.add(input), input)
|
|
|
5750
5910
|
|
|
5751
5911
|
const _weakSerialize = input => (weakSerializeSet.add(input), input);
|
|
5752
5912
|
|
|
5753
|
-
const
|
|
5754
|
-
|
|
5755
|
-
const SYNC_QRL = "<sync>";
|
|
5756
|
-
|
|
5757
|
-
const isSyncQrl = value => isQrl(value) && "<sync>" == value.$symbol$;
|
|
5758
|
-
|
|
5759
|
-
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
|
|
5913
|
+
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
5760
5914
|
let _containerEl;
|
|
5761
5915
|
const qrl = async function(...args) {
|
|
5762
5916
|
const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
|
|
@@ -5764,9 +5918,14 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
|
|
|
5764
5918
|
};
|
|
5765
5919
|
const setContainer = el => (_containerEl || (_containerEl = el), _containerEl);
|
|
5766
5920
|
function bindFnToContext(currentCtx, beforeFn) {
|
|
5767
|
-
|
|
5768
|
-
if (!
|
|
5769
|
-
|
|
5921
|
+
const bound = (...args) => {
|
|
5922
|
+
if (!qrl.resolved) {
|
|
5923
|
+
return qrl.resolve().then((fn => {
|
|
5924
|
+
if (!isFunction(fn)) {
|
|
5925
|
+
throw qError(QError.qrlIsNotFunction);
|
|
5926
|
+
}
|
|
5927
|
+
return bound(...args);
|
|
5928
|
+
}));
|
|
5770
5929
|
}
|
|
5771
5930
|
if (beforeFn && !1 === beforeFn()) {
|
|
5772
5931
|
return;
|
|
@@ -5776,17 +5935,29 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
|
|
|
5776
5935
|
const prevEvent = context.$event$;
|
|
5777
5936
|
context.$qrl$ = qrl, context.$event$ ||= this;
|
|
5778
5937
|
try {
|
|
5779
|
-
return invoke.call(this, context,
|
|
5938
|
+
return invoke.call(this, context, symbolRef, ...args);
|
|
5780
5939
|
} finally {
|
|
5781
5940
|
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
5782
5941
|
}
|
|
5783
|
-
}
|
|
5942
|
+
};
|
|
5943
|
+
return bound;
|
|
5784
5944
|
}
|
|
5785
|
-
const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
|
|
5786
5945
|
const wrapFn = fn => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
|
|
5787
5946
|
let context = tryGetInvokeContext();
|
|
5788
|
-
|
|
5789
|
-
|
|
5947
|
+
if (context) {
|
|
5948
|
+
if (context.$qrl$?.$symbol$ === qrl.$symbol$) {
|
|
5949
|
+
return fn.apply(this, args);
|
|
5950
|
+
}
|
|
5951
|
+
const prevQrl = context.$qrl$;
|
|
5952
|
+
context.$qrl$ = qrl;
|
|
5953
|
+
try {
|
|
5954
|
+
return fn.apply(this, args);
|
|
5955
|
+
} finally {
|
|
5956
|
+
context.$qrl$ = prevQrl;
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
|
|
5960
|
+
invoke.call(this, context, fn, ...args);
|
|
5790
5961
|
};
|
|
5791
5962
|
const resolve = async containerEl => {
|
|
5792
5963
|
if (null !== symbolRef) {
|
|
@@ -5801,49 +5972,38 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
|
|
|
5801
5972
|
const start = now();
|
|
5802
5973
|
const ctx = tryGetInvokeContext();
|
|
5803
5974
|
if (null !== symbolFn) {
|
|
5804
|
-
symbolRef = symbolFn().then((module => qrl.resolved = symbolRef =
|
|
5975
|
+
symbolRef = symbolFn().then((module => qrl.resolved = wrapFn(symbolRef = module[symbol])));
|
|
5805
5976
|
} else {
|
|
5806
5977
|
const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
|
|
5807
|
-
symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef =
|
|
5978
|
+
symbolRef = maybeThen(imported, (ref => qrl.resolved = wrapFn(symbolRef = ref)));
|
|
5808
5979
|
}
|
|
5809
5980
|
return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
|
|
5810
5981
|
throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
|
|
5811
5982
|
})), symbolRef;
|
|
5812
5983
|
};
|
|
5813
5984
|
const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
|
|
5814
|
-
const
|
|
5815
|
-
const hash = getSymbolHash(resolvedSymbol);
|
|
5985
|
+
const hash = getSymbolHash(symbol);
|
|
5816
5986
|
return Object.assign(qrl, {
|
|
5817
|
-
getSymbol: () =>
|
|
5987
|
+
getSymbol: () => symbol,
|
|
5818
5988
|
getHash: () => hash,
|
|
5819
5989
|
getCaptured: () => captureRef,
|
|
5820
5990
|
resolve,
|
|
5821
|
-
$resolveLazy$:
|
|
5991
|
+
$resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
|
|
5822
5992
|
$setContainer$: setContainer,
|
|
5823
5993
|
$chunk$: chunk,
|
|
5824
5994
|
$symbol$: symbol,
|
|
5825
|
-
$refSymbol$: refSymbol,
|
|
5826
5995
|
$hash$: hash,
|
|
5827
5996
|
getFn: bindFnToContext,
|
|
5828
5997
|
$capture$: capture,
|
|
5829
5998
|
$captureRef$: captureRef,
|
|
5830
5999
|
dev: null,
|
|
5831
6000
|
resolved: void 0
|
|
5832
|
-
}), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef =
|
|
6001
|
+
}), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = wrapFn(symbolRef = resolved)))),
|
|
5833
6002
|
isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
|
|
5834
6003
|
get: () => symbolRef
|
|
5835
6004
|
}), qrl;
|
|
5836
6005
|
};
|
|
5837
6006
|
|
|
5838
|
-
const getSymbolHash = symbolName => {
|
|
5839
|
-
const index = symbolName.lastIndexOf("_");
|
|
5840
|
-
return index > -1 ? symbolName.slice(index + 1) : symbolName;
|
|
5841
|
-
};
|
|
5842
|
-
|
|
5843
|
-
function assertQrl() {
|
|
5844
|
-
qDev;
|
|
5845
|
-
}
|
|
5846
|
-
|
|
5847
6007
|
const EMITTED = /*#__PURE__*/ new Set;
|
|
5848
6008
|
|
|
5849
6009
|
const emitUsedSymbol = (symbol, element, reqTime) => {
|
|
@@ -5865,17 +6025,17 @@ const now = () => isServerPlatform() ? 0 : "object" == typeof performance ? perf
|
|
|
5865
6025
|
|
|
5866
6026
|
let runtimeSymbolId = 0;
|
|
5867
6027
|
|
|
5868
|
-
const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null
|
|
6028
|
+
const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
|
|
5869
6029
|
|
|
5870
6030
|
const dollar = $;
|
|
5871
6031
|
|
|
5872
6032
|
const eventQrl = qrl => qrl;
|
|
5873
6033
|
|
|
5874
|
-
const sync$ = fn => createQRL("", "<sync>", fn, null, null, null
|
|
6034
|
+
const sync$ = fn => createQRL("", "<sync>", fn, null, null, null);
|
|
5875
6035
|
|
|
5876
6036
|
const _qrlSync = function(fn, serializedFn) {
|
|
5877
6037
|
return void 0 === serializedFn && (serializedFn = fn.toString()), fn.serialized = serializedFn,
|
|
5878
|
-
createQRL("", "<sync>", fn, null, null, null
|
|
6038
|
+
createQRL("", "<sync>", fn, null, null, null);
|
|
5879
6039
|
};
|
|
5880
6040
|
|
|
5881
6041
|
const componentQrl = componentQrl => {
|
|
@@ -6005,7 +6165,7 @@ const scopeStylesheet = (css, scopeId) => {
|
|
|
6005
6165
|
out.push(css.substring(lastIdx, idx)), lastIdx = idx;
|
|
6006
6166
|
}
|
|
6007
6167
|
function insertScopingSelector(idx) {
|
|
6008
|
-
mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "
|
|
6168
|
+
mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "⚡️", scopeId));
|
|
6009
6169
|
}
|
|
6010
6170
|
function lookAhead(arc) {
|
|
6011
6171
|
let prefix = 0;
|
|
@@ -6156,7 +6316,7 @@ const useStylesQrl = styles => ({
|
|
|
6156
6316
|
const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
|
|
6157
6317
|
|
|
6158
6318
|
const useStylesScopedQrl = styles => ({
|
|
6159
|
-
scopeId: "
|
|
6319
|
+
scopeId: "⚡️" + _useStyles(styles, getScopedStyles, !0)
|
|
6160
6320
|
});
|
|
6161
6321
|
|
|
6162
6322
|
const useStylesScoped$ = /*#__PURE__*/ implicit$FirstArg(useStylesScopedQrl);
|
|
@@ -6211,6 +6371,12 @@ const useVisibleTaskQrl = (qrl, opts) => {
|
|
|
6211
6371
|
iCtx.$container$.$scheduler$(ChoreType.VISIBLE, task));
|
|
6212
6372
|
};
|
|
6213
6373
|
|
|
6374
|
+
const useRunTask = (task, eagerness) => {
|
|
6375
|
+
"intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "document-idle" === eagerness && useOnDocument("qidle", getTaskHandlerQrl(task));
|
|
6376
|
+
};
|
|
6377
|
+
|
|
6378
|
+
const getTaskHandlerQrl = task => createQRL(null, "_task", scheduleTask, null, null, [ task ]);
|
|
6379
|
+
|
|
6214
6380
|
const useResource$ = (generatorFn, opts) => useResourceQrl(dollar(generatorFn), opts);
|
|
6215
6381
|
|
|
6216
6382
|
const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
|
|
@@ -6283,4 +6449,4 @@ const PrefetchGraph = (opts = {}) => {
|
|
|
6283
6449
|
}, null, 0, "prefetch-graph");
|
|
6284
6450
|
};
|
|
6285
6451
|
|
|
6286
|
-
export { $, Fragment, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, EMPTY_ARRAY as _EMPTY_ARRAY,
|
|
6452
|
+
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 };
|