@qwik.dev/core 2.0.0-alpha.6 → 2.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +65 -42
- package/dist/core-internal.d.ts +92 -78
- package/dist/core.cjs +1603 -1374
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +1600 -1374
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +963 -834
- package/dist/core.prod.mjs +1093 -927
- package/dist/insights/index.qwik.cjs +3679 -167
- package/dist/insights/index.qwik.mjs +3679 -167
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +228 -5715
- package/dist/optimizer.mjs +208 -6038
- package/dist/prefetch/package.json +1 -1
- package/dist/qwikloader.debug.js +12 -15
- package/dist/qwikloader.js +2 -2
- package/dist/server.cjs +787 -7152
- package/dist/server.mjs +805 -7148
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +2 -0
- package/dist/starters/features/cypress/package.json +1 -1
- package/dist/starters/features/drizzle/drizzle/schema.ts +6 -18
- package/dist/starters/features/drizzle/drizzle.config.ts +5 -4
- package/dist/starters/features/drizzle/package.json +14 -11
- package/dist/starters/features/pandacss/package.json +1 -1
- package/dist/starters/features/partytown/package.json +1 -1
- package/dist/starters/features/postcss/package.json +1 -1
- package/dist/starters/features/prisma/package.json +1 -1
- package/dist/starters/features/react/package.json +1 -1
- package/dist/starters/features/storybook/package.json +1 -1
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +15 -9
- package/dist/starters/features/tailwind/src/global.css +1 -7
- package/dist/starters/features/turso/package.json +1 -1
- package/dist/starters/features/vitest/package.json +1 -1
- package/dist/testing/index.cjs +1341 -1180
- package/dist/testing/index.mjs +1354 -1186
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +9 -0
- package/package.json +6 -4
- package/public.d.ts +2 -0
- package/dist/starters/features/tailwind/.vscode/settings.json +0 -3
- package/dist/starters/features/tailwind/postcss.config.cjs +0 -6
- package/dist/starters/features/tailwind/tailwind.config.js +0 -8
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
var _a, _b, _c, _d, _e;
|
|
4
5
|
import { sync$, component$ } from "@qwik.dev/core";
|
|
6
|
+
var isBrowser = /* @__PURE__ */ (() => typeof window !== "undefined" && typeof HTMLElement !== "undefined" && !!window.document && String(HTMLElement).includes("[native code]"))();
|
|
7
|
+
var isServer = !isBrowser;
|
|
8
|
+
var isDev = false;
|
|
5
9
|
/**
|
|
6
10
|
* @license
|
|
7
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
11
|
+
* @qwik.dev/core 2.0.0-alpha.8-dev+66037b5
|
|
8
12
|
* Copyright QwikDev. All Rights Reserved.
|
|
9
13
|
* Use of this source code is governed by an MIT-style license that can be
|
|
10
14
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
11
15
|
*/
|
|
16
|
+
const logError = (message, ...optionalParams) => createAndLogError(false, message, ...optionalParams);
|
|
17
|
+
const throwErrorAndStop = (message, ...optionalParams) => {
|
|
18
|
+
throw createAndLogError(false, message, ...optionalParams);
|
|
19
|
+
};
|
|
12
20
|
const logErrorAndStop = (message, ...optionalParams) => createAndLogError(true, message, ...optionalParams);
|
|
13
21
|
const createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
14
22
|
const err = message instanceof Error ? message : new Error(message);
|
|
@@ -16,6 +24,10 @@ const createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
|
16
24
|
throw err;
|
|
17
25
|
}, 0), err;
|
|
18
26
|
};
|
|
27
|
+
function assertDefined() {
|
|
28
|
+
}
|
|
29
|
+
function assertEqual() {
|
|
30
|
+
}
|
|
19
31
|
function assertTrue() {
|
|
20
32
|
}
|
|
21
33
|
function assertFalse() {
|
|
@@ -23,12 +35,18 @@ function assertFalse() {
|
|
|
23
35
|
const codeToText = (code) => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
|
|
24
36
|
var QError;
|
|
25
37
|
!function(QError2) {
|
|
26
|
-
QError2[QError2.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError2[QError2.
|
|
38
|
+
QError2[QError2.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError2[QError2.schedulerNotFound = 1] = "schedulerNotFound", QError2[QError2.trackObjectWithoutProp = 2] = "trackObjectWithoutProp", QError2[QError2.verifySerializable = 3] = "verifySerializable", QError2[QError2.UNUSED_4 = 4] = "UNUSED_4", QError2[QError2.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer", QError2[QError2.UNUSED_6 = 6] = "UNUSED_6", QError2[QError2.UNUSED_7 = 7] = "UNUSED_7", QError2[QError2.UNUSED_8 = 8] = "UNUSED_8", QError2[QError2.UNUSED_9 = 9] = "UNUSED_9", QError2[QError2.qrlIsNotFunction = 10] = "qrlIsNotFunction", QError2[QError2.dynamicImportFailed = 11] = "dynamicImportFailed", QError2[QError2.unknownTypeArgument = 12] = "unknownTypeArgument", QError2[QError2.notFoundContext = 13] = "notFoundContext", QError2[QError2.useMethodOutsideContext = 14] = "useMethodOutsideContext", QError2[QError2.UNUSED_15 = 15] = "UNUSED_15", QError2[QError2.UNUSED_16 = 16] = "UNUSED_16", QError2[QError2.UNUSED_17 = 17] = "UNUSED_17", QError2[QError2.UNUSED_18 = 18] = "UNUSED_18", QError2[QError2.UNUSED_19 = 19] = "UNUSED_19", QError2[QError2.useInvokeContext = 20] = "useInvokeContext", QError2[QError2.UNUSED_21 = 21] = "UNUSED_21", QError2[QError2.UNUSED_22 = 22] = "UNUSED_22", QError2[QError2.UNUSED_23 = 23] = "UNUSED_23", QError2[QError2.UNUSED_24 = 24] = "UNUSED_24", QError2[QError2.UNUSED_25 = 25] = "UNUSED_25", QError2[QError2.UNUSED_26 = 26] = "UNUSED_26", QError2[QError2.UNUSED_27 = 27] = "UNUSED_27", QError2[QError2.invalidContext = 28] = "invalidContext", QError2[QError2.tagError = 29] = "tagError", QError2[QError2.qrlMissingContainer = 30] = "qrlMissingContainer", QError2[QError2.qrlMissingChunk = 31] = "qrlMissingChunk", QError2[QError2.invalidRefValue = 32] = "invalidRefValue", QError2[QError2.serializeErrorNotImplemented = 33] = "serializeErrorNotImplemented", QError2[QError2.serializeErrorExpectedVNode = 34] = "serializeErrorExpectedVNode", QError2[QError2.serializeErrorCannotAllocate = 35] = "serializeErrorCannotAllocate", QError2[QError2.serializeErrorMissingRootId = 36] = "serializeErrorMissingRootId", QError2[QError2.serializeErrorUnknownType = 37] = "serializeErrorUnknownType", QError2[QError2.serializeErrorUnvisited = 38] = "serializeErrorUnvisited", QError2[QError2.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError2[QError2.wrongTextareaValue = 40] = "wrongTextareaValue", QError2[QError2.containerNotFound = 41] = "containerNotFound", QError2[QError2.elementWithoutContainer = 42] = "elementWithoutContainer", QError2[QError2.invalidVNodeType = 43] = "invalidVNodeType", QError2[QError2.materializeVNodeDataError = 44] = "materializeVNodeDataError", QError2[QError2.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError2[QError2.computedNotSync = 46] = "computedNotSync", QError2[QError2.computedReadOnly = 47] = "computedReadOnly", QError2[QError2.wrappedReadOnly = 48] = "wrappedReadOnly", QError2[QError2.unsafeAttr = 49] = "unsafeAttr";
|
|
27
39
|
}(QError || (QError = {}));
|
|
28
40
|
const qError = (code, errorMessageArgs = []) => {
|
|
29
41
|
const text = codeToText(code, ...errorMessageArgs);
|
|
30
42
|
return logErrorAndStop(text, ...errorMessageArgs);
|
|
31
43
|
};
|
|
44
|
+
const isSyncQrl = (value) => isQrl$1(value) && "<sync>" == value.$symbol$;
|
|
45
|
+
const isQrl$1 = (value) => "function" == typeof value && "function" == typeof value.getSymbol;
|
|
46
|
+
const getSymbolHash = (symbolName) => {
|
|
47
|
+
const index = symbolName.lastIndexOf("_");
|
|
48
|
+
return index > -1 ? symbolName.slice(index + 1) : symbolName;
|
|
49
|
+
};
|
|
32
50
|
var VirtualType;
|
|
33
51
|
!function(VirtualType2) {
|
|
34
52
|
VirtualType2.Virtual = "V", VirtualType2.Fragment = "F", VirtualType2.WrappedSignal = "S", VirtualType2.Awaited = "A", VirtualType2.Component = "C", VirtualType2.InlineComponent = "I", VirtualType2.Projection = "P";
|
|
@@ -46,93 +64,1694 @@ var QContainerValue;
|
|
|
46
64
|
!function(QContainerValue2) {
|
|
47
65
|
QContainerValue2.PAUSED = "paused", QContainerValue2.RESUMED = "resumed", QContainerValue2.HTML = "html", QContainerValue2.TEXT = "text";
|
|
48
66
|
}(QContainerValue || (QContainerValue = {}));
|
|
67
|
+
const QSlot = "q:slot";
|
|
68
|
+
const QSlotS = "q:s";
|
|
69
|
+
const QStyle = "q:style";
|
|
70
|
+
const QStyleSelector = "style[q\\:style]";
|
|
71
|
+
const QStylesAllSelector = "style[q\\:style],style[q\\:sstyle]";
|
|
72
|
+
const getQFuncs = (document2, hash) => document2["qFuncs_" + hash] || [];
|
|
73
|
+
const QContainerIsland = "q:container-island";
|
|
74
|
+
const QContainerIslandEnd = "/" + QContainerIsland;
|
|
75
|
+
const QIgnore = "q:ignore";
|
|
76
|
+
const QIgnoreEnd = "/q:ignore";
|
|
77
|
+
const QTemplate = "q:template";
|
|
49
78
|
const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
|
|
79
|
+
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|
80
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
81
|
+
const MATH_NS = "http://www.w3.org/1998/Math/MathML";
|
|
50
82
|
const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
83
|
+
const createPlatform = () => ({
|
|
84
|
+
isServer,
|
|
85
|
+
importSymbol(containerEl, url, symbolName) {
|
|
86
|
+
if (isServer) {
|
|
87
|
+
const hash = getSymbolHash(symbolName);
|
|
88
|
+
const regSym = globalThis.__qwik_reg_symbols?.get(hash);
|
|
89
|
+
if (regSym) {
|
|
90
|
+
return regSym;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (!url) {
|
|
94
|
+
throw qError(QError.qrlMissingChunk, [symbolName]);
|
|
95
|
+
}
|
|
96
|
+
if (!containerEl) {
|
|
97
|
+
throw qError(QError.qrlMissingContainer, [url, symbolName]);
|
|
98
|
+
}
|
|
99
|
+
const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
|
|
100
|
+
const urlCopy = new URL(urlDoc);
|
|
101
|
+
urlCopy.hash = "";
|
|
102
|
+
return import(urlCopy.href).then((mod) => mod[symbolName]);
|
|
103
|
+
},
|
|
104
|
+
raf: (fn) => new Promise((resolve) => {
|
|
105
|
+
requestAnimationFrame(() => {
|
|
106
|
+
resolve(fn());
|
|
107
|
+
});
|
|
108
|
+
}),
|
|
109
|
+
nextTick: (fn) => new Promise((resolve) => {
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
resolve(fn());
|
|
112
|
+
});
|
|
113
|
+
}),
|
|
114
|
+
chunkForSymbol: (symbolName, chunk) => [symbolName, chunk ?? "_"]
|
|
115
|
+
});
|
|
116
|
+
const toUrl = (doc, containerEl, url) => {
|
|
117
|
+
const baseURI = doc.baseURI;
|
|
118
|
+
const base = new URL(containerEl.getAttribute("q:base") ?? baseURI, baseURI);
|
|
119
|
+
return new URL(url, base);
|
|
120
|
+
};
|
|
121
|
+
let _platform = /* @__PURE__ */ createPlatform();
|
|
122
|
+
const getPlatform = () => _platform;
|
|
123
|
+
const isServerPlatform = () => _platform.isServer;
|
|
51
124
|
const isPromise = (value) => !!value && "object" == typeof value && "function" == typeof value.then;
|
|
125
|
+
const safeCall = (call, thenFn, rejectFn) => {
|
|
126
|
+
try {
|
|
127
|
+
const result = call();
|
|
128
|
+
return isPromise(result) ? result.then(thenFn, rejectFn) : thenFn(result);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return rejectFn(e);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
|
|
134
|
+
const shouldNotError = (reason) => {
|
|
135
|
+
throwErrorAndStop(reason);
|
|
136
|
+
};
|
|
137
|
+
const delay = (timeout) => new Promise((resolve) => {
|
|
138
|
+
setTimeout(resolve, timeout);
|
|
139
|
+
});
|
|
140
|
+
function retryOnPromise(fn, retryCount = 0) {
|
|
141
|
+
const retryOrThrow = (e) => {
|
|
142
|
+
if (isPromise(e) && retryCount < 100) {
|
|
143
|
+
return e.then(retryOnPromise.bind(null, fn, retryCount++));
|
|
144
|
+
}
|
|
145
|
+
throw e;
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
const result = fn();
|
|
149
|
+
return isPromise(result) ? result.catch((e) => retryOrThrow(e)) : result;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
return retryOrThrow(e);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const isSerializableObject = (v) => {
|
|
155
|
+
const proto = Object.getPrototypeOf(v);
|
|
156
|
+
return proto === Object.prototype || proto === Array.prototype || null === proto;
|
|
157
|
+
};
|
|
52
158
|
const isArray = (v) => Array.isArray(v);
|
|
159
|
+
const isString = (v) => "string" == typeof v;
|
|
160
|
+
const isFunction = (v) => "function" == typeof v;
|
|
53
161
|
var VNodeDataFlag;
|
|
54
162
|
!function(VNodeDataFlag2) {
|
|
55
163
|
VNodeDataFlag2[VNodeDataFlag2.NONE = 0] = "NONE", VNodeDataFlag2[VNodeDataFlag2.TEXT_DATA = 1] = "TEXT_DATA", VNodeDataFlag2[VNodeDataFlag2.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag2[VNodeDataFlag2.ELEMENT_NODE = 4] = "ELEMENT_NODE", VNodeDataFlag2[VNodeDataFlag2.REFERENCE = 8] = "REFERENCE", VNodeDataFlag2[VNodeDataFlag2.SERIALIZE = 16] = "SERIALIZE";
|
|
56
164
|
}(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
57
|
-
const isQrl
|
|
165
|
+
const isQrl = (value) => "function" == typeof value && "function" == typeof value.getSymbol;
|
|
166
|
+
const EMPTY_ARRAY = [];
|
|
58
167
|
const EMPTY_OBJ = {};
|
|
59
|
-
Object.freeze(EMPTY_OBJ);
|
|
168
|
+
Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
|
|
169
|
+
var ChoreType;
|
|
170
|
+
!function(ChoreType2) {
|
|
171
|
+
ChoreType2[ChoreType2.MACRO = 240] = "MACRO", ChoreType2[ChoreType2.MICRO = 15] = "MICRO", ChoreType2[ChoreType2.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType2[ChoreType2.RUN_QRL = 2] = "RUN_QRL", ChoreType2[ChoreType2.TASK = 3] = "TASK", ChoreType2[ChoreType2.NODE_DIFF = 4] = "NODE_DIFF", ChoreType2[ChoreType2.NODE_PROP = 5] = "NODE_PROP", ChoreType2[ChoreType2.COMPONENT = 6] = "COMPONENT", ChoreType2[ChoreType2.RECOMPUTE_AND_SCHEDULE_EFFECTS = 7] = "RECOMPUTE_AND_SCHEDULE_EFFECTS", ChoreType2[ChoreType2.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType2[ChoreType2.VISIBLE = 32] = "VISIBLE", ChoreType2[ChoreType2.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType2[ChoreType2.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
|
|
172
|
+
}(ChoreType || (ChoreType = {}));
|
|
173
|
+
const Slot = (props) => _jsxSorted(Virtual, null, {
|
|
174
|
+
[QSlotS]: ""
|
|
175
|
+
}, props.children, 0, props.name ?? "");
|
|
176
|
+
const SkipRender = Symbol("skip render");
|
|
177
|
+
const SSRRaw = () => null;
|
|
178
|
+
const SSRComment = () => null;
|
|
179
|
+
const isJsxPropertyAnEventName = (name) => (name.startsWith("on") || name.startsWith("window:on") || name.startsWith("document:on")) && name.endsWith("$");
|
|
180
|
+
const isHtmlAttributeAnEventName = (name) => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
|
|
181
|
+
const getEventNameFromJsxProp = (name) => {
|
|
182
|
+
if (name.endsWith("$")) {
|
|
183
|
+
let idx = -1;
|
|
184
|
+
if (name.startsWith("on") ? idx = 2 : name.startsWith("window:on") ? idx = 9 : name.startsWith("document:on") && (idx = 11), -1 != idx) {
|
|
185
|
+
const isCaseSensitive = isDashAt(name, idx) && !isDashAt(name, idx + 1);
|
|
186
|
+
isCaseSensitive && idx++;
|
|
187
|
+
let lastIdx = idx;
|
|
188
|
+
let eventName = "";
|
|
189
|
+
for (; ; ) {
|
|
190
|
+
idx = name.indexOf("-", lastIdx);
|
|
191
|
+
const chunk = name.substring(lastIdx, -1 === idx ? name.length - 1 : idx);
|
|
192
|
+
if (eventName += isCaseSensitive ? chunk : chunk.toLowerCase(), -1 == idx) {
|
|
193
|
+
return eventName;
|
|
194
|
+
}
|
|
195
|
+
isDashAt(name, idx + 1) ? (eventName += "-", idx++) : (eventName += name.charAt(idx + 1).toUpperCase(), idx++), lastIdx = idx + 1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
};
|
|
201
|
+
const getEventNameScopeFromJsxProp = (name) => {
|
|
202
|
+
const index = name.indexOf(":");
|
|
203
|
+
return -1 !== index ? name.substring(0, index) : "";
|
|
204
|
+
};
|
|
205
|
+
const isDashAt = (name, idx) => 45 === name.charCodeAt(idx);
|
|
206
|
+
const convertEventNameFromJsxPropToHtmlAttr = (name) => {
|
|
207
|
+
if (name.endsWith("$")) {
|
|
208
|
+
let prefix = null;
|
|
209
|
+
if (name.startsWith("on") ? prefix = "on:" : name.startsWith("window:on") ? prefix = "on-window:" : name.startsWith("document:on") && (prefix = "on-document:"), null !== prefix) {
|
|
210
|
+
const eventName = getEventNameFromJsxProp(name);
|
|
211
|
+
return prefix + fromCamelToKebabCase(eventName);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
};
|
|
216
|
+
const fromCamelToKebabCase = (text) => text.replace(/([A-Z-])/g, "-$1").toLowerCase();
|
|
217
|
+
function isPreventDefault(key) {
|
|
218
|
+
return key.startsWith("preventdefault:");
|
|
219
|
+
}
|
|
220
|
+
function getFileLocationFromJsx(jsxDev) {
|
|
221
|
+
if (!jsxDev) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
|
|
225
|
+
return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
|
|
226
|
+
}
|
|
227
|
+
const styleContent = (styleId) => "⚡️" + styleId;
|
|
228
|
+
function hasClassAttr(props) {
|
|
229
|
+
for (const key in props) {
|
|
230
|
+
if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
function isClassAttr(key) {
|
|
237
|
+
return "class" === key || "className" === key;
|
|
238
|
+
}
|
|
239
|
+
function convertScopedStyleIdsToArray(scopedStyleIds) {
|
|
240
|
+
return scopedStyleIds?.split(" ") ?? null;
|
|
241
|
+
}
|
|
242
|
+
function convertStyleIdsToString(scopedStyleIds) {
|
|
243
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
244
|
+
}
|
|
245
|
+
const addComponentStylePrefix = (styleId) => {
|
|
246
|
+
if (styleId) {
|
|
247
|
+
let idx = 0;
|
|
248
|
+
do {
|
|
249
|
+
styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
|
|
250
|
+
} while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
|
|
251
|
+
}
|
|
252
|
+
return styleId || null;
|
|
253
|
+
};
|
|
254
|
+
const unitlessNumbers = /* @__PURE__ */ 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"]);
|
|
255
|
+
const isUnitlessNumber = (name) => unitlessNumbers.has(name);
|
|
256
|
+
const serializeClass = (obj) => {
|
|
257
|
+
if (!obj) {
|
|
258
|
+
return "";
|
|
259
|
+
}
|
|
260
|
+
if (isString(obj)) {
|
|
261
|
+
return obj.trim();
|
|
262
|
+
}
|
|
263
|
+
const classes = [];
|
|
264
|
+
if (isArray(obj)) {
|
|
265
|
+
for (const o of obj) {
|
|
266
|
+
const classList = serializeClass(o);
|
|
267
|
+
classList && classes.push(classList);
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
271
|
+
value && classes.push(key.trim());
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return classes.join(" ");
|
|
275
|
+
};
|
|
276
|
+
const fromCamelToKebabCaseWithDash = (text) => text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
277
|
+
const stringifyStyle = (obj) => {
|
|
278
|
+
if (null == obj) {
|
|
279
|
+
return "";
|
|
280
|
+
}
|
|
281
|
+
if ("object" == typeof obj) {
|
|
282
|
+
if (isArray(obj)) {
|
|
283
|
+
throw qError(QError.stringifyClassOrStyle, [obj, "style"]);
|
|
284
|
+
}
|
|
285
|
+
{
|
|
286
|
+
const chunks = [];
|
|
287
|
+
for (const key in obj) {
|
|
288
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
289
|
+
const value = obj[key];
|
|
290
|
+
null != value && "function" != typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return chunks.join(";");
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return String(obj);
|
|
297
|
+
};
|
|
298
|
+
const serializeBooleanOrNumberAttribute = (value) => null != value ? String(value) : null;
|
|
299
|
+
function serializeAttribute(key, value, styleScopedId) {
|
|
300
|
+
if (isClassAttr(key)) {
|
|
301
|
+
const serializedClass = serializeClass(value);
|
|
302
|
+
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
303
|
+
} else {
|
|
304
|
+
"style" === key ? value = stringifyStyle(value) : isEnumeratedBooleanAttribute(key) || "number" == typeof value ? value = serializeBooleanOrNumberAttribute(value) : false === value || null == value ? value = null : true === value && isPreventDefault(key) && (value = "");
|
|
305
|
+
}
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
function isEnumeratedBooleanAttribute(key) {
|
|
309
|
+
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
310
|
+
}
|
|
311
|
+
const setValueForStyle = (styleName, value) => "number" != typeof value || 0 === value || isUnitlessNumber(styleName) ? value : value + "px";
|
|
312
|
+
function isAriaAttribute(prop) {
|
|
313
|
+
return prop.startsWith("aria-");
|
|
314
|
+
}
|
|
60
315
|
const STORE_TARGET = Symbol("store.target");
|
|
316
|
+
const STORE_HANDLER = Symbol("store.handler");
|
|
317
|
+
const STORE_ALL_PROPS = Symbol("store.all");
|
|
61
318
|
var StoreFlags;
|
|
62
319
|
!function(StoreFlags2) {
|
|
63
320
|
StoreFlags2[StoreFlags2.NONE = 0] = "NONE", StoreFlags2[StoreFlags2.RECURSIVE = 1] = "RECURSIVE", StoreFlags2[StoreFlags2.IMMUTABLE = 2] = "IMMUTABLE";
|
|
64
321
|
}(StoreFlags || (StoreFlags = {}));
|
|
322
|
+
const getStoreHandler = (value) => value[STORE_HANDLER];
|
|
323
|
+
const getStoreTarget = (value) => value?.[STORE_TARGET] || null;
|
|
324
|
+
const unwrapStore = (value) => getStoreTarget(value) || value;
|
|
65
325
|
const isStore = (value) => STORE_TARGET in value;
|
|
66
|
-
|
|
326
|
+
function createStore(container, obj, flags) {
|
|
327
|
+
return new Proxy(obj, new StoreHandler(flags, container || null));
|
|
328
|
+
}
|
|
329
|
+
const getOrCreateStore = (obj, flags, container) => {
|
|
330
|
+
if (isSerializableObject(obj) && container) {
|
|
331
|
+
let store = container.$storeProxyMap$.get(obj);
|
|
332
|
+
return store || (store = createStore(container, obj, flags), container.$storeProxyMap$.set(obj, store)), store;
|
|
333
|
+
}
|
|
334
|
+
return obj;
|
|
335
|
+
};
|
|
336
|
+
class StoreHandler {
|
|
337
|
+
constructor($flags$, $container$) {
|
|
338
|
+
__publicField(this, "$flags$");
|
|
339
|
+
__publicField(this, "$container$");
|
|
340
|
+
__publicField(this, "$effects$", null);
|
|
341
|
+
this.$flags$ = $flags$, this.$container$ = $container$;
|
|
342
|
+
}
|
|
343
|
+
toString() {
|
|
344
|
+
return "[Store]";
|
|
345
|
+
}
|
|
346
|
+
get(target, prop) {
|
|
347
|
+
if ("symbol" == typeof prop) {
|
|
348
|
+
return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
|
|
349
|
+
}
|
|
350
|
+
const ctx = tryGetInvokeContext();
|
|
351
|
+
const value = target[prop];
|
|
352
|
+
if (ctx) {
|
|
353
|
+
if (null === this.$container$) {
|
|
354
|
+
if (!ctx.$container$) {
|
|
355
|
+
return value;
|
|
356
|
+
}
|
|
357
|
+
this.$container$ = ctx.$container$;
|
|
358
|
+
} else {
|
|
359
|
+
assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$);
|
|
360
|
+
}
|
|
361
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
362
|
+
effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
|
|
363
|
+
}
|
|
364
|
+
if ("toString" === prop && value === Object.prototype.toString) {
|
|
365
|
+
return this.toString;
|
|
366
|
+
}
|
|
367
|
+
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;
|
|
368
|
+
}
|
|
369
|
+
set(target, prop, value) {
|
|
370
|
+
if ("symbol" == typeof prop) {
|
|
371
|
+
return target[prop] = value, true;
|
|
372
|
+
}
|
|
373
|
+
const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
|
|
374
|
+
if (prop in target) {
|
|
375
|
+
newValue !== target[prop] && setNewValueAndTriggerEffects(prop, newValue, target, this);
|
|
376
|
+
} else {
|
|
377
|
+
setNewValueAndTriggerEffects(prop, newValue, target, this);
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
deleteProperty(target, prop) {
|
|
382
|
+
return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)), true);
|
|
383
|
+
}
|
|
384
|
+
has(target, prop) {
|
|
385
|
+
if (prop === STORE_TARGET) {
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
if ("string" == typeof prop) {
|
|
389
|
+
const ctx = tryGetInvokeContext();
|
|
390
|
+
if (ctx) {
|
|
391
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
392
|
+
effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
396
|
+
}
|
|
397
|
+
ownKeys(target) {
|
|
398
|
+
const ctx = tryGetInvokeContext();
|
|
399
|
+
const effectSubscriber = ctx?.$effectSubscriber$;
|
|
400
|
+
return effectSubscriber && addStoreEffect(target, STORE_ALL_PROPS, this, effectSubscriber), Reflect.ownKeys(target);
|
|
401
|
+
}
|
|
402
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
403
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
|
|
404
|
+
return Array.isArray(target) || "symbol" == typeof prop || descriptor && !descriptor.configurable ? descriptor : {
|
|
405
|
+
enumerable: true,
|
|
406
|
+
configurable: true
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function addStoreEffect(target, prop, store, effectSubscription) {
|
|
411
|
+
const effectsMap = store.$effects$ || (store.$effects$ = /* @__PURE__ */ new Map());
|
|
412
|
+
let effects = effectsMap.get(prop);
|
|
413
|
+
effects || (effects = /* @__PURE__ */ new Set(), effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription), ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
|
|
414
|
+
}
|
|
415
|
+
function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
|
|
416
|
+
target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
|
|
417
|
+
}
|
|
418
|
+
function getEffects(target, prop, storeEffects) {
|
|
419
|
+
let effectsToTrigger;
|
|
420
|
+
if (storeEffects) {
|
|
421
|
+
if (Array.isArray(target)) {
|
|
422
|
+
for (const effects of storeEffects.values()) {
|
|
423
|
+
effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
|
|
424
|
+
for (const effect of effects) {
|
|
425
|
+
effectsToTrigger.add(effect);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
effectsToTrigger = storeEffects.get(prop);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const storeArrayValue = storeEffects?.get(STORE_ALL_PROPS);
|
|
433
|
+
if (storeArrayValue) {
|
|
434
|
+
effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
|
|
435
|
+
for (const effect of storeArrayValue) {
|
|
436
|
+
effectsToTrigger.add(effect);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return effectsToTrigger || null;
|
|
440
|
+
}
|
|
441
|
+
const NEEDS_COMPUTATION = Symbol("invalid");
|
|
442
|
+
const _EFFECT_BACK_REF = Symbol("backRef");
|
|
443
|
+
_a = _EFFECT_BACK_REF;
|
|
444
|
+
class BackRef {
|
|
67
445
|
constructor() {
|
|
68
|
-
__publicField(this,
|
|
446
|
+
__publicField(this, _a, null);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function clearAllEffects(container, consumer) {
|
|
450
|
+
vnode_isVNode(consumer) && vnode_isElementVNode(consumer) && ensureMaterialized(consumer);
|
|
451
|
+
const effects = consumer[_EFFECT_BACK_REF];
|
|
452
|
+
if (effects) {
|
|
453
|
+
for (const [, effect] of effects) {
|
|
454
|
+
const backRefs = effect[EffectSubscriptionProp.BACK_REF];
|
|
455
|
+
if (!backRefs) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
for (const producer of backRefs) {
|
|
459
|
+
if (producer instanceof Signal) {
|
|
460
|
+
clearSignal(container, producer, effect);
|
|
461
|
+
} else if (container.$storeProxyMap$.has(producer)) {
|
|
462
|
+
const target = container.$storeProxyMap$.get(producer);
|
|
463
|
+
clearStore(getStoreHandler(target), effect);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function clearSignal(container, producer, effect) {
|
|
470
|
+
const effects = producer.$effects$;
|
|
471
|
+
effects && effects.delete(effect), producer instanceof WrappedSignal && (producer.$hostElement$ = null, clearAllEffects(container, producer));
|
|
472
|
+
}
|
|
473
|
+
function clearStore(producer, effect) {
|
|
474
|
+
const effects = producer?.$effects$;
|
|
475
|
+
if (effects) {
|
|
476
|
+
for (const propEffects of effects.values()) {
|
|
477
|
+
propEffects.delete(effect);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function getSubscriber(effect, prop, data) {
|
|
482
|
+
effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", /* @__PURE__ */ new Map()) : effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map());
|
|
483
|
+
const subMap = effect[_EFFECT_BACK_REF];
|
|
484
|
+
let sub = subMap.get(prop);
|
|
485
|
+
return sub || (sub = [effect, prop], subMap.set(prop, sub)), data && (sub[EffectSubscriptionProp.DATA] = data), sub;
|
|
486
|
+
}
|
|
487
|
+
function isSsrNode(value) {
|
|
488
|
+
return "__brand__" in value && "currentComponentNode" in value;
|
|
489
|
+
}
|
|
490
|
+
var TaskFlags;
|
|
491
|
+
!function(TaskFlags2) {
|
|
492
|
+
TaskFlags2[TaskFlags2.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags2[TaskFlags2.TASK = 2] = "TASK", TaskFlags2[TaskFlags2.RESOURCE = 4] = "RESOURCE", TaskFlags2[TaskFlags2.DIRTY = 8] = "DIRTY";
|
|
493
|
+
}(TaskFlags || (TaskFlags = {}));
|
|
494
|
+
const runTask = (task, container, host) => {
|
|
495
|
+
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
496
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
497
|
+
iCtx.$container$ = container;
|
|
498
|
+
const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
|
|
499
|
+
let cleanupFns = null;
|
|
500
|
+
const cleanup2 = (fn) => {
|
|
501
|
+
"function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize(() => {
|
|
502
|
+
task.$destroy$ = null, cleanupFns.forEach((fn2) => {
|
|
503
|
+
try {
|
|
504
|
+
fn2();
|
|
505
|
+
} catch (err) {
|
|
506
|
+
container.handleError(err, host);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
})), cleanupFns.push(fn));
|
|
510
|
+
};
|
|
511
|
+
const taskApi = {
|
|
512
|
+
track: (obj, prop) => {
|
|
513
|
+
const ctx = newInvokeContext();
|
|
514
|
+
return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container, invoke(ctx, () => {
|
|
515
|
+
if (isFunction(obj)) {
|
|
516
|
+
return obj();
|
|
517
|
+
}
|
|
518
|
+
if (prop) {
|
|
519
|
+
return obj[prop];
|
|
520
|
+
}
|
|
521
|
+
if (isSignal(obj)) {
|
|
522
|
+
return obj.value;
|
|
523
|
+
}
|
|
524
|
+
if (isStore(obj)) {
|
|
525
|
+
return addStoreEffect(getStoreTarget(obj), STORE_ALL_PROPS, getStoreHandler(obj), ctx.$effectSubscriber$), obj;
|
|
526
|
+
}
|
|
527
|
+
throw qError(QError.trackObjectWithoutProp);
|
|
528
|
+
});
|
|
529
|
+
},
|
|
530
|
+
cleanup: cleanup2
|
|
531
|
+
};
|
|
532
|
+
return safeCall(() => taskFn(taskApi), cleanup2, (err) => {
|
|
533
|
+
if (isPromise(err)) {
|
|
534
|
+
return err.then(() => runTask(task, container, host));
|
|
535
|
+
}
|
|
536
|
+
throw err;
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
const cleanupTask = (task) => {
|
|
540
|
+
const destroy = task.$destroy$;
|
|
541
|
+
if (destroy) {
|
|
542
|
+
task.$destroy$ = null;
|
|
543
|
+
try {
|
|
544
|
+
destroy();
|
|
545
|
+
} catch (err) {
|
|
546
|
+
logError(err);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
class Task extends BackRef {
|
|
551
|
+
constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
|
|
552
|
+
super();
|
|
553
|
+
__publicField(this, "$flags$");
|
|
554
|
+
__publicField(this, "$index$");
|
|
555
|
+
__publicField(this, "$el$");
|
|
556
|
+
__publicField(this, "$qrl$");
|
|
557
|
+
__publicField(this, "$state$");
|
|
558
|
+
__publicField(this, "$destroy$");
|
|
559
|
+
this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$, this.$state$ = $state$, this.$destroy$ = $destroy$;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
const isTask = (value) => value instanceof Task;
|
|
563
|
+
var VNodeFlags;
|
|
564
|
+
var VNodeFlagsIndex;
|
|
565
|
+
var VNodeProps;
|
|
566
|
+
var ElementVNodeProps;
|
|
567
|
+
var TextVNodeProps;
|
|
568
|
+
var VirtualVNodeProps;
|
|
569
|
+
!function(VNodeFlags2) {
|
|
570
|
+
VNodeFlags2[VNodeFlags2.Element = 1] = "Element", VNodeFlags2[VNodeFlags2.Virtual = 2] = "Virtual", VNodeFlags2[VNodeFlags2.ELEMENT_OR_VIRTUAL_MASK = 3] = "ELEMENT_OR_VIRTUAL_MASK", VNodeFlags2[VNodeFlags2.ELEMENT_OR_TEXT_MASK = 5] = "ELEMENT_OR_TEXT_MASK", VNodeFlags2[VNodeFlags2.TYPE_MASK = 7] = "TYPE_MASK", VNodeFlags2[VNodeFlags2.INFLATED_TYPE_MASK = 15] = "INFLATED_TYPE_MASK", VNodeFlags2[VNodeFlags2.Text = 4] = "Text", VNodeFlags2[VNodeFlags2.Inflated = 8] = "Inflated", VNodeFlags2[VNodeFlags2.Resolved = 16] = "Resolved", VNodeFlags2[VNodeFlags2.Deleted = 32] = "Deleted", VNodeFlags2[VNodeFlags2.NAMESPACE_MASK = 192] = "NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NEGATED_NAMESPACE_MASK = -193] = "NEGATED_NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NS_html = 0] = "NS_html", VNodeFlags2[VNodeFlags2.NS_svg = 64] = "NS_svg", VNodeFlags2[VNodeFlags2.NS_math = 128] = "NS_math";
|
|
571
|
+
}(VNodeFlags || (VNodeFlags = {})), function(VNodeFlagsIndex2) {
|
|
572
|
+
VNodeFlagsIndex2[VNodeFlagsIndex2.mask = -256] = "mask", VNodeFlagsIndex2[VNodeFlagsIndex2.negated_mask = 255] = "negated_mask", VNodeFlagsIndex2[VNodeFlagsIndex2.shift = 8] = "shift";
|
|
573
|
+
}(VNodeFlagsIndex || (VNodeFlagsIndex = {})), function(VNodeProps2) {
|
|
574
|
+
VNodeProps2[VNodeProps2.flags = 0] = "flags", VNodeProps2[VNodeProps2.parent = 1] = "parent", VNodeProps2[VNodeProps2.previousSibling = 2] = "previousSibling", VNodeProps2[VNodeProps2.nextSibling = 3] = "nextSibling";
|
|
575
|
+
}(VNodeProps || (VNodeProps = {})), function(ElementVNodeProps2) {
|
|
576
|
+
ElementVNodeProps2[ElementVNodeProps2.firstChild = 4] = "firstChild", ElementVNodeProps2[ElementVNodeProps2.lastChild = 5] = "lastChild", ElementVNodeProps2[ElementVNodeProps2.element = 6] = "element", ElementVNodeProps2[ElementVNodeProps2.elementName = 7] = "elementName", ElementVNodeProps2[ElementVNodeProps2.PROPS_OFFSET = 8] = "PROPS_OFFSET";
|
|
577
|
+
}(ElementVNodeProps || (ElementVNodeProps = {})), function(TextVNodeProps2) {
|
|
578
|
+
TextVNodeProps2[TextVNodeProps2.node = 4] = "node", TextVNodeProps2[TextVNodeProps2.text = 5] = "text";
|
|
579
|
+
}(TextVNodeProps || (TextVNodeProps = {})), function(VirtualVNodeProps2) {
|
|
580
|
+
VirtualVNodeProps2[VirtualVNodeProps2.firstChild = 4] = "firstChild", VirtualVNodeProps2[VirtualVNodeProps2.lastChild = 5] = "lastChild", VirtualVNodeProps2[VirtualVNodeProps2.PROPS_OFFSET = 6] = "PROPS_OFFSET";
|
|
581
|
+
}(VirtualVNodeProps || (VirtualVNodeProps = {}));
|
|
582
|
+
const mapApp_findIndx = (array, key, start) => {
|
|
583
|
+
let bottom = start >> 1;
|
|
584
|
+
let top = array.length - 2 >> 1;
|
|
585
|
+
for (; bottom <= top; ) {
|
|
586
|
+
const mid = bottom + (top - bottom >> 1);
|
|
587
|
+
const midKey = array[mid << 1];
|
|
588
|
+
if (midKey === key) {
|
|
589
|
+
return mid << 1;
|
|
590
|
+
}
|
|
591
|
+
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
592
|
+
}
|
|
593
|
+
return ~(bottom << 1);
|
|
594
|
+
};
|
|
595
|
+
const mapArray_set = (array, key, value, start) => {
|
|
596
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
597
|
+
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(~indx, 0, key, value);
|
|
598
|
+
};
|
|
599
|
+
const mapArray_get = (array, key, start) => {
|
|
600
|
+
const indx = mapApp_findIndx(array, key, start);
|
|
601
|
+
return indx >= 0 ? array[indx + 1] : null;
|
|
602
|
+
};
|
|
603
|
+
const isForeignObjectElement = (elementName) => "foreignObject" === elementName;
|
|
604
|
+
const isSvgElement = (elementName) => "svg" === elementName || isForeignObjectElement(elementName);
|
|
605
|
+
const isMathElement = (elementName) => "math" === elementName;
|
|
606
|
+
const vnode_isDefaultNamespace = (vnode) => !(vnode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK);
|
|
607
|
+
const vnode_getElementNamespaceFlags = (element) => {
|
|
608
|
+
switch (fastNamespaceURI(element)) {
|
|
609
|
+
case SVG_NS:
|
|
610
|
+
return VNodeFlags.NS_svg;
|
|
611
|
+
case MATH_NS:
|
|
612
|
+
return VNodeFlags.NS_math;
|
|
613
|
+
default:
|
|
614
|
+
return VNodeFlags.NS_html;
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
|
|
618
|
+
const { elementNamespace, elementNamespaceFlag } = getNewElementNamespaceData(domParentVNode, newChild);
|
|
619
|
+
let domChildren = [];
|
|
620
|
+
if (elementNamespace === HTML_NS) {
|
|
621
|
+
domChildren = vnode_getDOMChildNodes(journal, newChild);
|
|
622
|
+
} else {
|
|
623
|
+
const children = vnode_getDOMChildNodes(journal, newChild, true);
|
|
624
|
+
for (let i = 0; i < children.length; i++) {
|
|
625
|
+
const childVNode = children[i];
|
|
626
|
+
if (vnode_isTextVNode(childVNode)) {
|
|
627
|
+
domChildren.push(childVNode[TextVNodeProps.node]);
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if ((childVNode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK) == (domParentVNode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK)) {
|
|
631
|
+
domChildren.push(childVNode[ElementVNodeProps.element]);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
const newChildElement = vnode_cloneElementWithNamespace(childVNode, domParentVNode, elementNamespace, elementNamespaceFlag);
|
|
635
|
+
newChildElement && domChildren.push(newChildElement);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return domChildren;
|
|
639
|
+
}
|
|
640
|
+
function cloneElementWithNamespace(element, elementName, namespace) {
|
|
641
|
+
const newElement = element.ownerDocument.createElementNS(namespace, elementName);
|
|
642
|
+
const attributes = element.attributes;
|
|
643
|
+
for (const attribute of attributes) {
|
|
644
|
+
const name = attribute.name;
|
|
645
|
+
name && ":" !== name && newElement.setAttribute(name, attribute.value);
|
|
646
|
+
}
|
|
647
|
+
return newElement;
|
|
648
|
+
}
|
|
649
|
+
function vnode_cloneElementWithNamespace(elementVNode, parentVNode, namespace, namespaceFlag) {
|
|
650
|
+
ensureElementVNode(elementVNode);
|
|
651
|
+
let vCursor = elementVNode;
|
|
652
|
+
let vParent = null;
|
|
653
|
+
let rootElement = null;
|
|
654
|
+
let parentElement = null;
|
|
655
|
+
for (; vCursor; ) {
|
|
656
|
+
let childElement = null;
|
|
657
|
+
let newChildElement = null;
|
|
658
|
+
if (vnode_isElementVNode(vCursor)) {
|
|
659
|
+
childElement = vCursor[ElementVNodeProps.element];
|
|
660
|
+
const childElementTag = vnode_getElementName(vCursor);
|
|
661
|
+
const vCursorParent = vnode_getParent(vCursor);
|
|
662
|
+
const vCursorDomParent = null == rootElement ? parentVNode : vCursorParent && vnode_getDomParentVNode(vCursorParent);
|
|
663
|
+
if (vCursorDomParent) {
|
|
664
|
+
const namespaceData = getNewElementNamespaceData(vCursorDomParent, vnode_getElementName(vCursor));
|
|
665
|
+
namespace = namespaceData.elementNamespace, namespaceFlag = namespaceData.elementNamespaceFlag;
|
|
666
|
+
}
|
|
667
|
+
newChildElement = cloneElementWithNamespace(childElement, childElementTag, namespace), childElement.remove(), null == rootElement && (rootElement = newChildElement), parentElement && parentElement.appendChild(newChildElement);
|
|
668
|
+
const vFirstChild = vnode_getFirstChild(vCursor);
|
|
669
|
+
if (vCursor[ElementVNodeProps.element] = newChildElement, vCursor[VNodeProps.flags] &= VNodeFlags.NEGATED_NAMESPACE_MASK, vCursor[VNodeProps.flags] |= namespaceFlag, vFirstChild) {
|
|
670
|
+
vCursor = vFirstChild, parentElement = newChildElement;
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
if (shouldIgnoreChildren(childElement)) {
|
|
674
|
+
const container = getDomContainerFromQContainerElement(childElement);
|
|
675
|
+
if (container) {
|
|
676
|
+
const innerContainerFirstVNode = vnode_getFirstChild(container.rootVNode);
|
|
677
|
+
if (innerContainerFirstVNode) {
|
|
678
|
+
vCursor = innerContainerFirstVNode, parentElement = newChildElement;
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (vCursor === elementVNode) {
|
|
685
|
+
return rootElement;
|
|
686
|
+
}
|
|
687
|
+
const vNextSibling = vnode_getNextSibling(vCursor);
|
|
688
|
+
if (vNextSibling) {
|
|
689
|
+
vCursor = vNextSibling;
|
|
690
|
+
} else {
|
|
691
|
+
for (vParent = vnode_getParent(vCursor); vParent; ) {
|
|
692
|
+
if (vParent === elementVNode) {
|
|
693
|
+
return rootElement;
|
|
694
|
+
}
|
|
695
|
+
const vNextParentSibling = vnode_getNextSibling(vParent);
|
|
696
|
+
if (vNextParentSibling) {
|
|
697
|
+
return vCursor = vNextParentSibling, rootElement;
|
|
698
|
+
}
|
|
699
|
+
vParent = vnode_getParent(vParent);
|
|
700
|
+
}
|
|
701
|
+
if (null == vParent) {
|
|
702
|
+
return rootElement;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return rootElement;
|
|
707
|
+
}
|
|
708
|
+
function isSvg(tagOrVNode) {
|
|
709
|
+
return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_svg);
|
|
710
|
+
}
|
|
711
|
+
function isMath(tagOrVNode) {
|
|
712
|
+
return "string" == typeof tagOrVNode ? isMathElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_math);
|
|
713
|
+
}
|
|
714
|
+
function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
|
|
715
|
+
const parentIsDefaultNamespace = !domParentVNode || !!vnode_getElementName(domParentVNode) && vnode_isDefaultNamespace(domParentVNode);
|
|
716
|
+
const parentIsForeignObject = !parentIsDefaultNamespace && isForeignObjectElement(vnode_getElementName(domParentVNode));
|
|
717
|
+
let elementNamespace = HTML_NS;
|
|
718
|
+
let elementNamespaceFlag = VNodeFlags.NS_html;
|
|
719
|
+
const isElementVNodeOrString = "string" == typeof tagOrVNode || vnode_isElementVNode(tagOrVNode);
|
|
720
|
+
if (isElementVNodeOrString && isSvg(tagOrVNode)) {
|
|
721
|
+
elementNamespace = SVG_NS, elementNamespaceFlag = VNodeFlags.NS_svg;
|
|
722
|
+
} else if (isElementVNodeOrString && isMath(tagOrVNode)) {
|
|
723
|
+
elementNamespace = MATH_NS, elementNamespaceFlag = VNodeFlags.NS_math;
|
|
724
|
+
} else if (domParentVNode && !parentIsForeignObject && !parentIsDefaultNamespace) {
|
|
725
|
+
elementNamespace = !!(domParentVNode[VNodeProps.flags] & VNodeFlags.NS_svg) ? SVG_NS : !!(domParentVNode[VNodeProps.flags] & VNodeFlags.NS_math) ? MATH_NS : HTML_NS, elementNamespaceFlag = domParentVNode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK;
|
|
726
|
+
}
|
|
727
|
+
return {
|
|
728
|
+
elementNamespace,
|
|
729
|
+
elementNamespaceFlag
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
|
|
733
|
+
const iCtx = newInvokeContext(container.$locale$, subscriptionHost || void 0, void 0, "qRender");
|
|
734
|
+
let componentFn;
|
|
735
|
+
subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, EffectProperty.COMPONENT), iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
|
|
736
|
+
let isInlineComponent = false;
|
|
737
|
+
if (null === componentQRL && assertDefined(componentQRL = container.getHostProp(renderHost, "q:renderFn")), isQrl$1(componentQRL)) {
|
|
738
|
+
(props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ).children && delete props.children, componentFn = componentQRL.getFn(iCtx);
|
|
739
|
+
} else if (isQwikComponent(componentQRL)) {
|
|
740
|
+
const qComponentFn = componentQRL;
|
|
741
|
+
componentFn = () => invokeApply(iCtx, qComponentFn, [props || EMPTY_OBJ, null, 0]);
|
|
742
|
+
} else {
|
|
743
|
+
isInlineComponent = true;
|
|
744
|
+
const inlineComponent = componentQRL;
|
|
745
|
+
componentFn = () => invokeApply(iCtx, inlineComponent, [props || EMPTY_OBJ]);
|
|
746
|
+
}
|
|
747
|
+
const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null), container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)), vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props)), (jsx2) => {
|
|
748
|
+
const useOnEvents = container.getHostProp(renderHost, ":on");
|
|
749
|
+
return useOnEvents ? addUseOnEvents(jsx2, useOnEvents) : jsx2;
|
|
750
|
+
}, (err) => {
|
|
751
|
+
if (isPromise(err) && retryCount < 100) {
|
|
752
|
+
return err.then(() => executeComponentWithPromiseExceptionRetry(retryCount++));
|
|
753
|
+
}
|
|
754
|
+
throw err;
|
|
755
|
+
});
|
|
756
|
+
return executeComponentWithPromiseExceptionRetry();
|
|
757
|
+
};
|
|
758
|
+
function addUseOnEvents(jsx2, useOnEvents) {
|
|
759
|
+
const jsxElement = findFirstStringJSX(jsx2);
|
|
760
|
+
let jsxResult = jsx2;
|
|
761
|
+
return maybeThen(jsxElement, (jsxElement2) => {
|
|
762
|
+
let isInvisibleComponent = false;
|
|
763
|
+
jsxElement2 || (isInvisibleComponent = true);
|
|
764
|
+
for (const key in useOnEvents) {
|
|
765
|
+
if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
|
|
766
|
+
if (isInvisibleComponent) {
|
|
767
|
+
if ("onQvisible$" === key) {
|
|
768
|
+
const [jsxElement3, jsx3] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
769
|
+
jsxResult = jsx3, jsxElement3 && addUseOnEvent(jsxElement3, "document:onQinit$", useOnEvents[key]);
|
|
770
|
+
} else if (key.startsWith("document:") || key.startsWith("window:")) {
|
|
771
|
+
const [jsxElement3, jsx3] = addScriptNodeForInvisibleComponents(jsxResult);
|
|
772
|
+
jsxResult = jsx3, jsxElement3 && addUseOnEvent(jsxElement3, key, useOnEvents[key]);
|
|
773
|
+
} else ;
|
|
774
|
+
} else {
|
|
775
|
+
jsxElement2 && addUseOnEvent(jsxElement2, key, useOnEvents[key]);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return jsxResult;
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
function addUseOnEvent(jsxElement, key, value) {
|
|
783
|
+
let props = jsxElement.props;
|
|
784
|
+
props === EMPTY_OBJ && (props = jsxElement.props = {});
|
|
785
|
+
let propValue = props[key];
|
|
786
|
+
void 0 === propValue ? propValue = [] : Array.isArray(propValue) || (propValue = [propValue]), propValue.push(...value), props[key] = propValue;
|
|
787
|
+
}
|
|
788
|
+
function findFirstStringJSX(jsx2) {
|
|
789
|
+
const queue = [jsx2];
|
|
790
|
+
for (; queue.length; ) {
|
|
791
|
+
const jsx3 = queue.shift();
|
|
792
|
+
if (isJSXNode(jsx3)) {
|
|
793
|
+
if ("string" == typeof jsx3.type) {
|
|
794
|
+
return jsx3;
|
|
795
|
+
}
|
|
796
|
+
queue.push(jsx3.children);
|
|
797
|
+
} else if (Array.isArray(jsx3)) {
|
|
798
|
+
queue.push(...jsx3);
|
|
799
|
+
} else {
|
|
800
|
+
if (isPromise(jsx3)) {
|
|
801
|
+
return maybeThen(jsx3, (jsx4) => findFirstStringJSX(jsx4));
|
|
802
|
+
}
|
|
803
|
+
if (isSignal(jsx3)) {
|
|
804
|
+
return findFirstStringJSX(untrack(() => jsx3.value));
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
return null;
|
|
809
|
+
}
|
|
810
|
+
function addScriptNodeForInvisibleComponents(jsx2) {
|
|
811
|
+
if (isJSXNode(jsx2)) {
|
|
812
|
+
const jsxElement = new JSXNodeImpl("script", {}, {
|
|
813
|
+
type: "placeholder",
|
|
814
|
+
hidden: ""
|
|
815
|
+
}, null, 3);
|
|
816
|
+
return jsx2.type === Slot ? [jsxElement, _jsxSorted(Fragment, null, null, [jsx2, jsxElement], 0, null)] : (null == jsx2.children ? jsx2.children = jsxElement : Array.isArray(jsx2.children) ? jsx2.children.push(jsxElement) : jsx2.children = [jsx2.children, jsxElement], [jsxElement, jsx2]);
|
|
817
|
+
}
|
|
818
|
+
if (Array.isArray(jsx2) && jsx2.length) {
|
|
819
|
+
const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx2[0]);
|
|
820
|
+
return [jsxElement, jsx2];
|
|
821
|
+
}
|
|
822
|
+
return [null, null];
|
|
823
|
+
}
|
|
824
|
+
const _CONST_PROPS = Symbol("CONST");
|
|
825
|
+
const _VAR_PROPS = Symbol("VAR");
|
|
826
|
+
function isSlotProp(prop) {
|
|
827
|
+
return !prop.startsWith("q:") && !prop.startsWith(":");
|
|
828
|
+
}
|
|
829
|
+
function escapeHTML(html) {
|
|
830
|
+
let escapedHTML = "";
|
|
831
|
+
const length = html.length;
|
|
832
|
+
let idx = 0;
|
|
833
|
+
let lastIdx = idx;
|
|
834
|
+
for (; idx < length; idx++) {
|
|
835
|
+
const ch = html.charCodeAt(idx);
|
|
836
|
+
if (60 === ch) {
|
|
837
|
+
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
838
|
+
} else if (62 === ch) {
|
|
839
|
+
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
840
|
+
} else if (38 === ch) {
|
|
841
|
+
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
842
|
+
} else if (34 === ch) {
|
|
843
|
+
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
844
|
+
} else {
|
|
845
|
+
if (39 !== ch) {
|
|
846
|
+
continue;
|
|
847
|
+
}
|
|
848
|
+
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
849
|
+
}
|
|
850
|
+
lastIdx = idx + 1;
|
|
851
|
+
}
|
|
852
|
+
return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
|
|
853
|
+
}
|
|
854
|
+
const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
855
|
+
let journal = container.$journal$;
|
|
856
|
+
const stack2 = [];
|
|
857
|
+
const asyncQueue = [];
|
|
858
|
+
let vParent = null;
|
|
859
|
+
let vCurrent = null;
|
|
860
|
+
let vNewNode = null;
|
|
861
|
+
let vSiblings = null;
|
|
862
|
+
let vSiblingsIdx = -1;
|
|
863
|
+
let jsxChildren = null;
|
|
864
|
+
let jsxValue = null;
|
|
865
|
+
let jsxIdx = 0;
|
|
866
|
+
let jsxCount = 0;
|
|
867
|
+
let shouldAdvance = true;
|
|
868
|
+
return diff(jsxNode, vStartNode), function drainAsyncQueue() {
|
|
869
|
+
for (; asyncQueue.length; ) {
|
|
870
|
+
const jsxNode2 = asyncQueue.shift();
|
|
871
|
+
const vHostNode = asyncQueue.shift();
|
|
872
|
+
if (isPromise(jsxNode2)) {
|
|
873
|
+
return jsxNode2.then((jsxNode3) => (diff(jsxNode3, vHostNode), drainAsyncQueue()));
|
|
874
|
+
}
|
|
875
|
+
diff(jsxNode2, vHostNode);
|
|
876
|
+
}
|
|
877
|
+
}();
|
|
878
|
+
function diff(jsxNode2, vStartNode2) {
|
|
879
|
+
for (vParent = vStartNode2, vNewNode = null, vCurrent = vnode_getFirstChild(vStartNode2), stackPush(jsxNode2, true); stack2.length; ) {
|
|
880
|
+
for (; jsxIdx < jsxCount; ) {
|
|
881
|
+
if ("string" == typeof jsxValue) {
|
|
882
|
+
expectText(jsxValue);
|
|
883
|
+
} else if ("number" == typeof jsxValue) {
|
|
884
|
+
expectText(String(jsxValue));
|
|
885
|
+
} else if (jsxValue && "object" == typeof jsxValue) {
|
|
886
|
+
if (Array.isArray(jsxValue)) {
|
|
887
|
+
descend(jsxValue, false);
|
|
888
|
+
} else if (isSignal(jsxValue)) {
|
|
889
|
+
vCurrent && clearAllEffects(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null), descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), true);
|
|
890
|
+
} else if (isPromise(jsxValue)) {
|
|
891
|
+
expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
|
|
892
|
+
} else if (isJSXNode(jsxValue)) {
|
|
893
|
+
const type = jsxValue.type;
|
|
894
|
+
"string" == typeof type ? (expectNoMoreTextNodes(), expectElement(jsxValue, type), descend(jsxValue.children, true)) : "function" == typeof type && (type === Fragment ? (expectNoMoreTextNodes(), expectVirtual(VirtualType.Fragment, jsxValue.key), descend(jsxValue.children, true)) : type === Slot ? (expectNoMoreTextNodes(), expectSlot() || descend(jsxValue.children, true)) : type === Projection ? (expectProjection(), descend(jsxValue.children, true)) : type === SSRComment || type === SSRRaw ? expectNoMore() : (expectNoMoreTextNodes(), expectComponent(type)));
|
|
895
|
+
}
|
|
896
|
+
} else {
|
|
897
|
+
jsxValue === SkipRender ? journal = [] : expectText("");
|
|
898
|
+
}
|
|
899
|
+
advance();
|
|
900
|
+
}
|
|
901
|
+
expectNoMore(), ascend();
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function advance() {
|
|
905
|
+
if (shouldAdvance) {
|
|
906
|
+
if (jsxIdx++, jsxIdx < jsxCount) {
|
|
907
|
+
jsxValue = jsxChildren[jsxIdx];
|
|
908
|
+
} else if (false === stack2[stack2.length - 1]) {
|
|
909
|
+
return ascend();
|
|
910
|
+
}
|
|
911
|
+
null !== vNewNode ? vNewNode = null : advanceToNextSibling();
|
|
912
|
+
} else {
|
|
913
|
+
shouldAdvance = true;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
function peekNextSibling() {
|
|
917
|
+
if (null !== vSiblings) {
|
|
918
|
+
const idx = vSiblingsIdx + SiblingsArray.NextVNode;
|
|
919
|
+
return idx < vSiblings.length ? vSiblings[idx] : null;
|
|
920
|
+
}
|
|
921
|
+
return vCurrent ? vnode_getNextSibling(vCurrent) : null;
|
|
922
|
+
}
|
|
923
|
+
function advanceToNextSibling() {
|
|
924
|
+
vCurrent = peekNextSibling(), null !== vSiblings && (vSiblingsIdx += SiblingsArray.Size);
|
|
925
|
+
}
|
|
926
|
+
function descend(children, descendVNode) {
|
|
927
|
+
null != children ? (stackPush(children, descendVNode), descendVNode && (vSiblings = null, vSiblingsIdx = -1, vParent = vNewNode || vCurrent, vCurrent = vnode_getFirstChild(vParent), vNewNode = null), shouldAdvance = false) : function() {
|
|
928
|
+
const vFirstChild = vCurrent && vnode_getFirstChild(vCurrent);
|
|
929
|
+
if (null !== vFirstChild) {
|
|
930
|
+
let vChild = vFirstChild;
|
|
931
|
+
for (; vChild; ) {
|
|
932
|
+
cleanup(container, vChild), vChild = vnode_getNextSibling(vChild);
|
|
933
|
+
}
|
|
934
|
+
vnode_truncate(journal, vCurrent, vFirstChild);
|
|
935
|
+
}
|
|
936
|
+
}();
|
|
937
|
+
}
|
|
938
|
+
function ascend() {
|
|
939
|
+
stack2.pop() && (vSiblingsIdx = stack2.pop(), vSiblings = stack2.pop(), vNewNode = stack2.pop(), vCurrent = stack2.pop(), vParent = stack2.pop()), jsxValue = stack2.pop(), jsxCount = stack2.pop(), jsxIdx = stack2.pop(), jsxChildren = stack2.pop(), advance();
|
|
940
|
+
}
|
|
941
|
+
function stackPush(children, descendVNode) {
|
|
942
|
+
stack2.push(jsxChildren, jsxIdx, jsxCount, jsxValue), descendVNode && stack2.push(vParent, vCurrent, vNewNode, vSiblings, vSiblingsIdx), stack2.push(descendVNode), Array.isArray(children) ? (jsxIdx = 0, jsxCount = children.length, jsxChildren = children, jsxValue = jsxCount > 0 ? children[0] : null) : void 0 === children ? (jsxIdx = 0, jsxValue = null, jsxChildren = null, jsxCount = 0) : (jsxIdx = 0, jsxValue = children, jsxChildren = null, jsxCount = 1);
|
|
943
|
+
}
|
|
944
|
+
function getInsertBefore() {
|
|
945
|
+
if (vNewNode) {
|
|
946
|
+
return vCurrent;
|
|
947
|
+
}
|
|
948
|
+
if (null !== vSiblings) {
|
|
949
|
+
const nextIdx = vSiblingsIdx + SiblingsArray.NextVNode;
|
|
950
|
+
return nextIdx < vSiblings.length ? vSiblings[nextIdx] : null;
|
|
951
|
+
}
|
|
952
|
+
return peekNextSibling();
|
|
953
|
+
}
|
|
954
|
+
function expectProjection() {
|
|
955
|
+
const slotName = jsxValue.key;
|
|
956
|
+
vCurrent = vnode_getProp(vParent, slotName, (id) => vnode_locate(container.rootVNode, id)), vCurrent = vCurrent && vCurrent[VNodeProps.flags] & VNodeFlags.Deleted ? null : vCurrent, null == vCurrent && (vNewNode = vnode_newVirtual(), vnode_setProp(vNewNode, QSlot, slotName), vnode_setProp(vNewNode, "q:sparent", vParent), vnode_setProp(vParent, slotName, vNewNode));
|
|
957
|
+
}
|
|
958
|
+
function expectSlot() {
|
|
959
|
+
const vHost = vnode_getProjectionParentComponent(vParent, container.rootVNode);
|
|
960
|
+
const slotNameKey = function(vHost2) {
|
|
961
|
+
const jsxNode2 = jsxValue;
|
|
962
|
+
const constProps = jsxNode2.constProps;
|
|
963
|
+
if (constProps && "object" == typeof constProps && "name" in constProps) {
|
|
964
|
+
const constValue = constProps.name;
|
|
965
|
+
if (vHost2 && constValue instanceof WrappedSignal) {
|
|
966
|
+
return trackSignalAndAssignHost(constValue, vHost2, EffectProperty.COMPONENT, container);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return directGetPropsProxyProp(jsxNode2, "name") || "";
|
|
970
|
+
}(vHost);
|
|
971
|
+
const vProjectedNode = vHost ? vnode_getProp(vHost, slotNameKey, null) : null;
|
|
972
|
+
if (null == vProjectedNode) {
|
|
973
|
+
return vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()), vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode), false;
|
|
974
|
+
}
|
|
975
|
+
if (vProjectedNode === vCurrent) ;
|
|
976
|
+
else {
|
|
977
|
+
const parent = vnode_getParent(vProjectedNode);
|
|
978
|
+
!(!parent || vnode_isElementVNode(parent) && vnode_getElementName(parent) === QTemplate) && vParent !== parent && vnode_remove(journal, parent, vProjectedNode, false), vnode_insertBefore(journal, vParent, vNewNode = vProjectedNode, vCurrent && getInsertBefore()), vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode);
|
|
979
|
+
}
|
|
980
|
+
return true;
|
|
981
|
+
}
|
|
982
|
+
function expectNoMore() {
|
|
983
|
+
if (null !== vCurrent) {
|
|
984
|
+
for (; vCurrent; ) {
|
|
985
|
+
const toRemove = vCurrent;
|
|
986
|
+
advanceToNextSibling(), vParent === vnode_getParent(toRemove) && (cleanup(container, toRemove), vnode_remove(journal, vParent, toRemove, true));
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function expectNoMoreTextNodes() {
|
|
991
|
+
for (; null !== vCurrent && vnode_isTextVNode(vCurrent); ) {
|
|
992
|
+
cleanup(container, vCurrent);
|
|
993
|
+
const toRemove = vCurrent;
|
|
994
|
+
advanceToNextSibling(), vnode_remove(journal, vParent, toRemove, true);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function createNewElement(jsx2, elementName, currentFile) {
|
|
998
|
+
const element = function(elementName2) {
|
|
999
|
+
const domParentVNode = vnode_getDomParentVNode(vParent);
|
|
1000
|
+
const { elementNamespace, elementNamespaceFlag } = getNewElementNamespaceData(domParentVNode, elementName2);
|
|
1001
|
+
const element2 = container.document.createElementNS(elementNamespace, elementName2);
|
|
1002
|
+
return vNewNode = vnode_newElement(element2, elementName2), vNewNode[VNodeProps.flags] |= elementNamespaceFlag, element2;
|
|
1003
|
+
}(elementName);
|
|
1004
|
+
const { constProps } = jsx2;
|
|
1005
|
+
let needsQDispatchEventPatch = false;
|
|
1006
|
+
if (constProps) {
|
|
1007
|
+
for (const key2 in constProps) {
|
|
1008
|
+
let value = constProps[key2];
|
|
1009
|
+
if (isJsxPropertyAnEventName(key2)) {
|
|
1010
|
+
const eventName = getEventNameFromJsxProp(key2);
|
|
1011
|
+
const scope = getEventNameScopeFromJsxProp(key2);
|
|
1012
|
+
if (eventName && (vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)), scope) {
|
|
1013
|
+
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
|
|
1014
|
+
htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
|
|
1015
|
+
}
|
|
1016
|
+
needsQDispatchEventPatch = true;
|
|
1017
|
+
} else {
|
|
1018
|
+
if ("ref" === key2) {
|
|
1019
|
+
if (isSignal(value)) {
|
|
1020
|
+
value.value = element;
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1023
|
+
if ("function" == typeof value) {
|
|
1024
|
+
value(element);
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
1027
|
+
if (null == value) {
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
throw qError(QError.invalidRefValue, [currentFile]);
|
|
1031
|
+
}
|
|
1032
|
+
if (isSignal(value)) {
|
|
1033
|
+
const signalData = new SubscriptionData({
|
|
1034
|
+
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1035
|
+
$isConst$: true
|
|
1036
|
+
});
|
|
1037
|
+
value = trackSignalAndAssignHost(value, vNewNode, key2, container, signalData);
|
|
1038
|
+
}
|
|
1039
|
+
if (key2 !== dangerouslySetInnerHTML) {
|
|
1040
|
+
if ("textarea" !== elementName || "value" !== key2) {
|
|
1041
|
+
value = serializeAttribute(key2, value, scopedStyleIdPrefix), null != value && element.setAttribute(key2, String(value));
|
|
1042
|
+
} else {
|
|
1043
|
+
if (value && "string" != typeof value) {
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
element.value = escapeHTML(value || "");
|
|
1047
|
+
}
|
|
1048
|
+
} else {
|
|
1049
|
+
element.innerHTML = value, element.setAttribute("q:container", QContainerValue.HTML);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
const key = jsx2.key;
|
|
1055
|
+
key && (element.setAttribute("q:key", key), vnode_setProp(vNewNode, "q:key", key));
|
|
1056
|
+
return !(hasClassAttr(jsx2.varProps) || jsx2.constProps && hasClassAttr(jsx2.constProps)) && scopedStyleIdPrefix && element.setAttribute("class", scopedStyleIdPrefix), vnode_insertBefore(journal, vParent, vNewNode, vCurrent), needsQDispatchEventPatch;
|
|
1057
|
+
}
|
|
1058
|
+
function expectElement(jsx2, elementName) {
|
|
1059
|
+
const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
|
|
1060
|
+
const jsxKey = jsx2.key;
|
|
1061
|
+
let needsQDispatchEventPatch = false;
|
|
1062
|
+
const currentFile = getFileLocationFromJsx(jsx2.dev);
|
|
1063
|
+
isSameElementName && jsxKey === getKey(vCurrent) || (vNewNode = retrieveChildWithKey(elementName, jsxKey), null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx2, elementName) : (vnode_insertBefore(journal, vParent, vNewNode, vCurrent), vCurrent = vNewNode, vNewNode = null, null !== vSiblings && (vSiblingsIdx -= SiblingsArray.Size)));
|
|
1064
|
+
const jsxAttrs = [];
|
|
1065
|
+
const props = jsx2.varProps;
|
|
1066
|
+
for (const key in props) {
|
|
1067
|
+
const value = props[key];
|
|
1068
|
+
null != value && mapArray_set(jsxAttrs, key, value, 0);
|
|
1069
|
+
}
|
|
1070
|
+
null !== jsxKey && mapArray_set(jsxAttrs, "q:key", jsxKey, 0);
|
|
1071
|
+
const vNode = vNewNode || vCurrent;
|
|
1072
|
+
if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile2) {
|
|
1073
|
+
vnode_ensureElementInflated(vnode);
|
|
1074
|
+
const dstAttrs = vnode_getProps(vnode);
|
|
1075
|
+
let srcIdx = 0;
|
|
1076
|
+
const srcLength = srcAttrs.length;
|
|
1077
|
+
let dstIdx = 0;
|
|
1078
|
+
let dstLength = dstAttrs.length;
|
|
1079
|
+
let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
|
|
1080
|
+
let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
1081
|
+
let patchEventDispatch = false;
|
|
1082
|
+
const record = (key, value) => {
|
|
1083
|
+
if (key.startsWith(":")) {
|
|
1084
|
+
vnode_setProp(vnode, key, value);
|
|
1085
|
+
} else {
|
|
1086
|
+
if ("ref" === key) {
|
|
1087
|
+
const element = vnode_getNode(vnode);
|
|
1088
|
+
if (isSignal(value)) {
|
|
1089
|
+
return void (value.value = element);
|
|
1090
|
+
}
|
|
1091
|
+
if ("function" == typeof value) {
|
|
1092
|
+
return void value(element);
|
|
1093
|
+
}
|
|
1094
|
+
if (null == value) {
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
throw qError(QError.invalidRefValue, [currentFile2]);
|
|
1098
|
+
}
|
|
1099
|
+
if (isSignal(value)) {
|
|
1100
|
+
const signalData = new SubscriptionData({
|
|
1101
|
+
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
1102
|
+
$isConst$: false
|
|
1103
|
+
});
|
|
1104
|
+
value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
|
|
1105
|
+
}
|
|
1106
|
+
vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix)), null === value && (dstLength = dstAttrs.length);
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
const recordJsxEvent = (key, value) => {
|
|
1110
|
+
const eventName = getEventNameFromJsxProp(key);
|
|
1111
|
+
const scope = getEventNameScopeFromJsxProp(key);
|
|
1112
|
+
if (eventName && (record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)), scope) {
|
|
1113
|
+
const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
|
|
1114
|
+
htmlEvent && record(htmlEvent, "");
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
for (; null !== srcKey || null !== dstKey; ) {
|
|
1118
|
+
if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
|
|
1119
|
+
dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
1120
|
+
} else if (null == srcKey) {
|
|
1121
|
+
dstKey && isHtmlAttributeAnEventName(dstKey) ? (patchEventDispatch = true, dstIdx++) : (record(dstKey, null), dstIdx--), dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
1122
|
+
} else if (null == dstKey) {
|
|
1123
|
+
isJsxPropertyAnEventName(srcKey) ? (patchEventDispatch = true, recordJsxEvent(srcKey, srcAttrs[srcIdx])) : record(srcKey, srcAttrs[srcIdx]), srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
1124
|
+
} else if (srcKey == dstKey) {
|
|
1125
|
+
const srcValue = srcAttrs[srcIdx++];
|
|
1126
|
+
srcValue !== dstAttrs[dstIdx++] && record(dstKey, srcValue), srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
|
|
1127
|
+
} else {
|
|
1128
|
+
srcKey < dstKey ? (isJsxPropertyAnEventName(srcKey) ? (patchEventDispatch = true, recordJsxEvent(srcKey, srcAttrs[srcIdx])) : record(srcKey, srcAttrs[srcIdx]), srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null) : (isHtmlAttributeAnEventName(dstKey) ? (patchEventDispatch = true, dstIdx++) : (record(dstKey, null), dstIdx--), dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return patchEventDispatch;
|
|
1132
|
+
}(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch, needsQDispatchEventPatch) {
|
|
1133
|
+
const element = vnode_getNode(vNode);
|
|
1134
|
+
element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
|
|
1135
|
+
const eventName = event.type;
|
|
1136
|
+
const eventProp = ":" + scope.substring(1) + ":" + eventName;
|
|
1137
|
+
const qrls = [vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null)];
|
|
1138
|
+
let returnValue = false;
|
|
1139
|
+
return qrls.flat(2).forEach((qrl2) => {
|
|
1140
|
+
if (qrl2) {
|
|
1141
|
+
const value = container.$scheduler$(ChoreType.RUN_QRL, vNode, qrl2, [event, element]);
|
|
1142
|
+
returnValue = returnValue || true === value;
|
|
1143
|
+
}
|
|
1144
|
+
}), returnValue;
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
function registerQwikLoaderEvent(eventName) {
|
|
1149
|
+
const window2 = container.document.defaultView;
|
|
1150
|
+
window2 && (window2.qwikevents || (window2.qwikevents = [])).push(eventName);
|
|
1151
|
+
}
|
|
1152
|
+
function retrieveChildWithKey(nodeName, key) {
|
|
1153
|
+
let vNodeWithKey = null;
|
|
1154
|
+
if (-1 === vSiblingsIdx) {
|
|
1155
|
+
vSiblings = [], vSiblingsIdx = 0;
|
|
1156
|
+
let vNode = vCurrent;
|
|
1157
|
+
for (; vNode; ) {
|
|
1158
|
+
const name = vnode_isElementVNode(vNode) ? vnode_getElementName(vNode) : null;
|
|
1159
|
+
const vKey = getKey(vNode) || getComponentHash(vNode, container.$getObjectById$);
|
|
1160
|
+
null === vNodeWithKey && vKey == key && name == nodeName ? vNodeWithKey = vNode : vSiblings.push(name, vKey, vNode), vNode = vnode_getNextSibling(vNode);
|
|
1161
|
+
}
|
|
1162
|
+
} else {
|
|
1163
|
+
for (let idx = vSiblingsIdx; idx < vSiblings.length; idx += SiblingsArray.Size) {
|
|
1164
|
+
if (vSiblings[idx + SiblingsArray.Key] === key && vSiblings[idx + SiblingsArray.Name] === nodeName) {
|
|
1165
|
+
vNodeWithKey = vSiblings[idx + SiblingsArray.VNode], vSiblings?.splice(idx, SiblingsArray.Size);
|
|
1166
|
+
break;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return vNodeWithKey;
|
|
1171
|
+
}
|
|
1172
|
+
function expectVirtual(type, jsxKey) {
|
|
1173
|
+
vCurrent && vnode_isVirtualVNode(vCurrent) && getKey(vCurrent) === jsxKey || (null === jsxKey || (vNewNode = retrieveChildWithKey(null, jsxKey), null == vNewNode) ? (vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()), vnode_setProp(vNewNode, "q:key", jsxKey), isDev) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent && getInsertBefore()));
|
|
1174
|
+
}
|
|
1175
|
+
function expectComponent(component) {
|
|
1176
|
+
const componentMeta = component[SERIALIZABLE_STATE];
|
|
1177
|
+
let host = vNewNode || vCurrent;
|
|
1178
|
+
const jsxNode2 = jsxValue;
|
|
1179
|
+
if (componentMeta) {
|
|
1180
|
+
const jsxProps = jsxNode2.props;
|
|
1181
|
+
let shouldRender = false;
|
|
1182
|
+
const [componentQRL] = componentMeta;
|
|
1183
|
+
const componentHash = componentQRL.$hash$;
|
|
1184
|
+
const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
|
|
1185
|
+
const lookupKey = jsxNode2.key || componentHash;
|
|
1186
|
+
if (lookupKey === (getKey(host) || vNodeComponentHash) ? componentHash === vNodeComponentHash || (insertNewComponent(host, componentQRL, jsxProps), host = vNewNode, shouldRender = true) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps), host = vNewNode, shouldRender = true), host) {
|
|
1187
|
+
const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
|
|
1188
|
+
shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps), shouldRender && (host[VNodeProps.flags] &= ~VNodeFlags.Deleted, container.$scheduler$(ChoreType.COMPONENT, host, componentQRL, jsxProps));
|
|
1189
|
+
}
|
|
1190
|
+
!function(children, host2) {
|
|
1191
|
+
const projectionChildren = Array.isArray(children) ? children : [children];
|
|
1192
|
+
const createProjectionJSXNode = (slotName) => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
|
|
1193
|
+
const projections = [];
|
|
1194
|
+
if (host2) {
|
|
1195
|
+
const props = vnode_getProps(host2);
|
|
1196
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
1197
|
+
const prop = props[i];
|
|
1198
|
+
if (isSlotProp(prop)) {
|
|
1199
|
+
const slotName = prop;
|
|
1200
|
+
projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (0 !== projections.length || null != children) {
|
|
1205
|
+
for (let i = 0; i < projectionChildren.length; i++) {
|
|
1206
|
+
const child = projectionChildren[i];
|
|
1207
|
+
const slotName = String(isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || "");
|
|
1208
|
+
const idx = mapApp_findIndx(projections, slotName, 0);
|
|
1209
|
+
let jsxBucket;
|
|
1210
|
+
idx >= 0 ? jsxBucket = projections[idx + 1] : projections.splice(~idx, 0, slotName, jsxBucket = createProjectionJSXNode(slotName)), false === child || jsxBucket.children.push(child);
|
|
1211
|
+
}
|
|
1212
|
+
for (let i = projections.length - 2; i >= 0; i -= 2) {
|
|
1213
|
+
projections.splice(i, 1);
|
|
1214
|
+
}
|
|
1215
|
+
descend(projections, true);
|
|
1216
|
+
}
|
|
1217
|
+
}(jsxNode2.children, host);
|
|
1218
|
+
} else {
|
|
1219
|
+
const lookupKey = jsxNode2.key;
|
|
1220
|
+
const lookupKeysAreEqual = lookupKey === getKey(host);
|
|
1221
|
+
const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
|
|
1222
|
+
if (lookupKeysAreEqual ? null != vNodeComponentHash && (insertNewInlineComponent(), host = vNewNode) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewInlineComponent(), host = vNewNode), host) {
|
|
1223
|
+
let componentHost = host;
|
|
1224
|
+
for (; componentHost && (!vnode_isVirtualVNode(componentHost) || null === vnode_getProp(componentHost, "q:renderFn", null)); ) {
|
|
1225
|
+
componentHost = vnode_getParent(componentHost);
|
|
1226
|
+
}
|
|
1227
|
+
const jsxOutput = executeComponent(container, host, componentHost || container.rootVNode, component, jsxNode2.props);
|
|
1228
|
+
asyncQueue.push(jsxOutput, host);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
function insertNewComponent(host, componentQRL, jsxProps) {
|
|
1233
|
+
host && clearAllEffects(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1234
|
+
const jsxNode2 = jsxValue;
|
|
1235
|
+
container.setHostProp(vNewNode, "q:renderFn", componentQRL), container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode2.key);
|
|
1236
|
+
}
|
|
1237
|
+
function insertNewInlineComponent() {
|
|
1238
|
+
vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
|
|
1239
|
+
const jsxNode2 = jsxValue;
|
|
1240
|
+
vnode_setProp(vNewNode, "q:props", jsxNode2.props), jsxNode2.key && vnode_setProp(vNewNode, "q:key", jsxNode2.key);
|
|
1241
|
+
}
|
|
1242
|
+
function expectText(text) {
|
|
1243
|
+
if (null !== vCurrent) {
|
|
1244
|
+
if (3 === vnode_getType(vCurrent)) {
|
|
1245
|
+
return text !== vnode_getText(vCurrent) ? void vnode_setText(journal, vCurrent, text) : void 0;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
vnode_insertBefore(journal, vParent, vNewNode = vnode_newText(container.document.createTextNode(text), text), vCurrent);
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
function getKey(vNode) {
|
|
1252
|
+
return null == vNode ? null : vnode_getProp(vNode, "q:key", null);
|
|
1253
|
+
}
|
|
1254
|
+
function getComponentHash(vNode, getObject) {
|
|
1255
|
+
if (null == vNode) {
|
|
1256
|
+
return null;
|
|
1257
|
+
}
|
|
1258
|
+
const qrl2 = vnode_getProp(vNode, "q:renderFn", getObject);
|
|
1259
|
+
return qrl2 ? qrl2.$hash$ : null;
|
|
1260
|
+
}
|
|
1261
|
+
function Projection() {
|
|
1262
|
+
}
|
|
1263
|
+
function propsDiffer(src, dst) {
|
|
1264
|
+
if (!src || !dst) {
|
|
1265
|
+
return true;
|
|
1266
|
+
}
|
|
1267
|
+
let srcKeys = removePropsKeys(Object.keys(src), ["children", "q:brefs"]);
|
|
1268
|
+
let dstKeys = removePropsKeys(Object.keys(dst), ["children", "q:brefs"]);
|
|
1269
|
+
if (srcKeys.length !== dstKeys.length) {
|
|
1270
|
+
return true;
|
|
1271
|
+
}
|
|
1272
|
+
srcKeys = srcKeys.sort(), dstKeys = dstKeys.sort();
|
|
1273
|
+
for (let idx = 0; idx < srcKeys.length; idx++) {
|
|
1274
|
+
const srcKey = srcKeys[idx];
|
|
1275
|
+
const dstKey = dstKeys[idx];
|
|
1276
|
+
if (srcKey !== dstKey || src[srcKey] !== dst[dstKey]) {
|
|
1277
|
+
return true;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
return false;
|
|
1281
|
+
}
|
|
1282
|
+
function removePropsKeys(keys, propKeys) {
|
|
1283
|
+
for (let i = propKeys.length - 1; i >= 0; i--) {
|
|
1284
|
+
const propIdx = keys.indexOf(propKeys[i]);
|
|
1285
|
+
-1 !== propIdx && keys.splice(propIdx, 1);
|
|
1286
|
+
}
|
|
1287
|
+
return keys;
|
|
1288
|
+
}
|
|
1289
|
+
function cleanup(container, vNode) {
|
|
1290
|
+
let vCursor = vNode;
|
|
1291
|
+
if (vnode_isTextVNode(vNode)) {
|
|
1292
|
+
return void markVNodeAsDeleted(vCursor);
|
|
1293
|
+
}
|
|
1294
|
+
let vParent = null;
|
|
1295
|
+
for (; ; ) {
|
|
1296
|
+
const type = vCursor[VNodeProps.flags];
|
|
1297
|
+
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
1298
|
+
if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), type & VNodeFlags.Virtual) {
|
|
1299
|
+
const seq = container.getHostProp(vCursor, "q:seq");
|
|
1300
|
+
if (seq) {
|
|
1301
|
+
for (let i = 0; i < seq.length; i++) {
|
|
1302
|
+
const obj = seq[i];
|
|
1303
|
+
if (isTask(obj)) {
|
|
1304
|
+
const task = obj;
|
|
1305
|
+
clearAllEffects(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, "q:renderFn", null)) {
|
|
1311
|
+
const attrs = vnode_getProps(vCursor);
|
|
1312
|
+
for (let i = 0; i < attrs.length; i += 2) {
|
|
1313
|
+
if (isSlotProp(attrs[i])) {
|
|
1314
|
+
const value = attrs[i + 1];
|
|
1315
|
+
if (value) {
|
|
1316
|
+
attrs[i + 1] = null;
|
|
1317
|
+
const projection = "string" == typeof value ? vnode_locate(container.rootVNode, value) : value;
|
|
1318
|
+
let projectionChild = vnode_getFirstChild(projection);
|
|
1319
|
+
for (; projectionChild; ) {
|
|
1320
|
+
cleanup(container, projectionChild), projectionChild = vnode_getNextSibling(projectionChild);
|
|
1321
|
+
}
|
|
1322
|
+
cleanupStaleUnclaimedProjection(container.$journal$, projection);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
if (vnode_isProjection(vCursor)) {
|
|
1328
|
+
if (vCursor === vNode) {
|
|
1329
|
+
const vFirstChild = vnode_getFirstChild(vCursor);
|
|
1330
|
+
if (vFirstChild) {
|
|
1331
|
+
return void vnode_walkVNode(vFirstChild);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
} else {
|
|
1335
|
+
const vFirstChild = vnode_getFirstChild(vCursor);
|
|
1336
|
+
if (vFirstChild) {
|
|
1337
|
+
vCursor = vFirstChild;
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
} else {
|
|
1342
|
+
type & VNodeFlags.Text && markVNodeAsDeleted(vCursor);
|
|
1343
|
+
}
|
|
1344
|
+
if (vCursor === vNode) {
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
const vNextSibling = vnode_getNextSibling(vCursor);
|
|
1348
|
+
if (vNextSibling) {
|
|
1349
|
+
vCursor = vNextSibling;
|
|
1350
|
+
} else {
|
|
1351
|
+
for (vParent = vnode_getParent(vCursor); vParent; ) {
|
|
1352
|
+
if (vParent === vNode) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
const vNextParentSibling = vnode_getNextSibling(vParent);
|
|
1356
|
+
if (vNextParentSibling) {
|
|
1357
|
+
vCursor = vNextParentSibling;
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
vParent = vnode_getParent(vParent);
|
|
1361
|
+
}
|
|
1362
|
+
if (null == vParent) {
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
69
1366
|
}
|
|
70
1367
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
1368
|
+
function cleanupStaleUnclaimedProjection(journal, projection) {
|
|
1369
|
+
const projectionParent = vnode_getParent(projection);
|
|
1370
|
+
if (projectionParent) {
|
|
1371
|
+
projectionParent[VNodeProps.flags] & VNodeFlags.Element && vnode_getElementName(projectionParent) === QTemplate && vnode_remove(journal, projectionParent, projection, true);
|
|
1372
|
+
}
|
|
73
1373
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var TextVNodeProps;
|
|
79
|
-
var VirtualVNodeProps;
|
|
80
|
-
!function(VNodeFlags2) {
|
|
81
|
-
VNodeFlags2[VNodeFlags2.Element = 1] = "Element", VNodeFlags2[VNodeFlags2.Virtual = 2] = "Virtual", VNodeFlags2[VNodeFlags2.ELEMENT_OR_VIRTUAL_MASK = 3] = "ELEMENT_OR_VIRTUAL_MASK", VNodeFlags2[VNodeFlags2.ELEMENT_OR_TEXT_MASK = 5] = "ELEMENT_OR_TEXT_MASK", VNodeFlags2[VNodeFlags2.TYPE_MASK = 7] = "TYPE_MASK", VNodeFlags2[VNodeFlags2.INFLATED_TYPE_MASK = 15] = "INFLATED_TYPE_MASK", VNodeFlags2[VNodeFlags2.Text = 4] = "Text", VNodeFlags2[VNodeFlags2.Inflated = 8] = "Inflated", VNodeFlags2[VNodeFlags2.Resolved = 16] = "Resolved", VNodeFlags2[VNodeFlags2.Deleted = 32] = "Deleted", VNodeFlags2[VNodeFlags2.NAMESPACE_MASK = 192] = "NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NEGATED_NAMESPACE_MASK = -193] = "NEGATED_NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NS_html = 0] = "NS_html", VNodeFlags2[VNodeFlags2.NS_svg = 64] = "NS_svg", VNodeFlags2[VNodeFlags2.NS_math = 128] = "NS_math";
|
|
82
|
-
}(VNodeFlags || (VNodeFlags = {})), function(VNodeFlagsIndex2) {
|
|
83
|
-
VNodeFlagsIndex2[VNodeFlagsIndex2.mask = -256] = "mask", VNodeFlagsIndex2[VNodeFlagsIndex2.negated_mask = 255] = "negated_mask", VNodeFlagsIndex2[VNodeFlagsIndex2.shift = 8] = "shift";
|
|
84
|
-
}(VNodeFlagsIndex || (VNodeFlagsIndex = {})), function(VNodeProps2) {
|
|
85
|
-
VNodeProps2[VNodeProps2.flags = 0] = "flags", VNodeProps2[VNodeProps2.parent = 1] = "parent", VNodeProps2[VNodeProps2.previousSibling = 2] = "previousSibling", VNodeProps2[VNodeProps2.nextSibling = 3] = "nextSibling";
|
|
86
|
-
}(VNodeProps || (VNodeProps = {})), function(ElementVNodeProps2) {
|
|
87
|
-
ElementVNodeProps2[ElementVNodeProps2.firstChild = 4] = "firstChild", ElementVNodeProps2[ElementVNodeProps2.lastChild = 5] = "lastChild", ElementVNodeProps2[ElementVNodeProps2.element = 6] = "element", ElementVNodeProps2[ElementVNodeProps2.elementName = 7] = "elementName", ElementVNodeProps2[ElementVNodeProps2.PROPS_OFFSET = 8] = "PROPS_OFFSET";
|
|
88
|
-
}(ElementVNodeProps || (ElementVNodeProps = {})), function(TextVNodeProps2) {
|
|
89
|
-
TextVNodeProps2[TextVNodeProps2.node = 4] = "node", TextVNodeProps2[TextVNodeProps2.text = 5] = "text";
|
|
90
|
-
}(TextVNodeProps || (TextVNodeProps = {})), function(VirtualVNodeProps2) {
|
|
91
|
-
VirtualVNodeProps2[VirtualVNodeProps2.firstChild = 4] = "firstChild", VirtualVNodeProps2[VirtualVNodeProps2.lastChild = 5] = "lastChild", VirtualVNodeProps2[VirtualVNodeProps2.PROPS_OFFSET = 6] = "PROPS_OFFSET";
|
|
92
|
-
}(VirtualVNodeProps || (VirtualVNodeProps = {}));
|
|
1374
|
+
function markVNodeAsDeleted(vCursor) {
|
|
1375
|
+
vCursor[VNodeProps.flags] |= VNodeFlags.Deleted;
|
|
1376
|
+
}
|
|
1377
|
+
const HANDLER_PREFIX = ":";
|
|
93
1378
|
var SiblingsArray;
|
|
94
1379
|
!function(SiblingsArray2) {
|
|
95
1380
|
SiblingsArray2[SiblingsArray2.Name = 0] = "Name", SiblingsArray2[SiblingsArray2.Key = 1] = "Key", SiblingsArray2[SiblingsArray2.VNode = 2] = "VNode", SiblingsArray2[SiblingsArray2.Size = 3] = "Size", SiblingsArray2[SiblingsArray2.NextVNode = 5] = "NextVNode";
|
|
96
1381
|
}(SiblingsArray || (SiblingsArray = {}));
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
1382
|
+
const _createResourceReturn = (opts) => ({
|
|
1383
|
+
__brand: "resource",
|
|
1384
|
+
value: void 0,
|
|
1385
|
+
loading: !isServerPlatform(),
|
|
1386
|
+
_resolved: void 0,
|
|
1387
|
+
_error: void 0,
|
|
1388
|
+
_state: "pending",
|
|
1389
|
+
_timeout: -1,
|
|
1390
|
+
_cache: 0
|
|
1391
|
+
});
|
|
1392
|
+
const createResourceReturn = (container, opts, initialPromise) => {
|
|
1393
|
+
const result = _createResourceReturn();
|
|
1394
|
+
return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
|
|
1395
|
+
};
|
|
1396
|
+
const runResource = (task, container, host) => {
|
|
1397
|
+
task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
|
|
1398
|
+
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
1399
|
+
iCtx.$container$ = container;
|
|
1400
|
+
const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
|
|
1401
|
+
const resource = task.$state$;
|
|
1402
|
+
const cleanups = [];
|
|
1403
|
+
task.$destroy$ = noSerialize(() => {
|
|
1404
|
+
cleanups.forEach((fn) => {
|
|
1405
|
+
try {
|
|
1406
|
+
fn();
|
|
1407
|
+
} catch (err) {
|
|
1408
|
+
container.handleError(err, host);
|
|
1409
|
+
}
|
|
1410
|
+
}), done = true;
|
|
1411
|
+
});
|
|
1412
|
+
const resourceTarget = unwrapStore(resource);
|
|
1413
|
+
const opts = {
|
|
1414
|
+
track: (obj, prop) => {
|
|
1415
|
+
const ctx = newInvokeContext();
|
|
1416
|
+
return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container, invoke(ctx, () => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj);
|
|
1417
|
+
},
|
|
1418
|
+
cleanup(fn) {
|
|
1419
|
+
"function" == typeof fn && cleanups.push(fn);
|
|
1420
|
+
},
|
|
1421
|
+
cache(policy) {
|
|
1422
|
+
let milliseconds = 0;
|
|
1423
|
+
milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
|
|
1424
|
+
},
|
|
1425
|
+
previous: resourceTarget._resolved
|
|
1426
|
+
};
|
|
1427
|
+
let resolve;
|
|
1428
|
+
let reject;
|
|
1429
|
+
let done = false;
|
|
1430
|
+
const setState = (resolved, value) => !done && (done = true, resolved ? (done = true, resource.loading = false, resource._state = "resolved", resource._resolved = value, resource._error = void 0, resolve(value)) : (done = true, resource.loading = false, resource._state = "rejected", resource._error = value, reject(value)), true);
|
|
1431
|
+
cleanups.push(() => {
|
|
1432
|
+
if (true === untrack(() => resource.loading)) {
|
|
1433
|
+
const value = untrack(() => resource._resolved);
|
|
1434
|
+
setState(true, value);
|
|
1435
|
+
}
|
|
1436
|
+
}), invoke(iCtx, () => {
|
|
1437
|
+
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
1438
|
+
(resource.value = new Promise((r, re) => {
|
|
1439
|
+
resolve = r, reject = re;
|
|
1440
|
+
})).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
1441
|
+
});
|
|
1442
|
+
const promise = safeCall(() => Promise.resolve(taskFn(opts)), (value) => {
|
|
1443
|
+
setState(true, value);
|
|
1444
|
+
}, (err) => {
|
|
1445
|
+
if (isPromise(err)) {
|
|
1446
|
+
return err.then(() => runResource(task, container, host));
|
|
1447
|
+
}
|
|
1448
|
+
setState(false, err);
|
|
1449
|
+
});
|
|
1450
|
+
const timeout = resourceTarget._timeout;
|
|
1451
|
+
return timeout > 0 ? Promise.race([promise, delay(timeout).then(() => {
|
|
1452
|
+
setState(false, new Error("timeout")) && cleanupTask(task);
|
|
1453
|
+
})]) : promise;
|
|
1454
|
+
};
|
|
1455
|
+
const ignoreErrorToPreventNodeFromCrashing = () => {
|
|
1456
|
+
};
|
|
1457
|
+
const aVNodePath = [];
|
|
1458
|
+
const bVNodePath = [];
|
|
1459
|
+
const vnode_documentPosition = (a2, b, rootVNode) => {
|
|
1460
|
+
if (a2 === b) {
|
|
1461
|
+
return 0;
|
|
1462
|
+
}
|
|
1463
|
+
let aDepth = -1;
|
|
1464
|
+
let bDepth = -1;
|
|
1465
|
+
for (; a2; ) {
|
|
1466
|
+
a2 = (aVNodePath[++aDepth] = a2)[VNodeProps.parent] || rootVNode && vnode_getProp(a2, "q:sparent", (id) => vnode_locate(rootVNode, id));
|
|
1467
|
+
}
|
|
1468
|
+
for (; b; ) {
|
|
1469
|
+
b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, "q:sparent", (id) => vnode_locate(rootVNode, id));
|
|
1470
|
+
}
|
|
1471
|
+
for (; aDepth >= 0 && bDepth >= 0; ) {
|
|
1472
|
+
if ((a2 = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
|
|
1473
|
+
let cursor = b;
|
|
1474
|
+
do {
|
|
1475
|
+
if (cursor = vnode_getNextSibling(cursor), cursor === a2) {
|
|
1476
|
+
return 1;
|
|
1477
|
+
}
|
|
1478
|
+
} while (cursor);
|
|
1479
|
+
cursor = b;
|
|
1480
|
+
do {
|
|
1481
|
+
if (cursor = vnode_getPreviousSibling(cursor), cursor === a2) {
|
|
1482
|
+
return -1;
|
|
1483
|
+
}
|
|
1484
|
+
} while (cursor);
|
|
1485
|
+
return rootVNode && vnode_getProp(b, "q:sparent", (id) => vnode_locate(rootVNode, id)) ? -1 : 1;
|
|
1486
|
+
}
|
|
1487
|
+
aDepth--, bDepth--;
|
|
1488
|
+
}
|
|
1489
|
+
return aDepth < bDepth ? -1 : 1;
|
|
1490
|
+
};
|
|
1491
|
+
const aSsrNodePath = [];
|
|
1492
|
+
const bSsrNodePath = [];
|
|
1493
|
+
const ssrNodeDocumentPosition = (a2, b) => {
|
|
1494
|
+
if (a2 === b) {
|
|
1495
|
+
return 0;
|
|
1496
|
+
}
|
|
1497
|
+
let aDepth = -1;
|
|
1498
|
+
let bDepth = -1;
|
|
1499
|
+
for (; a2; ) {
|
|
1500
|
+
a2 = (aSsrNodePath[++aDepth] = a2).currentComponentNode;
|
|
1501
|
+
}
|
|
1502
|
+
for (; b; ) {
|
|
1503
|
+
b = (bSsrNodePath[++bDepth] = b).currentComponentNode;
|
|
1504
|
+
}
|
|
1505
|
+
for (; aDepth >= 0 && bDepth >= 0; ) {
|
|
1506
|
+
if ((a2 = aSsrNodePath[aDepth]) !== (b = bSsrNodePath[bDepth])) {
|
|
1507
|
+
return 1;
|
|
1508
|
+
}
|
|
1509
|
+
aDepth--, bDepth--;
|
|
1510
|
+
}
|
|
1511
|
+
return aDepth < bDepth ? -1 : 1;
|
|
1512
|
+
};
|
|
1513
|
+
const getPromise = (chore) => chore.$promise$ || (chore.$promise$ = new Promise((resolve) => {
|
|
1514
|
+
chore.$resolve$ = resolve;
|
|
1515
|
+
}));
|
|
1516
|
+
const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
1517
|
+
const choreQueue = [];
|
|
1518
|
+
const qrlRuns = [];
|
|
1519
|
+
let currentChore = null;
|
|
1520
|
+
let drainScheduled = false;
|
|
1521
|
+
return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
|
|
1522
|
+
const isServer3 = !isDomContainer(container);
|
|
1523
|
+
const isComponentSsr = isServer3 && type === ChoreType.COMPONENT;
|
|
1524
|
+
const runLater = type !== ChoreType.WAIT_FOR_ALL && !isComponentSsr && type !== ChoreType.RUN_QRL;
|
|
1525
|
+
const isTask2 = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
|
|
1526
|
+
const isClientOnly = type === ChoreType.JOURNAL_FLUSH || type === ChoreType.NODE_DIFF || type === ChoreType.NODE_PROP;
|
|
1527
|
+
if (isServer3 && isClientOnly) {
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
isTask2 && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
|
|
1531
|
+
let chore = {
|
|
1532
|
+
$type$: type,
|
|
1533
|
+
$idx$: isTask2 ? hostOrTask.$index$ : "string" == typeof targetOrQrl ? targetOrQrl : 0,
|
|
1534
|
+
$host$: isTask2 ? hostOrTask.$el$ : hostOrTask,
|
|
1535
|
+
$target$: targetOrQrl,
|
|
1536
|
+
$payload$: isTask2 ? hostOrTask : payload,
|
|
1537
|
+
$resolve$: null,
|
|
1538
|
+
$promise$: null,
|
|
1539
|
+
$returnValue$: null,
|
|
1540
|
+
$executed$: false
|
|
1541
|
+
};
|
|
1542
|
+
chore = function(sortedArray, value, rootVNode) {
|
|
1543
|
+
const idx = function(sortedArray2, value2, rootVNode2) {
|
|
1544
|
+
let bottom = 0;
|
|
1545
|
+
let top = sortedArray2.length;
|
|
1546
|
+
for (; bottom < top; ) {
|
|
1547
|
+
const middle = bottom + (top - bottom >> 1);
|
|
1548
|
+
const comp = choreComparator(value2, sortedArray2[middle], rootVNode2);
|
|
1549
|
+
if (comp < 0) {
|
|
1550
|
+
top = middle;
|
|
1551
|
+
} else {
|
|
1552
|
+
if (!(comp > 0)) {
|
|
1553
|
+
return middle;
|
|
1554
|
+
}
|
|
1555
|
+
bottom = middle + 1;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
return ~bottom;
|
|
1559
|
+
}(sortedArray, value, rootVNode);
|
|
1560
|
+
if (idx < 0) {
|
|
1561
|
+
return sortedArray.splice(~idx, 0, value), value;
|
|
1562
|
+
}
|
|
1563
|
+
const existing = sortedArray[idx];
|
|
1564
|
+
existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = value.$payload$);
|
|
1565
|
+
existing.$executed$ && (existing.$executed$ = false);
|
|
1566
|
+
return existing;
|
|
1567
|
+
}(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = true, schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain()?.catch?.(() => {
|
|
1568
|
+
}));
|
|
1569
|
+
return runLater ? getPromise(chore) : drainUpTo(chore, isServer3);
|
|
1570
|
+
};
|
|
1571
|
+
function drainUpTo(runUptoChore, isServer3) {
|
|
1572
|
+
let maxRetries = 5e3;
|
|
1573
|
+
for (; choreQueue.length; ) {
|
|
1574
|
+
if (maxRetries-- < 0) {
|
|
1575
|
+
throw new Error("drainUpTo: max retries reached");
|
|
1576
|
+
}
|
|
1577
|
+
if (currentChore) {
|
|
1578
|
+
return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer3)).catch((e) => {
|
|
1579
|
+
container.handleError(e, currentChore?.$host$);
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
const nextChore = choreQueue[0];
|
|
1583
|
+
if (nextChore.$executed$) {
|
|
1584
|
+
if (choreQueue.shift(), nextChore === runUptoChore) {
|
|
1585
|
+
break;
|
|
1586
|
+
}
|
|
1587
|
+
} else {
|
|
1588
|
+
vNodeAlreadyDeleted(nextChore) && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE ? choreQueue.shift() : executeChore(nextChore, isServer3);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
return runUptoChore.$returnValue$;
|
|
1592
|
+
}
|
|
1593
|
+
function executeChore(chore, isServer3) {
|
|
1594
|
+
const host = chore.$host$;
|
|
1595
|
+
currentChore = chore;
|
|
1596
|
+
let returnValue = null;
|
|
1597
|
+
try {
|
|
1598
|
+
switch (chore.$type$) {
|
|
1599
|
+
case ChoreType.WAIT_FOR_ALL:
|
|
1600
|
+
isServer3 && (drainScheduled = false);
|
|
1601
|
+
break;
|
|
1602
|
+
case ChoreType.JOURNAL_FLUSH:
|
|
1603
|
+
returnValue = journalFlush(), drainScheduled = false;
|
|
1604
|
+
break;
|
|
1605
|
+
case ChoreType.COMPONENT:
|
|
1606
|
+
returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), (jsx2) => {
|
|
1607
|
+
if (isServer3) {
|
|
1608
|
+
return jsx2;
|
|
1609
|
+
}
|
|
1610
|
+
{
|
|
1611
|
+
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
1612
|
+
return retryOnPromise(() => vnode_diff(container, jsx2, host, addComponentStylePrefix(styleScopedId)));
|
|
1613
|
+
}
|
|
1614
|
+
}, (err) => container.handleError(err, host));
|
|
1615
|
+
break;
|
|
1616
|
+
case ChoreType.RUN_QRL:
|
|
1617
|
+
{
|
|
1618
|
+
const fn = chore.$target$.getFn();
|
|
1619
|
+
const result = retryOnPromise(() => fn(...chore.$payload$));
|
|
1620
|
+
if (isPromise(result)) {
|
|
1621
|
+
const handled = result.finally(() => {
|
|
1622
|
+
qrlRuns.splice(qrlRuns.indexOf(handled), 1);
|
|
1623
|
+
}).catch((error) => {
|
|
1624
|
+
container.handleError(error, chore.$host$);
|
|
1625
|
+
});
|
|
1626
|
+
return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled), currentChore = null, void (chore.$executed$ = true);
|
|
1627
|
+
}
|
|
1628
|
+
returnValue = null;
|
|
1629
|
+
}
|
|
1630
|
+
break;
|
|
1631
|
+
case ChoreType.TASK:
|
|
1632
|
+
case ChoreType.VISIBLE:
|
|
1633
|
+
{
|
|
1634
|
+
const payload = chore.$payload$;
|
|
1635
|
+
if (payload.$flags$ & TaskFlags.RESOURCE) {
|
|
1636
|
+
const result = runResource(payload, container, host);
|
|
1637
|
+
returnValue = isServer3 ? result : null;
|
|
1638
|
+
} else {
|
|
1639
|
+
returnValue = runTask(payload, container, host);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
break;
|
|
1643
|
+
case ChoreType.CLEANUP_VISIBLE:
|
|
1644
|
+
cleanupTask(chore.$payload$);
|
|
1645
|
+
break;
|
|
1646
|
+
case ChoreType.NODE_DIFF:
|
|
1647
|
+
{
|
|
1648
|
+
const parentVirtualNode = chore.$target$;
|
|
1649
|
+
let jsx2 = chore.$payload$;
|
|
1650
|
+
isSignal(jsx2) && (jsx2 = jsx2.value), returnValue = retryOnPromise(() => vnode_diff(container, jsx2, parentVirtualNode, null));
|
|
1651
|
+
}
|
|
1652
|
+
break;
|
|
1653
|
+
case ChoreType.NODE_PROP:
|
|
1654
|
+
{
|
|
1655
|
+
const virtualNode = chore.$host$;
|
|
1656
|
+
const payload = chore.$payload$;
|
|
1657
|
+
let value = payload.$value$;
|
|
1658
|
+
isSignal(value) && (value = value.value);
|
|
1659
|
+
const isConst = payload.$isConst$;
|
|
1660
|
+
const journal = container.$journal$;
|
|
1661
|
+
const property = chore.$idx$;
|
|
1662
|
+
const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
|
|
1663
|
+
if (isConst) {
|
|
1664
|
+
journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
|
|
1665
|
+
} else {
|
|
1666
|
+
vnode_setAttr(journal, virtualNode, property, serializedValue);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
break;
|
|
1670
|
+
case ChoreType.QRL_RESOLVE:
|
|
1671
|
+
{
|
|
1672
|
+
const target = chore.$target$;
|
|
1673
|
+
returnValue = target.resolved ? null : target.resolve();
|
|
1674
|
+
}
|
|
1675
|
+
break;
|
|
1676
|
+
case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS: {
|
|
1677
|
+
const target = chore.$target$;
|
|
1678
|
+
const forceRunEffects = target.$forceRunEffects$;
|
|
1679
|
+
if (target.$forceRunEffects$ = false, !target.$effects$?.size) {
|
|
1680
|
+
break;
|
|
1681
|
+
}
|
|
1682
|
+
returnValue = retryOnPromise(() => {
|
|
1683
|
+
(target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
} catch (e) {
|
|
1688
|
+
returnValue = Promise.reject(e);
|
|
1689
|
+
}
|
|
1690
|
+
const after = (value, error) => {
|
|
1691
|
+
currentChore = null, chore.$executed$ = true, error ? container.handleError(error, host) : (chore.$returnValue$ = value, chore.$resolve$?.(value));
|
|
1692
|
+
};
|
|
1693
|
+
isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error) => after(void 0, error)), chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
|
|
1694
|
+
}
|
|
1695
|
+
function choreComparator(a2, b, rootVNode) {
|
|
1696
|
+
const macroTypeDiff = (a2.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
|
|
1697
|
+
if (0 !== macroTypeDiff) {
|
|
1698
|
+
return macroTypeDiff;
|
|
1699
|
+
}
|
|
1700
|
+
const aHost = a2.$host$;
|
|
1701
|
+
const bHost = b.$host$;
|
|
1702
|
+
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
1703
|
+
if (vnode_isVNode(aHost) && vnode_isVNode(bHost)) {
|
|
1704
|
+
const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
|
|
1705
|
+
if (0 !== hostDiff) {
|
|
1706
|
+
return hostDiff;
|
|
1707
|
+
}
|
|
1708
|
+
} else {
|
|
1709
|
+
`SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
|
|
1710
|
+
You are attempting to change a state that has already been streamed to the client.
|
|
1711
|
+
This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
|
|
1712
|
+
Problematic Node: ${aHost.toString()}`;
|
|
1713
|
+
const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
|
|
1714
|
+
if (0 !== hostDiff) {
|
|
1715
|
+
return hostDiff;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
const microTypeDiff = (a2.$type$ & ChoreType.MICRO) - (b.$type$ & ChoreType.MICRO);
|
|
1720
|
+
if (0 !== microTypeDiff) {
|
|
1721
|
+
return microTypeDiff;
|
|
1722
|
+
}
|
|
1723
|
+
const idxDiff = toNumber(a2.$idx$) - toNumber(b.$idx$);
|
|
1724
|
+
return 0 !== idxDiff ? idxDiff : a2.$target$ !== b.$target$ || a2.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
|
|
115
1725
|
}
|
|
1726
|
+
};
|
|
1727
|
+
const toNumber = (value) => "number" == typeof value ? value : -1;
|
|
1728
|
+
function vNodeAlreadyDeleted(chore) {
|
|
1729
|
+
return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
|
|
116
1730
|
}
|
|
117
|
-
|
|
118
|
-
|
|
1731
|
+
var SignalFlags;
|
|
1732
|
+
var WrappedSignalFlags;
|
|
1733
|
+
!function(SignalFlags2) {
|
|
1734
|
+
SignalFlags2[SignalFlags2.INVALID = 1] = "INVALID";
|
|
1735
|
+
}(SignalFlags || (SignalFlags = {})), function(WrappedSignalFlags2) {
|
|
1736
|
+
WrappedSignalFlags2[WrappedSignalFlags2.UNWRAP = 2] = "UNWRAP";
|
|
1737
|
+
}(WrappedSignalFlags || (WrappedSignalFlags = {}));
|
|
119
1738
|
const throwIfQRLNotResolved = (qrl2) => {
|
|
120
1739
|
if (!qrl2.resolved) {
|
|
121
1740
|
throw qrl2.resolve();
|
|
122
1741
|
}
|
|
123
1742
|
};
|
|
124
1743
|
const isSignal = (value) => value instanceof Signal;
|
|
125
|
-
class
|
|
1744
|
+
class SubscriptionData {
|
|
126
1745
|
constructor(data) {
|
|
127
1746
|
__publicField(this, "data");
|
|
128
1747
|
this.data = data;
|
|
129
1748
|
}
|
|
130
1749
|
}
|
|
131
|
-
var
|
|
1750
|
+
var EffectSubscriptionProp;
|
|
132
1751
|
var EffectProperty;
|
|
133
|
-
!function(
|
|
134
|
-
|
|
135
|
-
}(
|
|
1752
|
+
!function(EffectSubscriptionProp2) {
|
|
1753
|
+
EffectSubscriptionProp2[EffectSubscriptionProp2.CONSUMER = 0] = "CONSUMER", EffectSubscriptionProp2[EffectSubscriptionProp2.PROPERTY = 1] = "PROPERTY", EffectSubscriptionProp2[EffectSubscriptionProp2.BACK_REF = 2] = "BACK_REF", EffectSubscriptionProp2[EffectSubscriptionProp2.DATA = 3] = "DATA";
|
|
1754
|
+
}(EffectSubscriptionProp || (EffectSubscriptionProp = {})), function(EffectProperty2) {
|
|
136
1755
|
EffectProperty2.COMPONENT = ":", EffectProperty2.VNODE = ".";
|
|
137
1756
|
}(EffectProperty || (EffectProperty = {}));
|
|
138
1757
|
class Signal {
|
|
@@ -161,8 +1780,8 @@ class Signal {
|
|
|
161
1780
|
}
|
|
162
1781
|
const effectSubscriber = ctx.$effectSubscriber$;
|
|
163
1782
|
if (effectSubscriber) {
|
|
164
|
-
const effects = this.$effects$ || (this.$effects$ =
|
|
165
|
-
|
|
1783
|
+
const effects = this.$effects$ || (this.$effects$ = /* @__PURE__ */ new Set());
|
|
1784
|
+
ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this), addQrlToSerializationCtx(effectSubscriber, this.$container$);
|
|
166
1785
|
}
|
|
167
1786
|
}
|
|
168
1787
|
return this.untrackedValue;
|
|
@@ -173,7 +1792,7 @@ class Signal {
|
|
|
173
1792
|
valueOf() {
|
|
174
1793
|
}
|
|
175
1794
|
toString() {
|
|
176
|
-
return `[${this.constructor.name}${this.$
|
|
1795
|
+
return `[${this.constructor.name}${this.$flags$ & SignalFlags.INVALID ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
|
|
177
1796
|
}
|
|
178
1797
|
toJSON() {
|
|
179
1798
|
return {
|
|
@@ -181,112 +1800,92 @@ class Signal {
|
|
|
181
1800
|
};
|
|
182
1801
|
}
|
|
183
1802
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
};
|
|
187
|
-
const ensureContainsEffect = (array, effectSubscriptions) => {
|
|
188
|
-
for (let i = 0; i < array.length; i++) {
|
|
189
|
-
const existingEffect = array[i];
|
|
190
|
-
if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
array.push(effectSubscriptions);
|
|
1803
|
+
const ensureContainsSubscription = (array, effectSubscription) => {
|
|
1804
|
+
array.add(effectSubscription);
|
|
195
1805
|
};
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
effect.$effectDependencies$.push(subscriber);
|
|
202
|
-
} else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
|
|
203
|
-
let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
|
|
204
|
-
if (subscribers || (subscribers = []), subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
|
|
208
|
-
} else if (isSSRNode(effect)) {
|
|
209
|
-
let subscribers = effect.getProp("q:subs");
|
|
210
|
-
if (subscribers || (subscribers = []), subscriberExistInSubscribers(subscribers, subscriber)) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
|
|
214
|
-
}
|
|
1806
|
+
const ensureContainsBackRef = (array, value) => {
|
|
1807
|
+
var _a2;
|
|
1808
|
+
array[_a2 = EffectSubscriptionProp.BACK_REF] || (array[_a2] = /* @__PURE__ */ new Set()), array[EffectSubscriptionProp.BACK_REF].add(value);
|
|
215
1809
|
};
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
1810
|
+
const addQrlToSerializationCtx = (effectSubscriber, container) => {
|
|
1811
|
+
if (container && !isDomContainer(container)) {
|
|
1812
|
+
const effect = effectSubscriber[EffectSubscriptionProp.CONSUMER];
|
|
1813
|
+
const property = effectSubscriber[EffectSubscriptionProp.PROPERTY];
|
|
1814
|
+
let qrl2 = null;
|
|
1815
|
+
isTask(effect) ? qrl2 = effect.$qrl$ : effect instanceof ComputedSignal ? qrl2 = effect.$computeQrl$ : property === EffectProperty.COMPONENT && (qrl2 = container.getHostProp(effect, "q:renderFn")), qrl2 && container.serializationCtx.$eventQrls$.add(qrl2);
|
|
222
1816
|
}
|
|
223
|
-
return false;
|
|
224
1817
|
};
|
|
225
1818
|
const triggerEffects = (container, signal, effects) => {
|
|
1819
|
+
const isBrowser2 = isDomContainer(container);
|
|
226
1820
|
if (effects) {
|
|
227
|
-
const scheduleEffect = (
|
|
228
|
-
const
|
|
229
|
-
const property =
|
|
230
|
-
if (isTask(
|
|
231
|
-
|
|
1821
|
+
const scheduleEffect = (effectSubscription) => {
|
|
1822
|
+
const consumer = effectSubscription[EffectSubscriptionProp.CONSUMER];
|
|
1823
|
+
const property = effectSubscription[EffectSubscriptionProp.PROPERTY];
|
|
1824
|
+
if (isTask(consumer)) {
|
|
1825
|
+
consumer.$flags$ |= TaskFlags.DIRTY;
|
|
232
1826
|
let choreType = ChoreType.TASK;
|
|
233
|
-
|
|
234
|
-
} else if (
|
|
235
|
-
|
|
1827
|
+
consumer.$flags$ & TaskFlags.VISIBLE_TASK && (choreType = ChoreType.VISIBLE), container.$scheduler$(choreType, consumer);
|
|
1828
|
+
} else if (consumer instanceof Signal) {
|
|
1829
|
+
consumer instanceof ComputedSignal && (consumer.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, consumer.$computeQrl$)), consumer.$invalidate$();
|
|
236
1830
|
} else if (property === EffectProperty.COMPONENT) {
|
|
237
|
-
const host =
|
|
1831
|
+
const host = consumer;
|
|
238
1832
|
const qrl2 = container.getHostProp(host, "q:renderFn");
|
|
239
1833
|
const props = container.getHostProp(host, "q:props");
|
|
240
1834
|
container.$scheduler$(ChoreType.COMPONENT, host, qrl2, props);
|
|
241
|
-
} else if (
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
1835
|
+
} else if (isBrowser2) {
|
|
1836
|
+
if (property === EffectProperty.VNODE) {
|
|
1837
|
+
container.$scheduler$(ChoreType.NODE_DIFF, consumer, consumer, signal);
|
|
1838
|
+
} else {
|
|
1839
|
+
const effectData = effectSubscription[EffectSubscriptionProp.DATA];
|
|
1840
|
+
if (effectData instanceof SubscriptionData) {
|
|
1841
|
+
const payload = {
|
|
1842
|
+
...effectData.data,
|
|
1843
|
+
$value$: signal
|
|
1844
|
+
};
|
|
1845
|
+
container.$scheduler$(ChoreType.NODE_PROP, consumer, property, payload);
|
|
1846
|
+
}
|
|
251
1847
|
}
|
|
252
1848
|
}
|
|
253
1849
|
};
|
|
254
|
-
effects
|
|
1850
|
+
for (const effect of effects) {
|
|
1851
|
+
scheduleEffect(effect);
|
|
1852
|
+
}
|
|
255
1853
|
}
|
|
256
1854
|
};
|
|
257
|
-
class ComputedSignal extends Signal {
|
|
258
|
-
constructor(container, fn) {
|
|
1855
|
+
class ComputedSignal extends (_c = Signal, _b = _EFFECT_BACK_REF, _c) {
|
|
1856
|
+
constructor(container, fn, flags = SignalFlags.INVALID) {
|
|
259
1857
|
super(container, NEEDS_COMPUTATION);
|
|
260
1858
|
__publicField(this, "$computeQrl$");
|
|
261
|
-
__publicField(this, "$
|
|
1859
|
+
__publicField(this, "$flags$");
|
|
262
1860
|
__publicField(this, "$forceRunEffects$", false);
|
|
263
|
-
this
|
|
1861
|
+
__publicField(this, _b, null);
|
|
1862
|
+
this.$computeQrl$ = fn, this.$flags$ = flags;
|
|
264
1863
|
}
|
|
265
1864
|
$invalidate$() {
|
|
266
|
-
this.$
|
|
1865
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
|
|
267
1866
|
}
|
|
268
1867
|
force() {
|
|
269
|
-
this.$
|
|
1868
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, triggerEffects(this.$container$, this, this.$effects$);
|
|
270
1869
|
}
|
|
271
1870
|
get untrackedValue() {
|
|
272
1871
|
const didChange = this.$computeIfNeeded$();
|
|
273
1872
|
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION), this.$untrackedValue$;
|
|
274
1873
|
}
|
|
275
1874
|
$computeIfNeeded$() {
|
|
276
|
-
if (!this.$
|
|
1875
|
+
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
277
1876
|
return false;
|
|
278
1877
|
}
|
|
279
1878
|
const computeQrl = this.$computeQrl$;
|
|
280
1879
|
throwIfQRLNotResolved(computeQrl);
|
|
281
1880
|
const ctx = tryGetInvokeContext();
|
|
282
1881
|
const previousEffectSubscription = ctx?.$effectSubscriber$;
|
|
283
|
-
ctx && (ctx.$effectSubscriber$ =
|
|
1882
|
+
ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
|
|
284
1883
|
try {
|
|
285
1884
|
const untrackedValue = computeQrl.getFn(ctx)();
|
|
286
1885
|
if (isPromise(untrackedValue)) {
|
|
287
1886
|
throw qError(QError.computedNotSync, [computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$]);
|
|
288
1887
|
}
|
|
289
|
-
this.$
|
|
1888
|
+
this.$flags$ &= ~SignalFlags.INVALID;
|
|
290
1889
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
291
1890
|
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
292
1891
|
} finally {
|
|
@@ -300,30 +1899,30 @@ class ComputedSignal extends Signal {
|
|
|
300
1899
|
throw qError(QError.computedReadOnly);
|
|
301
1900
|
}
|
|
302
1901
|
}
|
|
303
|
-
class WrappedSignal extends Signal {
|
|
304
|
-
constructor(container, fn, args, fnStr) {
|
|
1902
|
+
class WrappedSignal extends (_e = Signal, _d = _EFFECT_BACK_REF, _e) {
|
|
1903
|
+
constructor(container, fn, args, fnStr, flags = SignalFlags.INVALID | WrappedSignalFlags.UNWRAP) {
|
|
305
1904
|
super(container, NEEDS_COMPUTATION);
|
|
306
1905
|
__publicField(this, "$args$");
|
|
307
1906
|
__publicField(this, "$func$");
|
|
308
1907
|
__publicField(this, "$funcStr$");
|
|
309
|
-
__publicField(this, "$
|
|
310
|
-
__publicField(this, "$effectDependencies$", null);
|
|
1908
|
+
__publicField(this, "$flags$");
|
|
311
1909
|
__publicField(this, "$hostElement$", null);
|
|
312
1910
|
__publicField(this, "$forceRunEffects$", false);
|
|
313
|
-
this
|
|
1911
|
+
__publicField(this, _d, null);
|
|
1912
|
+
this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr, this.$flags$ = flags;
|
|
314
1913
|
}
|
|
315
1914
|
$invalidate$() {
|
|
316
|
-
this.$
|
|
1915
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
|
|
317
1916
|
}
|
|
318
1917
|
force() {
|
|
319
|
-
this.$
|
|
1918
|
+
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, triggerEffects(this.$container$, this, this.$effects$);
|
|
320
1919
|
}
|
|
321
1920
|
get untrackedValue() {
|
|
322
1921
|
const didChange = this.$computeIfNeeded$();
|
|
323
1922
|
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION), this.$untrackedValue$;
|
|
324
1923
|
}
|
|
325
1924
|
$computeIfNeeded$() {
|
|
326
|
-
if (!this.$
|
|
1925
|
+
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
327
1926
|
return false;
|
|
328
1927
|
}
|
|
329
1928
|
const untrackedValue = trackSignal(() => this.$func$(...this.$args$), this, EffectProperty.VNODE, this.$container$);
|
|
@@ -337,11 +1936,31 @@ class WrappedSignal extends Signal {
|
|
|
337
1936
|
throw qError(QError.wrappedReadOnly);
|
|
338
1937
|
}
|
|
339
1938
|
}
|
|
340
|
-
const
|
|
341
|
-
|
|
1939
|
+
const version = "2.0.0-alpha.8-dev+66037b5";
|
|
1940
|
+
class _SharedContainer {
|
|
1941
|
+
constructor(scheduleDrain, journalFlush, serverData, locale) {
|
|
1942
|
+
__publicField(this, "$version$");
|
|
1943
|
+
__publicField(this, "$scheduler$");
|
|
1944
|
+
__publicField(this, "$storeProxyMap$");
|
|
1945
|
+
__publicField(this, "$locale$");
|
|
1946
|
+
__publicField(this, "$getObjectById$");
|
|
1947
|
+
__publicField(this, "$serverData$");
|
|
1948
|
+
__publicField(this, "$currentUniqueId$", 0);
|
|
1949
|
+
__publicField(this, "$instanceHash$", null);
|
|
1950
|
+
this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version, this.$storeProxyMap$ = /* @__PURE__ */ new WeakMap(), this.$getObjectById$ = () => {
|
|
1951
|
+
throw Error("Not implemented");
|
|
1952
|
+
}, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
|
|
1953
|
+
}
|
|
1954
|
+
trackSignalValue(signal, subscriber, property, data) {
|
|
1955
|
+
return trackSignalAndAssignHost(signal, subscriber, property, this, data);
|
|
1956
|
+
}
|
|
1957
|
+
serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
1958
|
+
return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
342
1961
|
const _jsxSorted = (type, varProps, constProps, children, flags, key) => {
|
|
343
1962
|
const processed = null == key ? null : String(key);
|
|
344
|
-
const node = new JSXNodeImpl(type, varProps || {}, null, children, flags, processed);
|
|
1963
|
+
const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
|
|
345
1964
|
return node;
|
|
346
1965
|
};
|
|
347
1966
|
const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
|
|
@@ -349,9 +1968,10 @@ const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
|
|
|
349
1968
|
return sortedProps = varProps ? Object.fromEntries(untrack(() => Object.entries(varProps)).filter((entry) => {
|
|
350
1969
|
const attr = entry[0];
|
|
351
1970
|
return "children" === attr ? (children ?? (children = entry[1]), false) : "key" === attr ? (key = entry[1], false) : !constProps;
|
|
352
|
-
}).sort(([a2], [b]) => a2 < b ? -1 : 1)) : EMPTY_OBJ, _jsxSorted(type, sortedProps, constProps, children, flags, key);
|
|
1971
|
+
}).sort(([a2], [b]) => a2 < b ? -1 : 1)) : "string" == typeof type ? EMPTY_OBJ : {}, _jsxSorted(type, sortedProps, constProps, children, flags, key);
|
|
353
1972
|
};
|
|
354
1973
|
const jsx = (type, props, key) => _jsxSplit(type, props, null, null, 0, null);
|
|
1974
|
+
const isPropsProxy = (obj) => obj && void 0 !== obj[_VAR_PROPS];
|
|
355
1975
|
class JSXNodeImpl {
|
|
356
1976
|
constructor(type, varProps, constProps, children, flags, key = null) {
|
|
357
1977
|
__publicField(this, "type");
|
|
@@ -368,7 +1988,9 @@ class JSXNodeImpl {
|
|
|
368
1988
|
return this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children)), this._proxy;
|
|
369
1989
|
}
|
|
370
1990
|
}
|
|
1991
|
+
const Virtual = (props) => props.children;
|
|
371
1992
|
const isJSXNode = (n) => n instanceof JSXNodeImpl;
|
|
1993
|
+
const Fragment = (props) => props.children;
|
|
372
1994
|
function createPropsProxy(varProps, constProps, children) {
|
|
373
1995
|
return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
|
|
374
1996
|
}
|
|
@@ -390,7 +2012,7 @@ class PropsProxyHandler {
|
|
|
390
2012
|
return this.$children$;
|
|
391
2013
|
}
|
|
392
2014
|
const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
|
|
393
|
-
return value instanceof WrappedSignal ? value.value : value;
|
|
2015
|
+
return value instanceof WrappedSignal && value.$flags$ & WrappedSignalFlags.UNWRAP ? value.value : value;
|
|
394
2016
|
}
|
|
395
2017
|
set(_, prop, value) {
|
|
396
2018
|
return prop === _CONST_PROPS ? (this.$constProps$ = value, true) : prop === _VAR_PROPS ? (this.$varProps$ = value, true) : (this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] = value : this.$varProps$[prop] = value, true);
|
|
@@ -422,6 +2044,7 @@ class PropsProxyHandler {
|
|
|
422
2044
|
return out;
|
|
423
2045
|
}
|
|
424
2046
|
}
|
|
2047
|
+
const directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
|
|
425
2048
|
const stringifyPath = [];
|
|
426
2049
|
function qwikDebugToString(value) {
|
|
427
2050
|
if (null === value) {
|
|
@@ -439,7 +2062,7 @@ function qwikDebugToString(value) {
|
|
|
439
2062
|
if (isTask(value)) {
|
|
440
2063
|
return `Task(${qwikDebugToString(value.$qrl$)})`;
|
|
441
2064
|
}
|
|
442
|
-
if (isQrl
|
|
2065
|
+
if (isQrl(value)) {
|
|
443
2066
|
return `Qrl(${value.$symbol$})`;
|
|
444
2067
|
}
|
|
445
2068
|
if ("object" == typeof value || "function" == typeof value) {
|
|
@@ -484,17 +2107,124 @@ const jsxToString = (value) => {
|
|
|
484
2107
|
}
|
|
485
2108
|
return String(value);
|
|
486
2109
|
};
|
|
2110
|
+
const VNodeDataSeparator = {
|
|
2111
|
+
REFERENCE_CH: "~",
|
|
2112
|
+
REFERENCE: 126,
|
|
2113
|
+
ADVANCE_1_CH: "!",
|
|
2114
|
+
ADVANCE_1: 33,
|
|
2115
|
+
ADVANCE_2_CH: '"',
|
|
2116
|
+
ADVANCE_2: 34,
|
|
2117
|
+
ADVANCE_4_CH: "#",
|
|
2118
|
+
ADVANCE_4: 35,
|
|
2119
|
+
ADVANCE_8_CH: "$",
|
|
2120
|
+
ADVANCE_8: 36,
|
|
2121
|
+
ADVANCE_16_CH: "%",
|
|
2122
|
+
ADVANCE_16: 37,
|
|
2123
|
+
ADVANCE_32_CH: "&",
|
|
2124
|
+
ADVANCE_32: 38,
|
|
2125
|
+
ADVANCE_64_CH: "'",
|
|
2126
|
+
ADVANCE_64: 39,
|
|
2127
|
+
ADVANCE_128_CH: "(",
|
|
2128
|
+
ADVANCE_128: 40,
|
|
2129
|
+
ADVANCE_256_CH: ")",
|
|
2130
|
+
ADVANCE_256: 41,
|
|
2131
|
+
ADVANCE_512_CH: "*",
|
|
2132
|
+
ADVANCE_512: 42,
|
|
2133
|
+
ADVANCE_1024_CH: "+",
|
|
2134
|
+
ADVANCE_1024: 43,
|
|
2135
|
+
ADVANCE_2048_CH: ",",
|
|
2136
|
+
ADVANCE_2048: 44,
|
|
2137
|
+
ADVANCE_4096_CH: "-",
|
|
2138
|
+
ADVANCE_4096: 45,
|
|
2139
|
+
ADVANCE_8192_CH: ".",
|
|
2140
|
+
ADVANCE_8192: 46
|
|
2141
|
+
};
|
|
2142
|
+
const VNodeDataChar = {
|
|
2143
|
+
OPEN: 123,
|
|
2144
|
+
OPEN_CHAR: "{",
|
|
2145
|
+
CLOSE: 125,
|
|
2146
|
+
CLOSE_CHAR: "}",
|
|
2147
|
+
SCOPED_STYLE: 59,
|
|
2148
|
+
SCOPED_STYLE_CHAR: ";",
|
|
2149
|
+
RENDER_FN: 60,
|
|
2150
|
+
RENDER_FN_CHAR: "<",
|
|
2151
|
+
ID: 61,
|
|
2152
|
+
ID_CHAR: "=",
|
|
2153
|
+
PROPS: 62,
|
|
2154
|
+
PROPS_CHAR: ">",
|
|
2155
|
+
SLOT_PARENT: 63,
|
|
2156
|
+
SLOT_PARENT_CHAR: "?",
|
|
2157
|
+
KEY: 64,
|
|
2158
|
+
KEY_CHAR: "@",
|
|
2159
|
+
SEQ: 91,
|
|
2160
|
+
SEQ_CHAR: "[",
|
|
2161
|
+
DON_T_USE: 92,
|
|
2162
|
+
DON_T_USE_CHAR: "\\",
|
|
2163
|
+
CONTEXT: 93,
|
|
2164
|
+
CONTEXT_CHAR: "]",
|
|
2165
|
+
SEQ_IDX: 94,
|
|
2166
|
+
SEQ_IDX_CHAR: "^",
|
|
2167
|
+
BACK_REFS: 96,
|
|
2168
|
+
BACK_REFS_CHAR: "`",
|
|
2169
|
+
SEPARATOR: 124,
|
|
2170
|
+
SEPARATOR_CHAR: "|",
|
|
2171
|
+
SLOT: 126,
|
|
2172
|
+
SLOT_CHAR: "~"
|
|
2173
|
+
};
|
|
2174
|
+
const mergeMaps = (map1, map2) => {
|
|
2175
|
+
for (const [k, v] of map2) {
|
|
2176
|
+
map1.set(k, v);
|
|
2177
|
+
}
|
|
2178
|
+
return map1;
|
|
2179
|
+
};
|
|
487
2180
|
var VNodeJournalOpCode;
|
|
488
2181
|
!function(VNodeJournalOpCode2) {
|
|
489
2182
|
VNodeJournalOpCode2[VNodeJournalOpCode2.SetText = 1] = "SetText", VNodeJournalOpCode2[VNodeJournalOpCode2.SetAttribute = 2] = "SetAttribute", VNodeJournalOpCode2[VNodeJournalOpCode2.HoistStyles = 3] = "HoistStyles", VNodeJournalOpCode2[VNodeJournalOpCode2.Remove = 4] = "Remove", VNodeJournalOpCode2[VNodeJournalOpCode2.Insert = 5] = "Insert";
|
|
490
2183
|
}(VNodeJournalOpCode || (VNodeJournalOpCode = {}));
|
|
2184
|
+
const vnode_newElement = (element, elementName) => {
|
|
2185
|
+
assertEqual(fastNodeType(element));
|
|
2186
|
+
const vnode = VNodeArray.createElement(VNodeFlags.Element | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, null, null, element, elementName);
|
|
2187
|
+
return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2188
|
+
};
|
|
2189
|
+
const vnode_newUnMaterializedElement = (element) => {
|
|
2190
|
+
assertEqual(fastNodeType(element));
|
|
2191
|
+
const vnode = VNodeArray.createElement(VNodeFlags.Element | -1 << VNodeFlagsIndex.shift, null, null, null, void 0, void 0, element, void 0);
|
|
2192
|
+
return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2193
|
+
};
|
|
2194
|
+
const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
|
|
2195
|
+
sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
|
|
2196
|
+
const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
|
|
2197
|
+
return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2198
|
+
};
|
|
2199
|
+
const vnode_newText = (textNode, textContent) => {
|
|
2200
|
+
const vnode = VNodeArray.createText(VNodeFlags.Text | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, textNode, textContent);
|
|
2201
|
+
return assertEqual(fastNodeType(textNode)), assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
|
|
2202
|
+
};
|
|
2203
|
+
const vnode_newVirtual = () => {
|
|
2204
|
+
const vnode = VNodeArray.createVirtual(VNodeFlags.Virtual | -1 << VNodeFlagsIndex.shift, null, null, null, null, null);
|
|
2205
|
+
return assertFalse(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)), assertTrue(vnode_isVirtualVNode(vnode)), vnode;
|
|
2206
|
+
};
|
|
491
2207
|
const vnode_isVNode = (vNode) => vNode instanceof VNodeArray;
|
|
2208
|
+
const vnode_isElementVNode = (vNode) => {
|
|
2209
|
+
return (vNode[VNodeProps.flags] & VNodeFlags.Element) === VNodeFlags.Element;
|
|
2210
|
+
};
|
|
2211
|
+
const vnode_isElementOrTextVNode = (vNode) => {
|
|
2212
|
+
return !!(vNode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK);
|
|
2213
|
+
};
|
|
492
2214
|
const vnode_isTextVNode = (vNode) => {
|
|
493
2215
|
return (vNode[VNodeProps.flags] & VNodeFlags.Text) === VNodeFlags.Text;
|
|
494
2216
|
};
|
|
2217
|
+
const vnode_isVirtualVNode = (vNode) => {
|
|
2218
|
+
return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual;
|
|
2219
|
+
};
|
|
2220
|
+
const vnode_isProjection = (vNode) => {
|
|
2221
|
+
return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual && null !== vnode_getProp(vNode, QSlot, null);
|
|
2222
|
+
};
|
|
2223
|
+
const ensureTextVNode = (vNode) => (assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)), vNode);
|
|
495
2224
|
const ensureElementOrVirtualVNode = (vNode) => {
|
|
496
2225
|
assertTrue(!!(vNode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
|
|
497
2226
|
};
|
|
2227
|
+
const ensureElementVNode = (vNode) => (assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)), vNode);
|
|
498
2228
|
const vnode_getNodeTypeName = (vNode) => {
|
|
499
2229
|
if (vNode) {
|
|
500
2230
|
switch (vNode[VNodeProps.flags] & VNodeFlags.TYPE_MASK) {
|
|
@@ -514,6 +2244,7 @@ const vnode_ensureElementInflated = (vnode) => {
|
|
|
514
2244
|
elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
|
|
515
2245
|
const element = elementVNode[ElementVNodeProps.element];
|
|
516
2246
|
const attributes = element.attributes;
|
|
2247
|
+
const props = vnode_getProps(elementVNode);
|
|
517
2248
|
for (let idx = 0; idx < attributes.length; idx++) {
|
|
518
2249
|
const attr = attributes[idx];
|
|
519
2250
|
const key = attr.name;
|
|
@@ -521,46 +2252,519 @@ const vnode_ensureElementInflated = (vnode) => {
|
|
|
521
2252
|
break;
|
|
522
2253
|
}
|
|
523
2254
|
if (key.startsWith("q:container")) {
|
|
524
|
-
attr.value === QContainerValue.HTML ? mapArray_set(
|
|
2255
|
+
attr.value === QContainerValue.HTML ? mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0) : attr.value === QContainerValue.TEXT && "value" in element && mapArray_set(props, "value", element.value, 0);
|
|
525
2256
|
} else if (!key.startsWith("on:")) {
|
|
526
|
-
mapArray_set(
|
|
2257
|
+
mapArray_set(props, key, attr.value, 0);
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
};
|
|
2262
|
+
function vnode_walkVNode(vNode) {
|
|
2263
|
+
let vCursor = vNode;
|
|
2264
|
+
if (vnode_isTextVNode(vNode)) {
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
let vParent = null;
|
|
2268
|
+
for (; ; ) {
|
|
2269
|
+
const vFirstChild = vnode_getFirstChild(vCursor);
|
|
2270
|
+
if (vFirstChild) {
|
|
2271
|
+
vCursor = vFirstChild;
|
|
2272
|
+
continue;
|
|
2273
|
+
}
|
|
2274
|
+
if (vCursor === vNode) {
|
|
2275
|
+
return;
|
|
2276
|
+
}
|
|
2277
|
+
const vNextSibling = vnode_getNextSibling(vCursor);
|
|
2278
|
+
if (vNextSibling) {
|
|
2279
|
+
vCursor = vNextSibling;
|
|
2280
|
+
} else {
|
|
2281
|
+
for (vParent = vnode_getParent(vCursor); vParent; ) {
|
|
2282
|
+
if (vParent === vNode) {
|
|
2283
|
+
return;
|
|
2284
|
+
}
|
|
2285
|
+
const vNextParentSibling = vnode_getNextSibling(vParent);
|
|
2286
|
+
if (vNextParentSibling) {
|
|
2287
|
+
vCursor = vNextParentSibling;
|
|
2288
|
+
break;
|
|
2289
|
+
}
|
|
2290
|
+
vParent = vnode_getParent(vParent);
|
|
2291
|
+
}
|
|
2292
|
+
if (null == vParent) {
|
|
2293
|
+
return;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
function vnode_getDOMChildNodes(journal, root, isVNode = false, childNodes = []) {
|
|
2299
|
+
if (vnode_isElementOrTextVNode(root)) {
|
|
2300
|
+
return vnode_isTextVNode(root) && vnode_ensureTextInflated(journal, root), childNodes.push(isVNode ? root : vnode_getNode(root)), childNodes;
|
|
2301
|
+
}
|
|
2302
|
+
let vNode = vnode_getFirstChild(root);
|
|
2303
|
+
for (; vNode; ) {
|
|
2304
|
+
vnode_isElementVNode(vNode) ? childNodes.push(isVNode ? vNode : vnode_getNode(vNode)) : vnode_isTextVNode(vNode) ? (vnode_ensureTextInflated(journal, vNode), childNodes.push(isVNode ? vNode : vnode_getNode(vNode))) : vnode_getDOMChildNodes(journal, vNode, !!isVNode, childNodes), vNode = vnode_getNextSibling(vNode);
|
|
2305
|
+
}
|
|
2306
|
+
return childNodes;
|
|
2307
|
+
}
|
|
2308
|
+
const vnode_getDomSibling = (vNode, nextDirection, descend) => {
|
|
2309
|
+
const childProp = nextDirection ? VirtualVNodeProps.firstChild : VirtualVNodeProps.lastChild;
|
|
2310
|
+
const siblingProp = nextDirection ? VNodeProps.nextSibling : VNodeProps.previousSibling;
|
|
2311
|
+
let cursor = vNode;
|
|
2312
|
+
for (; descend && cursor && vnode_isVirtualVNode(cursor); ) {
|
|
2313
|
+
const child = cursor[childProp];
|
|
2314
|
+
if (!child) {
|
|
2315
|
+
break;
|
|
2316
|
+
}
|
|
2317
|
+
if (child[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK) {
|
|
2318
|
+
return child;
|
|
2319
|
+
}
|
|
2320
|
+
cursor = child;
|
|
2321
|
+
}
|
|
2322
|
+
for (; cursor; ) {
|
|
2323
|
+
let sibling = cursor[siblingProp];
|
|
2324
|
+
if (sibling && sibling[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK) {
|
|
2325
|
+
return sibling;
|
|
2326
|
+
}
|
|
2327
|
+
if (!sibling) {
|
|
2328
|
+
let virtual = cursor[VNodeProps.parent];
|
|
2329
|
+
if (virtual && !vnode_isVirtualVNode(virtual)) {
|
|
2330
|
+
return null;
|
|
2331
|
+
}
|
|
2332
|
+
for (; virtual && !(sibling = virtual[siblingProp]); ) {
|
|
2333
|
+
if (virtual = virtual[VNodeProps.parent], virtual && !vnode_isVirtualVNode(virtual)) {
|
|
2334
|
+
return null;
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2337
|
+
if (!sibling) {
|
|
2338
|
+
return null;
|
|
2339
|
+
}
|
|
2340
|
+
if (vnode_isTextVNode(sibling) && virtual && vnode_isElementVNode(virtual)) {
|
|
2341
|
+
return null;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
for (; sibling; ) {
|
|
2345
|
+
if (cursor = sibling, cursor[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK && vnode_getNode(cursor)) {
|
|
2346
|
+
return cursor;
|
|
2347
|
+
}
|
|
2348
|
+
sibling = cursor[childProp];
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
return null;
|
|
2352
|
+
};
|
|
2353
|
+
const vnode_ensureInflatedIfText = (journal, vNode) => {
|
|
2354
|
+
vnode_isTextVNode(vNode) && vnode_ensureTextInflated(journal, vNode);
|
|
2355
|
+
};
|
|
2356
|
+
const vnode_ensureTextInflated = (journal, vnode) => {
|
|
2357
|
+
const textVNode = ensureTextVNode(vnode);
|
|
2358
|
+
if (!(textVNode[VNodeProps.flags] & VNodeFlags.Inflated)) {
|
|
2359
|
+
const parentNode = vnode_getDomParent(vnode);
|
|
2360
|
+
const sharedTextNode = textVNode[TextVNodeProps.node];
|
|
2361
|
+
const doc = parentNode.ownerDocument;
|
|
2362
|
+
let cursor = vnode_getDomSibling(vnode, false, true);
|
|
2363
|
+
const insertBeforeNode = sharedTextNode || vnode_getDomSibling(vnode, true, true)?.[ElementVNodeProps.element] || null;
|
|
2364
|
+
let lastPreviousTextNode = insertBeforeNode;
|
|
2365
|
+
for (; cursor && vnode_isTextVNode(cursor); ) {
|
|
2366
|
+
if (!(cursor[VNodeProps.flags] & VNodeFlags.Inflated)) {
|
|
2367
|
+
const textNode = doc.createTextNode(cursor[TextVNodeProps.text]);
|
|
2368
|
+
journal.push(VNodeJournalOpCode.Insert, parentNode, lastPreviousTextNode, textNode), lastPreviousTextNode = textNode, cursor[TextVNodeProps.node] = textNode, cursor[VNodeProps.flags] |= VNodeFlags.Inflated;
|
|
2369
|
+
}
|
|
2370
|
+
cursor = vnode_getDomSibling(cursor, false, true);
|
|
2371
|
+
}
|
|
2372
|
+
for (cursor = vnode; cursor && vnode_isTextVNode(cursor); ) {
|
|
2373
|
+
const next = vnode_getDomSibling(cursor, true, true);
|
|
2374
|
+
const isLastNode = !next || !vnode_isTextVNode(next);
|
|
2375
|
+
if (!(cursor[VNodeProps.flags] & VNodeFlags.Inflated)) {
|
|
2376
|
+
if (isLastNode && sharedTextNode) {
|
|
2377
|
+
journal.push(VNodeJournalOpCode.SetText, sharedTextNode, cursor[TextVNodeProps.text]);
|
|
2378
|
+
} else {
|
|
2379
|
+
const textNode = doc.createTextNode(cursor[TextVNodeProps.text]);
|
|
2380
|
+
journal.push(VNodeJournalOpCode.Insert, parentNode, insertBeforeNode, textNode), cursor[TextVNodeProps.node] = textNode;
|
|
2381
|
+
}
|
|
2382
|
+
cursor[VNodeProps.flags] |= VNodeFlags.Inflated;
|
|
2383
|
+
}
|
|
2384
|
+
cursor = next;
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
const vnode_locate = (rootVNode, id) => {
|
|
2389
|
+
ensureElementVNode(rootVNode);
|
|
2390
|
+
let vNode = rootVNode;
|
|
2391
|
+
const containerElement = rootVNode[ElementVNodeProps.element];
|
|
2392
|
+
const { qVNodeRefs } = containerElement;
|
|
2393
|
+
let elementOffset = -1;
|
|
2394
|
+
let refElement;
|
|
2395
|
+
if ("string" == typeof id ? (elementOffset = parseInt(id), refElement = qVNodeRefs.get(elementOffset)) : refElement = id, vnode_isVNode(refElement)) {
|
|
2396
|
+
vNode = refElement;
|
|
2397
|
+
} else {
|
|
2398
|
+
assertTrue(containerElement.contains(refElement));
|
|
2399
|
+
let parent = refElement;
|
|
2400
|
+
const elementPath = [refElement];
|
|
2401
|
+
for (; parent && parent !== containerElement; ) {
|
|
2402
|
+
parent = parent.parentElement, elementPath.push(parent);
|
|
2403
|
+
}
|
|
2404
|
+
for (let i = elementPath.length - 2; i >= 0; i--) {
|
|
2405
|
+
vNode = vnode_getVNodeForChildNode(vNode, elementPath[i]);
|
|
2406
|
+
}
|
|
2407
|
+
-1 != elementOffset && qVNodeRefs.set(elementOffset, vNode);
|
|
2408
|
+
}
|
|
2409
|
+
if ("string" == typeof id) {
|
|
2410
|
+
const idLength = id.length;
|
|
2411
|
+
let idx = indexOfAlphanumeric(id, idLength);
|
|
2412
|
+
let childIdx = 0;
|
|
2413
|
+
for (; idx < idLength; ) {
|
|
2414
|
+
const ch = id.charCodeAt(idx);
|
|
2415
|
+
childIdx *= 26, ch >= 97 ? childIdx += ch - 97 : (childIdx += ch - 65, vNode = vnode_getChildWithIdx(vNode, childIdx), childIdx = 0), idx++;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
return vNode;
|
|
2419
|
+
};
|
|
2420
|
+
const vnode_getChildWithIdx = (vNode, childIdx) => {
|
|
2421
|
+
let child = vnode_getFirstChild(vNode);
|
|
2422
|
+
for (assertDefined(); child[VNodeProps.flags] >>> VNodeFlagsIndex.shift !== childIdx; ) {
|
|
2423
|
+
child = vnode_getNextSibling(child);
|
|
2424
|
+
}
|
|
2425
|
+
return child;
|
|
2426
|
+
};
|
|
2427
|
+
const vNodeStack = [];
|
|
2428
|
+
const vnode_getVNodeForChildNode = (vNode, childElement) => {
|
|
2429
|
+
ensureElementVNode(vNode);
|
|
2430
|
+
let child = vnode_getFirstChild(vNode);
|
|
2431
|
+
for (assertDefined(); child && child[ElementVNodeProps.element] !== childElement; ) {
|
|
2432
|
+
if (vnode_isVirtualVNode(child)) {
|
|
2433
|
+
const next = vnode_getNextSibling(child);
|
|
2434
|
+
const firstChild = vnode_getFirstChild(child);
|
|
2435
|
+
firstChild ? (next && vNodeStack.push(next), child = firstChild) : child = next || (vNodeStack.length ? vNodeStack.pop() : null);
|
|
2436
|
+
} else {
|
|
2437
|
+
const next = vnode_getNextSibling(child);
|
|
2438
|
+
child = next || (next || vNodeStack.pop());
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
for (; vNodeStack.length; ) {
|
|
2442
|
+
vNodeStack.pop();
|
|
2443
|
+
}
|
|
2444
|
+
return ensureElementVNode(child), assertEqual(child[ElementVNodeProps.element]), child;
|
|
2445
|
+
};
|
|
2446
|
+
const indexOfAlphanumeric = (id, length) => {
|
|
2447
|
+
let idx = 0;
|
|
2448
|
+
for (; idx < length; ) {
|
|
2449
|
+
if (!(id.charCodeAt(idx) <= 57)) {
|
|
2450
|
+
return idx;
|
|
2451
|
+
}
|
|
2452
|
+
idx++;
|
|
2453
|
+
}
|
|
2454
|
+
return length;
|
|
2455
|
+
};
|
|
2456
|
+
const parseBoolean = (value) => "false" !== value && Boolean(value);
|
|
2457
|
+
const isBooleanAttr = (element, key) => ("allowfullscreen" == key || "async" == key || "autofocus" == key || "autoplay" == key || "checked" == key || "controls" == key || "default" == key || "defer" == key || "disabled" == key || "formnovalidate" == key || "inert" == key || "ismap" == key || "itemscope" == key || "loop" == key || "multiple" == key || "muted" == key || "nomodule" == key || "novalidate" == key || "open" == key || "playsinline" == key || "readonly" == key || "required" == key || "reversed" == key || "selected" == key) && key in element;
|
|
2458
|
+
const vnode_applyJournal = (journal) => {
|
|
2459
|
+
let idx = 0;
|
|
2460
|
+
const length = journal.length;
|
|
2461
|
+
for (; idx < length; ) {
|
|
2462
|
+
switch (journal[idx++]) {
|
|
2463
|
+
case VNodeJournalOpCode.SetText:
|
|
2464
|
+
journal[idx++].nodeValue = journal[idx++];
|
|
2465
|
+
break;
|
|
2466
|
+
case VNodeJournalOpCode.SetAttribute:
|
|
2467
|
+
const element = journal[idx++];
|
|
2468
|
+
let key = journal[idx++];
|
|
2469
|
+
"className" === key && (key = "class");
|
|
2470
|
+
const value = journal[idx++];
|
|
2471
|
+
isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value = String(value) : key === dangerouslySetInnerHTML ? element.innerHTML = value : null == value || false === value ? element.removeAttribute(key) : element.setAttribute(key, String(value));
|
|
2472
|
+
break;
|
|
2473
|
+
case VNodeJournalOpCode.HoistStyles:
|
|
2474
|
+
const document2 = journal[idx++];
|
|
2475
|
+
const head = document2.head;
|
|
2476
|
+
const styles = document2.querySelectorAll(QStylesAllSelector);
|
|
2477
|
+
for (let i = 0; i < styles.length; i++) {
|
|
2478
|
+
head.appendChild(styles[i]);
|
|
2479
|
+
}
|
|
2480
|
+
break;
|
|
2481
|
+
case VNodeJournalOpCode.Remove:
|
|
2482
|
+
const removeParent = journal[idx++];
|
|
2483
|
+
let nodeToRemove;
|
|
2484
|
+
for (; idx < length && "number" != typeof (nodeToRemove = journal[idx]); ) {
|
|
2485
|
+
removeParent.removeChild(nodeToRemove), idx++;
|
|
2486
|
+
}
|
|
2487
|
+
break;
|
|
2488
|
+
case VNodeJournalOpCode.Insert:
|
|
2489
|
+
const insertParent = journal[idx++];
|
|
2490
|
+
const insertBefore = journal[idx++];
|
|
2491
|
+
let newChild;
|
|
2492
|
+
for (; idx < length && "number" != typeof (newChild = journal[idx]); ) {
|
|
2493
|
+
insertParent.insertBefore(newChild, insertBefore), idx++;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
journal.length = 0;
|
|
2498
|
+
};
|
|
2499
|
+
const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
|
|
2500
|
+
ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent), newChild === insertBefore && (insertBefore = null);
|
|
2501
|
+
let adjustedInsertBefore = null;
|
|
2502
|
+
null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, true, false)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, true, true) : insertBefore, adjustedInsertBefore && vnode_ensureInflatedIfText(journal, adjustedInsertBefore);
|
|
2503
|
+
const domParentVNode = vnode_getDomParentVNode(parent);
|
|
2504
|
+
const parentNode = domParentVNode && domParentVNode[ElementVNodeProps.element];
|
|
2505
|
+
if (parentNode) {
|
|
2506
|
+
const domChildren = vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild);
|
|
2507
|
+
domChildren.length && journal.push(VNodeJournalOpCode.Insert, parentNode, vnode_getNode(adjustedInsertBefore), ...domChildren);
|
|
2508
|
+
}
|
|
2509
|
+
const newChildCurrentParent = newChild[VNodeProps.parent];
|
|
2510
|
+
newChildCurrentParent && (newChild[VNodeProps.previousSibling] || newChild[VNodeProps.nextSibling] || vnode_isElementVNode(newChildCurrentParent) && newChildCurrentParent !== parent) && vnode_remove(journal, newChildCurrentParent, newChild, false);
|
|
2511
|
+
const vNext = insertBefore;
|
|
2512
|
+
const vPrevious = vNext ? vNext[VNodeProps.previousSibling] : parent[ElementVNodeProps.lastChild];
|
|
2513
|
+
vNext ? vNext[VNodeProps.previousSibling] = newChild : parent[ElementVNodeProps.lastChild] = newChild, vPrevious ? vPrevious[VNodeProps.nextSibling] = newChild : parent[ElementVNodeProps.firstChild] = newChild, newChild[VNodeProps.previousSibling] = vPrevious, newChild[VNodeProps.nextSibling] = vNext, newChild[VNodeProps.parent] = parent;
|
|
2514
|
+
};
|
|
2515
|
+
const vnode_getDomParent = (vnode) => (vnode = vnode_getDomParentVNode(vnode)) && vnode[ElementVNodeProps.element];
|
|
2516
|
+
const vnode_getDomParentVNode = (vnode) => {
|
|
2517
|
+
for (; vnode && !vnode_isElementVNode(vnode); ) {
|
|
2518
|
+
vnode = vnode[VNodeProps.parent];
|
|
2519
|
+
}
|
|
2520
|
+
return vnode;
|
|
2521
|
+
};
|
|
2522
|
+
const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
|
|
2523
|
+
assertEqual(vParent, vnode_getParent(vToRemove)), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove);
|
|
2524
|
+
const vPrevious = vToRemove[VNodeProps.previousSibling];
|
|
2525
|
+
const vNext = vToRemove[VNodeProps.nextSibling];
|
|
2526
|
+
if (vPrevious ? vPrevious[VNodeProps.nextSibling] = vNext : vParent[ElementVNodeProps.firstChild] = vNext, vNext ? vNext[VNodeProps.previousSibling] = vPrevious : vParent[ElementVNodeProps.lastChild] = vPrevious, vToRemove[VNodeProps.previousSibling] = null, vToRemove[VNodeProps.nextSibling] = null, removeDOM) {
|
|
2527
|
+
const domParent = vnode_getDomParent(vParent);
|
|
2528
|
+
if (vnode_getAttr(vParent, dangerouslySetInnerHTML)) {
|
|
2529
|
+
return;
|
|
2530
|
+
}
|
|
2531
|
+
const children = vnode_getDOMChildNodes(journal, vToRemove);
|
|
2532
|
+
domParent && children.length && journal.push(VNodeJournalOpCode.Remove, domParent, ...children);
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
const vnode_truncate = (journal, vParent, vDelete) => {
|
|
2536
|
+
const parent = vnode_getDomParent(vParent);
|
|
2537
|
+
const children = vnode_getDOMChildNodes(journal, vDelete);
|
|
2538
|
+
parent && children.length && journal.push(VNodeJournalOpCode.Remove, parent, ...children);
|
|
2539
|
+
const vPrevious = vDelete[VNodeProps.previousSibling];
|
|
2540
|
+
vPrevious ? vPrevious[VNodeProps.nextSibling] = null : vParent[ElementVNodeProps.firstChild] = null, vParent[ElementVNodeProps.lastChild] = vPrevious;
|
|
2541
|
+
};
|
|
2542
|
+
const vnode_getElementName = (vnode) => {
|
|
2543
|
+
const elementVNode = ensureElementVNode(vnode);
|
|
2544
|
+
let elementName = elementVNode[ElementVNodeProps.elementName];
|
|
2545
|
+
if (void 0 === elementName) {
|
|
2546
|
+
const element = elementVNode[ElementVNodeProps.element];
|
|
2547
|
+
const nodeName = fastNodeName(element);
|
|
2548
|
+
elementName = elementVNode[ElementVNodeProps.elementName] = nodeName, elementVNode[VNodeProps.flags] |= vnode_getElementNamespaceFlags(element);
|
|
2549
|
+
}
|
|
2550
|
+
return elementName;
|
|
2551
|
+
};
|
|
2552
|
+
const vnode_getText = (vnode) => {
|
|
2553
|
+
const textVNode = ensureTextVNode(vnode);
|
|
2554
|
+
let text = textVNode[TextVNodeProps.text];
|
|
2555
|
+
return void 0 === text && (text = textVNode[TextVNodeProps.text] = textVNode[TextVNodeProps.node].nodeValue), text;
|
|
2556
|
+
};
|
|
2557
|
+
const vnode_setText = (journal, textVNode, text) => {
|
|
2558
|
+
vnode_ensureTextInflated(journal, textVNode);
|
|
2559
|
+
journal.push(VNodeJournalOpCode.SetText, textVNode[TextVNodeProps.node], textVNode[TextVNodeProps.text] = text);
|
|
2560
|
+
};
|
|
2561
|
+
const vnode_getFirstChild = (vnode) => {
|
|
2562
|
+
if (vnode_isTextVNode(vnode)) {
|
|
2563
|
+
return null;
|
|
2564
|
+
}
|
|
2565
|
+
let vFirstChild = vnode[ElementVNodeProps.firstChild];
|
|
2566
|
+
return void 0 === vFirstChild && (vFirstChild = ensureMaterialized(vnode)), vFirstChild;
|
|
2567
|
+
};
|
|
2568
|
+
const vnode_materialize = (vNode) => {
|
|
2569
|
+
const element = vNode[ElementVNodeProps.element];
|
|
2570
|
+
const firstChild = fastFirstChild(element);
|
|
2571
|
+
const vNodeData = element.ownerDocument?.qVNodeData?.get(element);
|
|
2572
|
+
return materialize(vNode, element, firstChild, vNodeData);
|
|
2573
|
+
};
|
|
2574
|
+
const materialize = (vNode, element, firstChild, vNodeData) => {
|
|
2575
|
+
if (vNodeData) {
|
|
2576
|
+
if (vNodeData.charCodeAt(0) === VNodeDataChar.SEPARATOR) {
|
|
2577
|
+
const elementVNodeDataStartIdx = 1;
|
|
2578
|
+
let elementVNodeDataEndIdx = 1;
|
|
2579
|
+
for (; vNodeData.charCodeAt(elementVNodeDataEndIdx) !== VNodeDataChar.SEPARATOR; ) {
|
|
2580
|
+
elementVNodeDataEndIdx++;
|
|
2581
|
+
}
|
|
2582
|
+
const elementVNodeData = vNodeData.substring(elementVNodeDataStartIdx, elementVNodeDataEndIdx);
|
|
2583
|
+
vNodeData = vNodeData.substring(elementVNodeDataEndIdx + 1);
|
|
2584
|
+
const vFirstChild = materializeFromDOM(vNode, firstChild, elementVNodeData);
|
|
2585
|
+
if (!vNodeData) {
|
|
2586
|
+
return vFirstChild;
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
return materializeFromVNodeData(vNode, vNodeData, element, firstChild);
|
|
2590
|
+
}
|
|
2591
|
+
return materializeFromDOM(vNode, firstChild);
|
|
2592
|
+
};
|
|
2593
|
+
const ensureMaterialized = (vnode) => {
|
|
2594
|
+
const vParent = ensureElementVNode(vnode);
|
|
2595
|
+
let vFirstChild = vParent[ElementVNodeProps.firstChild];
|
|
2596
|
+
if (void 0 === vFirstChild) {
|
|
2597
|
+
vFirstChild = vParent[VNodeProps.parent] && shouldIgnoreChildren(vParent[ElementVNodeProps.element]) ? vParent[ElementVNodeProps.firstChild] = vParent[ElementVNodeProps.lastChild] = null : vnode_materialize(vParent);
|
|
2598
|
+
}
|
|
2599
|
+
return assertTrue(void 0 !== vParent[ElementVNodeProps.firstChild]), assertTrue(void 0 !== vParent[ElementVNodeProps.lastChild]), vFirstChild;
|
|
2600
|
+
};
|
|
2601
|
+
let _fastHasAttribute = null;
|
|
2602
|
+
const shouldIgnoreChildren = (node) => (_fastHasAttribute || (_fastHasAttribute = node.hasAttribute), _fastHasAttribute.call(node, "q:container"));
|
|
2603
|
+
let _fastNodeType = null;
|
|
2604
|
+
const fastNodeType = (node) => (_fastNodeType || (_fastNodeType = fastGetter(node, "nodeType")), _fastNodeType.call(node));
|
|
2605
|
+
const fastIsTextOrElement = (node) => {
|
|
2606
|
+
const type = fastNodeType(node);
|
|
2607
|
+
return 3 === type || 1 === type;
|
|
2608
|
+
};
|
|
2609
|
+
let _fastNextSibling = null;
|
|
2610
|
+
const fastNextSibling = (node) => {
|
|
2611
|
+
for (_fastNextSibling || (_fastNextSibling = fastGetter(node, "nextSibling")), _fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild")); node; ) {
|
|
2612
|
+
if (null !== (node = _fastNextSibling.call(node))) {
|
|
2613
|
+
const type = fastNodeType(node);
|
|
2614
|
+
if (3 === type || 1 === type) {
|
|
2615
|
+
break;
|
|
2616
|
+
}
|
|
2617
|
+
if (8 === type) {
|
|
2618
|
+
const nodeValue = node.nodeValue;
|
|
2619
|
+
if (nodeValue?.startsWith(QIgnore)) {
|
|
2620
|
+
return getNodeAfterCommentNode(node, QContainerIsland, _fastNextSibling, _fastFirstChild);
|
|
2621
|
+
}
|
|
2622
|
+
if (node.nodeValue?.startsWith(QContainerIslandEnd)) {
|
|
2623
|
+
return getNodeAfterCommentNode(node, QIgnoreEnd, _fastNextSibling, _fastFirstChild);
|
|
2624
|
+
}
|
|
2625
|
+
if (nodeValue?.startsWith("q:container")) {
|
|
2626
|
+
for (; node && (node = _fastNextSibling.call(node)) && (8 !== fastNodeType(node) || !node.nodeValue?.startsWith("/q:container")); ) {
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
return node;
|
|
2633
|
+
};
|
|
2634
|
+
function getNodeAfterCommentNode(node, commentValue, nextSibling, firstChild) {
|
|
2635
|
+
for (; node; ) {
|
|
2636
|
+
if (node.nodeValue?.startsWith(commentValue)) {
|
|
2637
|
+
return node = nextSibling.call(node) || null;
|
|
2638
|
+
}
|
|
2639
|
+
let nextNode = firstChild.call(node);
|
|
2640
|
+
nextNode || (nextNode = nextSibling.call(node)), nextNode || (nextNode = fastParentNode(node), nextNode && (nextNode = nextSibling.call(nextNode))), node = nextNode;
|
|
2641
|
+
}
|
|
2642
|
+
return null;
|
|
2643
|
+
}
|
|
2644
|
+
let _fastParentNode = null;
|
|
2645
|
+
const fastParentNode = (node) => (_fastParentNode || (_fastParentNode = fastGetter(node, "parentNode")), _fastParentNode.call(node));
|
|
2646
|
+
let _fastFirstChild = null;
|
|
2647
|
+
const fastFirstChild = (node) => {
|
|
2648
|
+
for (_fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild")), node = node && _fastFirstChild.call(node); node && !fastIsTextOrElement(node); ) {
|
|
2649
|
+
node = fastNextSibling(node);
|
|
2650
|
+
}
|
|
2651
|
+
return node;
|
|
2652
|
+
};
|
|
2653
|
+
let _fastNamespaceURI = null;
|
|
2654
|
+
const fastNamespaceURI = (element) => (_fastNamespaceURI || (_fastNamespaceURI = fastGetter(element, "namespaceURI")), _fastNamespaceURI.call(element));
|
|
2655
|
+
let _fastNodeName = null;
|
|
2656
|
+
const fastNodeName = (element) => (_fastNodeName || (_fastNodeName = fastGetter(element, "nodeName")), _fastNodeName.call(element));
|
|
2657
|
+
const fastGetter = (prototype, name) => {
|
|
2658
|
+
let getter;
|
|
2659
|
+
for (; prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
|
|
2660
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
2661
|
+
}
|
|
2662
|
+
return getter || function() {
|
|
2663
|
+
return this[name];
|
|
2664
|
+
};
|
|
2665
|
+
};
|
|
2666
|
+
const isQStyleElement = (node) => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute("q:sstyle") || node.hasAttribute(QStyle));
|
|
2667
|
+
const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
2668
|
+
let vFirstChild = null;
|
|
2669
|
+
const skipStyleElements = () => {
|
|
2670
|
+
for (; isQStyleElement(child); ) {
|
|
2671
|
+
child = fastNextSibling(child);
|
|
2672
|
+
}
|
|
2673
|
+
};
|
|
2674
|
+
let child = firstChild;
|
|
2675
|
+
skipStyleElements();
|
|
2676
|
+
let vChild = null;
|
|
2677
|
+
for (; child; ) {
|
|
2678
|
+
const nodeType = fastNodeType(child);
|
|
2679
|
+
let vNextChild = null;
|
|
2680
|
+
3 === nodeType ? vNextChild = vnode_newText(child, child.textContent ?? void 0) : 1 === nodeType && (vNextChild = vnode_newUnMaterializedElement(child)), vNextChild && (vNextChild[VNodeProps.parent] = vParent, vChild && (vChild[VNodeProps.nextSibling] = vNextChild), vNextChild[VNodeProps.previousSibling] = vChild, vChild = vNextChild), vFirstChild || (vParent[ElementVNodeProps.firstChild] = vFirstChild = vChild), child = fastNextSibling(child), skipStyleElements();
|
|
2681
|
+
}
|
|
2682
|
+
if (vParent[ElementVNodeProps.lastChild] = vChild || null, vParent[ElementVNodeProps.firstChild] = vFirstChild, vData) {
|
|
2683
|
+
let container = null;
|
|
2684
|
+
processVNodeData$1(vData, (peek, consumeValue) => {
|
|
2685
|
+
if (peek() === VNodeDataChar.ID) {
|
|
2686
|
+
container || (container = getDomContainer(vParent[ElementVNodeProps.element]));
|
|
2687
|
+
const id = consumeValue();
|
|
2688
|
+
container.$setRawState$(parseInt(id), vParent);
|
|
2689
|
+
} else {
|
|
2690
|
+
peek() === VNodeDataChar.BACK_REFS ? (container || (container = getDomContainer(vParent[ElementVNodeProps.element])), setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
|
|
527
2691
|
}
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
return vFirstChild;
|
|
2695
|
+
};
|
|
2696
|
+
function setEffectBackRefFromVNodeData(vParent, value, container) {
|
|
2697
|
+
const deserializedSubMap = container.$getObjectById$(value);
|
|
2698
|
+
if (vParent[_EFFECT_BACK_REF]) {
|
|
2699
|
+
mergeMaps(vParent[_EFFECT_BACK_REF], deserializedSubMap);
|
|
2700
|
+
} else {
|
|
2701
|
+
Object.defineProperty(vParent, _EFFECT_BACK_REF, {
|
|
2702
|
+
value: deserializedSubMap
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
const processVNodeData$1 = (vData, callback) => {
|
|
2707
|
+
let nextToConsumeIdx = 0;
|
|
2708
|
+
let ch = 0;
|
|
2709
|
+
let peekCh = 0;
|
|
2710
|
+
const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
|
|
2711
|
+
const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
|
|
2712
|
+
const consumeValue = () => {
|
|
2713
|
+
consume();
|
|
2714
|
+
const start = nextToConsumeIdx;
|
|
2715
|
+
for (; peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
|
|
2716
|
+
consume();
|
|
528
2717
|
}
|
|
2718
|
+
return vData.substring(start, nextToConsumeIdx);
|
|
2719
|
+
};
|
|
2720
|
+
for (; 0 !== peek(); ) {
|
|
2721
|
+
callback(peek, consumeValue, consume, nextToConsumeIdx);
|
|
529
2722
|
}
|
|
530
2723
|
};
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
2724
|
+
const vnode_getNextSibling = (vnode) => vnode[VNodeProps.nextSibling];
|
|
2725
|
+
const vnode_getPreviousSibling = (vnode) => vnode[VNodeProps.previousSibling];
|
|
2726
|
+
const vnode_setAttr = (journal, vnode, key, value) => {
|
|
2727
|
+
const type = vnode[VNodeProps.flags];
|
|
2728
|
+
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
2729
|
+
vnode_ensureElementInflated(vnode);
|
|
2730
|
+
const props = vnode_getProps(vnode);
|
|
2731
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
2732
|
+
if (idx >= 0) {
|
|
2733
|
+
if (props[idx + 1] != value && type & VNodeFlags.Element) {
|
|
2734
|
+
journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
|
|
2735
|
+
}
|
|
2736
|
+
null == value ? props.splice(idx, 2) : props[idx + 1] = value;
|
|
2737
|
+
} else if (null != value && (props.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
|
|
2738
|
+
journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
|
|
539
2739
|
}
|
|
540
|
-
midKey < key ? bottom = mid + 1 : top = mid - 1;
|
|
541
2740
|
}
|
|
542
|
-
return ~(bottom << 1);
|
|
543
2741
|
};
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
2742
|
+
const vnode_getAttr = (vnode, key) => {
|
|
2743
|
+
if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
2744
|
+
vnode_ensureElementInflated(vnode);
|
|
2745
|
+
const props = vnode_getProps(vnode);
|
|
2746
|
+
return mapArray_get(props, key, 0);
|
|
2747
|
+
}
|
|
2748
|
+
return null;
|
|
547
2749
|
};
|
|
548
2750
|
const vnode_getProp = (vnode, key, getObject) => {
|
|
549
2751
|
const type = vnode[VNodeProps.flags];
|
|
550
2752
|
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
551
2753
|
type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
|
|
552
|
-
const
|
|
2754
|
+
const props = vnode_getProps(vnode);
|
|
2755
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
553
2756
|
if (idx >= 0) {
|
|
554
|
-
let value =
|
|
555
|
-
return "string" == typeof value && getObject && (
|
|
2757
|
+
let value = props[idx + 1];
|
|
2758
|
+
return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)), value;
|
|
556
2759
|
}
|
|
557
2760
|
}
|
|
558
2761
|
return null;
|
|
559
2762
|
};
|
|
560
2763
|
const vnode_setProp = (vnode, key, value) => {
|
|
561
2764
|
ensureElementOrVirtualVNode(vnode);
|
|
562
|
-
const
|
|
563
|
-
|
|
2765
|
+
const props = vnode_getProps(vnode);
|
|
2766
|
+
const idx = mapApp_findIndx(props, key, 0);
|
|
2767
|
+
idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
|
|
564
2768
|
};
|
|
565
2769
|
const vnode_getPropStartIndex = (vnode) => {
|
|
566
2770
|
const type = vnode[VNodeProps.flags] & VNodeFlags.TYPE_MASK;
|
|
@@ -572,21 +2776,124 @@ const vnode_getPropStartIndex = (vnode) => {
|
|
|
572
2776
|
}
|
|
573
2777
|
throw qError(QError.invalidVNodeType, [type]);
|
|
574
2778
|
};
|
|
2779
|
+
const vnode_getProps = (vnode) => vnode[vnode_getPropStartIndex(vnode)];
|
|
2780
|
+
const vnode_getParent = (vnode) => vnode[VNodeProps.parent] || null;
|
|
2781
|
+
const vnode_getNode = (vnode) => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)), vnode[TextVNodeProps.node]);
|
|
2782
|
+
const isNumber = (ch) => 48 <= ch && ch <= 57;
|
|
2783
|
+
const isLowercase = (ch) => 97 <= ch && ch <= 122;
|
|
2784
|
+
const stack = [];
|
|
2785
|
+
function materializeFromVNodeData(vParent, vData, element, child) {
|
|
2786
|
+
let idx = 0;
|
|
2787
|
+
let vFirst = null;
|
|
2788
|
+
let vLast = null;
|
|
2789
|
+
let previousTextNode = null;
|
|
2790
|
+
const addVNode = (node) => {
|
|
2791
|
+
node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift, idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast, node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node), vLast = node;
|
|
2792
|
+
};
|
|
2793
|
+
let textIdx = 0;
|
|
2794
|
+
let combinedText = null;
|
|
2795
|
+
let container = null;
|
|
2796
|
+
return processVNodeData$1(vData, (peek, consumeValue, consume, nextToConsumeIdx) => {
|
|
2797
|
+
if (isNumber(peek())) {
|
|
2798
|
+
for (; !isElement(child); ) {
|
|
2799
|
+
if (!(child = fastNextSibling(child))) {
|
|
2800
|
+
throw qError(QError.materializeVNodeDataError, [vData, peek(), nextToConsumeIdx]);
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
for (; isQStyleElement(child); ) {
|
|
2804
|
+
child = fastNextSibling(child);
|
|
2805
|
+
}
|
|
2806
|
+
combinedText = null, previousTextNode = null;
|
|
2807
|
+
let value = 0;
|
|
2808
|
+
for (; isNumber(peek()); ) {
|
|
2809
|
+
value *= 10, value += consume() - 48;
|
|
2810
|
+
}
|
|
2811
|
+
for (; value--; ) {
|
|
2812
|
+
addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
|
|
2813
|
+
}
|
|
2814
|
+
} else if (peek() === VNodeDataChar.SCOPED_STYLE) {
|
|
2815
|
+
vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
|
|
2816
|
+
} else if (peek() === VNodeDataChar.RENDER_FN) {
|
|
2817
|
+
vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
|
|
2818
|
+
} else if (peek() === VNodeDataChar.ID) {
|
|
2819
|
+
container || (container = getDomContainer(element));
|
|
2820
|
+
const id = consumeValue();
|
|
2821
|
+
container.$setRawState$(parseInt(id), vParent);
|
|
2822
|
+
} else if (peek() === VNodeDataChar.PROPS) {
|
|
2823
|
+
vnode_setAttr(null, vParent, "q:props", consumeValue());
|
|
2824
|
+
} else if (peek() === VNodeDataChar.KEY) {
|
|
2825
|
+
vnode_setAttr(null, vParent, "q:key", consumeValue());
|
|
2826
|
+
} else if (peek() === VNodeDataChar.SEQ) {
|
|
2827
|
+
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
2828
|
+
} else if (peek() === VNodeDataChar.SEQ_IDX) {
|
|
2829
|
+
vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
|
|
2830
|
+
} else if (peek() === VNodeDataChar.BACK_REFS) {
|
|
2831
|
+
container || (container = getDomContainer(element)), setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
|
|
2832
|
+
} else if (peek() === VNodeDataChar.SLOT_PARENT) {
|
|
2833
|
+
vnode_setProp(vParent, "q:sparent", consumeValue());
|
|
2834
|
+
} else if (peek() === VNodeDataChar.CONTEXT) {
|
|
2835
|
+
vnode_setAttr(null, vParent, "q:ctx", consumeValue());
|
|
2836
|
+
} else if (peek() === VNodeDataChar.OPEN) {
|
|
2837
|
+
consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx), idx = 0, vParent = vLast, vFirst = vLast = null;
|
|
2838
|
+
} else if (peek() === VNodeDataChar.SEPARATOR) {
|
|
2839
|
+
const key = consumeValue();
|
|
2840
|
+
const value = consumeValue();
|
|
2841
|
+
vnode_setAttr(null, vParent, key, value);
|
|
2842
|
+
} else if (peek() === VNodeDataChar.CLOSE) {
|
|
2843
|
+
consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(), vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
|
|
2844
|
+
} else if (peek() === VNodeDataChar.SLOT) {
|
|
2845
|
+
vnode_setAttr(null, vParent, QSlot, consumeValue());
|
|
2846
|
+
} else {
|
|
2847
|
+
const textNode = child && 3 === fastNodeType(child) ? child : null;
|
|
2848
|
+
null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
|
|
2849
|
+
let length = 0;
|
|
2850
|
+
for (; isLowercase(peek()); ) {
|
|
2851
|
+
length += consume() - 97, length *= 26;
|
|
2852
|
+
}
|
|
2853
|
+
length += consume() - 65;
|
|
2854
|
+
const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
|
|
2855
|
+
addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)), textIdx += length;
|
|
2856
|
+
}
|
|
2857
|
+
}), vParent[ElementVNodeProps.lastChild] = vLast, vFirst;
|
|
2858
|
+
}
|
|
2859
|
+
const vnode_getType = (vnode) => {
|
|
2860
|
+
const type = vnode[VNodeProps.flags];
|
|
2861
|
+
if (type & VNodeFlags.Element) {
|
|
2862
|
+
return 1;
|
|
2863
|
+
}
|
|
2864
|
+
if (type & VNodeFlags.Virtual) {
|
|
2865
|
+
return 11;
|
|
2866
|
+
}
|
|
2867
|
+
if (type & VNodeFlags.Text) {
|
|
2868
|
+
return 3;
|
|
2869
|
+
}
|
|
2870
|
+
throw qError(QError.invalidVNodeType, [type]);
|
|
2871
|
+
};
|
|
2872
|
+
const isElement = (node) => node && "object" == typeof node && 1 === fastNodeType(node);
|
|
2873
|
+
const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
|
|
2874
|
+
let projectionDepth = 1;
|
|
2875
|
+
for (; projectionDepth--; ) {
|
|
2876
|
+
for (; vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
|
|
2877
|
+
const qSlotParent = vnode_getProp(vHost, "q:sparent", (id) => vnode_locate(rootVNode, id));
|
|
2878
|
+
const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
|
|
2879
|
+
vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
|
|
2880
|
+
}
|
|
2881
|
+
projectionDepth > 0 && (vHost = vnode_getParent(vHost));
|
|
2882
|
+
}
|
|
2883
|
+
return vHost;
|
|
2884
|
+
};
|
|
575
2885
|
const VNodeArray = class VNode extends Array {
|
|
576
2886
|
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
577
|
-
|
|
578
|
-
return vnode.push(firstChild, lastChild, element, elementName), vnode;
|
|
2887
|
+
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
|
|
579
2888
|
}
|
|
580
2889
|
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
581
|
-
|
|
582
|
-
return vnode.push(textNode, text), vnode;
|
|
2890
|
+
return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
|
|
583
2891
|
}
|
|
584
2892
|
static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
|
|
585
|
-
|
|
586
|
-
return vnode.push(firstChild, lastChild), vnode;
|
|
2893
|
+
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
|
|
587
2894
|
}
|
|
588
|
-
constructor(flags, parent, previousSibling, nextSibling) {
|
|
589
|
-
super(
|
|
2895
|
+
constructor(flags, parent, previousSibling, nextSibling, ...rest) {
|
|
2896
|
+
super(flags, parent, previousSibling, nextSibling, ...rest);
|
|
590
2897
|
}
|
|
591
2898
|
};
|
|
592
2899
|
let _context;
|
|
@@ -614,9 +2921,11 @@ function invokeApply(context, fn, args) {
|
|
|
614
2921
|
return returnValue;
|
|
615
2922
|
}
|
|
616
2923
|
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
617
|
-
const
|
|
2924
|
+
const domContainer = getDomContainer(element);
|
|
2925
|
+
const container = domContainer.element;
|
|
2926
|
+
const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
|
|
618
2927
|
const locale = container?.getAttribute("q:locale") || void 0;
|
|
619
|
-
return newInvokeContext(locale,
|
|
2928
|
+
return newInvokeContext(locale, vNode, element, event, url);
|
|
620
2929
|
};
|
|
621
2930
|
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
622
2931
|
const ctx = {
|
|
@@ -638,18 +2947,1221 @@ const trackSignal = (fn, subscriber, property, container, data) => {
|
|
|
638
2947
|
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
639
2948
|
const previousContainer = trackInvocation.$container$;
|
|
640
2949
|
try {
|
|
641
|
-
return trackInvocation.$effectSubscriber$ =
|
|
2950
|
+
return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data), trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
642
2951
|
} finally {
|
|
643
2952
|
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
644
2953
|
}
|
|
645
2954
|
};
|
|
2955
|
+
const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignal && value.$hostElement$ !== host && host && (value.$hostElement$ = host), trackSignal(() => value.value, host, property, container, data));
|
|
2956
|
+
const createContextId = (name) => /* @__PURE__ */ Object.freeze({
|
|
2957
|
+
id: fromCamelToKebabCase(name)
|
|
2958
|
+
});
|
|
2959
|
+
const ERROR_CONTEXT = /* @__PURE__ */ createContextId("qk-error");
|
|
2960
|
+
function processVNodeData(document2) {
|
|
2961
|
+
const vNodeDataMap = document2.qVNodeData || (document2.qVNodeData = /* @__PURE__ */ new WeakMap());
|
|
2962
|
+
const prototype = document2.body;
|
|
2963
|
+
const getAttribute = prototype.getAttribute;
|
|
2964
|
+
const hasAttribute = prototype.hasAttribute;
|
|
2965
|
+
const getNodeType = ((prototype2, name) => {
|
|
2966
|
+
let getter;
|
|
2967
|
+
for (; prototype2 && !(getter = Object.getOwnPropertyDescriptor(prototype2, name)?.get); ) {
|
|
2968
|
+
prototype2 = Object.getPrototypeOf(prototype2);
|
|
2969
|
+
}
|
|
2970
|
+
return getter || function() {
|
|
2971
|
+
return this[name];
|
|
2972
|
+
};
|
|
2973
|
+
})(prototype, "nodeType");
|
|
2974
|
+
const attachVnodeDataAndRefs = (element) => {
|
|
2975
|
+
Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script) => {
|
|
2976
|
+
script.setAttribute("type", "x-qwik/vnode");
|
|
2977
|
+
const qContainerElement = script.closest("[q\\:container]");
|
|
2978
|
+
qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = /* @__PURE__ */ new Map();
|
|
2979
|
+
}), element.querySelectorAll("[q\\:shadowroot]").forEach((parent) => {
|
|
2980
|
+
const shadowRoot = parent.shadowRoot;
|
|
2981
|
+
shadowRoot && attachVnodeDataAndRefs(shadowRoot);
|
|
2982
|
+
});
|
|
2983
|
+
};
|
|
2984
|
+
let NodeType;
|
|
2985
|
+
attachVnodeDataAndRefs(document2), function(NodeType2) {
|
|
2986
|
+
NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT", NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT", NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END", NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END", NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END", NodeType2[NodeType2.OTHER = 0] = "OTHER";
|
|
2987
|
+
}(NodeType || (NodeType = {}));
|
|
2988
|
+
const getFastNodeType = (node) => {
|
|
2989
|
+
const nodeType = getNodeType.call(node);
|
|
2990
|
+
if (1 === nodeType) {
|
|
2991
|
+
if (null === getAttribute.call(node, "q:container")) {
|
|
2992
|
+
if (hasAttribute.call(node, "q:shadowroot")) {
|
|
2993
|
+
return NodeType.ELEMENT_SHADOW_ROOT;
|
|
2994
|
+
}
|
|
2995
|
+
return hasAttribute.call(node, ":") ? NodeType.ELEMENT : NodeType.OTHER;
|
|
2996
|
+
}
|
|
2997
|
+
return NodeType.ELEMENT_CONTAINER;
|
|
2998
|
+
}
|
|
2999
|
+
if (8 === nodeType) {
|
|
3000
|
+
const nodeValue = node.nodeValue || "";
|
|
3001
|
+
if (nodeValue.startsWith("q:container-island")) {
|
|
3002
|
+
return NodeType.COMMENT_ISLAND_START;
|
|
3003
|
+
}
|
|
3004
|
+
if (nodeValue.startsWith("q:ignore")) {
|
|
3005
|
+
return NodeType.COMMENT_IGNORE_START;
|
|
3006
|
+
}
|
|
3007
|
+
if (nodeValue.startsWith("q:container")) {
|
|
3008
|
+
return NodeType.COMMENT_SKIP_START;
|
|
3009
|
+
}
|
|
3010
|
+
if (nodeValue.startsWith("/q:container-island")) {
|
|
3011
|
+
return NodeType.COMMENT_ISLAND_END;
|
|
3012
|
+
}
|
|
3013
|
+
if (nodeValue.startsWith("/q:ignore")) {
|
|
3014
|
+
return NodeType.COMMENT_IGNORE_END;
|
|
3015
|
+
}
|
|
3016
|
+
if (nodeValue.startsWith("/q:container")) {
|
|
3017
|
+
return NodeType.COMMENT_SKIP_END;
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
return NodeType.OTHER;
|
|
3021
|
+
};
|
|
3022
|
+
const isSeparator = (ch) => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
|
|
3023
|
+
const findVDataSectionEnd = (vData, start, end) => {
|
|
3024
|
+
let depth = 0;
|
|
3025
|
+
for (; start < end; ) {
|
|
3026
|
+
const ch = vData.charCodeAt(start);
|
|
3027
|
+
if (0 === depth && isSeparator(ch)) {
|
|
3028
|
+
break;
|
|
3029
|
+
}
|
|
3030
|
+
ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--, start++;
|
|
3031
|
+
}
|
|
3032
|
+
return start;
|
|
3033
|
+
};
|
|
3034
|
+
const nextSibling = (node) => {
|
|
3035
|
+
for (; node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {
|
|
3036
|
+
}
|
|
3037
|
+
return node;
|
|
3038
|
+
};
|
|
3039
|
+
const firstChild = (node) => {
|
|
3040
|
+
for (; node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {
|
|
3041
|
+
}
|
|
3042
|
+
return node;
|
|
3043
|
+
};
|
|
3044
|
+
const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs) => {
|
|
3045
|
+
const vData_length = vData.length;
|
|
3046
|
+
let elementIdx = 0;
|
|
3047
|
+
let vNodeElementIndex = -1;
|
|
3048
|
+
let vData_start = 0;
|
|
3049
|
+
let vData_end = 0;
|
|
3050
|
+
let ch = 0;
|
|
3051
|
+
let needsToStoreRef = -1;
|
|
3052
|
+
let nextNode = null;
|
|
3053
|
+
const howManyElementsToSkip = () => {
|
|
3054
|
+
let elementsToSkip = 0;
|
|
3055
|
+
for (; isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1, vData_start++, !(vData_start >= vData_length)); ) {
|
|
3056
|
+
}
|
|
3057
|
+
return elementsToSkip;
|
|
3058
|
+
};
|
|
3059
|
+
do {
|
|
3060
|
+
if (node === exitNode) {
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3063
|
+
nextNode = null;
|
|
3064
|
+
const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
|
|
3065
|
+
if (nodeType === NodeType.ELEMENT_CONTAINER) {
|
|
3066
|
+
const container = node;
|
|
3067
|
+
let cursor = node;
|
|
3068
|
+
for (; cursor && !(nextNode = nextSibling(cursor)); ) {
|
|
3069
|
+
cursor = cursor.parentNode;
|
|
3070
|
+
}
|
|
3071
|
+
walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
|
|
3072
|
+
} else if (nodeType === NodeType.COMMENT_IGNORE_START) {
|
|
3073
|
+
let islandNode = node;
|
|
3074
|
+
do {
|
|
3075
|
+
if (islandNode = walker2.nextNode(), !islandNode) {
|
|
3076
|
+
throw new Error(`Island inside <!--${node?.nodeValue}--> not found!`);
|
|
3077
|
+
}
|
|
3078
|
+
} while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
|
|
3079
|
+
nextNode = null;
|
|
3080
|
+
} else if (nodeType === NodeType.COMMENT_ISLAND_END) {
|
|
3081
|
+
nextNode = node;
|
|
3082
|
+
do {
|
|
3083
|
+
if (nextNode = walker2.nextNode(), !nextNode) {
|
|
3084
|
+
throw new Error("Ignore block not closed!");
|
|
3085
|
+
}
|
|
3086
|
+
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
|
|
3087
|
+
nextNode = null;
|
|
3088
|
+
} else if (nodeType === NodeType.COMMENT_SKIP_START) {
|
|
3089
|
+
nextNode = node;
|
|
3090
|
+
do {
|
|
3091
|
+
if (nextNode = nextSibling(nextNode), !nextNode) {
|
|
3092
|
+
throw new Error(`<!--${node?.nodeValue}--> not closed!`);
|
|
3093
|
+
}
|
|
3094
|
+
} while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
|
|
3095
|
+
walkContainer(walker2, node, node, nextNode, "", null);
|
|
3096
|
+
} else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
|
|
3097
|
+
nextNode = nextSibling(node);
|
|
3098
|
+
const shadowRootContainer = node;
|
|
3099
|
+
const shadowRoot = shadowRootContainer?.shadowRoot;
|
|
3100
|
+
shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
|
|
3101
|
+
}
|
|
3102
|
+
if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
|
|
3103
|
+
if (vNodeElementIndex < elementIdx) {
|
|
3104
|
+
if (-1 === vNodeElementIndex && (vNodeElementIndex = 0), vData_start = vData_end, vData_start < vData_length) {
|
|
3105
|
+
vNodeElementIndex += howManyElementsToSkip();
|
|
3106
|
+
ch === VNodeDataSeparator.REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++, ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1), vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
|
|
3107
|
+
} else {
|
|
3108
|
+
vNodeElementIndex = Number.MAX_SAFE_INTEGER;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
if (elementIdx === vNodeElementIndex) {
|
|
3112
|
+
needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
|
|
3113
|
+
const instructions = vData.substring(vData_start, vData_end);
|
|
3114
|
+
vNodeDataMap.set(node, instructions);
|
|
3115
|
+
}
|
|
3116
|
+
elementIdx++;
|
|
3117
|
+
}
|
|
3118
|
+
} while (node = nextNode || walker2.nextNode());
|
|
3119
|
+
};
|
|
3120
|
+
const walker = document2.createTreeWalker(document2, 129);
|
|
3121
|
+
walkContainer(walker, null, walker.firstChild(), null, "", null);
|
|
3122
|
+
}
|
|
3123
|
+
function getDomContainer(element) {
|
|
3124
|
+
const qContainerElement = _getQContainerElement(element);
|
|
3125
|
+
if (!qContainerElement) {
|
|
3126
|
+
throw qError(QError.containerNotFound);
|
|
3127
|
+
}
|
|
3128
|
+
return getDomContainerFromQContainerElement(qContainerElement);
|
|
3129
|
+
}
|
|
3130
|
+
function getDomContainerFromQContainerElement(qContainerElement) {
|
|
3131
|
+
const qElement = qContainerElement;
|
|
3132
|
+
let container = qElement.qContainer;
|
|
3133
|
+
if (!container) {
|
|
3134
|
+
container = new DomContainer(qElement);
|
|
3135
|
+
const containerAttributes = {};
|
|
3136
|
+
if (qElement) {
|
|
3137
|
+
const attrs = qElement.attributes;
|
|
3138
|
+
if (attrs) {
|
|
3139
|
+
for (let index = 0; index < attrs.length; index++) {
|
|
3140
|
+
const attr = attrs[index];
|
|
3141
|
+
":" !== attr.name && (containerAttributes[attr.name] = attr.value);
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
container.$serverData$ = {
|
|
3146
|
+
containerAttributes
|
|
3147
|
+
}, qElement.setAttribute("q:container", QContainerValue.RESUMED), qElement.qContainer = container;
|
|
3148
|
+
}
|
|
3149
|
+
return container;
|
|
3150
|
+
}
|
|
3151
|
+
function _getQContainerElement(element) {
|
|
3152
|
+
return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
|
|
3153
|
+
}
|
|
3154
|
+
const isDomContainer = (container) => container instanceof DomContainer;
|
|
3155
|
+
class DomContainer extends _SharedContainer {
|
|
3156
|
+
constructor(element) {
|
|
3157
|
+
super(() => this.scheduleRender(), () => vnode_applyJournal(this.$journal$), {}, element.getAttribute("q:locale"));
|
|
3158
|
+
__publicField(this, "element");
|
|
3159
|
+
__publicField(this, "qContainer");
|
|
3160
|
+
__publicField(this, "qBase");
|
|
3161
|
+
__publicField(this, "qManifestHash");
|
|
3162
|
+
__publicField(this, "rootVNode");
|
|
3163
|
+
__publicField(this, "document");
|
|
3164
|
+
__publicField(this, "$journal$");
|
|
3165
|
+
__publicField(this, "renderDone", null);
|
|
3166
|
+
__publicField(this, "$rawStateData$");
|
|
3167
|
+
__publicField(this, "$storeProxyMap$", /* @__PURE__ */ new WeakMap());
|
|
3168
|
+
__publicField(this, "$qFuncs$");
|
|
3169
|
+
__publicField(this, "$instanceHash$");
|
|
3170
|
+
__publicField(this, "vNodeLocate", (id) => vnode_locate(this.rootVNode, id));
|
|
3171
|
+
__publicField(this, "$stateData$");
|
|
3172
|
+
__publicField(this, "$styleIds$", null);
|
|
3173
|
+
__publicField(this, "$renderCount$", 0);
|
|
3174
|
+
__publicField(this, "$getObjectById$", (id) => ("string" == typeof id && (id = parseFloat(id)), assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`), this.$stateData$[id]));
|
|
3175
|
+
if (this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
|
|
3176
|
+
throw qError(QError.elementWithoutContainer);
|
|
3177
|
+
}
|
|
3178
|
+
this.$journal$ = [VNodeJournalOpCode.HoistStyles, element.ownerDocument], this.document = element.ownerDocument, this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"), this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element), this.$rawStateData$ = null, this.$stateData$ = null;
|
|
3179
|
+
const document2 = this.element.ownerDocument;
|
|
3180
|
+
document2.qVNodeData || processVNodeData(document2), this.$rawStateData$ = [], this.$stateData$ = [];
|
|
3181
|
+
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
3182
|
+
if (0 !== qwikStates.length) {
|
|
3183
|
+
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent), this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
|
|
3184
|
+
}
|
|
3185
|
+
this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
|
|
3186
|
+
}
|
|
3187
|
+
$setRawState$(id, vParent) {
|
|
3188
|
+
this.$stateData$[id] = vParent;
|
|
3189
|
+
}
|
|
3190
|
+
parseQRL(qrl2) {
|
|
3191
|
+
return inflateQRL(this, parseQRL(qrl2));
|
|
3192
|
+
}
|
|
3193
|
+
handleError(err, host) {
|
|
3194
|
+
const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
|
|
3195
|
+
if (!errorStore) {
|
|
3196
|
+
throw err;
|
|
3197
|
+
}
|
|
3198
|
+
errorStore.error = err;
|
|
3199
|
+
}
|
|
3200
|
+
setContext(host, context, value) {
|
|
3201
|
+
let ctx = this.getHostProp(host, "q:ctx");
|
|
3202
|
+
ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
|
|
3203
|
+
}
|
|
3204
|
+
resolveContext(host, contextId) {
|
|
3205
|
+
for (; host; ) {
|
|
3206
|
+
const ctx = this.getHostProp(host, "q:ctx");
|
|
3207
|
+
if (ctx) {
|
|
3208
|
+
const value = mapArray_get(ctx, contextId.id, 0);
|
|
3209
|
+
if (value) {
|
|
3210
|
+
return value;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
host = this.getParentHost(host);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
getParentHost(host) {
|
|
3217
|
+
let vNode = vnode_getParent(host);
|
|
3218
|
+
for (; vNode; ) {
|
|
3219
|
+
if (vnode_isVirtualVNode(vNode)) {
|
|
3220
|
+
if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
|
|
3221
|
+
return vNode;
|
|
3222
|
+
}
|
|
3223
|
+
vNode = vnode_getParent(vNode) || vnode_getProp(vNode, "q:sparent", this.vNodeLocate);
|
|
3224
|
+
} else {
|
|
3225
|
+
vNode = vnode_getParent(vNode);
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
return null;
|
|
3229
|
+
}
|
|
3230
|
+
setHostProp(host, name, value) {
|
|
3231
|
+
vnode_setProp(host, name, value);
|
|
3232
|
+
}
|
|
3233
|
+
getHostProp(host, name) {
|
|
3234
|
+
const vNode = host;
|
|
3235
|
+
let getObjectById2 = null;
|
|
3236
|
+
switch (name) {
|
|
3237
|
+
case "q:seq":
|
|
3238
|
+
case "q:props":
|
|
3239
|
+
case "q:renderFn":
|
|
3240
|
+
case "q:ctx":
|
|
3241
|
+
case "q:brefs":
|
|
3242
|
+
getObjectById2 = this.$getObjectById$;
|
|
3243
|
+
break;
|
|
3244
|
+
case "q:seqIdx":
|
|
3245
|
+
case ":onIdx":
|
|
3246
|
+
getObjectById2 = parseInt;
|
|
3247
|
+
}
|
|
3248
|
+
return vnode_getProp(vNode, name, getObjectById2);
|
|
3249
|
+
}
|
|
3250
|
+
scheduleRender() {
|
|
3251
|
+
return this.$renderCount$++, this.renderDone || (this.renderDone = getPlatform().nextTick(() => this.processChores())), this.renderDone.finally(() => emitEvent("qrender", {
|
|
3252
|
+
instanceHash: this.$instanceHash$,
|
|
3253
|
+
renderCount: this.$renderCount$
|
|
3254
|
+
}));
|
|
3255
|
+
}
|
|
3256
|
+
processChores() {
|
|
3257
|
+
let renderCount = this.$renderCount$;
|
|
3258
|
+
const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
3259
|
+
if (isPromise(result)) {
|
|
3260
|
+
return result.then(async () => {
|
|
3261
|
+
for (; renderCount !== this.$renderCount$; ) {
|
|
3262
|
+
renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
|
|
3263
|
+
}
|
|
3264
|
+
this.renderDone = null;
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3267
|
+
renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
|
|
3268
|
+
}
|
|
3269
|
+
ensureProjectionResolved(vNode) {
|
|
3270
|
+
if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
|
|
3271
|
+
vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
|
|
3272
|
+
const props = vnode_getProps(vNode);
|
|
3273
|
+
for (let i = 0; i < props.length; i += 2) {
|
|
3274
|
+
if (isSlotProp(props[i])) {
|
|
3275
|
+
const value = props[i + 1];
|
|
3276
|
+
"string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
getSyncFn(id) {
|
|
3282
|
+
const fn = this.$qFuncs$[id];
|
|
3283
|
+
return fn;
|
|
3284
|
+
}
|
|
3285
|
+
$appendStyle$(content, styleId, host, scoped) {
|
|
3286
|
+
if (scoped) {
|
|
3287
|
+
const scopedStyleIdsString = this.getHostProp(host, "q:sstyle");
|
|
3288
|
+
const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
|
|
3289
|
+
scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", convertStyleIdsToString(scopedStyleIds));
|
|
3290
|
+
}
|
|
3291
|
+
if (null == this.$styleIds$ && (this.$styleIds$ = /* @__PURE__ */ new Set(), this.element.querySelectorAll(QStyleSelector).forEach((style) => {
|
|
3292
|
+
this.$styleIds$.add(style.getAttribute(QStyle));
|
|
3293
|
+
})), !this.$styleIds$.has(styleId)) {
|
|
3294
|
+
this.$styleIds$.add(styleId);
|
|
3295
|
+
const styleElement = this.document.createElement("style");
|
|
3296
|
+
styleElement.setAttribute(QStyle, styleId), styleElement.textContent = content, this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
const deserializedProxyMap = /* @__PURE__ */ new WeakMap();
|
|
3301
|
+
const isDeserializerProxy = (value) => "object" == typeof value && null !== value && SERIALIZER_PROXY_UNWRAP in value;
|
|
3302
|
+
const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
|
|
3303
|
+
const wrapDeserializerProxy = (container, data) => {
|
|
3304
|
+
if (!Array.isArray(data) || vnode_isVNode(data) || isDeserializerProxy(data)) {
|
|
3305
|
+
return data;
|
|
3306
|
+
}
|
|
3307
|
+
let proxy = deserializedProxyMap.get(data);
|
|
3308
|
+
if (!proxy) {
|
|
3309
|
+
const target = Array(data.length / 2).fill(void 0);
|
|
3310
|
+
proxy = new Proxy(target, new DeserializationHandler(container, data)), deserializedProxyMap.set(data, proxy);
|
|
3311
|
+
}
|
|
3312
|
+
return proxy;
|
|
3313
|
+
};
|
|
3314
|
+
class DeserializationHandler {
|
|
3315
|
+
constructor($container$, $data$) {
|
|
3316
|
+
__publicField(this, "$container$");
|
|
3317
|
+
__publicField(this, "$data$");
|
|
3318
|
+
__publicField(this, "$length$");
|
|
3319
|
+
this.$container$ = $container$, this.$data$ = $data$, this.$length$ = this.$data$.length / 2;
|
|
3320
|
+
}
|
|
3321
|
+
get(target, property, receiver) {
|
|
3322
|
+
if (property === SERIALIZER_PROXY_UNWRAP) {
|
|
3323
|
+
return target;
|
|
3324
|
+
}
|
|
3325
|
+
const i = "number" == typeof property ? property : "string" == typeof property ? parseInt(property, 10) : NaN;
|
|
3326
|
+
if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
|
|
3327
|
+
return Reflect.get(target, property, receiver);
|
|
3328
|
+
}
|
|
3329
|
+
const idx = 2 * i;
|
|
3330
|
+
const typeId = this.$data$[idx];
|
|
3331
|
+
const value = this.$data$[idx + 1];
|
|
3332
|
+
if (void 0 === typeId) {
|
|
3333
|
+
return value;
|
|
3334
|
+
}
|
|
3335
|
+
const container = this.$container$;
|
|
3336
|
+
let propValue = allocate(container, typeId, value);
|
|
3337
|
+
return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)), Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue, propValue;
|
|
3338
|
+
}
|
|
3339
|
+
has(target, property) {
|
|
3340
|
+
return property === SERIALIZER_PROXY_UNWRAP || Object.prototype.hasOwnProperty.call(target, property);
|
|
3341
|
+
}
|
|
3342
|
+
set(target, property, value, receiver) {
|
|
3343
|
+
if (property === SERIALIZER_PROXY_UNWRAP) {
|
|
3344
|
+
return false;
|
|
3345
|
+
}
|
|
3346
|
+
const out = Reflect.set(target, property, value, receiver);
|
|
3347
|
+
const i = "number" == typeof property ? property : parseInt(property, 10);
|
|
3348
|
+
if (Number.isNaN(i) || i < 0 || i >= this.$data$.length / 2) {
|
|
3349
|
+
return out;
|
|
3350
|
+
}
|
|
3351
|
+
const idx = 2 * i;
|
|
3352
|
+
return this.$data$[idx] = void 0, this.$data$[idx + 1] = value, true;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
const _eagerDeserializeArray = (container, data) => {
|
|
3356
|
+
const out = Array(data.length / 2);
|
|
3357
|
+
for (let i = 0; i < data.length; i += 2) {
|
|
3358
|
+
out[i / 2] = deserializeData(container, data[i], data[i + 1]);
|
|
3359
|
+
}
|
|
3360
|
+
return out;
|
|
3361
|
+
};
|
|
3362
|
+
const resolvers = /* @__PURE__ */ new WeakMap();
|
|
3363
|
+
const inflate = (container, target, typeId, data) => {
|
|
3364
|
+
if (void 0 === typeId) {
|
|
3365
|
+
return target;
|
|
3366
|
+
}
|
|
3367
|
+
switch (typeId !== TypeIds.Object && Array.isArray(data) && (data = _eagerDeserializeArray(container, data)), typeId) {
|
|
3368
|
+
case TypeIds.Object:
|
|
3369
|
+
for (let i2 = 0; i2 < data.length; i2 += 4) {
|
|
3370
|
+
const key = deserializeData(container, data[i2], data[i2 + 1]);
|
|
3371
|
+
const valType = data[i2 + 2];
|
|
3372
|
+
const valData = data[i2 + 3];
|
|
3373
|
+
valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
|
|
3374
|
+
get() {
|
|
3375
|
+
const value = deserializeData(container, valType, valData);
|
|
3376
|
+
return target[key] = value, value;
|
|
3377
|
+
},
|
|
3378
|
+
set(value) {
|
|
3379
|
+
Object.defineProperty(target, key, {
|
|
3380
|
+
value,
|
|
3381
|
+
writable: true,
|
|
3382
|
+
enumerable: true,
|
|
3383
|
+
configurable: true
|
|
3384
|
+
});
|
|
3385
|
+
},
|
|
3386
|
+
enumerable: true,
|
|
3387
|
+
configurable: true
|
|
3388
|
+
}) : target[key] = deserializeData(container, valType, valData);
|
|
3389
|
+
}
|
|
3390
|
+
break;
|
|
3391
|
+
case TypeIds.QRL:
|
|
3392
|
+
inflateQRL(container, target);
|
|
3393
|
+
break;
|
|
3394
|
+
case TypeIds.Task:
|
|
3395
|
+
const task = target;
|
|
3396
|
+
const v = data;
|
|
3397
|
+
task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2], task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
|
|
3398
|
+
break;
|
|
3399
|
+
case TypeIds.Resource:
|
|
3400
|
+
const [resolved, result, effects] = data;
|
|
3401
|
+
const resource = target;
|
|
3402
|
+
resolved ? (resource.value = Promise.resolve(result), resource._resolved = result, resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result, resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
|
|
3403
|
+
break;
|
|
3404
|
+
case TypeIds.Component:
|
|
3405
|
+
target[SERIALIZABLE_STATE][0] = data[0];
|
|
3406
|
+
break;
|
|
3407
|
+
case TypeIds.Store:
|
|
3408
|
+
case TypeIds.StoreArray: {
|
|
3409
|
+
const [value, flags, effects2] = data;
|
|
3410
|
+
const store = getOrCreateStore(value, flags, container);
|
|
3411
|
+
getStoreHandler(store).$effects$ = effects2, target = store;
|
|
3412
|
+
break;
|
|
3413
|
+
}
|
|
3414
|
+
case TypeIds.Signal: {
|
|
3415
|
+
const signal = target;
|
|
3416
|
+
const d = data;
|
|
3417
|
+
signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
|
|
3418
|
+
break;
|
|
3419
|
+
}
|
|
3420
|
+
case TypeIds.WrappedSignal: {
|
|
3421
|
+
const signal = target;
|
|
3422
|
+
const d = data;
|
|
3423
|
+
signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2], signal.$untrackedValue$ = d[3], signal.$flags$ = d[4], signal.$hostElement$ = d[5], signal.$effects$ = new Set(d.slice(6));
|
|
3424
|
+
break;
|
|
3425
|
+
}
|
|
3426
|
+
case TypeIds.ComputedSignal: {
|
|
3427
|
+
const computed = target;
|
|
3428
|
+
const d = data;
|
|
3429
|
+
computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$flags$ |= SignalFlags.INVALID, computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
|
|
3430
|
+
break;
|
|
3431
|
+
}
|
|
3432
|
+
case TypeIds.Error: {
|
|
3433
|
+
const d = data;
|
|
3434
|
+
target.message = d[0];
|
|
3435
|
+
const second = d[1];
|
|
3436
|
+
if (second && Array.isArray(second)) {
|
|
3437
|
+
for (let i2 = 0; i2 < second.length; i2++) {
|
|
3438
|
+
target[second[i2++]] = d[i2];
|
|
3439
|
+
}
|
|
3440
|
+
target.stack = d[2];
|
|
3441
|
+
} else {
|
|
3442
|
+
target.stack = second;
|
|
3443
|
+
}
|
|
3444
|
+
break;
|
|
3445
|
+
}
|
|
3446
|
+
case TypeIds.FormData: {
|
|
3447
|
+
const formData = target;
|
|
3448
|
+
const d = data;
|
|
3449
|
+
for (let i2 = 0; i2 < d.length; i2++) {
|
|
3450
|
+
formData.append(d[i2++], d[i2]);
|
|
3451
|
+
}
|
|
3452
|
+
break;
|
|
3453
|
+
}
|
|
3454
|
+
case TypeIds.JSXNode: {
|
|
3455
|
+
const jsx2 = target;
|
|
3456
|
+
const [type, varProps, constProps, children, flags, key] = data;
|
|
3457
|
+
jsx2.type = type, jsx2.varProps = varProps, jsx2.constProps = constProps, jsx2.children = children, jsx2.flags = flags, jsx2.key = key;
|
|
3458
|
+
break;
|
|
3459
|
+
}
|
|
3460
|
+
case TypeIds.Set: {
|
|
3461
|
+
const set = target;
|
|
3462
|
+
const d = data;
|
|
3463
|
+
for (let i2 = 0; i2 < d.length; i2++) {
|
|
3464
|
+
set.add(d[i2]);
|
|
3465
|
+
}
|
|
3466
|
+
break;
|
|
3467
|
+
}
|
|
3468
|
+
case TypeIds.Map: {
|
|
3469
|
+
const map = target;
|
|
3470
|
+
const d = data;
|
|
3471
|
+
for (let i2 = 0; i2 < d.length; i2++) {
|
|
3472
|
+
map.set(d[i2++], d[i2]);
|
|
3473
|
+
}
|
|
3474
|
+
break;
|
|
3475
|
+
}
|
|
3476
|
+
case TypeIds.Promise: {
|
|
3477
|
+
const promise = target;
|
|
3478
|
+
const [resolved2, result2] = data;
|
|
3479
|
+
const [resolve, reject] = resolvers.get(promise);
|
|
3480
|
+
resolved2 ? resolve(result2) : reject(result2);
|
|
3481
|
+
break;
|
|
3482
|
+
}
|
|
3483
|
+
case TypeIds.Uint8Array:
|
|
3484
|
+
const bytes = target;
|
|
3485
|
+
const buf = atob(data);
|
|
3486
|
+
let i = 0;
|
|
3487
|
+
for (const s of buf) {
|
|
3488
|
+
bytes[i++] = s.charCodeAt(0);
|
|
3489
|
+
}
|
|
3490
|
+
break;
|
|
3491
|
+
case TypeIds.PropsProxy:
|
|
3492
|
+
const propsProxy = target;
|
|
3493
|
+
propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
|
|
3494
|
+
break;
|
|
3495
|
+
case TypeIds.EffectData: {
|
|
3496
|
+
const effectData = target;
|
|
3497
|
+
effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
|
|
3498
|
+
break;
|
|
3499
|
+
}
|
|
3500
|
+
default:
|
|
3501
|
+
throw qError(QError.serializeErrorNotImplemented, [typeId]);
|
|
3502
|
+
}
|
|
3503
|
+
return target;
|
|
3504
|
+
};
|
|
3505
|
+
const _constants = [void 0, null, true, false, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER];
|
|
3506
|
+
const allocate = (container, typeId, value) => {
|
|
3507
|
+
if (void 0 === value) {
|
|
3508
|
+
return typeId;
|
|
3509
|
+
}
|
|
3510
|
+
switch (typeId) {
|
|
3511
|
+
case TypeIds.RootRef:
|
|
3512
|
+
return container.$getObjectById$(value);
|
|
3513
|
+
case TypeIds.Constant:
|
|
3514
|
+
return _constants[value];
|
|
3515
|
+
case TypeIds.Number:
|
|
3516
|
+
return value;
|
|
3517
|
+
case TypeIds.Array:
|
|
3518
|
+
return wrapDeserializerProxy(container, value);
|
|
3519
|
+
case TypeIds.Object:
|
|
3520
|
+
return {};
|
|
3521
|
+
case TypeIds.QRL:
|
|
3522
|
+
return parseQRL(container.$getObjectById$(value));
|
|
3523
|
+
case TypeIds.Task:
|
|
3524
|
+
return new Task(-1, -1, null, null, null, null);
|
|
3525
|
+
case TypeIds.Resource: {
|
|
3526
|
+
const res = createResourceReturn(container, void 0, void 0);
|
|
3527
|
+
return res.loading = false, res;
|
|
3528
|
+
}
|
|
3529
|
+
case TypeIds.URL:
|
|
3530
|
+
return new URL(value);
|
|
3531
|
+
case TypeIds.Date:
|
|
3532
|
+
return new Date(value);
|
|
3533
|
+
case TypeIds.Regex:
|
|
3534
|
+
const idx = value.lastIndexOf("/");
|
|
3535
|
+
return new RegExp(value.slice(1, idx), value.slice(idx + 1));
|
|
3536
|
+
case TypeIds.Error:
|
|
3537
|
+
return new Error();
|
|
3538
|
+
case TypeIds.Component:
|
|
3539
|
+
return componentQrl(null);
|
|
3540
|
+
case TypeIds.Signal:
|
|
3541
|
+
return new Signal(container, 0);
|
|
3542
|
+
case TypeIds.WrappedSignal:
|
|
3543
|
+
return new WrappedSignal(container, null, null, null);
|
|
3544
|
+
case TypeIds.ComputedSignal:
|
|
3545
|
+
return new ComputedSignal(container, null);
|
|
3546
|
+
case TypeIds.Store:
|
|
3547
|
+
case TypeIds.StoreArray:
|
|
3548
|
+
return null;
|
|
3549
|
+
case TypeIds.URLSearchParams:
|
|
3550
|
+
return new URLSearchParams(value);
|
|
3551
|
+
case TypeIds.FormData:
|
|
3552
|
+
return new FormData();
|
|
3553
|
+
case TypeIds.JSXNode:
|
|
3554
|
+
return new JSXNodeImpl(null, null, null, null, -1, null);
|
|
3555
|
+
case TypeIds.BigInt:
|
|
3556
|
+
return BigInt(value);
|
|
3557
|
+
case TypeIds.Set:
|
|
3558
|
+
return /* @__PURE__ */ new Set();
|
|
3559
|
+
case TypeIds.Map:
|
|
3560
|
+
return /* @__PURE__ */ new Map();
|
|
3561
|
+
case TypeIds.String:
|
|
3562
|
+
return value;
|
|
3563
|
+
case TypeIds.Promise:
|
|
3564
|
+
let resolve;
|
|
3565
|
+
let reject;
|
|
3566
|
+
const promise = new Promise((res, rej) => {
|
|
3567
|
+
resolve = res, reject = rej;
|
|
3568
|
+
});
|
|
3569
|
+
return resolvers.set(promise, [resolve, reject]), promise.catch(() => {
|
|
3570
|
+
}), promise;
|
|
3571
|
+
case TypeIds.Uint8Array:
|
|
3572
|
+
const encodedLength = value.length;
|
|
3573
|
+
const rest = 3 & encodedLength;
|
|
3574
|
+
return new Uint8Array(3 * (encodedLength >>> 2) + (rest ? rest - 1 : 0));
|
|
3575
|
+
case TypeIds.PropsProxy:
|
|
3576
|
+
return createPropsProxy(null, null);
|
|
3577
|
+
case TypeIds.VNode:
|
|
3578
|
+
return retrieveVNodeOrDocument(container, value);
|
|
3579
|
+
case TypeIds.RefVNode:
|
|
3580
|
+
const vNode = retrieveVNodeOrDocument(container, value);
|
|
3581
|
+
if (vnode_isVNode(vNode)) {
|
|
3582
|
+
return vnode_getNode(vNode);
|
|
3583
|
+
}
|
|
3584
|
+
throw qError(QError.serializeErrorExpectedVNode, [typeof vNode]);
|
|
3585
|
+
case TypeIds.EffectData:
|
|
3586
|
+
return new SubscriptionData({});
|
|
3587
|
+
default:
|
|
3588
|
+
throw qError(QError.serializeErrorCannotAllocate, [typeId]);
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3591
|
+
function retrieveVNodeOrDocument(container, value) {
|
|
3592
|
+
return value ? container.rootVNode ? vnode_locate(container.rootVNode, value) : void 0 : container.element?.ownerDocument;
|
|
3593
|
+
}
|
|
3594
|
+
function parseQRL(qrl2) {
|
|
3595
|
+
const hashIdx = qrl2.indexOf("#");
|
|
3596
|
+
const captureStart = qrl2.indexOf("[", hashIdx);
|
|
3597
|
+
const captureEnd = qrl2.indexOf("]", captureStart);
|
|
3598
|
+
const chunk = qrl2.slice(0, hashIdx > -1 ? hashIdx : captureStart);
|
|
3599
|
+
const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
|
|
3600
|
+
const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
|
|
3601
|
+
let qrlRef = null;
|
|
3602
|
+
if (chunk === QRL_RUNTIME_CHUNK) {
|
|
3603
|
+
const backChannel = globalThis[QRL_RUNTIME_CHUNK];
|
|
3604
|
+
qrlRef = backChannel.get(symbol);
|
|
3605
|
+
}
|
|
3606
|
+
return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
|
|
3607
|
+
}
|
|
3608
|
+
function inflateQRL(container, qrl2) {
|
|
3609
|
+
const captureIds = qrl2.$capture$;
|
|
3610
|
+
return qrl2.$captureRef$ = captureIds ? captureIds.map((id) => container.$getObjectById$(id)) : null, container.element && qrl2.$setContainer$(container.element), qrl2;
|
|
3611
|
+
}
|
|
3612
|
+
let isDomRef = () => false;
|
|
3613
|
+
const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp2, setProp, storeProxyMap, writer, prepVNodeData) => {
|
|
3614
|
+
if (!writer) {
|
|
3615
|
+
const buffer = [];
|
|
3616
|
+
writer = {
|
|
3617
|
+
write: (text) => buffer.push(text),
|
|
3618
|
+
toString: () => buffer.join("")
|
|
3619
|
+
};
|
|
3620
|
+
}
|
|
3621
|
+
const map = /* @__PURE__ */ new Map();
|
|
3622
|
+
const syncFnMap = /* @__PURE__ */ new Map();
|
|
3623
|
+
const syncFns = [];
|
|
3624
|
+
const roots = [];
|
|
3625
|
+
const $wasSeen$ = (obj) => map.get(obj);
|
|
3626
|
+
const $seen$ = (obj) => map.set(obj, -1);
|
|
3627
|
+
const $addRoot$ = (obj) => {
|
|
3628
|
+
let id = map.get(obj);
|
|
3629
|
+
return "number" == typeof id && -1 !== id || (id = roots.length, map.set(obj, id), roots.push(obj)), id;
|
|
3630
|
+
};
|
|
3631
|
+
const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
|
|
3632
|
+
return isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false, {
|
|
3633
|
+
$serialize$() {
|
|
3634
|
+
serialize(this);
|
|
3635
|
+
},
|
|
3636
|
+
$isSsrNode$: isSsrNode2,
|
|
3637
|
+
$isDomRef$: isDomRef,
|
|
3638
|
+
$symbolToChunkResolver$: symbolToChunkResolver,
|
|
3639
|
+
$wasSeen$,
|
|
3640
|
+
$roots$: roots,
|
|
3641
|
+
$seen$,
|
|
3642
|
+
$hasRootId$: (obj) => {
|
|
3643
|
+
const id = map.get(obj);
|
|
3644
|
+
return void 0 === id || -1 === id ? void 0 : id;
|
|
3645
|
+
},
|
|
3646
|
+
$addRoot$,
|
|
3647
|
+
$getRootId$: (obj) => {
|
|
3648
|
+
const id = map.get(obj);
|
|
3649
|
+
if (!id || -1 === id) {
|
|
3650
|
+
throw qError(QError.serializeErrorMissingRootId, [obj]);
|
|
3651
|
+
}
|
|
3652
|
+
return id;
|
|
3653
|
+
},
|
|
3654
|
+
$syncFns$: syncFns,
|
|
3655
|
+
$addSyncFn$: (funcStr, argCount, fn) => {
|
|
3656
|
+
const isFullFn = null == funcStr;
|
|
3657
|
+
isFullFn && (funcStr = fn.serialized || fn.toString());
|
|
3658
|
+
let id = syncFnMap.get(funcStr);
|
|
3659
|
+
if (void 0 === id) {
|
|
3660
|
+
if (id = syncFns.length, syncFnMap.set(funcStr, id), isFullFn) {
|
|
3661
|
+
syncFns.push(funcStr);
|
|
3662
|
+
} else {
|
|
3663
|
+
let code = "(";
|
|
3664
|
+
for (let i = 0; i < argCount; i++) {
|
|
3665
|
+
code += (0 == i ? "p" : ",p") + i;
|
|
3666
|
+
}
|
|
3667
|
+
syncFns.push(code += ")=>" + funcStr);
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
return id;
|
|
3671
|
+
},
|
|
3672
|
+
$writer$: writer,
|
|
3673
|
+
$breakCircularDepsAndAwaitPromises$: async function() {
|
|
3674
|
+
const discoveredValues = [];
|
|
3675
|
+
const promises = [];
|
|
3676
|
+
const visit = (obj) => {
|
|
3677
|
+
if ("function" == typeof obj) {
|
|
3678
|
+
if (isQrl$1(obj)) {
|
|
3679
|
+
obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
|
|
3680
|
+
} else if (isQwikComponent(obj)) {
|
|
3681
|
+
const [qrl2] = obj[SERIALIZABLE_STATE];
|
|
3682
|
+
discoveredValues.push(qrl2);
|
|
3683
|
+
}
|
|
3684
|
+
} else if ("object" != typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || "undefined" != typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) ;
|
|
3685
|
+
else if (obj instanceof Error) {
|
|
3686
|
+
discoveredValues.push(...Object.values(obj));
|
|
3687
|
+
} else if (isStore(obj)) {
|
|
3688
|
+
const target = getStoreTarget(obj);
|
|
3689
|
+
const effects = getStoreHandler(obj).$effects$;
|
|
3690
|
+
discoveredValues.push(target, effects);
|
|
3691
|
+
for (const prop in target) {
|
|
3692
|
+
const propValue = target[prop];
|
|
3693
|
+
storeProxyMap.has(propValue) && discoveredValues.push(prop, storeProxyMap.get(propValue));
|
|
3694
|
+
}
|
|
3695
|
+
} else if (obj instanceof Set) {
|
|
3696
|
+
discoveredValues.push(...obj.values());
|
|
3697
|
+
} else if (obj instanceof Map) {
|
|
3698
|
+
obj.forEach((v, k) => {
|
|
3699
|
+
discoveredValues.push(k, v);
|
|
3700
|
+
});
|
|
3701
|
+
} else if (obj instanceof Signal) {
|
|
3702
|
+
const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$flags$ & SignalFlags.INVALID || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
|
|
3703
|
+
v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(obj.$effects$), obj instanceof WrappedSignal ? (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues), obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues), discoveredValues.push(obj.$computeQrl$));
|
|
3704
|
+
} else if (obj instanceof Task) {
|
|
3705
|
+
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$), discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
|
|
3706
|
+
} else if (isSsrNode2(obj)) {
|
|
3707
|
+
if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
|
|
3708
|
+
for (const data of obj.childrenVNodeData) {
|
|
3709
|
+
discoverValuesForVNodeData(data, discoveredValues);
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
} else if (isDomRef(obj)) {
|
|
3713
|
+
discoveredValues.push(obj.$ssrNode$.id);
|
|
3714
|
+
} else if (isJSXNode(obj)) {
|
|
3715
|
+
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
3716
|
+
} else if (Array.isArray(obj)) {
|
|
3717
|
+
discoveredValues.push(...obj);
|
|
3718
|
+
} else if (isQrl$1(obj)) {
|
|
3719
|
+
obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
|
|
3720
|
+
} else if (isPropsProxy(obj)) {
|
|
3721
|
+
discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
|
|
3722
|
+
} else if (isPromise(obj)) {
|
|
3723
|
+
obj.then((value) => {
|
|
3724
|
+
promiseResults.set(obj, [true, value]), discoveredValues.push(value);
|
|
3725
|
+
}, (error) => {
|
|
3726
|
+
promiseResults.set(obj, [false, error]), discoveredValues.push(error);
|
|
3727
|
+
}), promises.push(obj);
|
|
3728
|
+
} else if (obj instanceof SubscriptionData) {
|
|
3729
|
+
discoveredValues.push(obj.data);
|
|
3730
|
+
} else {
|
|
3731
|
+
if (!isObjectLiteral(obj)) {
|
|
3732
|
+
throw qError(QError.serializeErrorUnknownType, [obj]);
|
|
3733
|
+
}
|
|
3734
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
3735
|
+
discoveredValues.push(key, value);
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
};
|
|
3739
|
+
for (const root of roots) {
|
|
3740
|
+
visit(root);
|
|
3741
|
+
}
|
|
3742
|
+
do {
|
|
3743
|
+
for (; discoveredValues.length; ) {
|
|
3744
|
+
const obj = discoveredValues.pop();
|
|
3745
|
+
if (!shouldTrackObj(obj) && !frameworkType(obj)) {
|
|
3746
|
+
continue;
|
|
3747
|
+
}
|
|
3748
|
+
const id = $wasSeen$(obj);
|
|
3749
|
+
void 0 === id ? ($seen$(obj), visit(obj)) : -1 === id && $addRoot$(obj);
|
|
3750
|
+
}
|
|
3751
|
+
await Promise.allSettled(promises), promises.length = 0;
|
|
3752
|
+
} while (discoveredValues.length);
|
|
3753
|
+
},
|
|
3754
|
+
$eventQrls$: /* @__PURE__ */ new Set(),
|
|
3755
|
+
$eventNames$: /* @__PURE__ */ new Set(),
|
|
3756
|
+
$resources$: /* @__PURE__ */ new Set(),
|
|
3757
|
+
$renderSymbols$: /* @__PURE__ */ new Set(),
|
|
3758
|
+
$storeProxyMap$: storeProxyMap,
|
|
3759
|
+
$getProp$: getProp2,
|
|
3760
|
+
$setProp$: setProp,
|
|
3761
|
+
$prepVNodeData$: prepVNodeData
|
|
3762
|
+
};
|
|
3763
|
+
};
|
|
3764
|
+
const isSsrAttrs = (value) => Array.isArray(value) && value.length > 0;
|
|
3765
|
+
const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
|
|
3766
|
+
for (const value of vnodeData) {
|
|
3767
|
+
if (isSsrAttrs(value)) {
|
|
3768
|
+
for (let i = 1; i < value.length; i += 2) {
|
|
3769
|
+
const attrValue = value[i];
|
|
3770
|
+
"string" != typeof attrValue && discoveredValues.push(attrValue);
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
};
|
|
3775
|
+
const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
|
|
3776
|
+
effectsBackRefs && discoveredValues.push(effectsBackRefs);
|
|
3777
|
+
};
|
|
3778
|
+
const promiseResults = /* @__PURE__ */ new WeakMap();
|
|
3779
|
+
function serialize(serializationContext) {
|
|
3780
|
+
const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
|
|
3781
|
+
let depth = -1;
|
|
3782
|
+
let writeType = false;
|
|
3783
|
+
const output = (type, value) => {
|
|
3784
|
+
if (writeType ? $writer$.write(`${type},`) : writeType = true, "number" == typeof value) {
|
|
3785
|
+
$writer$.write(value.toString());
|
|
3786
|
+
} else if ("string" == typeof value) {
|
|
3787
|
+
const s = JSON.stringify(value);
|
|
3788
|
+
let angleBracketIdx = -1;
|
|
3789
|
+
let lastIdx = 0;
|
|
3790
|
+
for (; -1 !== (angleBracketIdx = s.indexOf("</", lastIdx)); ) {
|
|
3791
|
+
$writer$.write(s.slice(lastIdx, angleBracketIdx)), $writer$.write("<\\/"), lastIdx = angleBracketIdx + 2;
|
|
3792
|
+
}
|
|
3793
|
+
$writer$.write(0 === lastIdx ? s : s.slice(lastIdx));
|
|
3794
|
+
} else {
|
|
3795
|
+
depth++, $writer$.write("[");
|
|
3796
|
+
let separator = false;
|
|
3797
|
+
for (let i = 0; i < value.length; i++) {
|
|
3798
|
+
separator ? $writer$.write(",") : separator = true, writeValue(value[i], i);
|
|
3799
|
+
}
|
|
3800
|
+
$writer$.write("]"), depth--;
|
|
3801
|
+
}
|
|
3802
|
+
};
|
|
3803
|
+
const writeValue = (value, idx) => {
|
|
3804
|
+
if (fastSkipSerialize(value)) {
|
|
3805
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
3806
|
+
} else if ("bigint" == typeof value) {
|
|
3807
|
+
output(TypeIds.BigInt, value.toString());
|
|
3808
|
+
} else if ("boolean" == typeof value) {
|
|
3809
|
+
output(TypeIds.Constant, value ? Constants.True : Constants.False);
|
|
3810
|
+
} else if ("function" == typeof value) {
|
|
3811
|
+
if (value === Slot) {
|
|
3812
|
+
output(TypeIds.Constant, Constants.Slot);
|
|
3813
|
+
} else if (value === Fragment) {
|
|
3814
|
+
output(TypeIds.Constant, Constants.Fragment);
|
|
3815
|
+
} else if (isQrl$1(value)) {
|
|
3816
|
+
const qrl2 = qrlToString(serializationContext, value);
|
|
3817
|
+
const id = serializationContext.$addRoot$(qrl2);
|
|
3818
|
+
output(TypeIds.QRL, id);
|
|
3819
|
+
} else if (isQwikComponent(value)) {
|
|
3820
|
+
const [qrl2] = value[SERIALIZABLE_STATE];
|
|
3821
|
+
serializationContext.$renderSymbols$.add(qrl2.$symbol$), output(TypeIds.Component, [qrl2]);
|
|
3822
|
+
} else {
|
|
3823
|
+
console.error("Cannot serialize function (ignoring for now): " + value.toString()), output(TypeIds.Constant, Constants.Undefined);
|
|
3824
|
+
}
|
|
3825
|
+
} else if ("number" == typeof value) {
|
|
3826
|
+
Number.isNaN(value) ? output(TypeIds.Constant, Constants.NaN) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(TypeIds.Constant, Constants.MaxSafeInt) : value === Number.MAX_SAFE_INTEGER - 1 ? output(TypeIds.Constant, Constants.AlmostMaxSafeInt) : value === Number.MIN_SAFE_INTEGER ? output(TypeIds.Constant, Constants.MinSafeInt) : output(TypeIds.Number, value) : output(TypeIds.Constant, value < 0 ? Constants.NegativeInfinity : Constants.PositiveInfinity);
|
|
3827
|
+
} else if ("object" == typeof value) {
|
|
3828
|
+
value === EMPTY_ARRAY ? output(TypeIds.Constant, Constants.EMPTY_ARRAY) : value === EMPTY_OBJ ? output(TypeIds.Constant, Constants.EMPTY_OBJ) : (depth++, null === value ? output(TypeIds.Constant, Constants.Null) : writeObjectValue(value, idx), depth--);
|
|
3829
|
+
} else if ("string" == typeof value) {
|
|
3830
|
+
if (0 === value.length) {
|
|
3831
|
+
output(TypeIds.Constant, Constants.EmptyString);
|
|
3832
|
+
} else {
|
|
3833
|
+
const seen = depth > 1 && serializationContext.$wasSeen$(value);
|
|
3834
|
+
"number" == typeof seen && seen >= 0 ? output(TypeIds.RootRef, seen) : output(TypeIds.String, value);
|
|
3835
|
+
}
|
|
3836
|
+
} else if (void 0 === value) {
|
|
3837
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
3838
|
+
} else if (value === NEEDS_COMPUTATION) {
|
|
3839
|
+
output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
|
|
3840
|
+
} else {
|
|
3841
|
+
if (value !== STORE_ALL_PROPS) {
|
|
3842
|
+
throw qError(QError.serializeErrorUnknownType, [typeof value]);
|
|
3843
|
+
}
|
|
3844
|
+
output(TypeIds.Constant, Constants.STORE_ALL_PROPS);
|
|
3845
|
+
}
|
|
3846
|
+
};
|
|
3847
|
+
const writeObjectValue = (value, idx) => {
|
|
3848
|
+
const isRootObject = 2 === depth;
|
|
3849
|
+
if (depth > 2) {
|
|
3850
|
+
const seen = serializationContext.$wasSeen$(value);
|
|
3851
|
+
if ("number" == typeof seen && seen >= 0) {
|
|
3852
|
+
return void output(TypeIds.RootRef, seen);
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
if (isPropsProxy(value)) {
|
|
3856
|
+
const varProps = value[_VAR_PROPS];
|
|
3857
|
+
const constProps = value[_CONST_PROPS];
|
|
3858
|
+
const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
|
|
3859
|
+
output(TypeIds.PropsProxy, out);
|
|
3860
|
+
} else if (value instanceof SubscriptionData) {
|
|
3861
|
+
output(TypeIds.EffectData, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
|
|
3862
|
+
} else if (isStore(value)) {
|
|
3863
|
+
if (isResource(value)) {
|
|
3864
|
+
serializationContext.$resources$.add(value);
|
|
3865
|
+
const res = promiseResults.get(value.value);
|
|
3866
|
+
if (!res) {
|
|
3867
|
+
throw qError(QError.serializeErrorUnvisited, ["resource"]);
|
|
3868
|
+
}
|
|
3869
|
+
output(TypeIds.Resource, [...res, getStoreHandler(value).$effects$]);
|
|
3870
|
+
} else {
|
|
3871
|
+
const storeHandler = getStoreHandler(value);
|
|
3872
|
+
const storeTarget = getStoreTarget(value);
|
|
3873
|
+
const flags = storeHandler.$flags$;
|
|
3874
|
+
const effects = storeHandler.$effects$;
|
|
3875
|
+
const innerStores = [];
|
|
3876
|
+
for (const prop in storeTarget) {
|
|
3877
|
+
const propValue = storeTarget[prop];
|
|
3878
|
+
if ($storeProxyMap$.has(propValue)) {
|
|
3879
|
+
const innerStore = $storeProxyMap$.get(propValue);
|
|
3880
|
+
innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
const out = [storeTarget, flags, effects, ...innerStores];
|
|
3884
|
+
for (; null == out[out.length - 1]; ) {
|
|
3885
|
+
out.pop();
|
|
3886
|
+
}
|
|
3887
|
+
output(Array.isArray(storeTarget) ? TypeIds.StoreArray : TypeIds.Store, out);
|
|
3888
|
+
}
|
|
3889
|
+
} else if (isObjectLiteral(value)) {
|
|
3890
|
+
if (Array.isArray(value)) {
|
|
3891
|
+
output(TypeIds.Array, value);
|
|
3892
|
+
} else {
|
|
3893
|
+
const out = [];
|
|
3894
|
+
for (const key in value) {
|
|
3895
|
+
Object.prototype.hasOwnProperty.call(value, key) && !fastSkipSerialize(value[key]) && out.push(key, value[key]);
|
|
3896
|
+
}
|
|
3897
|
+
output(TypeIds.Object, out);
|
|
3898
|
+
}
|
|
3899
|
+
} else if ($isDomRef$(value)) {
|
|
3900
|
+
value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE, output(TypeIds.RefVNode, value.$ssrNode$.id);
|
|
3901
|
+
} else if (value instanceof Signal) {
|
|
3902
|
+
const v = value instanceof ComputedSignal && (value.$flags$ & SignalFlags.INVALID || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
3903
|
+
if (value instanceof WrappedSignal) {
|
|
3904
|
+
output(TypeIds.WrappedSignal, [...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), v, value.$flags$, value.$hostElement$, ...value.$effects$ || []]);
|
|
3905
|
+
} else if (value instanceof ComputedSignal) {
|
|
3906
|
+
const out = [value.$computeQrl$, value.$effects$];
|
|
3907
|
+
v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
|
|
3908
|
+
} else {
|
|
3909
|
+
output(TypeIds.Signal, [v, ...value.$effects$ || []]);
|
|
3910
|
+
}
|
|
3911
|
+
} else if (value instanceof URL) {
|
|
3912
|
+
output(TypeIds.URL, value.href);
|
|
3913
|
+
} else if (value instanceof Date) {
|
|
3914
|
+
output(TypeIds.Date, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
|
|
3915
|
+
} else if (value instanceof RegExp) {
|
|
3916
|
+
output(TypeIds.Regex, value.toString());
|
|
3917
|
+
} else if (value instanceof Error) {
|
|
3918
|
+
const out = [value.message];
|
|
3919
|
+
const extraProps = Object.entries(value).flat();
|
|
3920
|
+
extraProps.length && out.push(extraProps), out.push(value.stack), output(TypeIds.Error, out);
|
|
3921
|
+
} else if ($isSsrNode$(value)) {
|
|
3922
|
+
if (isRootObject) {
|
|
3923
|
+
$setProp$(value, "q:id", String(idx)), output(TypeIds.VNode, value.id);
|
|
3924
|
+
const vNodeData = value.vnodeData;
|
|
3925
|
+
if (vNodeData && (serializationContext.$prepVNodeData$?.(vNodeData), vNodeData[0] |= VNodeDataFlag.SERIALIZE), value.childrenVNodeData) {
|
|
3926
|
+
for (const vNodeData2 of value.childrenVNodeData) {
|
|
3927
|
+
vNodeData2[0] |= VNodeDataFlag.SERIALIZE;
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
} else {
|
|
3931
|
+
serializationContext.$addRoot$(value), output(TypeIds.RootRef, serializationContext.$roots$.length - 1);
|
|
3932
|
+
}
|
|
3933
|
+
} else if ("undefined" != typeof FormData && value instanceof FormData) {
|
|
3934
|
+
const array = [];
|
|
3935
|
+
value.forEach((value2, key) => {
|
|
3936
|
+
array.push(key, "string" == typeof value2 ? value2 : value2.name);
|
|
3937
|
+
}), output(TypeIds.FormData, array);
|
|
3938
|
+
} else if (value instanceof URLSearchParams) {
|
|
3939
|
+
output(TypeIds.URLSearchParams, value.toString());
|
|
3940
|
+
} else if (value instanceof Set) {
|
|
3941
|
+
output(TypeIds.Set, [...value.values()]);
|
|
3942
|
+
} else if (value instanceof Map) {
|
|
3943
|
+
const combined = [];
|
|
3944
|
+
for (const [k, v] of value.entries()) {
|
|
3945
|
+
combined.push(k, v);
|
|
3946
|
+
}
|
|
3947
|
+
output(TypeIds.Map, combined);
|
|
3948
|
+
} else if (isJSXNode(value)) {
|
|
3949
|
+
output(TypeIds.JSXNode, [value.type, value.varProps, value.constProps, value.children, value.flags, value.key]);
|
|
3950
|
+
} else if (value instanceof Task) {
|
|
3951
|
+
const out = [value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$];
|
|
3952
|
+
for (; null == out[out.length - 1]; ) {
|
|
3953
|
+
out.pop();
|
|
3954
|
+
}
|
|
3955
|
+
output(TypeIds.Task, out);
|
|
3956
|
+
} else if (isPromise(value)) {
|
|
3957
|
+
const res = promiseResults.get(value);
|
|
3958
|
+
if (!res) {
|
|
3959
|
+
throw qError(QError.serializeErrorUnvisited, ["promise"]);
|
|
3960
|
+
}
|
|
3961
|
+
output(TypeIds.Promise, res);
|
|
3962
|
+
} else if (value instanceof Uint8Array) {
|
|
3963
|
+
let buf = "";
|
|
3964
|
+
for (const c of value) {
|
|
3965
|
+
buf += String.fromCharCode(c);
|
|
3966
|
+
}
|
|
3967
|
+
const out = btoa(buf).replace(/=+$/, "");
|
|
3968
|
+
output(TypeIds.Uint8Array, out);
|
|
3969
|
+
} else {
|
|
3970
|
+
if (!vnode_isVNode(value)) {
|
|
3971
|
+
throw qError(QError.serializeErrorUnknownType, [typeof value]);
|
|
3972
|
+
}
|
|
3973
|
+
output(TypeIds.Constant, Constants.Undefined);
|
|
3974
|
+
}
|
|
3975
|
+
};
|
|
3976
|
+
writeValue(serializationContext.$roots$, -1);
|
|
3977
|
+
}
|
|
3978
|
+
function filterEffectBackRefs(effectBackRef) {
|
|
3979
|
+
let effectBackRefToSerialize = null;
|
|
3980
|
+
if (effectBackRef) {
|
|
3981
|
+
for (const [effectProp, effect] of effectBackRef) {
|
|
3982
|
+
effect[EffectSubscriptionProp.BACK_REF] && (effectBackRefToSerialize || (effectBackRefToSerialize = /* @__PURE__ */ new Map()), effectBackRefToSerialize.set(effectProp, effect));
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
return effectBackRefToSerialize;
|
|
3986
|
+
}
|
|
3987
|
+
function serializeWrappingFn(serializationContext, value) {
|
|
3988
|
+
value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
|
|
3989
|
+
return [serializationContext.$addSyncFn$(value.$funcStr$, value.$args$.length, value.$func$), value.$args$];
|
|
3990
|
+
}
|
|
3991
|
+
function qrlToString(serializationContext, value) {
|
|
3992
|
+
let symbol = value.$symbol$;
|
|
3993
|
+
let chunk = value.$chunk$;
|
|
3994
|
+
const platform = getPlatform();
|
|
3995
|
+
if (platform) {
|
|
3996
|
+
const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
|
|
3997
|
+
result && (chunk = result[1], symbol = result[0]);
|
|
3998
|
+
}
|
|
3999
|
+
if (isSyncQrl(value)) {
|
|
4000
|
+
chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
|
|
4001
|
+
} else {
|
|
4002
|
+
chunk || (chunk = serializationContext.$symbolToChunkResolver$(value.$hash$));
|
|
4003
|
+
{
|
|
4004
|
+
let backChannel = globalThis[QRL_RUNTIME_CHUNK];
|
|
4005
|
+
backChannel || (backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map()), backChannel.set(value.$symbol$, value._devOnlySymbolRef), chunk || (chunk = QRL_RUNTIME_CHUNK);
|
|
4006
|
+
}
|
|
4007
|
+
if (!chunk) {
|
|
4008
|
+
throw qError(QError.qrlMissingChunk, [value.$symbol$]);
|
|
4009
|
+
}
|
|
4010
|
+
chunk.startsWith("./") && (chunk = chunk.slice(2));
|
|
4011
|
+
}
|
|
4012
|
+
let qrlStringInline = `${chunk}#${symbol}`;
|
|
4013
|
+
if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0) {
|
|
4014
|
+
let serializedReferences = "";
|
|
4015
|
+
for (let i = 0; i < value.$captureRef$.length; i++) {
|
|
4016
|
+
i > 0 && (serializedReferences += " "), serializedReferences += serializationContext.$addRoot$(value.$captureRef$[i]);
|
|
4017
|
+
}
|
|
4018
|
+
qrlStringInline += `[${serializedReferences}]`;
|
|
4019
|
+
} else {
|
|
4020
|
+
value.$capture$ && value.$capture$.length > 0 && (qrlStringInline += `[${value.$capture$.join(" ")}]`);
|
|
4021
|
+
}
|
|
4022
|
+
return qrlStringInline;
|
|
4023
|
+
}
|
|
4024
|
+
function deserializeData(container, typeId, value) {
|
|
4025
|
+
if (void 0 === typeId) {
|
|
4026
|
+
return value;
|
|
4027
|
+
}
|
|
4028
|
+
let propValue = allocate(container, typeId, value);
|
|
4029
|
+
return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)), propValue;
|
|
4030
|
+
}
|
|
4031
|
+
function shouldTrackObj(obj) {
|
|
4032
|
+
return "object" == typeof obj && null !== obj || "string" == typeof obj && obj.length > 1;
|
|
4033
|
+
}
|
|
4034
|
+
function isObjectLiteral(obj) {
|
|
4035
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
4036
|
+
return null == prototype || prototype === Object.prototype || prototype === Array.prototype;
|
|
4037
|
+
}
|
|
4038
|
+
function isResource(value) {
|
|
4039
|
+
return "__brand" in value && "resource" === value.__brand;
|
|
4040
|
+
}
|
|
4041
|
+
const frameworkType = (obj) => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl$1(obj);
|
|
4042
|
+
const QRL_RUNTIME_CHUNK = "mock-chunk";
|
|
646
4043
|
var TypeIds;
|
|
647
4044
|
var Constants;
|
|
648
4045
|
!function(TypeIds2) {
|
|
649
4046
|
TypeIds2[TypeIds2.RootRef = 0] = "RootRef", TypeIds2[TypeIds2.Constant = 1] = "Constant", TypeIds2[TypeIds2.Number = 2] = "Number", TypeIds2[TypeIds2.String = 3] = "String", TypeIds2[TypeIds2.Array = 4] = "Array", TypeIds2[TypeIds2.URL = 5] = "URL", TypeIds2[TypeIds2.Date = 6] = "Date", TypeIds2[TypeIds2.Regex = 7] = "Regex", TypeIds2[TypeIds2.VNode = 8] = "VNode", TypeIds2[TypeIds2.RefVNode = 9] = "RefVNode", TypeIds2[TypeIds2.BigInt = 10] = "BigInt", TypeIds2[TypeIds2.URLSearchParams = 11] = "URLSearchParams", TypeIds2[TypeIds2.Error = 12] = "Error", TypeIds2[TypeIds2.Object = 13] = "Object", TypeIds2[TypeIds2.Promise = 14] = "Promise", TypeIds2[TypeIds2.Set = 15] = "Set", TypeIds2[TypeIds2.Map = 16] = "Map", TypeIds2[TypeIds2.Uint8Array = 17] = "Uint8Array", TypeIds2[TypeIds2.QRL = 18] = "QRL", TypeIds2[TypeIds2.Task = 19] = "Task", TypeIds2[TypeIds2.Resource = 20] = "Resource", TypeIds2[TypeIds2.Component = 21] = "Component", TypeIds2[TypeIds2.Signal = 22] = "Signal", TypeIds2[TypeIds2.WrappedSignal = 23] = "WrappedSignal", TypeIds2[TypeIds2.ComputedSignal = 24] = "ComputedSignal", TypeIds2[TypeIds2.Store = 25] = "Store", TypeIds2[TypeIds2.StoreArray = 26] = "StoreArray", TypeIds2[TypeIds2.FormData = 27] = "FormData", TypeIds2[TypeIds2.JSXNode = 28] = "JSXNode", TypeIds2[TypeIds2.PropsProxy = 29] = "PropsProxy", TypeIds2[TypeIds2.EffectData = 30] = "EffectData";
|
|
650
4047
|
}(TypeIds || (TypeIds = {})), function(Constants2) {
|
|
651
|
-
Constants2[Constants2.Undefined = 0] = "Undefined", Constants2[Constants2.Null = 1] = "Null", Constants2[Constants2.True = 2] = "True", Constants2[Constants2.False = 3] = "False", Constants2[Constants2.EmptyString = 4] = "EmptyString", Constants2[Constants2.EMPTY_ARRAY = 5] = "EMPTY_ARRAY", Constants2[Constants2.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants2[Constants2.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION", Constants2[Constants2.
|
|
4048
|
+
Constants2[Constants2.Undefined = 0] = "Undefined", Constants2[Constants2.Null = 1] = "Null", Constants2[Constants2.True = 2] = "True", Constants2[Constants2.False = 3] = "False", Constants2[Constants2.EmptyString = 4] = "EmptyString", Constants2[Constants2.EMPTY_ARRAY = 5] = "EMPTY_ARRAY", Constants2[Constants2.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants2[Constants2.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION", Constants2[Constants2.STORE_ALL_PROPS = 8] = "STORE_ALL_PROPS", Constants2[Constants2.Slot = 9] = "Slot", Constants2[Constants2.Fragment = 10] = "Fragment", Constants2[Constants2.NaN = 11] = "NaN", Constants2[Constants2.PositiveInfinity = 12] = "PositiveInfinity", Constants2[Constants2.NegativeInfinity = 13] = "NegativeInfinity", Constants2[Constants2.MaxSafeInt = 14] = "MaxSafeInt", Constants2[Constants2.AlmostMaxSafeInt = 15] = "AlmostMaxSafeInt", Constants2[Constants2.MinSafeInt = 16] = "MinSafeInt";
|
|
652
4049
|
}(Constants || (Constants = {}));
|
|
4050
|
+
const noSerializeSet = /* @__PURE__ */ new WeakSet();
|
|
4051
|
+
const fastSkipSerialize = (obj) => noSerializeSet.has(obj);
|
|
4052
|
+
const noSerialize = (input) => (null != input && noSerializeSet.add(input), input);
|
|
4053
|
+
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
4054
|
+
let _containerEl;
|
|
4055
|
+
const qrl2 = async function(...args) {
|
|
4056
|
+
const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
|
|
4057
|
+
return await boundedFn(...args);
|
|
4058
|
+
};
|
|
4059
|
+
const setContainer = (el) => (_containerEl || (_containerEl = el), _containerEl);
|
|
4060
|
+
function bindFnToContext(currentCtx, beforeFn) {
|
|
4061
|
+
const bound = (...args) => {
|
|
4062
|
+
if (!qrl2.resolved) {
|
|
4063
|
+
return qrl2.resolve().then((fn) => {
|
|
4064
|
+
if (!isFunction(fn)) {
|
|
4065
|
+
throw qError(QError.qrlIsNotFunction);
|
|
4066
|
+
}
|
|
4067
|
+
return bound(...args);
|
|
4068
|
+
});
|
|
4069
|
+
}
|
|
4070
|
+
if (beforeFn && false === beforeFn()) {
|
|
4071
|
+
return;
|
|
4072
|
+
}
|
|
4073
|
+
const context = createOrReuseInvocationContext(currentCtx);
|
|
4074
|
+
const prevQrl = context.$qrl$;
|
|
4075
|
+
const prevEvent = context.$event$;
|
|
4076
|
+
context.$qrl$ = qrl2, context.$event$ || (context.$event$ = this);
|
|
4077
|
+
try {
|
|
4078
|
+
return invoke.call(this, context, symbolRef, ...args);
|
|
4079
|
+
} finally {
|
|
4080
|
+
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
4081
|
+
}
|
|
4082
|
+
};
|
|
4083
|
+
return bound;
|
|
4084
|
+
}
|
|
4085
|
+
const wrapFn = (fn) => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
|
|
4086
|
+
let context = tryGetInvokeContext();
|
|
4087
|
+
if (context) {
|
|
4088
|
+
if (context.$qrl$?.$symbol$ === qrl2.$symbol$) {
|
|
4089
|
+
return fn.apply(this, args);
|
|
4090
|
+
}
|
|
4091
|
+
const prevQrl = context.$qrl$;
|
|
4092
|
+
context.$qrl$ = qrl2;
|
|
4093
|
+
try {
|
|
4094
|
+
return fn.apply(this, args);
|
|
4095
|
+
} finally {
|
|
4096
|
+
context.$qrl$ = prevQrl;
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
return context = newInvokeContext(), context.$qrl$ = qrl2, context.$event$ = this, invoke.call(this, context, fn, ...args);
|
|
4100
|
+
};
|
|
4101
|
+
const resolve = async (containerEl) => {
|
|
4102
|
+
if (null !== symbolRef) {
|
|
4103
|
+
return symbolRef;
|
|
4104
|
+
}
|
|
4105
|
+
if (containerEl && setContainer(containerEl), "" === chunk) {
|
|
4106
|
+
const hash2 = _containerEl.getAttribute("q:instance");
|
|
4107
|
+
const qFuncs = getQFuncs(_containerEl.ownerDocument, hash2);
|
|
4108
|
+
return qrl2.resolved = symbolRef = qFuncs[Number(symbol)];
|
|
4109
|
+
}
|
|
4110
|
+
const start = now();
|
|
4111
|
+
const ctx = tryGetInvokeContext();
|
|
4112
|
+
{
|
|
4113
|
+
const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
|
|
4114
|
+
symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
|
|
4115
|
+
}
|
|
4116
|
+
return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then(() => emitUsedSymbol(symbol, ctx?.$element$, start), (err) => {
|
|
4117
|
+
throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
|
|
4118
|
+
}), symbolRef;
|
|
4119
|
+
};
|
|
4120
|
+
const createOrReuseInvocationContext = (invoke2) => null == invoke2 ? newInvokeContext() : isArray(invoke2) ? newInvokeContextFromTuple(invoke2) : invoke2;
|
|
4121
|
+
const hash = getSymbolHash(symbol);
|
|
4122
|
+
return Object.assign(qrl2, {
|
|
4123
|
+
getSymbol: () => symbol,
|
|
4124
|
+
getHash: () => hash,
|
|
4125
|
+
getCaptured: () => captureRef,
|
|
4126
|
+
resolve,
|
|
4127
|
+
$resolveLazy$: (containerEl) => null !== symbolRef ? symbolRef : resolve(containerEl),
|
|
4128
|
+
$setContainer$: setContainer,
|
|
4129
|
+
$chunk$: chunk,
|
|
4130
|
+
$symbol$: symbol,
|
|
4131
|
+
$hash$: hash,
|
|
4132
|
+
getFn: bindFnToContext,
|
|
4133
|
+
$capture$: capture,
|
|
4134
|
+
$captureRef$: captureRef,
|
|
4135
|
+
dev: null,
|
|
4136
|
+
resolved: void 0
|
|
4137
|
+
}), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved))), qrl2;
|
|
4138
|
+
};
|
|
4139
|
+
const EMITTED = /* @__PURE__ */ new Set();
|
|
4140
|
+
const emitUsedSymbol = (symbol, element, reqTime) => {
|
|
4141
|
+
EMITTED.has(symbol) || (EMITTED.add(symbol), emitEvent("qsymbol", {
|
|
4142
|
+
symbol,
|
|
4143
|
+
element,
|
|
4144
|
+
reqTime
|
|
4145
|
+
}));
|
|
4146
|
+
};
|
|
4147
|
+
const emitEvent = (eventName, detail) => {
|
|
4148
|
+
isServerPlatform() || "object" != typeof document || document.dispatchEvent(new CustomEvent(eventName, {
|
|
4149
|
+
bubbles: false,
|
|
4150
|
+
detail
|
|
4151
|
+
}));
|
|
4152
|
+
};
|
|
4153
|
+
const now = () => isServerPlatform() ? 0 : "object" == typeof performance ? performance.now() : 0;
|
|
4154
|
+
const componentQrl = (componentQrl2) => {
|
|
4155
|
+
function QwikComponent(props, key, flags = 0) {
|
|
4156
|
+
const finalKey = componentQrl2.$hash$.slice(0, 4) + ":" + (key || "");
|
|
4157
|
+
const InnerCmp = () => {
|
|
4158
|
+
};
|
|
4159
|
+
return InnerCmp[SERIALIZABLE_STATE] = [componentQrl2], _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
|
|
4160
|
+
}
|
|
4161
|
+
return QwikComponent[SERIALIZABLE_STATE] = [componentQrl2], QwikComponent;
|
|
4162
|
+
};
|
|
4163
|
+
const SERIALIZABLE_STATE = Symbol("serializable-data");
|
|
4164
|
+
const isQwikComponent = (component) => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
|
|
653
4165
|
const insightsPing = sync$(
|
|
654
4166
|
() => ((window2, document2, location2, navigator2, performance2, round, JSON_stringify) => {
|
|
655
4167
|
var publicApiKey = __QI_KEY__, postUrl = __QI_URL__, getAttribute_s = "getAttribute", querySelector_s = "querySelector", manifest_s = "manifest", manifest_hash_s = `${manifest_s}-hash`, manifestHash_s = `${manifest_s}Hash`, version_s = "version", publicApiKey_s = "publicApiKey", sendBeacon_s = "sendBeacon", symbol_s = "symbol", length_s = "length", addEventListener_s = "addEventListener", route_s = "route", error_s = "error", stack_s = "stack", message_s = "message", symbols_s = `${symbol_s}s`, qVersion = document2[querySelector_s](`[q\\:${version_s}]`)?.[getAttribute_s](`q:${version_s}`) || "unknown", manifestHash = document2[querySelector_s](`[q\\:${manifest_hash_s}]`)?.[getAttribute_s](
|