@qwik.dev/core 2.0.0-alpha.8 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.wasm.cjs +27 -27
- package/bindings/qwik.wasm.mjs +27 -27
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/index.cjs +3 -3
- package/dist/build/index.d.ts +22 -22
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +6 -6
- package/dist/core-internal.d.ts +4447 -3941
- package/dist/core.cjs +7974 -7742
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +7960 -7738
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +3839 -3777
- package/dist/core.prod.mjs +4183 -4168
- package/dist/insights/index.qwik.cjs +1 -4260
- package/dist/insights/index.qwik.mjs +63 -4251
- package/dist/insights/vite/index.cjs +1 -82
- package/dist/insights/vite/index.mjs +65 -37
- package/dist/insights/vite.d.ts +22 -0
- package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
- 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 +599 -370
- package/dist/optimizer.d.ts +779 -707
- package/dist/optimizer.mjs +595 -414
- package/dist/preloader.cjs +269 -0
- package/dist/preloader.mjs +198 -0
- package/dist/qwikloader.debug.js +242 -222
- package/dist/qwikloader.js +1 -3
- package/dist/server.cjs +676 -574
- package/dist/server.d.ts +504 -402
- package/dist/server.mjs +647 -549
- package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +0 -2
- package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
- package/dist/starters/adapters/bun/src/entry.bun.ts +3 -2
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
- package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
- package/dist/starters/adapters/deno/src/entry.deno.ts +3 -2
- package/dist/starters/adapters/express/src/entry.express.tsx +5 -2
- package/dist/starters/adapters/fastify/src/entry.fastify.tsx +2 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +9 -1
- package/dist/starters/adapters/firebase/firebase.json +12 -1
- package/dist/starters/adapters/firebase/functions/index.js +2 -3
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
- package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -2
- package/dist/starters/adapters/static/README.md +4 -0
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
- package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
- package/dist/starters/features/partytown/package.json +4 -4
- package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
- package/dist/starters/features/postcss/postcss.config.js +1 -1
- package/dist/starters/features/service-worker/package.json +13 -0
- package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +4 -3
- package/dist/starters/features/tailwind/src/global.css +1 -1
- package/dist/starters/features/tailwind-v3/.vscode/settings.json +3 -0
- package/dist/starters/features/tailwind-v3/package.json +21 -0
- package/dist/starters/features/tailwind-v3/postcss.config.cjs +6 -0
- package/dist/starters/features/tailwind-v3/src/global.css +7 -0
- package/dist/starters/features/tailwind-v3/tailwind.config.js +8 -0
- package/dist/testing/index.cjs +8390 -8048
- package/dist/testing/index.d.ts +141 -140
- package/dist/testing/index.mjs +8378 -8044
- package/dist/testing/package.json +1 -1
- package/package.json +19 -11
- package/public.d.ts +10 -0
- package/server.d.ts +1 -0
- package/dist/insights/index.d.ts +0 -1
- package/dist/insights/vite/index.d.ts +0 -1
- package/dist/insights/vite/insights-plugin.d.ts +0 -10
- package/dist/prefetch/index.cjs +0 -4
- package/dist/prefetch/index.d.ts +0 -2
- package/dist/prefetch/index.mjs +0 -3
- package/dist/prefetch/package.json +0 -8
- package/dist/qwik-prefetch.debug.js +0 -244
- package/dist/qwik-prefetch.js +0 -1
|
@@ -1,4260 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
var _a, _b, _c, _d, _e;
|
|
6
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
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;
|
|
11
|
-
/**
|
|
12
|
-
* @license
|
|
13
|
-
* @qwik.dev/core 2.0.0-alpha.8-dev+66037b5
|
|
14
|
-
* Copyright QwikDev. All Rights Reserved.
|
|
15
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
16
|
-
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
17
|
-
*/
|
|
18
|
-
const logError = (message, ...optionalParams) => createAndLogError(false, message, ...optionalParams);
|
|
19
|
-
const throwErrorAndStop = (message, ...optionalParams) => {
|
|
20
|
-
throw createAndLogError(false, message, ...optionalParams);
|
|
21
|
-
};
|
|
22
|
-
const logErrorAndStop = (message, ...optionalParams) => createAndLogError(true, message, ...optionalParams);
|
|
23
|
-
const createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
24
|
-
const err = message instanceof Error ? message : new Error(message);
|
|
25
|
-
return console.error("%cQWIK ERROR", "", err.message, ...optionalParams, err.stack), asyncThrow && setTimeout(() => {
|
|
26
|
-
throw err;
|
|
27
|
-
}, 0), err;
|
|
28
|
-
};
|
|
29
|
-
function assertDefined() {
|
|
30
|
-
}
|
|
31
|
-
function assertEqual() {
|
|
32
|
-
}
|
|
33
|
-
function assertTrue() {
|
|
34
|
-
}
|
|
35
|
-
function assertFalse() {
|
|
36
|
-
}
|
|
37
|
-
const codeToText = (code) => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
|
|
38
|
-
var QError;
|
|
39
|
-
!function(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";
|
|
41
|
-
}(QError || (QError = {}));
|
|
42
|
-
const qError = (code, errorMessageArgs = []) => {
|
|
43
|
-
const text = codeToText(code, ...errorMessageArgs);
|
|
44
|
-
return logErrorAndStop(text, ...errorMessageArgs);
|
|
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
|
-
};
|
|
52
|
-
var VirtualType;
|
|
53
|
-
!function(VirtualType2) {
|
|
54
|
-
VirtualType2.Virtual = "V", VirtualType2.Fragment = "F", VirtualType2.WrappedSignal = "S", VirtualType2.Awaited = "A", VirtualType2.Component = "C", VirtualType2.InlineComponent = "I", VirtualType2.Projection = "P";
|
|
55
|
-
}(VirtualType || (VirtualType = {}));
|
|
56
|
-
({
|
|
57
|
-
[VirtualType.Virtual]: "\x1B[34mVirtual\x1B[0m",
|
|
58
|
-
[VirtualType.Fragment]: "\x1B[34mFragment\x1B[0m",
|
|
59
|
-
[VirtualType.WrappedSignal]: "\x1B[34mSignal\x1B[0m",
|
|
60
|
-
[VirtualType.Awaited]: "\x1B[34mAwaited\x1B[0m",
|
|
61
|
-
[VirtualType.Component]: "\x1B[34mComponent\x1B[0m",
|
|
62
|
-
[VirtualType.InlineComponent]: "\x1B[34mInlineComponent\x1B[0m",
|
|
63
|
-
[VirtualType.Projection]: "\x1B[34mProjection\x1B[0m"
|
|
64
|
-
});
|
|
65
|
-
var QContainerValue;
|
|
66
|
-
!function(QContainerValue2) {
|
|
67
|
-
QContainerValue2.PAUSED = "paused", QContainerValue2.RESUMED = "resumed", QContainerValue2.HTML = "html", QContainerValue2.TEXT = "text";
|
|
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";
|
|
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";
|
|
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;
|
|
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
|
-
};
|
|
160
|
-
const isArray = (v) => Array.isArray(v);
|
|
161
|
-
const isString = (v) => "string" == typeof v;
|
|
162
|
-
const isFunction = (v) => "function" == typeof v;
|
|
163
|
-
var VNodeDataFlag;
|
|
164
|
-
!function(VNodeDataFlag2) {
|
|
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";
|
|
166
|
-
}(VNodeDataFlag || (VNodeDataFlag = {}));
|
|
167
|
-
const isQrl = (value) => "function" == typeof value && "function" == typeof value.getSymbol;
|
|
168
|
-
const EMPTY_ARRAY = [];
|
|
169
|
-
const 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
|
-
}
|
|
317
|
-
const STORE_TARGET = Symbol("store.target");
|
|
318
|
-
const STORE_HANDLER = Symbol("store.handler");
|
|
319
|
-
const STORE_ALL_PROPS = Symbol("store.all");
|
|
320
|
-
var StoreFlags;
|
|
321
|
-
!function(StoreFlags2) {
|
|
322
|
-
StoreFlags2[StoreFlags2.NONE = 0] = "NONE", StoreFlags2[StoreFlags2.RECURSIVE = 1] = "RECURSIVE", StoreFlags2[StoreFlags2.IMMUTABLE = 2] = "IMMUTABLE";
|
|
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;
|
|
327
|
-
const isStore = (value) => STORE_TARGET in value;
|
|
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 {
|
|
447
|
-
constructor() {
|
|
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
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
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
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
function markVNodeAsDeleted(vCursor) {
|
|
1377
|
-
vCursor[VNodeProps.flags] |= VNodeFlags.Deleted;
|
|
1378
|
-
}
|
|
1379
|
-
const HANDLER_PREFIX = ":";
|
|
1380
|
-
var SiblingsArray;
|
|
1381
|
-
!function(SiblingsArray2) {
|
|
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";
|
|
1383
|
-
}(SiblingsArray || (SiblingsArray = {}));
|
|
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;
|
|
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);
|
|
1732
|
-
}
|
|
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 = {}));
|
|
1740
|
-
const throwIfQRLNotResolved = (qrl2) => {
|
|
1741
|
-
if (!qrl2.resolved) {
|
|
1742
|
-
throw qrl2.resolve();
|
|
1743
|
-
}
|
|
1744
|
-
};
|
|
1745
|
-
const isSignal = (value) => value instanceof Signal;
|
|
1746
|
-
class SubscriptionData {
|
|
1747
|
-
constructor(data) {
|
|
1748
|
-
__publicField(this, "data");
|
|
1749
|
-
this.data = data;
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
var EffectSubscriptionProp;
|
|
1753
|
-
var EffectProperty;
|
|
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) {
|
|
1757
|
-
EffectProperty2.COMPONENT = ":", EffectProperty2.VNODE = ".";
|
|
1758
|
-
}(EffectProperty || (EffectProperty = {}));
|
|
1759
|
-
class Signal {
|
|
1760
|
-
constructor(container, value) {
|
|
1761
|
-
__publicField(this, "$untrackedValue$");
|
|
1762
|
-
__publicField(this, "$effects$", null);
|
|
1763
|
-
__publicField(this, "$container$", null);
|
|
1764
|
-
this.$container$ = container, this.$untrackedValue$ = value;
|
|
1765
|
-
}
|
|
1766
|
-
get untrackedValue() {
|
|
1767
|
-
return this.$untrackedValue$;
|
|
1768
|
-
}
|
|
1769
|
-
set untrackedValue(value) {
|
|
1770
|
-
this.$untrackedValue$ = value;
|
|
1771
|
-
}
|
|
1772
|
-
get value() {
|
|
1773
|
-
const ctx = tryGetInvokeContext();
|
|
1774
|
-
if (ctx) {
|
|
1775
|
-
if (null === this.$container$) {
|
|
1776
|
-
if (!ctx.$container$) {
|
|
1777
|
-
return this.untrackedValue;
|
|
1778
|
-
}
|
|
1779
|
-
this.$container$ = ctx.$container$;
|
|
1780
|
-
} else {
|
|
1781
|
-
assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$);
|
|
1782
|
-
}
|
|
1783
|
-
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1784
|
-
if (effectSubscriber) {
|
|
1785
|
-
const effects = this.$effects$ || (this.$effects$ = /* @__PURE__ */ new Set());
|
|
1786
|
-
ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this), addQrlToSerializationCtx(effectSubscriber, this.$container$);
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
return this.untrackedValue;
|
|
1790
|
-
}
|
|
1791
|
-
set value(value) {
|
|
1792
|
-
value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
|
|
1793
|
-
}
|
|
1794
|
-
valueOf() {
|
|
1795
|
-
}
|
|
1796
|
-
toString() {
|
|
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") || "");
|
|
1798
|
-
}
|
|
1799
|
-
toJSON() {
|
|
1800
|
-
return {
|
|
1801
|
-
value: this.$untrackedValue$
|
|
1802
|
-
};
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
const ensureContainsSubscription = (array, effectSubscription) => {
|
|
1806
|
-
array.add(effectSubscription);
|
|
1807
|
-
};
|
|
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);
|
|
1811
|
-
};
|
|
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);
|
|
1818
|
-
}
|
|
1819
|
-
};
|
|
1820
|
-
const triggerEffects = (container, signal, effects) => {
|
|
1821
|
-
const isBrowser2 = isDomContainer(container);
|
|
1822
|
-
if (effects) {
|
|
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;
|
|
1828
|
-
let choreType = ChoreType.TASK;
|
|
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$();
|
|
1832
|
-
} else if (property === EffectProperty.COMPONENT) {
|
|
1833
|
-
const host = consumer;
|
|
1834
|
-
const qrl2 = container.getHostProp(host, "q:renderFn");
|
|
1835
|
-
const props = container.getHostProp(host, "q:props");
|
|
1836
|
-
container.$scheduler$(ChoreType.COMPONENT, host, qrl2, props);
|
|
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
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
};
|
|
1852
|
-
for (const effect of effects) {
|
|
1853
|
-
scheduleEffect(effect);
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
};
|
|
1857
|
-
class ComputedSignal extends (_c = Signal, _b = _EFFECT_BACK_REF, _c) {
|
|
1858
|
-
constructor(container, fn, flags = SignalFlags.INVALID) {
|
|
1859
|
-
super(container, NEEDS_COMPUTATION);
|
|
1860
|
-
__publicField(this, "$computeQrl$");
|
|
1861
|
-
__publicField(this, "$flags$");
|
|
1862
|
-
__publicField(this, "$forceRunEffects$", false);
|
|
1863
|
-
__publicField(this, _b, null);
|
|
1864
|
-
this.$computeQrl$ = fn, this.$flags$ = flags;
|
|
1865
|
-
}
|
|
1866
|
-
$invalidate$() {
|
|
1867
|
-
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
|
|
1868
|
-
}
|
|
1869
|
-
force() {
|
|
1870
|
-
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, triggerEffects(this.$container$, this, this.$effects$);
|
|
1871
|
-
}
|
|
1872
|
-
get untrackedValue() {
|
|
1873
|
-
const didChange = this.$computeIfNeeded$();
|
|
1874
|
-
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION), this.$untrackedValue$;
|
|
1875
|
-
}
|
|
1876
|
-
$computeIfNeeded$() {
|
|
1877
|
-
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
1878
|
-
return false;
|
|
1879
|
-
}
|
|
1880
|
-
const computeQrl = this.$computeQrl$;
|
|
1881
|
-
throwIfQRLNotResolved(computeQrl);
|
|
1882
|
-
const ctx = tryGetInvokeContext();
|
|
1883
|
-
const previousEffectSubscription = ctx?.$effectSubscriber$;
|
|
1884
|
-
ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
|
|
1885
|
-
try {
|
|
1886
|
-
const untrackedValue = computeQrl.getFn(ctx)();
|
|
1887
|
-
if (isPromise(untrackedValue)) {
|
|
1888
|
-
throw qError(QError.computedNotSync, [computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$]);
|
|
1889
|
-
}
|
|
1890
|
-
this.$flags$ &= ~SignalFlags.INVALID;
|
|
1891
|
-
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1892
|
-
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
1893
|
-
} finally {
|
|
1894
|
-
ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
get value() {
|
|
1898
|
-
return super.value;
|
|
1899
|
-
}
|
|
1900
|
-
set value(_) {
|
|
1901
|
-
throw qError(QError.computedReadOnly);
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
class WrappedSignal extends (_e = Signal, _d = _EFFECT_BACK_REF, _e) {
|
|
1905
|
-
constructor(container, fn, args, fnStr, flags = SignalFlags.INVALID | WrappedSignalFlags.UNWRAP) {
|
|
1906
|
-
super(container, NEEDS_COMPUTATION);
|
|
1907
|
-
__publicField(this, "$args$");
|
|
1908
|
-
__publicField(this, "$func$");
|
|
1909
|
-
__publicField(this, "$funcStr$");
|
|
1910
|
-
__publicField(this, "$flags$");
|
|
1911
|
-
__publicField(this, "$hostElement$", null);
|
|
1912
|
-
__publicField(this, "$forceRunEffects$", false);
|
|
1913
|
-
__publicField(this, _d, null);
|
|
1914
|
-
this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr, this.$flags$ = flags;
|
|
1915
|
-
}
|
|
1916
|
-
$invalidate$() {
|
|
1917
|
-
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
|
|
1918
|
-
}
|
|
1919
|
-
force() {
|
|
1920
|
-
this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = false, triggerEffects(this.$container$, this, this.$effects$);
|
|
1921
|
-
}
|
|
1922
|
-
get untrackedValue() {
|
|
1923
|
-
const didChange = this.$computeIfNeeded$();
|
|
1924
|
-
return didChange && (this.$forceRunEffects$ = didChange), assertFalse(this.$untrackedValue$ === NEEDS_COMPUTATION), this.$untrackedValue$;
|
|
1925
|
-
}
|
|
1926
|
-
$computeIfNeeded$() {
|
|
1927
|
-
if (!(this.$flags$ & SignalFlags.INVALID)) {
|
|
1928
|
-
return false;
|
|
1929
|
-
}
|
|
1930
|
-
const untrackedValue = trackSignal(() => this.$func$(...this.$args$), this, EffectProperty.VNODE, this.$container$);
|
|
1931
|
-
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1932
|
-
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
1933
|
-
}
|
|
1934
|
-
get value() {
|
|
1935
|
-
return super.value;
|
|
1936
|
-
}
|
|
1937
|
-
set value(_) {
|
|
1938
|
-
throw qError(QError.wrappedReadOnly);
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
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
|
-
}
|
|
1963
|
-
const _jsxSorted = (type, varProps, constProps, children, flags, key) => {
|
|
1964
|
-
const processed = null == key ? null : String(key);
|
|
1965
|
-
const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
|
|
1966
|
-
return node;
|
|
1967
|
-
};
|
|
1968
|
-
const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
|
|
1969
|
-
let sortedProps;
|
|
1970
|
-
return sortedProps = varProps ? Object.fromEntries(untrack(() => Object.entries(varProps)).filter((entry) => {
|
|
1971
|
-
const attr = entry[0];
|
|
1972
|
-
return "children" === attr ? (children ?? (children = entry[1]), false) : "key" === attr ? (key = entry[1], false) : !constProps;
|
|
1973
|
-
}).sort(([a2], [b]) => a2 < b ? -1 : 1)) : "string" == typeof type ? EMPTY_OBJ : {}, _jsxSorted(type, sortedProps, constProps, children, flags, key);
|
|
1974
|
-
};
|
|
1975
|
-
const jsx = (type, props, key) => _jsxSplit(type, props, null, null, 0, null);
|
|
1976
|
-
const isPropsProxy = (obj) => obj && void 0 !== obj[_VAR_PROPS];
|
|
1977
|
-
class JSXNodeImpl {
|
|
1978
|
-
constructor(type, varProps, constProps, children, flags, key = null) {
|
|
1979
|
-
__publicField(this, "type");
|
|
1980
|
-
__publicField(this, "varProps");
|
|
1981
|
-
__publicField(this, "constProps");
|
|
1982
|
-
__publicField(this, "children");
|
|
1983
|
-
__publicField(this, "flags");
|
|
1984
|
-
__publicField(this, "key");
|
|
1985
|
-
__publicField(this, "dev");
|
|
1986
|
-
__publicField(this, "_proxy", null);
|
|
1987
|
-
this.type = type, this.varProps = varProps, this.constProps = constProps, this.children = children, this.flags = flags, this.key = key;
|
|
1988
|
-
}
|
|
1989
|
-
get props() {
|
|
1990
|
-
return this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children)), this._proxy;
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
const Virtual = (props) => props.children;
|
|
1994
|
-
const isJSXNode = (n) => n instanceof JSXNodeImpl;
|
|
1995
|
-
const Fragment = (props) => props.children;
|
|
1996
|
-
function createPropsProxy(varProps, constProps, children) {
|
|
1997
|
-
return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
|
|
1998
|
-
}
|
|
1999
|
-
class PropsProxyHandler {
|
|
2000
|
-
constructor($varProps$, $constProps$, $children$) {
|
|
2001
|
-
__publicField(this, "$varProps$");
|
|
2002
|
-
__publicField(this, "$constProps$");
|
|
2003
|
-
__publicField(this, "$children$");
|
|
2004
|
-
this.$varProps$ = $varProps$, this.$constProps$ = $constProps$, this.$children$ = $children$;
|
|
2005
|
-
}
|
|
2006
|
-
get(_, prop) {
|
|
2007
|
-
if (prop === _CONST_PROPS) {
|
|
2008
|
-
return this.$constProps$;
|
|
2009
|
-
}
|
|
2010
|
-
if (prop === _VAR_PROPS) {
|
|
2011
|
-
return this.$varProps$;
|
|
2012
|
-
}
|
|
2013
|
-
if (null != this.$children$ && "children" === prop) {
|
|
2014
|
-
return this.$children$;
|
|
2015
|
-
}
|
|
2016
|
-
const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
|
|
2017
|
-
return value instanceof WrappedSignal && value.$flags$ & WrappedSignalFlags.UNWRAP ? value.value : value;
|
|
2018
|
-
}
|
|
2019
|
-
set(_, prop, value) {
|
|
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);
|
|
2021
|
-
}
|
|
2022
|
-
deleteProperty(_, prop) {
|
|
2023
|
-
if ("string" != typeof prop) {
|
|
2024
|
-
return false;
|
|
2025
|
-
}
|
|
2026
|
-
let didDelete = delete this.$varProps$[prop];
|
|
2027
|
-
return this.$constProps$ && (didDelete = delete this.$constProps$[prop] || didDelete), null != this.$children$ && "children" === prop && (this.$children$ = null), didDelete;
|
|
2028
|
-
}
|
|
2029
|
-
has(_, prop) {
|
|
2030
|
-
return "children" === prop && null != this.$children$ || prop === _CONST_PROPS || prop === _VAR_PROPS || prop in this.$varProps$ || !!this.$constProps$ && prop in this.$constProps$;
|
|
2031
|
-
}
|
|
2032
|
-
getOwnPropertyDescriptor(target, p) {
|
|
2033
|
-
return {
|
|
2034
|
-
configurable: true,
|
|
2035
|
-
enumerable: true,
|
|
2036
|
-
value: "children" === p && null != this.$children$ ? this.$children$ : this.$constProps$ && p in this.$constProps$ ? this.$constProps$[p] : this.$varProps$[p]
|
|
2037
|
-
};
|
|
2038
|
-
}
|
|
2039
|
-
ownKeys() {
|
|
2040
|
-
const out = Object.keys(this.$varProps$);
|
|
2041
|
-
if (null != this.$children$ && -1 === out.indexOf("children") && out.push("children"), this.$constProps$) {
|
|
2042
|
-
for (const key in this.$constProps$) {
|
|
2043
|
-
-1 === out.indexOf(key) && out.push(key);
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
return out;
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
const directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
|
|
2050
|
-
const stringifyPath = [];
|
|
2051
|
-
function qwikDebugToString(value) {
|
|
2052
|
-
if (null === value) {
|
|
2053
|
-
return "null";
|
|
2054
|
-
}
|
|
2055
|
-
if (void 0 === value) {
|
|
2056
|
-
return "undefined";
|
|
2057
|
-
}
|
|
2058
|
-
if ("string" == typeof value) {
|
|
2059
|
-
return '"' + value + '"';
|
|
2060
|
-
}
|
|
2061
|
-
if ("number" == typeof value || "boolean" == typeof value) {
|
|
2062
|
-
return String(value);
|
|
2063
|
-
}
|
|
2064
|
-
if (isTask(value)) {
|
|
2065
|
-
return `Task(${qwikDebugToString(value.$qrl$)})`;
|
|
2066
|
-
}
|
|
2067
|
-
if (isQrl(value)) {
|
|
2068
|
-
return `Qrl(${value.$symbol$})`;
|
|
2069
|
-
}
|
|
2070
|
-
if ("object" == typeof value || "function" == typeof value) {
|
|
2071
|
-
if (stringifyPath.includes(value)) {
|
|
2072
|
-
return "*";
|
|
2073
|
-
}
|
|
2074
|
-
try {
|
|
2075
|
-
if (stringifyPath.push(value), Array.isArray(value)) {
|
|
2076
|
-
return vnode_isVNode(value) ? "(" + vnode_getProp(value, "q:type", null) + ")" : value.map(qwikDebugToString);
|
|
2077
|
-
}
|
|
2078
|
-
if (isSignal(value)) {
|
|
2079
|
-
return value instanceof WrappedSignal ? "WrappedSignal" : value instanceof ComputedSignal ? "ComputedSignal" : "Signal";
|
|
2080
|
-
}
|
|
2081
|
-
if (isStore(value)) {
|
|
2082
|
-
return "Store";
|
|
2083
|
-
}
|
|
2084
|
-
if (isJSXNode(value)) {
|
|
2085
|
-
return jsxToString(value);
|
|
2086
|
-
}
|
|
2087
|
-
} finally {
|
|
2088
|
-
stringifyPath.pop();
|
|
2089
|
-
}
|
|
2090
|
-
}
|
|
2091
|
-
return value;
|
|
2092
|
-
}
|
|
2093
|
-
const pad = (text, prefix) => String(text).split("\n").map((line, idx) => (idx ? prefix : "") + line).join("\n");
|
|
2094
|
-
const jsxToString = (value) => {
|
|
2095
|
-
if (isJSXNode(value)) {
|
|
2096
|
-
let type = value.type;
|
|
2097
|
-
"function" == typeof type && (type = type.name || "Component");
|
|
2098
|
-
let str = "<" + value.type;
|
|
2099
|
-
if (value.props) {
|
|
2100
|
-
for (const [key, val] of Object.entries(value.props)) {
|
|
2101
|
-
str += " " + key + "=" + qwikDebugToString(val);
|
|
2102
|
-
}
|
|
2103
|
-
const children = value.children;
|
|
2104
|
-
null != children ? (str += ">", Array.isArray(children) ? children.forEach((child) => {
|
|
2105
|
-
str += jsxToString(child);
|
|
2106
|
-
}) : str += jsxToString(children), str += "</" + value.type + ">") : str += "/>";
|
|
2107
|
-
}
|
|
2108
|
-
return str;
|
|
2109
|
-
}
|
|
2110
|
-
return String(value);
|
|
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
|
-
};
|
|
2182
|
-
var VNodeJournalOpCode;
|
|
2183
|
-
!function(VNodeJournalOpCode2) {
|
|
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";
|
|
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
|
-
};
|
|
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
|
-
};
|
|
2216
|
-
const vnode_isTextVNode = (vNode) => {
|
|
2217
|
-
return (vNode[VNodeProps.flags] & VNodeFlags.Text) === VNodeFlags.Text;
|
|
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);
|
|
2226
|
-
const ensureElementOrVirtualVNode = (vNode) => {
|
|
2227
|
-
assertTrue(!!(vNode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
|
|
2228
|
-
};
|
|
2229
|
-
const ensureElementVNode = (vNode) => (assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)), vNode);
|
|
2230
|
-
const vnode_getNodeTypeName = (vNode) => {
|
|
2231
|
-
if (vNode) {
|
|
2232
|
-
switch (vNode[VNodeProps.flags] & VNodeFlags.TYPE_MASK) {
|
|
2233
|
-
case VNodeFlags.Element:
|
|
2234
|
-
return "Element";
|
|
2235
|
-
case VNodeFlags.Virtual:
|
|
2236
|
-
return "Virtual";
|
|
2237
|
-
case VNodeFlags.Text:
|
|
2238
|
-
return "Text";
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
return "<unknown>";
|
|
2242
|
-
};
|
|
2243
|
-
const vnode_ensureElementInflated = (vnode) => {
|
|
2244
|
-
if ((vnode[VNodeProps.flags] & VNodeFlags.INFLATED_TYPE_MASK) === VNodeFlags.Element) {
|
|
2245
|
-
const elementVNode = vnode;
|
|
2246
|
-
elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
|
|
2247
|
-
const element = elementVNode[ElementVNodeProps.element];
|
|
2248
|
-
const attributes = element.attributes;
|
|
2249
|
-
const props = vnode_getProps(elementVNode);
|
|
2250
|
-
for (let idx = 0; idx < attributes.length; idx++) {
|
|
2251
|
-
const attr = attributes[idx];
|
|
2252
|
-
const key = attr.name;
|
|
2253
|
-
if (":" === key || !key) {
|
|
2254
|
-
break;
|
|
2255
|
-
}
|
|
2256
|
-
if (key.startsWith("q:container")) {
|
|
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);
|
|
2258
|
-
} else if (!key.startsWith("on:")) {
|
|
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();
|
|
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();
|
|
2719
|
-
}
|
|
2720
|
-
return vData.substring(start, nextToConsumeIdx);
|
|
2721
|
-
};
|
|
2722
|
-
for (; 0 !== peek(); ) {
|
|
2723
|
-
callback(peek, consumeValue, consume, nextToConsumeIdx);
|
|
2724
|
-
}
|
|
2725
|
-
};
|
|
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);
|
|
2741
|
-
}
|
|
2742
|
-
}
|
|
2743
|
-
};
|
|
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;
|
|
2751
|
-
};
|
|
2752
|
-
const vnode_getProp = (vnode, key, getObject) => {
|
|
2753
|
-
const type = vnode[VNodeProps.flags];
|
|
2754
|
-
if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
|
|
2755
|
-
type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
|
|
2756
|
-
const props = vnode_getProps(vnode);
|
|
2757
|
-
const idx = mapApp_findIndx(props, key, 0);
|
|
2758
|
-
if (idx >= 0) {
|
|
2759
|
-
let value = props[idx + 1];
|
|
2760
|
-
return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)), value;
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
return null;
|
|
2764
|
-
};
|
|
2765
|
-
const vnode_setProp = (vnode, key, value) => {
|
|
2766
|
-
ensureElementOrVirtualVNode(vnode);
|
|
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);
|
|
2770
|
-
};
|
|
2771
|
-
const vnode_getPropStartIndex = (vnode) => {
|
|
2772
|
-
const type = vnode[VNodeProps.flags] & VNodeFlags.TYPE_MASK;
|
|
2773
|
-
if (type === VNodeFlags.Element) {
|
|
2774
|
-
return ElementVNodeProps.PROPS_OFFSET;
|
|
2775
|
-
}
|
|
2776
|
-
if (type === VNodeFlags.Virtual) {
|
|
2777
|
-
return VirtualVNodeProps.PROPS_OFFSET;
|
|
2778
|
-
}
|
|
2779
|
-
throw qError(QError.invalidVNodeType, [type]);
|
|
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
|
-
};
|
|
2887
|
-
const VNodeArray = class VNode extends Array {
|
|
2888
|
-
static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
|
|
2889
|
-
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
|
|
2890
|
-
}
|
|
2891
|
-
static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
|
|
2892
|
-
return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
|
|
2893
|
-
}
|
|
2894
|
-
static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
|
|
2895
|
-
return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
|
|
2896
|
-
}
|
|
2897
|
-
constructor(flags, parent, previousSibling, nextSibling, ...rest) {
|
|
2898
|
-
super(flags, parent, previousSibling, nextSibling, ...rest);
|
|
2899
|
-
}
|
|
2900
|
-
};
|
|
2901
|
-
let _context;
|
|
2902
|
-
const tryGetInvokeContext = () => {
|
|
2903
|
-
if (!_context) {
|
|
2904
|
-
const context = "undefined" != typeof document && document && document.__q_context__;
|
|
2905
|
-
if (!context) {
|
|
2906
|
-
return;
|
|
2907
|
-
}
|
|
2908
|
-
return isArray(context) ? document.__q_context__ = newInvokeContextFromTuple(context) : context;
|
|
2909
|
-
}
|
|
2910
|
-
return _context;
|
|
2911
|
-
};
|
|
2912
|
-
function invoke(context, fn, ...args) {
|
|
2913
|
-
return invokeApply.call(this, context, fn, args);
|
|
2914
|
-
}
|
|
2915
|
-
function invokeApply(context, fn, args) {
|
|
2916
|
-
const previousContext = _context;
|
|
2917
|
-
let returnValue;
|
|
2918
|
-
try {
|
|
2919
|
-
_context = context, returnValue = fn.apply(this, args);
|
|
2920
|
-
} finally {
|
|
2921
|
-
_context = previousContext;
|
|
2922
|
-
}
|
|
2923
|
-
return returnValue;
|
|
2924
|
-
}
|
|
2925
|
-
const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
2926
|
-
const domContainer = getDomContainer(element);
|
|
2927
|
-
const container = domContainer.element;
|
|
2928
|
-
const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
|
|
2929
|
-
const locale = container?.getAttribute("q:locale") || void 0;
|
|
2930
|
-
return newInvokeContext(locale, vNode, element, event, url);
|
|
2931
|
-
};
|
|
2932
|
-
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
2933
|
-
const ctx = {
|
|
2934
|
-
$url$: url,
|
|
2935
|
-
$i$: 0,
|
|
2936
|
-
$hostElement$: hostElement,
|
|
2937
|
-
$element$: element,
|
|
2938
|
-
$event$: event,
|
|
2939
|
-
$qrl$: void 0,
|
|
2940
|
-
$effectSubscriber$: void 0,
|
|
2941
|
-
$locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
|
|
2942
|
-
$container$: void 0
|
|
2943
|
-
};
|
|
2944
|
-
return ctx;
|
|
2945
|
-
};
|
|
2946
|
-
const untrack = (fn) => invoke(void 0, fn);
|
|
2947
|
-
const trackInvocation = /* @__PURE__ */ newInvokeContext(void 0, void 0, void 0, "qRender");
|
|
2948
|
-
const trackSignal = (fn, subscriber, property, container, data) => {
|
|
2949
|
-
const previousSubscriber = trackInvocation.$effectSubscriber$;
|
|
2950
|
-
const previousContainer = trackInvocation.$container$;
|
|
2951
|
-
try {
|
|
2952
|
-
return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data), trackInvocation.$container$ = container, invoke(trackInvocation, fn);
|
|
2953
|
-
} finally {
|
|
2954
|
-
trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
|
|
2955
|
-
}
|
|
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";
|
|
4045
|
-
var TypeIds;
|
|
4046
|
-
var Constants;
|
|
4047
|
-
!function(TypeIds2) {
|
|
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";
|
|
4049
|
-
}(TypeIds || (TypeIds = {})), function(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";
|
|
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];
|
|
4167
|
-
const insightsPing = core.sync$(
|
|
4168
|
-
() => ((window2, document2, location2, navigator2, performance2, round, JSON_stringify) => {
|
|
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](
|
|
4170
|
-
`q:${manifest_hash_s}`
|
|
4171
|
-
) || "dev", qSymbols = [], existingSymbols = /* @__PURE__ */ new Set(), flushSymbolIndex = 0, lastReqTime = 0, timeoutID, qRouteChangeTime = performance2.now(), qRouteEl = document2[querySelector_s](`[q\\:${route_s}]`), flush = () => {
|
|
4172
|
-
timeoutID = void 0;
|
|
4173
|
-
if (qSymbols[length_s] > flushSymbolIndex) {
|
|
4174
|
-
var payload = {
|
|
4175
|
-
qVersion,
|
|
4176
|
-
[publicApiKey_s]: publicApiKey,
|
|
4177
|
-
[manifestHash_s]: manifestHash,
|
|
4178
|
-
previousSymbol: flushSymbolIndex == 0 ? void 0 : qSymbols[flushSymbolIndex - 1][symbol_s],
|
|
4179
|
-
[symbols_s]: qSymbols.slice(flushSymbolIndex)
|
|
4180
|
-
};
|
|
4181
|
-
navigator2[sendBeacon_s](postUrl, JSON_stringify(payload));
|
|
4182
|
-
flushSymbolIndex = qSymbols[length_s];
|
|
4183
|
-
}
|
|
4184
|
-
}, debounceFlush = () => {
|
|
4185
|
-
timeoutID != void 0 && clearTimeout(timeoutID);
|
|
4186
|
-
timeoutID = setTimeout(flush, 1e3);
|
|
4187
|
-
};
|
|
4188
|
-
window2.qSymbolTracker = {
|
|
4189
|
-
[symbols_s]: qSymbols,
|
|
4190
|
-
[publicApiKey_s]: publicApiKey
|
|
4191
|
-
};
|
|
4192
|
-
if (qRouteEl) {
|
|
4193
|
-
new MutationObserver((mutations) => {
|
|
4194
|
-
var mutation = mutations.find((m) => m.attributeName === `q:${route_s}`);
|
|
4195
|
-
if (mutation) {
|
|
4196
|
-
qRouteChangeTime = performance2.now();
|
|
4197
|
-
}
|
|
4198
|
-
}).observe(qRouteEl, { attributes: true });
|
|
4199
|
-
}
|
|
4200
|
-
document2[addEventListener_s](
|
|
4201
|
-
"visibilitychange",
|
|
4202
|
-
() => document2.visibilityState === "hidden" && flush()
|
|
4203
|
-
);
|
|
4204
|
-
document2[addEventListener_s](`q${symbol_s}`, (_event) => {
|
|
4205
|
-
var event = _event, detail = event.detail, symbolRequestTime = detail.reqTime, symbolDeliveredTime = event.timeStamp, symbol = detail[symbol_s];
|
|
4206
|
-
if (!existingSymbols.has(symbol)) {
|
|
4207
|
-
existingSymbols.add(symbol);
|
|
4208
|
-
var route = qRouteEl?.[getAttribute_s](`q:${route_s}`) || "/";
|
|
4209
|
-
qSymbols.push({
|
|
4210
|
-
[symbol_s]: symbol,
|
|
4211
|
-
[route_s]: route,
|
|
4212
|
-
delay: round(0 - lastReqTime + symbolRequestTime),
|
|
4213
|
-
latency: round(symbolDeliveredTime - symbolRequestTime),
|
|
4214
|
-
timeline: round(0 - qRouteChangeTime + symbolRequestTime),
|
|
4215
|
-
interaction: !!detail.element
|
|
4216
|
-
});
|
|
4217
|
-
lastReqTime = symbolDeliveredTime;
|
|
4218
|
-
debounceFlush();
|
|
4219
|
-
}
|
|
4220
|
-
});
|
|
4221
|
-
window2[addEventListener_s](error_s, (event) => {
|
|
4222
|
-
var error = event[error_s];
|
|
4223
|
-
if (!(error && typeof error === "object")) {
|
|
4224
|
-
return;
|
|
4225
|
-
}
|
|
4226
|
-
var payload = {
|
|
4227
|
-
url: `${location2}`,
|
|
4228
|
-
[manifestHash_s]: manifestHash,
|
|
4229
|
-
timestamp: (/* @__PURE__ */ new Date()).getTime(),
|
|
4230
|
-
source: event.filename,
|
|
4231
|
-
line: event.lineno,
|
|
4232
|
-
column: event.colno,
|
|
4233
|
-
[message_s]: event[message_s],
|
|
4234
|
-
[error_s]: message_s in error ? error[message_s] : `${error}`,
|
|
4235
|
-
[stack_s]: stack_s in error ? error[stack_s] || "" : ""
|
|
4236
|
-
};
|
|
4237
|
-
navigator2[sendBeacon_s](`${postUrl}${error_s}/`, JSON_stringify(payload));
|
|
4238
|
-
});
|
|
4239
|
-
})(window, document, location, navigator, performance, Math.round, JSON.stringify)
|
|
4240
|
-
);
|
|
4241
|
-
const Insights = core.component$(
|
|
4242
|
-
({ publicApiKey, postUrl }) => {
|
|
4243
|
-
if (!__EXPERIMENTAL__.insights) {
|
|
4244
|
-
throw new Error(
|
|
4245
|
-
'Insights is experimental and must be enabled with `experimental: ["insights"]` in the `qwikVite` plugin.'
|
|
4246
|
-
);
|
|
4247
|
-
}
|
|
4248
|
-
if (!publicApiKey) {
|
|
4249
|
-
return null;
|
|
4250
|
-
}
|
|
4251
|
-
return (
|
|
4252
|
-
// the script will set the variables before the qinit event
|
|
4253
|
-
/* @__PURE__ */ jsx("script", {
|
|
4254
|
-
"document:onQInit$": insightsPing,
|
|
4255
|
-
dangerouslySetInnerHTML: `__QI_KEY__=${JSON.stringify(publicApiKey)};__QI_URL__=${JSON.stringify(postUrl || `https://insights.qwik.dev/api/v1/${publicApiKey}/post/`)}`
|
|
4256
|
-
})
|
|
4257
|
-
);
|
|
4258
|
-
}
|
|
4259
|
-
);
|
|
4260
|
-
exports.Insights = Insights;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@qwik.dev/core"),L=require("@qwik.dev/core/jsx-runtime"),T=g.sync$(()=>((r,i,w,_,b,l,y)=>{var h=__QI_KEY__,d=__QI_URL__,E=i.querySelector("[q\\:version]")?.getAttribute("q:version")||"unknown",f=i.querySelector("[q\\:manifest-hash]")?.getAttribute("q:manifest-hash")||"dev",s=[],q=new Set,o=0,v=0,a,p=b.now(),m=i.querySelector("[q\\:route]"),I=()=>{if(a=void 0,s.length>o){var t={qVersion:E,publicApiKey:h,manifestHash:f,previousSymbol:o==0?void 0:s[o-1].symbol,symbols:s.slice(o)};_.sendBeacon(d,y(t)),o=s.length}},k=()=>{a!=null&&clearTimeout(a),a=setTimeout(I,1e3)};r.qSymbolTracker={symbols:s,publicApiKey:h},m&&new MutationObserver(t=>{var e=t.find(n=>n.attributeName==="q:route");e&&(p=b.now())}).observe(m,{attributes:!0}),i.addEventListener("visibilitychange",()=>i.visibilityState==="hidden"&&I()),i.addEventListener("qsymbol",t=>{var e=t,n=e.detail,u=n.reqTime,S=e.timeStamp,c=n.symbol;if(!q.has(c)){q.add(c);var R=m?.getAttribute("q:route")||"/";s.push({symbol:c,route:R,delay:l(0-v+u),latency:l(S-u),timeline:l(0-p+u),interaction:!!n.element}),v=S,k()}}),r.addEventListener("error",t=>{var e=t.error;if(e&&typeof e=="object"){var n={url:`${w}`,manifestHash:f,timestamp:new Date().getTime(),source:t.filename,line:t.lineno,column:t.colno,message:t.message,error:"message"in e?e.message:`${e}`,stack:"stack"in e&&e.stack||""};_.sendBeacon(`${d}error/`,y(n))}})})(window,document,location,navigator,performance,Math.round,JSON.stringify)),$=g.component$(()=>{if(!__EXPERIMENTAL__.insights)throw new Error('Insights is experimental and must be enabled with `experimental: ["insights"]` in the `qwikVite` plugin.');const r=globalThis.__QI_KEY__,i=globalThis.__QI_URL__;return!r||!i?(g.isDev||console.warn("<Insights />: no config from qwikInsights plugin, skipping..."),null):L.jsx("script",{"document:onQInit$":T,dangerouslySetInnerHTML:`__QI_KEY__=${JSON.stringify(r)};__QI_URL__=${JSON.stringify(i)}`})});exports.Insights=$;exports.insightsPing=T;
|