@qwik.dev/core 2.0.0-alpha.2 → 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.wasm.cjs +259 -272
- package/bindings/qwik.wasm.mjs +259 -272
- 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 +41 -22
- package/dist/core.cjs +6313 -6125
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +6300 -6124
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +1574 -1407
- package/dist/core.prod.mjs +3043 -2898
- 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 +1946 -1927
- package/dist/optimizer.mjs +2410 -2444
- package/dist/prefetch/package.json +1 -1
- package/dist/server.cjs +745 -578
- package/dist/server.mjs +736 -570
- package/dist/testing/index.cjs +3297 -3119
- package/dist/testing/index.mjs +3267 -3090
- package/dist/testing/package.json +1 -1
- package/package.json +4 -4
- 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
|
}
|
|
@@ -1560,21 +1271,22 @@
|
|
|
1560
1271
|
}(jsxProps, vNodeProps), shouldRender && (host[VNodeProps.flags] &= ~VNodeFlags.Deleted,
|
|
1561
1272
|
container.$scheduler$(ChoreType.COMPONENT, host, componentQRL, jsxProps));
|
|
1562
1273
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}
|
|
1274
|
+
!function(children, host) {
|
|
1275
|
+
const projectionChildren = Array.isArray(children) ? children : [ children ];
|
|
1276
|
+
const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
|
|
1277
|
+
const projections = [];
|
|
1278
|
+
if (host) {
|
|
1279
|
+
for (let i = vnode_getPropStartIndex(host); i < host.length; i += 2) {
|
|
1280
|
+
const prop = host[i];
|
|
1281
|
+
if (isSlotProp(prop)) {
|
|
1282
|
+
const slotName = prop;
|
|
1283
|
+
projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
|
|
1574
1284
|
}
|
|
1575
1285
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1286
|
+
}
|
|
1287
|
+
if (0 !== projections.length || null != children) {
|
|
1288
|
+
for (let i = 0; i < projectionChildren.length; i++) {
|
|
1289
|
+
const child = projectionChildren[i];
|
|
1578
1290
|
const slotName = String(isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || "");
|
|
1579
1291
|
const idx = mapApp_findIndx(projections, slotName, 0);
|
|
1580
1292
|
let jsxBucket;
|
|
@@ -1606,7 +1318,7 @@
|
|
|
1606
1318
|
}
|
|
1607
1319
|
}
|
|
1608
1320
|
function insertNewComponent(host, componentQRL, jsxProps) {
|
|
1609
|
-
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());
|
|
1610
1322
|
const jsxNode = jsxValue;
|
|
1611
1323
|
build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
|
|
1612
1324
|
container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
|
|
@@ -1631,9 +1343,12 @@
|
|
|
1631
1343
|
return qrl ? qrl.$hash$ : null;
|
|
1632
1344
|
}
|
|
1633
1345
|
function Projection() {}
|
|
1634
|
-
function
|
|
1635
|
-
|
|
1636
|
-
|
|
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;
|
|
1637
1352
|
}
|
|
1638
1353
|
function cleanup(container, vNode) {
|
|
1639
1354
|
let vCursor = vNode;
|
|
@@ -1644,8 +1359,8 @@
|
|
|
1644
1359
|
for (;;) {
|
|
1645
1360
|
const type = vCursor[VNodeProps.flags];
|
|
1646
1361
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
1647
|
-
if (
|
|
1648
|
-
|
|
1362
|
+
if (clearVNodeEffectDependencies(container, vCursor), markVNodeAsDeleted(vCursor),
|
|
1363
|
+
type & VNodeFlags.Virtual) {
|
|
1649
1364
|
const seq = container.getHostProp(vCursor, "q:seq");
|
|
1650
1365
|
if (seq) {
|
|
1651
1366
|
for (let i = 0; i < seq.length; i++) {
|
|
@@ -1726,26 +1441,33 @@
|
|
|
1726
1441
|
const HANDLER_PREFIX = ":";
|
|
1727
1442
|
let count = 0;
|
|
1728
1443
|
var SiblingsArray;
|
|
1729
|
-
var ChoreType;
|
|
1730
1444
|
!function(SiblingsArray) {
|
|
1731
1445
|
SiblingsArray[SiblingsArray.Name = 0] = "Name", SiblingsArray[SiblingsArray.Key = 1] = "Key",
|
|
1732
1446
|
SiblingsArray[SiblingsArray.VNode = 2] = "VNode", SiblingsArray[SiblingsArray.Size = 3] = "Size",
|
|
1733
1447
|
SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
|
|
1734
|
-
}(SiblingsArray || (SiblingsArray = {}))
|
|
1735
|
-
|
|
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",
|
|
1736
1458
|
ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RESOURCE = 2] = "RESOURCE",
|
|
1737
1459
|
ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
|
|
1738
1460
|
ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
|
|
1739
|
-
ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.
|
|
1740
|
-
ChoreType[ChoreType.JOURNAL_FLUSH =
|
|
1741
|
-
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";
|
|
1742
1464
|
}(ChoreType || (ChoreType = {}));
|
|
1743
1465
|
const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
1744
1466
|
const choreQueue = [];
|
|
1745
1467
|
let currentChore = null;
|
|
1746
1468
|
let journalFlushScheduled = !1;
|
|
1747
1469
|
return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
|
|
1748
|
-
const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.
|
|
1470
|
+
const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.COMPONENT_SSR;
|
|
1749
1471
|
const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.RESOURCE || type === ChoreType.CLEANUP_VISIBLE;
|
|
1750
1472
|
isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
|
|
1751
1473
|
let chore = {
|
|
@@ -1824,7 +1546,13 @@
|
|
|
1824
1546
|
|
|
1825
1547
|
case ChoreType.COMPONENT:
|
|
1826
1548
|
case ChoreType.COMPONENT_SSR:
|
|
1827
|
-
returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx =>
|
|
1549
|
+
returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
|
|
1550
|
+
if (chore.$type$ === ChoreType.COMPONENT) {
|
|
1551
|
+
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
1552
|
+
return vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId));
|
|
1553
|
+
}
|
|
1554
|
+
return jsx;
|
|
1555
|
+
}), (err => container.handleError(err, host)));
|
|
1828
1556
|
break;
|
|
1829
1557
|
|
|
1830
1558
|
case ChoreType.RESOURCE:
|
|
@@ -1869,6 +1597,19 @@
|
|
|
1869
1597
|
returnValue = target.resolved ? null : target.resolve();
|
|
1870
1598
|
break;
|
|
1871
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
|
+
}
|
|
1872
1613
|
}
|
|
1873
1614
|
return thenFn = value => (currentChore && (currentChore.$executed$ = !0, currentChore.$resolve$?.(value)),
|
|
1874
1615
|
currentChore = null, chore.$returnValue$ = value), isPromise(valueOrPromise = returnValue) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
@@ -1890,8 +1631,10 @@
|
|
|
1890
1631
|
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
1891
1632
|
if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
|
|
1892
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()}`;
|
|
1893
|
-
|
|
1894
|
-
|
|
1634
|
+
if (shouldThrowOnHostMismatch) {
|
|
1635
|
+
throw qError(QError.serverHostMismatch, [ errorMessage ]);
|
|
1636
|
+
}
|
|
1637
|
+
return logWarn(errorMessage), null;
|
|
1895
1638
|
}
|
|
1896
1639
|
{
|
|
1897
1640
|
const hostDiff = vnode_documentPosition(aHost, bHost);
|
|
@@ -1908,460 +1651,338 @@
|
|
|
1908
1651
|
if (0 !== idxDiff) {
|
|
1909
1652
|
return idxDiff;
|
|
1910
1653
|
}
|
|
1911
|
-
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)) {
|
|
1912
1655
|
return 1;
|
|
1913
1656
|
}
|
|
1914
1657
|
}
|
|
1915
1658
|
return 0;
|
|
1916
1659
|
}
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
|
|
1929
|
-
this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
|
|
1930
|
-
throw Error("Not implemented");
|
|
1931
|
-
}, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
|
|
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$)));
|
|
1932
1671
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
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;
|
|
1935
1683
|
}
|
|
1936
|
-
|
|
1937
|
-
|
|
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$;
|
|
1938
1753
|
}
|
|
1939
1754
|
}
|
|
1940
|
-
const
|
|
1941
|
-
const
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
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
|
+
}
|
|
1945
1772
|
}
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
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;
|
|
1958
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$);
|
|
1959
1810
|
}
|
|
1960
1811
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
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
|
+
};
|
|
1964
1827
|
}
|
|
1965
|
-
return container;
|
|
1966
|
-
}
|
|
1967
|
-
function _getQContainerElement(element) {
|
|
1968
|
-
return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
|
|
1969
1828
|
}
|
|
1970
|
-
const
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
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
|
-
|
|
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);
|
|
2005
1899
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
})(prototype, "nodeType");
|
|
2010
|
-
const attachVnodeDataAndRefs = element => {
|
|
2011
|
-
Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
|
|
2012
|
-
script.setAttribute("type", "x-qwik/vnode");
|
|
2013
|
-
const qContainerElement = script.closest("[q\\:container]");
|
|
2014
|
-
qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
|
|
2015
|
-
})), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
|
|
2016
|
-
const shadowRoot = parent.shadowRoot;
|
|
2017
|
-
shadowRoot && attachVnodeDataAndRefs(shadowRoot);
|
|
2018
|
-
}));
|
|
2019
|
-
};
|
|
2020
|
-
let NodeType;
|
|
2021
|
-
attachVnodeDataAndRefs(document), function(NodeType) {
|
|
2022
|
-
NodeType[NodeType.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType[NodeType.ELEMENT = 2] = "ELEMENT",
|
|
2023
|
-
NodeType[NodeType.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType[NodeType.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT",
|
|
2024
|
-
NodeType[NodeType.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType[NodeType.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END",
|
|
2025
|
-
NodeType[NodeType.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType[NodeType.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END",
|
|
2026
|
-
NodeType[NodeType.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType[NodeType.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END",
|
|
2027
|
-
NodeType[NodeType.OTHER = 0] = "OTHER";
|
|
2028
|
-
}(NodeType || (NodeType = {}));
|
|
2029
|
-
const getFastNodeType = node => {
|
|
2030
|
-
const nodeType = getNodeType.call(node);
|
|
2031
|
-
if (1 === nodeType) {
|
|
2032
|
-
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;
|
|
2033
|
-
}
|
|
2034
|
-
if (8 === nodeType) {
|
|
2035
|
-
const nodeValue = node.nodeValue || "";
|
|
2036
|
-
if (nodeValue.startsWith("q:container-island")) {
|
|
2037
|
-
return NodeType.COMMENT_ISLAND_START;
|
|
2038
|
-
}
|
|
2039
|
-
if (nodeValue.startsWith("q:ignore")) {
|
|
2040
|
-
return NodeType.COMMENT_IGNORE_START;
|
|
2041
|
-
}
|
|
2042
|
-
if (nodeValue.startsWith("q:container")) {
|
|
2043
|
-
return NodeType.COMMENT_SKIP_START;
|
|
2044
|
-
}
|
|
2045
|
-
if (nodeValue.startsWith("/q:container-island")) {
|
|
2046
|
-
return NodeType.COMMENT_ISLAND_END;
|
|
2047
|
-
}
|
|
2048
|
-
if (nodeValue.startsWith("/q:ignore")) {
|
|
2049
|
-
return NodeType.COMMENT_IGNORE_END;
|
|
2050
|
-
}
|
|
2051
|
-
if (nodeValue.startsWith("/q:container")) {
|
|
2052
|
-
return NodeType.COMMENT_SKIP_END;
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
return NodeType.OTHER;
|
|
2056
|
-
};
|
|
2057
|
-
const isSeparator = ch => VNodeDataSeparator_ADVANCE_1 <= ch && ch <= VNodeDataSeparator_ADVANCE_8192;
|
|
2058
|
-
const findVDataSectionEnd = (vData, start, end) => {
|
|
2059
|
-
let depth = 0;
|
|
2060
|
-
for (;start < end; ) {
|
|
2061
|
-
const ch = vData.charCodeAt(start);
|
|
2062
|
-
if (0 === depth && isSeparator(ch)) {
|
|
2063
|
-
break;
|
|
2064
|
-
}
|
|
2065
|
-
ch === VNodeDataChar_OPEN ? depth++ : ch === VNodeDataChar_CLOSE && depth--, start++;
|
|
2066
|
-
}
|
|
2067
|
-
return start;
|
|
2068
|
-
};
|
|
2069
|
-
const nextSibling = node => {
|
|
2070
|
-
for (;node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {}
|
|
2071
|
-
return node;
|
|
2072
|
-
};
|
|
2073
|
-
const firstChild = node => {
|
|
2074
|
-
for (;node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {}
|
|
2075
|
-
return node;
|
|
2076
|
-
};
|
|
2077
|
-
const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
|
|
2078
|
-
const vData_length = vData.length;
|
|
2079
|
-
let elementIdx = 0;
|
|
2080
|
-
let vNodeElementIndex = -1;
|
|
2081
|
-
let vData_start = 0;
|
|
2082
|
-
let vData_end = 0;
|
|
2083
|
-
let ch = 0;
|
|
2084
|
-
let needsToStoreRef = -1;
|
|
2085
|
-
let nextNode = null;
|
|
2086
|
-
const howManyElementsToSkip = () => {
|
|
2087
|
-
let elementsToSkip = 0;
|
|
2088
|
-
for (;isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator_ADVANCE_1,
|
|
2089
|
-
vData_start++, !(vData_start >= vData_length)); ) {}
|
|
2090
|
-
return elementsToSkip;
|
|
2091
|
-
};
|
|
2092
|
-
do {
|
|
2093
|
-
if (node === exitNode) {
|
|
2094
|
-
return;
|
|
2095
|
-
}
|
|
2096
|
-
nextNode = null;
|
|
2097
|
-
const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
|
|
2098
|
-
if (nodeType === NodeType.ELEMENT_CONTAINER) {
|
|
2099
|
-
const container = node;
|
|
2100
|
-
let cursor = node;
|
|
2101
|
-
for (;cursor && !(nextNode = nextSibling(cursor)); ) {
|
|
2102
|
-
cursor = cursor.parentNode;
|
|
2103
|
-
}
|
|
2104
|
-
walkContainer(walker, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
|
|
2105
|
-
} else if (nodeType === NodeType.COMMENT_IGNORE_START) {
|
|
2106
|
-
let islandNode = node;
|
|
2107
|
-
do {
|
|
2108
|
-
if (islandNode = walker.nextNode(), !islandNode) {
|
|
2109
|
-
throw new Error(`Island inside \x3c!--${node?.nodeValue}--\x3e not found!`);
|
|
2110
|
-
}
|
|
2111
|
-
} while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
|
|
2112
|
-
nextNode = null;
|
|
2113
|
-
} else if (nodeType === NodeType.COMMENT_ISLAND_END) {
|
|
2114
|
-
nextNode = node;
|
|
2115
|
-
do {
|
|
2116
|
-
if (nextNode = walker.nextNode(), !nextNode) {
|
|
2117
|
-
throw new Error("Ignore block not closed!");
|
|
2118
|
-
}
|
|
2119
|
-
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
|
|
2120
|
-
nextNode = null;
|
|
2121
|
-
} else if (nodeType === NodeType.COMMENT_SKIP_START) {
|
|
2122
|
-
nextNode = node;
|
|
2123
|
-
do {
|
|
2124
|
-
if (nextNode = nextSibling(nextNode), !nextNode) {
|
|
2125
|
-
throw new Error(`\x3c!--${node?.nodeValue}--\x3e not closed!`);
|
|
2126
|
-
}
|
|
2127
|
-
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
|
|
2128
|
-
walkContainer(walker, node, node, nextNode, "", null);
|
|
2129
|
-
} else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
|
|
2130
|
-
nextNode = nextSibling(node);
|
|
2131
|
-
const shadowRootContainer = node;
|
|
2132
|
-
const shadowRoot = shadowRootContainer?.shadowRoot;
|
|
2133
|
-
shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
|
|
2134
|
-
}
|
|
2135
|
-
if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
|
|
2136
|
-
if (vNodeElementIndex < elementIdx && (-1 === vNodeElementIndex && (vNodeElementIndex = 0),
|
|
2137
|
-
vData_start = vData_end, vData_start < vData_length ? (vNodeElementIndex += howManyElementsToSkip(),
|
|
2138
|
-
ch === VNodeDataSeparator_REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++,
|
|
2139
|
-
ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator_ADVANCE_1),
|
|
2140
|
-
vData_end = findVDataSectionEnd(vData, vData_start, vData_length)) : vNodeElementIndex = Number.MAX_SAFE_INTEGER),
|
|
2141
|
-
elementIdx === vNodeElementIndex) {
|
|
2142
|
-
needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
|
|
2143
|
-
const instructions = vData.substring(vData_start, vData_end);
|
|
2144
|
-
vNodeDataMap.set(node, instructions);
|
|
2145
|
-
}
|
|
2146
|
-
elementIdx++;
|
|
2147
|
-
}
|
|
2148
|
-
} while (node = nextNode || walker.nextNode());
|
|
2149
|
-
};
|
|
2150
|
-
const walker = document.createTreeWalker(document, 129);
|
|
2151
|
-
walkContainer(walker, null, walker.firstChild(), null, "", null);
|
|
2152
|
-
}(document), this.$rawStateData$ = [], this.stateData = [];
|
|
2153
|
-
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
2154
|
-
if (0 !== qwikStates.length) {
|
|
2155
|
-
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
|
|
2156
|
-
this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
|
|
2157
|
-
}
|
|
2158
|
-
this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
|
|
2159
|
-
}
|
|
2160
|
-
$setRawState$(id, vParent) {
|
|
2161
|
-
this.stateData[id] = vParent;
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
effects.forEach(scheduleEffect);
|
|
2162
1903
|
}
|
|
2163
|
-
|
|
2164
|
-
|
|
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;
|
|
2165
1911
|
}
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
return vnode_diff(this, jsx, host, addComponentStylePrefix(styleScopedId));
|
|
1912
|
+
$invalidate$() {
|
|
1913
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
|
|
2169
1914
|
}
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
if (!errorStore) {
|
|
2173
|
-
throw err;
|
|
2174
|
-
}
|
|
2175
|
-
errorStore.error = err;
|
|
1915
|
+
force() {
|
|
1916
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
|
|
2176
1917
|
}
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
1918
|
+
get untrackedValue() {
|
|
1919
|
+
const didChange = this.$computeIfNeeded$();
|
|
1920
|
+
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
|
|
2180
1921
|
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
if (ctx) {
|
|
2185
|
-
const value = mapArray_get(ctx, contextId.id, 0);
|
|
2186
|
-
if (value) {
|
|
2187
|
-
return value;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
host = this.getParentHost(host);
|
|
1922
|
+
$computeIfNeeded$() {
|
|
1923
|
+
if (!this.$invalid$) {
|
|
1924
|
+
return !1;
|
|
2191
1925
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
if (parent) {
|
|
2202
|
-
vNode = parent;
|
|
2203
|
-
continue;
|
|
2204
|
-
}
|
|
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$ ]);
|
|
2205
1935
|
}
|
|
2206
|
-
|
|
1936
|
+
this.$invalid$ = !1;
|
|
1937
|
+
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1938
|
+
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
1939
|
+
} finally {
|
|
1940
|
+
ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
|
|
2207
1941
|
}
|
|
2208
|
-
return null;
|
|
2209
1942
|
}
|
|
2210
|
-
|
|
2211
|
-
|
|
1943
|
+
get value() {
|
|
1944
|
+
return super.value;
|
|
2212
1945
|
}
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
let getObjectById = null;
|
|
2216
|
-
switch (name) {
|
|
2217
|
-
case "q:seq":
|
|
2218
|
-
case "q:props":
|
|
2219
|
-
case "q:renderFn":
|
|
2220
|
-
case "q:ctx":
|
|
2221
|
-
case "q:subs":
|
|
2222
|
-
getObjectById = this.$getObjectById$;
|
|
2223
|
-
break;
|
|
2224
|
-
|
|
2225
|
-
case "q:seqIdx":
|
|
2226
|
-
case ":onIdx":
|
|
2227
|
-
getObjectById = parseInt;
|
|
2228
|
-
}
|
|
2229
|
-
return vnode_getProp(vNode, name, getObjectById);
|
|
1946
|
+
set value(_) {
|
|
1947
|
+
throw qError(QError.computedReadOnly);
|
|
2230
1948
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
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;
|
|
2234
1960
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
2238
|
-
if (isPromise(result)) {
|
|
2239
|
-
return result.then((async () => {
|
|
2240
|
-
for (;renderCount !== this.$renderCount$; ) {
|
|
2241
|
-
renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
2242
|
-
}
|
|
2243
|
-
this.renderDone = null;
|
|
2244
|
-
}));
|
|
2245
|
-
}
|
|
2246
|
-
renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
|
|
2247
|
-
}
|
|
2248
|
-
ensureProjectionResolved(vNode) {
|
|
2249
|
-
if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
|
|
2250
|
-
vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
|
|
2251
|
-
for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
|
|
2252
|
-
if (isSlotProp(vNode[i])) {
|
|
2253
|
-
const value = vNode[i + 1];
|
|
2254
|
-
"string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
1961
|
+
$invalidate$() {
|
|
1962
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
|
|
2258
1963
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
getSyncFn(id) {
|
|
2262
|
-
const fn = this.$qFuncs$[id];
|
|
2263
|
-
return assertTrue(), fn;
|
|
1964
|
+
force() {
|
|
1965
|
+
this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
|
|
2264
1966
|
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
const scopedStyleIds = new Set(function(scopedStyleIds) {
|
|
2269
|
-
return scopedStyleIds?.split(" ") ?? null;
|
|
2270
|
-
}(scopedStyleIdsString));
|
|
2271
|
-
scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", function(scopedStyleIds) {
|
|
2272
|
-
return Array.from(scopedStyleIds).join(" ");
|
|
2273
|
-
}(scopedStyleIds));
|
|
2274
|
-
}
|
|
2275
|
-
if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach((style => {
|
|
2276
|
-
this.$styleIds$.add(style.getAttribute("q:style"));
|
|
2277
|
-
}))), !this.$styleIds$.has(styleId)) {
|
|
2278
|
-
this.$styleIds$.add(styleId);
|
|
2279
|
-
const styleElement = this.document.createElement("style");
|
|
2280
|
-
styleElement.setAttribute("q:style", styleId), styleElement.textContent = content,
|
|
2281
|
-
this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
|
|
2282
|
-
}
|
|
1967
|
+
get untrackedValue() {
|
|
1968
|
+
const didChange = this.$computeIfNeeded$();
|
|
1969
|
+
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
|
|
2283
1970
|
}
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
if (!_context) {
|
|
2288
|
-
const context = "undefined" != typeof document && document && document.__q_context__;
|
|
2289
|
-
if (!context) {
|
|
2290
|
-
return;
|
|
1971
|
+
$computeIfNeeded$() {
|
|
1972
|
+
if (!this.$invalid$) {
|
|
1973
|
+
return !1;
|
|
2291
1974
|
}
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
};
|
|
2296
|
-
const getInvokeContext = () => {
|
|
2297
|
-
const ctx = tryGetInvokeContext();
|
|
2298
|
-
if (!ctx) {
|
|
2299
|
-
throw qError(14);
|
|
2300
|
-
}
|
|
2301
|
-
return ctx;
|
|
2302
|
-
};
|
|
2303
|
-
const useInvokeContext = () => {
|
|
2304
|
-
const ctx = tryGetInvokeContext();
|
|
2305
|
-
if (!ctx || "qRender" !== ctx.$event$) {
|
|
2306
|
-
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;
|
|
2307
1978
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
function useBindInvokeContext(fn) {
|
|
2311
|
-
if (null == fn) {
|
|
2312
|
-
return fn;
|
|
1979
|
+
get value() {
|
|
1980
|
+
return super.value;
|
|
2313
1981
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
return invokeApply.call(this, ctx, fn, args);
|
|
2317
|
-
};
|
|
2318
|
-
}
|
|
2319
|
-
function invoke(context, fn, ...args) {
|
|
2320
|
-
return invokeApply.call(this, context, fn, args);
|
|
2321
|
-
}
|
|
2322
|
-
function invokeApply(context, fn, args) {
|
|
2323
|
-
const previousContext = _context;
|
|
2324
|
-
let returnValue;
|
|
2325
|
-
try {
|
|
2326
|
-
_context = context, returnValue = fn.apply(this, args);
|
|
2327
|
-
} finally {
|
|
2328
|
-
_context = previousContext;
|
|
1982
|
+
set value(_) {
|
|
1983
|
+
throw qError(QError.wrappedReadOnly);
|
|
2329
1984
|
}
|
|
2330
|
-
return returnValue;
|
|
2331
1985
|
}
|
|
2332
|
-
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
2333
|
-
const container = element.closest(QContainerSelector);
|
|
2334
|
-
const locale = container?.getAttribute("q:locale") || void 0;
|
|
2335
|
-
return locale && function(locale) {
|
|
2336
|
-
_locale = locale;
|
|
2337
|
-
}(locale), newInvokeContext(locale, void 0, element, event, url);
|
|
2338
|
-
};
|
|
2339
|
-
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
2340
|
-
const ctx = {
|
|
2341
|
-
$url$: url,
|
|
2342
|
-
$i$: 0,
|
|
2343
|
-
$hostElement$: hostElement,
|
|
2344
|
-
$element$: element,
|
|
2345
|
-
$event$: event,
|
|
2346
|
-
$qrl$: void 0,
|
|
2347
|
-
$effectSubscriber$: void 0,
|
|
2348
|
-
$locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
|
|
2349
|
-
$container$: void 0
|
|
2350
|
-
};
|
|
2351
|
-
return seal(), ctx;
|
|
2352
|
-
};
|
|
2353
|
-
const untrack = fn => invoke(void 0, fn);
|
|
2354
|
-
const trackInvocation = /*#__PURE__*/ newInvokeContext(void 0, void 0, void 0, "qRender");
|
|
2355
|
-
const trackSignal = (fn, subscriber, property, container, data) => {
|
|
2356
|
-
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
2357
|
-
const previousContainer = trackInvocation.$container$;
|
|
2358
|
-
try {
|
|
2359
|
-
return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
|
|
2360
|
-
trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
2361
|
-
} finally {
|
|
2362
|
-
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
2363
|
-
}
|
|
2364
|
-
};
|
|
2365
1986
|
class ParentComponentData {
|
|
2366
1987
|
$scopedStyle$;
|
|
2367
1988
|
$componentFrame$;
|
|
@@ -2392,11 +2013,17 @@
|
|
|
2392
2013
|
});
|
|
2393
2014
|
} else {
|
|
2394
2015
|
if (value === Promise) {
|
|
2395
|
-
|
|
2016
|
+
if (!options.allowPromises) {
|
|
2017
|
+
throw qError(QError.promisesNotExpected);
|
|
2018
|
+
}
|
|
2019
|
+
return void stack.pop().then(resolveValue, rejectDrain);
|
|
2396
2020
|
}
|
|
2397
2021
|
const waitOn = value.apply(ssr);
|
|
2398
2022
|
if (waitOn) {
|
|
2399
|
-
|
|
2023
|
+
if (!options.allowPromises) {
|
|
2024
|
+
throw qError(QError.promisesNotExpected);
|
|
2025
|
+
}
|
|
2026
|
+
return void waitOn.then(drain, rejectDrain);
|
|
2400
2027
|
}
|
|
2401
2028
|
}
|
|
2402
2029
|
}
|
|
@@ -2421,7 +2048,7 @@
|
|
|
2421
2048
|
} else if (isSignal(value)) {
|
|
2422
2049
|
ssr.openFragment(build.isDev ? [ "q:type", VirtualType.WrappedSignal ] : EMPTY_ARRAY);
|
|
2423
2050
|
const signalNode = ssr.getLastNode();
|
|
2424
|
-
enqueue(ssr.closeFragment), enqueue(
|
|
2051
|
+
enqueue(ssr.closeFragment), enqueue(trackSignalAndAssignHost(value, signalNode, EffectProperty.VNODE, ssr));
|
|
2425
2052
|
} else if (isPromise(value)) {
|
|
2426
2053
|
ssr.openFragment(build.isDev ? [ "q:type", VirtualType.Awaited ] : EMPTY_ARRAY),
|
|
2427
2054
|
enqueue(ssr.closeFragment), enqueue(value), enqueue(Promise), enqueue((() => ssr.commentNode("qkssr-f")));
|
|
@@ -2480,7 +2107,7 @@
|
|
|
2480
2107
|
if (constProps && "object" == typeof constProps && "name" in constProps) {
|
|
2481
2108
|
const constValue = constProps.name;
|
|
2482
2109
|
if (constValue instanceof WrappedSignal) {
|
|
2483
|
-
return
|
|
2110
|
+
return trackSignalAndAssignHost(constValue, host, EffectProperty.COMPONENT, ssr);
|
|
2484
2111
|
}
|
|
2485
2112
|
}
|
|
2486
2113
|
return directGetPropsProxyProp(jsx, "name") || "";
|
|
@@ -2614,6 +2241,29 @@
|
|
|
2614
2241
|
const eventName = key.substring(15);
|
|
2615
2242
|
eventName && serializationCtx.$eventNames$.add(eventName);
|
|
2616
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
|
+
}
|
|
2617
2267
|
const _CONST_PROPS = Symbol("CONST");
|
|
2618
2268
|
const _VAR_PROPS = Symbol("VAR");
|
|
2619
2269
|
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
@@ -2820,6 +2470,8 @@
|
|
|
2820
2470
|
}
|
|
2821
2471
|
return String(value);
|
|
2822
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;
|
|
2823
2475
|
var VNodeJournalOpCode;
|
|
2824
2476
|
!function(VNodeJournalOpCode) {
|
|
2825
2477
|
VNodeJournalOpCode[VNodeJournalOpCode.SetText = 1] = "SetText", VNodeJournalOpCode[VNodeJournalOpCode.SetAttribute = 2] = "SetAttribute",
|
|
@@ -2838,12 +2490,6 @@
|
|
|
2838
2490
|
return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)),
|
|
2839
2491
|
assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2840
2492
|
};
|
|
2841
|
-
const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
|
|
2842
|
-
sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
|
|
2843
|
-
const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
|
|
2844
|
-
return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)),
|
|
2845
|
-
assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2846
|
-
};
|
|
2847
2493
|
const vnode_newText = (textNode, textContent) => {
|
|
2848
2494
|
const vnode = VNodeArray.createText(VNodeFlags.Text | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, textNode, textContent);
|
|
2849
2495
|
return assertEqual(fastNodeType(textNode)), assertFalse(vnode_isElementVNode(vnode)),
|
|
@@ -3286,107 +2932,118 @@
|
|
|
3286
2932
|
let vFirstChild = vnode[ElementVNodeProps.firstChild];
|
|
3287
2933
|
return void 0 === vFirstChild && (vFirstChild = ensureMaterialized(vnode)), vFirstChild;
|
|
3288
2934
|
};
|
|
3289
|
-
const
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
let vFirst = null;
|
|
3297
|
-
let vLast = null;
|
|
3298
|
-
let previousTextNode = null;
|
|
3299
|
-
let ch = 0;
|
|
3300
|
-
let peekCh = 0;
|
|
3301
|
-
const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
|
|
3302
|
-
const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
|
|
3303
|
-
const addVNode = node => {
|
|
3304
|
-
node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift,
|
|
3305
|
-
idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast,
|
|
3306
|
-
node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node),
|
|
3307
|
-
vLast = node;
|
|
3308
|
-
};
|
|
3309
|
-
const consumeValue = () => {
|
|
3310
|
-
consume();
|
|
3311
|
-
const start = nextToConsumeIdx;
|
|
3312
|
-
for (;peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
|
|
3313
|
-
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++;
|
|
3314
2942
|
}
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
for (;0 !== peek(); ) {
|
|
3321
|
-
if (isNumber(peek())) {
|
|
3322
|
-
for (;!isElement(child); ) {
|
|
3323
|
-
(child = fastNextSibling(child)) || throwErrorAndStop("Materialize error: missing element: " + vData + " " + peek() + " " + nextToConsumeIdx);
|
|
3324
|
-
}
|
|
3325
|
-
for (;isQStyleElement(child); ) {
|
|
3326
|
-
child = fastNextSibling(child);
|
|
3327
|
-
}
|
|
3328
|
-
combinedText = null, previousTextNode = null;
|
|
3329
|
-
let value = 0;
|
|
3330
|
-
for (;isNumber(peek()); ) {
|
|
3331
|
-
value *= 10, value += consume() - 48;
|
|
3332
|
-
}
|
|
3333
|
-
for (;value--; ) {
|
|
3334
|
-
addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
|
|
3335
|
-
}
|
|
3336
|
-
} else if (peek() === VNodeDataChar_SCOPED_STYLE) {
|
|
3337
|
-
vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
|
|
3338
|
-
} else if (peek() === VNodeDataChar_RENDER_FN) {
|
|
3339
|
-
vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
|
|
3340
|
-
} else if (peek() === VNodeDataChar_ID) {
|
|
3341
|
-
container || (container = getDomContainer(element));
|
|
3342
|
-
const id = consumeValue();
|
|
3343
|
-
container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
|
|
3344
|
-
} else if (peek() === VNodeDataChar_PROPS) {
|
|
3345
|
-
vnode_setAttr(null, vParent, "q:props", consumeValue());
|
|
3346
|
-
} else if (peek() === VNodeDataChar_SLOT_REF) {
|
|
3347
|
-
vnode_setAttr(null, vParent, "q:sref", consumeValue());
|
|
3348
|
-
} else if (peek() === VNodeDataChar_KEY) {
|
|
3349
|
-
vnode_setAttr(null, vParent, "q:key", consumeValue());
|
|
3350
|
-
} else if (peek() === VNodeDataChar_SEQ) {
|
|
3351
|
-
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
3352
|
-
} else if (peek() === VNodeDataChar_SEQ_IDX) {
|
|
3353
|
-
vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
|
|
3354
|
-
} else if (peek() === VNodeDataChar_CONTEXT) {
|
|
3355
|
-
vnode_setAttr(null, vParent, "q:ctx", consumeValue());
|
|
3356
|
-
} else if (peek() === VNodeDataChar_OPEN) {
|
|
3357
|
-
consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx),
|
|
3358
|
-
idx = 0, vParent = vLast, vFirst = vLast = null;
|
|
3359
|
-
} else if (peek() === VNodeDataChar_SEPARATOR) {
|
|
3360
|
-
const key = consumeValue();
|
|
3361
|
-
const value = consumeValue();
|
|
3362
|
-
vnode_setAttr(null, vParent, key, value);
|
|
3363
|
-
} else if (peek() === VNodeDataChar_CLOSE) {
|
|
3364
|
-
consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(),
|
|
3365
|
-
vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
|
|
3366
|
-
} else if (peek() === VNodeDataChar_SLOT) {
|
|
3367
|
-
vnode_setAttr(null, vParent, QSlot, consumeValue());
|
|
3368
|
-
} else {
|
|
3369
|
-
const textNode = child && 3 === fastNodeType(child) ? child : null;
|
|
3370
|
-
null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
|
|
3371
|
-
let length = 0;
|
|
3372
|
-
for (;isLowercase(peek()); ) {
|
|
3373
|
-
length += consume() - 97, length *= 26;
|
|
3374
|
-
}
|
|
3375
|
-
length += consume() - 65;
|
|
3376
|
-
const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
|
|
3377
|
-
addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)),
|
|
3378
|
-
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;
|
|
3379
2948
|
}
|
|
3380
2949
|
}
|
|
3381
|
-
return vParent
|
|
3382
|
-
|
|
3383
|
-
|
|
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);
|
|
3384
3036
|
};
|
|
3385
3037
|
const ensureMaterialized = vnode => {
|
|
3386
3038
|
const vParent = ensureElementVNode(vnode);
|
|
3387
3039
|
let vFirstChild = vParent[ElementVNodeProps.firstChild];
|
|
3388
3040
|
if (void 0 === vFirstChild) {
|
|
3389
|
-
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);
|
|
3390
3047
|
}
|
|
3391
3048
|
return assertTrue(), assertTrue(), vFirstChild;
|
|
3392
3049
|
};
|
|
@@ -3455,7 +3112,7 @@
|
|
|
3455
3112
|
};
|
|
3456
3113
|
};
|
|
3457
3114
|
const isQStyleElement = node => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute("q:sstyle") || node.hasAttribute("q:style"));
|
|
3458
|
-
const materializeFromDOM = (vParent, firstChild) => {
|
|
3115
|
+
const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
3459
3116
|
let vFirstChild = null;
|
|
3460
3117
|
const skipStyleElements = () => {
|
|
3461
3118
|
for (;isQStyleElement(child); ) {
|
|
@@ -3473,8 +3130,38 @@
|
|
|
3473
3130
|
vNextChild[VNodeProps.previousSibling] = vChild, vChild = vNextChild), vFirstChild || (vParent[ElementVNodeProps.firstChild] = vFirstChild = vChild),
|
|
3474
3131
|
child = fastNextSibling(child), skipStyleElements();
|
|
3475
3132
|
}
|
|
3476
|
-
|
|
3477
|
-
|
|
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
|
+
}
|
|
3478
3165
|
};
|
|
3479
3166
|
const vnode_getNextSibling = vnode => vnode[VNodeProps.nextSibling];
|
|
3480
3167
|
const vnode_getAttrKeys = vnode => {
|
|
@@ -3529,164 +3216,588 @@
|
|
|
3529
3216
|
if (type === VNodeFlags.Element) {
|
|
3530
3217
|
return ElementVNodeProps.PROPS_OFFSET;
|
|
3531
3218
|
}
|
|
3532
|
-
if (type === VNodeFlags.Virtual) {
|
|
3533
|
-
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;
|
|
3534
3682
|
}
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
|
|
3538
|
-
const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)),
|
|
3539
|
-
vnode[TextVNodeProps.node]);
|
|
3540
|
-
function vnode_toString(depth = 10, offset = "", materialize = !1, siblings = !1) {
|
|
3541
|
-
let vnode = this;
|
|
3542
|
-
if (0 === depth) {
|
|
3543
|
-
return "...";
|
|
3683
|
+
parseQRL(qrl) {
|
|
3684
|
+
return inflateQRL(this, parseQRL(qrl));
|
|
3544
3685
|
}
|
|
3545
|
-
|
|
3546
|
-
|
|
3686
|
+
handleError(err, host) {
|
|
3687
|
+
const errorStore = this.resolveContext(host, ERROR_CONTEXT);
|
|
3688
|
+
if (!errorStore) {
|
|
3689
|
+
throw err;
|
|
3690
|
+
}
|
|
3691
|
+
errorStore.error = err;
|
|
3547
3692
|
}
|
|
3548
|
-
|
|
3549
|
-
|
|
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);
|
|
3550
3696
|
}
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
if ("q:type" !== key) {
|
|
3559
|
-
const value = vnode_getAttr(vnode, key);
|
|
3560
|
-
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;
|
|
3561
3704
|
}
|
|
3562
|
-
}));
|
|
3563
|
-
const name = VirtualTypeName[vnode_getAttr(vnode, "q:type") || VirtualType.Virtual] || VirtualTypeName[VirtualType.Virtual];
|
|
3564
|
-
strings.push("<" + name + attrs.join("") + ">");
|
|
3565
|
-
const child = vnode_getFirstChild(vnode);
|
|
3566
|
-
child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", !0, !0)),
|
|
3567
|
-
strings.push("</" + name + ">");
|
|
3568
|
-
} else if (vnode_isElementVNode(vnode)) {
|
|
3569
|
-
const tag = vnode_getElementName(vnode);
|
|
3570
|
-
const attrs = [];
|
|
3571
|
-
const keys = vnode_getAttrKeys(vnode);
|
|
3572
|
-
keys.forEach((key => {
|
|
3573
|
-
const value = vnode_getAttr(vnode, key);
|
|
3574
|
-
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
3575
|
-
}));
|
|
3576
|
-
const node = vnode_getNode(vnode);
|
|
3577
|
-
if (node) {
|
|
3578
|
-
const vnodeData = node.ownerDocument.qVNodeData?.get(node);
|
|
3579
|
-
vnodeData && attrs.push(" q:vnodeData=" + qwikDebugToString(vnodeData));
|
|
3580
3705
|
}
|
|
3581
|
-
|
|
3582
|
-
for (let i = 0; i < domAttrs.length; i++) {
|
|
3583
|
-
const attr = domAttrs[i];
|
|
3584
|
-
-1 === keys.indexOf(attr.name) && attrs.push(" " + attr.name + (attr.value ? "=" + qwikDebugToString(attr.value) : ""));
|
|
3585
|
-
}
|
|
3586
|
-
if (strings.push("<" + tag + attrs.join("") + ">"), vnode_isMaterialized(vnode) || materialize) {
|
|
3587
|
-
const child = vnode_getFirstChild(vnode);
|
|
3588
|
-
child && strings.push(" " + vnode_toString.call(child, depth - 1, offset + " ", !0, !0));
|
|
3589
|
-
} else {
|
|
3590
|
-
strings.push(" \x3c!-- not materialized --!>");
|
|
3591
|
-
}
|
|
3592
|
-
strings.push("</" + tag + ">");
|
|
3706
|
+
host = this.getParentHost(host);
|
|
3593
3707
|
}
|
|
3594
|
-
vnode = siblings && vnode_getNextSibling(vnode) || null;
|
|
3595
|
-
} while (vnode);
|
|
3596
|
-
return strings.join("\n" + offset);
|
|
3597
|
-
}
|
|
3598
|
-
const isNumber = ch => 48 <= ch && ch <= 57;
|
|
3599
|
-
const isLowercase = ch => 97 <= ch && ch <= 122;
|
|
3600
|
-
const stack = [];
|
|
3601
|
-
const vnode_getType = vnode => {
|
|
3602
|
-
const type = vnode[VNodeProps.flags];
|
|
3603
|
-
if (type & VNodeFlags.Element) {
|
|
3604
|
-
return 1;
|
|
3605
3708
|
}
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
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;
|
|
3611
3725
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
const isElement = node => node && "object" == typeof node && 1 === fastNodeType(node);
|
|
3615
|
-
const aPath = [];
|
|
3616
|
-
const bPath = [];
|
|
3617
|
-
const vnode_documentPosition = (a, b) => {
|
|
3618
|
-
if (a === b) {
|
|
3619
|
-
return 0;
|
|
3726
|
+
setHostProp(host, name, value) {
|
|
3727
|
+
vnode_setProp(host, name, value);
|
|
3620
3728
|
}
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
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);
|
|
3625
3746
|
}
|
|
3626
|
-
|
|
3627
|
-
|
|
3747
|
+
scheduleRender() {
|
|
3748
|
+
return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
|
|
3749
|
+
this.renderDone;
|
|
3628
3750
|
}
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
} while (cursor);
|
|
3637
|
-
cursor = b;
|
|
3638
|
-
do {
|
|
3639
|
-
if (cursor = cursor[VNodeProps.previousSibling], cursor === a) {
|
|
3640
|
-
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);
|
|
3641
3758
|
}
|
|
3642
|
-
|
|
3643
|
-
|
|
3759
|
+
this.renderDone = null;
|
|
3760
|
+
}));
|
|
3644
3761
|
}
|
|
3645
|
-
|
|
3762
|
+
renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
|
|
3646
3763
|
}
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
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
|
+
}
|
|
3657
3773
|
}
|
|
3658
|
-
projectionDepth > 0 && (vHost = vnode_getParent(vHost));
|
|
3659
|
-
}
|
|
3660
|
-
return vHost;
|
|
3661
|
-
};
|
|
3662
|
-
const VNodeArray = class VNode extends Array {
|
|
3663
|
-
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
3664
|
-
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3665
|
-
return vnode.push(firstChild, lastChild, element, elementName), vnode;
|
|
3666
|
-
}
|
|
3667
|
-
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
3668
|
-
const vnode = new VNode(flags, parent, previousSibling, nextSibling);
|
|
3669
|
-
return vnode.push(textNode, text), vnode;
|
|
3670
3774
|
}
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
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;
|
|
3674
3780
|
}
|
|
3675
|
-
|
|
3676
|
-
|
|
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
|
+
}
|
|
3677
3799
|
}
|
|
3678
|
-
}
|
|
3679
|
-
var ExperimentalFeatures;
|
|
3680
|
-
var VNodeDataFlag;
|
|
3681
|
-
!function(ExperimentalFeatures) {
|
|
3682
|
-
ExperimentalFeatures.preventNavigate = "preventNavigate", ExperimentalFeatures.valibot = "valibot",
|
|
3683
|
-
ExperimentalFeatures.noSPA = "noSPA", ExperimentalFeatures.webWorker = "webWorker",
|
|
3684
|
-
ExperimentalFeatures.insights = "insights";
|
|
3685
|
-
}(ExperimentalFeatures || (ExperimentalFeatures = {})), function(VNodeDataFlag) {
|
|
3686
|
-
VNodeDataFlag[VNodeDataFlag.NONE = 0] = "NONE", VNodeDataFlag[VNodeDataFlag.TEXT_DATA = 1] = "TEXT_DATA",
|
|
3687
|
-
VNodeDataFlag[VNodeDataFlag.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag[VNodeDataFlag.REFERENCE = 4] = "REFERENCE",
|
|
3688
|
-
VNodeDataFlag[VNodeDataFlag.SERIALIZE = 8] = "SERIALIZE";
|
|
3689
|
-
}(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
3800
|
+
}
|
|
3690
3801
|
const deserializedProxyMap = new WeakMap;
|
|
3691
3802
|
const unwrapDeserializerProxy = value => {
|
|
3692
3803
|
const unwrapped = "object" == typeof value && null !== value && value[SERIALIZER_PROXY_UNWRAP];
|
|
@@ -3763,7 +3874,10 @@
|
|
|
3763
3874
|
const valType = data[i + 2];
|
|
3764
3875
|
const valData = data[i + 3];
|
|
3765
3876
|
valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
|
|
3766
|
-
get
|
|
3877
|
+
get() {
|
|
3878
|
+
const value = deserializeData(container, valType, valData);
|
|
3879
|
+
return target[key] = value, value;
|
|
3880
|
+
},
|
|
3767
3881
|
set(value) {
|
|
3768
3882
|
Object.defineProperty(target, key, {
|
|
3769
3883
|
value,
|
|
@@ -3824,7 +3938,7 @@
|
|
|
3824
3938
|
const signal = target;
|
|
3825
3939
|
const d = data;
|
|
3826
3940
|
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
|
|
3827
|
-
signal.$untrackedValue$ = d[3], signal.$effects$ = d.slice(
|
|
3941
|
+
signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
|
|
3828
3942
|
break;
|
|
3829
3943
|
}
|
|
3830
3944
|
|
|
@@ -3916,11 +4030,14 @@
|
|
|
3916
4030
|
break;
|
|
3917
4031
|
|
|
3918
4032
|
case TypeIds.EffectData:
|
|
3919
|
-
|
|
3920
|
-
|
|
4033
|
+
{
|
|
4034
|
+
const effectData = target;
|
|
4035
|
+
effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
|
|
4036
|
+
break;
|
|
4037
|
+
}
|
|
3921
4038
|
|
|
3922
4039
|
default:
|
|
3923
|
-
|
|
4040
|
+
throw qError(QError.serializeErrorNotImplemented, [ typeId ]);
|
|
3924
4041
|
}
|
|
3925
4042
|
}
|
|
3926
4043
|
};
|
|
@@ -4032,13 +4149,16 @@
|
|
|
4032
4149
|
return vnodeOrDocument;
|
|
4033
4150
|
}
|
|
4034
4151
|
const vNode = retrieveVNodeOrDocument(container, value);
|
|
4035
|
-
|
|
4152
|
+
if (vnode_isVNode(vNode)) {
|
|
4153
|
+
return vnode_getNode(vNode);
|
|
4154
|
+
}
|
|
4155
|
+
throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
|
|
4036
4156
|
|
|
4037
4157
|
case TypeIds.EffectData:
|
|
4038
|
-
return new
|
|
4158
|
+
return new EffectPropData({});
|
|
4039
4159
|
|
|
4040
4160
|
default:
|
|
4041
|
-
|
|
4161
|
+
throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
|
|
4042
4162
|
}
|
|
4043
4163
|
};
|
|
4044
4164
|
function retrieveVNodeOrDocument(container, value) {
|
|
@@ -4063,6 +4183,7 @@
|
|
|
4063
4183
|
return qrl.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null,
|
|
4064
4184
|
container.element && qrl.$setContainer$(container.element), qrl;
|
|
4065
4185
|
}
|
|
4186
|
+
let isDomRef = () => !1;
|
|
4066
4187
|
const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
|
|
4067
4188
|
if (!writer) {
|
|
4068
4189
|
const buffer = [];
|
|
@@ -4083,8 +4204,8 @@
|
|
|
4083
4204
|
roots.push(obj)), id;
|
|
4084
4205
|
};
|
|
4085
4206
|
const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
|
|
4086
|
-
|
|
4087
|
-
|
|
4207
|
+
return isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1,
|
|
4208
|
+
{
|
|
4088
4209
|
$serialize$() {
|
|
4089
4210
|
!function(serializationContext) {
|
|
4090
4211
|
const {$writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$} = serializationContext;
|
|
@@ -4146,8 +4267,13 @@
|
|
|
4146
4267
|
const seen = depth > 1 && serializationContext.$wasSeen$(value);
|
|
4147
4268
|
"number" == typeof seen && seen >= 0 ? output(TypeIds.RootRef, seen) : output(TypeIds.String, value);
|
|
4148
4269
|
}
|
|
4270
|
+
} else if (void 0 === value) {
|
|
4271
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
4149
4272
|
} else {
|
|
4150
|
-
|
|
4273
|
+
if (value !== NEEDS_COMPUTATION) {
|
|
4274
|
+
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
4275
|
+
}
|
|
4276
|
+
output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
|
|
4151
4277
|
}
|
|
4152
4278
|
};
|
|
4153
4279
|
const writeObjectValue = (value, idx) => {
|
|
@@ -4163,8 +4289,8 @@
|
|
|
4163
4289
|
const constProps = value[_CONST_PROPS];
|
|
4164
4290
|
const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
|
|
4165
4291
|
output(TypeIds.PropsProxy, out);
|
|
4166
|
-
} else if (value instanceof
|
|
4167
|
-
output(TypeIds.EffectData, [ value.data ]);
|
|
4292
|
+
} else if (value instanceof EffectPropData) {
|
|
4293
|
+
output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
|
|
4168
4294
|
} else if (isStore(value)) {
|
|
4169
4295
|
if (function(value) {
|
|
4170
4296
|
return "__brand" in value && "resource" === value.__brand;
|
|
@@ -4172,7 +4298,7 @@
|
|
|
4172
4298
|
serializationContext.$resources$.add(value);
|
|
4173
4299
|
const res = promiseResults.get(value.value);
|
|
4174
4300
|
if (!res) {
|
|
4175
|
-
|
|
4301
|
+
throw qError(QError.serializeErrorUnvisited, [ "resource" ]);
|
|
4176
4302
|
}
|
|
4177
4303
|
output(TypeIds.Resource, [ ...res, getStoreHandler(value).$effects$ ]);
|
|
4178
4304
|
} else {
|
|
@@ -4206,11 +4332,11 @@
|
|
|
4206
4332
|
output(TypeIds.Object, out);
|
|
4207
4333
|
}
|
|
4208
4334
|
} else if ($isDomRef$(value)) {
|
|
4209
|
-
output(TypeIds.RefVNode, value
|
|
4335
|
+
value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE, output(TypeIds.RefVNode, value.$ssrNode$.id);
|
|
4210
4336
|
} else if (value instanceof Signal) {
|
|
4211
4337
|
const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
4212
4338
|
if (value instanceof WrappedSignal) {
|
|
4213
|
-
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$ || [] ]);
|
|
4214
4340
|
} else if (value instanceof ComputedSignal) {
|
|
4215
4341
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
4216
4342
|
v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
|
|
@@ -4266,12 +4392,12 @@
|
|
|
4266
4392
|
} else if (isPromise(value)) {
|
|
4267
4393
|
const res = promiseResults.get(value);
|
|
4268
4394
|
if (!res) {
|
|
4269
|
-
|
|
4395
|
+
throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
|
|
4270
4396
|
}
|
|
4271
4397
|
output(TypeIds.Promise, res);
|
|
4272
4398
|
} else {
|
|
4273
4399
|
if (!(value instanceof Uint8Array)) {
|
|
4274
|
-
|
|
4400
|
+
throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
|
|
4275
4401
|
}
|
|
4276
4402
|
{
|
|
4277
4403
|
let buf = "";
|
|
@@ -4299,7 +4425,10 @@
|
|
|
4299
4425
|
$addRoot$,
|
|
4300
4426
|
$getRootId$: obj => {
|
|
4301
4427
|
const id = map.get(obj);
|
|
4302
|
-
|
|
4428
|
+
if (!id || -1 === id) {
|
|
4429
|
+
throw qError(QError.serializeErrorMissingRootId, [ obj ]);
|
|
4430
|
+
}
|
|
4431
|
+
return id;
|
|
4303
4432
|
},
|
|
4304
4433
|
$syncFns$: syncFns,
|
|
4305
4434
|
$addSyncFn$: (funcStr, argCount, fn) => {
|
|
@@ -4351,13 +4480,17 @@
|
|
|
4351
4480
|
const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
|
|
4352
4481
|
v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$),
|
|
4353
4482
|
obj instanceof WrappedSignal ? (obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$),
|
|
4354
|
-
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$);
|
|
4355
4484
|
} else if (obj instanceof Task) {
|
|
4356
4485
|
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
|
|
4357
4486
|
} else if (isSsrNode(obj)) {
|
|
4358
|
-
|
|
4487
|
+
if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
|
|
4488
|
+
for (const data of obj.childrenVNodeData) {
|
|
4489
|
+
discoverValuesForVNodeData(data, discoveredValues);
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4359
4492
|
} else if (isDomRef(obj)) {
|
|
4360
|
-
discoveredValues.push(obj
|
|
4493
|
+
discoveredValues.push(obj.$ssrNode$.id);
|
|
4361
4494
|
} else if (isJSXNode(obj)) {
|
|
4362
4495
|
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
4363
4496
|
} else if (Array.isArray(obj)) {
|
|
@@ -4372,11 +4505,11 @@
|
|
|
4372
4505
|
}), (error => {
|
|
4373
4506
|
promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
|
|
4374
4507
|
})), promises.push(obj);
|
|
4375
|
-
} else if (obj instanceof
|
|
4508
|
+
} else if (obj instanceof EffectPropData) {
|
|
4376
4509
|
discoveredValues.push(obj.data);
|
|
4377
4510
|
} else {
|
|
4378
4511
|
if (!isObjectLiteral(obj)) {
|
|
4379
|
-
|
|
4512
|
+
throw qError(QError.serializeErrorUnknownType, [ obj ]);
|
|
4380
4513
|
}
|
|
4381
4514
|
Object.entries(obj).forEach((([key, value]) => {
|
|
4382
4515
|
discoveredValues.push(key, value);
|
|
@@ -4408,6 +4541,19 @@
|
|
|
4408
4541
|
$prepVNodeData$: prepVNodeData
|
|
4409
4542
|
};
|
|
4410
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
|
+
};
|
|
4411
4557
|
const promiseResults = new WeakMap;
|
|
4412
4558
|
function serializeWrappingFn(serializationContext, value) {
|
|
4413
4559
|
value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
|
|
@@ -4431,7 +4577,10 @@
|
|
|
4431
4577
|
backChannel || (backChannel = globalThis[QRL_RUNTIME_CHUNK] = new Map), backChannel.set(value.$symbol$, value._devOnlySymbolRef),
|
|
4432
4578
|
chunk || (chunk = QRL_RUNTIME_CHUNK);
|
|
4433
4579
|
}
|
|
4434
|
-
|
|
4580
|
+
if (!chunk) {
|
|
4581
|
+
throw qError(QError.qrlMissingChunk, [ value.$symbol$ ]);
|
|
4582
|
+
}
|
|
4583
|
+
chunk.startsWith("./") && (chunk = chunk.slice(2));
|
|
4435
4584
|
}
|
|
4436
4585
|
let qrlStringInline = `${chunk}#${symbol}`;
|
|
4437
4586
|
if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0) {
|
|
@@ -4535,6 +4684,9 @@
|
|
|
4535
4684
|
if (value instanceof Uint8Array) {
|
|
4536
4685
|
return !0;
|
|
4537
4686
|
}
|
|
4687
|
+
if (isDomRef?.(value)) {
|
|
4688
|
+
return !0;
|
|
4689
|
+
}
|
|
4538
4690
|
} else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
|
|
4539
4691
|
return !0;
|
|
4540
4692
|
}
|
|
@@ -4600,7 +4752,7 @@
|
|
|
4600
4752
|
let expectIndex = 0;
|
|
4601
4753
|
return unwrapped.forEach(((v, i) => {
|
|
4602
4754
|
if (i !== expectIndex) {
|
|
4603
|
-
throw qError(
|
|
4755
|
+
throw qError(QError.verifySerializable, [ unwrapped ]);
|
|
4604
4756
|
}
|
|
4605
4757
|
_verifySerializable(v, seen, ctx + "[" + i + "]"), expectIndex = i + 1;
|
|
4606
4758
|
})), value;
|
|
@@ -4626,7 +4778,7 @@
|
|
|
4626
4778
|
const fnName = value.name;
|
|
4627
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.`;
|
|
4628
4780
|
}
|
|
4629
|
-
|
|
4781
|
+
throw qError(QError.verifySerializable, [ message ]);
|
|
4630
4782
|
}
|
|
4631
4783
|
return value;
|
|
4632
4784
|
};
|
|
@@ -4647,7 +4799,7 @@
|
|
|
4647
4799
|
function bindFnToContext(currentCtx, beforeFn) {
|
|
4648
4800
|
return (...args) => maybeThen(resolveLazy(), (fn => {
|
|
4649
4801
|
if (!isFunction(fn)) {
|
|
4650
|
-
throw qError(
|
|
4802
|
+
throw qError(QError.qrlIsNotFunction);
|
|
4651
4803
|
}
|
|
4652
4804
|
if (beforeFn && !1 === beforeFn()) {
|
|
4653
4805
|
return;
|
|
@@ -4948,7 +5100,22 @@
|
|
|
4948
5100
|
onReady = () => q.forEach(q.push = v => sw.active.postMessage(v)), sw.installing ? sw.installing.addEventListener("statechange", (e => "activated" == e.target.state && onReady())) : onReady();
|
|
4949
5101
|
})), v && q.push([ "verbose" ]), document.addEventListener("qprefetch", (e => e.detail.bundles && q.push([ "prefetch", b, ...e.detail.bundles ])));
|
|
4950
5102
|
}).toString();
|
|
4951
|
-
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 = {}) => {
|
|
4952
5119
|
const isTest = (void 0).TEST;
|
|
4953
5120
|
if (build.isDev && !isTest) {
|
|
4954
5121
|
return _jsxSorted("script", null, {
|
|
@@ -5010,7 +5177,7 @@
|
|
|
5010
5177
|
}), props.children, jsx(SSRComment, {
|
|
5011
5178
|
data: "qkssr-po"
|
|
5012
5179
|
}) ], exports.SkipRender = SkipRender, exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS,
|
|
5013
|
-
exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData =
|
|
5180
|
+
exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = EffectPropData,
|
|
5014
5181
|
exports._IMMUTABLE = _IMMUTABLE, exports._SharedContainer = _SharedContainer, exports._VAR_PROPS = _VAR_PROPS,
|
|
5015
5182
|
exports._deserialize = function(rawStateData, element) {
|
|
5016
5183
|
if (null == rawStateData) {
|
|
@@ -5153,7 +5320,7 @@
|
|
|
5153
5320
|
if (void 0 !== defaultValue) {
|
|
5154
5321
|
return set(defaultValue);
|
|
5155
5322
|
}
|
|
5156
|
-
throw qError(
|
|
5323
|
+
throw qError(QError.notFoundContext, [ context.id ]);
|
|
5157
5324
|
}, exports.useContextProvider = useContextProvider, exports.useErrorBoundary = () => {
|
|
5158
5325
|
const store = useStore({
|
|
5159
5326
|
error: void 0
|