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