@qwik.dev/core 2.0.0-alpha.3 → 2.0.0-alpha.4
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 +34 -4
- package/dist/core-internal.d.ts +38 -16
- package/dist/core.cjs +6473 -6292
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +6460 -6291
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +1543 -1386
- package/dist/core.prod.mjs +3013 -2879
- package/dist/insights/index.qwik.cjs +144 -147
- package/dist/insights/index.qwik.mjs +144 -147
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +1894 -1887
- package/dist/optimizer.mjs +1728 -1775
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +689 -529
- package/dist/server.mjs +680 -521
- package/dist/testing/index.cjs +3200 -3029
- package/dist/testing/index.mjs +3165 -2995
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
- package/public.d.ts +3 -0
- package/dist/index.d.ts +0 -2
package/dist/core.prod.cjs
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core 2.0.0-alpha.4-dev+374e0d6
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
7
7
|
*/
|
|
8
8
|
!function(global, factory) {
|
|
9
|
-
"object" == typeof exports && "undefined" != typeof module ? factory(exports, require("@qwik.dev/core/build")
|
|
9
|
+
"object" == typeof exports && "undefined" != typeof module ? factory(exports, require("@qwik.dev/core/build")) : "function" == typeof define && define.amd ? define([ "exports", "@qwik.dev/core/build" ], factory) : factory((global = "undefined" != typeof globalThis ? globalThis : global || self).qwikCore = {}, global.qwikBuild);
|
|
10
10
|
}(this, (function(exports, build) {
|
|
11
11
|
"use strict";
|
|
12
12
|
const qDev = !1;
|
|
13
13
|
const seal = () => {
|
|
14
14
|
qDev;
|
|
15
15
|
};
|
|
16
|
-
const logError = (message, ...optionalParams) => createAndLogError(!1, message, ...optionalParams);
|
|
17
16
|
const throwErrorAndStop = (message, ...optionalParams) => {
|
|
18
17
|
throw createAndLogError(!1, message, ...optionalParams);
|
|
19
18
|
};
|
|
@@ -39,9 +38,40 @@
|
|
|
39
38
|
function assertFalse() {
|
|
40
39
|
qDev;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
var QError;
|
|
42
|
+
!function(QError) {
|
|
43
|
+
QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.UNUSED_1 = 1] = "UNUSED_1",
|
|
44
|
+
QError[QError.UNUSED_2 = 2] = "UNUSED_2", QError[QError.verifySerializable = 3] = "verifySerializable",
|
|
45
|
+
QError[QError.UNUSED_4 = 4] = "UNUSED_4", QError[QError.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer",
|
|
46
|
+
QError[QError.UNUSED_6 = 6] = "UNUSED_6", QError[QError.UNUSED_7 = 7] = "UNUSED_7",
|
|
47
|
+
QError[QError.UNUSED_8 = 8] = "UNUSED_8", QError[QError.UNUSED_9 = 9] = "UNUSED_9",
|
|
48
|
+
QError[QError.qrlIsNotFunction = 10] = "qrlIsNotFunction", QError[QError.dynamicImportFailed = 11] = "dynamicImportFailed",
|
|
49
|
+
QError[QError.unknownTypeArgument = 12] = "unknownTypeArgument", QError[QError.notFoundContext = 13] = "notFoundContext",
|
|
50
|
+
QError[QError.useMethodOutsideContext = 14] = "useMethodOutsideContext", QError[QError.UNUSED_15 = 15] = "UNUSED_15",
|
|
51
|
+
QError[QError.UNUSED_16 = 16] = "UNUSED_16", QError[QError.UNUSED_17 = 17] = "UNUSED_17",
|
|
52
|
+
QError[QError.UNUSED_18 = 18] = "UNUSED_18", QError[QError.UNUSED_19 = 19] = "UNUSED_19",
|
|
53
|
+
QError[QError.useInvokeContext = 20] = "useInvokeContext", QError[QError.UNUSED_21 = 21] = "UNUSED_21",
|
|
54
|
+
QError[QError.UNUSED_22 = 22] = "UNUSED_22", QError[QError.UNUSED_23 = 23] = "UNUSED_23",
|
|
55
|
+
QError[QError.UNUSED_24 = 24] = "UNUSED_24", QError[QError.UNUSED_25 = 25] = "UNUSED_25",
|
|
56
|
+
QError[QError.UNUSED_26 = 26] = "UNUSED_26", QError[QError.UNUSED_27 = 27] = "UNUSED_27",
|
|
57
|
+
QError[QError.invalidContext = 28] = "invalidContext", QError[QError.tagError = 29] = "tagError",
|
|
58
|
+
QError[QError.qrlMissingContainer = 30] = "qrlMissingContainer", QError[QError.qrlMissingChunk = 31] = "qrlMissingChunk",
|
|
59
|
+
QError[QError.invalidRefValue = 32] = "invalidRefValue", QError[QError.serializeErrorNotImplemented = 33] = "serializeErrorNotImplemented",
|
|
60
|
+
QError[QError.serializeErrorExpectedVNode = 34] = "serializeErrorExpectedVNode",
|
|
61
|
+
QError[QError.serializeErrorCannotAllocate = 35] = "serializeErrorCannotAllocate",
|
|
62
|
+
QError[QError.serializeErrorMissingRootId = 36] = "serializeErrorMissingRootId",
|
|
63
|
+
QError[QError.serializeErrorUnknownType = 37] = "serializeErrorUnknownType", QError[QError.serializeErrorUnvisited = 38] = "serializeErrorUnvisited",
|
|
64
|
+
QError[QError.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError[QError.wrongTextareaValue = 40] = "wrongTextareaValue",
|
|
65
|
+
QError[QError.containerNotFound = 41] = "containerNotFound", QError[QError.elementWithoutContainer = 42] = "elementWithoutContainer",
|
|
66
|
+
QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
|
|
67
|
+
QError[QError.serverHostMismatch = 45] = "serverHostMismatch", QError[QError.cannotCoerceSignal = 46] = "cannotCoerceSignal",
|
|
68
|
+
QError[QError.computedNotSync = 47] = "computedNotSync", QError[QError.computedReadOnly = 48] = "computedReadOnly",
|
|
69
|
+
QError[QError.wrappedReadOnly = 49] = "wrappedReadOnly", QError[QError.promisesNotExpected = 50] = "promisesNotExpected",
|
|
70
|
+
QError[QError.unsafeAttr = 51] = "unsafeAttr";
|
|
71
|
+
}(QError || (QError = {}));
|
|
72
|
+
const qError = (code, errorMessageArgs = []) => {
|
|
73
|
+
const text = (code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...errorMessageArgs);
|
|
74
|
+
return ((message, ...optionalParams) => createAndLogError(!0, message, ...optionalParams))(text, ...errorMessageArgs);
|
|
45
75
|
};
|
|
46
76
|
const createPlatform = () => ({
|
|
47
77
|
isServer: build.isServer,
|
|
@@ -54,10 +84,10 @@
|
|
|
54
84
|
}
|
|
55
85
|
}
|
|
56
86
|
if (!url) {
|
|
57
|
-
throw qError(
|
|
87
|
+
throw qError(QError.qrlMissingChunk, [ symbolName ]);
|
|
58
88
|
}
|
|
59
89
|
if (!containerEl) {
|
|
60
|
-
throw qError(
|
|
90
|
+
throw qError(QError.qrlMissingContainer, [ url, symbolName ]);
|
|
61
91
|
}
|
|
62
92
|
const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
|
|
63
93
|
const urlCopy = new URL(urlDoc);
|
|
@@ -97,7 +127,7 @@
|
|
|
97
127
|
};
|
|
98
128
|
const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
|
|
99
129
|
const shouldNotError = reason => {
|
|
100
|
-
throwErrorAndStop(
|
|
130
|
+
throwErrorAndStop(reason);
|
|
101
131
|
};
|
|
102
132
|
const delay = timeout => new Promise((resolve => {
|
|
103
133
|
setTimeout(resolve, timeout);
|
|
@@ -120,6 +150,92 @@
|
|
|
120
150
|
const isArray = v => Array.isArray(v);
|
|
121
151
|
const isString = v => "string" == typeof v;
|
|
122
152
|
const isFunction = v => "function" == typeof v;
|
|
153
|
+
var VNodeDataFlag;
|
|
154
|
+
!function(VNodeDataFlag) {
|
|
155
|
+
VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
|
|
156
|
+
VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.ELEMENT_NODE = 4] = "ELEMENT_NODE",
|
|
157
|
+
VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
|
|
158
|
+
}(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
159
|
+
var VirtualType;
|
|
160
|
+
!function(VirtualType) {
|
|
161
|
+
VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
|
|
162
|
+
VirtualType.Awaited = "A", VirtualType.Component = "C", VirtualType.InlineComponent = "I",
|
|
163
|
+
VirtualType.Projection = "P";
|
|
164
|
+
}(VirtualType || (VirtualType = {}));
|
|
165
|
+
const VirtualTypeName = {
|
|
166
|
+
[VirtualType.Virtual]: "[34mVirtual[0m",
|
|
167
|
+
[VirtualType.Fragment]: "[34mFragment[0m",
|
|
168
|
+
[VirtualType.WrappedSignal]: "[34mSignal[0m",
|
|
169
|
+
[VirtualType.Awaited]: "[34mAwaited[0m",
|
|
170
|
+
[VirtualType.Component]: "[34mComponent[0m",
|
|
171
|
+
[VirtualType.InlineComponent]: "[34mInlineComponent[0m",
|
|
172
|
+
[VirtualType.Projection]: "[34mProjection[0m"
|
|
173
|
+
};
|
|
174
|
+
var QContainerValue;
|
|
175
|
+
!function(QContainerValue) {
|
|
176
|
+
QContainerValue.PAUSED = "paused", QContainerValue.RESUMED = "resumed", QContainerValue.HTML = "html",
|
|
177
|
+
QContainerValue.TEXT = "text";
|
|
178
|
+
}(QContainerValue || (QContainerValue = {}));
|
|
179
|
+
const QSlot = "q:slot";
|
|
180
|
+
const QSlotS = "q:s";
|
|
181
|
+
const getQFuncs = (document, hash) => document["qFuncs_" + hash] || [];
|
|
182
|
+
const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
|
|
183
|
+
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
184
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
185
|
+
const MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
186
|
+
let _locale;
|
|
187
|
+
const EMPTY_ARRAY = [];
|
|
188
|
+
const EMPTY_OBJ = {};
|
|
189
|
+
Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
|
|
190
|
+
const EXTRACT_IMPORT_PATH = /\(\s*(['"])([^\1]+)\1\s*\)/;
|
|
191
|
+
const EXTRACT_SELF_IMPORT = /Promise\s*\.\s*resolve/;
|
|
192
|
+
const EXTRACT_FILE_NAME = /[\\/(]([\w\d.\-_]+\.(js|ts)x?):/;
|
|
193
|
+
const announcedQRL = /*#__PURE__*/ new Set;
|
|
194
|
+
const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset = 0) => {
|
|
195
|
+
let chunk = null;
|
|
196
|
+
let symbolFn = null;
|
|
197
|
+
if (isFunction(chunkOrFn)) {
|
|
198
|
+
symbolFn = chunkOrFn;
|
|
199
|
+
{
|
|
200
|
+
let match;
|
|
201
|
+
const srcCode = String(chunkOrFn);
|
|
202
|
+
if ((match = srcCode.match(EXTRACT_IMPORT_PATH)) && match[2]) {
|
|
203
|
+
chunk = match[2];
|
|
204
|
+
} else {
|
|
205
|
+
if (!(match = srcCode.match(EXTRACT_SELF_IMPORT))) {
|
|
206
|
+
throw qError(QError.dynamicImportFailed, [ srcCode ]);
|
|
207
|
+
}
|
|
208
|
+
{
|
|
209
|
+
const ref = "QWIK-SELF";
|
|
210
|
+
const frames = new Error(ref).stack.split("\n");
|
|
211
|
+
const start = frames.findIndex((f => f.includes(ref)));
|
|
212
|
+
match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
if (!isString(chunkOrFn)) {
|
|
218
|
+
throw qError(QError.unknownTypeArgument, [ chunkOrFn ]);
|
|
219
|
+
}
|
|
220
|
+
chunk = chunkOrFn;
|
|
221
|
+
}
|
|
222
|
+
return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
|
|
223
|
+
symbols: [ getSymbolHash(symbol) ],
|
|
224
|
+
bundles: chunk && [ chunk ]
|
|
225
|
+
})), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture, null);
|
|
226
|
+
};
|
|
227
|
+
const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
|
|
228
|
+
const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
|
|
229
|
+
const Slot = props => _jsxSorted(Virtual, null, {
|
|
230
|
+
[QSlotS]: ""
|
|
231
|
+
}, props.children, 0, props.name ?? "");
|
|
232
|
+
const SkipRender = Symbol("skip render");
|
|
233
|
+
const SSRRaw = () => null;
|
|
234
|
+
const SSRComment = () => null;
|
|
235
|
+
const SSRStream = (props, key) => jsx(RenderOnce, {
|
|
236
|
+
children: jsx(InternalSSRStream, props)
|
|
237
|
+
}, key);
|
|
238
|
+
const InternalSSRStream = () => null;
|
|
123
239
|
const isJsxPropertyAnEventName = name => (name.startsWith("on") || name.startsWith("window:on") || name.startsWith("document:on")) && name.endsWith("$");
|
|
124
240
|
const isHtmlAttributeAnEventName = name => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
|
|
125
241
|
const getEventNameFromJsxProp = name => {
|
|
@@ -164,26 +280,6 @@
|
|
|
164
280
|
function isPreventDefault(key) {
|
|
165
281
|
return key.startsWith("preventdefault:");
|
|
166
282
|
}
|
|
167
|
-
function hasClassAttr(props) {
|
|
168
|
-
for (const key in props) {
|
|
169
|
-
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
170
|
-
return !0;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return !1;
|
|
174
|
-
}
|
|
175
|
-
function isClassAttr(key) {
|
|
176
|
-
return "class" === key || "className" === key;
|
|
177
|
-
}
|
|
178
|
-
const addComponentStylePrefix = styleId => {
|
|
179
|
-
if (styleId) {
|
|
180
|
-
let idx = 0;
|
|
181
|
-
do {
|
|
182
|
-
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
183
|
-
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
184
|
-
}
|
|
185
|
-
return styleId || null;
|
|
186
|
-
};
|
|
187
283
|
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" ]);
|
|
188
284
|
const hashCode = (text, hash = 0) => {
|
|
189
285
|
for (let i = 0; i < text.length; i++) {
|
|
@@ -191,33 +287,6 @@
|
|
|
191
287
|
}
|
|
192
288
|
return Number(Math.abs(hash)).toString(36);
|
|
193
289
|
};
|
|
194
|
-
var VirtualType;
|
|
195
|
-
!function(VirtualType) {
|
|
196
|
-
VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
|
|
197
|
-
VirtualType.Awaited = "A", VirtualType.Component = "C", VirtualType.InlineComponent = "I",
|
|
198
|
-
VirtualType.Projection = "P";
|
|
199
|
-
}(VirtualType || (VirtualType = {}));
|
|
200
|
-
const VirtualTypeName = {
|
|
201
|
-
[VirtualType.Virtual]: "[34mVirtual[0m",
|
|
202
|
-
[VirtualType.Fragment]: "[34mFragment[0m",
|
|
203
|
-
[VirtualType.WrappedSignal]: "[34mSignal[0m",
|
|
204
|
-
[VirtualType.Awaited]: "[34mAwaited[0m",
|
|
205
|
-
[VirtualType.Component]: "[34mComponent[0m",
|
|
206
|
-
[VirtualType.InlineComponent]: "[34mInlineComponent[0m",
|
|
207
|
-
[VirtualType.Projection]: "[34mProjection[0m"
|
|
208
|
-
};
|
|
209
|
-
var QContainerValue;
|
|
210
|
-
!function(QContainerValue) {
|
|
211
|
-
QContainerValue.PAUSED = "paused", QContainerValue.RESUMED = "resumed", QContainerValue.HTML = "html",
|
|
212
|
-
QContainerValue.TEXT = "text";
|
|
213
|
-
}(QContainerValue || (QContainerValue = {}));
|
|
214
|
-
const QSlot = "q:slot";
|
|
215
|
-
const QSlotS = "q:s";
|
|
216
|
-
const getQFuncs = (document, hash) => document["qFuncs_" + hash] || [];
|
|
217
|
-
const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
|
|
218
|
-
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
219
|
-
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
220
|
-
const MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
221
290
|
const serializeClass = obj => {
|
|
222
291
|
if (!obj) {
|
|
223
292
|
return "";
|
|
@@ -249,7 +318,7 @@
|
|
|
249
318
|
}
|
|
250
319
|
if ("object" == typeof obj) {
|
|
251
320
|
if (isArray(obj)) {
|
|
252
|
-
throw qError(
|
|
321
|
+
throw qError(QError.stringifyClassOrStyle, [ obj, "style" ]);
|
|
253
322
|
}
|
|
254
323
|
{
|
|
255
324
|
const chunks = [];
|
|
@@ -272,678 +341,279 @@
|
|
|
272
341
|
}
|
|
273
342
|
const setValueForStyle = (styleName, value) => "number" != typeof value || 0 === value || unitlessNumbers.has(styleName) ? value : value + "px";
|
|
274
343
|
const styleContent = styleId => "⭐️" + styleId;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const EXTRACT_SELF_IMPORT = /Promise\s*\.\s*resolve/;
|
|
280
|
-
const EXTRACT_FILE_NAME = /[\\/(]([\w\d.\-_]+\.(js|ts)x?):/;
|
|
281
|
-
const announcedQRL = /*#__PURE__*/ new Set;
|
|
282
|
-
const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset = 0) => {
|
|
283
|
-
let chunk = null;
|
|
284
|
-
let symbolFn = null;
|
|
285
|
-
if (isFunction(chunkOrFn)) {
|
|
286
|
-
symbolFn = chunkOrFn;
|
|
287
|
-
{
|
|
288
|
-
let match;
|
|
289
|
-
const srcCode = String(chunkOrFn);
|
|
290
|
-
if ((match = srcCode.match(EXTRACT_IMPORT_PATH)) && match[2]) {
|
|
291
|
-
chunk = match[2];
|
|
292
|
-
} else {
|
|
293
|
-
if (!(match = srcCode.match(EXTRACT_SELF_IMPORT))) {
|
|
294
|
-
throw qError(11, srcCode);
|
|
295
|
-
}
|
|
296
|
-
{
|
|
297
|
-
const ref = "QWIK-SELF";
|
|
298
|
-
const frames = new Error(ref).stack.split("\n");
|
|
299
|
-
const start = frames.findIndex((f => f.includes(ref)));
|
|
300
|
-
match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
if (!isString(chunkOrFn)) {
|
|
306
|
-
throw qError(12, chunkOrFn);
|
|
344
|
+
function hasClassAttr(props) {
|
|
345
|
+
for (const key in props) {
|
|
346
|
+
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
347
|
+
return !0;
|
|
307
348
|
}
|
|
308
|
-
chunk = chunkOrFn;
|
|
309
|
-
}
|
|
310
|
-
return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
|
|
311
|
-
symbols: [ getSymbolHash(symbol) ],
|
|
312
|
-
bundles: chunk && [ chunk ]
|
|
313
|
-
})), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture, null);
|
|
314
|
-
};
|
|
315
|
-
const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
|
|
316
|
-
const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
|
|
317
|
-
const Slot = props => _jsxSorted(Virtual, null, {
|
|
318
|
-
[QSlotS]: ""
|
|
319
|
-
}, props.children, 0, props.name ?? "");
|
|
320
|
-
const SkipRender = Symbol("skip render");
|
|
321
|
-
const SSRRaw = () => null;
|
|
322
|
-
const SSRComment = () => null;
|
|
323
|
-
const SSRStream = (props, key) => jsx(RenderOnce, {
|
|
324
|
-
children: jsx(InternalSSRStream, props)
|
|
325
|
-
}, key);
|
|
326
|
-
const InternalSSRStream = () => null;
|
|
327
|
-
let _locale;
|
|
328
|
-
const useSequentialScope = () => {
|
|
329
|
-
const iCtx = useInvokeContext();
|
|
330
|
-
const host = iCtx.$hostElement$;
|
|
331
|
-
let seq = iCtx.$container$.getHostProp(host, "q:seq");
|
|
332
|
-
null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
|
|
333
|
-
let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
|
|
334
|
-
for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
|
|
335
|
-
seq.push(void 0);
|
|
336
349
|
}
|
|
337
|
-
return
|
|
338
|
-
val: seq[seqIdx],
|
|
339
|
-
set: value => seq[seqIdx] = value,
|
|
340
|
-
i: seqIdx,
|
|
341
|
-
iCtx
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
const createContextId = name => (assertTrue(/^[\w/.-]+$/.test(name)), /*#__PURE__*/ Object.freeze({
|
|
345
|
-
id: fromCamelToKebabCase(name)
|
|
346
|
-
}));
|
|
347
|
-
const useContextProvider = (context, newValue) => {
|
|
348
|
-
const {val, set, iCtx} = useSequentialScope();
|
|
349
|
-
void 0 === val && (iCtx.$container$.setContext(iCtx.$hostElement$, context, newValue),
|
|
350
|
-
set(1));
|
|
351
|
-
};
|
|
352
|
-
const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
|
|
353
|
-
function isSlotProp(prop) {
|
|
354
|
-
return !prop.startsWith("q:") && !prop.startsWith(":");
|
|
355
|
-
}
|
|
356
|
-
class Subscriber {
|
|
357
|
-
$effectDependencies$=null;
|
|
350
|
+
return !1;
|
|
358
351
|
}
|
|
359
|
-
function
|
|
360
|
-
return
|
|
352
|
+
function isClassAttr(key) {
|
|
353
|
+
return "class" === key || "className" === key;
|
|
361
354
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
355
|
+
const addComponentStylePrefix = styleId => {
|
|
356
|
+
if (styleId) {
|
|
357
|
+
let idx = 0;
|
|
358
|
+
do {
|
|
359
|
+
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
360
|
+
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
368
361
|
}
|
|
362
|
+
return styleId || null;
|
|
363
|
+
};
|
|
364
|
+
const STORE_TARGET = Symbol("store.target");
|
|
365
|
+
const STORE_HANDLER = Symbol("store.handler");
|
|
366
|
+
const STORE_ARRAY_PROP = Symbol("store.array");
|
|
367
|
+
var StoreFlags;
|
|
368
|
+
!function(StoreFlags) {
|
|
369
|
+
StoreFlags[StoreFlags.NONE = 0] = "NONE", StoreFlags[StoreFlags.RECURSIVE = 1] = "RECURSIVE",
|
|
370
|
+
StoreFlags[StoreFlags.IMMUTABLE = 2] = "IMMUTABLE";
|
|
371
|
+
}(StoreFlags || (StoreFlags = {}));
|
|
372
|
+
const getStoreHandler = value => value[STORE_HANDLER];
|
|
373
|
+
const getStoreTarget = value => value?.[STORE_TARGET] || null;
|
|
374
|
+
const unwrapStore = value => getStoreTarget(value) || value;
|
|
375
|
+
const isStore = value => STORE_TARGET in value;
|
|
376
|
+
function createStore(container, obj, flags) {
|
|
377
|
+
return new Proxy(obj, new StoreHandler(flags, container || null));
|
|
369
378
|
}
|
|
370
|
-
|
|
371
|
-
if (
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
function clearEffects(subscriber, value) {
|
|
378
|
-
if (!isSignal(subscriber)) {
|
|
379
|
-
return !1;
|
|
380
|
-
}
|
|
381
|
-
const effectSubscriptions = subscriber.$effects$;
|
|
382
|
-
if (!effectSubscriptions) {
|
|
383
|
-
return !1;
|
|
384
|
-
}
|
|
385
|
-
let subscriptionRemoved = !1;
|
|
386
|
-
for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
|
|
387
|
-
effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
|
|
388
|
-
subscriptionRemoved = !0);
|
|
389
|
-
}
|
|
390
|
-
return subscriptionRemoved;
|
|
391
|
-
}
|
|
392
|
-
const NEEDS_COMPUTATION = Symbol("invalid");
|
|
393
|
-
const throwIfQRLNotResolved = qrl => {
|
|
394
|
-
if (!qrl.resolved) {
|
|
395
|
-
throw qrl.resolve();
|
|
379
|
+
const getOrCreateStore = (obj, flags, container) => {
|
|
380
|
+
if (isSerializableObject(obj) && container) {
|
|
381
|
+
let store = container.$storeProxyMap$.get(obj);
|
|
382
|
+
return store || (store = createStore(container, obj, flags), container.$storeProxyMap$.set(obj, store)),
|
|
383
|
+
store;
|
|
396
384
|
}
|
|
385
|
+
return obj;
|
|
397
386
|
};
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
constructor(data) {
|
|
402
|
-
this.data = data;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
var EffectSubscriptionsProp;
|
|
406
|
-
var EffectProperty;
|
|
407
|
-
!function(EffectSubscriptionsProp) {
|
|
408
|
-
EffectSubscriptionsProp[EffectSubscriptionsProp.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp[EffectSubscriptionsProp.PROPERTY = 1] = "PROPERTY",
|
|
409
|
-
EffectSubscriptionsProp[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
|
|
410
|
-
}(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty) {
|
|
411
|
-
EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
|
|
412
|
-
}(EffectProperty || (EffectProperty = {}));
|
|
413
|
-
class Signal {
|
|
414
|
-
$untrackedValue$;
|
|
387
|
+
class StoreHandler {
|
|
388
|
+
$flags$;
|
|
389
|
+
$container$;
|
|
415
390
|
$effects$=null;
|
|
416
|
-
$container
|
|
417
|
-
|
|
418
|
-
this.$container$ = container, this.$untrackedValue$ = value;
|
|
419
|
-
}
|
|
420
|
-
get untrackedValue() {
|
|
421
|
-
return this.$untrackedValue$;
|
|
391
|
+
constructor($flags$, $container$) {
|
|
392
|
+
this.$flags$ = $flags$, this.$container$ = $container$;
|
|
422
393
|
}
|
|
423
|
-
|
|
424
|
-
|
|
394
|
+
toString() {
|
|
395
|
+
return "[Store]";
|
|
425
396
|
}
|
|
426
|
-
get
|
|
397
|
+
get(target, prop) {
|
|
398
|
+
if ("symbol" == typeof prop) {
|
|
399
|
+
return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
|
|
400
|
+
}
|
|
427
401
|
const ctx = tryGetInvokeContext();
|
|
402
|
+
const value = target[prop];
|
|
428
403
|
if (ctx) {
|
|
429
404
|
if (null === this.$container$) {
|
|
430
405
|
if (!ctx.$container$) {
|
|
431
|
-
return
|
|
406
|
+
return value;
|
|
432
407
|
}
|
|
433
408
|
this.$container$ = ctx.$container$;
|
|
434
409
|
} else {
|
|
435
410
|
assertTrue();
|
|
436
411
|
}
|
|
437
412
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
438
|
-
|
|
439
|
-
const effects = this.$effects$ ||= [];
|
|
440
|
-
ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this),
|
|
441
|
-
isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
|
|
442
|
-
}
|
|
413
|
+
effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
443
414
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
set value(value) {
|
|
447
|
-
value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
|
|
448
|
-
}
|
|
449
|
-
valueOf() {
|
|
450
|
-
qDev;
|
|
451
|
-
}
|
|
452
|
-
toString() {
|
|
453
|
-
return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
|
|
454
|
-
}
|
|
455
|
-
toJSON() {
|
|
456
|
-
return {
|
|
457
|
-
value: this.$untrackedValue$
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
const ensureContains = (array, value) => {
|
|
462
|
-
-1 === array.indexOf(value) && array.push(value);
|
|
463
|
-
};
|
|
464
|
-
const ensureContainsEffect = (array, effectSubscriptions) => {
|
|
465
|
-
for (let i = 0; i < array.length; i++) {
|
|
466
|
-
const existingEffect = array[i];
|
|
467
|
-
if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
|
|
468
|
-
return;
|
|
415
|
+
if ("toString" === prop && value === Object.prototype.toString) {
|
|
416
|
+
return this.toString;
|
|
469
417
|
}
|
|
418
|
+
return this.$flags$ & StoreFlags.RECURSIVE && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
|
|
470
419
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (isSubscriber(effect)) {
|
|
475
|
-
if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
effect.$effectDependencies$.push(subscriber);
|
|
479
|
-
} else if (vnode_isVNode(effect) && vnode_isVirtualVNode(effect)) {
|
|
480
|
-
let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
|
|
481
|
-
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
482
|
-
return;
|
|
420
|
+
set(target, prop, value) {
|
|
421
|
+
if (target = unwrapDeserializerProxy(target), "symbol" == typeof prop) {
|
|
422
|
+
return target[prop] = value, !0;
|
|
483
423
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
424
|
+
const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
|
|
425
|
+
if (prop in target) {
|
|
426
|
+
newValue !== target[prop] && setNewValueAndTriggerEffects(prop, newValue, target, this);
|
|
427
|
+
} else {
|
|
428
|
+
setNewValueAndTriggerEffects(prop, newValue, target, this);
|
|
489
429
|
}
|
|
490
|
-
|
|
430
|
+
return !0;
|
|
491
431
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
432
|
+
deleteProperty(target, prop) {
|
|
433
|
+
return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)),
|
|
434
|
+
!0);
|
|
435
|
+
}
|
|
436
|
+
has(target, prop) {
|
|
437
|
+
if (prop === STORE_TARGET) {
|
|
497
438
|
return !0;
|
|
498
439
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const scheduleEffect = effectSubscriptions => {
|
|
505
|
-
const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
|
|
506
|
-
const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
|
|
507
|
-
if (assertDefined(), isTask(effect)) {
|
|
508
|
-
effect.$flags$ |= TaskFlags.DIRTY;
|
|
509
|
-
let choreType = ChoreType.TASK;
|
|
510
|
-
effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE),
|
|
511
|
-
container.$scheduler$(choreType, effect);
|
|
512
|
-
} else if (effect instanceof Signal) {
|
|
513
|
-
effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$));
|
|
514
|
-
try {
|
|
515
|
-
retryOnPromise((() => effect.$invalidate$()));
|
|
516
|
-
} catch (e) {
|
|
517
|
-
logError(e);
|
|
518
|
-
}
|
|
519
|
-
} else if (property === EffectProperty.COMPONENT) {
|
|
520
|
-
const host = effect;
|
|
521
|
-
const qrl = container.getHostProp(host, "q:renderFn");
|
|
522
|
-
assertDefined();
|
|
523
|
-
const props = container.getHostProp(host, "q:props");
|
|
524
|
-
container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
|
|
525
|
-
} else if (property === EffectProperty.VNODE) {
|
|
526
|
-
container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
|
|
527
|
-
} else {
|
|
528
|
-
let effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
|
|
529
|
-
if (effectData instanceof EffectData) {
|
|
530
|
-
const payload = {
|
|
531
|
-
...effectData.data,
|
|
532
|
-
$value$: signal
|
|
533
|
-
};
|
|
534
|
-
container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
|
|
535
|
-
}
|
|
440
|
+
if ("string" == typeof prop) {
|
|
441
|
+
const ctx = tryGetInvokeContext();
|
|
442
|
+
if (ctx) {
|
|
443
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
444
|
+
effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
536
445
|
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
class ComputedSignal extends Signal {
|
|
542
|
-
$computeQrl$;
|
|
543
|
-
$invalid$=!0;
|
|
544
|
-
constructor(container, fn) {
|
|
545
|
-
super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn;
|
|
446
|
+
}
|
|
447
|
+
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
546
448
|
}
|
|
547
|
-
|
|
548
|
-
|
|
449
|
+
ownKeys(target) {
|
|
450
|
+
const ctx = tryGetInvokeContext();
|
|
451
|
+
const effectSubscriber = ctx?.$effectSubscriber$;
|
|
452
|
+
return effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber),
|
|
453
|
+
Reflect.ownKeys(target);
|
|
549
454
|
}
|
|
550
|
-
|
|
551
|
-
|
|
455
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
456
|
+
return Array.isArray(target) || "symbol" == typeof prop ? Object.getOwnPropertyDescriptor(target, prop) : {
|
|
457
|
+
enumerable: !0,
|
|
458
|
+
configurable: !0
|
|
459
|
+
};
|
|
552
460
|
}
|
|
553
|
-
|
|
554
|
-
|
|
461
|
+
}
|
|
462
|
+
function addEffect(target, prop, store, effectSubscriber) {
|
|
463
|
+
const effectsMap = store.$effects$ ||= {};
|
|
464
|
+
const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
|
|
465
|
+
ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target);
|
|
466
|
+
}
|
|
467
|
+
function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
|
|
468
|
+
target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
|
|
469
|
+
}
|
|
470
|
+
function getEffects(target, prop, storeEffects) {
|
|
471
|
+
let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
|
|
472
|
+
const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
|
|
473
|
+
return storeArrayValue && (effectsToTrigger ||= [], effectsToTrigger.push(...storeArrayValue)),
|
|
474
|
+
effectsToTrigger;
|
|
475
|
+
}
|
|
476
|
+
const useSequentialScope = () => {
|
|
477
|
+
const iCtx = useInvokeContext();
|
|
478
|
+
const host = iCtx.$hostElement$;
|
|
479
|
+
let seq = iCtx.$container$.getHostProp(host, "q:seq");
|
|
480
|
+
null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
|
|
481
|
+
let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
|
|
482
|
+
for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
|
|
483
|
+
seq.push(void 0);
|
|
555
484
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
485
|
+
return {
|
|
486
|
+
val: seq[seqIdx],
|
|
487
|
+
set: value => seq[seqIdx] = value,
|
|
488
|
+
i: seqIdx,
|
|
489
|
+
iCtx
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
class Subscriber {
|
|
493
|
+
$effectDependencies$=null;
|
|
494
|
+
}
|
|
495
|
+
function isSubscriber(value) {
|
|
496
|
+
return value instanceof Subscriber || value instanceof WrappedSignal;
|
|
497
|
+
}
|
|
498
|
+
function clearVNodeEffectDependencies(container, value) {
|
|
499
|
+
vnode_isElementVNode(value) && ensureMaterialized(value);
|
|
500
|
+
const effects = vnode_getProp(value, "q:subs", container.$getObjectById$);
|
|
501
|
+
if (effects) {
|
|
502
|
+
for (let i = effects.length - 1; i >= 0; i--) {
|
|
503
|
+
clearEffects(effects[i], value) && effects.splice(i, 1);
|
|
559
504
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
const untrackedValue = computeQrl.getFn(ctx)();
|
|
567
|
-
isPromise(untrackedValue) && throwErrorAndStop(`useComputedSignal$ QRL ${computeQrl.dev ? `${computeQrl.dev.file} ` : ""}${computeQrl.$hash$} returned a Promise`),
|
|
568
|
-
this.$invalid$ = !1;
|
|
569
|
-
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
570
|
-
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
571
|
-
} finally {
|
|
572
|
-
ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function clearSubscriberEffectDependencies(value) {
|
|
508
|
+
if (value.$effectDependencies$) {
|
|
509
|
+
for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
|
|
510
|
+
clearEffects(value.$effectDependencies$[i], value) && value.$effectDependencies$.splice(i, 1);
|
|
573
511
|
}
|
|
574
512
|
}
|
|
575
|
-
|
|
576
|
-
|
|
513
|
+
}
|
|
514
|
+
function clearEffects(subscriber, value) {
|
|
515
|
+
if (!isSignal(subscriber)) {
|
|
516
|
+
return !1;
|
|
577
517
|
}
|
|
578
|
-
|
|
579
|
-
|
|
518
|
+
const effectSubscriptions = subscriber.$effects$;
|
|
519
|
+
const hostElement = subscriber.$hostElement$;
|
|
520
|
+
hostElement && hostElement === value && (subscriber.$hostElement$ = null);
|
|
521
|
+
let subscriptionRemoved = !1;
|
|
522
|
+
if (effectSubscriptions) {
|
|
523
|
+
for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
|
|
524
|
+
effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
|
|
525
|
+
subscriptionRemoved = !0);
|
|
526
|
+
}
|
|
580
527
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
$funcStr$;
|
|
586
|
-
$invalid$=!0;
|
|
587
|
-
$effectDependencies$=null;
|
|
588
|
-
constructor(container, fn, args, fnStr) {
|
|
589
|
-
super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
|
|
590
|
-
}
|
|
591
|
-
$invalidate$() {
|
|
592
|
-
this.$invalid$ = !0, this.$effects$?.length && this.$computeIfNeeded$() && triggerEffects(this.$container$, this, this.$effects$);
|
|
593
|
-
}
|
|
594
|
-
force() {
|
|
595
|
-
this.$invalid$ = !0, triggerEffects(this.$container$, this, this.$effects$);
|
|
596
|
-
}
|
|
597
|
-
get untrackedValue() {
|
|
598
|
-
return this.$computeIfNeeded$(), assertFalse(), this.$untrackedValue$;
|
|
599
|
-
}
|
|
600
|
-
$computeIfNeeded$() {
|
|
601
|
-
if (!this.$invalid$) {
|
|
602
|
-
return !1;
|
|
528
|
+
const args = subscriber.$args$;
|
|
529
|
+
if (args) {
|
|
530
|
+
for (let i = args.length - 1; i >= 0; i--) {
|
|
531
|
+
clearEffects(args[i], subscriber);
|
|
603
532
|
}
|
|
604
|
-
const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, EffectProperty.VNODE, this.$container$);
|
|
605
|
-
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
606
|
-
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
607
|
-
}
|
|
608
|
-
get value() {
|
|
609
|
-
return super.value;
|
|
610
|
-
}
|
|
611
|
-
set value(_) {
|
|
612
|
-
throwErrorAndStop("WrappedSignal is read-only");
|
|
613
533
|
}
|
|
534
|
+
return subscriptionRemoved;
|
|
614
535
|
}
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
|
|
620
|
-
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
|
|
621
|
-
const useLexicalScope = () => {
|
|
622
|
-
const context = getInvokeContext();
|
|
623
|
-
let qrl = context.$qrl$;
|
|
624
|
-
if (qrl) {
|
|
625
|
-
assertQrl(qrl), assertDefined();
|
|
626
|
-
} else {
|
|
627
|
-
const el = context.$element$;
|
|
628
|
-
assertDefined();
|
|
629
|
-
const containerElement = _getQContainerElement(el);
|
|
630
|
-
assertDefined();
|
|
631
|
-
qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
|
|
632
|
-
}
|
|
633
|
-
return qrl.$captureRef$;
|
|
634
|
-
};
|
|
635
|
-
const useOn = (event, eventQrl) => {
|
|
636
|
-
_useOn(createEventName(event, void 0), eventQrl);
|
|
637
|
-
};
|
|
638
|
-
const useOnDocument = (event, eventQrl) => {
|
|
639
|
-
_useOn(createEventName(event, "document"), eventQrl);
|
|
640
|
-
};
|
|
641
|
-
const createEventName = (event, eventType) => {
|
|
642
|
-
const prefix = void 0 !== eventType ? eventType + ":" : "";
|
|
643
|
-
const map = name => prefix + "on" + name.charAt(0).toUpperCase() + name.substring(1) + "$";
|
|
644
|
-
return Array.isArray(event) ? event.map(map) : map(event);
|
|
645
|
-
};
|
|
646
|
-
const _useOn = (eventName, eventQrl) => {
|
|
647
|
-
const {isAdded, addEvent} = useOnEventsSequentialScope();
|
|
648
|
-
isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach((event => addEvent(event, eventQrl))) : addEvent(eventName, eventQrl));
|
|
649
|
-
};
|
|
650
|
-
const useOnEventsSequentialScope = () => {
|
|
651
|
-
const iCtx = useInvokeContext();
|
|
652
|
-
const host = iCtx.$hostElement$;
|
|
653
|
-
let onMap = iCtx.$container$.getHostProp(host, ":on");
|
|
654
|
-
null === onMap && (onMap = {}, iCtx.$container$.setHostProp(host, ":on", onMap));
|
|
655
|
-
let seqIdx = iCtx.$container$.getHostProp(host, ":onIdx");
|
|
656
|
-
null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, ":onIdx", seqIdx + 1);
|
|
657
|
-
let addedFlags = iCtx.$container$.getHostProp(host, ":onFlags");
|
|
658
|
-
for (null === addedFlags && (addedFlags = [], iCtx.$container$.setHostProp(host, ":onFlags", addedFlags)); addedFlags.length <= seqIdx; ) {
|
|
659
|
-
addedFlags.push(!1);
|
|
536
|
+
const useResourceQrl = (qrl, opts) => {
|
|
537
|
+
const {val, set, i, iCtx} = useSequentialScope();
|
|
538
|
+
if (null != val) {
|
|
539
|
+
return val;
|
|
660
540
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
events || (onMap[eventName] = events = []), events.push(eventQrl);
|
|
667
|
-
}
|
|
668
|
-
};
|
|
541
|
+
assertQrl(qrl);
|
|
542
|
+
const container = iCtx.$container$;
|
|
543
|
+
const resource = createResourceReturn(container, opts);
|
|
544
|
+
const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
|
|
545
|
+
return runResource(task, container, iCtx.$hostElement$), set(resource), resource;
|
|
669
546
|
};
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
683
|
-
set(task);
|
|
684
|
-
const result = runTask(task, iCtx.$container$, host);
|
|
685
|
-
if (isPromise(result)) {
|
|
686
|
-
throw result;
|
|
687
|
-
}
|
|
688
|
-
qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
|
|
547
|
+
const createResourceReturn = (container, opts, initialPromise) => {
|
|
548
|
+
const result = (opts => ({
|
|
549
|
+
__brand: "resource",
|
|
550
|
+
value: void 0,
|
|
551
|
+
loading: !isServerPlatform(),
|
|
552
|
+
_resolved: void 0,
|
|
553
|
+
_error: void 0,
|
|
554
|
+
_state: "pending",
|
|
555
|
+
_timeout: opts?.timeout ?? -1,
|
|
556
|
+
_cache: 0
|
|
557
|
+
}))(opts);
|
|
558
|
+
return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
|
|
689
559
|
};
|
|
690
|
-
const
|
|
560
|
+
const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
|
|
561
|
+
const runResource = (task, container, host) => {
|
|
691
562
|
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
692
|
-
const iCtx = newInvokeContext(container.$locale$, host, void 0, "
|
|
563
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
693
564
|
iCtx.$container$ = container;
|
|
694
565
|
const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
const
|
|
566
|
+
const resource = task.$state$;
|
|
567
|
+
assertDefined();
|
|
568
|
+
const cleanups = [];
|
|
569
|
+
task.$destroy$ = noSerialize((() => {
|
|
570
|
+
cleanups.forEach((fn => {
|
|
571
|
+
try {
|
|
572
|
+
fn();
|
|
573
|
+
} catch (err) {
|
|
574
|
+
container.handleError(err, host);
|
|
575
|
+
}
|
|
576
|
+
})), done = !0;
|
|
577
|
+
}));
|
|
578
|
+
const resourceTarget = unwrapStore(resource);
|
|
579
|
+
const opts = {
|
|
709
580
|
track: (obj, prop) => {
|
|
710
581
|
const ctx = newInvokeContext();
|
|
711
582
|
return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
|
|
712
583
|
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
713
584
|
},
|
|
714
|
-
cleanup
|
|
585
|
+
cleanup(fn) {
|
|
586
|
+
"function" == typeof fn && cleanups.push(fn);
|
|
587
|
+
},
|
|
588
|
+
cache(policy) {
|
|
589
|
+
let milliseconds = 0;
|
|
590
|
+
milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
|
|
591
|
+
},
|
|
592
|
+
previous: resourceTarget._resolved
|
|
715
593
|
};
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
594
|
+
let resolve;
|
|
595
|
+
let reject;
|
|
596
|
+
let done = !1;
|
|
597
|
+
const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
|
|
598
|
+
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
599
|
+
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
600
|
+
resource._error = value, reject(value)), !0);
|
|
601
|
+
cleanups.push((() => {
|
|
602
|
+
if (!0 === untrack((() => resource.loading))) {
|
|
603
|
+
const value = untrack((() => resource._resolved));
|
|
604
|
+
setState(!0, value);
|
|
726
605
|
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
$flags$;
|
|
739
|
-
$index$;
|
|
740
|
-
$el$;
|
|
741
|
-
$qrl$;
|
|
742
|
-
$state$;
|
|
743
|
-
$destroy$;
|
|
744
|
-
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
745
|
-
super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
|
|
746
|
-
this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
const isTask = value => value instanceof Task;
|
|
750
|
-
const _hW = () => {
|
|
751
|
-
const [task] = useLexicalScope();
|
|
752
|
-
getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
|
|
753
|
-
};
|
|
754
|
-
const STORE_TARGET = Symbol("store.target");
|
|
755
|
-
const STORE_HANDLER = Symbol("store.handler");
|
|
756
|
-
const STORE_ARRAY_PROP = Symbol("store.array");
|
|
757
|
-
var StoreFlags;
|
|
758
|
-
!function(StoreFlags) {
|
|
759
|
-
StoreFlags[StoreFlags.NONE = 0] = "NONE", StoreFlags[StoreFlags.RECURSIVE = 1] = "RECURSIVE",
|
|
760
|
-
StoreFlags[StoreFlags.IMMUTABLE = 2] = "IMMUTABLE";
|
|
761
|
-
}(StoreFlags || (StoreFlags = {}));
|
|
762
|
-
const getStoreHandler = value => value[STORE_HANDLER];
|
|
763
|
-
const getStoreTarget = value => value?.[STORE_TARGET] || null;
|
|
764
|
-
const unwrapStore = value => getStoreTarget(value) || value;
|
|
765
|
-
const isStore = value => STORE_TARGET in value;
|
|
766
|
-
function createStore(container, obj, flags) {
|
|
767
|
-
return new Proxy(obj, new StoreHandler(flags, container || null));
|
|
768
|
-
}
|
|
769
|
-
const getOrCreateStore = (obj, flags, container) => {
|
|
770
|
-
if (isSerializableObject(obj) && container) {
|
|
771
|
-
let store = container.$storeProxyMap$.get(obj);
|
|
772
|
-
return store || (store = createStore(container, obj, flags), container.$storeProxyMap$.set(obj, store)),
|
|
773
|
-
store;
|
|
774
|
-
}
|
|
775
|
-
return obj;
|
|
776
|
-
};
|
|
777
|
-
class StoreHandler {
|
|
778
|
-
$flags$;
|
|
779
|
-
$container$;
|
|
780
|
-
$effects$=null;
|
|
781
|
-
constructor($flags$, $container$) {
|
|
782
|
-
this.$flags$ = $flags$, this.$container$ = $container$;
|
|
783
|
-
}
|
|
784
|
-
toString() {
|
|
785
|
-
return "[Store]";
|
|
786
|
-
}
|
|
787
|
-
get(target, prop) {
|
|
788
|
-
if ("symbol" == typeof prop) {
|
|
789
|
-
return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
|
|
790
|
-
}
|
|
791
|
-
const ctx = tryGetInvokeContext();
|
|
792
|
-
const value = target[prop];
|
|
793
|
-
if (ctx) {
|
|
794
|
-
if (null === this.$container$) {
|
|
795
|
-
if (!ctx.$container$) {
|
|
796
|
-
return value;
|
|
797
|
-
}
|
|
798
|
-
this.$container$ = ctx.$container$;
|
|
799
|
-
} else {
|
|
800
|
-
assertTrue();
|
|
801
|
-
}
|
|
802
|
-
const effectSubscriber = ctx.$effectSubscriber$;
|
|
803
|
-
effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
804
|
-
}
|
|
805
|
-
if ("toString" === prop && value === Object.prototype.toString) {
|
|
806
|
-
return this.toString;
|
|
807
|
-
}
|
|
808
|
-
return this.$flags$ & StoreFlags.RECURSIVE && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
|
|
809
|
-
}
|
|
810
|
-
set(target, prop, value) {
|
|
811
|
-
if (target = unwrapDeserializerProxy(target), "symbol" == typeof prop) {
|
|
812
|
-
return target[prop] = value, !0;
|
|
813
|
-
}
|
|
814
|
-
const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
|
|
815
|
-
if (prop in target) {
|
|
816
|
-
newValue !== target[prop] && setNewValueAndTriggerEffects(prop, newValue, target, this);
|
|
817
|
-
} else {
|
|
818
|
-
setNewValueAndTriggerEffects(prop, newValue, target, this);
|
|
819
|
-
}
|
|
820
|
-
return !0;
|
|
821
|
-
}
|
|
822
|
-
deleteProperty(target, prop) {
|
|
823
|
-
return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)),
|
|
824
|
-
!0);
|
|
825
|
-
}
|
|
826
|
-
has(target, prop) {
|
|
827
|
-
if (prop === STORE_TARGET) {
|
|
828
|
-
return !0;
|
|
829
|
-
}
|
|
830
|
-
if ("string" == typeof prop) {
|
|
831
|
-
const ctx = tryGetInvokeContext();
|
|
832
|
-
if (ctx) {
|
|
833
|
-
const effectSubscriber = ctx.$effectSubscriber$;
|
|
834
|
-
effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
838
|
-
}
|
|
839
|
-
ownKeys(target) {
|
|
840
|
-
const ctx = tryGetInvokeContext();
|
|
841
|
-
const effectSubscriber = ctx?.$effectSubscriber$;
|
|
842
|
-
return effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber),
|
|
843
|
-
Reflect.ownKeys(target);
|
|
844
|
-
}
|
|
845
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
846
|
-
return Array.isArray(target) || "symbol" == typeof prop ? Object.getOwnPropertyDescriptor(target, prop) : {
|
|
847
|
-
enumerable: !0,
|
|
848
|
-
configurable: !0
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
function addEffect(target, prop, store, effectSubscriber) {
|
|
853
|
-
const effectsMap = store.$effects$ ||= {};
|
|
854
|
-
const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
|
|
855
|
-
ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target);
|
|
856
|
-
}
|
|
857
|
-
function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
|
|
858
|
-
target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
|
|
859
|
-
}
|
|
860
|
-
function getEffects(target, prop, storeEffects) {
|
|
861
|
-
let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
|
|
862
|
-
const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
|
|
863
|
-
return storeArrayValue && (effectsToTrigger ||= [], effectsToTrigger.push(...storeArrayValue)),
|
|
864
|
-
effectsToTrigger;
|
|
865
|
-
}
|
|
866
|
-
const useResourceQrl = (qrl, opts) => {
|
|
867
|
-
const {val, set, i, iCtx} = useSequentialScope();
|
|
868
|
-
if (null != val) {
|
|
869
|
-
return val;
|
|
870
|
-
}
|
|
871
|
-
assertQrl(qrl);
|
|
872
|
-
const container = iCtx.$container$;
|
|
873
|
-
const resource = createResourceReturn(container, opts);
|
|
874
|
-
const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
|
|
875
|
-
return runResource(task, container, iCtx.$hostElement$), set(resource), resource;
|
|
876
|
-
};
|
|
877
|
-
const createResourceReturn = (container, opts, initialPromise) => {
|
|
878
|
-
const result = (opts => ({
|
|
879
|
-
__brand: "resource",
|
|
880
|
-
value: void 0,
|
|
881
|
-
loading: !isServerPlatform(),
|
|
882
|
-
_resolved: void 0,
|
|
883
|
-
_error: void 0,
|
|
884
|
-
_state: "pending",
|
|
885
|
-
_timeout: opts?.timeout ?? -1,
|
|
886
|
-
_cache: 0
|
|
887
|
-
}))(opts);
|
|
888
|
-
return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
|
|
889
|
-
};
|
|
890
|
-
const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
|
|
891
|
-
const runResource = (task, container, host) => {
|
|
892
|
-
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
893
|
-
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
894
|
-
iCtx.$container$ = container;
|
|
895
|
-
const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
|
|
896
|
-
const resource = task.$state$;
|
|
897
|
-
assertDefined();
|
|
898
|
-
const cleanups = [];
|
|
899
|
-
task.$destroy$ = noSerialize((() => {
|
|
900
|
-
cleanups.forEach((fn => {
|
|
901
|
-
try {
|
|
902
|
-
fn();
|
|
903
|
-
} catch (err) {
|
|
904
|
-
container.handleError(err, host);
|
|
905
|
-
}
|
|
906
|
-
})), done = !0;
|
|
907
|
-
}));
|
|
908
|
-
const resourceTarget = unwrapStore(resource);
|
|
909
|
-
const opts = {
|
|
910
|
-
track: (obj, prop) => {
|
|
911
|
-
const ctx = newInvokeContext();
|
|
912
|
-
return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
|
|
913
|
-
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
914
|
-
},
|
|
915
|
-
cleanup(fn) {
|
|
916
|
-
"function" == typeof fn && cleanups.push(fn);
|
|
917
|
-
},
|
|
918
|
-
cache(policy) {
|
|
919
|
-
let milliseconds = 0;
|
|
920
|
-
milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
|
|
921
|
-
},
|
|
922
|
-
previous: resourceTarget._resolved
|
|
923
|
-
};
|
|
924
|
-
let resolve;
|
|
925
|
-
let reject;
|
|
926
|
-
let done = !1;
|
|
927
|
-
const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
|
|
928
|
-
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
929
|
-
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
930
|
-
resource._error = value, reject(value)), !0);
|
|
931
|
-
cleanups.push((() => {
|
|
932
|
-
if (!0 === untrack((() => resource.loading))) {
|
|
933
|
-
const value = untrack((() => resource._resolved));
|
|
934
|
-
setState(!0, value);
|
|
935
|
-
}
|
|
936
|
-
})), invoke(iCtx, (() => {
|
|
937
|
-
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
938
|
-
(resource.value = new Promise(((r, re) => {
|
|
939
|
-
resolve = r, reject = re;
|
|
940
|
-
}))).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
941
|
-
}));
|
|
942
|
-
const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
|
|
943
|
-
setState(!0, value);
|
|
944
|
-
}), (err => {
|
|
945
|
-
if (isPromise(err)) {
|
|
946
|
-
return err.then((() => runResource(task, container, host)));
|
|
606
|
+
})), invoke(iCtx, (() => {
|
|
607
|
+
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
608
|
+
(resource.value = new Promise(((r, re) => {
|
|
609
|
+
resolve = r, reject = re;
|
|
610
|
+
}))).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
611
|
+
}));
|
|
612
|
+
const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
|
|
613
|
+
setState(!0, value);
|
|
614
|
+
}), (err => {
|
|
615
|
+
if (isPromise(err)) {
|
|
616
|
+
return err.then((() => runResource(task, container, host)));
|
|
947
617
|
}
|
|
948
618
|
setState(!1, err);
|
|
949
619
|
}));
|
|
@@ -1083,6 +753,41 @@
|
|
|
1083
753
|
elementNamespaceFlag
|
|
1084
754
|
};
|
|
1085
755
|
}
|
|
756
|
+
const useOn = (event, eventQrl) => {
|
|
757
|
+
_useOn(createEventName(event, void 0), eventQrl);
|
|
758
|
+
};
|
|
759
|
+
const useOnDocument = (event, eventQrl) => {
|
|
760
|
+
_useOn(createEventName(event, "document"), eventQrl);
|
|
761
|
+
};
|
|
762
|
+
const createEventName = (event, eventType) => {
|
|
763
|
+
const prefix = void 0 !== eventType ? eventType + ":" : "";
|
|
764
|
+
const map = name => prefix + "on" + name.charAt(0).toUpperCase() + name.substring(1) + "$";
|
|
765
|
+
return Array.isArray(event) ? event.map(map) : map(event);
|
|
766
|
+
};
|
|
767
|
+
const _useOn = (eventName, eventQrl) => {
|
|
768
|
+
const {isAdded, addEvent} = useOnEventsSequentialScope();
|
|
769
|
+
isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach((event => addEvent(event, eventQrl))) : addEvent(eventName, eventQrl));
|
|
770
|
+
};
|
|
771
|
+
const useOnEventsSequentialScope = () => {
|
|
772
|
+
const iCtx = useInvokeContext();
|
|
773
|
+
const host = iCtx.$hostElement$;
|
|
774
|
+
let onMap = iCtx.$container$.getHostProp(host, ":on");
|
|
775
|
+
null === onMap && (onMap = {}, iCtx.$container$.setHostProp(host, ":on", onMap));
|
|
776
|
+
let seqIdx = iCtx.$container$.getHostProp(host, ":onIdx");
|
|
777
|
+
null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, ":onIdx", seqIdx + 1);
|
|
778
|
+
let addedFlags = iCtx.$container$.getHostProp(host, ":onFlags");
|
|
779
|
+
for (null === addedFlags && (addedFlags = [], iCtx.$container$.setHostProp(host, ":onFlags", addedFlags)); addedFlags.length <= seqIdx; ) {
|
|
780
|
+
addedFlags.push(!1);
|
|
781
|
+
}
|
|
782
|
+
return {
|
|
783
|
+
isAdded: addedFlags[seqIdx],
|
|
784
|
+
addEvent: (eventName, eventQrl) => {
|
|
785
|
+
addedFlags[seqIdx] = !0;
|
|
786
|
+
let events = onMap[eventName];
|
|
787
|
+
events || (onMap[eventName] = events = []), events.push(eventQrl);
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
};
|
|
1086
791
|
const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
|
|
1087
792
|
const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, "qRender");
|
|
1088
793
|
let componentFn;
|
|
@@ -1103,7 +808,8 @@
|
|
|
1103
808
|
}
|
|
1104
809
|
const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
|
|
1105
810
|
container.setHostProp(renderHost, ":onIdx", null), container.getHostProp(renderHost, "q:props") !== props && container.setHostProp(renderHost, "q:props", props)),
|
|
1106
|
-
vnode_isVNode(renderHost) && clearVNodeEffectDependencies(
|
|
811
|
+
vnode_isVNode(renderHost) && clearVNodeEffectDependencies(container, renderHost),
|
|
812
|
+
componentFn(props))), (jsx => {
|
|
1107
813
|
const useOnEvents = container.getHostProp(renderHost, ":on");
|
|
1108
814
|
return useOnEvents ? maybeThen(function(jsx, useOnEvents) {
|
|
1109
815
|
const jsxElement = findFirstStringJSX(jsx);
|
|
@@ -1164,6 +870,9 @@
|
|
|
1164
870
|
}
|
|
1165
871
|
return Array.isArray(jsx) && jsx.length ? addScriptNodeForInvisibleComponents(jsx[0]) : null;
|
|
1166
872
|
}
|
|
873
|
+
function isSlotProp(prop) {
|
|
874
|
+
return !prop.startsWith("q:") && !prop.startsWith(":");
|
|
875
|
+
}
|
|
1167
876
|
function escapeHTML(html) {
|
|
1168
877
|
let escapedHTML = "";
|
|
1169
878
|
const length = html.length;
|
|
@@ -1226,8 +935,8 @@
|
|
|
1226
935
|
if (Array.isArray(jsxValue)) {
|
|
1227
936
|
descend(jsxValue, !1);
|
|
1228
937
|
} else if (isSignal(jsxValue)) {
|
|
1229
|
-
vCurrent && clearVNodeEffectDependencies(vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
|
|
1230
|
-
descend(
|
|
938
|
+
vCurrent && clearVNodeEffectDependencies(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
|
|
939
|
+
descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
|
|
1231
940
|
} else if (isPromise(jsxValue)) {
|
|
1232
941
|
expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
|
|
1233
942
|
} else if (isJSXNode(jsxValue)) {
|
|
@@ -1320,7 +1029,7 @@
|
|
|
1320
1029
|
if (constProps && "object" == typeof constProps && "name" in constProps) {
|
|
1321
1030
|
const constValue = constProps.name;
|
|
1322
1031
|
if (vHost && constValue instanceof WrappedSignal) {
|
|
1323
|
-
return
|
|
1032
|
+
return trackSignalAndAssignHost(constValue, vHost, EffectProperty.COMPONENT, container);
|
|
1324
1033
|
}
|
|
1325
1034
|
}
|
|
1326
1035
|
return directGetPropsProxyProp(jsxNode, "name") || "";
|
|
@@ -1379,18 +1088,20 @@
|
|
|
1379
1088
|
}
|
|
1380
1089
|
}
|
|
1381
1090
|
if (isSignal(value)) {
|
|
1382
|
-
const signalData = new
|
|
1091
|
+
const signalData = new EffectPropData({
|
|
1383
1092
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1384
1093
|
$isConst$: !0
|
|
1385
1094
|
});
|
|
1386
|
-
value =
|
|
1095
|
+
value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
|
|
1387
1096
|
}
|
|
1388
1097
|
if ("dangerouslySetInnerHTML" !== key) {
|
|
1389
1098
|
if ("textarea" !== elementName || "value" !== key) {
|
|
1390
1099
|
value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && element.setAttribute(key, String(value));
|
|
1391
1100
|
} else {
|
|
1392
1101
|
if ("string" != typeof value) {
|
|
1393
|
-
build.isDev
|
|
1102
|
+
if (build.isDev) {
|
|
1103
|
+
throw qError(QError.wrongTextareaValue);
|
|
1104
|
+
}
|
|
1394
1105
|
continue;
|
|
1395
1106
|
}
|
|
1396
1107
|
element.value = escapeHTML(value);
|
|
@@ -1457,7 +1168,7 @@
|
|
|
1457
1168
|
htmlEvent && record(htmlEvent, ""), eventName && registerQwikLoaderEvent(eventName);
|
|
1458
1169
|
};
|
|
1459
1170
|
for (;null !== srcKey || null !== dstKey; ) {
|
|
1460
|
-
if (dstKey?.startsWith(HANDLER_PREFIX) || "q:
|
|
1171
|
+
if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
|
|
1461
1172
|
dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
1462
1173
|
} else if (null == srcKey) {
|
|
1463
1174
|
dstKey && isHtmlAttributeAnEventName(dstKey) ? (patchEventDispatch = !0, dstIdx++) : (record(dstKey, null),
|
|
@@ -1543,8 +1254,8 @@
|
|
|
1543
1254
|
if (!src || !dst) {
|
|
1544
1255
|
return !0;
|
|
1545
1256
|
}
|
|
1546
|
-
let srcKeys =
|
|
1547
|
-
let dstKeys =
|
|
1257
|
+
let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:subs" ]);
|
|
1258
|
+
let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:subs" ]);
|
|
1548
1259
|
if (srcKeys.length !== dstKeys.length) {
|
|
1549
1260
|
return !0;
|
|
1550
1261
|
}
|
|
@@ -1607,7 +1318,7 @@
|
|
|
1607
1318
|
}
|
|
1608
1319
|
}
|
|
1609
1320
|
function insertNewComponent(host, componentQRL, jsxProps) {
|
|
1610
|
-
host && clearVNodeEffectDependencies(host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1321
|
+
host && clearVNodeEffectDependencies(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1611
1322
|
const jsxNode = jsxValue;
|
|
1612
1323
|
build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
|
|
1613
1324
|
container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
|
|
@@ -1632,9 +1343,12 @@
|
|
|
1632
1343
|
return qrl ? qrl.$hash$ : null;
|
|
1633
1344
|
}
|
|
1634
1345
|
function Projection() {}
|
|
1635
|
-
function
|
|
1636
|
-
|
|
1637
|
-
|
|
1346
|
+
function removePropsKeys(keys, propKeys) {
|
|
1347
|
+
for (let i = propKeys.length - 1; i >= 0; i--) {
|
|
1348
|
+
const propIdx = keys.indexOf(propKeys[i]);
|
|
1349
|
+
-1 !== propIdx && keys.splice(propIdx, 1);
|
|
1350
|
+
}
|
|
1351
|
+
return keys;
|
|
1638
1352
|
}
|
|
1639
1353
|
function cleanup(container, vNode) {
|
|
1640
1354
|
let vCursor = vNode;
|
|
@@ -1645,8 +1359,8 @@
|
|
|
1645
1359
|
for (;;) {
|
|
1646
1360
|
const type = vCursor[VNodeProps.flags];
|
|
1647
1361
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
1648
|
-
if (
|
|
1649
|
-
|
|
1362
|
+
if (clearVNodeEffectDependencies(container, vCursor), markVNodeAsDeleted(vCursor),
|
|
1363
|
+
type & VNodeFlags.Virtual) {
|
|
1650
1364
|
const seq = container.getHostProp(vCursor, "q:seq");
|
|
1651
1365
|
if (seq) {
|
|
1652
1366
|
for (let i = 0; i < seq.length; i++) {
|
|
@@ -1727,26 +1441,33 @@
|
|
|
1727
1441
|
const HANDLER_PREFIX = ":";
|
|
1728
1442
|
let count = 0;
|
|
1729
1443
|
var SiblingsArray;
|
|
1730
|
-
var ChoreType;
|
|
1731
1444
|
!function(SiblingsArray) {
|
|
1732
1445
|
SiblingsArray[SiblingsArray.Name = 0] = "Name", SiblingsArray[SiblingsArray.Key = 1] = "Key",
|
|
1733
1446
|
SiblingsArray[SiblingsArray.VNode = 2] = "VNode", SiblingsArray[SiblingsArray.Size = 3] = "Size",
|
|
1734
1447
|
SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
|
|
1735
|
-
}(SiblingsArray || (SiblingsArray = {}))
|
|
1736
|
-
|
|
1448
|
+
}(SiblingsArray || (SiblingsArray = {}));
|
|
1449
|
+
const implicit$FirstArg = fn => function(first, ...rest) {
|
|
1450
|
+
return fn.call(null, dollar(first), ...rest);
|
|
1451
|
+
};
|
|
1452
|
+
const createSignal = value => new Signal(null, value);
|
|
1453
|
+
const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
|
|
1454
|
+
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
|
|
1455
|
+
var ChoreType;
|
|
1456
|
+
!function(ChoreType) {
|
|
1457
|
+
ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
|
|
1737
1458
|
ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RESOURCE = 2] = "RESOURCE",
|
|
1738
1459
|
ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
|
|
1739
1460
|
ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
|
|
1740
|
-
ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.
|
|
1741
|
-
ChoreType[ChoreType.JOURNAL_FLUSH =
|
|
1742
|
-
ChoreType[ChoreType.CLEANUP_VISIBLE =
|
|
1461
|
+
ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
|
|
1462
|
+
ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
|
|
1463
|
+
ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
|
|
1743
1464
|
}(ChoreType || (ChoreType = {}));
|
|
1744
1465
|
const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
1745
1466
|
const choreQueue = [];
|
|
1746
1467
|
let currentChore = null;
|
|
1747
1468
|
let journalFlushScheduled = !1;
|
|
1748
1469
|
return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
|
|
1749
|
-
const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.
|
|
1470
|
+
const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.COMPONENT_SSR;
|
|
1750
1471
|
const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.RESOURCE || type === ChoreType.CLEANUP_VISIBLE;
|
|
1751
1472
|
isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
|
|
1752
1473
|
let chore = {
|
|
@@ -1876,6 +1597,19 @@
|
|
|
1876
1597
|
returnValue = target.resolved ? null : target.resolve();
|
|
1877
1598
|
break;
|
|
1878
1599
|
}
|
|
1600
|
+
|
|
1601
|
+
case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
|
|
1602
|
+
{
|
|
1603
|
+
const target = chore.$target$;
|
|
1604
|
+
const forceRunEffects = target.$forceRunEffects$;
|
|
1605
|
+
if (target.$forceRunEffects$ = !1, !target.$effects$?.length) {
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
returnValue = retryOnPromise((() => {
|
|
1609
|
+
(target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
|
|
1610
|
+
}));
|
|
1611
|
+
break;
|
|
1612
|
+
}
|
|
1879
1613
|
}
|
|
1880
1614
|
return thenFn = value => (currentChore && (currentChore.$executed$ = !0, currentChore.$resolve$?.(value)),
|
|
1881
1615
|
currentChore = null, chore.$returnValue$ = value), isPromise(valueOrPromise = returnValue) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
@@ -1897,8 +1631,10 @@
|
|
|
1897
1631
|
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
1898
1632
|
if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
|
|
1899
1633
|
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()}`;
|
|
1900
|
-
|
|
1901
|
-
|
|
1634
|
+
if (shouldThrowOnHostMismatch) {
|
|
1635
|
+
throw qError(QError.serverHostMismatch, [ errorMessage ]);
|
|
1636
|
+
}
|
|
1637
|
+
return logWarn(errorMessage), null;
|
|
1902
1638
|
}
|
|
1903
1639
|
{
|
|
1904
1640
|
const hostDiff = vnode_documentPosition(aHost, bHost);
|
|
@@ -1915,456 +1651,338 @@
|
|
|
1915
1651
|
if (0 !== idxDiff) {
|
|
1916
1652
|
return idxDiff;
|
|
1917
1653
|
}
|
|
1918
|
-
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)) {
|
|
1654
|
+
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)) {
|
|
1919
1655
|
return 1;
|
|
1920
1656
|
}
|
|
1921
1657
|
}
|
|
1922
1658
|
return 0;
|
|
1923
1659
|
}
|
|
1924
|
-
const
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
|
|
1936
|
-
this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
|
|
1937
|
-
throw Error("Not implemented");
|
|
1938
|
-
}, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
|
|
1939
|
-
}
|
|
1940
|
-
trackSignalValue(signal, subscriber, property, data) {
|
|
1941
|
-
return trackSignal((() => signal.value), subscriber, property, this, data);
|
|
1660
|
+
const useLexicalScope = () => {
|
|
1661
|
+
const context = getInvokeContext();
|
|
1662
|
+
let qrl = context.$qrl$;
|
|
1663
|
+
if (qrl) {
|
|
1664
|
+
assertQrl(qrl), assertDefined();
|
|
1665
|
+
} else {
|
|
1666
|
+
const el = context.$element$;
|
|
1667
|
+
assertDefined();
|
|
1668
|
+
const containerElement = _getQContainerElement(el);
|
|
1669
|
+
assertDefined();
|
|
1670
|
+
qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
|
|
1942
1671
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1672
|
+
return qrl.$captureRef$;
|
|
1673
|
+
};
|
|
1674
|
+
var TaskFlags;
|
|
1675
|
+
!function(TaskFlags) {
|
|
1676
|
+
TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
|
|
1677
|
+
TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
|
|
1678
|
+
}(TaskFlags || (TaskFlags = {}));
|
|
1679
|
+
const useTaskQrl = (qrl, opts) => {
|
|
1680
|
+
const {val, set, iCtx, i} = useSequentialScope();
|
|
1681
|
+
if (val) {
|
|
1682
|
+
return;
|
|
1683
|
+
}
|
|
1684
|
+
assertQrl(qrl), set(1);
|
|
1685
|
+
const host = iCtx.$hostElement$;
|
|
1686
|
+
const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
1687
|
+
set(task);
|
|
1688
|
+
const result = runTask(task, iCtx.$container$, host);
|
|
1689
|
+
if (isPromise(result)) {
|
|
1690
|
+
throw result;
|
|
1691
|
+
}
|
|
1692
|
+
qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
|
|
1693
|
+
};
|
|
1694
|
+
const runTask = (task, container, host) => {
|
|
1695
|
+
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
1696
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
1697
|
+
iCtx.$container$ = container;
|
|
1698
|
+
const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(task)));
|
|
1699
|
+
const handleError = reason => container.handleError(reason, host);
|
|
1700
|
+
let cleanupFns = null;
|
|
1701
|
+
const cleanup = fn => {
|
|
1702
|
+
"function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
|
|
1703
|
+
task.$destroy$ = null, cleanupFns.forEach((fn => {
|
|
1704
|
+
try {
|
|
1705
|
+
fn();
|
|
1706
|
+
} catch (err) {
|
|
1707
|
+
handleError(err);
|
|
1708
|
+
}
|
|
1709
|
+
}));
|
|
1710
|
+
}))), cleanupFns.push(fn));
|
|
1711
|
+
};
|
|
1712
|
+
const taskApi = {
|
|
1713
|
+
track: (obj, prop) => {
|
|
1714
|
+
const ctx = newInvokeContext();
|
|
1715
|
+
return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
|
|
1716
|
+
invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
|
|
1717
|
+
},
|
|
1718
|
+
cleanup
|
|
1719
|
+
};
|
|
1720
|
+
return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
|
|
1721
|
+
};
|
|
1722
|
+
const cleanupTask = task => {
|
|
1723
|
+
const destroy = task.$destroy$;
|
|
1724
|
+
if (destroy) {
|
|
1725
|
+
task.$destroy$ = null;
|
|
1726
|
+
try {
|
|
1727
|
+
destroy();
|
|
1728
|
+
} catch (err) {
|
|
1729
|
+
((message, ...optionalParams) => {
|
|
1730
|
+
createAndLogError(!1, message, ...optionalParams);
|
|
1731
|
+
})(err);
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
};
|
|
1735
|
+
const useRunTask = (task, eagerness) => {
|
|
1736
|
+
"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));
|
|
1737
|
+
};
|
|
1738
|
+
const getTaskHandlerQrl = task => {
|
|
1739
|
+
const taskQrl = task.$qrl$;
|
|
1740
|
+
const taskHandler = createQRL(taskQrl.$chunk$, "_hW", _hW, null, null, [ task ], taskQrl.$symbol$);
|
|
1741
|
+
return taskQrl.dev && (taskHandler.dev = taskQrl.dev), taskHandler;
|
|
1742
|
+
};
|
|
1743
|
+
class Task extends Subscriber {
|
|
1744
|
+
$flags$;
|
|
1745
|
+
$index$;
|
|
1746
|
+
$el$;
|
|
1747
|
+
$qrl$;
|
|
1748
|
+
$state$;
|
|
1749
|
+
$destroy$;
|
|
1750
|
+
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
1751
|
+
super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
|
|
1752
|
+
this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
1945
1753
|
}
|
|
1946
1754
|
}
|
|
1947
|
-
const
|
|
1948
|
-
const
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1755
|
+
const isTask = value => value instanceof Task;
|
|
1756
|
+
const _hW = () => {
|
|
1757
|
+
const [task] = useLexicalScope();
|
|
1758
|
+
getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
|
|
1759
|
+
};
|
|
1760
|
+
const NEEDS_COMPUTATION = Symbol("invalid");
|
|
1761
|
+
const throwIfQRLNotResolved = qrl => {
|
|
1762
|
+
if (!qrl.resolved) {
|
|
1763
|
+
throw qrl.resolve();
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
const isSignal = value => value instanceof Signal;
|
|
1767
|
+
class EffectPropData {
|
|
1768
|
+
data;
|
|
1769
|
+
constructor(data) {
|
|
1770
|
+
this.data = data;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
var EffectSubscriptionsProp;
|
|
1774
|
+
var EffectProperty;
|
|
1775
|
+
!function(EffectSubscriptionsProp) {
|
|
1776
|
+
EffectSubscriptionsProp[EffectSubscriptionsProp.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp[EffectSubscriptionsProp.PROPERTY = 1] = "PROPERTY",
|
|
1777
|
+
EffectSubscriptionsProp[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
|
|
1778
|
+
}(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty) {
|
|
1779
|
+
EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
|
|
1780
|
+
}(EffectProperty || (EffectProperty = {}));
|
|
1781
|
+
class Signal {
|
|
1782
|
+
$untrackedValue$;
|
|
1783
|
+
$effects$=null;
|
|
1784
|
+
$container$=null;
|
|
1785
|
+
constructor(container, value) {
|
|
1786
|
+
this.$container$ = container, this.$untrackedValue$ = value;
|
|
1787
|
+
}
|
|
1788
|
+
get untrackedValue() {
|
|
1789
|
+
return this.$untrackedValue$;
|
|
1790
|
+
}
|
|
1791
|
+
set untrackedValue(value) {
|
|
1792
|
+
this.$untrackedValue$ = value;
|
|
1793
|
+
}
|
|
1794
|
+
get value() {
|
|
1795
|
+
const ctx = tryGetInvokeContext();
|
|
1796
|
+
if (ctx) {
|
|
1797
|
+
if (null === this.$container$) {
|
|
1798
|
+
if (!ctx.$container$) {
|
|
1799
|
+
return this.untrackedValue;
|
|
1965
1800
|
}
|
|
1801
|
+
this.$container$ = ctx.$container$;
|
|
1802
|
+
} else {
|
|
1803
|
+
assertTrue();
|
|
1804
|
+
}
|
|
1805
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1806
|
+
if (effectSubscriber) {
|
|
1807
|
+
const effects = this.$effects$ ||= [];
|
|
1808
|
+
ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this),
|
|
1809
|
+
isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
|
|
1966
1810
|
}
|
|
1967
1811
|
}
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1812
|
+
return this.untrackedValue;
|
|
1813
|
+
}
|
|
1814
|
+
set value(value) {
|
|
1815
|
+
value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
|
|
1816
|
+
}
|
|
1817
|
+
valueOf() {
|
|
1818
|
+
qDev;
|
|
1819
|
+
}
|
|
1820
|
+
toString() {
|
|
1821
|
+
return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
|
|
1822
|
+
}
|
|
1823
|
+
toJSON() {
|
|
1824
|
+
return {
|
|
1825
|
+
value: this.$untrackedValue$
|
|
1826
|
+
};
|
|
1971
1827
|
}
|
|
1972
|
-
return container;
|
|
1973
|
-
}
|
|
1974
|
-
function _getQContainerElement(element) {
|
|
1975
|
-
return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
|
|
1976
1828
|
}
|
|
1977
|
-
const
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
1829
|
+
const ensureContains = (array, value) => {
|
|
1830
|
+
-1 === array.indexOf(value) && array.push(value);
|
|
1831
|
+
};
|
|
1832
|
+
const ensureContainsEffect = (array, effectSubscriptions) => {
|
|
1833
|
+
for (let i = 0; i < array.length; i++) {
|
|
1834
|
+
const existingEffect = array[i];
|
|
1835
|
+
if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
array.push(effectSubscriptions);
|
|
1840
|
+
};
|
|
1841
|
+
const ensureEffectContainsSubscriber = (effect, subscriber, container) => {
|
|
1842
|
+
if (isSubscriber(effect)) {
|
|
1843
|
+
if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
effect.$effectDependencies$.push(subscriber);
|
|
1847
|
+
} else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
|
|
1848
|
+
let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
|
|
1849
|
+
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
1850
|
+
return;
|
|
1851
|
+
}
|
|
1852
|
+
subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
|
|
1853
|
+
} else if (isSSRNode(effect)) {
|
|
1854
|
+
let subscribers = effect.getProp("q:subs");
|
|
1855
|
+
if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
1856
|
+
return;
|
|
1857
|
+
}
|
|
1858
|
+
subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
const isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
|
|
1862
|
+
const subscriberExistInSubscribers = (subscribers, subscriber) => {
|
|
1863
|
+
for (let i = 0; i < subscribers.length; i++) {
|
|
1864
|
+
if (subscribers[i] === subscriber) {
|
|
1865
|
+
return !0;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
return !1;
|
|
1869
|
+
};
|
|
1870
|
+
const triggerEffects = (container, signal, effects) => {
|
|
1871
|
+
if (effects) {
|
|
1872
|
+
const scheduleEffect = effectSubscriptions => {
|
|
1873
|
+
const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
|
|
1874
|
+
const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
|
|
1875
|
+
if (assertDefined(), isTask(effect)) {
|
|
1876
|
+
effect.$flags$ |= TaskFlags.DIRTY;
|
|
1877
|
+
let choreType = ChoreType.TASK;
|
|
1878
|
+
effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE),
|
|
1879
|
+
container.$scheduler$(choreType, effect);
|
|
1880
|
+
} else if (effect instanceof Signal) {
|
|
1881
|
+
effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$)),
|
|
1882
|
+
effect.$invalidate$();
|
|
1883
|
+
} else if (property === EffectProperty.COMPONENT) {
|
|
1884
|
+
const host = effect;
|
|
1885
|
+
const qrl = container.getHostProp(host, "q:renderFn");
|
|
1886
|
+
assertDefined();
|
|
1887
|
+
const props = container.getHostProp(host, "q:props");
|
|
1888
|
+
container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
|
|
1889
|
+
} else if (property === EffectProperty.VNODE) {
|
|
1890
|
+
container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
|
|
1891
|
+
} else {
|
|
1892
|
+
const effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
|
|
1893
|
+
if (effectData instanceof EffectPropData) {
|
|
1894
|
+
const payload = {
|
|
1895
|
+
...effectData.data,
|
|
1896
|
+
$value$: signal
|
|
1897
|
+
};
|
|
1898
|
+
container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
|
|
2012
1899
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
})(prototype, "nodeType");
|
|
2017
|
-
const attachVnodeDataAndRefs = element => {
|
|
2018
|
-
Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
|
|
2019
|
-
script.setAttribute("type", "x-qwik/vnode");
|
|
2020
|
-
const qContainerElement = script.closest("[q\\:container]");
|
|
2021
|
-
qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
|
|
2022
|
-
})), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
|
|
2023
|
-
const shadowRoot = parent.shadowRoot;
|
|
2024
|
-
shadowRoot && attachVnodeDataAndRefs(shadowRoot);
|
|
2025
|
-
}));
|
|
2026
|
-
};
|
|
2027
|
-
let NodeType;
|
|
2028
|
-
attachVnodeDataAndRefs(document), function(NodeType) {
|
|
2029
|
-
NodeType[NodeType.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType[NodeType.ELEMENT = 2] = "ELEMENT",
|
|
2030
|
-
NodeType[NodeType.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType[NodeType.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT",
|
|
2031
|
-
NodeType[NodeType.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType[NodeType.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END",
|
|
2032
|
-
NodeType[NodeType.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType[NodeType.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END",
|
|
2033
|
-
NodeType[NodeType.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType[NodeType.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END",
|
|
2034
|
-
NodeType[NodeType.OTHER = 0] = "OTHER";
|
|
2035
|
-
}(NodeType || (NodeType = {}));
|
|
2036
|
-
const getFastNodeType = node => {
|
|
2037
|
-
const nodeType = getNodeType.call(node);
|
|
2038
|
-
if (1 === nodeType) {
|
|
2039
|
-
return null === getAttribute.call(node, "q:container") ? hasAttribute.call(node, "q:shadowroot") ? NodeType.ELEMENT_SHADOW_ROOT : hasAttribute.call(node, ":") ? NodeType.ELEMENT : NodeType.OTHER : NodeType.ELEMENT_CONTAINER;
|
|
2040
|
-
}
|
|
2041
|
-
if (8 === nodeType) {
|
|
2042
|
-
const nodeValue = node.nodeValue || "";
|
|
2043
|
-
if (nodeValue.startsWith("q:container-island")) {
|
|
2044
|
-
return NodeType.COMMENT_ISLAND_START;
|
|
2045
|
-
}
|
|
2046
|
-
if (nodeValue.startsWith("q:ignore")) {
|
|
2047
|
-
return NodeType.COMMENT_IGNORE_START;
|
|
2048
|
-
}
|
|
2049
|
-
if (nodeValue.startsWith("q:container")) {
|
|
2050
|
-
return NodeType.COMMENT_SKIP_START;
|
|
2051
|
-
}
|
|
2052
|
-
if (nodeValue.startsWith("/q:container-island")) {
|
|
2053
|
-
return NodeType.COMMENT_ISLAND_END;
|
|
2054
|
-
}
|
|
2055
|
-
if (nodeValue.startsWith("/q:ignore")) {
|
|
2056
|
-
return NodeType.COMMENT_IGNORE_END;
|
|
2057
|
-
}
|
|
2058
|
-
if (nodeValue.startsWith("/q:container")) {
|
|
2059
|
-
return NodeType.COMMENT_SKIP_END;
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
return NodeType.OTHER;
|
|
2063
|
-
};
|
|
2064
|
-
const isSeparator = ch => VNodeDataSeparator_ADVANCE_1 <= ch && ch <= VNodeDataSeparator_ADVANCE_8192;
|
|
2065
|
-
const findVDataSectionEnd = (vData, start, end) => {
|
|
2066
|
-
let depth = 0;
|
|
2067
|
-
for (;start < end; ) {
|
|
2068
|
-
const ch = vData.charCodeAt(start);
|
|
2069
|
-
if (0 === depth && isSeparator(ch)) {
|
|
2070
|
-
break;
|
|
2071
|
-
}
|
|
2072
|
-
ch === VNodeDataChar_OPEN ? depth++ : ch === VNodeDataChar_CLOSE && depth--, start++;
|
|
2073
|
-
}
|
|
2074
|
-
return start;
|
|
2075
|
-
};
|
|
2076
|
-
const nextSibling = node => {
|
|
2077
|
-
for (;node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {}
|
|
2078
|
-
return node;
|
|
2079
|
-
};
|
|
2080
|
-
const firstChild = node => {
|
|
2081
|
-
for (;node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {}
|
|
2082
|
-
return node;
|
|
2083
|
-
};
|
|
2084
|
-
const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
|
|
2085
|
-
const vData_length = vData.length;
|
|
2086
|
-
let elementIdx = 0;
|
|
2087
|
-
let vNodeElementIndex = -1;
|
|
2088
|
-
let vData_start = 0;
|
|
2089
|
-
let vData_end = 0;
|
|
2090
|
-
let ch = 0;
|
|
2091
|
-
let needsToStoreRef = -1;
|
|
2092
|
-
let nextNode = null;
|
|
2093
|
-
const howManyElementsToSkip = () => {
|
|
2094
|
-
let elementsToSkip = 0;
|
|
2095
|
-
for (;isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator_ADVANCE_1,
|
|
2096
|
-
vData_start++, !(vData_start >= vData_length)); ) {}
|
|
2097
|
-
return elementsToSkip;
|
|
2098
|
-
};
|
|
2099
|
-
do {
|
|
2100
|
-
if (node === exitNode) {
|
|
2101
|
-
return;
|
|
2102
|
-
}
|
|
2103
|
-
nextNode = null;
|
|
2104
|
-
const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
|
|
2105
|
-
if (nodeType === NodeType.ELEMENT_CONTAINER) {
|
|
2106
|
-
const container = node;
|
|
2107
|
-
let cursor = node;
|
|
2108
|
-
for (;cursor && !(nextNode = nextSibling(cursor)); ) {
|
|
2109
|
-
cursor = cursor.parentNode;
|
|
2110
|
-
}
|
|
2111
|
-
walkContainer(walker, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
|
|
2112
|
-
} else if (nodeType === NodeType.COMMENT_IGNORE_START) {
|
|
2113
|
-
let islandNode = node;
|
|
2114
|
-
do {
|
|
2115
|
-
if (islandNode = walker.nextNode(), !islandNode) {
|
|
2116
|
-
throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
|
|
2117
|
-
}
|
|
2118
|
-
} while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
|
|
2119
|
-
nextNode = null;
|
|
2120
|
-
} else if (nodeType === NodeType.COMMENT_ISLAND_END) {
|
|
2121
|
-
nextNode = node;
|
|
2122
|
-
do {
|
|
2123
|
-
if (nextNode = walker.nextNode(), !nextNode) {
|
|
2124
|
-
throw new Error("Ignore block not closed!");
|
|
2125
|
-
}
|
|
2126
|
-
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
|
|
2127
|
-
nextNode = null;
|
|
2128
|
-
} else if (nodeType === NodeType.COMMENT_SKIP_START) {
|
|
2129
|
-
nextNode = node;
|
|
2130
|
-
do {
|
|
2131
|
-
if (nextNode = nextSibling(nextNode), !nextNode) {
|
|
2132
|
-
throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
|
|
2133
|
-
}
|
|
2134
|
-
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
|
|
2135
|
-
walkContainer(walker, node, node, nextNode, "", null);
|
|
2136
|
-
} else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
|
|
2137
|
-
nextNode = nextSibling(node);
|
|
2138
|
-
const shadowRootContainer = node;
|
|
2139
|
-
const shadowRoot = shadowRootContainer?.shadowRoot;
|
|
2140
|
-
shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
|
|
2141
|
-
}
|
|
2142
|
-
if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
|
|
2143
|
-
if (vNodeElementIndex < elementIdx && (-1 === vNodeElementIndex && (vNodeElementIndex = 0),
|
|
2144
|
-
vData_start = vData_end, vData_start < vData_length ? (vNodeElementIndex += howManyElementsToSkip(),
|
|
2145
|
-
ch === VNodeDataSeparator_REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++,
|
|
2146
|
-
ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator_ADVANCE_1),
|
|
2147
|
-
vData_end = findVDataSectionEnd(vData, vData_start, vData_length)) : vNodeElementIndex = Number.MAX_SAFE_INTEGER),
|
|
2148
|
-
elementIdx === vNodeElementIndex) {
|
|
2149
|
-
needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
|
|
2150
|
-
const instructions = vData.substring(vData_start, vData_end);
|
|
2151
|
-
vNodeDataMap.set(node, instructions);
|
|
2152
|
-
}
|
|
2153
|
-
elementIdx++;
|
|
2154
|
-
}
|
|
2155
|
-
} while (node = nextNode || walker.nextNode());
|
|
2156
|
-
};
|
|
2157
|
-
const walker = document.createTreeWalker(document, 129);
|
|
2158
|
-
walkContainer(walker, null, walker.firstChild(), null, "", null);
|
|
2159
|
-
}(document), this.$rawStateData$ = [], this.stateData = [];
|
|
2160
|
-
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
2161
|
-
if (0 !== qwikStates.length) {
|
|
2162
|
-
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
|
|
2163
|
-
this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
|
|
2164
|
-
}
|
|
2165
|
-
this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
effects.forEach(scheduleEffect);
|
|
2166
1903
|
}
|
|
2167
|
-
|
|
2168
|
-
|
|
1904
|
+
};
|
|
1905
|
+
class ComputedSignal extends Signal {
|
|
1906
|
+
$computeQrl$;
|
|
1907
|
+
$invalid$=!0;
|
|
1908
|
+
$forceRunEffects$=!1;
|
|
1909
|
+
constructor(container, fn) {
|
|
1910
|
+
super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn;
|
|
2169
1911
|
}
|
|
2170
|
-
|
|
2171
|
-
|
|
1912
|
+
$invalidate$() {
|
|
1913
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
|
|
2172
1914
|
}
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
if (!errorStore) {
|
|
2176
|
-
throw err;
|
|
2177
|
-
}
|
|
2178
|
-
errorStore.error = err;
|
|
1915
|
+
force() {
|
|
1916
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
|
|
2179
1917
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
1918
|
+
get untrackedValue() {
|
|
1919
|
+
const didChange = this.$computeIfNeeded$();
|
|
1920
|
+
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
|
|
2183
1921
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
if (ctx) {
|
|
2188
|
-
const value = mapArray_get(ctx, contextId.id, 0);
|
|
2189
|
-
if (value) {
|
|
2190
|
-
return value;
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
host = this.getParentHost(host);
|
|
1922
|
+
$computeIfNeeded$() {
|
|
1923
|
+
if (!this.$invalid$) {
|
|
1924
|
+
return !1;
|
|
2194
1925
|
}
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
if (parent) {
|
|
2205
|
-
vNode = parent;
|
|
2206
|
-
continue;
|
|
2207
|
-
}
|
|
1926
|
+
const computeQrl = this.$computeQrl$;
|
|
1927
|
+
throwIfQRLNotResolved(computeQrl);
|
|
1928
|
+
const ctx = tryGetInvokeContext();
|
|
1929
|
+
const previousEffectSubscription = ctx?.$effectSubscriber$;
|
|
1930
|
+
ctx && (ctx.$effectSubscriber$ = [ this, EffectProperty.VNODE ]);
|
|
1931
|
+
try {
|
|
1932
|
+
const untrackedValue = computeQrl.getFn(ctx)();
|
|
1933
|
+
if (isPromise(untrackedValue)) {
|
|
1934
|
+
throw qError(QError.computedNotSync, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
|
|
2208
1935
|
}
|
|
2209
|
-
|
|
1936
|
+
this.$invalid$ = !1;
|
|
1937
|
+
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1938
|
+
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
1939
|
+
} finally {
|
|
1940
|
+
ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
|
|
2210
1941
|
}
|
|
2211
|
-
return null;
|
|
2212
1942
|
}
|
|
2213
|
-
|
|
2214
|
-
|
|
1943
|
+
get value() {
|
|
1944
|
+
return super.value;
|
|
2215
1945
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
let getObjectById = null;
|
|
2219
|
-
switch (name) {
|
|
2220
|
-
case "q:seq":
|
|
2221
|
-
case "q:props":
|
|
2222
|
-
case "q:renderFn":
|
|
2223
|
-
case "q:ctx":
|
|
2224
|
-
case "q:subs":
|
|
2225
|
-
getObjectById = this.$getObjectById$;
|
|
2226
|
-
break;
|
|
2227
|
-
|
|
2228
|
-
case "q:seqIdx":
|
|
2229
|
-
case ":onIdx":
|
|
2230
|
-
getObjectById = parseInt;
|
|
2231
|
-
}
|
|
2232
|
-
return vnode_getProp(vNode, name, getObjectById);
|
|
1946
|
+
set value(_) {
|
|
1947
|
+
throw qError(QError.computedReadOnly);
|
|
2233
1948
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
1949
|
+
}
|
|
1950
|
+
class WrappedSignal extends Signal {
|
|
1951
|
+
$args$;
|
|
1952
|
+
$func$;
|
|
1953
|
+
$funcStr$;
|
|
1954
|
+
$invalid$=!0;
|
|
1955
|
+
$effectDependencies$=null;
|
|
1956
|
+
$hostElement$=null;
|
|
1957
|
+
$forceRunEffects$=!1;
|
|
1958
|
+
constructor(container, fn, args, fnStr) {
|
|
1959
|
+
super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
|
|
2237
1960
|
}
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
2241
|
-
if (isPromise(result)) {
|
|
2242
|
-
return result.then((async () => {
|
|
2243
|
-
for (;renderCount !== this.$renderCount$; ) {
|
|
2244
|
-
renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
2245
|
-
}
|
|
2246
|
-
this.renderDone = null;
|
|
2247
|
-
}));
|
|
2248
|
-
}
|
|
2249
|
-
renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
|
|
2250
|
-
}
|
|
2251
|
-
ensureProjectionResolved(vNode) {
|
|
2252
|
-
if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
|
|
2253
|
-
vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
|
|
2254
|
-
for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
|
|
2255
|
-
if (isSlotProp(vNode[i])) {
|
|
2256
|
-
const value = vNode[i + 1];
|
|
2257
|
-
"string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
1961
|
+
$invalidate$() {
|
|
1962
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
|
|
2261
1963
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
getSyncFn(id) {
|
|
2265
|
-
const fn = this.$qFuncs$[id];
|
|
2266
|
-
return assertTrue(), fn;
|
|
1964
|
+
force() {
|
|
1965
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
|
|
2267
1966
|
}
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
const scopedStyleIds = new Set(function(scopedStyleIds) {
|
|
2272
|
-
return scopedStyleIds?.split(" ") ?? null;
|
|
2273
|
-
}(scopedStyleIdsString));
|
|
2274
|
-
scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", function(scopedStyleIds) {
|
|
2275
|
-
return Array.from(scopedStyleIds).join(" ");
|
|
2276
|
-
}(scopedStyleIds));
|
|
2277
|
-
}
|
|
2278
|
-
if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach((style => {
|
|
2279
|
-
this.$styleIds$.add(style.getAttribute("q:style"));
|
|
2280
|
-
}))), !this.$styleIds$.has(styleId)) {
|
|
2281
|
-
this.$styleIds$.add(styleId);
|
|
2282
|
-
const styleElement = this.document.createElement("style");
|
|
2283
|
-
styleElement.setAttribute("q:style", styleId), styleElement.textContent = content,
|
|
2284
|
-
this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
|
|
2285
|
-
}
|
|
1967
|
+
get untrackedValue() {
|
|
1968
|
+
const didChange = this.$computeIfNeeded$();
|
|
1969
|
+
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
|
|
2286
1970
|
}
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
if (!_context) {
|
|
2291
|
-
const context = "undefined" != typeof document && document && document.__q_context__;
|
|
2292
|
-
if (!context) {
|
|
2293
|
-
return;
|
|
1971
|
+
$computeIfNeeded$() {
|
|
1972
|
+
if (!this.$invalid$) {
|
|
1973
|
+
return !1;
|
|
2294
1974
|
}
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
};
|
|
2299
|
-
const getInvokeContext = () => {
|
|
2300
|
-
const ctx = tryGetInvokeContext();
|
|
2301
|
-
if (!ctx) {
|
|
2302
|
-
throw qError(14);
|
|
2303
|
-
}
|
|
2304
|
-
return ctx;
|
|
2305
|
-
};
|
|
2306
|
-
const useInvokeContext = () => {
|
|
2307
|
-
const ctx = tryGetInvokeContext();
|
|
2308
|
-
if (!ctx || "qRender" !== ctx.$event$) {
|
|
2309
|
-
throw qError(20);
|
|
1975
|
+
const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, EffectProperty.VNODE, this.$container$);
|
|
1976
|
+
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1977
|
+
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
2310
1978
|
}
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
function useBindInvokeContext(fn) {
|
|
2314
|
-
if (null == fn) {
|
|
2315
|
-
return fn;
|
|
1979
|
+
get value() {
|
|
1980
|
+
return super.value;
|
|
2316
1981
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
return invokeApply.call(this, ctx, fn, args);
|
|
2320
|
-
};
|
|
2321
|
-
}
|
|
2322
|
-
function invoke(context, fn, ...args) {
|
|
2323
|
-
return invokeApply.call(this, context, fn, args);
|
|
2324
|
-
}
|
|
2325
|
-
function invokeApply(context, fn, args) {
|
|
2326
|
-
const previousContext = _context;
|
|
2327
|
-
let returnValue;
|
|
2328
|
-
try {
|
|
2329
|
-
_context = context, returnValue = fn.apply(this, args);
|
|
2330
|
-
} finally {
|
|
2331
|
-
_context = previousContext;
|
|
1982
|
+
set value(_) {
|
|
1983
|
+
throw qError(QError.wrappedReadOnly);
|
|
2332
1984
|
}
|
|
2333
|
-
return returnValue;
|
|
2334
1985
|
}
|
|
2335
|
-
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
2336
|
-
const container = element.closest(QContainerSelector);
|
|
2337
|
-
const locale = container?.getAttribute("q:locale") || void 0;
|
|
2338
|
-
return locale && function(locale) {
|
|
2339
|
-
_locale = locale;
|
|
2340
|
-
}(locale), newInvokeContext(locale, void 0, element, event, url);
|
|
2341
|
-
};
|
|
2342
|
-
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
2343
|
-
const ctx = {
|
|
2344
|
-
$url$: url,
|
|
2345
|
-
$i$: 0,
|
|
2346
|
-
$hostElement$: hostElement,
|
|
2347
|
-
$element$: element,
|
|
2348
|
-
$event$: event,
|
|
2349
|
-
$qrl$: void 0,
|
|
2350
|
-
$effectSubscriber$: void 0,
|
|
2351
|
-
$locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
|
|
2352
|
-
$container$: void 0
|
|
2353
|
-
};
|
|
2354
|
-
return seal(), ctx;
|
|
2355
|
-
};
|
|
2356
|
-
const untrack = fn => invoke(void 0, fn);
|
|
2357
|
-
const trackInvocation = /*#__PURE__*/ newInvokeContext(void 0, void 0, void 0, "qRender");
|
|
2358
|
-
const trackSignal = (fn, subscriber, property, container, data) => {
|
|
2359
|
-
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
2360
|
-
const previousContainer = trackInvocation.$container$;
|
|
2361
|
-
try {
|
|
2362
|
-
return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
|
|
2363
|
-
trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
2364
|
-
} finally {
|
|
2365
|
-
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
1986
|
class ParentComponentData {
|
|
2369
1987
|
$scopedStyle$;
|
|
2370
1988
|
$componentFrame$;
|
|
@@ -2395,11 +2013,17 @@
|
|
|
2395
2013
|
});
|
|
2396
2014
|
} else {
|
|
2397
2015
|
if (value === Promise) {
|
|
2398
|
-
|
|
2016
|
+
if (!options.allowPromises) {
|
|
2017
|
+
throw qError(QError.promisesNotExpected);
|
|
2018
|
+
}
|
|
2019
|
+
return void stack.pop().then(resolveValue, rejectDrain);
|
|
2399
2020
|
}
|
|
2400
2021
|
const waitOn = value.apply(ssr);
|
|
2401
2022
|
if (waitOn) {
|
|
2402
|
-
|
|
2023
|
+
if (!options.allowPromises) {
|
|
2024
|
+
throw qError(QError.promisesNotExpected);
|
|
2025
|
+
}
|
|
2026
|
+
return void waitOn.then(drain, rejectDrain);
|
|
2403
2027
|
}
|
|
2404
2028
|
}
|
|
2405
2029
|
}
|
|
@@ -2424,7 +2048,7 @@
|
|
|
2424
2048
|
} else if (isSignal(value)) {
|
|
2425
2049
|
ssr.openFragment(build.isDev ? [ "q:type", VirtualType.WrappedSignal ] : EMPTY_ARRAY);
|
|
2426
2050
|
const signalNode = ssr.getLastNode();
|
|
2427
|
-
enqueue(ssr.closeFragment), enqueue(
|
|
2051
|
+
enqueue(ssr.closeFragment), enqueue(trackSignalAndAssignHost(value, signalNode, EffectProperty.VNODE, ssr));
|
|
2428
2052
|
} else if (isPromise(value)) {
|
|
2429
2053
|
ssr.openFragment(build.isDev ? [ "q:type", VirtualType.Awaited ] : EMPTY_ARRAY),
|
|
2430
2054
|
enqueue(ssr.closeFragment), enqueue(value), enqueue(Promise), enqueue((() => ssr.commentNode("qkssr-f")));
|
|
@@ -2483,7 +2107,7 @@
|
|
|
2483
2107
|
if (constProps && "object" == typeof constProps && "name" in constProps) {
|
|
2484
2108
|
const constValue = constProps.name;
|
|
2485
2109
|
if (constValue instanceof WrappedSignal) {
|
|
2486
|
-
return
|
|
2110
|
+
return trackSignalAndAssignHost(constValue, host, EffectProperty.COMPONENT, ssr);
|
|
2487
2111
|
}
|
|
2488
2112
|
}
|
|
2489
2113
|
return directGetPropsProxyProp(jsx, "name") || "";
|
|
@@ -2617,6 +2241,29 @@
|
|
|
2617
2241
|
const eventName = key.substring(15);
|
|
2618
2242
|
eventName && serializationCtx.$eventNames$.add(eventName);
|
|
2619
2243
|
}
|
|
2244
|
+
const version = "2.0.0-alpha.4-dev+374e0d6";
|
|
2245
|
+
class _SharedContainer {
|
|
2246
|
+
$version$;
|
|
2247
|
+
$scheduler$;
|
|
2248
|
+
$storeProxyMap$;
|
|
2249
|
+
$locale$;
|
|
2250
|
+
$getObjectById$;
|
|
2251
|
+
$serverData$;
|
|
2252
|
+
$currentUniqueId$=0;
|
|
2253
|
+
$instanceHash$=null;
|
|
2254
|
+
constructor(scheduleDrain, journalFlush, serverData, locale) {
|
|
2255
|
+
this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
|
|
2256
|
+
this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
|
|
2257
|
+
throw Error("Not implemented");
|
|
2258
|
+
}, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
|
|
2259
|
+
}
|
|
2260
|
+
trackSignalValue(signal, subscriber, property, data) {
|
|
2261
|
+
return trackSignalAndAssignHost(signal, subscriber, property, this, data);
|
|
2262
|
+
}
|
|
2263
|
+
serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
2264
|
+
return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2620
2267
|
const _CONST_PROPS = Symbol("CONST");
|
|
2621
2268
|
const _VAR_PROPS = Symbol("VAR");
|
|
2622
2269
|
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
@@ -2823,6 +2470,8 @@
|
|
|
2823
2470
|
}
|
|
2824
2471
|
return String(value);
|
|
2825
2472
|
};
|
|
2473
|
+
const VNodeDataSeparator_REFERENCE = 126, VNodeDataSeparator_ADVANCE_1 = 33, VNodeDataSeparator_ADVANCE_8192 = 46;
|
|
2474
|
+
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_SUBS = 96, VNodeDataChar_SEPARATOR = 124, VNodeDataChar_SLOT = 126;
|
|
2826
2475
|
var VNodeJournalOpCode;
|
|
2827
2476
|
!function(VNodeJournalOpCode) {
|
|
2828
2477
|
VNodeJournalOpCode[VNodeJournalOpCode.SetText = 1] = "SetText", VNodeJournalOpCode[VNodeJournalOpCode.SetAttribute = 2] = "SetAttribute",
|
|
@@ -2841,12 +2490,6 @@
|
|
|
2841
2490
|
return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)),
|
|
2842
2491
|
assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2843
2492
|
};
|
|
2844
|
-
const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
|
|
2845
|
-
sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
|
|
2846
|
-
const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
|
|
2847
|
-
return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)),
|
|
2848
|
-
assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2849
|
-
};
|
|
2850
2493
|
const vnode_newText = (textNode, textContent) => {
|
|
2851
2494
|
const vnode = VNodeArray.createText(VNodeFlags.Text | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, textNode, textContent);
|
|
2852
2495
|
return assertEqual(fastNodeType(textNode)), assertFalse(vnode_isElementVNode(vnode)),
|
|
@@ -3289,107 +2932,118 @@
|
|
|
3289
2932
|
let vFirstChild = vnode[ElementVNodeProps.firstChild];
|
|
3290
2933
|
return void 0 === vFirstChild && (vFirstChild = ensureMaterialized(vnode)), vFirstChild;
|
|
3291
2934
|
};
|
|
3292
|
-
const
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
let vFirst = null;
|
|
3300
|
-
let vLast = null;
|
|
3301
|
-
let previousTextNode = null;
|
|
3302
|
-
let ch = 0;
|
|
3303
|
-
let peekCh = 0;
|
|
3304
|
-
const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
|
|
3305
|
-
const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
|
|
3306
|
-
const addVNode = node => {
|
|
3307
|
-
node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift,
|
|
3308
|
-
idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast,
|
|
3309
|
-
node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node),
|
|
3310
|
-
vLast = node;
|
|
3311
|
-
};
|
|
3312
|
-
const consumeValue = () => {
|
|
3313
|
-
consume();
|
|
3314
|
-
const start = nextToConsumeIdx;
|
|
3315
|
-
for (;peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
|
|
3316
|
-
consume();
|
|
2935
|
+
const materialize = (vNode, element, firstChild, vNodeData) => {
|
|
2936
|
+
if (vNodeData) {
|
|
2937
|
+
if (vNodeData.charCodeAt(0) === VNodeDataChar_SEPARATOR) {
|
|
2938
|
+
const elementVNodeDataStartIdx = 1;
|
|
2939
|
+
let elementVNodeDataEndIdx = 1;
|
|
2940
|
+
for (;vNodeData.charCodeAt(elementVNodeDataEndIdx) !== VNodeDataChar_SEPARATOR; ) {
|
|
2941
|
+
elementVNodeDataEndIdx++;
|
|
3317
2942
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
for (;0 !== peek(); ) {
|
|
3324
|
-
if (isNumber(peek())) {
|
|
3325
|
-
for (;!isElement(child); ) {
|
|
3326
|
-
(child = fastNextSibling(child)) || throwErrorAndStop("Materialize error: missing element: " + vData + " " + peek() + " " + nextToConsumeIdx);
|
|
3327
|
-
}
|
|
3328
|
-
for (;isQStyleElement(child); ) {
|
|
3329
|
-
child = fastNextSibling(child);
|
|
3330
|
-
}
|
|
3331
|
-
combinedText = null, previousTextNode = null;
|
|
3332
|
-
let value = 0;
|
|
3333
|
-
for (;isNumber(peek()); ) {
|
|
3334
|
-
value *= 10, value += consume() - 48;
|
|
3335
|
-
}
|
|
3336
|
-
for (;value--; ) {
|
|
3337
|
-
addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
|
|
3338
|
-
}
|
|
3339
|
-
} else if (peek() === VNodeDataChar_SCOPED_STYLE) {
|
|
3340
|
-
vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
|
|
3341
|
-
} else if (peek() === VNodeDataChar_RENDER_FN) {
|
|
3342
|
-
vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
|
|
3343
|
-
} else if (peek() === VNodeDataChar_ID) {
|
|
3344
|
-
container || (container = getDomContainer(element));
|
|
3345
|
-
const id = consumeValue();
|
|
3346
|
-
container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
3347
|
-
} else if (peek() === VNodeDataChar_PROPS) {
|
|
3348
|
-
vnode_setAttr(null, vParent, "q:props", consumeValue());
|
|
3349
|
-
} else if (peek() === VNodeDataChar_SLOT_REF) {
|
|
3350
|
-
vnode_setAttr(null, vParent, "q:sref", consumeValue());
|
|
3351
|
-
} else if (peek() === VNodeDataChar_KEY) {
|
|
3352
|
-
vnode_setAttr(null, vParent, "q:key", consumeValue());
|
|
3353
|
-
} else if (peek() === VNodeDataChar_SEQ) {
|
|
3354
|
-
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
3355
|
-
} else if (peek() === VNodeDataChar_SEQ_IDX) {
|
|
3356
|
-
vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
|
|
3357
|
-
} else if (peek() === VNodeDataChar_CONTEXT) {
|
|
3358
|
-
vnode_setAttr(null, vParent, "q:ctx", consumeValue());
|
|
3359
|
-
} else if (peek() === VNodeDataChar_OPEN) {
|
|
3360
|
-
consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx),
|
|
3361
|
-
idx = 0, vParent = vLast, vFirst = vLast = null;
|
|
3362
|
-
} else if (peek() === VNodeDataChar_SEPARATOR) {
|
|
3363
|
-
const key = consumeValue();
|
|
3364
|
-
const value = consumeValue();
|
|
3365
|
-
vnode_setAttr(null, vParent, key, value);
|
|
3366
|
-
} else if (peek() === VNodeDataChar_CLOSE) {
|
|
3367
|
-
consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(),
|
|
3368
|
-
vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
|
|
3369
|
-
} else if (peek() === VNodeDataChar_SLOT) {
|
|
3370
|
-
vnode_setAttr(null, vParent, QSlot, consumeValue());
|
|
3371
|
-
} else {
|
|
3372
|
-
const textNode = child && 3 === fastNodeType(child) ? child : null;
|
|
3373
|
-
null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
|
|
3374
|
-
let length = 0;
|
|
3375
|
-
for (;isLowercase(peek()); ) {
|
|
3376
|
-
length += consume() - 97, length *= 26;
|
|
3377
|
-
}
|
|
3378
|
-
length += consume() - 65;
|
|
3379
|
-
const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
|
|
3380
|
-
addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)),
|
|
3381
|
-
textIdx += length;
|
|
2943
|
+
const elementVNodeData = vNodeData.substring(elementVNodeDataStartIdx, elementVNodeDataEndIdx);
|
|
2944
|
+
vNodeData = vNodeData.substring(elementVNodeDataEndIdx + 1);
|
|
2945
|
+
const vFirstChild = materializeFromDOM(vNode, firstChild, elementVNodeData);
|
|
2946
|
+
if (!vNodeData) {
|
|
2947
|
+
return vFirstChild;
|
|
3382
2948
|
}
|
|
3383
2949
|
}
|
|
3384
|
-
return vParent
|
|
3385
|
-
|
|
3386
|
-
|
|
2950
|
+
return function(vParent, vData, element, child) {
|
|
2951
|
+
let idx = 0;
|
|
2952
|
+
let vFirst = null;
|
|
2953
|
+
let vLast = null;
|
|
2954
|
+
let previousTextNode = null;
|
|
2955
|
+
const addVNode = node => {
|
|
2956
|
+
node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift,
|
|
2957
|
+
idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast,
|
|
2958
|
+
node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node),
|
|
2959
|
+
vLast = node;
|
|
2960
|
+
};
|
|
2961
|
+
let textIdx = 0;
|
|
2962
|
+
let combinedText = null;
|
|
2963
|
+
let container = null;
|
|
2964
|
+
return processVNodeData$1(vData, ((peek, consumeValue, consume, nextToConsumeIdx) => {
|
|
2965
|
+
if (isNumber(peek())) {
|
|
2966
|
+
for (;!isElement(child); ) {
|
|
2967
|
+
if (!(child = fastNextSibling(child))) {
|
|
2968
|
+
throw qError(QError.materializeVNodeDataError, [ vData, peek(), nextToConsumeIdx ]);
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
for (;isQStyleElement(child); ) {
|
|
2972
|
+
child = fastNextSibling(child);
|
|
2973
|
+
}
|
|
2974
|
+
combinedText = null, previousTextNode = null;
|
|
2975
|
+
let value = 0;
|
|
2976
|
+
for (;isNumber(peek()); ) {
|
|
2977
|
+
value *= 10, value += consume() - 48;
|
|
2978
|
+
}
|
|
2979
|
+
for (;value--; ) {
|
|
2980
|
+
addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
|
|
2981
|
+
}
|
|
2982
|
+
} else if (peek() === VNodeDataChar_SCOPED_STYLE) {
|
|
2983
|
+
vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
|
|
2984
|
+
} else if (peek() === VNodeDataChar_RENDER_FN) {
|
|
2985
|
+
vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
|
|
2986
|
+
} else if (peek() === VNodeDataChar_ID) {
|
|
2987
|
+
container || (container = getDomContainer(element));
|
|
2988
|
+
const id = consumeValue();
|
|
2989
|
+
container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
2990
|
+
} else if (peek() === VNodeDataChar_PROPS) {
|
|
2991
|
+
vnode_setAttr(null, vParent, "q:props", consumeValue());
|
|
2992
|
+
} else if (peek() === VNodeDataChar_SLOT_REF) {
|
|
2993
|
+
vnode_setAttr(null, vParent, "q:sref", consumeValue());
|
|
2994
|
+
} else if (peek() === VNodeDataChar_KEY) {
|
|
2995
|
+
vnode_setAttr(null, vParent, "q:key", consumeValue());
|
|
2996
|
+
} else if (peek() === VNodeDataChar_SEQ) {
|
|
2997
|
+
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
2998
|
+
} else if (peek() === VNodeDataChar_SEQ_IDX) {
|
|
2999
|
+
vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
|
|
3000
|
+
} else if (peek() === VNodeDataChar_SUBS) {
|
|
3001
|
+
vnode_setProp(vParent, "q:subs", consumeValue());
|
|
3002
|
+
} else if (peek() === VNodeDataChar_CONTEXT) {
|
|
3003
|
+
vnode_setAttr(null, vParent, "q:ctx", consumeValue());
|
|
3004
|
+
} else if (peek() === VNodeDataChar_OPEN) {
|
|
3005
|
+
consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx),
|
|
3006
|
+
idx = 0, vParent = vLast, vFirst = vLast = null;
|
|
3007
|
+
} else if (peek() === VNodeDataChar_SEPARATOR) {
|
|
3008
|
+
const key = consumeValue();
|
|
3009
|
+
const value = consumeValue();
|
|
3010
|
+
vnode_setAttr(null, vParent, key, value);
|
|
3011
|
+
} else if (peek() === VNodeDataChar_CLOSE) {
|
|
3012
|
+
consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(),
|
|
3013
|
+
vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
|
|
3014
|
+
} else if (peek() === VNodeDataChar_SLOT) {
|
|
3015
|
+
vnode_setAttr(null, vParent, QSlot, consumeValue());
|
|
3016
|
+
} else {
|
|
3017
|
+
const textNode = child && 3 === fastNodeType(child) ? child : null;
|
|
3018
|
+
null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
|
|
3019
|
+
let length = 0;
|
|
3020
|
+
for (;isLowercase(peek()); ) {
|
|
3021
|
+
length += consume() - 97, length *= 26;
|
|
3022
|
+
}
|
|
3023
|
+
length += consume() - 65;
|
|
3024
|
+
const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
|
|
3025
|
+
addVNode(previousTextNode = ((previousTextNode, sharedTextNode, textContent) => {
|
|
3026
|
+
sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
|
|
3027
|
+
const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
|
|
3028
|
+
return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)),
|
|
3029
|
+
assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
3030
|
+
})(previousTextNode, textNode, text)), textIdx += length;
|
|
3031
|
+
}
|
|
3032
|
+
})), vParent[ElementVNodeProps.lastChild] = vLast, vFirst;
|
|
3033
|
+
}(vNode, vNodeData, element, firstChild);
|
|
3034
|
+
}
|
|
3035
|
+
return materializeFromDOM(vNode, firstChild);
|
|
3387
3036
|
};
|
|
3388
3037
|
const ensureMaterialized = vnode => {
|
|
3389
3038
|
const vParent = ensureElementVNode(vnode);
|
|
3390
3039
|
let vFirstChild = vParent[ElementVNodeProps.firstChild];
|
|
3391
3040
|
if (void 0 === vFirstChild) {
|
|
3392
|
-
vFirstChild = vParent[VNodeProps.parent] && shouldIgnoreChildren(vParent[ElementVNodeProps.element]) ? vParent[ElementVNodeProps.firstChild] = vParent[ElementVNodeProps.lastChild] = null :
|
|
3041
|
+
vFirstChild = vParent[VNodeProps.parent] && shouldIgnoreChildren(vParent[ElementVNodeProps.element]) ? vParent[ElementVNodeProps.firstChild] = vParent[ElementVNodeProps.lastChild] = null : (vNode => {
|
|
3042
|
+
const element = vNode[ElementVNodeProps.element];
|
|
3043
|
+
const firstChild = fastFirstChild(element);
|
|
3044
|
+
const vNodeData = element.ownerDocument?.qVNodeData?.get(element);
|
|
3045
|
+
return materialize(vNode, element, firstChild, vNodeData);
|
|
3046
|
+
})(vParent);
|
|
3393
3047
|
}
|
|
3394
3048
|
return assertTrue(), assertTrue(), vFirstChild;
|
|
3395
3049
|
};
|
|
@@ -3458,7 +3112,7 @@
|
|
|
3458
3112
|
};
|
|
3459
3113
|
};
|
|
3460
3114
|
const isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute("q:sstyle") || node.hasAttribute("q:style"));
|
|
3461
|
-
const materializeFromDOM = (vParent, firstChild) => {
|
|
3115
|
+
const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
3462
3116
|
let vFirstChild = null;
|
|
3463
3117
|
const skipStyleElements = () => {
|
|
3464
3118
|
for (;isQStyleElement(child); ) {
|
|
@@ -3476,8 +3130,38 @@
|
|
|
3476
3130
|
vNextChild[VNodeProps.previousSibling] = vChild, vChild = vNextChild), vFirstChild || (vParent[ElementVNodeProps.firstChild] = vFirstChild = vChild),
|
|
3477
3131
|
child = fastNextSibling(child), skipStyleElements();
|
|
3478
3132
|
}
|
|
3479
|
-
|
|
3480
|
-
|
|
3133
|
+
if (vParent[ElementVNodeProps.lastChild] = vChild || null, vParent[ElementVNodeProps.firstChild] = vFirstChild,
|
|
3134
|
+
vData) {
|
|
3135
|
+
let container = null;
|
|
3136
|
+
processVNodeData$1(vData, ((peek, consumeValue) => {
|
|
3137
|
+
if (peek() === VNodeDataChar_ID) {
|
|
3138
|
+
container || (container = getDomContainer(vParent[ElementVNodeProps.element]));
|
|
3139
|
+
const id = consumeValue();
|
|
3140
|
+
container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
3141
|
+
} else {
|
|
3142
|
+
peek() === VNodeDataChar_SUBS ? vnode_setProp(vParent, "q:subs", consumeValue()) : consumeValue();
|
|
3143
|
+
}
|
|
3144
|
+
}));
|
|
3145
|
+
}
|
|
3146
|
+
return vFirstChild;
|
|
3147
|
+
};
|
|
3148
|
+
const processVNodeData$1 = (vData, callback) => {
|
|
3149
|
+
let nextToConsumeIdx = 0;
|
|
3150
|
+
let ch = 0;
|
|
3151
|
+
let peekCh = 0;
|
|
3152
|
+
const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
|
|
3153
|
+
const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
|
|
3154
|
+
const consumeValue = () => {
|
|
3155
|
+
consume();
|
|
3156
|
+
const start = nextToConsumeIdx;
|
|
3157
|
+
for (;peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
|
|
3158
|
+
consume();
|
|
3159
|
+
}
|
|
3160
|
+
return vData.substring(start, nextToConsumeIdx);
|
|
3161
|
+
};
|
|
3162
|
+
for (;0 !== peek(); ) {
|
|
3163
|
+
callback(peek, consumeValue, consume, nextToConsumeIdx);
|
|
3164
|
+
}
|
|
3481
3165
|
};
|
|
3482
3166
|
const vnode_getNextSibling = vnode => vnode[VNodeProps.nextSibling];
|
|
3483
3167
|
const vnode_getAttrKeys = vnode => {
|
|
@@ -3532,164 +3216,588 @@
|
|
|
3532
3216
|
if (type === VNodeFlags.Element) {
|
|
3533
3217
|
return ElementVNodeProps.PROPS_OFFSET;
|
|
3534
3218
|
}
|
|
3535
|
-
if (type === VNodeFlags.Virtual) {
|
|
3536
|
-
return VirtualVNodeProps.PROPS_OFFSET;
|
|
3219
|
+
if (type === VNodeFlags.Virtual) {
|
|
3220
|
+
return VirtualVNodeProps.PROPS_OFFSET;
|
|
3221
|
+
}
|
|
3222
|
+
throw qError(QError.invalidVNodeType, [ type ]);
|
|
3223
|
+
};
|
|
3224
|
+
const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
|
|
3225
|
+
const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)),
|
|
3226
|
+
vnode[TextVNodeProps.node]);
|
|
3227
|
+
function vnode_toString(depth = 10, offset = "", materialize = !1, siblings = !1) {
|
|
3228
|
+
let vnode = this;
|
|
3229
|
+
if (0 === depth) {
|
|
3230
|
+
return "...";
|
|
3231
|
+
}
|
|
3232
|
+
if (null === vnode) {
|
|
3233
|
+
return "null";
|
|
3234
|
+
}
|
|
3235
|
+
if (void 0 === vnode) {
|
|
3236
|
+
return "undefined";
|
|
3237
|
+
}
|
|
3238
|
+
const strings = [];
|
|
3239
|
+
do {
|
|
3240
|
+
if (vnode_isTextVNode(vnode)) {
|
|
3241
|
+
strings.push(qwikDebugToString(vnode_getText(vnode)));
|
|
3242
|
+
} else if (vnode_isVirtualVNode(vnode)) {
|
|
3243
|
+
const attrs = [ "[" + String(vnode[VNodeProps.flags] >>> VNodeFlagsIndex.shift) + "]" ];
|
|
3244
|
+
vnode_getAttrKeys(vnode).forEach((key => {
|
|
3245
|
+
if ("q:type" !== key) {
|
|
3246
|
+
const value = vnode_getAttr(vnode, key);
|
|
3247
|
+
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
3248
|
+
}
|
|
3249
|
+
}));
|
|
3250
|
+
const name = VirtualTypeName[vnode_getAttr(vnode, "q:type") || VirtualType.Virtual] || VirtualTypeName[VirtualType.Virtual];
|
|
3251
|
+
strings.push("<" + name + attrs.join("") + ">");
|
|
3252
|
+
const child = vnode_getFirstChild(vnode);
|
|
3253
|
+
child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", !0, !0)),
|
|
3254
|
+
strings.push("</" + name + ">");
|
|
3255
|
+
} else if (vnode_isElementVNode(vnode)) {
|
|
3256
|
+
const tag = vnode_getElementName(vnode);
|
|
3257
|
+
const attrs = [];
|
|
3258
|
+
const keys = vnode_getAttrKeys(vnode);
|
|
3259
|
+
keys.forEach((key => {
|
|
3260
|
+
const value = vnode_getAttr(vnode, key);
|
|
3261
|
+
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
3262
|
+
}));
|
|
3263
|
+
const node = vnode_getNode(vnode);
|
|
3264
|
+
if (node) {
|
|
3265
|
+
const vnodeData = node.ownerDocument.qVNodeData?.get(node);
|
|
3266
|
+
vnodeData && attrs.push(" q:vnodeData=" + qwikDebugToString(vnodeData));
|
|
3267
|
+
}
|
|
3268
|
+
const domAttrs = node.attributes;
|
|
3269
|
+
for (let i = 0; i < domAttrs.length; i++) {
|
|
3270
|
+
const attr = domAttrs[i];
|
|
3271
|
+
-1 === keys.indexOf(attr.name) && attrs.push(" " + attr.name + (attr.value ? "=" + qwikDebugToString(attr.value) : ""));
|
|
3272
|
+
}
|
|
3273
|
+
if (strings.push("<" + tag + attrs.join("") + ">"), vnode_isMaterialized(vnode) || materialize) {
|
|
3274
|
+
const child = vnode_getFirstChild(vnode);
|
|
3275
|
+
child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", !0, !0));
|
|
3276
|
+
} else {
|
|
3277
|
+
strings.push(" \x3c!-- not materialized --!>");
|
|
3278
|
+
}
|
|
3279
|
+
strings.push("</" + tag + ">");
|
|
3280
|
+
}
|
|
3281
|
+
vnode = siblings && vnode_getNextSibling(vnode) || null;
|
|
3282
|
+
} while (vnode);
|
|
3283
|
+
return strings.join("\n" + offset);
|
|
3284
|
+
}
|
|
3285
|
+
const isNumber = ch => 48 <= ch && ch <= 57;
|
|
3286
|
+
const isLowercase = ch => 97 <= ch && ch <= 122;
|
|
3287
|
+
const stack = [];
|
|
3288
|
+
const vnode_getType = vnode => {
|
|
3289
|
+
const type = vnode[VNodeProps.flags];
|
|
3290
|
+
if (type & VNodeFlags.Element) {
|
|
3291
|
+
return 1;
|
|
3292
|
+
}
|
|
3293
|
+
if (type & VNodeFlags.Virtual) {
|
|
3294
|
+
return 11;
|
|
3295
|
+
}
|
|
3296
|
+
if (type & VNodeFlags.Text) {
|
|
3297
|
+
return 3;
|
|
3298
|
+
}
|
|
3299
|
+
throw qError(QError.invalidVNodeType, [ type ]);
|
|
3300
|
+
};
|
|
3301
|
+
const isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
|
|
3302
|
+
const aPath = [];
|
|
3303
|
+
const bPath = [];
|
|
3304
|
+
const vnode_documentPosition = (a, b) => {
|
|
3305
|
+
if (a === b) {
|
|
3306
|
+
return 0;
|
|
3307
|
+
}
|
|
3308
|
+
let aDepth = -1;
|
|
3309
|
+
let bDepth = -1;
|
|
3310
|
+
for (;a; ) {
|
|
3311
|
+
a = (aPath[++aDepth] = a)[VNodeProps.parent];
|
|
3312
|
+
}
|
|
3313
|
+
for (;b; ) {
|
|
3314
|
+
b = (bPath[++bDepth] = b)[VNodeProps.parent];
|
|
3315
|
+
}
|
|
3316
|
+
for (;aDepth >= 0 && bDepth >= 0; ) {
|
|
3317
|
+
if ((a = aPath[aDepth]) !== (b = bPath[bDepth])) {
|
|
3318
|
+
let cursor = b;
|
|
3319
|
+
do {
|
|
3320
|
+
if (cursor = vnode_getNextSibling(cursor), cursor === a) {
|
|
3321
|
+
return 1;
|
|
3322
|
+
}
|
|
3323
|
+
} while (cursor);
|
|
3324
|
+
cursor = b;
|
|
3325
|
+
do {
|
|
3326
|
+
if (cursor = cursor[VNodeProps.previousSibling], cursor === a) {
|
|
3327
|
+
return -1;
|
|
3328
|
+
}
|
|
3329
|
+
} while (cursor);
|
|
3330
|
+
return 1;
|
|
3331
|
+
}
|
|
3332
|
+
aDepth--, bDepth--;
|
|
3333
|
+
}
|
|
3334
|
+
return aDepth < bDepth ? -1 : 1;
|
|
3335
|
+
};
|
|
3336
|
+
const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
|
|
3337
|
+
let projectionDepth = 1;
|
|
3338
|
+
for (;projectionDepth--; ) {
|
|
3339
|
+
for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
|
|
3340
|
+
const qSlotParentProp = vnode_getProp(vHost, ":", null);
|
|
3341
|
+
const qSlotParent = qSlotParentProp && ("string" == typeof qSlotParentProp ? vnode_locate(rootVNode, qSlotParentProp) : qSlotParentProp);
|
|
3342
|
+
const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
|
|
3343
|
+
vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
|
|
3344
|
+
}
|
|
3345
|
+
projectionDepth > 0 && (vHost = vnode_getParent(vHost));
|
|
3346
|
+
}
|
|
3347
|
+
return vHost;
|
|
3348
|
+
};
|
|
3349
|
+
const VNodeArray = class VNode extends Array {
|
|
3350
|
+
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
3351
|
+
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3352
|
+
return vnode.push(firstChild, lastChild, element, elementName), vnode;
|
|
3353
|
+
}
|
|
3354
|
+
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
3355
|
+
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3356
|
+
return vnode.push(textNode, text), vnode;
|
|
3357
|
+
}
|
|
3358
|
+
static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
|
|
3359
|
+
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3360
|
+
return vnode.push(firstChild, lastChild), vnode;
|
|
3361
|
+
}
|
|
3362
|
+
constructor(flags, parent, previousSibling, nextSibling) {
|
|
3363
|
+
super(), this.push(flags, parent, previousSibling, nextSibling), build.isDev && (this.toString = vnode_toString);
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
let _context;
|
|
3367
|
+
const tryGetInvokeContext = () => {
|
|
3368
|
+
if (!_context) {
|
|
3369
|
+
const context = "undefined" != typeof document && document && document.__q_context__;
|
|
3370
|
+
if (!context) {
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
return isArray(context) ? document.__q_context__ = newInvokeContextFromTuple(context) : context;
|
|
3374
|
+
}
|
|
3375
|
+
return _context;
|
|
3376
|
+
};
|
|
3377
|
+
const getInvokeContext = () => {
|
|
3378
|
+
const ctx = tryGetInvokeContext();
|
|
3379
|
+
if (!ctx) {
|
|
3380
|
+
throw qError(QError.useMethodOutsideContext);
|
|
3381
|
+
}
|
|
3382
|
+
return ctx;
|
|
3383
|
+
};
|
|
3384
|
+
const useInvokeContext = () => {
|
|
3385
|
+
const ctx = tryGetInvokeContext();
|
|
3386
|
+
if (!ctx || "qRender" !== ctx.$event$) {
|
|
3387
|
+
throw qError(QError.useInvokeContext);
|
|
3388
|
+
}
|
|
3389
|
+
return assertDefined(), assertDefined(), ctx;
|
|
3390
|
+
};
|
|
3391
|
+
function useBindInvokeContext(fn) {
|
|
3392
|
+
if (null == fn) {
|
|
3393
|
+
return fn;
|
|
3394
|
+
}
|
|
3395
|
+
const ctx = getInvokeContext();
|
|
3396
|
+
return function(...args) {
|
|
3397
|
+
return invokeApply.call(this, ctx, fn, args);
|
|
3398
|
+
};
|
|
3399
|
+
}
|
|
3400
|
+
function invoke(context, fn, ...args) {
|
|
3401
|
+
return invokeApply.call(this, context, fn, args);
|
|
3402
|
+
}
|
|
3403
|
+
function invokeApply(context, fn, args) {
|
|
3404
|
+
const previousContext = _context;
|
|
3405
|
+
let returnValue;
|
|
3406
|
+
try {
|
|
3407
|
+
_context = context, returnValue = fn.apply(this, args);
|
|
3408
|
+
} finally {
|
|
3409
|
+
_context = previousContext;
|
|
3410
|
+
}
|
|
3411
|
+
return returnValue;
|
|
3412
|
+
}
|
|
3413
|
+
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
3414
|
+
const container = element.closest(QContainerSelector);
|
|
3415
|
+
const locale = container?.getAttribute("q:locale") || void 0;
|
|
3416
|
+
return locale && function(locale) {
|
|
3417
|
+
_locale = locale;
|
|
3418
|
+
}(locale), newInvokeContext(locale, void 0, element, event, url);
|
|
3419
|
+
};
|
|
3420
|
+
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
3421
|
+
const ctx = {
|
|
3422
|
+
$url$: url,
|
|
3423
|
+
$i$: 0,
|
|
3424
|
+
$hostElement$: hostElement,
|
|
3425
|
+
$element$: element,
|
|
3426
|
+
$event$: event,
|
|
3427
|
+
$qrl$: void 0,
|
|
3428
|
+
$effectSubscriber$: void 0,
|
|
3429
|
+
$locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
|
|
3430
|
+
$container$: void 0
|
|
3431
|
+
};
|
|
3432
|
+
return seal(), ctx;
|
|
3433
|
+
};
|
|
3434
|
+
const untrack = fn => invoke(void 0, fn);
|
|
3435
|
+
const trackInvocation = /*#__PURE__*/ newInvokeContext(void 0, void 0, void 0, "qRender");
|
|
3436
|
+
const trackSignal = (fn, subscriber, property, container, data) => {
|
|
3437
|
+
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
3438
|
+
const previousContainer = trackInvocation.$container$;
|
|
3439
|
+
try {
|
|
3440
|
+
return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
|
|
3441
|
+
trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
3442
|
+
} finally {
|
|
3443
|
+
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
3444
|
+
}
|
|
3445
|
+
};
|
|
3446
|
+
const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignal && value.$hostElement$ !== host && host && (value.$hostElement$ = host),
|
|
3447
|
+
trackSignal((() => value.value), host, property, container, data));
|
|
3448
|
+
const createContextId = name => (assertTrue(/^[\w/.-]+$/.test(name)), /*#__PURE__*/ Object.freeze({
|
|
3449
|
+
id: fromCamelToKebabCase(name)
|
|
3450
|
+
}));
|
|
3451
|
+
const useContextProvider = (context, newValue) => {
|
|
3452
|
+
const {val, set, iCtx} = useSequentialScope();
|
|
3453
|
+
void 0 === val && (iCtx.$container$.setContext(iCtx.$hostElement$, context, newValue),
|
|
3454
|
+
set(1));
|
|
3455
|
+
};
|
|
3456
|
+
const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
|
|
3457
|
+
function getDomContainer(element) {
|
|
3458
|
+
const qContainerElement = _getQContainerElement(element);
|
|
3459
|
+
if (!qContainerElement) {
|
|
3460
|
+
throw qError(QError.containerNotFound);
|
|
3461
|
+
}
|
|
3462
|
+
return getDomContainerFromQContainerElement(qContainerElement);
|
|
3463
|
+
}
|
|
3464
|
+
function getDomContainerFromQContainerElement(qContainerElement) {
|
|
3465
|
+
const qElement = qContainerElement;
|
|
3466
|
+
let container = qElement.qContainer;
|
|
3467
|
+
if (!container) {
|
|
3468
|
+
container = new DomContainer(qElement);
|
|
3469
|
+
const containerAttributes = {};
|
|
3470
|
+
if (qElement) {
|
|
3471
|
+
const attrs = qElement.attributes;
|
|
3472
|
+
if (attrs) {
|
|
3473
|
+
for (let index = 0; index < attrs.length; index++) {
|
|
3474
|
+
const attr = attrs[index];
|
|
3475
|
+
":" !== attr.name && (containerAttributes[attr.name] = attr.value);
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
container.$serverData$ = {
|
|
3480
|
+
containerAttributes
|
|
3481
|
+
}, qElement.setAttribute("q:container", QContainerValue.RESUMED), qElement.qContainer = container;
|
|
3482
|
+
}
|
|
3483
|
+
return container;
|
|
3484
|
+
}
|
|
3485
|
+
function _getQContainerElement(element) {
|
|
3486
|
+
return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
|
|
3487
|
+
}
|
|
3488
|
+
const isDomContainer = container => container instanceof DomContainer;
|
|
3489
|
+
class DomContainer extends _SharedContainer {
|
|
3490
|
+
element;
|
|
3491
|
+
qContainer;
|
|
3492
|
+
qBase;
|
|
3493
|
+
qManifestHash;
|
|
3494
|
+
rootVNode;
|
|
3495
|
+
document;
|
|
3496
|
+
$journal$;
|
|
3497
|
+
renderDone=null;
|
|
3498
|
+
$rawStateData$;
|
|
3499
|
+
$storeProxyMap$=new WeakMap;
|
|
3500
|
+
$qFuncs$;
|
|
3501
|
+
$instanceHash$;
|
|
3502
|
+
stateData;
|
|
3503
|
+
$styleIds$=null;
|
|
3504
|
+
$vnodeLocate$=id => vnode_locate(this.rootVNode, id);
|
|
3505
|
+
$renderCount$=0;
|
|
3506
|
+
constructor(element) {
|
|
3507
|
+
if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
|
|
3508
|
+
this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
|
|
3509
|
+
throw qError(QError.elementWithoutContainer);
|
|
3510
|
+
}
|
|
3511
|
+
this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
|
|
3512
|
+
this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
|
|
3513
|
+
this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
|
|
3514
|
+
this.$rawStateData$ = null, this.stateData = null;
|
|
3515
|
+
const document = this.element.ownerDocument;
|
|
3516
|
+
document.qVNodeData || function(document) {
|
|
3517
|
+
const vNodeDataMap = document.qVNodeData || (document.qVNodeData = new WeakMap);
|
|
3518
|
+
const prototype = document.body;
|
|
3519
|
+
const getAttribute = prototype.getAttribute;
|
|
3520
|
+
const hasAttribute = prototype.hasAttribute;
|
|
3521
|
+
const getNodeType = ((prototype, name) => {
|
|
3522
|
+
let getter;
|
|
3523
|
+
for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
|
|
3524
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
3525
|
+
}
|
|
3526
|
+
return getter || function() {
|
|
3527
|
+
return this[name];
|
|
3528
|
+
};
|
|
3529
|
+
})(prototype, "nodeType");
|
|
3530
|
+
const attachVnodeDataAndRefs = element => {
|
|
3531
|
+
Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
|
|
3532
|
+
script.setAttribute("type", "x-qwik/vnode");
|
|
3533
|
+
const qContainerElement = script.closest("[q\\:container]");
|
|
3534
|
+
qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
|
|
3535
|
+
})), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
|
|
3536
|
+
const shadowRoot = parent.shadowRoot;
|
|
3537
|
+
shadowRoot && attachVnodeDataAndRefs(shadowRoot);
|
|
3538
|
+
}));
|
|
3539
|
+
};
|
|
3540
|
+
let NodeType;
|
|
3541
|
+
attachVnodeDataAndRefs(document), function(NodeType) {
|
|
3542
|
+
NodeType[NodeType.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType[NodeType.ELEMENT = 2] = "ELEMENT",
|
|
3543
|
+
NodeType[NodeType.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType[NodeType.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT",
|
|
3544
|
+
NodeType[NodeType.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType[NodeType.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END",
|
|
3545
|
+
NodeType[NodeType.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType[NodeType.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END",
|
|
3546
|
+
NodeType[NodeType.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType[NodeType.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END",
|
|
3547
|
+
NodeType[NodeType.OTHER = 0] = "OTHER";
|
|
3548
|
+
}(NodeType || (NodeType = {}));
|
|
3549
|
+
const getFastNodeType = node => {
|
|
3550
|
+
const nodeType = getNodeType.call(node);
|
|
3551
|
+
if (1 === nodeType) {
|
|
3552
|
+
return null === getAttribute.call(node, "q:container") ? hasAttribute.call(node, "q:shadowroot") ? NodeType.ELEMENT_SHADOW_ROOT : hasAttribute.call(node, ":") ? NodeType.ELEMENT : NodeType.OTHER : NodeType.ELEMENT_CONTAINER;
|
|
3553
|
+
}
|
|
3554
|
+
if (8 === nodeType) {
|
|
3555
|
+
const nodeValue = node.nodeValue || "";
|
|
3556
|
+
if (nodeValue.startsWith("q:container-island")) {
|
|
3557
|
+
return NodeType.COMMENT_ISLAND_START;
|
|
3558
|
+
}
|
|
3559
|
+
if (nodeValue.startsWith("q:ignore")) {
|
|
3560
|
+
return NodeType.COMMENT_IGNORE_START;
|
|
3561
|
+
}
|
|
3562
|
+
if (nodeValue.startsWith("q:container")) {
|
|
3563
|
+
return NodeType.COMMENT_SKIP_START;
|
|
3564
|
+
}
|
|
3565
|
+
if (nodeValue.startsWith("/q:container-island")) {
|
|
3566
|
+
return NodeType.COMMENT_ISLAND_END;
|
|
3567
|
+
}
|
|
3568
|
+
if (nodeValue.startsWith("/q:ignore")) {
|
|
3569
|
+
return NodeType.COMMENT_IGNORE_END;
|
|
3570
|
+
}
|
|
3571
|
+
if (nodeValue.startsWith("/q:container")) {
|
|
3572
|
+
return NodeType.COMMENT_SKIP_END;
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
return NodeType.OTHER;
|
|
3576
|
+
};
|
|
3577
|
+
const isSeparator = ch => VNodeDataSeparator_ADVANCE_1 <= ch && ch <= VNodeDataSeparator_ADVANCE_8192;
|
|
3578
|
+
const findVDataSectionEnd = (vData, start, end) => {
|
|
3579
|
+
let depth = 0;
|
|
3580
|
+
for (;start < end; ) {
|
|
3581
|
+
const ch = vData.charCodeAt(start);
|
|
3582
|
+
if (0 === depth && isSeparator(ch)) {
|
|
3583
|
+
break;
|
|
3584
|
+
}
|
|
3585
|
+
ch === VNodeDataChar_OPEN ? depth++ : ch === VNodeDataChar_CLOSE && depth--, start++;
|
|
3586
|
+
}
|
|
3587
|
+
return start;
|
|
3588
|
+
};
|
|
3589
|
+
const nextSibling = node => {
|
|
3590
|
+
for (;node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {}
|
|
3591
|
+
return node;
|
|
3592
|
+
};
|
|
3593
|
+
const firstChild = node => {
|
|
3594
|
+
for (;node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {}
|
|
3595
|
+
return node;
|
|
3596
|
+
};
|
|
3597
|
+
const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
|
|
3598
|
+
const vData_length = vData.length;
|
|
3599
|
+
let elementIdx = 0;
|
|
3600
|
+
let vNodeElementIndex = -1;
|
|
3601
|
+
let vData_start = 0;
|
|
3602
|
+
let vData_end = 0;
|
|
3603
|
+
let ch = 0;
|
|
3604
|
+
let needsToStoreRef = -1;
|
|
3605
|
+
let nextNode = null;
|
|
3606
|
+
const howManyElementsToSkip = () => {
|
|
3607
|
+
let elementsToSkip = 0;
|
|
3608
|
+
for (;isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator_ADVANCE_1,
|
|
3609
|
+
vData_start++, !(vData_start >= vData_length)); ) {}
|
|
3610
|
+
return elementsToSkip;
|
|
3611
|
+
};
|
|
3612
|
+
do {
|
|
3613
|
+
if (node === exitNode) {
|
|
3614
|
+
return;
|
|
3615
|
+
}
|
|
3616
|
+
nextNode = null;
|
|
3617
|
+
const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
|
|
3618
|
+
if (nodeType === NodeType.ELEMENT_CONTAINER) {
|
|
3619
|
+
const container = node;
|
|
3620
|
+
let cursor = node;
|
|
3621
|
+
for (;cursor && !(nextNode = nextSibling(cursor)); ) {
|
|
3622
|
+
cursor = cursor.parentNode;
|
|
3623
|
+
}
|
|
3624
|
+
walkContainer(walker, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
|
|
3625
|
+
} else if (nodeType === NodeType.COMMENT_IGNORE_START) {
|
|
3626
|
+
let islandNode = node;
|
|
3627
|
+
do {
|
|
3628
|
+
if (islandNode = walker.nextNode(), !islandNode) {
|
|
3629
|
+
throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
|
|
3630
|
+
}
|
|
3631
|
+
} while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
|
|
3632
|
+
nextNode = null;
|
|
3633
|
+
} else if (nodeType === NodeType.COMMENT_ISLAND_END) {
|
|
3634
|
+
nextNode = node;
|
|
3635
|
+
do {
|
|
3636
|
+
if (nextNode = walker.nextNode(), !nextNode) {
|
|
3637
|
+
throw new Error("Ignore block not closed!");
|
|
3638
|
+
}
|
|
3639
|
+
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
|
|
3640
|
+
nextNode = null;
|
|
3641
|
+
} else if (nodeType === NodeType.COMMENT_SKIP_START) {
|
|
3642
|
+
nextNode = node;
|
|
3643
|
+
do {
|
|
3644
|
+
if (nextNode = nextSibling(nextNode), !nextNode) {
|
|
3645
|
+
throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
|
|
3646
|
+
}
|
|
3647
|
+
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
|
|
3648
|
+
walkContainer(walker, node, node, nextNode, "", null);
|
|
3649
|
+
} else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
|
|
3650
|
+
nextNode = nextSibling(node);
|
|
3651
|
+
const shadowRootContainer = node;
|
|
3652
|
+
const shadowRoot = shadowRootContainer?.shadowRoot;
|
|
3653
|
+
shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
|
|
3654
|
+
}
|
|
3655
|
+
if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
|
|
3656
|
+
if (vNodeElementIndex < elementIdx && (-1 === vNodeElementIndex && (vNodeElementIndex = 0),
|
|
3657
|
+
vData_start = vData_end, vData_start < vData_length ? (vNodeElementIndex += howManyElementsToSkip(),
|
|
3658
|
+
ch === VNodeDataSeparator_REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++,
|
|
3659
|
+
ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator_ADVANCE_1),
|
|
3660
|
+
vData_end = findVDataSectionEnd(vData, vData_start, vData_length)) : vNodeElementIndex = Number.MAX_SAFE_INTEGER),
|
|
3661
|
+
elementIdx === vNodeElementIndex) {
|
|
3662
|
+
needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
|
|
3663
|
+
const instructions = vData.substring(vData_start, vData_end);
|
|
3664
|
+
vNodeDataMap.set(node, instructions);
|
|
3665
|
+
}
|
|
3666
|
+
elementIdx++;
|
|
3667
|
+
}
|
|
3668
|
+
} while (node = nextNode || walker.nextNode());
|
|
3669
|
+
};
|
|
3670
|
+
const walker = document.createTreeWalker(document, 129);
|
|
3671
|
+
walkContainer(walker, null, walker.firstChild(), null, "", null);
|
|
3672
|
+
}(document), this.$rawStateData$ = [], this.stateData = [];
|
|
3673
|
+
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
3674
|
+
if (0 !== qwikStates.length) {
|
|
3675
|
+
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
|
|
3676
|
+
this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
|
|
3677
|
+
}
|
|
3678
|
+
this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
|
|
3679
|
+
}
|
|
3680
|
+
$setRawState$(id, vParent) {
|
|
3681
|
+
this.stateData[id] = vParent;
|
|
3537
3682
|
}
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
|
|
3541
|
-
const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)),
|
|
3542
|
-
vnode[TextVNodeProps.node]);
|
|
3543
|
-
function vnode_toString(depth = 10, offset = "", materialize = !1, siblings = !1) {
|
|
3544
|
-
let vnode = this;
|
|
3545
|
-
if (0 === depth) {
|
|
3546
|
-
return "...";
|
|
3683
|
+
parseQRL(qrl) {
|
|
3684
|
+
return inflateQRL(this, parseQRL(qrl));
|
|
3547
3685
|
}
|
|
3548
|
-
|
|
3549
|
-
|
|
3686
|
+
handleError(err, host) {
|
|
3687
|
+
const errorStore = this.resolveContext(host, ERROR_CONTEXT);
|
|
3688
|
+
if (!errorStore) {
|
|
3689
|
+
throw err;
|
|
3690
|
+
}
|
|
3691
|
+
errorStore.error = err;
|
|
3550
3692
|
}
|
|
3551
|
-
|
|
3552
|
-
|
|
3693
|
+
setContext(host, context, value) {
|
|
3694
|
+
let ctx = this.getHostProp(host, "q:ctx");
|
|
3695
|
+
ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
|
|
3553
3696
|
}
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
if ("q:type" !== key) {
|
|
3562
|
-
const value = vnode_getAttr(vnode, key);
|
|
3563
|
-
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
3697
|
+
resolveContext(host, contextId) {
|
|
3698
|
+
for (;host; ) {
|
|
3699
|
+
const ctx = this.getHostProp(host, "q:ctx");
|
|
3700
|
+
if (ctx) {
|
|
3701
|
+
const value = mapArray_get(ctx, contextId.id, 0);
|
|
3702
|
+
if (value) {
|
|
3703
|
+
return value;
|
|
3564
3704
|
}
|
|
3565
|
-
}));
|
|
3566
|
-
const name = VirtualTypeName[vnode_getAttr(vnode, "q:type") || VirtualType.Virtual] || VirtualTypeName[VirtualType.Virtual];
|
|
3567
|
-
strings.push("<" + name + attrs.join("") + ">");
|
|
3568
|
-
const child = vnode_getFirstChild(vnode);
|
|
3569
|
-
child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", !0, !0)),
|
|
3570
|
-
strings.push("</" + name + ">");
|
|
3571
|
-
} else if (vnode_isElementVNode(vnode)) {
|
|
3572
|
-
const tag = vnode_getElementName(vnode);
|
|
3573
|
-
const attrs = [];
|
|
3574
|
-
const keys = vnode_getAttrKeys(vnode);
|
|
3575
|
-
keys.forEach((key => {
|
|
3576
|
-
const value = vnode_getAttr(vnode, key);
|
|
3577
|
-
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
3578
|
-
}));
|
|
3579
|
-
const node = vnode_getNode(vnode);
|
|
3580
|
-
if (node) {
|
|
3581
|
-
const vnodeData = node.ownerDocument.qVNodeData?.get(node);
|
|
3582
|
-
vnodeData && attrs.push(" q:vnodeData=" + qwikDebugToString(vnodeData));
|
|
3583
|
-
}
|
|
3584
|
-
const domAttrs = node.attributes;
|
|
3585
|
-
for (let i = 0; i < domAttrs.length; i++) {
|
|
3586
|
-
const attr = domAttrs[i];
|
|
3587
|
-
-1 === keys.indexOf(attr.name) && attrs.push(" " + attr.name + (attr.value ? "=" + qwikDebugToString(attr.value) : ""));
|
|
3588
|
-
}
|
|
3589
|
-
if (strings.push("<" + tag + attrs.join("") + ">"), vnode_isMaterialized(vnode) || materialize) {
|
|
3590
|
-
const child = vnode_getFirstChild(vnode);
|
|
3591
|
-
child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", !0, !0));
|
|
3592
|
-
} else {
|
|
3593
|
-
strings.push(" \x3c!-- not materialized --!>");
|
|
3594
3705
|
}
|
|
3595
|
-
|
|
3706
|
+
host = this.getParentHost(host);
|
|
3596
3707
|
}
|
|
3597
|
-
vnode = siblings && vnode_getNextSibling(vnode) || null;
|
|
3598
|
-
} while (vnode);
|
|
3599
|
-
return strings.join("\n" + offset);
|
|
3600
|
-
}
|
|
3601
|
-
const isNumber = ch => 48 <= ch && ch <= 57;
|
|
3602
|
-
const isLowercase = ch => 97 <= ch && ch <= 122;
|
|
3603
|
-
const stack = [];
|
|
3604
|
-
const vnode_getType = vnode => {
|
|
3605
|
-
const type = vnode[VNodeProps.flags];
|
|
3606
|
-
if (type & VNodeFlags.Element) {
|
|
3607
|
-
return 1;
|
|
3608
|
-
}
|
|
3609
|
-
if (type & VNodeFlags.Virtual) {
|
|
3610
|
-
return 11;
|
|
3611
3708
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3709
|
+
getParentHost(host) {
|
|
3710
|
+
let vNode = vnode_getParent(host);
|
|
3711
|
+
for (;vNode; ) {
|
|
3712
|
+
if (vnode_isVirtualVNode(vNode)) {
|
|
3713
|
+
if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
|
|
3714
|
+
return vNode;
|
|
3715
|
+
}
|
|
3716
|
+
const parent = vnode_getProp(vNode, ":", this.$vnodeLocate$);
|
|
3717
|
+
if (parent) {
|
|
3718
|
+
vNode = parent;
|
|
3719
|
+
continue;
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
vNode = vnode_getParent(vNode);
|
|
3723
|
+
}
|
|
3724
|
+
return null;
|
|
3614
3725
|
}
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
const isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
|
|
3618
|
-
const aPath = [];
|
|
3619
|
-
const bPath = [];
|
|
3620
|
-
const vnode_documentPosition = (a, b) => {
|
|
3621
|
-
if (a === b) {
|
|
3622
|
-
return 0;
|
|
3726
|
+
setHostProp(host, name, value) {
|
|
3727
|
+
vnode_setProp(host, name, value);
|
|
3623
3728
|
}
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3729
|
+
getHostProp(host, name) {
|
|
3730
|
+
const vNode = host;
|
|
3731
|
+
let getObjectById = null;
|
|
3732
|
+
switch (name) {
|
|
3733
|
+
case "q:seq":
|
|
3734
|
+
case "q:props":
|
|
3735
|
+
case "q:renderFn":
|
|
3736
|
+
case "q:ctx":
|
|
3737
|
+
case "q:subs":
|
|
3738
|
+
getObjectById = this.$getObjectById$;
|
|
3739
|
+
break;
|
|
3740
|
+
|
|
3741
|
+
case "q:seqIdx":
|
|
3742
|
+
case ":onIdx":
|
|
3743
|
+
getObjectById = parseInt;
|
|
3744
|
+
}
|
|
3745
|
+
return vnode_getProp(vNode, name, getObjectById);
|
|
3628
3746
|
}
|
|
3629
|
-
|
|
3630
|
-
|
|
3747
|
+
scheduleRender() {
|
|
3748
|
+
return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
|
|
3749
|
+
this.renderDone;
|
|
3631
3750
|
}
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
} while (cursor);
|
|
3640
|
-
cursor = b;
|
|
3641
|
-
do {
|
|
3642
|
-
if (cursor = cursor[VNodeProps.previousSibling], cursor === a) {
|
|
3643
|
-
return -1;
|
|
3751
|
+
processChores() {
|
|
3752
|
+
let renderCount = this.$renderCount$;
|
|
3753
|
+
const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
3754
|
+
if (isPromise(result)) {
|
|
3755
|
+
return result.then((async () => {
|
|
3756
|
+
for (;renderCount !== this.$renderCount$; ) {
|
|
3757
|
+
renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
3644
3758
|
}
|
|
3645
|
-
|
|
3646
|
-
|
|
3759
|
+
this.renderDone = null;
|
|
3760
|
+
}));
|
|
3647
3761
|
}
|
|
3648
|
-
|
|
3762
|
+
renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
|
|
3649
3763
|
}
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
|
|
3764
|
+
ensureProjectionResolved(vNode) {
|
|
3765
|
+
if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
|
|
3766
|
+
vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
|
|
3767
|
+
for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
|
|
3768
|
+
if (isSlotProp(vNode[i])) {
|
|
3769
|
+
const value = vNode[i + 1];
|
|
3770
|
+
"string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3660
3773
|
}
|
|
3661
|
-
projectionDepth > 0 && (vHost = vnode_getParent(vHost));
|
|
3662
|
-
}
|
|
3663
|
-
return vHost;
|
|
3664
|
-
};
|
|
3665
|
-
const VNodeArray = class VNode extends Array {
|
|
3666
|
-
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
3667
|
-
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3668
|
-
return vnode.push(firstChild, lastChild, element, elementName), vnode;
|
|
3669
|
-
}
|
|
3670
|
-
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
3671
|
-
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3672
|
-
return vnode.push(textNode, text), vnode;
|
|
3673
3774
|
}
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3775
|
+
$getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(),
|
|
3776
|
+
this.stateData[id]);
|
|
3777
|
+
getSyncFn(id) {
|
|
3778
|
+
const fn = this.$qFuncs$[id];
|
|
3779
|
+
return assertTrue(), fn;
|
|
3677
3780
|
}
|
|
3678
|
-
|
|
3679
|
-
|
|
3781
|
+
$appendStyle$(content, styleId, host, scoped) {
|
|
3782
|
+
if (scoped) {
|
|
3783
|
+
const scopedStyleIdsString = this.getHostProp(host, "q:sstyle");
|
|
3784
|
+
const scopedStyleIds = new Set(function(scopedStyleIds) {
|
|
3785
|
+
return scopedStyleIds?.split(" ") ?? null;
|
|
3786
|
+
}(scopedStyleIdsString));
|
|
3787
|
+
scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", function(scopedStyleIds) {
|
|
3788
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
3789
|
+
}(scopedStyleIds));
|
|
3790
|
+
}
|
|
3791
|
+
if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach((style => {
|
|
3792
|
+
this.$styleIds$.add(style.getAttribute("q:style"));
|
|
3793
|
+
}))), !this.$styleIds$.has(styleId)) {
|
|
3794
|
+
this.$styleIds$.add(styleId);
|
|
3795
|
+
const styleElement = this.document.createElement("style");
|
|
3796
|
+
styleElement.setAttribute("q:style", styleId), styleElement.textContent = content,
|
|
3797
|
+
this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
|
|
3798
|
+
}
|
|
3680
3799
|
}
|
|
3681
|
-
}
|
|
3682
|
-
var ExperimentalFeatures;
|
|
3683
|
-
var VNodeDataFlag;
|
|
3684
|
-
!function(ExperimentalFeatures) {
|
|
3685
|
-
ExperimentalFeatures.preventNavigate = "preventNavigate", ExperimentalFeatures.valibot = "valibot",
|
|
3686
|
-
ExperimentalFeatures.noSPA = "noSPA", ExperimentalFeatures.webWorker = "webWorker",
|
|
3687
|
-
ExperimentalFeatures.insights = "insights";
|
|
3688
|
-
}(ExperimentalFeatures || (ExperimentalFeatures = {})), function(VNodeDataFlag) {
|
|
3689
|
-
VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
|
|
3690
|
-
VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.REFERENCE = 4] = "REFERENCE",
|
|
3691
|
-
VNodeDataFlag[VNodeDataFlag.SERIALIZE = 8] = "SERIALIZE";
|
|
3692
|
-
}(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
3800
|
+
}
|
|
3693
3801
|
const deserializedProxyMap = new WeakMap;
|
|
3694
3802
|
const unwrapDeserializerProxy = value => {
|
|
3695
3803
|
const unwrapped = "object" == typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
|
|
@@ -3830,7 +3938,7 @@
|
|
|
3830
3938
|
const signal = target;
|
|
3831
3939
|
const d = data;
|
|
3832
3940
|
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
|
|
3833
|
-
signal.$untrackedValue$ = d[3], signal.$effects$ = d.slice(
|
|
3941
|
+
signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
|
|
3834
3942
|
break;
|
|
3835
3943
|
}
|
|
3836
3944
|
|
|
@@ -3922,11 +4030,14 @@
|
|
|
3922
4030
|
break;
|
|
3923
4031
|
|
|
3924
4032
|
case TypeIds.EffectData:
|
|
3925
|
-
|
|
3926
|
-
|
|
4033
|
+
{
|
|
4034
|
+
const effectData = target;
|
|
4035
|
+
effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
|
|
4036
|
+
break;
|
|
4037
|
+
}
|
|
3927
4038
|
|
|
3928
4039
|
default:
|
|
3929
|
-
|
|
4040
|
+
throw qError(QError.serializeErrorNotImplemented, [ typeId ]);
|
|
3930
4041
|
}
|
|
3931
4042
|
}
|
|
3932
4043
|
};
|
|
@@ -4038,13 +4149,16 @@
|
|
|
4038
4149
|
return vnodeOrDocument;
|
|
4039
4150
|
}
|
|
4040
4151
|
const vNode = retrieveVNodeOrDocument(container, value);
|
|
4041
|
-
|
|
4152
|
+
if (vnode_isVNode(vNode)) {
|
|
4153
|
+
return vnode_getNode(vNode);
|
|
4154
|
+
}
|
|
4155
|
+
throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
|
|
4042
4156
|
|
|
4043
4157
|
case TypeIds.EffectData:
|
|
4044
|
-
return new
|
|
4158
|
+
return new EffectPropData({});
|
|
4045
4159
|
|
|
4046
4160
|
default:
|
|
4047
|
-
|
|
4161
|
+
throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
|
|
4048
4162
|
}
|
|
4049
4163
|
};
|
|
4050
4164
|
function retrieveVNodeOrDocument(container, value) {
|
|
@@ -4153,8 +4267,13 @@
|
|
|
4153
4267
|
const seen = depth > 1 && serializationContext.$wasSeen$(value);
|
|
4154
4268
|
"number" == typeof seen && seen >= 0 ? output(TypeIds.RootRef, seen) : output(TypeIds.String, value);
|
|
4155
4269
|
}
|
|
4270
|
+
} else if (void 0 === value) {
|
|
4271
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
4156
4272
|
} else {
|
|
4157
|
-
|
|
4273
|
+
if (value !== NEEDS_COMPUTATION) {
|
|
4274
|
+
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
4275
|
+
}
|
|
4276
|
+
output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
|
|
4158
4277
|
}
|
|
4159
4278
|
};
|
|
4160
4279
|
const writeObjectValue = (value, idx) => {
|
|
@@ -4170,8 +4289,8 @@
|
|
|
4170
4289
|
const constProps = value[_CONST_PROPS];
|
|
4171
4290
|
const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
|
|
4172
4291
|
output(TypeIds.PropsProxy, out);
|
|
4173
|
-
} else if (value instanceof
|
|
4174
|
-
output(TypeIds.EffectData, [ value.data ]);
|
|
4292
|
+
} else if (value instanceof EffectPropData) {
|
|
4293
|
+
output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
|
|
4175
4294
|
} else if (isStore(value)) {
|
|
4176
4295
|
if (function(value) {
|
|
4177
4296
|
return "__brand" in value && "resource" === value.__brand;
|
|
@@ -4179,7 +4298,7 @@
|
|
|
4179
4298
|
serializationContext.$resources$.add(value);
|
|
4180
4299
|
const res = promiseResults.get(value.value);
|
|
4181
4300
|
if (!res) {
|
|
4182
|
-
|
|
4301
|
+
throw qError(QError.serializeErrorUnvisited, [ "resource" ]);
|
|
4183
4302
|
}
|
|
4184
4303
|
output(TypeIds.Resource, [ ...res, getStoreHandler(value).$effects$ ]);
|
|
4185
4304
|
} else {
|
|
@@ -4217,7 +4336,7 @@
|
|
|
4217
4336
|
} else if (value instanceof Signal) {
|
|
4218
4337
|
const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
4219
4338
|
if (value instanceof WrappedSignal) {
|
|
4220
|
-
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
|
|
4339
|
+
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
|
|
4221
4340
|
} else if (value instanceof ComputedSignal) {
|
|
4222
4341
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
4223
4342
|
v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
|
|
@@ -4273,12 +4392,12 @@
|
|
|
4273
4392
|
} else if (isPromise(value)) {
|
|
4274
4393
|
const res = promiseResults.get(value);
|
|
4275
4394
|
if (!res) {
|
|
4276
|
-
|
|
4395
|
+
throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
|
|
4277
4396
|
}
|
|
4278
4397
|
output(TypeIds.Promise, res);
|
|
4279
4398
|
} else {
|
|
4280
4399
|
if (!(value instanceof Uint8Array)) {
|
|
4281
|
-
|
|
4400
|
+
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
4282
4401
|
}
|
|
4283
4402
|
{
|
|
4284
4403
|
let buf = "";
|
|
@@ -4306,7 +4425,10 @@
|
|
|
4306
4425
|
$addRoot$,
|
|
4307
4426
|
$getRootId$: obj => {
|
|
4308
4427
|
const id = map.get(obj);
|
|
4309
|
-
|
|
4428
|
+
if (!id || -1 === id) {
|
|
4429
|
+
throw qError(QError.serializeErrorMissingRootId, [ obj ]);
|
|
4430
|
+
}
|
|
4431
|
+
return id;
|
|
4310
4432
|
},
|
|
4311
4433
|
$syncFns$: syncFns,
|
|
4312
4434
|
$addSyncFn$: (funcStr, argCount, fn) => {
|
|
@@ -4358,11 +4480,15 @@
|
|
|
4358
4480
|
const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
|
|
4359
4481
|
v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$),
|
|
4360
4482
|
obj instanceof WrappedSignal ? (obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$),
|
|
4361
|
-
obj.$args$ && discoveredValues.push(...obj.$args$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
|
|
4483
|
+
obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
|
|
4362
4484
|
} else if (obj instanceof Task) {
|
|
4363
4485
|
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
|
|
4364
4486
|
} else if (isSsrNode(obj)) {
|
|
4365
|
-
|
|
4487
|
+
if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
|
|
4488
|
+
for (const data of obj.childrenVNodeData) {
|
|
4489
|
+
discoverValuesForVNodeData(data, discoveredValues);
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4366
4492
|
} else if (isDomRef(obj)) {
|
|
4367
4493
|
discoveredValues.push(obj.$ssrNode$.id);
|
|
4368
4494
|
} else if (isJSXNode(obj)) {
|
|
@@ -4379,11 +4505,11 @@
|
|
|
4379
4505
|
}), (error => {
|
|
4380
4506
|
promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
|
|
4381
4507
|
})), promises.push(obj);
|
|
4382
|
-
} else if (obj instanceof
|
|
4508
|
+
} else if (obj instanceof EffectPropData) {
|
|
4383
4509
|
discoveredValues.push(obj.data);
|
|
4384
4510
|
} else {
|
|
4385
4511
|
if (!isObjectLiteral(obj)) {
|
|
4386
|
-
|
|
4512
|
+
throw qError(QError.serializeErrorUnknownType, [ obj ]);
|
|
4387
4513
|
}
|
|
4388
4514
|
Object.entries(obj).forEach((([key, value]) => {
|
|
4389
4515
|
discoveredValues.push(key, value);
|
|
@@ -4415,6 +4541,19 @@
|
|
|
4415
4541
|
$prepVNodeData$: prepVNodeData
|
|
4416
4542
|
};
|
|
4417
4543
|
};
|
|
4544
|
+
const isSsrAttrs = value => Array.isArray(value) && value.length > 0;
|
|
4545
|
+
const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
|
|
4546
|
+
for (const value of vnodeData) {
|
|
4547
|
+
if (isSsrAttrs(value)) {
|
|
4548
|
+
for (let i = 1; i < value.length; i += 2) {
|
|
4549
|
+
if ("q:key" === value[i - 1]) {
|
|
4550
|
+
continue;
|
|
4551
|
+
}
|
|
4552
|
+
discoveredValues.push(value[i]);
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
};
|
|
4418
4557
|
const promiseResults = new WeakMap;
|
|
4419
4558
|
function serializeWrappingFn(serializationContext, value) {
|
|
4420
4559
|
value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
|
|
@@ -4438,7 +4577,10 @@
|
|
|
4438
4577
|
backChannel || (backChannel = globalThis[QRL_RUNTIME_CHUNK] = new Map), backChannel.set(value.$symbol$, value._devOnlySymbolRef),
|
|
4439
4578
|
chunk || (chunk = QRL_RUNTIME_CHUNK);
|
|
4440
4579
|
}
|
|
4441
|
-
|
|
4580
|
+
if (!chunk) {
|
|
4581
|
+
throw qError(QError.qrlMissingChunk, [ value.$symbol$ ]);
|
|
4582
|
+
}
|
|
4583
|
+
chunk.startsWith("./") && (chunk = chunk.slice(2));
|
|
4442
4584
|
}
|
|
4443
4585
|
let qrlStringInline = `${chunk}#${symbol}`;
|
|
4444
4586
|
if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0) {
|
|
@@ -4610,7 +4752,7 @@
|
|
|
4610
4752
|
let expectIndex = 0;
|
|
4611
4753
|
return unwrapped.forEach(((v, i) => {
|
|
4612
4754
|
if (i !== expectIndex) {
|
|
4613
|
-
throw qError(
|
|
4755
|
+
throw qError(QError.verifySerializable, [ unwrapped ]);
|
|
4614
4756
|
}
|
|
4615
4757
|
_verifySerializable(v, seen, ctx + "[" + i + "]"), expectIndex = i + 1;
|
|
4616
4758
|
})), value;
|
|
@@ -4636,7 +4778,7 @@
|
|
|
4636
4778
|
const fnName = value.name;
|
|
4637
4779
|
message += ` because it's a function named "${fnName}". You might need to convert it to a QRL using $(fn):\n\nconst ${fnName} = $(${String(value)});\n\nPlease check out https://qwik.dev/docs/advanced/qrl/ for more information.`;
|
|
4638
4780
|
}
|
|
4639
|
-
|
|
4781
|
+
throw qError(QError.verifySerializable, [ message ]);
|
|
4640
4782
|
}
|
|
4641
4783
|
return value;
|
|
4642
4784
|
};
|
|
@@ -4657,7 +4799,7 @@
|
|
|
4657
4799
|
function bindFnToContext(currentCtx, beforeFn) {
|
|
4658
4800
|
return (...args) => maybeThen(resolveLazy(), (fn => {
|
|
4659
4801
|
if (!isFunction(fn)) {
|
|
4660
|
-
throw qError(
|
|
4802
|
+
throw qError(QError.qrlIsNotFunction);
|
|
4661
4803
|
}
|
|
4662
4804
|
if (beforeFn && !1 === beforeFn()) {
|
|
4663
4805
|
return;
|
|
@@ -4958,7 +5100,22 @@
|
|
|
4958
5100
|
onReady = () => q.forEach(q.push = v => sw.active.postMessage(v)), sw.installing ? sw.installing.addEventListener("statechange", (e => "activated" == e.target.state && onReady())) : onReady();
|
|
4959
5101
|
})), v && q.push([ "verbose" ]), document.addEventListener("qprefetch", (e => e.detail.bundles && q.push([ "prefetch", b, ...e.detail.bundles ])));
|
|
4960
5102
|
}).toString();
|
|
4961
|
-
exports
|
|
5103
|
+
Object.defineProperty(exports, "isBrowser", {
|
|
5104
|
+
enumerable: !0,
|
|
5105
|
+
get: function() {
|
|
5106
|
+
return build.isBrowser;
|
|
5107
|
+
}
|
|
5108
|
+
}), Object.defineProperty(exports, "isDev", {
|
|
5109
|
+
enumerable: !0,
|
|
5110
|
+
get: function() {
|
|
5111
|
+
return build.isDev;
|
|
5112
|
+
}
|
|
5113
|
+
}), Object.defineProperty(exports, "isServer", {
|
|
5114
|
+
enumerable: !0,
|
|
5115
|
+
get: function() {
|
|
5116
|
+
return build.isServer;
|
|
5117
|
+
}
|
|
5118
|
+
}), exports.$ = $, exports.Fragment = Fragment, exports.PrefetchGraph = (opts = {}) => {
|
|
4962
5119
|
const isTest = (void 0).TEST;
|
|
4963
5120
|
if (build.isDev && !isTest) {
|
|
4964
5121
|
return _jsxSorted("script", null, {
|
|
@@ -5020,7 +5177,7 @@
|
|
|
5020
5177
|
}), props.children, jsx(SSRComment, {
|
|
5021
5178
|
data: "qkssr-po"
|
|
5022
5179
|
}) ], exports.SkipRender = SkipRender, exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS,
|
|
5023
|
-
exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData =
|
|
5180
|
+
exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = EffectPropData,
|
|
5024
5181
|
exports._IMMUTABLE = _IMMUTABLE, exports._SharedContainer = _SharedContainer, exports._VAR_PROPS = _VAR_PROPS,
|
|
5025
5182
|
exports._deserialize = function(rawStateData, element) {
|
|
5026
5183
|
if (null == rawStateData) {
|
|
@@ -5163,7 +5320,7 @@
|
|
|
5163
5320
|
if (void 0 !== defaultValue) {
|
|
5164
5321
|
return set(defaultValue);
|
|
5165
5322
|
}
|
|
5166
|
-
throw qError(
|
|
5323
|
+
throw qError(QError.notFoundContext, [ context.id ]);
|
|
5167
5324
|
}, exports.useContextProvider = useContextProvider, exports.useErrorBoundary = () => {
|
|
5168
5325
|
const store = useStore({
|
|
5169
5326
|
error: void 0
|