@qwik.dev/core 2.0.0-alpha.6 → 2.0.0-alpha.7
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 +77 -76
- package/dist/core.cjs +1498 -1323
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +1496 -1323
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +884 -782
- package/dist/core.prod.mjs +1006 -867
- package/dist/insights/index.qwik.cjs +3652 -154
- package/dist/insights/index.qwik.mjs +3652 -154
- 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 +210 -5714
- package/dist/optimizer.mjs +191 -6037
- package/dist/prefetch/package.json +1 -1
- package/dist/qwikloader.debug.js +12 -15
- package/dist/qwikloader.js +2 -2
- package/dist/server.cjs +762 -7127
- package/dist/server.mjs +778 -7121
- 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 +1265 -1124
- package/dist/testing/index.mjs +1271 -1124
- 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.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core 2.0.0-alpha.7-dev+a26598a
|
|
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
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
}
|
|
41
41
|
var QError;
|
|
42
42
|
!function(QError) {
|
|
43
|
-
QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.
|
|
44
|
-
QError[QError.
|
|
43
|
+
QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.schedulerNotFound = 1] = "schedulerNotFound",
|
|
44
|
+
QError[QError.trackObjectWithoutProp = 2] = "trackObjectWithoutProp", QError[QError.verifySerializable = 3] = "verifySerializable",
|
|
45
45
|
QError[QError.UNUSED_4 = 4] = "UNUSED_4", QError[QError.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer",
|
|
46
46
|
QError[QError.UNUSED_6 = 6] = "UNUSED_6", QError[QError.UNUSED_7 = 7] = "UNUSED_7",
|
|
47
47
|
QError[QError.UNUSED_8 = 8] = "UNUSED_8", QError[QError.UNUSED_9 = 9] = "UNUSED_9",
|
|
@@ -66,12 +66,22 @@
|
|
|
66
66
|
QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
|
|
67
67
|
QError[QError.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError[QError.computedNotSync = 46] = "computedNotSync",
|
|
68
68
|
QError[QError.computedReadOnly = 47] = "computedReadOnly", QError[QError.wrappedReadOnly = 48] = "wrappedReadOnly",
|
|
69
|
-
QError[QError.
|
|
69
|
+
QError[QError.unsafeAttr = 49] = "unsafeAttr";
|
|
70
70
|
}(QError || (QError = {}));
|
|
71
71
|
const qError = (code, errorMessageArgs = []) => {
|
|
72
72
|
const text = (code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...errorMessageArgs);
|
|
73
73
|
return ((message, ...optionalParams) => createAndLogError(!0, message, ...optionalParams))(text, ...errorMessageArgs);
|
|
74
74
|
};
|
|
75
|
+
const isQrl$1 = value => "function" == typeof value && "function" == typeof value.getSymbol;
|
|
76
|
+
function assertQrl(qrl) {
|
|
77
|
+
if (build.isDev && !isQrl$1(qrl)) {
|
|
78
|
+
throw new Error("Not a QRL");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const getSymbolHash = symbolName => {
|
|
82
|
+
const index = symbolName.lastIndexOf("_");
|
|
83
|
+
return index > -1 ? symbolName.slice(index + 1) : symbolName;
|
|
84
|
+
};
|
|
75
85
|
var VirtualType;
|
|
76
86
|
!function(VirtualType) {
|
|
77
87
|
VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
|
|
@@ -223,12 +233,45 @@
|
|
|
223
233
|
chunk = chunkOrFn;
|
|
224
234
|
}
|
|
225
235
|
return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
|
|
226
|
-
symbols: [
|
|
236
|
+
symbols: [ symbol ],
|
|
227
237
|
bundles: chunk && [ chunk ]
|
|
228
|
-
})), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture
|
|
238
|
+
})), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture);
|
|
239
|
+
};
|
|
240
|
+
const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
|
|
241
|
+
const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture);
|
|
242
|
+
var ChoreType;
|
|
243
|
+
!function(ChoreType) {
|
|
244
|
+
ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
|
|
245
|
+
ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RUN_QRL = 2] = "RUN_QRL",
|
|
246
|
+
ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
|
|
247
|
+
ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT = 6] = "COMPONENT",
|
|
248
|
+
ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 7] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
|
|
249
|
+
ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
|
|
250
|
+
ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
|
|
251
|
+
}(ChoreType || (ChoreType = {}));
|
|
252
|
+
const useLexicalScope = () => {
|
|
253
|
+
const context = getInvokeContext();
|
|
254
|
+
let qrl = context.$qrl$;
|
|
255
|
+
if (qrl) {
|
|
256
|
+
assertQrl(qrl), assertDefined();
|
|
257
|
+
} else {
|
|
258
|
+
const el = context.$element$;
|
|
259
|
+
assertDefined();
|
|
260
|
+
const containerElement = _getQContainerElement(el);
|
|
261
|
+
assertDefined();
|
|
262
|
+
qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
|
|
263
|
+
}
|
|
264
|
+
return qrl.$captureRef$;
|
|
265
|
+
};
|
|
266
|
+
const queueQRL = (...args) => {
|
|
267
|
+
const [runQrl] = useLexicalScope();
|
|
268
|
+
const hostElement = getInvokeContext().$hostElement$;
|
|
269
|
+
const scheduler = getDomContainer(hostElement).$scheduler$;
|
|
270
|
+
if (!scheduler) {
|
|
271
|
+
throw qError(QError.schedulerNotFound);
|
|
272
|
+
}
|
|
273
|
+
return scheduler(ChoreType.RUN_QRL, hostElement, runQrl, args);
|
|
229
274
|
};
|
|
230
|
-
const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
|
|
231
|
-
const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
|
|
232
275
|
const Slot = props => _jsxSorted(Virtual, null, {
|
|
233
276
|
[QSlotS]: ""
|
|
234
277
|
}, props.children, 0, props.name ?? "");
|
|
@@ -283,6 +326,34 @@
|
|
|
283
326
|
function isPreventDefault(key) {
|
|
284
327
|
return key.startsWith("preventdefault:");
|
|
285
328
|
}
|
|
329
|
+
function getFileLocationFromJsx(jsxDev) {
|
|
330
|
+
if (!jsxDev) {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
|
|
334
|
+
return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
|
|
335
|
+
}
|
|
336
|
+
const styleContent = styleId => "⚡️" + styleId;
|
|
337
|
+
function hasClassAttr(props) {
|
|
338
|
+
for (const key in props) {
|
|
339
|
+
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
340
|
+
return !0;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return !1;
|
|
344
|
+
}
|
|
345
|
+
function isClassAttr(key) {
|
|
346
|
+
return "class" === key || "className" === key;
|
|
347
|
+
}
|
|
348
|
+
const addComponentStylePrefix = styleId => {
|
|
349
|
+
if (styleId) {
|
|
350
|
+
let idx = 0;
|
|
351
|
+
do {
|
|
352
|
+
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
353
|
+
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
354
|
+
}
|
|
355
|
+
return styleId || null;
|
|
356
|
+
};
|
|
286
357
|
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" ]);
|
|
287
358
|
const hashCode = (text, hash = 0) => {
|
|
288
359
|
for (let i = 0; i < text.length; i++) {
|
|
@@ -343,27 +414,6 @@
|
|
|
343
414
|
return value;
|
|
344
415
|
}
|
|
345
416
|
const setValueForStyle = (styleName, value) => "number" != typeof value || 0 === value || unitlessNumbers.has(styleName) ? value : value + "px";
|
|
346
|
-
const styleContent = styleId => "⭐️" + styleId;
|
|
347
|
-
function hasClassAttr(props) {
|
|
348
|
-
for (const key in props) {
|
|
349
|
-
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
350
|
-
return !0;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return !1;
|
|
354
|
-
}
|
|
355
|
-
function isClassAttr(key) {
|
|
356
|
-
return "class" === key || "className" === key;
|
|
357
|
-
}
|
|
358
|
-
const addComponentStylePrefix = styleId => {
|
|
359
|
-
if (styleId) {
|
|
360
|
-
let idx = 0;
|
|
361
|
-
do {
|
|
362
|
-
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
363
|
-
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
364
|
-
}
|
|
365
|
-
return styleId || null;
|
|
366
|
-
};
|
|
367
417
|
const STORE_TARGET = Symbol("store.target");
|
|
368
418
|
const STORE_HANDLER = Symbol("store.handler");
|
|
369
419
|
const STORE_ARRAY_PROP = Symbol("store.array");
|
|
@@ -456,27 +506,89 @@
|
|
|
456
506
|
Reflect.ownKeys(target);
|
|
457
507
|
}
|
|
458
508
|
getOwnPropertyDescriptor(target, prop) {
|
|
459
|
-
|
|
509
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
510
|
+
return Array.isArray(target) || "symbol" == typeof prop || descriptor && !descriptor.configurable ? descriptor : {
|
|
460
511
|
enumerable: !0,
|
|
461
512
|
configurable: !0
|
|
462
513
|
};
|
|
463
514
|
}
|
|
464
515
|
}
|
|
465
|
-
function addEffect(target, prop, store,
|
|
466
|
-
const effectsMap = store.$effects$ ||=
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
516
|
+
function addEffect(target, prop, store, effectSubscription) {
|
|
517
|
+
const effectsMap = store.$effects$ ||= new Map;
|
|
518
|
+
let effects = effectsMap.get(prop);
|
|
519
|
+
effects || (effects = new Set, effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription),
|
|
520
|
+
ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
|
|
470
521
|
}
|
|
471
522
|
function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
|
|
472
523
|
target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
|
|
473
524
|
}
|
|
474
525
|
function getEffects(target, prop, storeEffects) {
|
|
475
|
-
let effectsToTrigger
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
526
|
+
let effectsToTrigger;
|
|
527
|
+
if (storeEffects) {
|
|
528
|
+
if (Array.isArray(target)) {
|
|
529
|
+
for (const effects of storeEffects.values()) {
|
|
530
|
+
effectsToTrigger ||= new Set;
|
|
531
|
+
for (const effect of effects) {
|
|
532
|
+
effectsToTrigger.add(effect);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
effectsToTrigger = storeEffects.get(prop);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
const storeArrayValue = storeEffects?.get(STORE_ARRAY_PROP);
|
|
540
|
+
if (storeArrayValue) {
|
|
541
|
+
effectsToTrigger ||= new Set;
|
|
542
|
+
for (const effect of storeArrayValue) {
|
|
543
|
+
effectsToTrigger.add(effect);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return effectsToTrigger || null;
|
|
547
|
+
}
|
|
548
|
+
const NEEDS_COMPUTATION = Symbol("invalid");
|
|
549
|
+
const _EFFECT_BACK_REF = Symbol("backRef");
|
|
550
|
+
class BackRef {
|
|
551
|
+
[_EFFECT_BACK_REF]=null;
|
|
552
|
+
}
|
|
553
|
+
function clearAllEffects(container, consumer) {
|
|
554
|
+
vnode_isVNode(consumer) && vnode_isElementVNode(consumer) && ensureMaterialized(consumer);
|
|
555
|
+
const effects = consumer[_EFFECT_BACK_REF];
|
|
556
|
+
if (effects) {
|
|
557
|
+
for (const [, effect] of effects) {
|
|
558
|
+
const backRefs = effect[EffectSubscriptionProp.BACK_REF];
|
|
559
|
+
if (!backRefs) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
for (const producer of backRefs) {
|
|
563
|
+
if (producer instanceof Signal) {
|
|
564
|
+
clearSignal(container, producer, effect);
|
|
565
|
+
} else if (container.$storeProxyMap$.has(producer)) {
|
|
566
|
+
const target = container.$storeProxyMap$.get(producer);
|
|
567
|
+
clearStore(getStoreHandler(target), effect);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function clearSignal(container, producer, effect) {
|
|
574
|
+
const effects = producer.$effects$;
|
|
575
|
+
effects && effects.delete(effect), producer instanceof WrappedSignal && (producer.$hostElement$ = null,
|
|
576
|
+
clearAllEffects(container, producer));
|
|
479
577
|
}
|
|
578
|
+
function clearStore(producer, effect) {
|
|
579
|
+
const effects = producer?.$effects$;
|
|
580
|
+
if (effects) {
|
|
581
|
+
for (const propEffects of effects.values()) {
|
|
582
|
+
propEffects.delete(effect);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const implicit$FirstArg = fn => function(first, ...rest) {
|
|
587
|
+
return fn.call(null, dollar(first), ...rest);
|
|
588
|
+
};
|
|
589
|
+
const createSignal = value => new Signal(null, value);
|
|
590
|
+
const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
|
|
591
|
+
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
|
|
480
592
|
const useSequentialScope = () => {
|
|
481
593
|
const iCtx = useInvokeContext();
|
|
482
594
|
const host = iCtx.$hostElement$;
|
|
@@ -493,196 +605,104 @@
|
|
|
493
605
|
iCtx
|
|
494
606
|
};
|
|
495
607
|
};
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
vnode_isElementVNode(value) && ensureMaterialized(value);
|
|
504
|
-
const effects = vnode_getProp(value, "q:subs", container.$getObjectById$);
|
|
505
|
-
if (effects) {
|
|
506
|
-
for (let i = effects.length - 1; i >= 0; i--) {
|
|
507
|
-
clearEffects(effects[i], value, effects, i, container);
|
|
508
|
-
}
|
|
509
|
-
0 === effects.length && vnode_setProp(value, "q:subs", null);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
function clearSubscriberEffectDependencies(container, value) {
|
|
513
|
-
if (value.$effectDependencies$) {
|
|
514
|
-
for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
|
|
515
|
-
clearEffects(value.$effectDependencies$[i], value, value.$effectDependencies$, i, container);
|
|
516
|
-
}
|
|
517
|
-
0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
|
|
521
|
-
let subscriptionRemoved = !1;
|
|
522
|
-
const seenSet = new Set;
|
|
523
|
-
if (subscriber instanceof WrappedSignal) {
|
|
524
|
-
subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
|
|
525
|
-
} else if (container.$storeProxyMap$.has(subscriber)) {
|
|
526
|
-
const store = container.$storeProxyMap$.get(subscriber);
|
|
527
|
-
subscriptionRemoved = clearStoreEffects(getStoreHandler(store), value);
|
|
528
|
-
}
|
|
529
|
-
subscriptionRemoved && effectArray.splice(indexToRemove, 1);
|
|
530
|
-
}
|
|
531
|
-
function clearSignalEffects(subscriber, value, seenSet) {
|
|
532
|
-
const effectSubscriptions = subscriber.$effects$;
|
|
533
|
-
let subscriptionRemoved = !1;
|
|
534
|
-
if (effectSubscriptions) {
|
|
535
|
-
for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
|
|
536
|
-
effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
|
|
537
|
-
subscriptionRemoved = !0);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
if (subscriber instanceof WrappedSignal) {
|
|
541
|
-
const hostElement = subscriber.$hostElement$;
|
|
542
|
-
hostElement && hostElement === value && (subscriber.$hostElement$ = null);
|
|
543
|
-
const args = subscriber.$args$;
|
|
544
|
-
args && clearArgsEffects(args, subscriber, seenSet);
|
|
545
|
-
}
|
|
546
|
-
return subscriptionRemoved;
|
|
547
|
-
}
|
|
548
|
-
function clearStoreEffects(storeHandler, value) {
|
|
549
|
-
const effectSubscriptions = storeHandler.$effects$;
|
|
550
|
-
if (!effectSubscriptions) {
|
|
551
|
-
return !1;
|
|
552
|
-
}
|
|
553
|
-
let subscriptionRemoved = !1;
|
|
554
|
-
for (const key in effectSubscriptions) {
|
|
555
|
-
const effects = effectSubscriptions[key];
|
|
556
|
-
for (let i = effects.length - 1; i >= 0; i--) {
|
|
557
|
-
effects[i][EffectSubscriptionsProp.EFFECT] === value && (effects.splice(i, 1), subscriptionRemoved = !0);
|
|
558
|
-
}
|
|
559
|
-
0 === effects.length && delete effectSubscriptions[key];
|
|
560
|
-
}
|
|
561
|
-
return subscriptionRemoved;
|
|
562
|
-
}
|
|
563
|
-
function clearArgsEffects(args, subscriber, seenSet) {
|
|
564
|
-
for (let i = args.length - 1; i >= 0; i--) {
|
|
565
|
-
clearArgEffect(args[i], subscriber, seenSet);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
function clearArgEffect(arg, subscriber, seenSet) {
|
|
569
|
-
if (!seenSet.has(arg)) {
|
|
570
|
-
if (seenSet.add(arg), isSignal(arg)) {
|
|
571
|
-
clearSignalEffects(arg, subscriber, seenSet);
|
|
572
|
-
} else if ("object" == typeof arg && null !== arg) {
|
|
573
|
-
if (isStore(arg)) {
|
|
574
|
-
clearStoreEffects(getStoreHandler(arg), subscriber);
|
|
575
|
-
} else if (isPropsProxy(arg)) {
|
|
576
|
-
const constProps = arg[_CONST_PROPS];
|
|
577
|
-
const varProps = arg[_VAR_PROPS];
|
|
578
|
-
if (constProps) {
|
|
579
|
-
for (const key in constProps) {
|
|
580
|
-
clearArgEffect(constProps[key], subscriber, seenSet);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
for (const key in varProps) {
|
|
584
|
-
clearArgEffect(varProps[key], subscriber, seenSet);
|
|
585
|
-
}
|
|
586
|
-
} else {
|
|
587
|
-
for (const key in arg) {
|
|
588
|
-
clearArgEffect(arg[key], subscriber, seenSet);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
} else {
|
|
592
|
-
Array.isArray(arg) && clearArgsEffects(arg, subscriber, seenSet);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
608
|
+
function getSubscriber(effect, prop, data) {
|
|
609
|
+
var value;
|
|
610
|
+
effect[_EFFECT_BACK_REF] || (build.isServer && ("__brand__" in (value = effect) && "currentComponentNode" in value) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
|
|
611
|
+
const subMap = effect[_EFFECT_BACK_REF];
|
|
612
|
+
let sub = subMap.get(prop);
|
|
613
|
+
return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[EffectSubscriptionProp.DATA] = data),
|
|
614
|
+
sub;
|
|
595
615
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
616
|
+
var TaskFlags;
|
|
617
|
+
!function(TaskFlags) {
|
|
618
|
+
TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
|
|
619
|
+
TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
|
|
620
|
+
}(TaskFlags || (TaskFlags = {}));
|
|
621
|
+
const useTaskQrl = qrl => {
|
|
622
|
+
const {val, set, iCtx, i} = useSequentialScope();
|
|
623
|
+
if (val) {
|
|
624
|
+
return;
|
|
600
625
|
}
|
|
601
|
-
assertQrl(qrl);
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
};
|
|
607
|
-
const createResourceReturn = (container, opts, initialPromise) => {
|
|
608
|
-
const result = (opts => ({
|
|
609
|
-
__brand: "resource",
|
|
610
|
-
value: void 0,
|
|
611
|
-
loading: !isServerPlatform(),
|
|
612
|
-
_resolved: void 0,
|
|
613
|
-
_error: void 0,
|
|
614
|
-
_state: "pending",
|
|
615
|
-
_timeout: opts?.timeout ?? -1,
|
|
616
|
-
_cache: 0
|
|
617
|
-
}))(opts);
|
|
618
|
-
return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
|
|
626
|
+
assertQrl(qrl), set(1);
|
|
627
|
+
const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
628
|
+
set(task);
|
|
629
|
+
const promise = iCtx.$container$.$scheduler$(ChoreType.TASK, task);
|
|
630
|
+
isPromise(promise) && promise.catch((() => {}));
|
|
619
631
|
};
|
|
620
|
-
const
|
|
621
|
-
const runResource = (task, container, host) => {
|
|
632
|
+
const runTask = (task, container, host) => {
|
|
622
633
|
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
623
|
-
const iCtx = newInvokeContext(container.$locale$, host, void 0, "
|
|
634
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
624
635
|
iCtx.$container$ = container;
|
|
625
|
-
const taskFn = task.$qrl$.getFn(iCtx, (() =>
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
636
|
-
})),
|
|
637
|
-
}
|
|
638
|
-
const
|
|
639
|
-
const opts = {
|
|
636
|
+
const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
|
|
637
|
+
let cleanupFns = null;
|
|
638
|
+
const cleanup = fn => {
|
|
639
|
+
"function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
|
|
640
|
+
task.$destroy$ = null, cleanupFns.forEach((fn => {
|
|
641
|
+
try {
|
|
642
|
+
fn();
|
|
643
|
+
} catch (err) {
|
|
644
|
+
container.handleError(err, host);
|
|
645
|
+
}
|
|
646
|
+
}));
|
|
647
|
+
}))), cleanupFns.push(fn));
|
|
648
|
+
};
|
|
649
|
+
const taskApi = {
|
|
640
650
|
track: (obj, prop) => {
|
|
641
651
|
const ctx = newInvokeContext();
|
|
642
|
-
return ctx.$effectSubscriber$ =
|
|
643
|
-
invoke(ctx, (() =>
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
652
|
+
return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
|
|
653
|
+
invoke(ctx, (() => {
|
|
654
|
+
if (isFunction(obj)) {
|
|
655
|
+
return obj();
|
|
656
|
+
}
|
|
657
|
+
if (prop) {
|
|
658
|
+
return obj[prop];
|
|
659
|
+
}
|
|
660
|
+
if (isSignal(obj)) {
|
|
661
|
+
return obj.value;
|
|
662
|
+
}
|
|
663
|
+
throw qError(QError.trackObjectWithoutProp);
|
|
664
|
+
}));
|
|
651
665
|
},
|
|
652
|
-
|
|
666
|
+
cleanup
|
|
653
667
|
};
|
|
654
|
-
|
|
655
|
-
let reject;
|
|
656
|
-
let done = !1;
|
|
657
|
-
const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
|
|
658
|
-
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
659
|
-
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
660
|
-
resource._error = value, reject(value)), !0);
|
|
661
|
-
cleanups.push((() => {
|
|
662
|
-
if (!0 === untrack((() => resource.loading))) {
|
|
663
|
-
const value = untrack((() => resource._resolved));
|
|
664
|
-
setState(!0, value);
|
|
665
|
-
}
|
|
666
|
-
})), invoke(iCtx, (() => {
|
|
667
|
-
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
668
|
-
(resource.value = new Promise(((r, re) => {
|
|
669
|
-
resolve = r, reject = re;
|
|
670
|
-
}))).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
671
|
-
}));
|
|
672
|
-
const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
|
|
673
|
-
setState(!0, value);
|
|
674
|
-
}), (err => {
|
|
668
|
+
return safeCall((() => taskFn(taskApi)), cleanup, (err => {
|
|
675
669
|
if (isPromise(err)) {
|
|
676
|
-
return err.then((() =>
|
|
670
|
+
return err.then((() => runTask(task, container, host)));
|
|
677
671
|
}
|
|
678
|
-
|
|
672
|
+
throw err;
|
|
679
673
|
}));
|
|
680
|
-
const timeout = resourceTarget._timeout;
|
|
681
|
-
return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
|
|
682
|
-
setState(!1, new Error("timeout")) && cleanupTask(task);
|
|
683
|
-
})) ]) : promise;
|
|
684
674
|
};
|
|
685
|
-
const
|
|
675
|
+
const cleanupTask = task => {
|
|
676
|
+
const destroy = task.$destroy$;
|
|
677
|
+
if (destroy) {
|
|
678
|
+
task.$destroy$ = null;
|
|
679
|
+
try {
|
|
680
|
+
destroy();
|
|
681
|
+
} catch (err) {
|
|
682
|
+
((message, ...optionalParams) => {
|
|
683
|
+
createAndLogError(!1, message, ...optionalParams);
|
|
684
|
+
})(err);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
class Task extends BackRef {
|
|
689
|
+
$flags$;
|
|
690
|
+
$index$;
|
|
691
|
+
$el$;
|
|
692
|
+
$qrl$;
|
|
693
|
+
$state$;
|
|
694
|
+
$destroy$;
|
|
695
|
+
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
696
|
+
super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
|
|
697
|
+
this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
const isTask = value => value instanceof Task;
|
|
701
|
+
const scheduleTask = (_event, element) => {
|
|
702
|
+
const [task] = useLexicalScope();
|
|
703
|
+
const type = task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK;
|
|
704
|
+
getDomContainer(element).$scheduler$(type, task);
|
|
705
|
+
};
|
|
686
706
|
var VNodeFlags;
|
|
687
707
|
var VNodeFlagsIndex;
|
|
688
708
|
var VNodeProps;
|
|
@@ -715,9 +735,29 @@
|
|
|
715
735
|
VirtualVNodeProps[VirtualVNodeProps.firstChild = 4] = "firstChild", VirtualVNodeProps[VirtualVNodeProps.lastChild = 5] = "lastChild",
|
|
716
736
|
VirtualVNodeProps[VirtualVNodeProps.PROPS_OFFSET = 6] = "PROPS_OFFSET";
|
|
717
737
|
}(VirtualVNodeProps || (VirtualVNodeProps = {}));
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
738
|
+
const mapApp_findIndx = (elementVNode, key, start) => {
|
|
739
|
+
assertTrue();
|
|
740
|
+
let bottom = start >> 1;
|
|
741
|
+
let top = elementVNode.length - 2 >> 1;
|
|
742
|
+
for (;bottom <= top; ) {
|
|
743
|
+
const mid = bottom + (top - bottom >> 1);
|
|
744
|
+
const midKey = elementVNode[mid << 1];
|
|
745
|
+
if (midKey === key) {
|
|
746
|
+
return mid << 1;
|
|
747
|
+
}
|
|
748
|
+
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
749
|
+
}
|
|
750
|
+
return ~(bottom << 1);
|
|
751
|
+
};
|
|
752
|
+
const mapArray_set = (elementVNode, key, value, start) => {
|
|
753
|
+
const indx = mapApp_findIndx(elementVNode, key, start);
|
|
754
|
+
indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
|
|
755
|
+
};
|
|
756
|
+
const mapArray_get = (elementVNode, key, start) => {
|
|
757
|
+
const indx = mapApp_findIndx(elementVNode, key, start);
|
|
758
|
+
return indx >= 0 ? elementVNode[indx + 1] : null;
|
|
759
|
+
};
|
|
760
|
+
const isForeignObjectElement = elementName => build.isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
|
|
721
761
|
function cloneElementWithNamespace(element, elementName, namespace) {
|
|
722
762
|
const newElement = element.ownerDocument.createElementNS(namespace, elementName);
|
|
723
763
|
const attributes = element.attributes;
|
|
@@ -788,6 +828,10 @@
|
|
|
788
828
|
}
|
|
789
829
|
return rootElement;
|
|
790
830
|
}
|
|
831
|
+
function isSvg(tagOrVNode) {
|
|
832
|
+
return "string" == typeof tagOrVNode ? "svg" === (elementName = tagOrVNode) || isForeignObjectElement(elementName) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_svg);
|
|
833
|
+
var elementName;
|
|
834
|
+
}
|
|
791
835
|
function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
|
|
792
836
|
const parentIsDefaultNamespace = !domParentVNode || !(!vnode_getElementName(domParentVNode) || (vnode = domParentVNode,
|
|
793
837
|
vnode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK));
|
|
@@ -796,12 +840,10 @@
|
|
|
796
840
|
let elementNamespace = HTML_NS;
|
|
797
841
|
let elementNamespaceFlag = VNodeFlags.NS_html;
|
|
798
842
|
const isElementVNodeOrString = "string" == typeof tagOrVNode || vnode_isElementVNode(tagOrVNode);
|
|
799
|
-
if (isElementVNodeOrString &&
|
|
800
|
-
return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_svg);
|
|
801
|
-
}(tagOrVNode)) {
|
|
843
|
+
if (isElementVNodeOrString && isSvg(tagOrVNode)) {
|
|
802
844
|
elementNamespace = SVG_NS, elementNamespaceFlag = VNodeFlags.NS_svg;
|
|
803
845
|
} else if (isElementVNodeOrString && function(tagOrVNode) {
|
|
804
|
-
return "string" == typeof tagOrVNode ?
|
|
846
|
+
return "string" == typeof tagOrVNode ? "math" === tagOrVNode : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_math);
|
|
805
847
|
}(tagOrVNode)) {
|
|
806
848
|
elementNamespace = MATH_NS, elementNamespaceFlag = VNodeFlags.NS_math;
|
|
807
849
|
} else if (domParentVNode && !parentIsForeignObject && !parentIsDefaultNamespace) {
|
|
@@ -849,14 +891,14 @@
|
|
|
849
891
|
};
|
|
850
892
|
};
|
|
851
893
|
const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
|
|
852
|
-
const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, "qRender");
|
|
894
|
+
const iCtx = newInvokeContext(container.$locale$, subscriptionHost || void 0, void 0, "qRender");
|
|
853
895
|
let componentFn;
|
|
854
|
-
iCtx.$effectSubscriber$ =
|
|
855
|
-
container.ensureProjectionResolved(renderHost);
|
|
896
|
+
subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, EffectProperty.COMPONENT),
|
|
897
|
+
iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
|
|
856
898
|
let isInlineComponent = !1;
|
|
857
|
-
if (null === componentQRL && (componentQRL =
|
|
858
|
-
assertDefined()), isQrl(componentQRL)) {
|
|
859
|
-
(props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ)
|
|
899
|
+
if (null === componentQRL && (componentQRL = container.getHostProp(renderHost, "q:renderFn"),
|
|
900
|
+
assertDefined()), isQrl$1(componentQRL)) {
|
|
901
|
+
(props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ).children && delete props.children,
|
|
860
902
|
componentFn = componentQRL.getFn(iCtx);
|
|
861
903
|
} else if (isQwikComponent(componentQRL)) {
|
|
862
904
|
const qComponentFn = componentQRL;
|
|
@@ -867,21 +909,35 @@
|
|
|
867
909
|
componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
|
|
868
910
|
}
|
|
869
911
|
const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
|
|
870
|
-
container.setHostProp(renderHost, ":onIdx", null), container.
|
|
871
|
-
vnode_isVNode(renderHost) &&
|
|
872
|
-
componentFn(props))), (jsx => {
|
|
912
|
+
container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)),
|
|
913
|
+
vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props))), (jsx => {
|
|
873
914
|
const useOnEvents = container.getHostProp(renderHost, ":on");
|
|
874
|
-
return useOnEvents ?
|
|
915
|
+
return useOnEvents ? function(jsx, useOnEvents) {
|
|
875
916
|
const jsxElement = findFirstStringJSX(jsx);
|
|
917
|
+
let jsxResult = jsx;
|
|
876
918
|
return maybeThen(jsxElement, (jsxElement => {
|
|
877
919
|
let isInvisibleComponent = !1;
|
|
878
920
|
jsxElement || (isInvisibleComponent = !0);
|
|
879
921
|
for (const key in useOnEvents) {
|
|
880
|
-
Object.prototype.hasOwnProperty.call(useOnEvents, key)
|
|
922
|
+
if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
|
|
923
|
+
if (isInvisibleComponent) {
|
|
924
|
+
if ("onQvisible$" === key) {
|
|
925
|
+
const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
926
|
+
jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]);
|
|
927
|
+
} else if (key.startsWith("document:") || key.startsWith("window:")) {
|
|
928
|
+
const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
929
|
+
jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
|
|
930
|
+
} else {
|
|
931
|
+
build.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. ');
|
|
932
|
+
}
|
|
933
|
+
} else {
|
|
934
|
+
jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
881
937
|
}
|
|
882
|
-
return
|
|
938
|
+
return jsxResult;
|
|
883
939
|
}));
|
|
884
|
-
}(jsx, useOnEvents)
|
|
940
|
+
}(jsx, useOnEvents) : jsx;
|
|
885
941
|
}), (err => {
|
|
886
942
|
if (isPromise(err) && retryCount < 100) {
|
|
887
943
|
return err.then((() => executeComponentWithPromiseExceptionRetry(retryCount++)));
|
|
@@ -925,11 +981,18 @@
|
|
|
925
981
|
type: "placeholder",
|
|
926
982
|
hidden: ""
|
|
927
983
|
}, null, 3);
|
|
928
|
-
return null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
|
|
929
|
-
jsxElement;
|
|
984
|
+
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 ],
|
|
985
|
+
[ jsxElement, jsx ]);
|
|
986
|
+
}
|
|
987
|
+
if (Array.isArray(jsx) && jsx.length) {
|
|
988
|
+
const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]);
|
|
989
|
+
return [ jsxElement, jsx ];
|
|
930
990
|
}
|
|
931
|
-
return
|
|
991
|
+
return [ null, null ];
|
|
932
992
|
}
|
|
993
|
+
const _CONST_PROPS = Symbol("CONST");
|
|
994
|
+
const _VAR_PROPS = Symbol("VAR");
|
|
995
|
+
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
933
996
|
function isSlotProp(prop) {
|
|
934
997
|
return !prop.startsWith("q:") && !prop.startsWith(":");
|
|
935
998
|
}
|
|
@@ -958,13 +1021,6 @@
|
|
|
958
1021
|
}
|
|
959
1022
|
return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
|
|
960
1023
|
}
|
|
961
|
-
function getFileLocationFromJsx(jsxDev) {
|
|
962
|
-
if (!jsxDev) {
|
|
963
|
-
return null;
|
|
964
|
-
}
|
|
965
|
-
const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
|
|
966
|
-
return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
|
|
967
|
-
}
|
|
968
1024
|
const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
969
1025
|
let journal = container.$journal$;
|
|
970
1026
|
const stack = [];
|
|
@@ -1002,7 +1058,7 @@
|
|
|
1002
1058
|
if (Array.isArray(jsxValue)) {
|
|
1003
1059
|
descend(jsxValue, !1);
|
|
1004
1060
|
} else if (isSignal(jsxValue)) {
|
|
1005
|
-
vCurrent &&
|
|
1061
|
+
vCurrent && clearAllEffects(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
|
|
1006
1062
|
descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
|
|
1007
1063
|
} else if (isPromise(jsxValue)) {
|
|
1008
1064
|
expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
|
|
@@ -1141,8 +1197,12 @@
|
|
|
1141
1197
|
if (isJsxPropertyAnEventName(key)) {
|
|
1142
1198
|
const eventName = getEventNameFromJsxProp(key);
|
|
1143
1199
|
const scope = getEventNameScopeFromJsxProp(key);
|
|
1144
|
-
vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
|
|
1145
|
-
|
|
1200
|
+
if (eventName && (vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
|
|
1201
|
+
registerQwikLoaderEvent(eventName)), scope) {
|
|
1202
|
+
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1203
|
+
htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
|
|
1204
|
+
}
|
|
1205
|
+
needsQDispatchEventPatch = !0;
|
|
1146
1206
|
} else {
|
|
1147
1207
|
if ("ref" === key) {
|
|
1148
1208
|
if (isSignal(value)) {
|
|
@@ -1153,10 +1213,13 @@
|
|
|
1153
1213
|
value(element);
|
|
1154
1214
|
continue;
|
|
1155
1215
|
}
|
|
1216
|
+
if (null == value) {
|
|
1217
|
+
continue;
|
|
1218
|
+
}
|
|
1156
1219
|
throw qError(QError.invalidRefValue, [ currentFile ]);
|
|
1157
1220
|
}
|
|
1158
1221
|
if (isSignal(value)) {
|
|
1159
|
-
const signalData = new
|
|
1222
|
+
const signalData = new SubscriptionData({
|
|
1160
1223
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1161
1224
|
$isConst$: !0
|
|
1162
1225
|
});
|
|
@@ -1203,10 +1266,10 @@
|
|
|
1203
1266
|
const vNode = vNewNode || vCurrent;
|
|
1204
1267
|
if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile) {
|
|
1205
1268
|
vnode_ensureElementInflated(vnode);
|
|
1206
|
-
const dstAttrs = vnode;
|
|
1269
|
+
const dstAttrs = vnode_getProps(vnode);
|
|
1207
1270
|
let srcIdx = 0;
|
|
1208
1271
|
const srcLength = srcAttrs.length;
|
|
1209
|
-
let dstIdx =
|
|
1272
|
+
let dstIdx = 0;
|
|
1210
1273
|
let dstLength = dstAttrs.length;
|
|
1211
1274
|
let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
|
|
1212
1275
|
let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
@@ -1223,10 +1286,13 @@
|
|
|
1223
1286
|
if ("function" == typeof value) {
|
|
1224
1287
|
return void value(element);
|
|
1225
1288
|
}
|
|
1289
|
+
if (null == value) {
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1226
1292
|
throw qError(QError.invalidRefValue, [ currentFile ]);
|
|
1227
1293
|
}
|
|
1228
1294
|
if (isSignal(value)) {
|
|
1229
|
-
const signalData = new
|
|
1295
|
+
const signalData = new SubscriptionData({
|
|
1230
1296
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1231
1297
|
$isConst$: !1
|
|
1232
1298
|
});
|
|
@@ -1238,12 +1304,12 @@
|
|
|
1238
1304
|
};
|
|
1239
1305
|
const recordJsxEvent = (key, value) => {
|
|
1240
1306
|
const eventName = getEventNameFromJsxProp(key);
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1307
|
+
const scope = getEventNameScopeFromJsxProp(key);
|
|
1308
|
+
if (eventName && (record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)),
|
|
1309
|
+
scope) {
|
|
1310
|
+
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1311
|
+
htmlEvent && record(htmlEvent, "");
|
|
1244
1312
|
}
|
|
1245
|
-
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1246
|
-
htmlEvent && record(htmlEvent, ""), eventName && registerQwikLoaderEvent(eventName);
|
|
1247
1313
|
};
|
|
1248
1314
|
for (;null !== srcKey || null !== dstKey; ) {
|
|
1249
1315
|
if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
|
|
@@ -1275,7 +1341,7 @@
|
|
|
1275
1341
|
let returnValue = !1;
|
|
1276
1342
|
return qrls.flat(2).forEach((qrl => {
|
|
1277
1343
|
if (qrl) {
|
|
1278
|
-
const value = qrl
|
|
1344
|
+
const value = container.$scheduler$(ChoreType.RUN_QRL, vNode, qrl, [ event, element ]);
|
|
1279
1345
|
returnValue = returnValue || !0 === value;
|
|
1280
1346
|
}
|
|
1281
1347
|
})), returnValue;
|
|
@@ -1324,16 +1390,16 @@
|
|
|
1324
1390
|
const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
|
|
1325
1391
|
const lookupKey = jsxNode.key || componentHash;
|
|
1326
1392
|
if (lookupKey === (getKey(host) || vNodeComponentHash) ? componentHash === vNodeComponentHash || (insertNewComponent(host, componentQRL, jsxProps),
|
|
1327
|
-
vNewNode && (host
|
|
1328
|
-
|
|
1393
|
+
vNewNode && (host = vNewNode, shouldRender = !0)) : (vNewNode = retrieveChildWithKey(null, lookupKey),
|
|
1394
|
+
vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps),
|
|
1329
1395
|
host = vNewNode, shouldRender = !0), host) {
|
|
1330
1396
|
const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
|
|
1331
1397
|
shouldRender = shouldRender || function(src, dst) {
|
|
1332
1398
|
if (!src || !dst) {
|
|
1333
1399
|
return !0;
|
|
1334
1400
|
}
|
|
1335
|
-
let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:
|
|
1336
|
-
let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:
|
|
1401
|
+
let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:brefs" ]);
|
|
1402
|
+
let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:brefs" ]);
|
|
1337
1403
|
if (srcKeys.length !== dstKeys.length) {
|
|
1338
1404
|
return !0;
|
|
1339
1405
|
}
|
|
@@ -1354,8 +1420,9 @@
|
|
|
1354
1420
|
const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
|
|
1355
1421
|
const projections = [];
|
|
1356
1422
|
if (host) {
|
|
1357
|
-
|
|
1358
|
-
|
|
1423
|
+
const props = vnode_getProps(host);
|
|
1424
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
1425
|
+
const prop = props[i];
|
|
1359
1426
|
if (isSlotProp(prop)) {
|
|
1360
1427
|
const slotName = prop;
|
|
1361
1428
|
projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
|
|
@@ -1396,7 +1463,7 @@
|
|
|
1396
1463
|
}
|
|
1397
1464
|
}
|
|
1398
1465
|
function insertNewComponent(host, componentQRL, jsxProps) {
|
|
1399
|
-
host &&
|
|
1466
|
+
host && clearAllEffects(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1400
1467
|
const jsxNode = jsxValue;
|
|
1401
1468
|
build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
|
|
1402
1469
|
container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
|
|
@@ -1437,22 +1504,21 @@
|
|
|
1437
1504
|
for (;;) {
|
|
1438
1505
|
const type = vCursor[VNodeProps.flags];
|
|
1439
1506
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
1440
|
-
if (
|
|
1441
|
-
type & VNodeFlags.Virtual) {
|
|
1507
|
+
if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), type & VNodeFlags.Virtual) {
|
|
1442
1508
|
const seq = container.getHostProp(vCursor, "q:seq");
|
|
1443
1509
|
if (seq) {
|
|
1444
1510
|
for (let i = 0; i < seq.length; i++) {
|
|
1445
1511
|
const obj = seq[i];
|
|
1446
1512
|
if (isTask(obj)) {
|
|
1447
1513
|
const task = obj;
|
|
1448
|
-
|
|
1514
|
+
clearAllEffects(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
|
|
1449
1515
|
}
|
|
1450
1516
|
}
|
|
1451
1517
|
}
|
|
1452
1518
|
}
|
|
1453
1519
|
if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, "q:renderFn", null)) {
|
|
1454
|
-
const attrs = vCursor;
|
|
1455
|
-
for (let i =
|
|
1520
|
+
const attrs = vnode_getProps(vCursor);
|
|
1521
|
+
for (let i = 0; i < attrs.length; i += 2) {
|
|
1456
1522
|
const key = attrs[i];
|
|
1457
1523
|
if (!key.startsWith(":") && isSlotProp(key)) {
|
|
1458
1524
|
const value = attrs[i + 1];
|
|
@@ -1524,33 +1590,117 @@
|
|
|
1524
1590
|
SiblingsArray[SiblingsArray.VNode = 2] = "VNode", SiblingsArray[SiblingsArray.Size = 3] = "Size",
|
|
1525
1591
|
SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
|
|
1526
1592
|
}(SiblingsArray || (SiblingsArray = {}));
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1593
|
+
const useResourceQrl = (qrl, opts) => {
|
|
1594
|
+
const {val, set, i, iCtx} = useSequentialScope();
|
|
1595
|
+
if (null != val) {
|
|
1596
|
+
return val;
|
|
1597
|
+
}
|
|
1598
|
+
assertQrl(qrl);
|
|
1599
|
+
const container = iCtx.$container$;
|
|
1600
|
+
const resource = createResourceReturn(container, opts);
|
|
1601
|
+
const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
|
|
1602
|
+
return container.$scheduler$(ChoreType.TASK, task), set(resource), resource;
|
|
1529
1603
|
};
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1532
|
-
|
|
1604
|
+
const createResourceReturn = (container, opts, initialPromise) => {
|
|
1605
|
+
const result = (opts => ({
|
|
1606
|
+
__brand: "resource",
|
|
1607
|
+
value: void 0,
|
|
1608
|
+
loading: !isServerPlatform(),
|
|
1609
|
+
_resolved: void 0,
|
|
1610
|
+
_error: void 0,
|
|
1611
|
+
_state: "pending",
|
|
1612
|
+
_timeout: opts?.timeout ?? -1,
|
|
1613
|
+
_cache: 0
|
|
1614
|
+
}))(opts);
|
|
1615
|
+
return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
|
|
1616
|
+
};
|
|
1617
|
+
const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
|
|
1618
|
+
const runResource = (task, container, host) => {
|
|
1619
|
+
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
1620
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
1621
|
+
iCtx.$container$ = container;
|
|
1622
|
+
const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
|
|
1623
|
+
const resource = task.$state$;
|
|
1624
|
+
assertDefined();
|
|
1625
|
+
const cleanups = [];
|
|
1626
|
+
task.$destroy$ = noSerialize((() => {
|
|
1627
|
+
cleanups.forEach((fn => {
|
|
1628
|
+
try {
|
|
1629
|
+
fn();
|
|
1630
|
+
} catch (err) {
|
|
1631
|
+
container.handleError(err, host);
|
|
1632
|
+
}
|
|
1633
|
+
})), done = !0;
|
|
1634
|
+
}));
|
|
1635
|
+
const resourceTarget = unwrapStore(resource);
|
|
1636
|
+
const opts = {
|
|
1637
|
+
track: (obj, prop) => {
|
|
1638
|
+
const ctx = newInvokeContext();
|
|
1639
|
+
return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
|
|
1640
|
+
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
1641
|
+
},
|
|
1642
|
+
cleanup(fn) {
|
|
1643
|
+
"function" == typeof fn && cleanups.push(fn);
|
|
1644
|
+
},
|
|
1645
|
+
cache(policy) {
|
|
1646
|
+
let milliseconds = 0;
|
|
1647
|
+
milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
|
|
1648
|
+
},
|
|
1649
|
+
previous: resourceTarget._resolved
|
|
1650
|
+
};
|
|
1651
|
+
let resolve;
|
|
1652
|
+
let reject;
|
|
1653
|
+
let done = !1;
|
|
1654
|
+
const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
|
|
1655
|
+
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
1656
|
+
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
1657
|
+
resource._error = value, reject(value)), !0);
|
|
1658
|
+
cleanups.push((() => {
|
|
1659
|
+
if (!0 === untrack((() => resource.loading))) {
|
|
1660
|
+
const value = untrack((() => resource._resolved));
|
|
1661
|
+
setState(!0, value);
|
|
1662
|
+
}
|
|
1663
|
+
})), invoke(iCtx, (() => {
|
|
1664
|
+
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
1665
|
+
(resource.value = new Promise(((r, re) => {
|
|
1666
|
+
resolve = r, reject = re;
|
|
1667
|
+
}))).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
1668
|
+
}));
|
|
1669
|
+
const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
|
|
1670
|
+
setState(!0, value);
|
|
1671
|
+
}), (err => {
|
|
1672
|
+
if (isPromise(err)) {
|
|
1673
|
+
return err.then((() => runResource(task, container, host)));
|
|
1674
|
+
}
|
|
1675
|
+
setState(!1, err);
|
|
1676
|
+
}));
|
|
1677
|
+
const timeout = resourceTarget._timeout;
|
|
1678
|
+
return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
|
|
1679
|
+
setState(!1, new Error("timeout")) && cleanupTask(task);
|
|
1680
|
+
})) ]) : promise;
|
|
1681
|
+
};
|
|
1682
|
+
const ignoreErrorToPreventNodeFromCrashing = () => {};
|
|
1533
1683
|
const aVNodePath = [];
|
|
1534
1684
|
const bVNodePath = [];
|
|
1535
1685
|
const aSsrNodePath = [];
|
|
1536
1686
|
const bSsrNodePath = [];
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RESOURCE = 2] = "RESOURCE",
|
|
1541
|
-
ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
|
|
1542
|
-
ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
|
|
1543
|
-
ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
|
|
1544
|
-
ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
|
|
1545
|
-
ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
|
|
1546
|
-
}(ChoreType || (ChoreType = {}));
|
|
1687
|
+
const getPromise = chore => chore.$promise$ ||= new Promise((resolve => {
|
|
1688
|
+
chore.$resolve$ = resolve;
|
|
1689
|
+
}));
|
|
1547
1690
|
const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
1548
1691
|
const choreQueue = [];
|
|
1692
|
+
const qrlRuns = [];
|
|
1549
1693
|
let currentChore = null;
|
|
1550
|
-
let
|
|
1694
|
+
let drainScheduled = !1;
|
|
1551
1695
|
return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
|
|
1552
|
-
const
|
|
1553
|
-
const
|
|
1696
|
+
const isServer = !isDomContainer(container);
|
|
1697
|
+
const isComponentSsr = isServer && type === ChoreType.COMPONENT;
|
|
1698
|
+
const runLater = type !== ChoreType.WAIT_FOR_ALL && !isComponentSsr && type !== ChoreType.RUN_QRL;
|
|
1699
|
+
const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
|
|
1700
|
+
const isClientOnly = type === ChoreType.JOURNAL_FLUSH || type === ChoreType.NODE_DIFF || type === ChoreType.NODE_PROP;
|
|
1701
|
+
if (isServer && isClientOnly) {
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1554
1704
|
isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
|
|
1555
1705
|
let chore = {
|
|
1556
1706
|
$type$: type,
|
|
@@ -1563,7 +1713,7 @@
|
|
|
1563
1713
|
$returnValue$: null,
|
|
1564
1714
|
$executed$: !1
|
|
1565
1715
|
};
|
|
1566
|
-
chore
|
|
1716
|
+
chore = function(sortedArray, value, rootVNode) {
|
|
1567
1717
|
const idx = function(sortedArray, value, rootVNode) {
|
|
1568
1718
|
let bottom = 0;
|
|
1569
1719
|
let top = sortedArray.length;
|
|
@@ -1585,129 +1735,156 @@
|
|
|
1585
1735
|
return sortedArray.splice(~idx, 0, value), value;
|
|
1586
1736
|
}
|
|
1587
1737
|
const existing = sortedArray[idx];
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1738
|
+
existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = value.$payload$);
|
|
1739
|
+
existing.$executed$ && (existing.$executed$ = !1);
|
|
1740
|
+
return existing;
|
|
1741
|
+
}(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
|
|
1742
|
+
schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain()?.catch?.((() => {})));
|
|
1743
|
+
return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
|
|
1592
1744
|
};
|
|
1593
|
-
function drainUpTo(runUptoChore,
|
|
1594
|
-
|
|
1595
|
-
return runUptoChore.$returnValue$;
|
|
1596
|
-
}
|
|
1597
|
-
if (currentChore) {
|
|
1598
|
-
return runUptoChore.$promise$;
|
|
1599
|
-
}
|
|
1745
|
+
function drainUpTo(runUptoChore, isServer) {
|
|
1746
|
+
let maxRetries = 5e3;
|
|
1600
1747
|
for (;choreQueue.length; ) {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
if (null === order) {
|
|
1604
|
-
continue;
|
|
1748
|
+
if (maxRetries-- < 0) {
|
|
1749
|
+
throw new Error("drainUpTo: max retries reached");
|
|
1605
1750
|
}
|
|
1606
|
-
if (
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
continue;
|
|
1751
|
+
if (currentChore) {
|
|
1752
|
+
return getPromise(currentChore).then((() => drainUpTo(runUptoChore, isServer))).catch((e => {
|
|
1753
|
+
container.handleError(e, currentChore?.$host$);
|
|
1754
|
+
}));
|
|
1611
1755
|
}
|
|
1612
|
-
const
|
|
1613
|
-
if (
|
|
1614
|
-
|
|
1756
|
+
const nextChore = choreQueue[0];
|
|
1757
|
+
if (nextChore.$executed$) {
|
|
1758
|
+
if (choreQueue.shift(), nextChore === runUptoChore) {
|
|
1759
|
+
break;
|
|
1760
|
+
}
|
|
1761
|
+
} else {
|
|
1762
|
+
(chore = nextChore).$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE ? choreQueue.shift() : executeChore(nextChore, isServer);
|
|
1615
1763
|
}
|
|
1616
1764
|
}
|
|
1617
1765
|
var chore;
|
|
1618
1766
|
return runUptoChore.$returnValue$;
|
|
1619
1767
|
}
|
|
1620
|
-
function executeChore(chore) {
|
|
1768
|
+
function executeChore(chore, isServer) {
|
|
1621
1769
|
const host = chore.$host$;
|
|
1622
1770
|
assertEqual(), currentChore = chore;
|
|
1623
1771
|
let returnValue = null;
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1772
|
+
try {
|
|
1773
|
+
switch (chore.$type$) {
|
|
1774
|
+
case ChoreType.WAIT_FOR_ALL:
|
|
1775
|
+
isServer && (drainScheduled = !1);
|
|
1776
|
+
break;
|
|
1628
1777
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
if (chore.$type$ === ChoreType.COMPONENT) {
|
|
1633
|
-
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
1634
|
-
return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
|
|
1635
|
-
}
|
|
1636
|
-
return jsx;
|
|
1637
|
-
}), (err => container.handleError(err, host)));
|
|
1638
|
-
break;
|
|
1778
|
+
case ChoreType.JOURNAL_FLUSH:
|
|
1779
|
+
returnValue = journalFlush(), drainScheduled = !1;
|
|
1780
|
+
break;
|
|
1639
1781
|
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1782
|
+
case ChoreType.COMPONENT:
|
|
1783
|
+
returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
|
|
1784
|
+
if (isServer) {
|
|
1785
|
+
return jsx;
|
|
1786
|
+
}
|
|
1787
|
+
{
|
|
1788
|
+
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
1789
|
+
return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
|
|
1790
|
+
}
|
|
1791
|
+
}), (err => container.handleError(err, host)));
|
|
1792
|
+
break;
|
|
1644
1793
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1794
|
+
case ChoreType.RUN_QRL:
|
|
1795
|
+
{
|
|
1796
|
+
const fn = chore.$target$.getFn();
|
|
1797
|
+
const result = retryOnPromise((() => fn(...chore.$payload$)));
|
|
1798
|
+
if (isPromise(result)) {
|
|
1799
|
+
const handled = result.finally((() => {
|
|
1800
|
+
qrlRuns.splice(qrlRuns.indexOf(handled), 1);
|
|
1801
|
+
})).catch((error => {
|
|
1802
|
+
container.handleError(error, chore.$host$);
|
|
1803
|
+
}));
|
|
1804
|
+
return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
|
|
1805
|
+
currentChore = null, void (chore.$executed$ = !0);
|
|
1806
|
+
}
|
|
1807
|
+
returnValue = null;
|
|
1808
|
+
}
|
|
1809
|
+
break;
|
|
1649
1810
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1811
|
+
case ChoreType.TASK:
|
|
1812
|
+
case ChoreType.VISIBLE:
|
|
1813
|
+
{
|
|
1814
|
+
const payload = chore.$payload$;
|
|
1815
|
+
if (payload.$flags$ & TaskFlags.RESOURCE) {
|
|
1816
|
+
const result = runResource(payload, container, host);
|
|
1817
|
+
returnValue = isServer ? result : null;
|
|
1818
|
+
} else {
|
|
1819
|
+
returnValue = runTask(payload, container, host);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
break;
|
|
1653
1823
|
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
|
|
1658
|
-
break;
|
|
1824
|
+
case ChoreType.CLEANUP_VISIBLE:
|
|
1825
|
+
cleanupTask(chore.$payload$);
|
|
1826
|
+
break;
|
|
1659
1827
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
const property = chore.$idx$;
|
|
1668
|
-
const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
|
|
1669
|
-
if (isConst) {
|
|
1670
|
-
journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
|
|
1671
|
-
} else {
|
|
1672
|
-
vnode_setAttr(journal, virtualNode, property, serializedValue);
|
|
1673
|
-
}
|
|
1674
|
-
break;
|
|
1828
|
+
case ChoreType.NODE_DIFF:
|
|
1829
|
+
{
|
|
1830
|
+
const parentVirtualNode = chore.$target$;
|
|
1831
|
+
let jsx = chore.$payload$;
|
|
1832
|
+
isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
|
|
1833
|
+
}
|
|
1834
|
+
break;
|
|
1675
1835
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1836
|
+
case ChoreType.NODE_PROP:
|
|
1837
|
+
{
|
|
1838
|
+
const virtualNode = chore.$host$;
|
|
1839
|
+
const payload = chore.$payload$;
|
|
1840
|
+
let value = payload.$value$;
|
|
1841
|
+
isSignal(value) && (value = value.value);
|
|
1842
|
+
const isConst = payload.$isConst$;
|
|
1843
|
+
const journal = container.$journal$;
|
|
1844
|
+
const property = chore.$idx$;
|
|
1845
|
+
const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
|
|
1846
|
+
if (isConst) {
|
|
1847
|
+
journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
|
|
1848
|
+
} else {
|
|
1849
|
+
vnode_setAttr(journal, virtualNode, property, serializedValue);
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1680
1852
|
break;
|
|
1681
|
-
}
|
|
1682
1853
|
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
if (target.$forceRunEffects$ = !1, !target.$effects$?.length) {
|
|
1688
|
-
break;
|
|
1854
|
+
case ChoreType.QRL_RESOLVE:
|
|
1855
|
+
{
|
|
1856
|
+
const target = chore.$target$;
|
|
1857
|
+
returnValue = target.resolved ? null : target.resolve();
|
|
1689
1858
|
}
|
|
1690
|
-
returnValue = retryOnPromise((() => {
|
|
1691
|
-
(target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
|
|
1692
|
-
}));
|
|
1693
1859
|
break;
|
|
1860
|
+
|
|
1861
|
+
case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
|
|
1862
|
+
{
|
|
1863
|
+
const target = chore.$target$;
|
|
1864
|
+
const forceRunEffects = target.$forceRunEffects$;
|
|
1865
|
+
if (target.$forceRunEffects$ = !1, !target.$effects$?.size) {
|
|
1866
|
+
break;
|
|
1867
|
+
}
|
|
1868
|
+
returnValue = retryOnPromise((() => {
|
|
1869
|
+
(target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
|
|
1870
|
+
}));
|
|
1871
|
+
}
|
|
1694
1872
|
}
|
|
1873
|
+
} catch (e) {
|
|
1874
|
+
returnValue = Promise.reject(e);
|
|
1695
1875
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
const choreUpdate = (existing, newChore) => {
|
|
1703
|
-
existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = newChore.$payload$);
|
|
1704
|
-
};
|
|
1705
|
-
function choreComparator(a, b, rootVNode) {
|
|
1706
|
-
const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
|
|
1707
|
-
if (0 !== macroTypeDiff) {
|
|
1708
|
-
return macroTypeDiff;
|
|
1876
|
+
const after = (value, error) => {
|
|
1877
|
+
currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
|
|
1878
|
+
chore.$resolve$?.(value));
|
|
1879
|
+
};
|
|
1880
|
+
isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error => after(void 0, error))),
|
|
1881
|
+
chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
|
|
1709
1882
|
}
|
|
1710
|
-
|
|
1883
|
+
function choreComparator(a, b, rootVNode) {
|
|
1884
|
+
const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
|
|
1885
|
+
if (0 !== macroTypeDiff) {
|
|
1886
|
+
return macroTypeDiff;
|
|
1887
|
+
}
|
|
1711
1888
|
const aHost = a.$host$;
|
|
1712
1889
|
const bHost = b.$host$;
|
|
1713
1890
|
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
@@ -1748,6 +1925,7 @@
|
|
|
1748
1925
|
return hostDiff;
|
|
1749
1926
|
}
|
|
1750
1927
|
} else {
|
|
1928
|
+
assertFalse(vnode_isVNode(aHost)), assertFalse(vnode_isVNode(bHost));
|
|
1751
1929
|
const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
|
|
1752
1930
|
logWarn(errorMessage);
|
|
1753
1931
|
const hostDiff = ((a, b) => {
|
|
@@ -1780,134 +1958,28 @@
|
|
|
1780
1958
|
return microTypeDiff;
|
|
1781
1959
|
}
|
|
1782
1960
|
const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
|
|
1783
|
-
|
|
1784
|
-
return idxDiff;
|
|
1785
|
-
}
|
|
1786
|
-
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)) {
|
|
1787
|
-
return 1;
|
|
1788
|
-
}
|
|
1789
|
-
}
|
|
1790
|
-
return 0;
|
|
1791
|
-
}
|
|
1792
|
-
const useLexicalScope = () => {
|
|
1793
|
-
const context = getInvokeContext();
|
|
1794
|
-
let qrl = context.$qrl$;
|
|
1795
|
-
if (qrl) {
|
|
1796
|
-
assertQrl(qrl), assertDefined();
|
|
1797
|
-
} else {
|
|
1798
|
-
const el = context.$element$;
|
|
1799
|
-
assertDefined();
|
|
1800
|
-
const containerElement = _getQContainerElement(el);
|
|
1801
|
-
assertDefined();
|
|
1802
|
-
qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
|
|
1803
|
-
}
|
|
1804
|
-
return qrl.$captureRef$;
|
|
1805
|
-
};
|
|
1806
|
-
var TaskFlags;
|
|
1807
|
-
!function(TaskFlags) {
|
|
1808
|
-
TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
|
|
1809
|
-
TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
|
|
1810
|
-
}(TaskFlags || (TaskFlags = {}));
|
|
1811
|
-
const useTaskQrl = (qrl, opts) => {
|
|
1812
|
-
const {val, set, iCtx, i} = useSequentialScope();
|
|
1813
|
-
if (val) {
|
|
1814
|
-
return;
|
|
1815
|
-
}
|
|
1816
|
-
assertQrl(qrl), set(1);
|
|
1817
|
-
const host = iCtx.$hostElement$;
|
|
1818
|
-
const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
1819
|
-
set(task);
|
|
1820
|
-
const result = runTask(task, iCtx.$container$, host);
|
|
1821
|
-
if (isPromise(result)) {
|
|
1822
|
-
throw result;
|
|
1823
|
-
}
|
|
1824
|
-
qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
|
|
1825
|
-
};
|
|
1826
|
-
const runTask = (task, container, host) => {
|
|
1827
|
-
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
1828
|
-
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
1829
|
-
iCtx.$container$ = container;
|
|
1830
|
-
const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
|
|
1831
|
-
const handleError = reason => container.handleError(reason, host);
|
|
1832
|
-
let cleanupFns = null;
|
|
1833
|
-
const cleanup = fn => {
|
|
1834
|
-
"function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
|
|
1835
|
-
task.$destroy$ = null, cleanupFns.forEach((fn => {
|
|
1836
|
-
try {
|
|
1837
|
-
fn();
|
|
1838
|
-
} catch (err) {
|
|
1839
|
-
handleError(err);
|
|
1840
|
-
}
|
|
1841
|
-
}));
|
|
1842
|
-
}))), cleanupFns.push(fn));
|
|
1843
|
-
};
|
|
1844
|
-
const taskApi = {
|
|
1845
|
-
track: (obj, prop) => {
|
|
1846
|
-
const ctx = newInvokeContext();
|
|
1847
|
-
return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
|
|
1848
|
-
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
1849
|
-
},
|
|
1850
|
-
cleanup
|
|
1851
|
-
};
|
|
1852
|
-
return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
|
|
1853
|
-
};
|
|
1854
|
-
const cleanupTask = task => {
|
|
1855
|
-
const destroy = task.$destroy$;
|
|
1856
|
-
if (destroy) {
|
|
1857
|
-
task.$destroy$ = null;
|
|
1858
|
-
try {
|
|
1859
|
-
destroy();
|
|
1860
|
-
} catch (err) {
|
|
1861
|
-
((message, ...optionalParams) => {
|
|
1862
|
-
createAndLogError(!1, message, ...optionalParams);
|
|
1863
|
-
})(err);
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
|
-
};
|
|
1867
|
-
const useRunTask = (task, eagerness) => {
|
|
1868
|
-
"visible" === eagerness || "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "load" === eagerness || "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "idle" !== eagerness && "document-idle" !== eagerness || useOnDocument("qidle", getTaskHandlerQrl(task));
|
|
1869
|
-
};
|
|
1870
|
-
const getTaskHandlerQrl = task => {
|
|
1871
|
-
const taskQrl = task.$qrl$;
|
|
1872
|
-
const taskHandler = createQRL(taskQrl.$chunk$, "_hW", _hW, null, null, [ task ], taskQrl.$symbol$);
|
|
1873
|
-
return taskQrl.dev && (taskHandler.dev = taskQrl.dev), taskHandler;
|
|
1874
|
-
};
|
|
1875
|
-
class Task extends Subscriber {
|
|
1876
|
-
$flags$;
|
|
1877
|
-
$index$;
|
|
1878
|
-
$el$;
|
|
1879
|
-
$qrl$;
|
|
1880
|
-
$state$;
|
|
1881
|
-
$destroy$;
|
|
1882
|
-
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
1883
|
-
super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
|
|
1884
|
-
this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
1961
|
+
return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
|
|
1885
1962
|
}
|
|
1886
|
-
}
|
|
1887
|
-
const isTask = value => value instanceof Task;
|
|
1888
|
-
const _hW = () => {
|
|
1889
|
-
const [task] = useLexicalScope();
|
|
1890
|
-
getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
|
|
1891
1963
|
};
|
|
1892
|
-
const
|
|
1964
|
+
const toNumber = value => "number" == typeof value ? value : -1;
|
|
1893
1965
|
const throwIfQRLNotResolved = qrl => {
|
|
1894
1966
|
if (!qrl.resolved) {
|
|
1895
1967
|
throw qrl.resolve();
|
|
1896
1968
|
}
|
|
1897
1969
|
};
|
|
1898
1970
|
const isSignal = value => value instanceof Signal;
|
|
1899
|
-
class
|
|
1971
|
+
class SubscriptionData {
|
|
1900
1972
|
data;
|
|
1901
1973
|
constructor(data) {
|
|
1902
1974
|
this.data = data;
|
|
1903
1975
|
}
|
|
1904
1976
|
}
|
|
1905
|
-
var
|
|
1977
|
+
var EffectSubscriptionProp;
|
|
1906
1978
|
var EffectProperty;
|
|
1907
|
-
!function(
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
}(
|
|
1979
|
+
!function(EffectSubscriptionProp) {
|
|
1980
|
+
EffectSubscriptionProp[EffectSubscriptionProp.CONSUMER = 0] = "CONSUMER", EffectSubscriptionProp[EffectSubscriptionProp.PROPERTY = 1] = "PROPERTY",
|
|
1981
|
+
EffectSubscriptionProp[EffectSubscriptionProp.BACK_REF = 2] = "BACK_REF", EffectSubscriptionProp[EffectSubscriptionProp.DATA = 3] = "DATA";
|
|
1982
|
+
}(EffectSubscriptionProp || (EffectSubscriptionProp = {})), function(EffectProperty) {
|
|
1911
1983
|
EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
|
|
1912
1984
|
}(EffectProperty || (EffectProperty = {}));
|
|
1913
1985
|
class Signal {
|
|
@@ -1936,9 +2008,9 @@
|
|
|
1936
2008
|
}
|
|
1937
2009
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1938
2010
|
if (effectSubscriber) {
|
|
1939
|
-
const effects = this.$effects$ ||=
|
|
1940
|
-
|
|
1941
|
-
|
|
2011
|
+
const effects = this.$effects$ ||= new Set;
|
|
2012
|
+
ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this),
|
|
2013
|
+
addQrlToSerializationCtx(effectSubscriber, this.$container$);
|
|
1942
2014
|
}
|
|
1943
2015
|
}
|
|
1944
2016
|
return this.untrackedValue;
|
|
@@ -1950,7 +2022,7 @@
|
|
|
1950
2022
|
qDev;
|
|
1951
2023
|
}
|
|
1952
2024
|
toString() {
|
|
1953
|
-
return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects
|
|
2025
|
+
return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
|
|
1954
2026
|
}
|
|
1955
2027
|
toJSON() {
|
|
1956
2028
|
return {
|
|
@@ -1958,80 +2030,58 @@
|
|
|
1958
2030
|
};
|
|
1959
2031
|
}
|
|
1960
2032
|
}
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1963
|
-
};
|
|
1964
|
-
const ensureContainsEffect = (array, effectSubscriptions) => {
|
|
1965
|
-
for (let i = 0; i < array.length; i++) {
|
|
1966
|
-
const existingEffect = array[i];
|
|
1967
|
-
if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
|
|
1968
|
-
return;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
array.push(effectSubscriptions);
|
|
2033
|
+
const ensureContainsSubscription = (array, effectSubscription) => {
|
|
2034
|
+
array.add(effectSubscription);
|
|
1972
2035
|
};
|
|
1973
|
-
const
|
|
1974
|
-
|
|
1975
|
-
if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
|
|
1976
|
-
return;
|
|
1977
|
-
}
|
|
1978
|
-
effect.$effectDependencies$.push(subscriber);
|
|
1979
|
-
} else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
|
|
1980
|
-
let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
|
|
1981
|
-
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
1982
|
-
return;
|
|
1983
|
-
}
|
|
1984
|
-
subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
|
|
1985
|
-
} else if (isSSRNode(effect)) {
|
|
1986
|
-
let subscribers = effect.getProp("q:subs");
|
|
1987
|
-
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
1988
|
-
return;
|
|
1989
|
-
}
|
|
1990
|
-
subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
|
|
1991
|
-
}
|
|
2036
|
+
const ensureContainsBackRef = (array, value) => {
|
|
2037
|
+
array[EffectSubscriptionProp.BACK_REF] ||= new Set, array[EffectSubscriptionProp.BACK_REF].add(value);
|
|
1992
2038
|
};
|
|
1993
|
-
const
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
2039
|
+
const addQrlToSerializationCtx = (effectSubscriber, container) => {
|
|
2040
|
+
if (container && !isDomContainer(container)) {
|
|
2041
|
+
const effect = effectSubscriber[EffectSubscriptionProp.CONSUMER];
|
|
2042
|
+
const property = effectSubscriber[EffectSubscriptionProp.PROPERTY];
|
|
2043
|
+
let qrl = null;
|
|
2044
|
+
isTask(effect) ? qrl = effect.$qrl$ : effect instanceof ComputedSignal ? qrl = effect.$computeQrl$ : property === EffectProperty.COMPONENT && (qrl = container.getHostProp(effect, "q:renderFn")),
|
|
2045
|
+
qrl && container.serializationCtx.$eventQrls$.add(qrl);
|
|
1999
2046
|
}
|
|
2000
|
-
return !1;
|
|
2001
2047
|
};
|
|
2002
2048
|
const triggerEffects = (container, signal, effects) => {
|
|
2049
|
+
const isBrowser = isDomContainer(container);
|
|
2003
2050
|
if (effects) {
|
|
2004
|
-
const scheduleEffect =
|
|
2005
|
-
const
|
|
2006
|
-
const property =
|
|
2007
|
-
if (assertDefined(), isTask(
|
|
2008
|
-
|
|
2051
|
+
const scheduleEffect = effectSubscription => {
|
|
2052
|
+
const consumer = effectSubscription[EffectSubscriptionProp.CONSUMER];
|
|
2053
|
+
const property = effectSubscription[EffectSubscriptionProp.PROPERTY];
|
|
2054
|
+
if (assertDefined(), isTask(consumer)) {
|
|
2055
|
+
consumer.$flags$ |= TaskFlags.DIRTY;
|
|
2009
2056
|
let choreType = ChoreType.TASK;
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
effect.$invalidate$();
|
|
2057
|
+
consumer.$flags$ & TaskFlags.VISIBLE_TASK && (choreType = ChoreType.VISIBLE), container.$scheduler$(choreType, consumer);
|
|
2058
|
+
} else if (consumer instanceof Signal) {
|
|
2059
|
+
consumer instanceof ComputedSignal && (consumer.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, consumer.$computeQrl$)),
|
|
2060
|
+
consumer.$invalidate$();
|
|
2015
2061
|
} else if (property === EffectProperty.COMPONENT) {
|
|
2016
|
-
const host =
|
|
2062
|
+
const host = consumer;
|
|
2017
2063
|
const qrl = container.getHostProp(host, "q:renderFn");
|
|
2018
2064
|
assertDefined();
|
|
2019
2065
|
const props = container.getHostProp(host, "q:props");
|
|
2020
2066
|
container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
|
|
2021
|
-
} else if (
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2067
|
+
} else if (isBrowser) {
|
|
2068
|
+
if (property === EffectProperty.VNODE) {
|
|
2069
|
+
container.$scheduler$(ChoreType.NODE_DIFF, consumer, consumer, signal);
|
|
2070
|
+
} else {
|
|
2071
|
+
const effectData = effectSubscription[EffectSubscriptionProp.DATA];
|
|
2072
|
+
if (effectData instanceof SubscriptionData) {
|
|
2073
|
+
const payload = {
|
|
2074
|
+
...effectData.data,
|
|
2075
|
+
$value$: signal
|
|
2076
|
+
};
|
|
2077
|
+
container.$scheduler$(ChoreType.NODE_PROP, consumer, property, payload);
|
|
2078
|
+
}
|
|
2031
2079
|
}
|
|
2032
2080
|
}
|
|
2033
2081
|
};
|
|
2034
|
-
effects
|
|
2082
|
+
for (const effect of effects) {
|
|
2083
|
+
scheduleEffect(effect);
|
|
2084
|
+
}
|
|
2035
2085
|
}
|
|
2036
2086
|
};
|
|
2037
2087
|
class ComputedSignal extends Signal {
|
|
@@ -2059,7 +2109,7 @@
|
|
|
2059
2109
|
throwIfQRLNotResolved(computeQrl);
|
|
2060
2110
|
const ctx = tryGetInvokeContext();
|
|
2061
2111
|
const previousEffectSubscription = ctx?.$effectSubscriber$;
|
|
2062
|
-
ctx && (ctx.$effectSubscriber$ =
|
|
2112
|
+
ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
|
|
2063
2113
|
try {
|
|
2064
2114
|
const untrackedValue = computeQrl.getFn(ctx)();
|
|
2065
2115
|
if (isPromise(untrackedValue)) {
|
|
@@ -2084,9 +2134,9 @@
|
|
|
2084
2134
|
$func$;
|
|
2085
2135
|
$funcStr$;
|
|
2086
2136
|
$invalid$=!0;
|
|
2087
|
-
$effectDependencies$=null;
|
|
2088
2137
|
$hostElement$=null;
|
|
2089
2138
|
$forceRunEffects$=!1;
|
|
2139
|
+
[_EFFECT_BACK_REF]=null;
|
|
2090
2140
|
constructor(container, fn, args, fnStr) {
|
|
2091
2141
|
super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
|
|
2092
2142
|
}
|
|
@@ -2122,18 +2172,10 @@
|
|
|
2122
2172
|
this.$scopedStyle$ = $scopedStyle$, this.$componentFrame$ = $componentFrame$;
|
|
2123
2173
|
}
|
|
2124
2174
|
}
|
|
2125
|
-
function _walkJSX(ssr, value, options) {
|
|
2175
|
+
async function _walkJSX(ssr, value, options) {
|
|
2126
2176
|
const stack = [ value ];
|
|
2127
|
-
let resolveDrain;
|
|
2128
|
-
let rejectDrain;
|
|
2129
|
-
const drained = options.allowPromises && new Promise(((res, rej) => {
|
|
2130
|
-
resolveDrain = res, rejectDrain = rej;
|
|
2131
|
-
}));
|
|
2132
2177
|
const enqueue = value => stack.push(value);
|
|
2133
|
-
|
|
2134
|
-
stack.push(value), drain();
|
|
2135
|
-
};
|
|
2136
|
-
const drain = () => {
|
|
2178
|
+
await (async () => {
|
|
2137
2179
|
for (;stack.length; ) {
|
|
2138
2180
|
const value = stack.pop();
|
|
2139
2181
|
if (value instanceof ParentComponentData) {
|
|
@@ -2145,23 +2187,13 @@
|
|
|
2145
2187
|
});
|
|
2146
2188
|
} else {
|
|
2147
2189
|
if (value === Promise) {
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
}
|
|
2151
|
-
return void stack.pop().then(resolveValue, rejectDrain);
|
|
2152
|
-
}
|
|
2153
|
-
const waitOn = value.apply(ssr);
|
|
2154
|
-
if (waitOn) {
|
|
2155
|
-
if (!options.allowPromises) {
|
|
2156
|
-
throw qError(QError.promisesNotExpected);
|
|
2157
|
-
}
|
|
2158
|
-
return void waitOn.then(drain, rejectDrain);
|
|
2190
|
+
stack.push(await stack.pop());
|
|
2191
|
+
continue;
|
|
2159
2192
|
}
|
|
2193
|
+
await value.apply(ssr);
|
|
2160
2194
|
}
|
|
2161
2195
|
}
|
|
2162
|
-
|
|
2163
|
-
};
|
|
2164
|
-
return drain(), drained;
|
|
2196
|
+
})();
|
|
2165
2197
|
}
|
|
2166
2198
|
function processJSXNode(ssr, enqueue, value, options) {
|
|
2167
2199
|
if (null == value) {
|
|
@@ -2190,7 +2222,6 @@
|
|
|
2190
2222
|
enqueue((async () => {
|
|
2191
2223
|
for await (const chunk of value) {
|
|
2192
2224
|
await _walkJSX(ssr, chunk, {
|
|
2193
|
-
allowPromises: !0,
|
|
2194
2225
|
currentStyleScoped: options.styleScoped,
|
|
2195
2226
|
parentComponentFrame: options.parentComponentFrame
|
|
2196
2227
|
}), ssr.commentNode("qkssr-f");
|
|
@@ -2257,7 +2288,6 @@
|
|
|
2257
2288
|
value = isFunction(generator) ? generator({
|
|
2258
2289
|
async write(chunk) {
|
|
2259
2290
|
await _walkJSX(ssr, chunk, {
|
|
2260
|
-
allowPromises: !0,
|
|
2261
2291
|
currentStyleScoped: options.styleScoped,
|
|
2262
2292
|
parentComponentFrame: options.parentComponentFrame
|
|
2263
2293
|
}), ssr.commentNode("qkssr-f");
|
|
@@ -2277,7 +2307,7 @@
|
|
|
2277
2307
|
srcProps && srcProps.children && delete srcProps.children;
|
|
2278
2308
|
const scheduler = ssr.$scheduler$;
|
|
2279
2309
|
return host.setProp("q:renderFn", componentQrl), host.setProp("q:props", srcProps),
|
|
2280
|
-
null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.
|
|
2310
|
+
null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.COMPONENT, host, componentQrl, srcProps);
|
|
2281
2311
|
})(ssr, jsx, type);
|
|
2282
2312
|
const compStyleComponentId = addComponentStylePrefix(host.getProp("q:sstyle"));
|
|
2283
2313
|
enqueue(new ParentComponentData(options.styleScoped, options.parentComponentFrame)),
|
|
@@ -2344,18 +2374,20 @@
|
|
|
2344
2374
|
const appendToValue = valueToAppend => {
|
|
2345
2375
|
value = (null == value ? "" : value + "\n") + valueToAppend;
|
|
2346
2376
|
};
|
|
2377
|
+
const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", queueQRL, null, null, [ qrl ])),
|
|
2378
|
+
qrlToString(serializationCtx, qrl));
|
|
2347
2379
|
if (Array.isArray(qrls)) {
|
|
2348
2380
|
for (let i = 0; i <= qrls.length; i++) {
|
|
2349
2381
|
const qrl = qrls[i];
|
|
2350
|
-
if (isQrl(qrl)) {
|
|
2351
|
-
appendToValue(
|
|
2382
|
+
if (isQrl$1(qrl)) {
|
|
2383
|
+
appendToValue(getQrlString(qrl)), addQwikEventToSerializationContext(serializationCtx, key, qrl);
|
|
2352
2384
|
} else if (null != qrl) {
|
|
2353
2385
|
const nestedValue = setEvent(serializationCtx, key, qrl);
|
|
2354
2386
|
nestedValue && appendToValue(nestedValue);
|
|
2355
2387
|
}
|
|
2356
2388
|
}
|
|
2357
2389
|
} else {
|
|
2358
|
-
isQrl(qrls) && (value =
|
|
2390
|
+
isQrl$1(qrls) && (value = getQrlString(qrls), addQwikEventToSerializationContext(serializationCtx, key, qrls));
|
|
2359
2391
|
}
|
|
2360
2392
|
return value;
|
|
2361
2393
|
}
|
|
@@ -2367,7 +2399,7 @@
|
|
|
2367
2399
|
const eventName = key.substring(15);
|
|
2368
2400
|
eventName && serializationCtx.$eventNames$.add(eventName);
|
|
2369
2401
|
}
|
|
2370
|
-
const version = "2.0.0-alpha.
|
|
2402
|
+
const version = "2.0.0-alpha.7-dev+a26598a";
|
|
2371
2403
|
class _SharedContainer {
|
|
2372
2404
|
$version$;
|
|
2373
2405
|
$scheduler$;
|
|
@@ -2390,9 +2422,6 @@
|
|
|
2390
2422
|
return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
2391
2423
|
}
|
|
2392
2424
|
}
|
|
2393
|
-
const _CONST_PROPS = Symbol("CONST");
|
|
2394
|
-
const _VAR_PROPS = Symbol("VAR");
|
|
2395
|
-
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
2396
2425
|
const getValueProp = p0 => p0.value;
|
|
2397
2426
|
const getProp = (p0, p1) => p0[p1];
|
|
2398
2427
|
const getWrapped = args => new WrappedSignal(null, 1 === args.length ? getValueProp : getProp, args, null);
|
|
@@ -2597,7 +2626,7 @@
|
|
|
2597
2626
|
return String(value);
|
|
2598
2627
|
};
|
|
2599
2628
|
const VNodeDataSeparator_REFERENCE = 126, VNodeDataSeparator_ADVANCE_1 = 33, VNodeDataSeparator_ADVANCE_8192 = 46;
|
|
2600
|
-
const VNodeDataChar_OPEN = 123, VNodeDataChar_CLOSE = 125, VNodeDataChar_SCOPED_STYLE = 59, VNodeDataChar_RENDER_FN = 60, VNodeDataChar_ID = 61, VNodeDataChar_PROPS = 62, VNodeDataChar_SLOT_REF = 63, VNodeDataChar_KEY = 64, VNodeDataChar_SEQ = 91, VNodeDataChar_CONTEXT = 93, VNodeDataChar_SEQ_IDX = 94,
|
|
2629
|
+
const VNodeDataChar_OPEN = 123, VNodeDataChar_CLOSE = 125, VNodeDataChar_SCOPED_STYLE = 59, VNodeDataChar_RENDER_FN = 60, VNodeDataChar_ID = 61, VNodeDataChar_PROPS = 62, VNodeDataChar_SLOT_REF = 63, VNodeDataChar_KEY = 64, VNodeDataChar_SEQ = 91, VNodeDataChar_CONTEXT = 93, VNodeDataChar_SEQ_IDX = 94, VNodeDataChar_BACK_REFS = 96, VNodeDataChar_SEPARATOR = 124, VNodeDataChar_SLOT = 126;
|
|
2601
2630
|
var VNodeJournalOpCode;
|
|
2602
2631
|
!function(VNodeJournalOpCode) {
|
|
2603
2632
|
VNodeJournalOpCode[VNodeJournalOpCode.SetText = 1] = "SetText", VNodeJournalOpCode[VNodeJournalOpCode.SetAttribute = 2] = "SetAttribute",
|
|
@@ -2676,6 +2705,7 @@
|
|
|
2676
2705
|
elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
|
|
2677
2706
|
const element = elementVNode[ElementVNodeProps.element];
|
|
2678
2707
|
const attributes = element.attributes;
|
|
2708
|
+
const props = vnode_getProps(elementVNode);
|
|
2679
2709
|
for (let idx = 0; idx < attributes.length; idx++) {
|
|
2680
2710
|
const attr = attributes[idx];
|
|
2681
2711
|
const key = attr.name;
|
|
@@ -2683,9 +2713,9 @@
|
|
|
2683
2713
|
break;
|
|
2684
2714
|
}
|
|
2685
2715
|
if (key.startsWith("q:container")) {
|
|
2686
|
-
attr.value === QContainerValue.HTML ? mapArray_set(
|
|
2716
|
+
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);
|
|
2687
2717
|
} else if (!key.startsWith("on:")) {
|
|
2688
|
-
mapArray_set(
|
|
2718
|
+
mapArray_set(props, key, attr.value, 0);
|
|
2689
2719
|
}
|
|
2690
2720
|
}
|
|
2691
2721
|
}
|
|
@@ -2936,30 +2966,9 @@
|
|
|
2936
2966
|
}
|
|
2937
2967
|
journal.length = 0;
|
|
2938
2968
|
};
|
|
2939
|
-
const mapApp_findIndx = (elementVNode, key, start) => {
|
|
2940
|
-
assertTrue();
|
|
2941
|
-
let bottom = start >> 1;
|
|
2942
|
-
let top = elementVNode.length - 2 >> 1;
|
|
2943
|
-
for (;bottom <= top; ) {
|
|
2944
|
-
const mid = bottom + (top - bottom >> 1);
|
|
2945
|
-
const midKey = elementVNode[mid << 1];
|
|
2946
|
-
if (midKey === key) {
|
|
2947
|
-
return mid << 1;
|
|
2948
|
-
}
|
|
2949
|
-
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
2950
|
-
}
|
|
2951
|
-
return ~(bottom << 1);
|
|
2952
|
-
};
|
|
2953
|
-
const mapArray_set = (elementVNode, key, value, start) => {
|
|
2954
|
-
const indx = mapApp_findIndx(elementVNode, key, start);
|
|
2955
|
-
indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
|
|
2956
|
-
};
|
|
2957
|
-
const mapArray_get = (elementVNode, key, start) => {
|
|
2958
|
-
const indx = mapApp_findIndx(elementVNode, key, start);
|
|
2959
|
-
return indx >= 0 ? elementVNode[indx + 1] : null;
|
|
2960
|
-
};
|
|
2961
2969
|
const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
|
|
2962
|
-
ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent)
|
|
2970
|
+
ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent),
|
|
2971
|
+
newChild === insertBefore && (insertBefore = null);
|
|
2963
2972
|
let adjustedInsertBefore = null;
|
|
2964
2973
|
null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
|
|
2965
2974
|
adjustedInsertBefore && ((journal, vNode) => {
|
|
@@ -3037,9 +3046,23 @@
|
|
|
3037
3046
|
const vnode_getElementName = vnode => {
|
|
3038
3047
|
const elementVNode = ensureElementVNode(vnode);
|
|
3039
3048
|
let elementName = elementVNode[ElementVNodeProps.elementName];
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3049
|
+
if (void 0 === elementName) {
|
|
3050
|
+
const element = elementVNode[ElementVNodeProps.element];
|
|
3051
|
+
const nodeName = build.isDev ? fastNodeName(element).toLowerCase() : fastNodeName(element);
|
|
3052
|
+
elementName = elementVNode[ElementVNodeProps.elementName] = nodeName, elementVNode[VNodeProps.flags] |= (element => {
|
|
3053
|
+
switch (fastNamespaceURI(element)) {
|
|
3054
|
+
case SVG_NS:
|
|
3055
|
+
return VNodeFlags.NS_svg;
|
|
3056
|
+
|
|
3057
|
+
case MATH_NS:
|
|
3058
|
+
return VNodeFlags.NS_math;
|
|
3059
|
+
|
|
3060
|
+
default:
|
|
3061
|
+
return VNodeFlags.NS_html;
|
|
3062
|
+
}
|
|
3063
|
+
})(element);
|
|
3064
|
+
}
|
|
3065
|
+
return elementName;
|
|
3043
3066
|
};
|
|
3044
3067
|
const vnode_getText = vnode => {
|
|
3045
3068
|
const textVNode = ensureTextVNode(vnode);
|
|
@@ -3123,8 +3146,8 @@
|
|
|
3123
3146
|
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
3124
3147
|
} else if (peek() === VNodeDataChar_SEQ_IDX) {
|
|
3125
3148
|
vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
|
|
3126
|
-
} else if (peek() ===
|
|
3127
|
-
|
|
3149
|
+
} else if (peek() === VNodeDataChar_BACK_REFS) {
|
|
3150
|
+
container || (container = getDomContainer(element)), setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
|
|
3128
3151
|
} else if (peek() === VNodeDataChar_CONTEXT) {
|
|
3129
3152
|
vnode_setAttr(null, vParent, "q:ctx", consumeValue());
|
|
3130
3153
|
} else if (peek() === VNodeDataChar_OPEN) {
|
|
@@ -3228,6 +3251,12 @@
|
|
|
3228
3251
|
}
|
|
3229
3252
|
return node;
|
|
3230
3253
|
};
|
|
3254
|
+
let _fastNamespaceURI = null;
|
|
3255
|
+
const fastNamespaceURI = element => (_fastNamespaceURI || (_fastNamespaceURI = fastGetter(element, "namespaceURI")),
|
|
3256
|
+
_fastNamespaceURI.call(element));
|
|
3257
|
+
let _fastNodeName = null;
|
|
3258
|
+
const fastNodeName = element => (_fastNodeName || (_fastNodeName = fastGetter(element, "nodeName")),
|
|
3259
|
+
_fastNodeName.call(element));
|
|
3231
3260
|
const fastGetter = (prototype, name) => {
|
|
3232
3261
|
let getter;
|
|
3233
3262
|
for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
|
|
@@ -3265,12 +3294,27 @@
|
|
|
3265
3294
|
const id = consumeValue();
|
|
3266
3295
|
container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
3267
3296
|
} else {
|
|
3268
|
-
peek() ===
|
|
3297
|
+
peek() === VNodeDataChar_BACK_REFS ? (container || (container = getDomContainer(vParent[ElementVNodeProps.element])),
|
|
3298
|
+
setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
|
|
3269
3299
|
}
|
|
3270
3300
|
}));
|
|
3271
3301
|
}
|
|
3272
3302
|
return vFirstChild;
|
|
3273
3303
|
};
|
|
3304
|
+
function setEffectBackRefFromVNodeData(vParent, value, container) {
|
|
3305
|
+
const deserializedSubMap = container.$getObjectById$(value);
|
|
3306
|
+
if (vParent[_EFFECT_BACK_REF]) {
|
|
3307
|
+
((map1, map2) => {
|
|
3308
|
+
for (const [k, v] of map2) {
|
|
3309
|
+
map1.set(k, v);
|
|
3310
|
+
}
|
|
3311
|
+
})(vParent[_EFFECT_BACK_REF], deserializedSubMap);
|
|
3312
|
+
} else {
|
|
3313
|
+
Object.defineProperty(vParent, _EFFECT_BACK_REF, {
|
|
3314
|
+
value: deserializedSubMap
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3274
3318
|
const processVNodeData$1 = (vData, callback) => {
|
|
3275
3319
|
let nextToConsumeIdx = 0;
|
|
3276
3320
|
let ch = 0;
|
|
@@ -3295,8 +3339,9 @@
|
|
|
3295
3339
|
if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3296
3340
|
vnode_ensureElementInflated(vnode);
|
|
3297
3341
|
const keys = [];
|
|
3298
|
-
|
|
3299
|
-
|
|
3342
|
+
const props = vnode_getProps(vnode);
|
|
3343
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
3344
|
+
const key = props[i];
|
|
3300
3345
|
key.startsWith(":") || keys.push(key);
|
|
3301
3346
|
}
|
|
3302
3347
|
return keys;
|
|
@@ -3307,27 +3352,35 @@
|
|
|
3307
3352
|
const type = vnode[VNodeProps.flags];
|
|
3308
3353
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3309
3354
|
vnode_ensureElementInflated(vnode);
|
|
3310
|
-
const
|
|
3355
|
+
const props = vnode_getProps(vnode);
|
|
3356
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
3311
3357
|
if (idx >= 0) {
|
|
3312
|
-
if (
|
|
3358
|
+
if (props[idx + 1] != value && type & VNodeFlags.Element) {
|
|
3313
3359
|
journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
|
|
3314
3360
|
}
|
|
3315
|
-
null == value ?
|
|
3316
|
-
} else if (null != value && (
|
|
3361
|
+
null == value ? props.splice(idx, 2) : props[idx + 1] = value;
|
|
3362
|
+
} else if (null != value && (props.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
|
|
3317
3363
|
journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
|
|
3318
3364
|
}
|
|
3319
3365
|
}
|
|
3320
3366
|
};
|
|
3321
|
-
const vnode_getAttr = (vnode, key) =>
|
|
3322
|
-
|
|
3367
|
+
const vnode_getAttr = (vnode, key) => {
|
|
3368
|
+
if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3369
|
+
vnode_ensureElementInflated(vnode);
|
|
3370
|
+
const props = vnode_getProps(vnode);
|
|
3371
|
+
return mapArray_get(props, key, 0);
|
|
3372
|
+
}
|
|
3373
|
+
return null;
|
|
3374
|
+
};
|
|
3323
3375
|
const vnode_getProp = (vnode, key, getObject) => {
|
|
3324
3376
|
const type = vnode[VNodeProps.flags];
|
|
3325
3377
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
3326
3378
|
type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
|
|
3327
|
-
const
|
|
3379
|
+
const props = vnode_getProps(vnode);
|
|
3380
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
3328
3381
|
if (idx >= 0) {
|
|
3329
|
-
let value =
|
|
3330
|
-
return "string" == typeof value && getObject && (
|
|
3382
|
+
let value = props[idx + 1];
|
|
3383
|
+
return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)),
|
|
3331
3384
|
value;
|
|
3332
3385
|
}
|
|
3333
3386
|
}
|
|
@@ -3335,10 +3388,11 @@
|
|
|
3335
3388
|
};
|
|
3336
3389
|
const vnode_setProp = (vnode, key, value) => {
|
|
3337
3390
|
ensureElementOrVirtualVNode(vnode);
|
|
3338
|
-
const
|
|
3339
|
-
|
|
3391
|
+
const props = vnode_getProps(vnode);
|
|
3392
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
3393
|
+
idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
|
|
3340
3394
|
};
|
|
3341
|
-
const
|
|
3395
|
+
const vnode_getProps = vnode => vnode[(vnode => {
|
|
3342
3396
|
const type = vnode[VNodeProps.flags] & VNodeFlags.TYPE_MASK;
|
|
3343
3397
|
if (type === VNodeFlags.Element) {
|
|
3344
3398
|
return ElementVNodeProps.PROPS_OFFSET;
|
|
@@ -3347,7 +3401,7 @@
|
|
|
3347
3401
|
return VirtualVNodeProps.PROPS_OFFSET;
|
|
3348
3402
|
}
|
|
3349
3403
|
throw qError(QError.invalidVNodeType, [ type ]);
|
|
3350
|
-
};
|
|
3404
|
+
})(vnode)];
|
|
3351
3405
|
const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
|
|
3352
3406
|
const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)),
|
|
3353
3407
|
vnode[TextVNodeProps.node]);
|
|
@@ -3440,19 +3494,16 @@
|
|
|
3440
3494
|
};
|
|
3441
3495
|
const VNodeArray = class VNode extends Array {
|
|
3442
3496
|
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
3443
|
-
|
|
3444
|
-
return vnode.push(firstChild, lastChild, element, elementName), vnode;
|
|
3497
|
+
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
|
|
3445
3498
|
}
|
|
3446
3499
|
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
3447
|
-
|
|
3448
|
-
return vnode.push(textNode, text), vnode;
|
|
3500
|
+
return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
|
|
3449
3501
|
}
|
|
3450
3502
|
static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
|
|
3451
|
-
|
|
3452
|
-
return vnode.push(firstChild, lastChild), vnode;
|
|
3503
|
+
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
|
|
3453
3504
|
}
|
|
3454
|
-
constructor(flags, parent, previousSibling, nextSibling) {
|
|
3455
|
-
super(
|
|
3505
|
+
constructor(flags, parent, previousSibling, nextSibling, ...rest) {
|
|
3506
|
+
super(flags, parent, previousSibling, nextSibling, ...rest), build.isDev && (this.toString = vnode_toString);
|
|
3456
3507
|
}
|
|
3457
3508
|
};
|
|
3458
3509
|
let _context;
|
|
@@ -3503,11 +3554,13 @@
|
|
|
3503
3554
|
return returnValue;
|
|
3504
3555
|
}
|
|
3505
3556
|
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
3506
|
-
const
|
|
3557
|
+
const domContainer = getDomContainer(element);
|
|
3558
|
+
const container = domContainer.element;
|
|
3559
|
+
const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
|
|
3507
3560
|
const locale = container?.getAttribute("q:locale") || void 0;
|
|
3508
3561
|
return locale && function(locale) {
|
|
3509
3562
|
_locale = locale;
|
|
3510
|
-
}(locale), newInvokeContext(locale,
|
|
3563
|
+
}(locale), newInvokeContext(locale, vNode, element, event, url);
|
|
3511
3564
|
};
|
|
3512
3565
|
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
3513
3566
|
const ctx = {
|
|
@@ -3529,7 +3582,7 @@
|
|
|
3529
3582
|
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
3530
3583
|
const previousContainer = trackInvocation.$container$;
|
|
3531
3584
|
try {
|
|
3532
|
-
return trackInvocation.$effectSubscriber$ =
|
|
3585
|
+
return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data),
|
|
3533
3586
|
trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
3534
3587
|
} finally {
|
|
3535
3588
|
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
@@ -3591,9 +3644,9 @@
|
|
|
3591
3644
|
$storeProxyMap$=new WeakMap;
|
|
3592
3645
|
$qFuncs$;
|
|
3593
3646
|
$instanceHash$;
|
|
3594
|
-
|
|
3647
|
+
vNodeLocate=id => vnode_locate(this.rootVNode, id);
|
|
3648
|
+
$stateData$;
|
|
3595
3649
|
$styleIds$=null;
|
|
3596
|
-
$vnodeLocate$=id => vnode_locate(this.rootVNode, id);
|
|
3597
3650
|
$renderCount$=0;
|
|
3598
3651
|
constructor(element) {
|
|
3599
3652
|
if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
|
|
@@ -3603,7 +3656,7 @@
|
|
|
3603
3656
|
this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
|
|
3604
3657
|
this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
|
|
3605
3658
|
this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
|
|
3606
|
-
this.$rawStateData$ = null, this
|
|
3659
|
+
this.$rawStateData$ = null, this.$stateData$ = null;
|
|
3607
3660
|
const document = this.element.ownerDocument;
|
|
3608
3661
|
document.qVNodeData || function(document) {
|
|
3609
3662
|
const vNodeDataMap = document.qVNodeData || (document.qVNodeData = new WeakMap);
|
|
@@ -3761,22 +3814,22 @@
|
|
|
3761
3814
|
};
|
|
3762
3815
|
const walker = document.createTreeWalker(document, 129);
|
|
3763
3816
|
walkContainer(walker, null, walker.firstChild(), null, "", null);
|
|
3764
|
-
}(document), this.$rawStateData$ = [], this
|
|
3817
|
+
}(document), this.$rawStateData$ = [], this.$stateData$ = [];
|
|
3765
3818
|
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
3766
3819
|
if (0 !== qwikStates.length) {
|
|
3767
3820
|
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
|
|
3768
|
-
this
|
|
3821
|
+
this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
|
|
3769
3822
|
}
|
|
3770
3823
|
this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
|
|
3771
3824
|
}
|
|
3772
3825
|
$setRawState$(id, vParent) {
|
|
3773
|
-
this
|
|
3826
|
+
this.$stateData$[id] = vParent;
|
|
3774
3827
|
}
|
|
3775
3828
|
parseQRL(qrl) {
|
|
3776
3829
|
return inflateQRL(this, parseQRL(qrl));
|
|
3777
3830
|
}
|
|
3778
3831
|
handleError(err, host) {
|
|
3779
|
-
const errorStore = this.resolveContext(host, ERROR_CONTEXT);
|
|
3832
|
+
const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
|
|
3780
3833
|
if (!errorStore) {
|
|
3781
3834
|
throw err;
|
|
3782
3835
|
}
|
|
@@ -3805,7 +3858,7 @@
|
|
|
3805
3858
|
if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
|
|
3806
3859
|
return vNode;
|
|
3807
3860
|
}
|
|
3808
|
-
vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this
|
|
3861
|
+
vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.vNodeLocate);
|
|
3809
3862
|
} else {
|
|
3810
3863
|
vNode = vnode_getParent(vNode);
|
|
3811
3864
|
}
|
|
@@ -3823,7 +3876,7 @@
|
|
|
3823
3876
|
case "q:props":
|
|
3824
3877
|
case "q:renderFn":
|
|
3825
3878
|
case "q:ctx":
|
|
3826
|
-
case "q:
|
|
3879
|
+
case "q:brefs":
|
|
3827
3880
|
getObjectById = this.$getObjectById$;
|
|
3828
3881
|
break;
|
|
3829
3882
|
|
|
@@ -3835,7 +3888,10 @@
|
|
|
3835
3888
|
}
|
|
3836
3889
|
scheduleRender() {
|
|
3837
3890
|
return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
|
|
3838
|
-
this.renderDone
|
|
3891
|
+
this.renderDone.finally((() => emitEvent("qrender", {
|
|
3892
|
+
instanceHash: this.$instanceHash$,
|
|
3893
|
+
renderCount: this.$renderCount$
|
|
3894
|
+
})));
|
|
3839
3895
|
}
|
|
3840
3896
|
processChores() {
|
|
3841
3897
|
let renderCount = this.$renderCount$;
|
|
@@ -3853,16 +3909,17 @@
|
|
|
3853
3909
|
ensureProjectionResolved(vNode) {
|
|
3854
3910
|
if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
|
|
3855
3911
|
vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3912
|
+
const props = vnode_getProps(vNode);
|
|
3913
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
3914
|
+
if (isSlotProp(props[i])) {
|
|
3915
|
+
const value = props[i + 1];
|
|
3916
|
+
"string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
|
|
3860
3917
|
}
|
|
3861
3918
|
}
|
|
3862
3919
|
}
|
|
3863
3920
|
}
|
|
3864
3921
|
$getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(),
|
|
3865
|
-
this
|
|
3922
|
+
this.$stateData$[id]);
|
|
3866
3923
|
getSyncFn(id) {
|
|
3867
3924
|
const fn = this.$qFuncs$[id];
|
|
3868
3925
|
return assertTrue(), fn;
|
|
@@ -3988,7 +4045,7 @@
|
|
|
3988
4045
|
const task = target;
|
|
3989
4046
|
const v = data;
|
|
3990
4047
|
task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
|
|
3991
|
-
task.$el$ = v[3], task
|
|
4048
|
+
task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
|
|
3992
4049
|
break;
|
|
3993
4050
|
|
|
3994
4051
|
case TypeIds.Resource:
|
|
@@ -4006,11 +4063,9 @@
|
|
|
4006
4063
|
case TypeIds.Store:
|
|
4007
4064
|
case TypeIds.StoreArray:
|
|
4008
4065
|
{
|
|
4009
|
-
const [value, flags, effects
|
|
4066
|
+
const [value, flags, effects] = data;
|
|
4010
4067
|
const store = getOrCreateStore(value, flags, container);
|
|
4011
|
-
|
|
4012
|
-
storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect), storeHandler.$effects$ = effects,
|
|
4013
|
-
target = store;
|
|
4068
|
+
getStoreHandler(store).$effects$ = effects, target = store;
|
|
4014
4069
|
break;
|
|
4015
4070
|
}
|
|
4016
4071
|
|
|
@@ -4018,7 +4073,7 @@
|
|
|
4018
4073
|
{
|
|
4019
4074
|
const signal = target;
|
|
4020
4075
|
const d = data;
|
|
4021
|
-
signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
|
|
4076
|
+
signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
|
|
4022
4077
|
break;
|
|
4023
4078
|
}
|
|
4024
4079
|
|
|
@@ -4026,8 +4081,8 @@
|
|
|
4026
4081
|
{
|
|
4027
4082
|
const signal = target;
|
|
4028
4083
|
const d = data;
|
|
4029
|
-
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal
|
|
4030
|
-
signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
|
|
4084
|
+
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
|
|
4085
|
+
signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
|
|
4031
4086
|
break;
|
|
4032
4087
|
}
|
|
4033
4088
|
|
|
@@ -4130,7 +4185,7 @@
|
|
|
4130
4185
|
}
|
|
4131
4186
|
return target;
|
|
4132
4187
|
};
|
|
4133
|
-
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 ];
|
|
4188
|
+
const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ARRAY_PROP, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
|
|
4134
4189
|
const allocate = (container, typeId, value) => {
|
|
4135
4190
|
if (void 0 === value) {
|
|
4136
4191
|
return typeId;
|
|
@@ -4219,7 +4274,7 @@
|
|
|
4219
4274
|
const promise = new Promise(((res, rej) => {
|
|
4220
4275
|
resolve = res, reject = rej;
|
|
4221
4276
|
}));
|
|
4222
|
-
return resolvers.set(promise, [ resolve, reject ]), promise;
|
|
4277
|
+
return resolvers.set(promise, [ resolve, reject ]), promise.catch((() => {})), promise;
|
|
4223
4278
|
|
|
4224
4279
|
case TypeIds.Uint8Array:
|
|
4225
4280
|
const encodedLength = value.length;
|
|
@@ -4229,12 +4284,10 @@
|
|
|
4229
4284
|
case TypeIds.PropsProxy:
|
|
4230
4285
|
return createPropsProxy(null, null);
|
|
4231
4286
|
|
|
4232
|
-
case TypeIds.RefVNode:
|
|
4233
4287
|
case TypeIds.VNode:
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
}
|
|
4288
|
+
return retrieveVNodeOrDocument(container, value);
|
|
4289
|
+
|
|
4290
|
+
case TypeIds.RefVNode:
|
|
4238
4291
|
const vNode = retrieveVNodeOrDocument(container, value);
|
|
4239
4292
|
if (vnode_isVNode(vNode)) {
|
|
4240
4293
|
return vnode_getNode(vNode);
|
|
@@ -4242,7 +4295,7 @@
|
|
|
4242
4295
|
throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
|
|
4243
4296
|
|
|
4244
4297
|
case TypeIds.EffectData:
|
|
4245
|
-
return new
|
|
4298
|
+
return new SubscriptionData({});
|
|
4246
4299
|
|
|
4247
4300
|
default:
|
|
4248
4301
|
throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
|
|
@@ -4263,7 +4316,7 @@
|
|
|
4263
4316
|
const backChannel = globalThis[QRL_RUNTIME_CHUNK];
|
|
4264
4317
|
assertDefined(), qrlRef = backChannel.get(symbol);
|
|
4265
4318
|
}
|
|
4266
|
-
return createQRL(chunk, symbol, qrlRef, null, captureIds, null
|
|
4319
|
+
return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
|
|
4267
4320
|
}
|
|
4268
4321
|
function inflateQRL(container, qrl) {
|
|
4269
4322
|
const captureIds = qrl.$capture$;
|
|
@@ -4330,7 +4383,7 @@
|
|
|
4330
4383
|
output(TypeIds.Constant, Constants.Slot);
|
|
4331
4384
|
} else if (value === Fragment) {
|
|
4332
4385
|
output(TypeIds.Constant, Constants.Fragment);
|
|
4333
|
-
} else if (isQrl(value)) {
|
|
4386
|
+
} else if (isQrl$1(value)) {
|
|
4334
4387
|
const qrl = qrlToString(serializationContext, value);
|
|
4335
4388
|
const id = serializationContext.$addRoot$(qrl);
|
|
4336
4389
|
output(TypeIds.QRL, id);
|
|
@@ -4356,11 +4409,13 @@
|
|
|
4356
4409
|
}
|
|
4357
4410
|
} else if (void 0 === value) {
|
|
4358
4411
|
output(TypeIds.Constant, Constants.Undefined);
|
|
4412
|
+
} else if (value === NEEDS_COMPUTATION) {
|
|
4413
|
+
output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
|
|
4359
4414
|
} else {
|
|
4360
|
-
if (value !==
|
|
4415
|
+
if (value !== STORE_ARRAY_PROP) {
|
|
4361
4416
|
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
4362
4417
|
}
|
|
4363
|
-
output(TypeIds.Constant, Constants.
|
|
4418
|
+
output(TypeIds.Constant, Constants.STORE_ARRAY_PROP);
|
|
4364
4419
|
}
|
|
4365
4420
|
};
|
|
4366
4421
|
const writeObjectValue = (value, idx) => {
|
|
@@ -4376,7 +4431,7 @@
|
|
|
4376
4431
|
const constProps = value[_CONST_PROPS];
|
|
4377
4432
|
const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
|
|
4378
4433
|
output(TypeIds.PropsProxy, out);
|
|
4379
|
-
} else if (value instanceof
|
|
4434
|
+
} else if (value instanceof SubscriptionData) {
|
|
4380
4435
|
output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
|
|
4381
4436
|
} else if (isStore(value)) {
|
|
4382
4437
|
if (function(value) {
|
|
@@ -4393,7 +4448,6 @@
|
|
|
4393
4448
|
const storeTarget = getStoreTarget(value);
|
|
4394
4449
|
const flags = storeHandler.$flags$;
|
|
4395
4450
|
const effects = storeHandler.$effects$;
|
|
4396
|
-
const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
|
|
4397
4451
|
const innerStores = [];
|
|
4398
4452
|
for (const prop in storeTarget) {
|
|
4399
4453
|
const propValue = storeTarget[prop];
|
|
@@ -4402,7 +4456,7 @@
|
|
|
4402
4456
|
innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
|
|
4403
4457
|
}
|
|
4404
4458
|
}
|
|
4405
|
-
const out = [ storeTarget, flags, effects,
|
|
4459
|
+
const out = [ storeTarget, flags, effects, ...innerStores ];
|
|
4406
4460
|
for (;null == out[out.length - 1]; ) {
|
|
4407
4461
|
out.pop();
|
|
4408
4462
|
}
|
|
@@ -4423,7 +4477,7 @@
|
|
|
4423
4477
|
} else if (value instanceof Signal) {
|
|
4424
4478
|
const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
4425
4479
|
if (value instanceof WrappedSignal) {
|
|
4426
|
-
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value
|
|
4480
|
+
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), v, value.$hostElement$, ...value.$effects$ || [] ]);
|
|
4427
4481
|
} else if (value instanceof ComputedSignal) {
|
|
4428
4482
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
4429
4483
|
v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
|
|
@@ -4471,7 +4525,7 @@
|
|
|
4471
4525
|
} else if (isJSXNode(value)) {
|
|
4472
4526
|
output(TypeIds.JSXNode, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
|
|
4473
4527
|
} else if (value instanceof Task) {
|
|
4474
|
-
const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value
|
|
4528
|
+
const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
|
|
4475
4529
|
for (;null == out[out.length - 1]; ) {
|
|
4476
4530
|
out.pop();
|
|
4477
4531
|
}
|
|
@@ -4482,18 +4536,18 @@
|
|
|
4482
4536
|
throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
|
|
4483
4537
|
}
|
|
4484
4538
|
output(TypeIds.Promise, res);
|
|
4539
|
+
} else if (value instanceof Uint8Array) {
|
|
4540
|
+
let buf = "";
|
|
4541
|
+
for (const c of value) {
|
|
4542
|
+
buf += String.fromCharCode(c);
|
|
4543
|
+
}
|
|
4544
|
+
const out = btoa(buf).replace(/=+$/, "");
|
|
4545
|
+
output(TypeIds.Uint8Array, out);
|
|
4485
4546
|
} else {
|
|
4486
|
-
if (!(value
|
|
4547
|
+
if (!vnode_isVNode(value)) {
|
|
4487
4548
|
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
4488
4549
|
}
|
|
4489
|
-
|
|
4490
|
-
let buf = "";
|
|
4491
|
-
for (const c of value) {
|
|
4492
|
-
buf += String.fromCharCode(c);
|
|
4493
|
-
}
|
|
4494
|
-
const out = btoa(buf).replace(/=+$/, "");
|
|
4495
|
-
output(TypeIds.Uint8Array, out);
|
|
4496
|
-
}
|
|
4550
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
4497
4551
|
}
|
|
4498
4552
|
};
|
|
4499
4553
|
writeValue(serializationContext.$roots$, -1);
|
|
@@ -4541,18 +4595,18 @@
|
|
|
4541
4595
|
const promises = [];
|
|
4542
4596
|
const visit = obj => {
|
|
4543
4597
|
if ("function" == typeof obj) {
|
|
4544
|
-
if (isQrl(obj)) {
|
|
4598
|
+
if (isQrl$1(obj)) {
|
|
4545
4599
|
obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
|
|
4546
4600
|
} else if (isQwikComponent(obj)) {
|
|
4547
4601
|
const [qrl] = obj[SERIALIZABLE_STATE];
|
|
4548
4602
|
discoveredValues.push(qrl);
|
|
4549
4603
|
}
|
|
4550
|
-
} 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) {
|
|
4604
|
+
} 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) {
|
|
4551
4605
|
discoveredValues.push(...Object.values(obj));
|
|
4552
4606
|
} else if (isStore(obj)) {
|
|
4553
4607
|
const target = getStoreTarget(obj);
|
|
4554
4608
|
const effects = getStoreHandler(obj).$effects$;
|
|
4555
|
-
discoveredValues.push(target, effects
|
|
4609
|
+
discoveredValues.push(target, effects);
|
|
4556
4610
|
for (const prop in target) {
|
|
4557
4611
|
const propValue = target[prop];
|
|
4558
4612
|
storeProxyMap.has(propValue) && discoveredValues.push(prop, storeProxyMap.get(propValue));
|
|
@@ -4566,10 +4620,10 @@
|
|
|
4566
4620
|
} else if (obj instanceof Signal) {
|
|
4567
4621
|
const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
|
|
4568
4622
|
v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$),
|
|
4569
|
-
obj instanceof WrappedSignal ? (obj
|
|
4623
|
+
obj instanceof WrappedSignal ? (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues),
|
|
4570
4624
|
obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
|
|
4571
4625
|
} else if (obj instanceof Task) {
|
|
4572
|
-
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state
|
|
4626
|
+
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$), discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
|
|
4573
4627
|
} else if (isSsrNode(obj)) {
|
|
4574
4628
|
if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
|
|
4575
4629
|
for (const data of obj.childrenVNodeData) {
|
|
@@ -4582,7 +4636,7 @@
|
|
|
4582
4636
|
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
4583
4637
|
} else if (Array.isArray(obj)) {
|
|
4584
4638
|
discoveredValues.push(...obj);
|
|
4585
|
-
} else if (isQrl(obj)) {
|
|
4639
|
+
} else if (isQrl$1(obj)) {
|
|
4586
4640
|
obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
|
|
4587
4641
|
} else if (isPropsProxy(obj)) {
|
|
4588
4642
|
discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
|
|
@@ -4592,7 +4646,7 @@
|
|
|
4592
4646
|
}), (error => {
|
|
4593
4647
|
promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
|
|
4594
4648
|
})), promises.push(obj);
|
|
4595
|
-
} else if (obj instanceof
|
|
4649
|
+
} else if (obj instanceof SubscriptionData) {
|
|
4596
4650
|
discoveredValues.push(obj.data);
|
|
4597
4651
|
} else {
|
|
4598
4652
|
if (!isObjectLiteral(obj)) {
|
|
@@ -4633,15 +4687,35 @@
|
|
|
4633
4687
|
for (const value of vnodeData) {
|
|
4634
4688
|
if (isSsrAttrs(value)) {
|
|
4635
4689
|
for (let i = 1; i < value.length; i += 2) {
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4690
|
+
const attrValue = value[i];
|
|
4691
|
+
"string" != typeof attrValue && discoveredValues.push(attrValue);
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
};
|
|
4696
|
+
const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
|
|
4697
|
+
if (effectsBackRefs) {
|
|
4698
|
+
let hasBackRefs = !1;
|
|
4699
|
+
for (const [, effect] of effectsBackRefs) {
|
|
4700
|
+
if (effect[EffectSubscriptionProp.BACK_REF]) {
|
|
4701
|
+
hasBackRefs = !0;
|
|
4702
|
+
break;
|
|
4640
4703
|
}
|
|
4641
4704
|
}
|
|
4705
|
+
hasBackRefs && discoveredValues.push(effectsBackRefs);
|
|
4642
4706
|
}
|
|
4643
4707
|
};
|
|
4644
4708
|
const promiseResults = new WeakMap;
|
|
4709
|
+
function filterEffectBackRefs(effectBackRef) {
|
|
4710
|
+
let effectBackRefToSerialize = null;
|
|
4711
|
+
if (effectBackRef) {
|
|
4712
|
+
for (const [effectProp, effect] of effectBackRef) {
|
|
4713
|
+
effect[EffectSubscriptionProp.BACK_REF] && (effectBackRefToSerialize ||= new Map,
|
|
4714
|
+
effectBackRefToSerialize.set(effectProp, effect));
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4717
|
+
return effectBackRefToSerialize;
|
|
4718
|
+
}
|
|
4645
4719
|
function serializeWrappingFn(serializationContext, value) {
|
|
4646
4720
|
value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
|
|
4647
4721
|
return [ serializationContext.$addSyncFn$(value.$funcStr$, value.$args$.length, value.$func$), value.$args$ ];
|
|
@@ -4649,13 +4723,13 @@
|
|
|
4649
4723
|
function qrlToString(serializationContext, value) {
|
|
4650
4724
|
let symbol = value.$symbol$;
|
|
4651
4725
|
let chunk = value.$chunk$;
|
|
4652
|
-
const refSymbol = value.$refSymbol$ ?? symbol;
|
|
4653
4726
|
const platform = getPlatform();
|
|
4654
4727
|
if (platform) {
|
|
4655
|
-
const result = platform.chunkForSymbol(
|
|
4656
|
-
result && (chunk = result[1],
|
|
4728
|
+
const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
|
|
4729
|
+
result && (chunk = result[1], symbol = result[0]);
|
|
4657
4730
|
}
|
|
4658
|
-
|
|
4731
|
+
const isSync = (value => isQrl$1(value) && "<sync>" == value.$symbol$)(value);
|
|
4732
|
+
if (isSync) {
|
|
4659
4733
|
chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
|
|
4660
4734
|
} else {
|
|
4661
4735
|
chunk || (chunk = serializationContext.$symbolToChunkResolver$(value.$hash$));
|
|
@@ -4709,16 +4783,20 @@
|
|
|
4709
4783
|
const prototype = Object.getPrototypeOf(obj);
|
|
4710
4784
|
return null == prototype || prototype === Object.prototype || prototype === Array.prototype;
|
|
4711
4785
|
}
|
|
4712
|
-
const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
|
|
4713
|
-
const canSerialize = value => {
|
|
4786
|
+
const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl$1(obj);
|
|
4787
|
+
const canSerialize = (value, seen = new WeakSet) => {
|
|
4714
4788
|
if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
|
|
4715
4789
|
return !0;
|
|
4716
4790
|
}
|
|
4717
4791
|
if ("object" == typeof value) {
|
|
4792
|
+
if (seen.has(value)) {
|
|
4793
|
+
return !0;
|
|
4794
|
+
}
|
|
4795
|
+
seen.add(value);
|
|
4718
4796
|
const proto = Object.getPrototypeOf(value);
|
|
4719
4797
|
if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
|
|
4720
4798
|
for (const key in value) {
|
|
4721
|
-
if (!canSerialize(untrack((() => value[key])))) {
|
|
4799
|
+
if (!canSerialize(untrack((() => value[key])), seen)) {
|
|
4722
4800
|
return !1;
|
|
4723
4801
|
}
|
|
4724
4802
|
}
|
|
@@ -4726,7 +4804,7 @@
|
|
|
4726
4804
|
}
|
|
4727
4805
|
if (proto == Array.prototype) {
|
|
4728
4806
|
for (let i = 0; i < value.length; i++) {
|
|
4729
|
-
if (!canSerialize(value[i])) {
|
|
4807
|
+
if (!canSerialize(value[i], seen)) {
|
|
4730
4808
|
return !1;
|
|
4731
4809
|
}
|
|
4732
4810
|
}
|
|
@@ -4774,7 +4852,7 @@
|
|
|
4774
4852
|
if (isDomRef?.(value)) {
|
|
4775
4853
|
return !0;
|
|
4776
4854
|
}
|
|
4777
|
-
} else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
|
|
4855
|
+
} else if ("function" == typeof value && (isQrl$1(value) || isQwikComponent(value))) {
|
|
4778
4856
|
return !0;
|
|
4779
4857
|
}
|
|
4780
4858
|
return !1;
|
|
@@ -4802,13 +4880,14 @@
|
|
|
4802
4880
|
Constants[Constants.True = 2] = "True", Constants[Constants.False = 3] = "False",
|
|
4803
4881
|
Constants[Constants.EmptyString = 4] = "EmptyString", Constants[Constants.EMPTY_ARRAY = 5] = "EMPTY_ARRAY",
|
|
4804
4882
|
Constants[Constants.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants[Constants.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION",
|
|
4805
|
-
Constants[Constants.
|
|
4806
|
-
Constants[Constants.
|
|
4807
|
-
Constants[Constants.
|
|
4808
|
-
Constants[Constants.
|
|
4883
|
+
Constants[Constants.STORE_ARRAY_PROP = 8] = "STORE_ARRAY_PROP", Constants[Constants.Slot = 9] = "Slot",
|
|
4884
|
+
Constants[Constants.Fragment = 10] = "Fragment", Constants[Constants.NaN = 11] = "NaN",
|
|
4885
|
+
Constants[Constants.PositiveInfinity = 12] = "PositiveInfinity", Constants[Constants.NegativeInfinity = 13] = "NegativeInfinity",
|
|
4886
|
+
Constants[Constants.MaxSafeInt = 14] = "MaxSafeInt", Constants[Constants.AlmostMaxSafeInt = 15] = "AlmostMaxSafeInt",
|
|
4887
|
+
Constants[Constants.MinSafeInt = 16] = "MinSafeInt";
|
|
4809
4888
|
}(Constants || (Constants = {}));
|
|
4810
4889
|
const verifySerializable = (value, preMessage) => {
|
|
4811
|
-
const seen = new
|
|
4890
|
+
const seen = new WeakSet;
|
|
4812
4891
|
return _verifySerializable(value, seen, "_", preMessage);
|
|
4813
4892
|
};
|
|
4814
4893
|
const _verifySerializable = (value, seen, ctx, preMessage) => {
|
|
@@ -4817,10 +4896,13 @@
|
|
|
4817
4896
|
return value;
|
|
4818
4897
|
}
|
|
4819
4898
|
if (shouldSerialize(unwrapped)) {
|
|
4820
|
-
if (
|
|
4821
|
-
|
|
4899
|
+
if ("object" == typeof unwrapped) {
|
|
4900
|
+
if (seen.has(unwrapped)) {
|
|
4901
|
+
return value;
|
|
4902
|
+
}
|
|
4903
|
+
seen.add(unwrapped);
|
|
4822
4904
|
}
|
|
4823
|
-
if (
|
|
4905
|
+
if (isSignal(unwrapped)) {
|
|
4824
4906
|
return value;
|
|
4825
4907
|
}
|
|
4826
4908
|
if (canSerialize(unwrapped)) {
|
|
@@ -4874,9 +4956,7 @@
|
|
|
4874
4956
|
const shouldSerialize = obj => !isObject(obj) && !isFunction(obj) || !noSerializeSet.has(obj);
|
|
4875
4957
|
const fastSkipSerialize = obj => noSerializeSet.has(obj);
|
|
4876
4958
|
const noSerialize = input => (null != input && noSerializeSet.add(input), input);
|
|
4877
|
-
const
|
|
4878
|
-
const isSyncQrl = value => isQrl(value) && "<sync>" == value.$symbol$;
|
|
4879
|
-
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
|
|
4959
|
+
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
4880
4960
|
let _containerEl;
|
|
4881
4961
|
const qrl = async function(...args) {
|
|
4882
4962
|
const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
|
|
@@ -4884,9 +4964,14 @@
|
|
|
4884
4964
|
};
|
|
4885
4965
|
const setContainer = el => (_containerEl || (_containerEl = el), _containerEl);
|
|
4886
4966
|
function bindFnToContext(currentCtx, beforeFn) {
|
|
4887
|
-
|
|
4888
|
-
if (!
|
|
4889
|
-
|
|
4967
|
+
const bound = (...args) => {
|
|
4968
|
+
if (!qrl.resolved) {
|
|
4969
|
+
return qrl.resolve().then((fn => {
|
|
4970
|
+
if (!isFunction(fn)) {
|
|
4971
|
+
throw qError(QError.qrlIsNotFunction);
|
|
4972
|
+
}
|
|
4973
|
+
return bound(...args);
|
|
4974
|
+
}));
|
|
4890
4975
|
}
|
|
4891
4976
|
if (beforeFn && !1 === beforeFn()) {
|
|
4892
4977
|
return;
|
|
@@ -4896,17 +4981,29 @@
|
|
|
4896
4981
|
const prevEvent = context.$event$;
|
|
4897
4982
|
context.$qrl$ = qrl, context.$event$ ||= this;
|
|
4898
4983
|
try {
|
|
4899
|
-
return invoke.call(this, context,
|
|
4984
|
+
return invoke.call(this, context, symbolRef, ...args);
|
|
4900
4985
|
} finally {
|
|
4901
4986
|
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
4902
4987
|
}
|
|
4903
|
-
}
|
|
4988
|
+
};
|
|
4989
|
+
return bound;
|
|
4904
4990
|
}
|
|
4905
|
-
const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
|
|
4906
4991
|
const wrapFn = fn => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
|
|
4907
4992
|
let context = tryGetInvokeContext();
|
|
4908
|
-
|
|
4909
|
-
|
|
4993
|
+
if (context) {
|
|
4994
|
+
if (context.$qrl$?.$symbol$ === qrl.$symbol$) {
|
|
4995
|
+
return fn.apply(this, args);
|
|
4996
|
+
}
|
|
4997
|
+
const prevQrl = context.$qrl$;
|
|
4998
|
+
context.$qrl$ = qrl;
|
|
4999
|
+
try {
|
|
5000
|
+
return fn.apply(this, args);
|
|
5001
|
+
} finally {
|
|
5002
|
+
context.$qrl$ = prevQrl;
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
5005
|
+
return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
|
|
5006
|
+
invoke.call(this, context, fn, ...args);
|
|
4910
5007
|
};
|
|
4911
5008
|
const resolve = async containerEl => {
|
|
4912
5009
|
if (null !== symbolRef) {
|
|
@@ -4921,46 +5018,37 @@
|
|
|
4921
5018
|
const start = now();
|
|
4922
5019
|
const ctx = tryGetInvokeContext();
|
|
4923
5020
|
if (null !== symbolFn) {
|
|
4924
|
-
symbolRef = symbolFn().then((module => qrl.resolved = symbolRef =
|
|
5021
|
+
symbolRef = symbolFn().then((module => qrl.resolved = wrapFn(symbolRef = module[symbol])));
|
|
4925
5022
|
} else {
|
|
4926
5023
|
const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
|
|
4927
|
-
symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef =
|
|
5024
|
+
symbolRef = maybeThen(imported, (ref => qrl.resolved = wrapFn(symbolRef = ref)));
|
|
4928
5025
|
}
|
|
4929
5026
|
return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
|
|
4930
5027
|
throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
|
|
4931
5028
|
})), symbolRef;
|
|
4932
5029
|
};
|
|
4933
5030
|
const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
|
|
4934
|
-
const
|
|
4935
|
-
const hash = getSymbolHash(resolvedSymbol);
|
|
5031
|
+
const hash = getSymbolHash(symbol);
|
|
4936
5032
|
return Object.assign(qrl, {
|
|
4937
|
-
getSymbol: () =>
|
|
5033
|
+
getSymbol: () => symbol,
|
|
4938
5034
|
getHash: () => hash,
|
|
4939
5035
|
getCaptured: () => captureRef,
|
|
4940
5036
|
resolve,
|
|
4941
|
-
$resolveLazy$:
|
|
5037
|
+
$resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
|
|
4942
5038
|
$setContainer$: setContainer,
|
|
4943
5039
|
$chunk$: chunk,
|
|
4944
5040
|
$symbol$: symbol,
|
|
4945
|
-
$refSymbol$: refSymbol,
|
|
4946
5041
|
$hash$: hash,
|
|
4947
5042
|
getFn: bindFnToContext,
|
|
4948
5043
|
$capture$: capture,
|
|
4949
5044
|
$captureRef$: captureRef,
|
|
4950
5045
|
dev: null,
|
|
4951
5046
|
resolved: void 0
|
|
4952
|
-
}), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef =
|
|
5047
|
+
}), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = wrapFn(symbolRef = resolved)))),
|
|
4953
5048
|
build.isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
|
|
4954
5049
|
get: () => symbolRef
|
|
4955
5050
|
}), qrl;
|
|
4956
5051
|
};
|
|
4957
|
-
const getSymbolHash = symbolName => {
|
|
4958
|
-
const index = symbolName.lastIndexOf("_");
|
|
4959
|
-
return index > -1 ? symbolName.slice(index + 1) : symbolName;
|
|
4960
|
-
};
|
|
4961
|
-
function assertQrl() {
|
|
4962
|
-
qDev;
|
|
4963
|
-
}
|
|
4964
5052
|
const EMITTED = /*#__PURE__*/ new Set;
|
|
4965
5053
|
const emitUsedSymbol = (symbol, element, reqTime) => {
|
|
4966
5054
|
EMITTED.has(symbol) || (EMITTED.add(symbol), emitEvent("qsymbol", {
|
|
@@ -4977,12 +5065,12 @@
|
|
|
4977
5065
|
};
|
|
4978
5066
|
const now = () => isServerPlatform() ? 0 : "object" == typeof performance ? performance.now() : 0;
|
|
4979
5067
|
let runtimeSymbolId = 0;
|
|
4980
|
-
const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null
|
|
5068
|
+
const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
|
|
4981
5069
|
const dollar = $;
|
|
4982
5070
|
const eventQrl = qrl => qrl;
|
|
4983
5071
|
const componentQrl = componentQrl => {
|
|
4984
5072
|
function QwikComponent(props, key, flags = 0) {
|
|
4985
|
-
assertQrl();
|
|
5073
|
+
assertQrl(componentQrl);
|
|
4986
5074
|
const finalKey = componentQrl.$hash$.slice(0, 4) + ":" + (key || "");
|
|
4987
5075
|
const InnerCmp = () => {};
|
|
4988
5076
|
return InnerCmp[SERIALIZABLE_STATE] = [ componentQrl ], _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
|
|
@@ -5062,7 +5150,7 @@
|
|
|
5062
5150
|
out.push(css.substring(lastIdx, idx)), lastIdx = idx;
|
|
5063
5151
|
}
|
|
5064
5152
|
function insertScopingSelector(idx) {
|
|
5065
|
-
mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "
|
|
5153
|
+
mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "⚡️", scopeId));
|
|
5066
5154
|
}
|
|
5067
5155
|
function lookAhead(arc) {
|
|
5068
5156
|
let prefix = 0;
|
|
@@ -5132,16 +5220,16 @@
|
|
|
5132
5220
|
});
|
|
5133
5221
|
const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
|
|
5134
5222
|
const useStylesScopedQrl = styles => ({
|
|
5135
|
-
scopeId: "
|
|
5223
|
+
scopeId: "⚡️" + _useStyles(styles, getScopedStyles, !0)
|
|
5136
5224
|
});
|
|
5137
5225
|
const useStylesScoped$ = /*#__PURE__*/ implicit$FirstArg(useStylesScopedQrl);
|
|
5138
5226
|
const _useStyles = (styleQrl, transform, scoped) => {
|
|
5139
|
-
assertQrl();
|
|
5227
|
+
assertQrl(styleQrl);
|
|
5140
5228
|
const {val, set, iCtx, i} = useSequentialScope();
|
|
5141
5229
|
if (val) {
|
|
5142
5230
|
return val;
|
|
5143
5231
|
}
|
|
5144
|
-
const styleId = (
|
|
5232
|
+
const styleId = (index = i, assertQrl(qStyles = styleQrl), `${hashCode(qStyles.$hash$)}-${index}`);
|
|
5145
5233
|
var qStyles, index;
|
|
5146
5234
|
const host = iCtx.$hostElement$;
|
|
5147
5235
|
set(styleId);
|
|
@@ -5162,7 +5250,7 @@
|
|
|
5162
5250
|
if (val) {
|
|
5163
5251
|
return val;
|
|
5164
5252
|
}
|
|
5165
|
-
assertQrl();
|
|
5253
|
+
assertQrl(qrl);
|
|
5166
5254
|
const signal = new ComputedSignal(null, qrl);
|
|
5167
5255
|
return set(signal), throwIfQRLNotResolved(qrl), signal;
|
|
5168
5256
|
};
|
|
@@ -5172,11 +5260,15 @@
|
|
|
5172
5260
|
if (val) {
|
|
5173
5261
|
return void (isServerPlatform() && useRunTask(val, eagerness));
|
|
5174
5262
|
}
|
|
5175
|
-
assertQrl();
|
|
5263
|
+
assertQrl(qrl);
|
|
5176
5264
|
const task = new Task(TaskFlags.VISIBLE_TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
5177
5265
|
set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.$resolveLazy$(iCtx.$element$),
|
|
5178
5266
|
iCtx.$container$.$scheduler$(ChoreType.VISIBLE, task));
|
|
5179
5267
|
};
|
|
5268
|
+
const useRunTask = (task, eagerness) => {
|
|
5269
|
+
"intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "document-idle" === eagerness && useOnDocument("qidle", getTaskHandlerQrl(task));
|
|
5270
|
+
};
|
|
5271
|
+
const getTaskHandlerQrl = task => createQRL(null, "_task", scheduleTask, null, null, [ task ]);
|
|
5180
5272
|
const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
|
|
5181
5273
|
const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
|
|
5182
5274
|
const useComputed$ = implicit$FirstArg(useComputedQrl);
|
|
@@ -5250,7 +5342,7 @@
|
|
|
5250
5342
|
return _jsxSorted("script", null, props, null, 0, "prefetch-service-worker");
|
|
5251
5343
|
}, exports.RenderOnce = RenderOnce, exports.Resource = props => _jsxSorted(Fragment, null, null, function(props) {
|
|
5252
5344
|
const resource = props.value;
|
|
5253
|
-
if (isResourceReturn(resource)) {
|
|
5345
|
+
if (isResourceReturn(resource) && resource.value) {
|
|
5254
5346
|
if (!isServerPlatform()) {
|
|
5255
5347
|
const state = resource._state;
|
|
5256
5348
|
if ("pending" === state && props.onPending) {
|
|
@@ -5275,9 +5367,9 @@
|
|
|
5275
5367
|
}), props.children, jsx(SSRComment, {
|
|
5276
5368
|
data: "qkssr-po"
|
|
5277
5369
|
}) ], exports.SkipRender = SkipRender, exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS,
|
|
5278
|
-
exports._DomContainer = DomContainer, exports.
|
|
5279
|
-
exports.
|
|
5280
|
-
exports._deserialize = function(rawStateData, element) {
|
|
5370
|
+
exports._DomContainer = DomContainer, exports._EFFECT_BACK_REF = _EFFECT_BACK_REF,
|
|
5371
|
+
exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = SubscriptionData, exports._IMMUTABLE = _IMMUTABLE,
|
|
5372
|
+
exports._SharedContainer = _SharedContainer, exports._VAR_PROPS = _VAR_PROPS, exports._deserialize = function(rawStateData, element) {
|
|
5281
5373
|
if (null == rawStateData) {
|
|
5282
5374
|
return [];
|
|
5283
5375
|
}
|
|
@@ -5298,7 +5390,7 @@
|
|
|
5298
5390
|
if (iCtx) {
|
|
5299
5391
|
const hostElement = iCtx.$hostElement$;
|
|
5300
5392
|
let element = null;
|
|
5301
|
-
return vnode_isVNode(hostElement)
|
|
5393
|
+
return null != hostElement && (vnode_isVNode(hostElement) ? vnode_isElementVNode(hostElement) && (element = vnode_getNode(hostElement)) : element = hostElement),
|
|
5302
5394
|
element ?? iCtx.$qrl$?.$setContainer$(void 0);
|
|
5303
5395
|
}
|
|
5304
5396
|
}, exports._getContextEvent = () => {
|
|
@@ -5307,7 +5399,7 @@
|
|
|
5307
5399
|
return iCtx.$event$;
|
|
5308
5400
|
}
|
|
5309
5401
|
}, exports._getDomContainer = getDomContainer, exports._getQContainerElement = _getQContainerElement,
|
|
5310
|
-
exports.
|
|
5402
|
+
exports._isJSXNode = isJSXNode, exports._isStringifiable = function(value) {
|
|
5311
5403
|
return null === value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value;
|
|
5312
5404
|
}, exports._jsxBranch = input => input, exports._jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key),
|
|
5313
5405
|
exports._jsxQ = (type, mutable, immutable, children, _flags, key) => jsx(type, {
|
|
@@ -5323,21 +5415,31 @@
|
|
|
5323
5415
|
return newQrl.dev = opts, newQrl;
|
|
5324
5416
|
}, exports._qrlSync = function(fn, serializedFn) {
|
|
5325
5417
|
return void 0 === serializedFn && (serializedFn = fn.toString()), fn.serialized = serializedFn,
|
|
5326
|
-
createQRL("", "<sync>", fn, null, null, null
|
|
5418
|
+
createQRL("", "<sync>", fn, null, null, null);
|
|
5327
5419
|
}, exports._regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
|
|
5328
5420
|
globalThis.__qwik_reg_symbols.set(hash, symbol), symbol), exports._restProps = (props, omit, target = {}) => {
|
|
5329
|
-
|
|
5330
|
-
|
|
5421
|
+
let constPropsTarget = null;
|
|
5422
|
+
const constProps = props[_CONST_PROPS];
|
|
5423
|
+
if (constProps) {
|
|
5424
|
+
for (const key in constProps) {
|
|
5425
|
+
omit.includes(key) || (constPropsTarget ||= {}, constPropsTarget[key] = constProps[key]);
|
|
5426
|
+
}
|
|
5331
5427
|
}
|
|
5332
|
-
|
|
5333
|
-
|
|
5428
|
+
const varPropsTarget = target;
|
|
5429
|
+
const varProps = props[_VAR_PROPS];
|
|
5430
|
+
for (const key in varProps) {
|
|
5431
|
+
omit.includes(key) || (varPropsTarget[key] = varProps[key]);
|
|
5432
|
+
}
|
|
5433
|
+
return createPropsProxy(varPropsTarget, constPropsTarget);
|
|
5434
|
+
}, exports._run = queueQRL, exports._serialize = async function(data) {
|
|
5334
5435
|
const serializationContext = createSerializationContext(null, null, (() => ""), (() => ""), (() => {}), new WeakMap);
|
|
5335
5436
|
for (const root of data) {
|
|
5336
5437
|
serializationContext.$addRoot$(root);
|
|
5337
5438
|
}
|
|
5338
5439
|
return await serializationContext.$breakCircularDepsAndAwaitPromises$(), serializationContext.$serialize$(),
|
|
5339
5440
|
serializationContext.$writer$.toString();
|
|
5340
|
-
}, exports.
|
|
5441
|
+
}, exports._task = scheduleTask, exports._verifySerializable = verifySerializable,
|
|
5442
|
+
exports._waitUntilRendered = elm => {
|
|
5341
5443
|
const containerEl = _getQContainerElement(elm);
|
|
5342
5444
|
if (!containerEl) {
|
|
5343
5445
|
return Promise.resolve();
|
|
@@ -5401,7 +5503,7 @@
|
|
|
5401
5503
|
cleanup(container, container.rootVNode);
|
|
5402
5504
|
}
|
|
5403
5505
|
};
|
|
5404
|
-
}, exports.setPlatform = plt => _platform = plt, exports.sync$ = fn => createQRL("", "<sync>", fn, null, null, null
|
|
5506
|
+
}, exports.setPlatform = plt => _platform = plt, exports.sync$ = fn => createQRL("", "<sync>", fn, null, null, null),
|
|
5405
5507
|
exports.untrack = untrack, exports.unwrapStore = unwrapStore, exports.useComputed$ = useComputed$,
|
|
5406
5508
|
exports.useComputedQrl = useComputedQrl, exports.useConstant = useConstant, exports.useContext = (context, defaultValue) => {
|
|
5407
5509
|
const {val, set, iCtx} = useSequentialScope();
|