@qwik.dev/core 2.0.0-beta.3 → 2.0.0-beta.31
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/dist/backpatch/index.d.ts +2 -0
- package/dist/backpatch/index.mjs +5 -0
- package/dist/backpatch/package.json +8 -0
- package/dist/backpatch-executor.debug.js +39 -0
- package/dist/backpatch-executor.js +1 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +12961 -0
- package/dist/core-internal.d.ts +1117 -707
- package/dist/core.min.mjs +2 -1
- package/dist/core.mjs +12216 -8953
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +8677 -5376
- package/dist/insights/index.qwik.mjs +80 -57
- package/dist/insights/vite/index.mjs +36 -33
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +47 -278
- package/dist/optimizer.mjs +2427 -3791
- package/dist/preloader.mjs +212 -117
- package/dist/qwikloader.debug.js +173 -135
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +51 -203
- package/dist/server.mjs +1661 -1157
- package/dist/server.prod.mjs +3452 -0
- package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/aws-lambda/package.json +3 -2
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -6
- package/dist/starters/adapters/azure-swa/adapters/azure-swa/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/azure-swa/package.json +3 -2
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -3
- package/dist/starters/adapters/bun/adapters/bun/{vite.config.mts → vite.config.ts} +3 -3
- package/dist/starters/adapters/bun/package.json +3 -2
- package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
- package/dist/starters/adapters/cloud-run/adapters/cloud-run/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/cloud-run/package.json +3 -2
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
- package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/cloudflare-pages/package.json +3 -2
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -3
- package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
- package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
- package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
- package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
- package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
- package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
- package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
- package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
- package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
- package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
- package/dist/starters/adapters/deno/adapters/deno/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/deno/package.json +3 -2
- package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
- package/dist/starters/adapters/express/adapters/express/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/express/package.json +4 -3
- package/dist/starters/adapters/express/src/entry.express.tsx +1 -3
- package/dist/starters/adapters/fastify/adapters/fastify/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/fastify/package.json +4 -3
- package/dist/starters/adapters/fastify/src/entry.fastify.tsx +1 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
- package/dist/starters/adapters/firebase/adapters/firebase/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/firebase/package.json +3 -2
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -3
- package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/netlify-edge/package.json +5 -4
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -3
- package/dist/starters/adapters/node-server/adapters/node-server/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/node-server/package.json +3 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
- package/dist/starters/adapters/{static/adapters/static/vite.config.mts → ssg/adapters/ssg/vite.config.ts} +3 -3
- package/dist/starters/adapters/ssg/package.json +20 -0
- package/dist/starters/adapters/vercel-edge/README.md +2 -2
- package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/vercel-edge/package.json +3 -2
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -3
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/compiled-i18n/package.json +37 -0
- package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
- package/dist/starters/features/compiled-i18n/src/entry.ssr.tsx +31 -0
- package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
- package/dist/starters/features/csr/index.html +27 -0
- package/dist/starters/features/csr/package.json +29 -0
- package/dist/starters/features/csr/src/root.tsx +15 -0
- package/dist/starters/features/csr/vite.config.ts +13 -0
- package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
- package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
- package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
- package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
- package/dist/starters/features/pandacss/package.json +1 -1
- package/dist/starters/features/postcss/postcss.config.js +1 -1
- package/dist/starters/features/storybook/.storybook/tsconfig.json +0 -1
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +2 -2
- package/dist/starters/features/tailwind/prettier.config.js +10 -0
- package/dist/starters/features/tailwind-v3/package.json +1 -1
- package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
- package/dist/testing/index.d.ts +928 -6
- package/dist/testing/index.mjs +16212 -11578
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +1 -1
- package/package.json +34 -56
- package/public.d.ts +5 -1
- package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
- package/server.d.ts +2 -0
- 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 +0 -471
- package/bindings/qwik.wasm.mjs +0 -464
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/index.cjs +0 -35
- package/dist/build/index.cjs.map +0 -7
- package/dist/build/index.dev.cjs +0 -37
- package/dist/build/index.dev.cjs.map +0 -7
- package/dist/build/index.prod.cjs +0 -37
- package/dist/build/index.prod.cjs.map +0 -7
- package/dist/cli.cjs +0 -5545
- package/dist/core.cjs +0 -11800
- package/dist/core.cjs.map +0 -1
- package/dist/core.prod.cjs +0 -5661
- package/dist/insights/index.qwik.cjs +0 -1
- package/dist/insights/vite/index.cjs +0 -1
- package/dist/loader/index.cjs +0 -4
- package/dist/optimizer.cjs +0 -4020
- package/dist/preloader.cjs +0 -269
- package/dist/server.cjs +0 -3037
- package/dist/starters/adapters/static/package.json +0 -19
- package/dist/starters/features/localize/package.json +0 -37
- package/dist/starters/features/localize/src/entry.ssr.tsx +0 -30
- package/dist/starters/features/localize/src/locales/message.en.json +0 -8
- package/dist/starters/features/localize/src/locales/message.it.json +0 -8
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
- package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
- package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
- package/dist/starters/features/playwright/playwright-report/index.html +0 -22026
- package/dist/starters/features/tailwind/.prettierrc.js +0 -3
- package/dist/testing/index.cjs +0 -33331
- /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
package/dist/server.mjs
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.31-dev+906321a
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
7
7
|
*/
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
-
}) : x)(function(x) {
|
|
13
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
-
});
|
|
16
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
17
8
|
|
|
18
9
|
// packages/qwik/src/server/index.ts
|
|
19
10
|
import { setPlatform as setPlatform2 } from "@qwik.dev/core";
|
|
20
11
|
|
|
21
12
|
// packages/qwik/src/server/platform.ts
|
|
22
13
|
import { setPlatform } from "@qwik.dev/core";
|
|
14
|
+
import { isDev as isDev5 } from "@qwik.dev/core/build";
|
|
15
|
+
|
|
16
|
+
// packages/qwik/src/core/client/util-mapArray.ts
|
|
17
|
+
import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
18
|
+
|
|
19
|
+
// packages/qwik/src/core/shared/error/assert.ts
|
|
20
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
23
21
|
|
|
24
22
|
// packages/qwik/src/core/shared/utils/qdev.ts
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var qDynamicPlatform =
|
|
29
|
-
var qTest =
|
|
30
|
-
var qRuntimeQrl =
|
|
23
|
+
var g = globalThis;
|
|
24
|
+
var qDev = g.qDev !== false;
|
|
25
|
+
var qInspector = g.qInspector === true;
|
|
26
|
+
var qDynamicPlatform = g.qDynamicPlatform !== false;
|
|
27
|
+
var qTest = g.qTest === true;
|
|
28
|
+
var qRuntimeQrl = g.qRuntimeQrl === true;
|
|
31
29
|
|
|
32
30
|
// packages/qwik/src/core/shared/utils/log.ts
|
|
33
31
|
var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
|
|
@@ -53,7 +51,7 @@ var createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
|
53
51
|
// packages/qwik/src/core/shared/error/assert.ts
|
|
54
52
|
var ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
|
|
55
53
|
function assertTrue(value1, text, ...parts) {
|
|
56
|
-
if (
|
|
54
|
+
if (isDev) {
|
|
57
55
|
if (value1 === true) {
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
@@ -63,7 +61,7 @@ function assertTrue(value1, text, ...parts) {
|
|
|
63
61
|
|
|
64
62
|
// packages/qwik/src/core/client/util-mapArray.ts
|
|
65
63
|
var mapApp_findIndx = (array, key, start) => {
|
|
66
|
-
assertTrue(start % 2 === 0, "Expecting even number.");
|
|
64
|
+
isDev2 && assertTrue(start % 2 === 0, "Expecting even number.");
|
|
67
65
|
let bottom = start >> 1;
|
|
68
66
|
let top = array.length - 2 >> 1;
|
|
69
67
|
while (bottom <= top) {
|
|
@@ -80,15 +78,15 @@ var mapApp_findIndx = (array, key, start) => {
|
|
|
80
78
|
}
|
|
81
79
|
return bottom << 1 ^ -1;
|
|
82
80
|
};
|
|
83
|
-
var mapArray_set = (array, key, value, start) => {
|
|
81
|
+
var mapArray_set = (array, key, value, start, allowNullValue = false) => {
|
|
84
82
|
const indx = mapApp_findIndx(array, key, start);
|
|
85
83
|
if (indx >= 0) {
|
|
86
|
-
if (value == null) {
|
|
84
|
+
if (value == null && !allowNullValue) {
|
|
87
85
|
array.splice(indx, 2);
|
|
88
86
|
} else {
|
|
89
87
|
array[indx + 1] = value;
|
|
90
88
|
}
|
|
91
|
-
} else if (value != null) {
|
|
89
|
+
} else if (value != null || allowNullValue) {
|
|
92
90
|
array.splice(indx ^ -1, 0, key, value);
|
|
93
91
|
}
|
|
94
92
|
};
|
|
@@ -114,6 +112,17 @@ var mapArray_has = (array, key, start) => {
|
|
|
114
112
|
return mapApp_findIndx(array, key, start) >= 0;
|
|
115
113
|
};
|
|
116
114
|
|
|
115
|
+
// packages/qwik/src/core/shared/utils/types.ts
|
|
116
|
+
var isObject = (v) => {
|
|
117
|
+
return typeof v === "object" && v !== null;
|
|
118
|
+
};
|
|
119
|
+
var isArray = (v) => {
|
|
120
|
+
return Array.isArray(v);
|
|
121
|
+
};
|
|
122
|
+
var isString = (v) => {
|
|
123
|
+
return typeof v === "string";
|
|
124
|
+
};
|
|
125
|
+
|
|
117
126
|
// packages/qwik/src/core/shared/error/error.ts
|
|
118
127
|
var codeToText = (code, ...parts) => {
|
|
119
128
|
if (qDev) {
|
|
@@ -130,7 +139,7 @@ var codeToText = (code, ...parts) => {
|
|
|
130
139
|
// 4
|
|
131
140
|
"QRL is not a function",
|
|
132
141
|
// 5
|
|
133
|
-
"Dynamic import not found",
|
|
142
|
+
"Dynamic import {{0}} not found",
|
|
134
143
|
// 6
|
|
135
144
|
"Unknown type argument",
|
|
136
145
|
// 7
|
|
@@ -139,7 +148,7 @@ var codeToText = (code, ...parts) => {
|
|
|
139
148
|
"Invoking 'use*()' method outside of invocation context.",
|
|
140
149
|
// 9
|
|
141
150
|
`Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.
|
|
142
|
-
See https://qwik.dev/docs/
|
|
151
|
+
See https://qwik.dev/docs/core/tasks/#use-method-rules`,
|
|
143
152
|
// 10
|
|
144
153
|
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
|
|
145
154
|
// 11
|
|
@@ -179,11 +188,16 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
179
188
|
// 28
|
|
180
189
|
"useComputed$ QRL {{0}} {{1}} cannot return a Promise",
|
|
181
190
|
// 29
|
|
182
|
-
|
|
191
|
+
`===
|
|
192
|
+
Qwik version {{0}} already imported while importing {{1}}.
|
|
193
|
+
This can lead to issues due to duplicated shared structures.
|
|
194
|
+
Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude".
|
|
195
|
+
===
|
|
196
|
+
`,
|
|
183
197
|
// 30
|
|
184
198
|
"WrappedSignal is read-only",
|
|
185
199
|
// 31
|
|
186
|
-
"Attribute value is unsafe for SSR",
|
|
200
|
+
"Attribute value is unsafe for SSR {{0}}",
|
|
187
201
|
// 32
|
|
188
202
|
"SerializerSymbol function returned rejected promise",
|
|
189
203
|
// 33
|
|
@@ -194,7 +208,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
194
208
|
if (parts.length) {
|
|
195
209
|
text = text.replaceAll(/{{(\d+)}}/g, (_, index) => {
|
|
196
210
|
let v = parts[index];
|
|
197
|
-
if (v &&
|
|
211
|
+
if (v && isObject(v) && v.constructor === Object) {
|
|
198
212
|
v = JSON.stringify(v).slice(0, 50);
|
|
199
213
|
}
|
|
200
214
|
return v;
|
|
@@ -202,7 +216,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
202
216
|
}
|
|
203
217
|
return `Code(Q${code}): ${text}`;
|
|
204
218
|
} else {
|
|
205
|
-
return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/
|
|
219
|
+
return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/build/v2/packages/qwik/src/core/shared/error/error.ts#${parts.join()}L${9 + code}`;
|
|
206
220
|
}
|
|
207
221
|
};
|
|
208
222
|
var qError = (code, errorMessageArgs = []) => {
|
|
@@ -211,255 +225,16 @@ var qError = (code, errorMessageArgs = []) => {
|
|
|
211
225
|
};
|
|
212
226
|
|
|
213
227
|
// packages/qwik/src/core/shared/qrl/qrl-utils.ts
|
|
214
|
-
import { isDev } from "@qwik.dev/core/build";
|
|
228
|
+
import { isDev as isDev3 } from "@qwik.dev/core/build";
|
|
215
229
|
var SYNC_QRL = "<sync>";
|
|
230
|
+
var getSymbolHash = (symbolName) => {
|
|
231
|
+
const index = symbolName.lastIndexOf("_") + 1;
|
|
232
|
+
return symbolName.slice(index);
|
|
233
|
+
};
|
|
216
234
|
|
|
217
235
|
// packages/qwik/src/core/shared/types.ts
|
|
218
236
|
var DEBUG_TYPE = "q:type";
|
|
219
237
|
|
|
220
|
-
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
221
|
-
function escapeHTML(html) {
|
|
222
|
-
let escapedHTML = "";
|
|
223
|
-
const length = html.length;
|
|
224
|
-
let idx = 0;
|
|
225
|
-
let lastIdx = idx;
|
|
226
|
-
for (; idx < length; idx++) {
|
|
227
|
-
const ch = html.charCodeAt(idx);
|
|
228
|
-
if (ch === 60) {
|
|
229
|
-
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
230
|
-
} else if (ch === 62) {
|
|
231
|
-
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
232
|
-
} else if (ch === 38) {
|
|
233
|
-
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
234
|
-
} else if (ch === 34) {
|
|
235
|
-
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
236
|
-
} else if (ch === 39) {
|
|
237
|
-
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
238
|
-
} else {
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
lastIdx = idx + 1;
|
|
242
|
-
}
|
|
243
|
-
if (lastIdx === 0) {
|
|
244
|
-
return html;
|
|
245
|
-
} else {
|
|
246
|
-
return escapedHTML + html.substring(lastIdx);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// packages/qwik/src/core/shared/utils/markers.ts
|
|
251
|
-
var OnRenderProp = "q:renderFn";
|
|
252
|
-
var QSlot = "q:slot";
|
|
253
|
-
var QSlotParent = "q:sparent";
|
|
254
|
-
var QStyle = "q:style";
|
|
255
|
-
var QStyleSelector = "style[q\\:style]";
|
|
256
|
-
var QStyleSSelector = "style[q\\:sstyle]";
|
|
257
|
-
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
258
|
-
var QScopedStyle = "q:sstyle";
|
|
259
|
-
var QCtxAttr = "q:ctx";
|
|
260
|
-
var QBackRefs = "q:brefs";
|
|
261
|
-
var QRenderAttr = "q:render";
|
|
262
|
-
var QRuntimeAttr = "q:runtime";
|
|
263
|
-
var QVersionAttr = "q:version";
|
|
264
|
-
var QBaseAttr = "q:base";
|
|
265
|
-
var QLocaleAttr = "q:locale";
|
|
266
|
-
var QManifestHashAttr = "q:manifest-hash";
|
|
267
|
-
var QInstanceAttr = "q:instance";
|
|
268
|
-
var QContainerIsland = "q:container-island";
|
|
269
|
-
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
270
|
-
var QIgnore = "q:ignore";
|
|
271
|
-
var QIgnoreEnd = "/" + QIgnore;
|
|
272
|
-
var QContainerAttr = "q:container";
|
|
273
|
-
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
274
|
-
var QTemplate = "q:template";
|
|
275
|
-
var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
|
|
276
|
-
var QDefaultSlot = "";
|
|
277
|
-
var ELEMENT_ID = "q:id";
|
|
278
|
-
var ELEMENT_KEY = "q:key";
|
|
279
|
-
var ELEMENT_PROPS = "q:props";
|
|
280
|
-
var ELEMENT_SEQ = "q:seq";
|
|
281
|
-
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
282
|
-
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
283
|
-
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
284
|
-
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
285
|
-
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
286
|
-
var FLUSH_COMMENT = "qkssr-f";
|
|
287
|
-
var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
|
|
288
|
-
var STREAM_BLOCK_END_COMMENT = "qkssr-po";
|
|
289
|
-
var Q_PROPS_SEPARATOR = ":";
|
|
290
|
-
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
291
|
-
|
|
292
|
-
// packages/qwik/src/core/shared/utils/promises.ts
|
|
293
|
-
import { isDev as isDev2, isServer } from "@qwik.dev/core/build";
|
|
294
|
-
var isPromise = (value) => {
|
|
295
|
-
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
296
|
-
};
|
|
297
|
-
var maybeThen = (valueOrPromise, thenFn) => {
|
|
298
|
-
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
|
|
299
|
-
};
|
|
300
|
-
var shouldNotError = (reason) => {
|
|
301
|
-
throwErrorAndStop(reason);
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
305
|
-
function isClassAttr(key) {
|
|
306
|
-
return key === "class" || key === "className";
|
|
307
|
-
}
|
|
308
|
-
function convertStyleIdsToString(scopedStyleIds) {
|
|
309
|
-
return Array.from(scopedStyleIds).join(" ");
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
313
|
-
function isPreventDefault(key) {
|
|
314
|
-
return key.startsWith("preventdefault:");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// packages/qwik/src/core/shared/utils/types.ts
|
|
318
|
-
var isArray = (v) => {
|
|
319
|
-
return Array.isArray(v);
|
|
320
|
-
};
|
|
321
|
-
var isString = (v) => {
|
|
322
|
-
return typeof v === "string";
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
// packages/qwik/src/core/shared/utils/unitless_number.ts
|
|
326
|
-
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
327
|
-
"animationIterationCount",
|
|
328
|
-
"aspectRatio",
|
|
329
|
-
"borderImageOutset",
|
|
330
|
-
"borderImageSlice",
|
|
331
|
-
"borderImageWidth",
|
|
332
|
-
"boxFlex",
|
|
333
|
-
"boxFlexGroup",
|
|
334
|
-
"boxOrdinalGroup",
|
|
335
|
-
"columnCount",
|
|
336
|
-
"columns",
|
|
337
|
-
"flex",
|
|
338
|
-
"flexGrow",
|
|
339
|
-
"flexShrink",
|
|
340
|
-
"gridArea",
|
|
341
|
-
"gridRow",
|
|
342
|
-
"gridRowEnd",
|
|
343
|
-
"gridRowStart",
|
|
344
|
-
"gridColumn",
|
|
345
|
-
"gridColumnEnd",
|
|
346
|
-
"gridColumnStart",
|
|
347
|
-
"fontWeight",
|
|
348
|
-
"lineClamp",
|
|
349
|
-
"lineHeight",
|
|
350
|
-
"opacity",
|
|
351
|
-
"order",
|
|
352
|
-
"orphans",
|
|
353
|
-
"scale",
|
|
354
|
-
"tabSize",
|
|
355
|
-
"widows",
|
|
356
|
-
"zIndex",
|
|
357
|
-
"zoom",
|
|
358
|
-
"MozAnimationIterationCount",
|
|
359
|
-
// Known Prefixed Properties
|
|
360
|
-
"MozBoxFlex",
|
|
361
|
-
// TODO: Remove these since they shouldn't be used in modern code
|
|
362
|
-
"msFlex",
|
|
363
|
-
"msFlexPositive",
|
|
364
|
-
"WebkitAnimationIterationCount",
|
|
365
|
-
"WebkitBoxFlex",
|
|
366
|
-
"WebkitBoxOrdinalGroup",
|
|
367
|
-
"WebkitColumnCount",
|
|
368
|
-
"WebkitColumns",
|
|
369
|
-
"WebkitFlex",
|
|
370
|
-
"WebkitFlexGrow",
|
|
371
|
-
"WebkitFlexShrink",
|
|
372
|
-
"WebkitLineClamp"
|
|
373
|
-
]);
|
|
374
|
-
var isUnitlessNumber = (name) => {
|
|
375
|
-
return unitlessNumbers.has(name);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// packages/qwik/src/core/shared/utils/styles.ts
|
|
379
|
-
var serializeClass = (obj) => {
|
|
380
|
-
if (!obj) {
|
|
381
|
-
return "";
|
|
382
|
-
}
|
|
383
|
-
if (isString(obj)) {
|
|
384
|
-
return obj.trim();
|
|
385
|
-
}
|
|
386
|
-
const classes = [];
|
|
387
|
-
if (isArray(obj)) {
|
|
388
|
-
for (const o of obj) {
|
|
389
|
-
const classList = serializeClass(o);
|
|
390
|
-
if (classList) {
|
|
391
|
-
classes.push(classList);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
396
|
-
if (value) {
|
|
397
|
-
classes.push(key.trim());
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return classes.join(" ");
|
|
402
|
-
};
|
|
403
|
-
var fromCamelToKebabCaseWithDash = (text) => {
|
|
404
|
-
return text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
405
|
-
};
|
|
406
|
-
var stringifyStyle = (obj) => {
|
|
407
|
-
if (obj == null) {
|
|
408
|
-
return "";
|
|
409
|
-
}
|
|
410
|
-
if (typeof obj == "object") {
|
|
411
|
-
if (isArray(obj)) {
|
|
412
|
-
throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]);
|
|
413
|
-
} else {
|
|
414
|
-
const chunks = [];
|
|
415
|
-
for (const key in obj) {
|
|
416
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
417
|
-
const value = obj[key];
|
|
418
|
-
if (value != null && typeof value !== "function") {
|
|
419
|
-
if (key.startsWith("--")) {
|
|
420
|
-
chunks.push(key + ":" + value);
|
|
421
|
-
} else {
|
|
422
|
-
chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value));
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return chunks.join(";");
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return String(obj);
|
|
431
|
-
};
|
|
432
|
-
var serializeBooleanOrNumberAttribute = (value) => {
|
|
433
|
-
return value != null ? String(value) : null;
|
|
434
|
-
};
|
|
435
|
-
function serializeAttribute(key, value, styleScopedId) {
|
|
436
|
-
if (isClassAttr(key)) {
|
|
437
|
-
const serializedClass = serializeClass(value);
|
|
438
|
-
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
439
|
-
} else if (key === "style") {
|
|
440
|
-
value = stringifyStyle(value);
|
|
441
|
-
} else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") {
|
|
442
|
-
value = serializeBooleanOrNumberAttribute(value);
|
|
443
|
-
} else if (value === false || value == null) {
|
|
444
|
-
value = null;
|
|
445
|
-
} else if (value === true && isPreventDefault(key)) {
|
|
446
|
-
value = "";
|
|
447
|
-
}
|
|
448
|
-
return value;
|
|
449
|
-
}
|
|
450
|
-
function isEnumeratedBooleanAttribute(key) {
|
|
451
|
-
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
452
|
-
}
|
|
453
|
-
var setValueForStyle = (styleName, value) => {
|
|
454
|
-
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) {
|
|
455
|
-
return value + "px";
|
|
456
|
-
}
|
|
457
|
-
return value;
|
|
458
|
-
};
|
|
459
|
-
function isAriaAttribute(prop) {
|
|
460
|
-
return prop.startsWith("aria-");
|
|
461
|
-
}
|
|
462
|
-
|
|
463
238
|
// packages/qwik/src/core/shared/vnode-data-types.ts
|
|
464
239
|
var VNodeDataSeparator = {
|
|
465
240
|
REFERENCE_CH: (
|
|
@@ -748,23 +523,400 @@ var VNodeDataChar = {
|
|
|
748
523
|
)
|
|
749
524
|
};
|
|
750
525
|
|
|
751
|
-
// packages/qwik/src/core/
|
|
752
|
-
|
|
753
|
-
|
|
526
|
+
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
527
|
+
function escapeHTML(html) {
|
|
528
|
+
let escapedHTML = "";
|
|
529
|
+
const length = html.length;
|
|
530
|
+
let idx = 0;
|
|
531
|
+
let lastIdx = idx;
|
|
532
|
+
for (; idx < length; idx++) {
|
|
533
|
+
const ch = html.charCodeAt(idx);
|
|
534
|
+
if (ch === 60) {
|
|
535
|
+
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
536
|
+
} else if (ch === 62) {
|
|
537
|
+
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
538
|
+
} else if (ch === 38) {
|
|
539
|
+
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
540
|
+
} else if (ch === 34) {
|
|
541
|
+
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
542
|
+
} else if (ch === 39) {
|
|
543
|
+
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
544
|
+
} else {
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
lastIdx = idx + 1;
|
|
548
|
+
}
|
|
549
|
+
if (lastIdx === 0) {
|
|
550
|
+
return html;
|
|
551
|
+
} else {
|
|
552
|
+
return escapedHTML + html.substring(lastIdx);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function encodeVNodeDataString(str) {
|
|
556
|
+
let escapedHTML = "";
|
|
557
|
+
const length = str.length;
|
|
558
|
+
let idx = 0;
|
|
559
|
+
let lastIdx = idx;
|
|
560
|
+
for (; idx < length; idx++) {
|
|
561
|
+
const ch = str.charCodeAt(idx);
|
|
562
|
+
if (ch >= VNodeDataSeparator.ADVANCE_1 && ch <= VNodeDataSeparator.ADVANCE_8192) {
|
|
563
|
+
escapedHTML += str.substring(lastIdx, idx) + "\\" + str.charAt(idx);
|
|
564
|
+
} else {
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
lastIdx = idx + 1;
|
|
568
|
+
}
|
|
569
|
+
if (lastIdx === 0) {
|
|
570
|
+
return str;
|
|
571
|
+
} else {
|
|
572
|
+
return escapedHTML + str.substring(lastIdx);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// packages/qwik/src/core/shared/utils/markers.ts
|
|
577
|
+
var OnRenderProp = "q:renderFn";
|
|
578
|
+
var QSlot = "q:slot";
|
|
579
|
+
var QSlotParent = "q:sparent";
|
|
580
|
+
var QStyle = "q:style";
|
|
581
|
+
var QStyleSelector = "style[q\\:style]";
|
|
582
|
+
var QStyleSSelector = "style[q\\:sstyle]";
|
|
583
|
+
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
584
|
+
var QScopedStyle = "q:sstyle";
|
|
585
|
+
var QCtxAttr = "q:ctx";
|
|
586
|
+
var QBackRefs = "q:brefs";
|
|
587
|
+
var QRenderAttr = "q:render";
|
|
588
|
+
var QRuntimeAttr = "q:runtime";
|
|
589
|
+
var QVersionAttr = "q:version";
|
|
590
|
+
var QBaseAttr = "q:base";
|
|
591
|
+
var QLocaleAttr = "q:locale";
|
|
592
|
+
var QManifestHashAttr = "q:manifest-hash";
|
|
593
|
+
var QInstanceAttr = "q:instance";
|
|
594
|
+
var QContainerIsland = "q:container-island";
|
|
595
|
+
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
596
|
+
var QIgnore = "q:ignore";
|
|
597
|
+
var QIgnoreEnd = "/" + QIgnore;
|
|
598
|
+
var QContainerAttr = "q:container";
|
|
599
|
+
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
600
|
+
var QTemplate = "q:template";
|
|
601
|
+
var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
|
|
602
|
+
var QDefaultSlot = "";
|
|
603
|
+
var ELEMENT_ID = "q:id";
|
|
604
|
+
var ELEMENT_KEY = "q:key";
|
|
605
|
+
var ELEMENT_PROPS = "q:props";
|
|
606
|
+
var ELEMENT_SEQ = "q:seq";
|
|
607
|
+
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
608
|
+
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
609
|
+
var ITERATION_ITEM_SINGLE = "q:p";
|
|
610
|
+
var ITERATION_ITEM_MULTI = "q:ps";
|
|
611
|
+
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
612
|
+
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
613
|
+
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
614
|
+
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
615
|
+
var Q_PROPS_SEPARATOR = ":";
|
|
616
|
+
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
617
|
+
|
|
618
|
+
// packages/qwik/src/core/shared/utils/promises.ts
|
|
619
|
+
import { isDev as isDev4, isServer } from "@qwik.dev/core/build";
|
|
620
|
+
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
621
|
+
var isPromise = (value) => {
|
|
622
|
+
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
623
|
+
};
|
|
624
|
+
var maybeThen = (valueOrPromise, thenFn) => {
|
|
625
|
+
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
626
|
+
};
|
|
627
|
+
var checkError = (e) => {
|
|
628
|
+
if (isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
629
|
+
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
var justThrow = (e) => {
|
|
633
|
+
throw e;
|
|
634
|
+
};
|
|
635
|
+
function retryOnPromise(fn, onError = justThrow) {
|
|
636
|
+
let ok = false;
|
|
637
|
+
let result;
|
|
638
|
+
try {
|
|
639
|
+
result = fn();
|
|
640
|
+
ok = true;
|
|
641
|
+
} catch (e) {
|
|
642
|
+
result = e;
|
|
643
|
+
}
|
|
644
|
+
if (!isPromise(result)) {
|
|
645
|
+
if (ok) {
|
|
646
|
+
return result;
|
|
647
|
+
}
|
|
648
|
+
isDev4 && checkError(result);
|
|
649
|
+
return onError(result);
|
|
650
|
+
}
|
|
651
|
+
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
652
|
+
const retry = async (p) => {
|
|
653
|
+
while (isPromise(p)) {
|
|
654
|
+
try {
|
|
655
|
+
await p;
|
|
656
|
+
return await fn();
|
|
657
|
+
} catch (err) {
|
|
658
|
+
if (isPromise(err)) {
|
|
659
|
+
if (!--retryCount) {
|
|
660
|
+
p = new Error("Exceeded max retry count in retryOnPromise");
|
|
661
|
+
break;
|
|
662
|
+
} else {
|
|
663
|
+
p = err;
|
|
664
|
+
}
|
|
665
|
+
} else {
|
|
666
|
+
p = err;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
isDev4 && checkError(p);
|
|
672
|
+
return onError(p);
|
|
673
|
+
};
|
|
674
|
+
return ok ? result.catch(retry) : retry(result);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
678
|
+
function isClassAttr(key) {
|
|
679
|
+
return key === "class";
|
|
680
|
+
}
|
|
681
|
+
function convertStyleIdsToString(scopedStyleIds) {
|
|
682
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
686
|
+
var isHtmlAttributeAnEventName = (name) => {
|
|
687
|
+
return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && name.charCodeAt(3) === 58;
|
|
688
|
+
};
|
|
689
|
+
function isPreventDefault(key) {
|
|
690
|
+
return key.startsWith("preventdefault:");
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// packages/qwik/src/core/shared/utils/unitless_number.ts
|
|
694
|
+
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
695
|
+
"animationIterationCount",
|
|
696
|
+
"aspectRatio",
|
|
697
|
+
"borderImageOutset",
|
|
698
|
+
"borderImageSlice",
|
|
699
|
+
"borderImageWidth",
|
|
700
|
+
"boxFlex",
|
|
701
|
+
"boxFlexGroup",
|
|
702
|
+
"boxOrdinalGroup",
|
|
703
|
+
"columnCount",
|
|
704
|
+
"columns",
|
|
705
|
+
"flex",
|
|
706
|
+
"flexGrow",
|
|
707
|
+
"flexShrink",
|
|
708
|
+
"gridArea",
|
|
709
|
+
"gridRow",
|
|
710
|
+
"gridRowEnd",
|
|
711
|
+
"gridRowStart",
|
|
712
|
+
"gridColumn",
|
|
713
|
+
"gridColumnEnd",
|
|
714
|
+
"gridColumnStart",
|
|
715
|
+
"fontWeight",
|
|
716
|
+
"lineClamp",
|
|
717
|
+
"lineHeight",
|
|
718
|
+
"opacity",
|
|
719
|
+
"order",
|
|
720
|
+
"orphans",
|
|
721
|
+
"scale",
|
|
722
|
+
"tabSize",
|
|
723
|
+
"widows",
|
|
724
|
+
"zIndex",
|
|
725
|
+
"zoom",
|
|
726
|
+
"MozAnimationIterationCount",
|
|
727
|
+
// Known Prefixed Properties
|
|
728
|
+
"MozBoxFlex",
|
|
729
|
+
// TODO: Remove these since they shouldn't be used in modern code
|
|
730
|
+
"msFlex",
|
|
731
|
+
"msFlexPositive",
|
|
732
|
+
"WebkitAnimationIterationCount",
|
|
733
|
+
"WebkitBoxFlex",
|
|
734
|
+
"WebkitBoxOrdinalGroup",
|
|
735
|
+
"WebkitColumnCount",
|
|
736
|
+
"WebkitColumns",
|
|
737
|
+
"WebkitFlex",
|
|
738
|
+
"WebkitFlexGrow",
|
|
739
|
+
"WebkitFlexShrink",
|
|
740
|
+
"WebkitLineClamp"
|
|
741
|
+
]);
|
|
742
|
+
var isUnitlessNumber = (name) => {
|
|
743
|
+
return unitlessNumbers.has(name);
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
// packages/qwik/src/core/shared/utils/styles.ts
|
|
747
|
+
var serializeClass = (obj) => {
|
|
748
|
+
if (!obj) {
|
|
749
|
+
return "";
|
|
750
|
+
}
|
|
751
|
+
if (isString(obj)) {
|
|
752
|
+
return obj.trim();
|
|
753
|
+
}
|
|
754
|
+
const classes = [];
|
|
755
|
+
if (isArray(obj)) {
|
|
756
|
+
for (let i = 0; i < obj.length; i++) {
|
|
757
|
+
const o = obj[i];
|
|
758
|
+
const classList = serializeClass(o);
|
|
759
|
+
if (classList) {
|
|
760
|
+
classes.push(classList);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
765
|
+
if (value) {
|
|
766
|
+
classes.push(key.trim());
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return classes.join(" ");
|
|
771
|
+
};
|
|
772
|
+
var fromCamelToKebabCaseWithDash = (text) => {
|
|
773
|
+
return text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
774
|
+
};
|
|
775
|
+
var stringifyStyle = (obj) => {
|
|
776
|
+
if (obj == null) {
|
|
777
|
+
return "";
|
|
778
|
+
}
|
|
779
|
+
if (typeof obj == "object") {
|
|
780
|
+
if (isArray(obj)) {
|
|
781
|
+
throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]);
|
|
782
|
+
} else {
|
|
783
|
+
const chunks = [];
|
|
784
|
+
for (const key in obj) {
|
|
785
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
786
|
+
const value = obj[key];
|
|
787
|
+
if (value != null && typeof value !== "function") {
|
|
788
|
+
if (key.startsWith("--")) {
|
|
789
|
+
chunks.push(key + ":" + value);
|
|
790
|
+
} else {
|
|
791
|
+
chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return chunks.join(";");
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return String(obj);
|
|
800
|
+
};
|
|
801
|
+
var serializeBooleanOrNumberAttribute = (value) => {
|
|
802
|
+
return value != null ? String(value) : null;
|
|
803
|
+
};
|
|
804
|
+
function serializeAttribute(key, value, styleScopedId) {
|
|
805
|
+
if (isClassAttr(key)) {
|
|
806
|
+
const serializedClass = serializeClass(value);
|
|
807
|
+
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
808
|
+
} else if (key === "style") {
|
|
809
|
+
value = stringifyStyle(value);
|
|
810
|
+
} else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") {
|
|
811
|
+
value = serializeBooleanOrNumberAttribute(value);
|
|
812
|
+
} else if (value === false || value == null) {
|
|
813
|
+
value = null;
|
|
814
|
+
} else if (value === true && isPreventDefault(key)) {
|
|
815
|
+
value = "";
|
|
816
|
+
}
|
|
817
|
+
return value;
|
|
818
|
+
}
|
|
819
|
+
function isEnumeratedBooleanAttribute(key) {
|
|
820
|
+
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
821
|
+
}
|
|
822
|
+
var setValueForStyle = (styleName, value) => {
|
|
823
|
+
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) {
|
|
824
|
+
return value + "px";
|
|
825
|
+
}
|
|
826
|
+
return value;
|
|
827
|
+
};
|
|
828
|
+
function isAriaAttribute(prop) {
|
|
829
|
+
return prop.startsWith("aria-");
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
833
|
+
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
834
|
+
|
|
754
835
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
755
|
-
import {
|
|
836
|
+
import { isServer as isServer4 } from "@qwik.dev/core/build";
|
|
837
|
+
|
|
838
|
+
// packages/qwik/src/core/shared/platform/platform.ts
|
|
839
|
+
import { isServer as isServer2 } from "@qwik.dev/core/build";
|
|
840
|
+
var createPlatform = () => {
|
|
841
|
+
return {
|
|
842
|
+
isServer: isServer2,
|
|
843
|
+
importSymbol(containerEl, url, symbolName) {
|
|
844
|
+
if (isServer2) {
|
|
845
|
+
const hash = getSymbolHash(symbolName);
|
|
846
|
+
const regSym = globalThis.__qwik_reg_symbols?.get(hash);
|
|
847
|
+
if (regSym) {
|
|
848
|
+
return regSym;
|
|
849
|
+
}
|
|
850
|
+
throw qError(6 /* dynamicImportFailed */, [symbolName]);
|
|
851
|
+
}
|
|
852
|
+
if (!url) {
|
|
853
|
+
throw qError(14 /* qrlMissingChunk */, [symbolName]);
|
|
854
|
+
}
|
|
855
|
+
if (!containerEl) {
|
|
856
|
+
throw qError(13 /* qrlMissingContainer */, [url, symbolName]);
|
|
857
|
+
}
|
|
858
|
+
const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
|
|
859
|
+
const urlCopy = new URL(urlDoc);
|
|
860
|
+
urlCopy.hash = "";
|
|
861
|
+
const importURL = urlCopy.href;
|
|
862
|
+
return import(
|
|
863
|
+
/* @vite-ignore */
|
|
864
|
+
importURL
|
|
865
|
+
).then((mod) => {
|
|
866
|
+
return mod[symbolName];
|
|
867
|
+
});
|
|
868
|
+
},
|
|
869
|
+
raf: (fn) => {
|
|
870
|
+
return new Promise((resolve) => {
|
|
871
|
+
requestAnimationFrame(() => {
|
|
872
|
+
resolve(fn());
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
},
|
|
876
|
+
chunkForSymbol(symbolName, chunk) {
|
|
877
|
+
return [symbolName, chunk ?? "_"];
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
};
|
|
881
|
+
var toUrl = (doc2, containerEl, url) => {
|
|
882
|
+
const baseURI = doc2.baseURI;
|
|
883
|
+
const base2 = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
|
|
884
|
+
return new URL(url, base2);
|
|
885
|
+
};
|
|
886
|
+
var _platform = /* @__PURE__ */ createPlatform();
|
|
887
|
+
var isServerPlatform = () => {
|
|
888
|
+
if (qDynamicPlatform) {
|
|
889
|
+
return _platform.isServer;
|
|
890
|
+
}
|
|
891
|
+
return false;
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
// packages/qwik/src/core/shared/platform/next-tick.ts
|
|
895
|
+
var createMacroTask = (fn) => {
|
|
896
|
+
let macroTask;
|
|
897
|
+
if (typeof MessageChannel !== "undefined") {
|
|
898
|
+
const channel = new MessageChannel();
|
|
899
|
+
channel.port1.onmessage = () => fn();
|
|
900
|
+
macroTask = () => channel.port2.postMessage(null);
|
|
901
|
+
} else {
|
|
902
|
+
macroTask = () => setTimeout(fn);
|
|
903
|
+
}
|
|
904
|
+
return macroTask;
|
|
905
|
+
};
|
|
756
906
|
|
|
757
907
|
// packages/qwik/src/core/preloader/constants.ts
|
|
758
|
-
import {
|
|
908
|
+
import { isServer as isServer3 } from "@qwik.dev/core/build";
|
|
909
|
+
var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
|
|
759
910
|
var doc = isBrowser ? document : void 0;
|
|
760
911
|
var config = {
|
|
761
912
|
$DEBUG$: false,
|
|
762
913
|
$maxIdlePreloads$: 25,
|
|
763
914
|
$invPreloadProbability$: 0.65
|
|
764
915
|
};
|
|
765
|
-
var rel = isBrowser && doc.createElement("link").relList
|
|
766
|
-
var loadStart =
|
|
916
|
+
var rel = isBrowser && doc.createElement("link").relList?.supports?.("modulepreload") ? "modulePreload" : "preload";
|
|
917
|
+
var loadStart = performance.now();
|
|
767
918
|
var isJSRegex = /\.[mc]?js$/;
|
|
919
|
+
var yieldInterval = 1e3 / 60;
|
|
768
920
|
|
|
769
921
|
// packages/qwik/src/core/preloader/types.ts
|
|
770
922
|
var BundleImportState_None = 0;
|
|
@@ -776,13 +928,14 @@ var BundleImportState_Loaded = 4;
|
|
|
776
928
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
777
929
|
var base;
|
|
778
930
|
var graph;
|
|
931
|
+
var isBrowser2 = import.meta.env.TEST ? !isServerPlatform() : !isServer4;
|
|
779
932
|
var makeBundle = (name, deps) => {
|
|
780
933
|
return {
|
|
781
934
|
$name$: name,
|
|
782
935
|
$state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
|
|
783
936
|
$deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
|
|
784
937
|
$inverseProbability$: 1,
|
|
785
|
-
$createdTs$:
|
|
938
|
+
$createdTs$: performance.now(),
|
|
786
939
|
$waitedMs$: 0,
|
|
787
940
|
$loadedMs$: 0
|
|
788
941
|
};
|
|
@@ -851,9 +1004,16 @@ var shouldResetFactor;
|
|
|
851
1004
|
var queueDirty;
|
|
852
1005
|
var preloadCount = 0;
|
|
853
1006
|
var queue = [];
|
|
1007
|
+
var nextTriggerMacroTask = createMacroTask(trigger);
|
|
1008
|
+
var nextAdjustmentMacroTask = createMacroTask(processPendingAdjustments);
|
|
1009
|
+
var isTriggerScheduled = false;
|
|
1010
|
+
var isAdjustmentScheduled = false;
|
|
1011
|
+
var isProcessingAdjustments = false;
|
|
1012
|
+
var shouldYieldInBrowser = import.meta.env.TEST ? !isServerPlatform() : isBrowser3;
|
|
1013
|
+
var adjustmentStack = [];
|
|
854
1014
|
var log = (...args) => {
|
|
855
1015
|
console.log(
|
|
856
|
-
`Preloader ${
|
|
1016
|
+
`Preloader ${performance.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
|
|
857
1017
|
...args
|
|
858
1018
|
);
|
|
859
1019
|
};
|
|
@@ -863,6 +1023,10 @@ var resetQueue = () => {
|
|
|
863
1023
|
shouldResetFactor = true;
|
|
864
1024
|
preloadCount = 0;
|
|
865
1025
|
queue.length = 0;
|
|
1026
|
+
adjustmentStack.length = 0;
|
|
1027
|
+
isTriggerScheduled = false;
|
|
1028
|
+
isAdjustmentScheduled = false;
|
|
1029
|
+
isProcessingAdjustments = false;
|
|
866
1030
|
};
|
|
867
1031
|
var sortQueue = () => {
|
|
868
1032
|
if (queueDirty) {
|
|
@@ -874,7 +1038,8 @@ var getQueue = () => {
|
|
|
874
1038
|
sortQueue();
|
|
875
1039
|
let probability = 0.4;
|
|
876
1040
|
const result = [];
|
|
877
|
-
for (
|
|
1041
|
+
for (let i = 0; i < queue.length; i++) {
|
|
1042
|
+
const b = queue[i];
|
|
878
1043
|
const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
|
|
879
1044
|
if (nextProbability !== probability) {
|
|
880
1045
|
probability = nextProbability;
|
|
@@ -884,29 +1049,37 @@ var getQueue = () => {
|
|
|
884
1049
|
}
|
|
885
1050
|
return result;
|
|
886
1051
|
};
|
|
887
|
-
|
|
1052
|
+
function trigger() {
|
|
1053
|
+
isTriggerScheduled = false;
|
|
888
1054
|
if (!queue.length) {
|
|
889
1055
|
return;
|
|
890
1056
|
}
|
|
891
1057
|
sortQueue();
|
|
1058
|
+
const deadline = performance.now() + yieldInterval;
|
|
1059
|
+
let shouldYield = false;
|
|
892
1060
|
while (queue.length) {
|
|
893
1061
|
const bundle = queue[0];
|
|
894
1062
|
const inverseProbability = bundle.$inverseProbability$;
|
|
895
1063
|
const probability = 1 - inverseProbability;
|
|
896
|
-
const allowedPreloads = graph ? (
|
|
897
|
-
//
|
|
898
|
-
|
|
899
|
-
) : (
|
|
900
|
-
// While the graph is not available, we limit to 2 preloads
|
|
901
|
-
2
|
|
1064
|
+
const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
|
|
1065
|
+
// While the graph is not available, we limit to 5 preloads
|
|
1066
|
+
5
|
|
902
1067
|
);
|
|
903
1068
|
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
904
1069
|
queue.shift();
|
|
905
1070
|
preloadOne(bundle);
|
|
1071
|
+
if (performance.now() >= deadline) {
|
|
1072
|
+
shouldYield = true;
|
|
1073
|
+
break;
|
|
1074
|
+
}
|
|
906
1075
|
} else {
|
|
907
1076
|
break;
|
|
908
1077
|
}
|
|
909
1078
|
}
|
|
1079
|
+
if (shouldYield && queue.length && !isTriggerScheduled) {
|
|
1080
|
+
isTriggerScheduled = true;
|
|
1081
|
+
nextTriggerMacroTask();
|
|
1082
|
+
}
|
|
910
1083
|
if (config.$DEBUG$ && !queue.length) {
|
|
911
1084
|
const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
|
|
912
1085
|
const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
|
|
@@ -915,13 +1088,112 @@ var trigger = () => {
|
|
|
915
1088
|
`>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
|
|
916
1089
|
);
|
|
917
1090
|
}
|
|
1091
|
+
}
|
|
1092
|
+
var enqueueAdjustment = (bundle, inverseProbability, context, seen) => {
|
|
1093
|
+
adjustmentStack.unshift({
|
|
1094
|
+
$bundle$: bundle,
|
|
1095
|
+
$inverseProbability$: inverseProbability,
|
|
1096
|
+
$seen$: seen,
|
|
1097
|
+
$context$: context
|
|
1098
|
+
});
|
|
918
1099
|
};
|
|
1100
|
+
var processAdjustmentFrame = () => {
|
|
1101
|
+
const frame = adjustmentStack[adjustmentStack.length - 1];
|
|
1102
|
+
const bundle = frame.$bundle$;
|
|
1103
|
+
if (frame.$deps$) {
|
|
1104
|
+
const index = frame.$index$;
|
|
1105
|
+
if (index >= frame.$deps$.length) {
|
|
1106
|
+
adjustmentStack.pop();
|
|
1107
|
+
return false;
|
|
1108
|
+
}
|
|
1109
|
+
const dep = frame.$deps$[index];
|
|
1110
|
+
frame.$index$ = index + 1;
|
|
1111
|
+
const depBundle = getBundle(dep.$name$);
|
|
1112
|
+
if (depBundle.$inverseProbability$ === 0) {
|
|
1113
|
+
return true;
|
|
1114
|
+
}
|
|
1115
|
+
const probability = 1 - bundle.$inverseProbability$;
|
|
1116
|
+
let newInverseProbability;
|
|
1117
|
+
if (probability === 1 || probability >= 0.99 && frame.$context$.$depsCount$ < 100) {
|
|
1118
|
+
frame.$context$.$depsCount$++;
|
|
1119
|
+
newInverseProbability = Math.min(0.01, 1 - dep.$importProbability$);
|
|
1120
|
+
} else {
|
|
1121
|
+
const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
|
|
1122
|
+
const prevAdjust = dep.$factor$;
|
|
1123
|
+
const factor = newInverseImportProbability / prevAdjust;
|
|
1124
|
+
newInverseProbability = Math.max(0.02, depBundle.$inverseProbability$ * factor);
|
|
1125
|
+
dep.$factor$ = factor;
|
|
1126
|
+
}
|
|
1127
|
+
adjustmentStack.push({
|
|
1128
|
+
$bundle$: depBundle,
|
|
1129
|
+
$inverseProbability$: newInverseProbability,
|
|
1130
|
+
$seen$: frame.$seen$,
|
|
1131
|
+
$context$: frame.$context$
|
|
1132
|
+
});
|
|
1133
|
+
return true;
|
|
1134
|
+
}
|
|
1135
|
+
if (frame.$seen$?.has(bundle)) {
|
|
1136
|
+
adjustmentStack.pop();
|
|
1137
|
+
return false;
|
|
1138
|
+
}
|
|
1139
|
+
const previousInverseProbability = bundle.$inverseProbability$;
|
|
1140
|
+
bundle.$inverseProbability$ = frame.$inverseProbability$;
|
|
1141
|
+
if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
|
|
1142
|
+
adjustmentStack.pop();
|
|
1143
|
+
return false;
|
|
1144
|
+
}
|
|
1145
|
+
if (
|
|
1146
|
+
// don't queue until we have initialized the preloader
|
|
1147
|
+
base != null && bundle.$state$ < BundleImportState_Preload
|
|
1148
|
+
) {
|
|
1149
|
+
if (bundle.$state$ === BundleImportState_None) {
|
|
1150
|
+
bundle.$state$ = BundleImportState_Queued;
|
|
1151
|
+
queue.push(bundle);
|
|
1152
|
+
config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
|
|
1153
|
+
}
|
|
1154
|
+
queueDirty = true;
|
|
1155
|
+
}
|
|
1156
|
+
if (bundle.$deps$?.length) {
|
|
1157
|
+
const seen = frame.$seen$ || /* @__PURE__ */ new Set();
|
|
1158
|
+
seen.add(bundle);
|
|
1159
|
+
frame.$seen$ = seen;
|
|
1160
|
+
frame.$deps$ = bundle.$deps$;
|
|
1161
|
+
frame.$index$ = 0;
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
adjustmentStack.pop();
|
|
1165
|
+
return false;
|
|
1166
|
+
};
|
|
1167
|
+
function processPendingAdjustments() {
|
|
1168
|
+
if (isProcessingAdjustments || !adjustmentStack.length) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
isAdjustmentScheduled = false;
|
|
1172
|
+
isProcessingAdjustments = true;
|
|
1173
|
+
const deadline = shouldYieldInBrowser ? performance.now() + yieldInterval : 0;
|
|
1174
|
+
let processed = false;
|
|
1175
|
+
while (adjustmentStack.length) {
|
|
1176
|
+
processed = true;
|
|
1177
|
+
const checkDeadline = processAdjustmentFrame();
|
|
1178
|
+
if (shouldYieldInBrowser && checkDeadline && performance.now() >= deadline) {
|
|
1179
|
+
if (!isAdjustmentScheduled) {
|
|
1180
|
+
isAdjustmentScheduled = true;
|
|
1181
|
+
nextAdjustmentMacroTask();
|
|
1182
|
+
}
|
|
1183
|
+
break;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
isProcessingAdjustments = false;
|
|
1187
|
+
if (processed && shouldYieldInBrowser) {
|
|
1188
|
+
nextTriggerMacroTask();
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
919
1191
|
var preloadOne = (bundle) => {
|
|
920
1192
|
if (bundle.$state$ >= BundleImportState_Preload) {
|
|
921
1193
|
return;
|
|
922
1194
|
}
|
|
923
1195
|
preloadCount++;
|
|
924
|
-
const start =
|
|
1196
|
+
const start = performance.now();
|
|
925
1197
|
bundle.$waitedMs$ = start - bundle.$createdTs$;
|
|
926
1198
|
bundle.$state$ = BundleImportState_Preload;
|
|
927
1199
|
config.$DEBUG$ && log(
|
|
@@ -934,116 +1206,123 @@ var preloadOne = (bundle) => {
|
|
|
934
1206
|
link.as = "script";
|
|
935
1207
|
link.onload = link.onerror = () => {
|
|
936
1208
|
preloadCount--;
|
|
937
|
-
const end =
|
|
1209
|
+
const end = performance.now();
|
|
938
1210
|
bundle.$loadedMs$ = end - start;
|
|
939
1211
|
bundle.$state$ = BundleImportState_Loaded;
|
|
940
1212
|
config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
|
|
941
|
-
link.remove();
|
|
942
|
-
|
|
943
|
-
};
|
|
944
|
-
doc.head.appendChild(link);
|
|
945
|
-
};
|
|
946
|
-
var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
if (
|
|
956
|
-
// don't queue until we have initialized the preloader
|
|
957
|
-
base != null && bundle.$state$ < BundleImportState_Preload && bundle.$inverseProbability$ < config.$invPreloadProbability$
|
|
958
|
-
) {
|
|
959
|
-
if (bundle.$state$ === BundleImportState_None) {
|
|
960
|
-
bundle.$state$ = BundleImportState_Queued;
|
|
961
|
-
queue.push(bundle);
|
|
962
|
-
config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
|
|
963
|
-
}
|
|
964
|
-
queueDirty = true;
|
|
965
|
-
}
|
|
966
|
-
if (bundle.$deps$) {
|
|
967
|
-
seen || (seen = /* @__PURE__ */ new Set());
|
|
968
|
-
seen.add(bundle);
|
|
969
|
-
const probability = 1 - bundle.$inverseProbability$;
|
|
970
|
-
for (const dep of bundle.$deps$) {
|
|
971
|
-
const depBundle = getBundle(dep.$name$);
|
|
972
|
-
if (depBundle.$inverseProbability$ === 0) {
|
|
973
|
-
continue;
|
|
974
|
-
}
|
|
975
|
-
let newInverseProbability2;
|
|
976
|
-
if (dep.$importProbability$ > 0.5 && (probability === 1 || probability >= 0.99 && depsCount < 100)) {
|
|
977
|
-
depsCount++;
|
|
978
|
-
newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
|
|
979
|
-
} else {
|
|
980
|
-
const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
|
|
981
|
-
const prevAdjust = dep.$factor$;
|
|
982
|
-
const factor = newInverseImportProbability / prevAdjust;
|
|
983
|
-
newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
|
|
984
|
-
dep.$factor$ = factor;
|
|
985
|
-
}
|
|
986
|
-
adjustProbabilities(depBundle, newInverseProbability2, seen);
|
|
987
|
-
}
|
|
1213
|
+
link.remove();
|
|
1214
|
+
nextTriggerMacroTask();
|
|
1215
|
+
};
|
|
1216
|
+
doc.head.appendChild(link);
|
|
1217
|
+
};
|
|
1218
|
+
var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
1219
|
+
enqueueAdjustment(bundle, newInverseProbability, { $depsCount$: 0 }, seen);
|
|
1220
|
+
if (shouldYieldInBrowser) {
|
|
1221
|
+
nextAdjustmentMacroTask();
|
|
1222
|
+
} else {
|
|
1223
|
+
processPendingAdjustments();
|
|
988
1224
|
}
|
|
989
1225
|
};
|
|
990
|
-
var handleBundle = (name, inverseProbability) => {
|
|
1226
|
+
var handleBundle = (name, inverseProbability, context) => {
|
|
991
1227
|
const bundle = getBundle(name);
|
|
992
1228
|
if (bundle && bundle.$inverseProbability$ > inverseProbability) {
|
|
993
|
-
|
|
1229
|
+
if (context) {
|
|
1230
|
+
enqueueAdjustment(bundle, inverseProbability, context);
|
|
1231
|
+
} else {
|
|
1232
|
+
adjustProbabilities(bundle, inverseProbability);
|
|
1233
|
+
}
|
|
994
1234
|
}
|
|
995
1235
|
};
|
|
996
|
-
var depsCount;
|
|
997
1236
|
var preload = (name, probability) => {
|
|
998
1237
|
if (!name?.length) {
|
|
999
1238
|
return;
|
|
1000
1239
|
}
|
|
1001
|
-
depsCount = 0;
|
|
1002
1240
|
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1241
|
+
const context = { $depsCount$: 0 };
|
|
1003
1242
|
if (Array.isArray(name)) {
|
|
1004
1243
|
for (let i = name.length - 1; i >= 0; i--) {
|
|
1005
1244
|
const item = name[i];
|
|
1006
1245
|
if (typeof item === "number") {
|
|
1007
1246
|
inverseProbability = 1 - item / 10;
|
|
1008
1247
|
} else {
|
|
1009
|
-
handleBundle(item, inverseProbability);
|
|
1248
|
+
handleBundle(item, inverseProbability, context);
|
|
1010
1249
|
}
|
|
1011
1250
|
}
|
|
1012
1251
|
} else {
|
|
1013
|
-
handleBundle(name, inverseProbability);
|
|
1252
|
+
handleBundle(name, inverseProbability, context);
|
|
1014
1253
|
}
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1254
|
+
if (shouldYieldInBrowser) {
|
|
1255
|
+
nextAdjustmentMacroTask();
|
|
1256
|
+
} else {
|
|
1257
|
+
processPendingAdjustments();
|
|
1017
1258
|
}
|
|
1018
1259
|
};
|
|
1019
|
-
if (isBrowser3) {
|
|
1260
|
+
if (import.meta.env.TEST ? !isServerPlatform() : isBrowser3) {
|
|
1020
1261
|
document.addEventListener("qsymbol", (ev) => {
|
|
1021
1262
|
const { symbol, href } = ev.detail;
|
|
1022
1263
|
if (href) {
|
|
1023
|
-
const
|
|
1024
|
-
preload(
|
|
1264
|
+
const hash = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1265
|
+
preload(hash, 1);
|
|
1025
1266
|
}
|
|
1026
1267
|
});
|
|
1027
1268
|
}
|
|
1028
1269
|
|
|
1270
|
+
// packages/qwik/src/core/shared/utils/objects.ts
|
|
1271
|
+
var isObjectEmpty = (obj) => {
|
|
1272
|
+
for (const key in obj) {
|
|
1273
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1274
|
+
return false;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
return true;
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1280
|
+
// packages/qwik/src/core/shared/ssr-const.ts
|
|
1281
|
+
var LT = "<";
|
|
1282
|
+
var GT = ">";
|
|
1283
|
+
var CLOSE_TAG = "</";
|
|
1284
|
+
var SPACE = " ";
|
|
1285
|
+
var ATTR_EQUALS_QUOTE = '="';
|
|
1286
|
+
var QUOTE = '"';
|
|
1287
|
+
var EMPTY_ATTR = '=""';
|
|
1288
|
+
var BRACKET_OPEN = "[";
|
|
1289
|
+
var BRACKET_CLOSE = "]";
|
|
1290
|
+
var PAREN_CLOSE = ")";
|
|
1291
|
+
var COMMA = ",";
|
|
1292
|
+
|
|
1029
1293
|
// packages/qwik/src/server/platform.ts
|
|
1030
|
-
|
|
1294
|
+
var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
|
|
1295
|
+
const existing = mapper?.[hash];
|
|
1296
|
+
if (existing) {
|
|
1297
|
+
return existing;
|
|
1298
|
+
}
|
|
1299
|
+
if (symbolName === SYNC_QRL) {
|
|
1300
|
+
return [symbolName, ""];
|
|
1301
|
+
}
|
|
1302
|
+
if (!parent) {
|
|
1303
|
+
if (symbolName.startsWith("_") && symbolName.length < 6) {
|
|
1304
|
+
return [symbolName, `${import.meta.env.BASE_URL}@qwik-handlers`];
|
|
1305
|
+
}
|
|
1306
|
+
console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
|
|
1307
|
+
return [symbolName, `${import.meta.env.BASE_URL}${symbolName}.js`];
|
|
1308
|
+
}
|
|
1309
|
+
const qrlFile = `${import.meta.env.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
|
|
1310
|
+
return [symbolName, qrlFile];
|
|
1311
|
+
};
|
|
1312
|
+
function createPlatform2(opts, resolvedManifest) {
|
|
1031
1313
|
const mapper = resolvedManifest?.mapper;
|
|
1032
1314
|
const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
|
|
1033
|
-
if (mapper) {
|
|
1034
|
-
const
|
|
1035
|
-
const result = mapper[
|
|
1315
|
+
if (mapper || isDev5 && import.meta.env.MODE !== "test") {
|
|
1316
|
+
const hash = getSymbolHash2(symbolName);
|
|
1317
|
+
const result = !isDev5 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
|
|
1036
1318
|
if (!result) {
|
|
1037
|
-
if (
|
|
1038
|
-
return [
|
|
1319
|
+
if (hash === SYNC_QRL) {
|
|
1320
|
+
return [hash, ""];
|
|
1039
1321
|
}
|
|
1040
|
-
const isRegistered = globalThis.__qwik_reg_symbols?.has(
|
|
1322
|
+
const isRegistered = globalThis.__qwik_reg_symbols?.has(hash);
|
|
1041
1323
|
if (isRegistered) {
|
|
1042
1324
|
return [symbolName, "_"];
|
|
1043
1325
|
}
|
|
1044
|
-
if (parent) {
|
|
1045
|
-
return [symbolName, `${parent}?qrl=${symbolName}`];
|
|
1046
|
-
}
|
|
1047
1326
|
console.error("Cannot resolve symbol", symbolName, "in", mapper, parent);
|
|
1048
1327
|
}
|
|
1049
1328
|
return result;
|
|
@@ -1052,32 +1331,17 @@ function createPlatform(opts, resolvedManifest) {
|
|
|
1052
1331
|
const serverPlatform = {
|
|
1053
1332
|
isServer: true,
|
|
1054
1333
|
async importSymbol(_containerEl, url, symbolName) {
|
|
1055
|
-
const
|
|
1056
|
-
const regSym = globalThis.__qwik_reg_symbols?.get(
|
|
1334
|
+
const hash = getSymbolHash2(symbolName);
|
|
1335
|
+
const regSym = globalThis.__qwik_reg_symbols?.get(hash);
|
|
1057
1336
|
if (regSym) {
|
|
1058
1337
|
return regSym;
|
|
1059
1338
|
}
|
|
1060
|
-
|
|
1061
|
-
if (!modulePath.endsWith(".js")) {
|
|
1062
|
-
modulePath += ".js";
|
|
1063
|
-
}
|
|
1064
|
-
const module = __require(modulePath);
|
|
1065
|
-
if (!(symbolName in module)) {
|
|
1066
|
-
throw new Error(`Q-ERROR: missing symbol '${symbolName}' in module '${modulePath}'.`);
|
|
1067
|
-
}
|
|
1068
|
-
return module[symbolName];
|
|
1339
|
+
throw qError(6 /* dynamicImportFailed */, [symbolName]);
|
|
1069
1340
|
},
|
|
1070
1341
|
raf: () => {
|
|
1071
1342
|
console.error("server can not rerender");
|
|
1072
1343
|
return Promise.resolve();
|
|
1073
1344
|
},
|
|
1074
|
-
nextTick: (fn) => {
|
|
1075
|
-
return new Promise((resolve) => {
|
|
1076
|
-
setTimeout(() => {
|
|
1077
|
-
resolve(fn());
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
},
|
|
1081
1345
|
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1082
1346
|
return mapperFn(symbolName, mapper, parent);
|
|
1083
1347
|
}
|
|
@@ -1085,10 +1349,10 @@ function createPlatform(opts, resolvedManifest) {
|
|
|
1085
1349
|
return serverPlatform;
|
|
1086
1350
|
}
|
|
1087
1351
|
async function setServerPlatform(opts, manifest) {
|
|
1088
|
-
const platform =
|
|
1352
|
+
const platform = createPlatform2(opts, manifest);
|
|
1089
1353
|
setPlatform(platform);
|
|
1090
1354
|
}
|
|
1091
|
-
var
|
|
1355
|
+
var getSymbolHash2 = (symbolName) => {
|
|
1092
1356
|
const index = symbolName.lastIndexOf("_");
|
|
1093
1357
|
if (index > -1) {
|
|
1094
1358
|
return symbolName.slice(index + 1);
|
|
@@ -1122,24 +1386,317 @@ function getBuildBase(opts) {
|
|
|
1122
1386
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1123
1387
|
}
|
|
1124
1388
|
var versions = {
|
|
1125
|
-
qwik: "2.0.0-beta.
|
|
1389
|
+
qwik: "2.0.0-beta.31-dev+906321a",
|
|
1126
1390
|
qwikDom: "2.1.19"
|
|
1127
1391
|
};
|
|
1128
1392
|
|
|
1129
1393
|
// packages/qwik/src/server/ssr-container.ts
|
|
1394
|
+
import { isDev as isDev7 } from "@qwik.dev/core/build";
|
|
1130
1395
|
import {
|
|
1131
1396
|
_SubscriptionData as SubscriptionData,
|
|
1132
1397
|
_SharedContainer,
|
|
1133
1398
|
_jsxSorted,
|
|
1134
1399
|
_jsxSplit,
|
|
1400
|
+
_res,
|
|
1401
|
+
_setEvent,
|
|
1135
1402
|
_walkJSX,
|
|
1403
|
+
_createQRL as createQRL,
|
|
1136
1404
|
isSignal
|
|
1137
|
-
} from "@qwik.dev/core";
|
|
1138
|
-
|
|
1405
|
+
} from "@qwik.dev/core/internal";
|
|
1406
|
+
|
|
1407
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1408
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1409
|
+
|
|
1410
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1411
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1412
|
+
const urls = [];
|
|
1413
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1414
|
+
if (prefetchResources2) {
|
|
1415
|
+
for (let i = 0; i < prefetchResources2.length; i++) {
|
|
1416
|
+
const prefetchResource = prefetchResources2[i];
|
|
1417
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1418
|
+
urls.push(prefetchResource.url);
|
|
1419
|
+
if (prefetchResource.imports) {
|
|
1420
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
addPrefetchResource(prefetchResources);
|
|
1427
|
+
return urls;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1431
|
+
var getBundles = (qrls) => {
|
|
1432
|
+
const platform = getPlatform();
|
|
1433
|
+
const bundles2 = qrls?.map((qrl) => {
|
|
1434
|
+
const symbol = qrl.$symbol$;
|
|
1435
|
+
const chunk = qrl.$chunk$;
|
|
1436
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1437
|
+
if (result) {
|
|
1438
|
+
return result[1];
|
|
1439
|
+
}
|
|
1440
|
+
return chunk;
|
|
1441
|
+
}).filter(Boolean);
|
|
1442
|
+
return [...new Set(bundles2)];
|
|
1443
|
+
};
|
|
1444
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1445
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1446
|
+
if (prefetchStrategy === null) {
|
|
1447
|
+
return [];
|
|
1448
|
+
}
|
|
1449
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1450
|
+
return getBundles(qrls);
|
|
1451
|
+
}
|
|
1452
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1453
|
+
try {
|
|
1454
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1455
|
+
manifest: resolvedManifest.manifest
|
|
1456
|
+
});
|
|
1457
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1458
|
+
} catch (e) {
|
|
1459
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1463
|
+
for (let i = 0; i < qrls.length; i++) {
|
|
1464
|
+
const symbol = getSymbolHash2(qrls[i].$symbol$);
|
|
1465
|
+
if (symbol && symbol.length >= 10) {
|
|
1466
|
+
symbols.add(symbol);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
return [...symbols];
|
|
1470
|
+
}
|
|
1471
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1472
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1473
|
+
return [...new Set(names)];
|
|
1474
|
+
}
|
|
1475
|
+
resetQueue();
|
|
1476
|
+
let probability = 0.99;
|
|
1477
|
+
for (let i = 0; i < names.length; i++) {
|
|
1478
|
+
preload(names[i], probability);
|
|
1479
|
+
probability *= 0.95;
|
|
1480
|
+
}
|
|
1481
|
+
return getQueue();
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1485
|
+
var simplifyPath = (base2, path) => {
|
|
1486
|
+
if (path == null) {
|
|
1487
|
+
return null;
|
|
1488
|
+
}
|
|
1489
|
+
const segments = `${base2}${path}`.split("/");
|
|
1490
|
+
const simplified = [];
|
|
1491
|
+
for (let i = 0; i < segments.length; i++) {
|
|
1492
|
+
const segment = segments[i];
|
|
1493
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1494
|
+
simplified.pop();
|
|
1495
|
+
} else {
|
|
1496
|
+
simplified.push(segment);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
return simplified.join("/");
|
|
1500
|
+
};
|
|
1501
|
+
var getBase = (container) => {
|
|
1502
|
+
let base2 = container.$buildBase$;
|
|
1503
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1504
|
+
base2 = import.meta.env.BASE_URL;
|
|
1505
|
+
}
|
|
1506
|
+
return base2;
|
|
1507
|
+
};
|
|
1508
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1509
|
+
const { resolvedManifest } = container;
|
|
1510
|
+
const base2 = getBase(container);
|
|
1511
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1512
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1513
|
+
if (bundleGraphPath) {
|
|
1514
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1515
|
+
}
|
|
1516
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1517
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1518
|
+
debug: options.debug,
|
|
1519
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1520
|
+
} : void 0;
|
|
1521
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1522
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1523
|
+
const opts = [];
|
|
1524
|
+
if (options) {
|
|
1525
|
+
if (options.debug) {
|
|
1526
|
+
opts.push("d:1");
|
|
1527
|
+
}
|
|
1528
|
+
if (options.maxIdlePreloads) {
|
|
1529
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1530
|
+
}
|
|
1531
|
+
if (options.preloadProbability) {
|
|
1532
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1536
|
+
const preloaderLinkAttrs = {
|
|
1537
|
+
rel: "modulepreload",
|
|
1538
|
+
href: preloaderBundle
|
|
1539
|
+
};
|
|
1540
|
+
if (nonce) {
|
|
1541
|
+
preloaderLinkAttrs["nonce"] = nonce;
|
|
1542
|
+
}
|
|
1543
|
+
container.openElement("link", null, preloaderLinkAttrs, null, null, null);
|
|
1544
|
+
container.closeElement();
|
|
1545
|
+
container.openElement(
|
|
1546
|
+
"link",
|
|
1547
|
+
null,
|
|
1548
|
+
{ rel: "preload", href: bundleGraphPath, as: "fetch", crossorigin: "anonymous" },
|
|
1549
|
+
null,
|
|
1550
|
+
null,
|
|
1551
|
+
null
|
|
1552
|
+
);
|
|
1553
|
+
container.closeElement();
|
|
1554
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1555
|
+
const scriptAttrs = {
|
|
1556
|
+
type: "module",
|
|
1557
|
+
async: true,
|
|
1558
|
+
crossorigin: "anonymous"
|
|
1559
|
+
};
|
|
1560
|
+
if (nonce) {
|
|
1561
|
+
scriptAttrs["nonce"] = nonce;
|
|
1562
|
+
}
|
|
1563
|
+
container.openElement("script", null, scriptAttrs, null, null, null);
|
|
1564
|
+
container.write(script);
|
|
1565
|
+
container.closeElement();
|
|
1566
|
+
}
|
|
1567
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1568
|
+
if (corePath) {
|
|
1569
|
+
const linkAttrs = { rel: "modulepreload", href: corePath };
|
|
1570
|
+
if (nonce) {
|
|
1571
|
+
linkAttrs["nonce"] = nonce;
|
|
1572
|
+
}
|
|
1573
|
+
container.openElement("link", null, linkAttrs, null, null, null);
|
|
1574
|
+
container.closeElement();
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1578
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1579
|
+
return null;
|
|
1580
|
+
}
|
|
1581
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1582
|
+
typeof options === "boolean" ? void 0 : options
|
|
1583
|
+
);
|
|
1584
|
+
let allowed = ssrPreloads;
|
|
1585
|
+
const base2 = getBase(container);
|
|
1586
|
+
const links = [];
|
|
1587
|
+
const { resolvedManifest } = container;
|
|
1588
|
+
if (allowed) {
|
|
1589
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1590
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1591
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1592
|
+
let probability = 4;
|
|
1593
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1594
|
+
for (let i = 0; i < expandedBundles.length; i++) {
|
|
1595
|
+
const hrefOrProbability = expandedBundles[i];
|
|
1596
|
+
if (typeof hrefOrProbability === "string") {
|
|
1597
|
+
if (probability < tenXMinProbability) {
|
|
1598
|
+
break;
|
|
1599
|
+
}
|
|
1600
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1601
|
+
continue;
|
|
1602
|
+
}
|
|
1603
|
+
links.push(hrefOrProbability);
|
|
1604
|
+
if (--allowed === 0) {
|
|
1605
|
+
break;
|
|
1606
|
+
}
|
|
1607
|
+
} else {
|
|
1608
|
+
probability = hrefOrProbability;
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1613
|
+
const insertLinks = links.length ? (
|
|
1614
|
+
/**
|
|
1615
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1616
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1617
|
+
* links.
|
|
1618
|
+
*/
|
|
1619
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1620
|
+
) : "";
|
|
1621
|
+
let script = insertLinks;
|
|
1622
|
+
if (preloaderBundle) {
|
|
1623
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1624
|
+
}
|
|
1625
|
+
if (script) {
|
|
1626
|
+
const attrs = { type: "module", async: "true", "q:type": "preload" };
|
|
1627
|
+
if (nonce) {
|
|
1628
|
+
attrs["nonce"] = nonce;
|
|
1629
|
+
}
|
|
1630
|
+
container.openElement("script", null, attrs, null, null, null);
|
|
1631
|
+
container.write(script);
|
|
1632
|
+
container.closeElement();
|
|
1633
|
+
}
|
|
1634
|
+
return null;
|
|
1635
|
+
};
|
|
1636
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1637
|
+
if (opts.preloader !== false) {
|
|
1638
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1639
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1640
|
+
if (preloadBundles.length > 0) {
|
|
1641
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
function normalizePreLoaderOptions(input) {
|
|
1646
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1647
|
+
}
|
|
1648
|
+
var preLoaderOptionsDefault = {
|
|
1649
|
+
ssrPreloads: 7,
|
|
1650
|
+
ssrPreloadProbability: 0.5,
|
|
1651
|
+
debug: false,
|
|
1652
|
+
maxIdlePreloads: 25,
|
|
1653
|
+
preloadProbability: 0.35
|
|
1654
|
+
// deprecated
|
|
1655
|
+
};
|
|
1139
1656
|
|
|
1140
1657
|
// packages/qwik/src/server/scripts.ts
|
|
1141
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = 'const
|
|
1142
|
-
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n
|
|
1658
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,n="w",o="d",r=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(n=>t.push(...l(n,e))),t},d=(e,t,n,o=!1)=>e.addEventListener(t,n,{capture:o,passive:!1}),b=e=>{_(e);const t=l(e,"[q\\\\:shadowroot]");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&b(n)}},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){t._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,n)=>{e.dispatchEvent(u(t,n))},g=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),m=e=>e.replace(/-./g,e=>e[1].toUpperCase()),v=e=>({scope:e.charAt(0),eventName:m(e.slice(2))}),w=async(t,n,o,r)=>{r&&(t.hasAttribute("preventdefault:"+r)&&n.preventDefault(),t.hasAttribute("stoppropagation:"+r)&&n.stopPropagation());const s=t._qDispatch?.[o];if(s){if("function"==typeof s){const e=s(n,t);f(e)&&await e}else if(s.length)for(let e=0;e<s.length;e++){const o=s[e],r=o?.(n,t);f(r)&&await r}return}const a=t.getAttribute("q-"+o);if(a){const o=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=o.getAttribute("q:base"),s=new URL(r,e.baseURI),c=a.split("|");for(let a=0;a<c.length;a++){const l=c[a],q=performance.now(),[d,b,u]=l.split("#"),g={qBase:r,symbol:b,element:t,reqTime:q};let m,v,w;if(""===d){const t=o.getAttribute("q:instance");m=(e["qFuncs_"+t]||[])[Number.parseInt(b)],m||(v="sync",w=Error("sym:"+b))}else{const e=`${b}|${r}|${d}`;if(m=i.get(e),!m){const t=new URL(d,s).href;try{const n=import(t);p(o),m=(await n)[b],m?(i.set(e,m),h("qsymbol",g)):(v="no-symbol",w=Error(`${b} not in ${t}`))}catch(e){v="async",w=e}}}if(m){if(t.isConnected)try{const e=m.call(u,n,t);f(e)&&await e}catch(e){h("qerror",{error:e,...g})}}else h("qerror",{importError:v,error:w,...g}),console.error(w)}}},y=async e=>{const t=g(e.type),n="e:"+t;let o=e.target;for(;o&&o.getAttribute;){const r=w(o,e,n,t),s=e.bubbles&&!e.cancelBubble;f(r)&&await r,o=s&&e.bubbles&&!e.cancelBubble?o.parentElement:null}},A=(e,t)=>{const n=g(t.type),o=e+":"+n,r=q("[q-"+e+"\\\\:"+n+"]");for(let e=0;e<r.length;e++){const s=r[e];w(s,t,o,n)}},E=async e=>{A(o,e)},C=e=>{A(n,e)},k=()=>{const n=e.readyState;if("interactive"==n||"complete"==n){if(c=1,s.forEach(b),r.has("d:qinit")){r.delete("d:qinit");const e=u("qinit"),t=q("[q-d\\\\:qinit]");for(let n=0;n<t.length;n++){const o=t[n];w(o,e,"d:qinit"),o.removeAttribute("q-d:qinit")}}if(r.has("d:qidle")&&(r.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle"),t=q("[q-d\\\\:qidle]");for(let n=0;n<t.length;n++){const o=t[n];w(o,e,"d:qidle"),o.removeAttribute("q-d:qidle")}})),r.has("e:qvisible")){a||(a=new IntersectionObserver(e=>{for(let t=0;t<e.length;t++){const n=e[t];n.isIntersecting&&(a.unobserve(n.target),w(n.target,u("qvisible",n),"e:qvisible"))}}));const e=q("[q-e\\\\:qvisible]:not([q\\\\:observed])");for(let t=0;t<e.length;t++){const n=e[t];a.observe(n),n.setAttribute("q:observed","true")}}}},_=(...e)=>{for(let i=0;i<e.length;i++){const a=e[i];if("string"==typeof a){if(!r.has(a)){r.add(a);const{scope:e,eventName:i}=v(a);e===n?d(t,i,C,!0):s.forEach(t=>d(t,i,e===o?E:y,!0)),1!==c||"e:qvisible"!==a&&"d:qinit"!==a&&"d:qidle"!==a||k()}}else s.has(a)||(r.forEach(e=>{const{scope:t,eventName:r}=v(e);t!==n&&d(a,r,t===o?E:y,!0)}),s.add(a))}},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:r,roots:s,push:_},d(e,"readystatechange",k),k())';
|
|
1659
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n const shadowRoots = nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]");\n for (let i = 0; i < shadowRoots.length; i++) {\n const parent = shadowRoots[i];\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (typeof handlers === "function") {\n const result = handlers(ev, element);\n if (isPromise(result)) {\n await result;\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const base = new URL(qBase, doc.baseURI);\n const qrls = attrValue.split("|");\n for (let i = 0; i < qrls.length; i++) {\n const qrl = qrls[i];\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n const elements = querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, kebabName);\n }\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n const elements = querySelectorAll("[q-d\\\\:qinit]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n }\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n const elements = querySelectorAll("[q-d\\\\:qidle]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n }\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\n }));\n const elements = querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n }\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (let i = 0; i < eventNames.length; i++) {\n const eventNameOrRoot = eventNames[i];\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1660
|
+
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]',e=document.currentScript;if(e){const o=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const e=o.querySelector(t);if(e){const t=JSON.parse(e.textContent||"[]"),n=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let r=n.currentNode,c=r.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let s=t[e+2];for(;c<o&&(r=n.nextNode(),r);)r.hasAttribute(":")&&c++;const l=r;null==s||!1===s?l.removeAttribute(i):("boolean"==typeof s&&(s=""),l.setAttribute(i,s))}}}}`;
|
|
1661
|
+
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1662
|
+
const executorScript = document.currentScript;
|
|
1663
|
+
if (executorScript) {
|
|
1664
|
+
const container = executorScript.closest(
|
|
1665
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1666
|
+
);
|
|
1667
|
+
if (container) {
|
|
1668
|
+
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1669
|
+
if (script) {
|
|
1670
|
+
const data = JSON.parse(script.textContent || "[]");
|
|
1671
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1672
|
+
let currentNode = walker.currentNode;
|
|
1673
|
+
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1674
|
+
for (let i = 0; i < data.length; i += 3) {
|
|
1675
|
+
const elementIdx = data[i];
|
|
1676
|
+
const attrName = data[i + 1];
|
|
1677
|
+
let value = data[i + 2];
|
|
1678
|
+
while (currentNodeIdx < elementIdx) {
|
|
1679
|
+
currentNode = walker.nextNode();
|
|
1680
|
+
if (!currentNode) {
|
|
1681
|
+
break;
|
|
1682
|
+
}
|
|
1683
|
+
if (currentNode.hasAttribute(":")) {
|
|
1684
|
+
currentNodeIdx++;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
const element = currentNode;
|
|
1688
|
+
if (value == null || value === false) {
|
|
1689
|
+
element.removeAttribute(attrName);
|
|
1690
|
+
} else {
|
|
1691
|
+
if (typeof value === "boolean") {
|
|
1692
|
+
value = "";
|
|
1693
|
+
}
|
|
1694
|
+
element.setAttribute(attrName, value);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}`;
|
|
1143
1700
|
function getQwikLoaderScript(opts = {}) {
|
|
1144
1701
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1145
1702
|
}
|
|
@@ -1148,50 +1705,56 @@ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
|
1148
1705
|
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1149
1706
|
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1150
1707
|
}
|
|
1708
|
+
function getQwikBackpatchExecutorScript(opts = {}) {
|
|
1709
|
+
return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
|
|
1710
|
+
}
|
|
1151
1711
|
|
|
1152
1712
|
// packages/qwik/src/server/ssr-node.ts
|
|
1153
1713
|
import {
|
|
1154
1714
|
_isJSXNode as isJSXNode,
|
|
1155
|
-
|
|
1715
|
+
_EMPTY_OBJ,
|
|
1156
1716
|
_EFFECT_BACK_REF
|
|
1157
|
-
} from "@qwik.dev/core";
|
|
1158
|
-
import { isDev as
|
|
1717
|
+
} from "@qwik.dev/core/internal";
|
|
1718
|
+
import { isDev as isDev6 } from "@qwik.dev/core/build";
|
|
1159
1719
|
var SsrNode = class {
|
|
1160
|
-
constructor(
|
|
1720
|
+
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1721
|
+
this.parentComponent = parentComponent;
|
|
1161
1722
|
this.attributesIndex = attributesIndex;
|
|
1162
1723
|
this.cleanupQueue = cleanupQueue;
|
|
1163
1724
|
this.vnodeData = vnodeData;
|
|
1164
|
-
|
|
1165
|
-
/**
|
|
1166
|
-
* ID which the deserialize will use to retrieve the node.
|
|
1167
|
-
*
|
|
1168
|
-
* @param id - Unique id for the node.
|
|
1169
|
-
*/
|
|
1170
|
-
__publicField(this, "id");
|
|
1171
|
-
__publicField(this, "parentSsrNode");
|
|
1172
|
-
__publicField(this, "children", null);
|
|
1173
|
-
__publicField(this, "attrs");
|
|
1174
|
-
/** Local props which don't serialize; */
|
|
1175
|
-
__publicField(this, "localProps", null);
|
|
1176
|
-
this.parentSsrNode = parentSsrNode;
|
|
1177
|
-
this.parentSsrNode?.addChild(this);
|
|
1725
|
+
this.currentFile = currentFile;
|
|
1178
1726
|
this.id = id;
|
|
1179
|
-
this.
|
|
1180
|
-
|
|
1727
|
+
this.flags = 1 /* Updatable */;
|
|
1728
|
+
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
|
|
1729
|
+
this.parentComponent?.addChild(this);
|
|
1730
|
+
if (isDev6 && id.indexOf("undefined") != -1) {
|
|
1181
1731
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1182
1732
|
}
|
|
1183
1733
|
}
|
|
1734
|
+
__brand__ = "SsrNode";
|
|
1735
|
+
/**
|
|
1736
|
+
* ID which the deserialize will use to retrieve the node.
|
|
1737
|
+
*
|
|
1738
|
+
* @param id - Unique id for the node.
|
|
1739
|
+
*/
|
|
1740
|
+
id;
|
|
1741
|
+
flags;
|
|
1742
|
+
dirty = 0 /* NONE */;
|
|
1743
|
+
children = null;
|
|
1744
|
+
attrs;
|
|
1745
|
+
/** Local props which don't serialize; */
|
|
1746
|
+
localProps = null;
|
|
1184
1747
|
get [_EFFECT_BACK_REF]() {
|
|
1185
1748
|
return this.getProp(QBackRefs);
|
|
1186
1749
|
}
|
|
1187
1750
|
setProp(name, value) {
|
|
1188
|
-
if (this.attrs ===
|
|
1751
|
+
if (this.attrs === _EMPTY_OBJ) {
|
|
1189
1752
|
this.setEmptyArrayAsVNodeDataAttributes();
|
|
1190
1753
|
}
|
|
1191
1754
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1192
|
-
|
|
1755
|
+
(this.localProps ||= {})[name] = value;
|
|
1193
1756
|
} else {
|
|
1194
|
-
|
|
1757
|
+
this.attrs[name] = value;
|
|
1195
1758
|
}
|
|
1196
1759
|
if (name == ELEMENT_SEQ && value) {
|
|
1197
1760
|
this.cleanupQueue.push(value);
|
|
@@ -1199,29 +1762,29 @@ var SsrNode = class {
|
|
|
1199
1762
|
}
|
|
1200
1763
|
setEmptyArrayAsVNodeDataAttributes() {
|
|
1201
1764
|
if (this.attributesIndex >= 0) {
|
|
1202
|
-
this.vnodeData[this.attributesIndex] =
|
|
1765
|
+
this.vnodeData[this.attributesIndex] = {};
|
|
1203
1766
|
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1204
1767
|
} else {
|
|
1205
1768
|
const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
|
|
1206
|
-
this.vnodeData.splice(newAttributesIndex, 0,
|
|
1769
|
+
this.vnodeData.splice(newAttributesIndex, 0, {});
|
|
1207
1770
|
this.attributesIndex = newAttributesIndex;
|
|
1208
1771
|
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1209
1772
|
}
|
|
1210
1773
|
}
|
|
1211
1774
|
getProp(name) {
|
|
1212
1775
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1213
|
-
return this.localProps ?
|
|
1776
|
+
return this.localProps ? this.localProps[name] ?? null : null;
|
|
1214
1777
|
} else {
|
|
1215
|
-
return
|
|
1778
|
+
return this.attrs[name] ?? null;
|
|
1216
1779
|
}
|
|
1217
1780
|
}
|
|
1218
1781
|
removeProp(name) {
|
|
1219
1782
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1220
1783
|
if (this.localProps) {
|
|
1221
|
-
|
|
1784
|
+
delete this.localProps[name];
|
|
1222
1785
|
}
|
|
1223
1786
|
} else {
|
|
1224
|
-
|
|
1787
|
+
delete this.attrs[name];
|
|
1225
1788
|
}
|
|
1226
1789
|
}
|
|
1227
1790
|
addChild(child) {
|
|
@@ -1230,35 +1793,47 @@ var SsrNode = class {
|
|
|
1230
1793
|
}
|
|
1231
1794
|
this.children.push(child);
|
|
1232
1795
|
}
|
|
1796
|
+
setTreeNonUpdatable() {
|
|
1797
|
+
if (this.flags & 1 /* Updatable */) {
|
|
1798
|
+
this.flags &= ~1 /* Updatable */;
|
|
1799
|
+
if (this.children) {
|
|
1800
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
1801
|
+
const child = this.children[i];
|
|
1802
|
+
child.setTreeNonUpdatable();
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1233
1807
|
toString() {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
const key
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
if (i < this.attrs.length - 2) {
|
|
1808
|
+
if (isDev6) {
|
|
1809
|
+
let stringifiedAttrs = "";
|
|
1810
|
+
for (const key in this.attrs) {
|
|
1811
|
+
const value = this.attrs[key];
|
|
1812
|
+
stringifiedAttrs += `${key}=`;
|
|
1813
|
+
stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
|
|
1241
1814
|
stringifiedAttrs += ", ";
|
|
1242
1815
|
}
|
|
1816
|
+
return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
|
|
1817
|
+
} else {
|
|
1818
|
+
return `<SSRNode id="${this.id}" />`;
|
|
1243
1819
|
}
|
|
1244
|
-
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1245
1820
|
}
|
|
1246
1821
|
};
|
|
1247
1822
|
var DomRef = class {
|
|
1248
1823
|
constructor($ssrNode$) {
|
|
1249
1824
|
this.$ssrNode$ = $ssrNode$;
|
|
1250
|
-
__publicField(this, "__brand__", "DomRef");
|
|
1251
1825
|
}
|
|
1826
|
+
__brand__ = "DomRef";
|
|
1252
1827
|
};
|
|
1253
1828
|
var SsrComponentFrame = class {
|
|
1254
1829
|
constructor(componentNode) {
|
|
1255
1830
|
this.componentNode = componentNode;
|
|
1256
|
-
__publicField(this, "slots", []);
|
|
1257
|
-
__publicField(this, "projectionDepth", 0);
|
|
1258
|
-
__publicField(this, "scopedStyleIds", /* @__PURE__ */ new Set());
|
|
1259
|
-
__publicField(this, "projectionScopedStyle", null);
|
|
1260
|
-
__publicField(this, "projectionComponentFrame", null);
|
|
1261
1831
|
}
|
|
1832
|
+
slots = [];
|
|
1833
|
+
projectionDepth = 0;
|
|
1834
|
+
scopedStyleIds = /* @__PURE__ */ new Set();
|
|
1835
|
+
projectionScopedStyle = null;
|
|
1836
|
+
projectionComponentFrame = null;
|
|
1262
1837
|
distributeChildrenIntoSlots(children, projectionScopedStyle, projectionComponentFrame) {
|
|
1263
1838
|
this.projectionScopedStyle = projectionScopedStyle;
|
|
1264
1839
|
this.projectionComponentFrame = projectionComponentFrame;
|
|
@@ -1311,13 +1886,6 @@ var SsrComponentFrame = class {
|
|
|
1311
1886
|
projectionNode.setProp(QSlotParent, this.componentNode.id);
|
|
1312
1887
|
return children;
|
|
1313
1888
|
}
|
|
1314
|
-
releaseUnclaimedProjections(unclaimedProjections) {
|
|
1315
|
-
if (this.slots.length) {
|
|
1316
|
-
unclaimedProjections.push(this);
|
|
1317
|
-
unclaimedProjections.push(this.projectionScopedStyle);
|
|
1318
|
-
unclaimedProjections.push.apply(unclaimedProjections, this.slots);
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
1889
|
};
|
|
1322
1890
|
|
|
1323
1891
|
// packages/qwik/src/server/tag-nesting.ts
|
|
@@ -1352,6 +1920,10 @@ var allowedContent = (state) => {
|
|
|
1352
1920
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1353
1921
|
case 1026 /* PHRASING_CONTAINER */:
|
|
1354
1922
|
return ["phrasing content", "<a>, <b>, <img>, <input> ... (no <div>, <p> ...)"];
|
|
1923
|
+
case 2050 /* PICTURE */:
|
|
1924
|
+
return ["picture content", "<source>, <img>"];
|
|
1925
|
+
case 4098 /* BUTTON */:
|
|
1926
|
+
return ["button content", "phrasing content except interactive elements"];
|
|
1355
1927
|
case 1 /* DOCUMENT */:
|
|
1356
1928
|
return ["document", "<html>"];
|
|
1357
1929
|
}
|
|
@@ -1393,6 +1965,10 @@ function isTagAllowed(state, tag) {
|
|
|
1393
1965
|
return isInPhrasing(tag, true);
|
|
1394
1966
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1395
1967
|
return isInPhrasing(tag, false);
|
|
1968
|
+
case 2050 /* PICTURE */:
|
|
1969
|
+
return isInPicture(tag);
|
|
1970
|
+
case 4098 /* BUTTON */:
|
|
1971
|
+
return isInButton(tag);
|
|
1396
1972
|
case 1 /* DOCUMENT */:
|
|
1397
1973
|
if (tag === "html") {
|
|
1398
1974
|
return 32 /* HTML */;
|
|
@@ -1472,9 +2048,12 @@ function isInAnything(text) {
|
|
|
1472
2048
|
case "body":
|
|
1473
2049
|
return 0 /* NOT_ALLOWED */;
|
|
1474
2050
|
case "button":
|
|
2051
|
+
return 4098 /* BUTTON */;
|
|
1475
2052
|
case "input":
|
|
1476
2053
|
case "textarea":
|
|
1477
2054
|
return 514 /* PHRASING_INSIDE_INPUT */;
|
|
2055
|
+
case "picture":
|
|
2056
|
+
return 2050 /* PICTURE */;
|
|
1478
2057
|
default:
|
|
1479
2058
|
return 10 /* ANYTHING */;
|
|
1480
2059
|
}
|
|
@@ -1489,6 +2068,8 @@ function isInTable(text) {
|
|
|
1489
2068
|
case "tbody":
|
|
1490
2069
|
case "tfoot":
|
|
1491
2070
|
return 8192 /* TABLE_BODY */;
|
|
2071
|
+
case "script":
|
|
2072
|
+
return 2 /* TEXT */;
|
|
1492
2073
|
default:
|
|
1493
2074
|
return 0 /* NOT_ALLOWED */;
|
|
1494
2075
|
}
|
|
@@ -1497,6 +2078,8 @@ function isInTableBody(text) {
|
|
|
1497
2078
|
switch (text) {
|
|
1498
2079
|
case "tr":
|
|
1499
2080
|
return 16384 /* TABLE_ROW */;
|
|
2081
|
+
case "script":
|
|
2082
|
+
return 2 /* TEXT */;
|
|
1500
2083
|
default:
|
|
1501
2084
|
return 0 /* NOT_ALLOWED */;
|
|
1502
2085
|
}
|
|
@@ -1506,6 +2089,8 @@ function isInTableRow(text) {
|
|
|
1506
2089
|
case "td":
|
|
1507
2090
|
case "th":
|
|
1508
2091
|
return 10 /* ANYTHING */;
|
|
2092
|
+
case "script":
|
|
2093
|
+
return 2 /* TEXT */;
|
|
1509
2094
|
default:
|
|
1510
2095
|
return 0 /* NOT_ALLOWED */;
|
|
1511
2096
|
}
|
|
@@ -1514,16 +2099,43 @@ function isInTableColGroup(text) {
|
|
|
1514
2099
|
switch (text) {
|
|
1515
2100
|
case "col":
|
|
1516
2101
|
return 4 /* EMPTY */;
|
|
2102
|
+
case "script":
|
|
2103
|
+
return 2 /* TEXT */;
|
|
2104
|
+
default:
|
|
2105
|
+
return 0 /* NOT_ALLOWED */;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
function isInPicture(text) {
|
|
2109
|
+
switch (text) {
|
|
2110
|
+
case "source":
|
|
2111
|
+
return 4 /* EMPTY */;
|
|
2112
|
+
case "img":
|
|
2113
|
+
return 4 /* EMPTY */;
|
|
2114
|
+
case "script":
|
|
2115
|
+
return 2 /* TEXT */;
|
|
1517
2116
|
default:
|
|
1518
2117
|
return 0 /* NOT_ALLOWED */;
|
|
1519
2118
|
}
|
|
1520
2119
|
}
|
|
2120
|
+
function isInButton(text) {
|
|
2121
|
+
switch (text) {
|
|
2122
|
+
case "button":
|
|
2123
|
+
case "input":
|
|
2124
|
+
case "textarea":
|
|
2125
|
+
case "select":
|
|
2126
|
+
case "a":
|
|
2127
|
+
return 0 /* NOT_ALLOWED */;
|
|
2128
|
+
case "picture":
|
|
2129
|
+
return 2050 /* PICTURE */;
|
|
2130
|
+
default:
|
|
2131
|
+
return isInPhrasing(text, false);
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
1521
2134
|
function isInPhrasing(text, allowInput) {
|
|
1522
2135
|
switch (text) {
|
|
1523
2136
|
case "svg":
|
|
1524
2137
|
case "math":
|
|
1525
2138
|
return 1026 /* PHRASING_CONTAINER */;
|
|
1526
|
-
case "button":
|
|
1527
2139
|
case "input":
|
|
1528
2140
|
case "textarea":
|
|
1529
2141
|
return allowInput ? 514 /* PHRASING_INSIDE_INPUT */ : 0 /* NOT_ALLOWED */;
|
|
@@ -1535,6 +2147,7 @@ function isInPhrasing(text, allowInput) {
|
|
|
1535
2147
|
case "bdi":
|
|
1536
2148
|
case "bdo":
|
|
1537
2149
|
case "br":
|
|
2150
|
+
case "button":
|
|
1538
2151
|
case "canvas":
|
|
1539
2152
|
case "cite":
|
|
1540
2153
|
case "code":
|
|
@@ -1562,13 +2175,11 @@ function isInPhrasing(text, allowInput) {
|
|
|
1562
2175
|
case "object":
|
|
1563
2176
|
case "option":
|
|
1564
2177
|
case "output":
|
|
1565
|
-
case "picture":
|
|
1566
2178
|
case "progress":
|
|
1567
2179
|
case "q":
|
|
1568
2180
|
case "ruby":
|
|
1569
2181
|
case "s":
|
|
1570
2182
|
case "samp":
|
|
1571
|
-
case "script":
|
|
1572
2183
|
case "select":
|
|
1573
2184
|
case "slot":
|
|
1574
2185
|
case "small":
|
|
@@ -1583,8 +2194,11 @@ function isInPhrasing(text, allowInput) {
|
|
|
1583
2194
|
case "video":
|
|
1584
2195
|
case "wbr":
|
|
1585
2196
|
return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
|
|
2197
|
+
case "script":
|
|
1586
2198
|
case "style":
|
|
1587
2199
|
return 2 /* TEXT */;
|
|
2200
|
+
case "picture":
|
|
2201
|
+
return 2050 /* PICTURE */;
|
|
1588
2202
|
default:
|
|
1589
2203
|
return 0 /* NOT_ALLOWED */;
|
|
1590
2204
|
}
|
|
@@ -1622,16 +2236,16 @@ function vNodeData_closeFragment(vNodeData) {
|
|
|
1622
2236
|
vNodeData.push(CLOSE_FRAGMENT);
|
|
1623
2237
|
}
|
|
1624
2238
|
function vNodeData_openElement(vNodeData) {
|
|
1625
|
-
vNodeData.push(
|
|
2239
|
+
vNodeData.push({}, WRITE_ELEMENT_ATTRS);
|
|
1626
2240
|
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
1627
2241
|
}
|
|
1628
|
-
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
2242
|
+
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
|
|
1629
2243
|
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1630
2244
|
const stack = [-1];
|
|
1631
2245
|
let attributesIndex = -1;
|
|
1632
2246
|
for (let i = 1; i < vNodeData.length; i++) {
|
|
1633
2247
|
const value = vNodeData[i];
|
|
1634
|
-
if (
|
|
2248
|
+
if (typeof value === "object" && value !== null) {
|
|
1635
2249
|
attributesIndex = i;
|
|
1636
2250
|
i++;
|
|
1637
2251
|
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
@@ -1647,275 +2261,51 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1647
2261
|
stack[stack.length - 1]++;
|
|
1648
2262
|
}
|
|
1649
2263
|
}
|
|
1650
|
-
let refId =
|
|
1651
|
-
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
1652
|
-
for (let i = 0; i < stack.length; i++) {
|
|
1653
|
-
const childCount = stack[i];
|
|
1654
|
-
if (childCount >= 0) {
|
|
1655
|
-
refId += encodeAsAlphanumeric(childCount);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
return new SsrNode(currentComponentNode, refId, attributesIndex, cleanupQueue, vNodeData);
|
|
1660
|
-
}
|
|
1661
|
-
var ALPHANUMERIC = [];
|
|
1662
|
-
function encodeAsAlphanumeric(value) {
|
|
1663
|
-
while (ALPHANUMERIC.length <= value) {
|
|
1664
|
-
let value2 = ALPHANUMERIC.length;
|
|
1665
|
-
let text = "";
|
|
1666
|
-
do {
|
|
1667
|
-
text = String.fromCharCode(
|
|
1668
|
-
(text.length === 0 ? 65 : 97) + value2 % 26
|
|
1669
|
-
/* A-Z */
|
|
1670
|
-
) + text;
|
|
1671
|
-
value2 = Math.floor(
|
|
1672
|
-
value2 / 26
|
|
1673
|
-
/* A-Z */
|
|
1674
|
-
);
|
|
1675
|
-
} while (value2 !== 0);
|
|
1676
|
-
ALPHANUMERIC.push(text);
|
|
1677
|
-
}
|
|
1678
|
-
return ALPHANUMERIC[value];
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1682
|
-
import { getPlatform } from "@qwik.dev/core";
|
|
1683
|
-
|
|
1684
|
-
// packages/qwik/src/server/preload-utils.ts
|
|
1685
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
1686
|
-
const urls = [];
|
|
1687
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
1688
|
-
if (prefetchResources2) {
|
|
1689
|
-
for (const prefetchResource of prefetchResources2) {
|
|
1690
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
1691
|
-
urls.push(prefetchResource.url);
|
|
1692
|
-
if (prefetchResource.imports) {
|
|
1693
|
-
addPrefetchResource(prefetchResource.imports);
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
};
|
|
1699
|
-
addPrefetchResource(prefetchResources);
|
|
1700
|
-
return urls;
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1704
|
-
var getBundles = (qrls) => {
|
|
1705
|
-
const platform = getPlatform();
|
|
1706
|
-
return qrls?.map((qrl) => {
|
|
1707
|
-
const symbol = qrl.$symbol$;
|
|
1708
|
-
const chunk = qrl.$chunk$;
|
|
1709
|
-
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1710
|
-
if (result) {
|
|
1711
|
-
return result[1];
|
|
1712
|
-
}
|
|
1713
|
-
return chunk;
|
|
1714
|
-
}).filter(Boolean);
|
|
1715
|
-
};
|
|
1716
|
-
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1717
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1718
|
-
if (prefetchStrategy === null) {
|
|
1719
|
-
return [];
|
|
1720
|
-
}
|
|
1721
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1722
|
-
return getBundles(qrls);
|
|
1723
|
-
}
|
|
1724
|
-
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1725
|
-
try {
|
|
1726
|
-
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1727
|
-
manifest: resolvedManifest.manifest
|
|
1728
|
-
});
|
|
1729
|
-
return flattenPrefetchResources(prefetchResources);
|
|
1730
|
-
} catch (e) {
|
|
1731
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
const symbols = /* @__PURE__ */ new Set();
|
|
1735
|
-
for (const qrl of qrls) {
|
|
1736
|
-
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1737
|
-
if (symbol && symbol.length >= 10) {
|
|
1738
|
-
symbols.add(symbol);
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
return [...symbols];
|
|
1742
|
-
}
|
|
1743
|
-
var expandBundles = (names, resolvedManifest) => {
|
|
1744
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1745
|
-
return [...new Set(names)];
|
|
1746
|
-
}
|
|
1747
|
-
resetQueue();
|
|
1748
|
-
let probability = 0.99;
|
|
1749
|
-
for (const name of names) {
|
|
1750
|
-
preload(name, probability);
|
|
1751
|
-
probability *= 0.95;
|
|
1752
|
-
}
|
|
1753
|
-
return getQueue();
|
|
1754
|
-
};
|
|
1755
|
-
|
|
1756
|
-
// packages/qwik/src/server/preload-impl.ts
|
|
1757
|
-
var simplifyPath = (base2, path) => {
|
|
1758
|
-
if (path == null) {
|
|
1759
|
-
return null;
|
|
1760
|
-
}
|
|
1761
|
-
const segments = `${base2}${path}`.split("/");
|
|
1762
|
-
const simplified = [];
|
|
1763
|
-
for (const segment of segments) {
|
|
1764
|
-
if (segment === ".." && simplified.length > 0) {
|
|
1765
|
-
simplified.pop();
|
|
1766
|
-
} else {
|
|
1767
|
-
simplified.push(segment);
|
|
1768
|
-
}
|
|
1769
|
-
}
|
|
1770
|
-
return simplified.join("/");
|
|
1771
|
-
};
|
|
1772
|
-
var getBase = (container) => {
|
|
1773
|
-
let base2 = container.$buildBase$;
|
|
1774
|
-
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1775
|
-
base2 = import.meta.env.BASE_URL;
|
|
1776
|
-
}
|
|
1777
|
-
return base2;
|
|
1778
|
-
};
|
|
1779
|
-
var preloaderPre = (container, options, nonce) => {
|
|
1780
|
-
const { resolvedManifest } = container;
|
|
1781
|
-
const base2 = getBase(container);
|
|
1782
|
-
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1783
|
-
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1784
|
-
if (bundleGraphPath) {
|
|
1785
|
-
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1786
|
-
}
|
|
1787
|
-
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1788
|
-
const preloaderOpts = typeof options === "object" ? {
|
|
1789
|
-
debug: options.debug,
|
|
1790
|
-
preloadProbability: options.ssrPreloadProbability
|
|
1791
|
-
} : void 0;
|
|
1792
|
-
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1793
|
-
initPreloader(bundleGraph, preloaderOpts);
|
|
1794
|
-
const opts = [];
|
|
1795
|
-
if (options) {
|
|
1796
|
-
if (options.debug) {
|
|
1797
|
-
opts.push("d:1");
|
|
1798
|
-
}
|
|
1799
|
-
if (options.maxIdlePreloads) {
|
|
1800
|
-
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1801
|
-
}
|
|
1802
|
-
if (options.preloadProbability) {
|
|
1803
|
-
opts.push(`Q:${options.preloadProbability}`);
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1807
|
-
container.openElement("link", null, ["rel", "modulepreload", "href", preloaderBundle]);
|
|
1808
|
-
container.closeElement();
|
|
1809
|
-
container.openElement("link", null, [
|
|
1810
|
-
"rel",
|
|
1811
|
-
"preload",
|
|
1812
|
-
"href",
|
|
1813
|
-
bundleGraphPath,
|
|
1814
|
-
"as",
|
|
1815
|
-
"fetch",
|
|
1816
|
-
"crossorigin",
|
|
1817
|
-
"anonymous"
|
|
1818
|
-
]);
|
|
1819
|
-
container.closeElement();
|
|
1820
|
-
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1821
|
-
const scriptAttrs = ["type", "module", "async", true];
|
|
1822
|
-
if (nonce) {
|
|
1823
|
-
scriptAttrs.push("nonce", nonce);
|
|
1824
|
-
}
|
|
1825
|
-
container.openElement("script", null, scriptAttrs);
|
|
1826
|
-
container.writer.write(script);
|
|
1827
|
-
container.closeElement();
|
|
1828
|
-
}
|
|
1829
|
-
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1830
|
-
if (corePath) {
|
|
1831
|
-
container.openElement("link", null, ["rel", "modulepreload", "href", corePath]);
|
|
1832
|
-
container.closeElement();
|
|
1833
|
-
}
|
|
1834
|
-
};
|
|
1835
|
-
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1836
|
-
if (referencedBundles.length === 0 || options === false) {
|
|
1837
|
-
return null;
|
|
1838
|
-
}
|
|
1839
|
-
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1840
|
-
typeof options === "boolean" ? void 0 : options
|
|
1841
|
-
);
|
|
1842
|
-
let allowed = ssrPreloads;
|
|
1843
|
-
const base2 = getBase(container);
|
|
1844
|
-
const links = [];
|
|
1845
|
-
const { resolvedManifest } = container;
|
|
1846
|
-
if (allowed) {
|
|
1847
|
-
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1848
|
-
const coreBundle = resolvedManifest?.manifest.core;
|
|
1849
|
-
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1850
|
-
let probability = 4;
|
|
1851
|
-
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1852
|
-
for (const hrefOrProbability of expandedBundles) {
|
|
1853
|
-
if (typeof hrefOrProbability === "string") {
|
|
1854
|
-
if (probability < tenXMinProbability) {
|
|
1855
|
-
break;
|
|
1856
|
-
}
|
|
1857
|
-
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1858
|
-
continue;
|
|
1859
|
-
}
|
|
1860
|
-
links.push(hrefOrProbability);
|
|
1861
|
-
if (--allowed === 0) {
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1864
|
-
} else {
|
|
1865
|
-
probability = hrefOrProbability;
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1870
|
-
const insertLinks = links.length ? (
|
|
1871
|
-
/**
|
|
1872
|
-
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1873
|
-
* preloader which does feature detection and which will be available soon after inserting these
|
|
1874
|
-
* links.
|
|
1875
|
-
*/
|
|
1876
|
-
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1877
|
-
) : "";
|
|
1878
|
-
let script = insertLinks;
|
|
1879
|
-
if (preloaderBundle) {
|
|
1880
|
-
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1881
|
-
}
|
|
1882
|
-
if (script) {
|
|
1883
|
-
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1884
|
-
if (nonce) {
|
|
1885
|
-
attrs.push("nonce", nonce);
|
|
1886
|
-
}
|
|
1887
|
-
container.openElement("script", null, attrs);
|
|
1888
|
-
container.writer.write(script);
|
|
1889
|
-
container.closeElement();
|
|
1890
|
-
}
|
|
1891
|
-
return null;
|
|
1892
|
-
};
|
|
1893
|
-
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1894
|
-
if (opts.preloader !== false) {
|
|
1895
|
-
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1896
|
-
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1897
|
-
if (preloadBundles.length > 0) {
|
|
1898
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
2264
|
+
let refId = depthFirstElementIdx + "";
|
|
2265
|
+
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
2266
|
+
for (let i = 0; i < stack.length; i++) {
|
|
2267
|
+
const childCount = stack[i];
|
|
2268
|
+
if (childCount >= 0) {
|
|
2269
|
+
refId += encodeAsAlphanumeric(childCount);
|
|
2270
|
+
}
|
|
1899
2271
|
}
|
|
1900
2272
|
}
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
2273
|
+
return new SsrNode(
|
|
2274
|
+
currentComponentNode,
|
|
2275
|
+
refId,
|
|
2276
|
+
attributesIndex,
|
|
2277
|
+
cleanupQueue,
|
|
2278
|
+
vNodeData,
|
|
2279
|
+
currentFile
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
var ALPHANUMERIC = [];
|
|
2283
|
+
function encodeAsAlphanumeric(value) {
|
|
2284
|
+
while (ALPHANUMERIC.length <= value) {
|
|
2285
|
+
let value2 = ALPHANUMERIC.length;
|
|
2286
|
+
let text = "";
|
|
2287
|
+
do {
|
|
2288
|
+
text = String.fromCharCode(
|
|
2289
|
+
(text.length === 0 ? 65 : 97) + value2 % 26
|
|
2290
|
+
/* A-Z */
|
|
2291
|
+
) + text;
|
|
2292
|
+
value2 = Math.floor(
|
|
2293
|
+
value2 / 26
|
|
2294
|
+
/* A-Z */
|
|
2295
|
+
);
|
|
2296
|
+
} while (value2 !== 0);
|
|
2297
|
+
ALPHANUMERIC.push(text);
|
|
2298
|
+
}
|
|
2299
|
+
return ALPHANUMERIC[value];
|
|
1904
2300
|
}
|
|
1905
|
-
var preLoaderOptionsDefault = {
|
|
1906
|
-
ssrPreloads: 7,
|
|
1907
|
-
ssrPreloadProbability: 0.5,
|
|
1908
|
-
debug: false,
|
|
1909
|
-
maxIdlePreloads: 25,
|
|
1910
|
-
preloadProbability: 0.35
|
|
1911
|
-
};
|
|
1912
2301
|
|
|
1913
2302
|
// packages/qwik/src/server/ssr-container.ts
|
|
1914
2303
|
function ssrCreateContainer(opts) {
|
|
1915
|
-
opts.renderOptions
|
|
2304
|
+
opts.renderOptions ||= {};
|
|
1916
2305
|
return new SSRContainer({
|
|
1917
2306
|
tagName: opts.tagName || "div",
|
|
1918
2307
|
writer: opts.writer || new StringBufferWriter(),
|
|
2308
|
+
streamHandler: opts.streamHandler,
|
|
1919
2309
|
locale: opts.locale || "",
|
|
1920
2310
|
timing: opts.timing || {
|
|
1921
2311
|
firstFlush: 0,
|
|
@@ -1934,9 +2324,7 @@ function ssrCreateContainer(opts) {
|
|
|
1934
2324
|
});
|
|
1935
2325
|
}
|
|
1936
2326
|
var StringBufferWriter = class {
|
|
1937
|
-
|
|
1938
|
-
__publicField(this, "buffer", []);
|
|
1939
|
-
}
|
|
2327
|
+
buffer = [];
|
|
1940
2328
|
write(text) {
|
|
1941
2329
|
this.buffer.push(text);
|
|
1942
2330
|
}
|
|
@@ -1945,61 +2333,59 @@ var StringBufferWriter = class {
|
|
|
1945
2333
|
}
|
|
1946
2334
|
};
|
|
1947
2335
|
var EMPTY_OBJ = {};
|
|
2336
|
+
var QTemplateProps = {
|
|
2337
|
+
hidden: true,
|
|
2338
|
+
"aria-hidden": true
|
|
2339
|
+
};
|
|
1948
2340
|
var SSRContainer = class extends _SharedContainer {
|
|
2341
|
+
tag;
|
|
2342
|
+
isHtml;
|
|
2343
|
+
writer;
|
|
2344
|
+
streamHandler;
|
|
2345
|
+
timing;
|
|
2346
|
+
size = 0;
|
|
2347
|
+
resolvedManifest;
|
|
2348
|
+
symbolToChunkResolver;
|
|
2349
|
+
renderOptions;
|
|
2350
|
+
serializationCtx;
|
|
2351
|
+
/**
|
|
2352
|
+
* We use this to append additional nodes in the head node
|
|
2353
|
+
*
|
|
2354
|
+
* - From manifest injections
|
|
2355
|
+
* - From useStyles and useScopedStyles hooks
|
|
2356
|
+
*/
|
|
2357
|
+
additionalHeadNodes = new Array();
|
|
2358
|
+
/**
|
|
2359
|
+
* We use this to append additional nodes in the body node
|
|
2360
|
+
*
|
|
2361
|
+
* - From manifest injections
|
|
2362
|
+
*/
|
|
2363
|
+
additionalBodyNodes = new Array();
|
|
2364
|
+
lastNode = null;
|
|
2365
|
+
currentComponentNode = null;
|
|
2366
|
+
styleIds = /* @__PURE__ */ new Set();
|
|
2367
|
+
isBackpatchExecutorEmitted = false;
|
|
2368
|
+
backpatchMap = /* @__PURE__ */ new Map();
|
|
2369
|
+
currentElementFrame = null;
|
|
2370
|
+
renderTimer;
|
|
2371
|
+
/**
|
|
2372
|
+
* Current element index.
|
|
2373
|
+
*
|
|
2374
|
+
* This number must match the depth-first traversal of the DOM elements as returned by the
|
|
2375
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
2376
|
+
*/
|
|
2377
|
+
depthFirstElementCount = -1;
|
|
2378
|
+
vNodeDatas = [];
|
|
2379
|
+
componentStack = [];
|
|
2380
|
+
cleanupQueue = [];
|
|
2381
|
+
emitContainerDataFrame = null;
|
|
2382
|
+
$instanceHash$ = randomStr();
|
|
2383
|
+
// Temporary flag to find missing roots after the state was serialized
|
|
2384
|
+
$noMoreRoots$ = false;
|
|
2385
|
+
qlInclude;
|
|
2386
|
+
promiseAttributes = null;
|
|
1949
2387
|
constructor(opts) {
|
|
1950
|
-
super(
|
|
1951
|
-
() => {
|
|
1952
|
-
try {
|
|
1953
|
-
return this.$scheduler$(255 /* WAIT_FOR_ALL */);
|
|
1954
|
-
} catch (e) {
|
|
1955
|
-
this.handleError(e, null);
|
|
1956
|
-
}
|
|
1957
|
-
},
|
|
1958
|
-
() => null,
|
|
1959
|
-
opts.renderOptions.serverData ?? EMPTY_OBJ,
|
|
1960
|
-
opts.locale
|
|
1961
|
-
);
|
|
1962
|
-
__publicField(this, "tag");
|
|
1963
|
-
__publicField(this, "isHtml");
|
|
1964
|
-
__publicField(this, "writer");
|
|
1965
|
-
__publicField(this, "timing");
|
|
1966
|
-
__publicField(this, "resolvedManifest");
|
|
1967
|
-
__publicField(this, "symbolToChunkResolver");
|
|
1968
|
-
__publicField(this, "renderOptions");
|
|
1969
|
-
__publicField(this, "serializationCtx");
|
|
1970
|
-
/**
|
|
1971
|
-
* We use this to append additional nodes in the head node
|
|
1972
|
-
*
|
|
1973
|
-
* - From manifest injections
|
|
1974
|
-
* - From useStyles and useScopedStyles hooks
|
|
1975
|
-
*/
|
|
1976
|
-
__publicField(this, "additionalHeadNodes", new Array());
|
|
1977
|
-
/**
|
|
1978
|
-
* We use this to append additional nodes in the body node
|
|
1979
|
-
*
|
|
1980
|
-
* - From manifest injections
|
|
1981
|
-
*/
|
|
1982
|
-
__publicField(this, "additionalBodyNodes", new Array());
|
|
1983
|
-
__publicField(this, "lastNode", null);
|
|
1984
|
-
__publicField(this, "currentComponentNode", null);
|
|
1985
|
-
__publicField(this, "styleIds", /* @__PURE__ */ new Set());
|
|
1986
|
-
__publicField(this, "currentElementFrame", null);
|
|
1987
|
-
__publicField(this, "renderTimer");
|
|
1988
|
-
/**
|
|
1989
|
-
* Current element index.
|
|
1990
|
-
*
|
|
1991
|
-
* This number must match the depth-first traversal of the DOM elements as returned by the
|
|
1992
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
1993
|
-
*/
|
|
1994
|
-
__publicField(this, "depthFirstElementCount", -1);
|
|
1995
|
-
__publicField(this, "vNodeDatas", []);
|
|
1996
|
-
__publicField(this, "componentStack", []);
|
|
1997
|
-
__publicField(this, "unclaimedProjections", []);
|
|
1998
|
-
__publicField(this, "unclaimedProjectionComponentFrameQueue", []);
|
|
1999
|
-
__publicField(this, "cleanupQueue", []);
|
|
2000
|
-
__publicField(this, "$instanceHash$", hash());
|
|
2001
|
-
// Temporary flag to find missing roots after the state was serialized
|
|
2002
|
-
__publicField(this, "$noMoreRoots$", false);
|
|
2388
|
+
super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
|
|
2003
2389
|
this.symbolToChunkResolver = (symbol) => {
|
|
2004
2390
|
const idx = symbol.lastIndexOf("_");
|
|
2005
2391
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2015,10 +2401,20 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2015
2401
|
this.tag = opts.tagName;
|
|
2016
2402
|
this.isHtml = opts.tagName === "html";
|
|
2017
2403
|
this.writer = opts.writer;
|
|
2404
|
+
this.streamHandler = opts.streamHandler;
|
|
2018
2405
|
this.timing = opts.timing;
|
|
2019
2406
|
this.$buildBase$ = opts.buildBase;
|
|
2020
2407
|
this.resolvedManifest = opts.resolvedManifest;
|
|
2021
2408
|
this.renderOptions = opts.renderOptions;
|
|
2409
|
+
this.$currentUniqueId$ = 1e5;
|
|
2410
|
+
const qlOpt = this.renderOptions.qwikLoader;
|
|
2411
|
+
this.qlInclude = qlOpt ? typeof qlOpt === "object" ? qlOpt.include === "never" ? 2 /* Done */ : 0 /* Module */ : qlOpt === "inline" ? 1 /* Inline */ : qlOpt === "never" ? 2 /* Done */ : 0 /* Module */ : 0 /* Module */;
|
|
2412
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2413
|
+
const qwikLoaderChunk = this.resolvedManifest?.manifest.qwikLoader;
|
|
2414
|
+
if (!qwikLoaderChunk) {
|
|
2415
|
+
this.qlInclude = 1 /* Inline */;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2022
2418
|
this.$processInjectionsFromManifest$();
|
|
2023
2419
|
}
|
|
2024
2420
|
ensureProjectionResolved(_host) {
|
|
@@ -2026,40 +2422,50 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2026
2422
|
handleError(err, _$host$) {
|
|
2027
2423
|
throw err;
|
|
2028
2424
|
}
|
|
2425
|
+
addBackpatchEntry(ssrNodeId, attrName, serializedValue) {
|
|
2426
|
+
const elementIndex = parseInt(ssrNodeId, 10);
|
|
2427
|
+
const entry = {
|
|
2428
|
+
attrName,
|
|
2429
|
+
value: serializedValue
|
|
2430
|
+
};
|
|
2431
|
+
const entries = this.backpatchMap.get(elementIndex) || [];
|
|
2432
|
+
entries.push(entry);
|
|
2433
|
+
this.backpatchMap.set(elementIndex, entries);
|
|
2434
|
+
}
|
|
2029
2435
|
async render(jsx) {
|
|
2030
2436
|
this.openContainer();
|
|
2031
|
-
await
|
|
2437
|
+
await this.renderJSX(jsx, {
|
|
2032
2438
|
currentStyleScoped: null,
|
|
2033
2439
|
parentComponentFrame: this.getComponentFrame()
|
|
2034
2440
|
});
|
|
2035
2441
|
await this.closeContainer();
|
|
2036
2442
|
}
|
|
2443
|
+
async renderJSX(jsx, options) {
|
|
2444
|
+
await _walkJSX(this, jsx, options);
|
|
2445
|
+
}
|
|
2037
2446
|
setContext(host, context, value) {
|
|
2038
2447
|
const ssrNode = host;
|
|
2039
2448
|
let ctx = ssrNode.getProp(QCtxAttr);
|
|
2040
|
-
if (
|
|
2449
|
+
if (ctx == null) {
|
|
2041
2450
|
ssrNode.setProp(QCtxAttr, ctx = []);
|
|
2042
2451
|
}
|
|
2043
|
-
mapArray_set(ctx, context.id, value, 0);
|
|
2452
|
+
mapArray_set(ctx, context.id, value, 0, true);
|
|
2044
2453
|
this.addRoot(ssrNode);
|
|
2045
2454
|
}
|
|
2046
2455
|
resolveContext(host, contextId) {
|
|
2047
2456
|
let ssrNode = host;
|
|
2048
2457
|
while (ssrNode) {
|
|
2049
2458
|
const ctx = ssrNode.getProp(QCtxAttr);
|
|
2050
|
-
if (ctx) {
|
|
2051
|
-
|
|
2052
|
-
if (value) {
|
|
2053
|
-
return value;
|
|
2054
|
-
}
|
|
2459
|
+
if (ctx != null && mapArray_has(ctx, contextId.id, 0)) {
|
|
2460
|
+
return mapArray_get(ctx, contextId.id, 0);
|
|
2055
2461
|
}
|
|
2056
|
-
ssrNode = ssrNode.
|
|
2462
|
+
ssrNode = ssrNode.parentComponent;
|
|
2057
2463
|
}
|
|
2058
2464
|
return void 0;
|
|
2059
2465
|
}
|
|
2060
2466
|
getParentHost(host) {
|
|
2061
2467
|
const ssrNode = host;
|
|
2062
|
-
return ssrNode.
|
|
2468
|
+
return ssrNode.parentComponent;
|
|
2063
2469
|
}
|
|
2064
2470
|
setHostProp(host, name, value) {
|
|
2065
2471
|
const ssrNode = host;
|
|
@@ -2082,52 +2488,86 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2082
2488
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
2083
2489
|
containerAttributes[QRuntimeAttr] = "2";
|
|
2084
2490
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
2085
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
2491
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev7 ? "ssr-dev" : "ssr");
|
|
2086
2492
|
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
2087
2493
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
2088
2494
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
2089
2495
|
containerAttributes[QInstanceAttr] = this.$instanceHash$;
|
|
2090
2496
|
this.$serverData$.containerAttributes = containerAttributes;
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
},
|
|
2096
|
-
[]
|
|
2097
|
-
);
|
|
2098
|
-
this.openElement(this.tag, containerAttributeArray);
|
|
2497
|
+
this.openElement(this.tag, null, containerAttributes);
|
|
2498
|
+
if (!this.isHtml) {
|
|
2499
|
+
this.emitContainerDataFrame = this.currentElementFrame;
|
|
2500
|
+
}
|
|
2099
2501
|
}
|
|
2100
2502
|
/** Renders closing tag for current container */
|
|
2101
2503
|
closeContainer() {
|
|
2102
2504
|
return this.closeElement();
|
|
2103
2505
|
}
|
|
2506
|
+
$noScriptHere$ = 0;
|
|
2104
2507
|
/** Renders opening tag for DOM element */
|
|
2105
|
-
openElement(elementName, varAttrs, constAttrs, currentFile) {
|
|
2508
|
+
openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
|
|
2509
|
+
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2510
|
+
if (elementName === "noscript" || elementName === "template" || elementName === "script") {
|
|
2511
|
+
this.$noScriptHere$++;
|
|
2512
|
+
}
|
|
2513
|
+
if (
|
|
2514
|
+
// don't append qwik loader before qwik style elements
|
|
2515
|
+
// it will confuse the resuming, because styles are expected to be the first nodes in subtree
|
|
2516
|
+
!isQwikStyle && this.qlInclude === 1 /* Inline */
|
|
2517
|
+
) {
|
|
2518
|
+
if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
|
|
2519
|
+
this.emitQwikLoaderInline();
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2106
2522
|
let innerHTML = void 0;
|
|
2107
2523
|
this.lastNode = null;
|
|
2108
|
-
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2109
2524
|
if (!isQwikStyle && this.currentElementFrame) {
|
|
2110
2525
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2111
2526
|
}
|
|
2112
2527
|
this.createAndPushFrame(elementName, this.depthFirstElementCount++, currentFile);
|
|
2528
|
+
if (this.isHtml && elementName === "body" && this.emitContainerDataFrame === null) {
|
|
2529
|
+
this.emitContainerDataFrame = this.currentElementFrame;
|
|
2530
|
+
}
|
|
2113
2531
|
vNodeData_openElement(this.currentElementFrame.vNodeData);
|
|
2114
|
-
this.write(
|
|
2532
|
+
this.write(LT);
|
|
2115
2533
|
this.write(elementName);
|
|
2534
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2116
2535
|
if (varAttrs) {
|
|
2117
|
-
innerHTML = this.writeAttrs(
|
|
2536
|
+
innerHTML = this.writeAttrs(
|
|
2537
|
+
elementName,
|
|
2538
|
+
varAttrs,
|
|
2539
|
+
false,
|
|
2540
|
+
styleScopedId,
|
|
2541
|
+
currentFile,
|
|
2542
|
+
hasMovedCaptures
|
|
2543
|
+
);
|
|
2118
2544
|
}
|
|
2119
2545
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2546
|
+
if (key !== null) {
|
|
2547
|
+
this.write(`="${key}"`);
|
|
2548
|
+
} else if (import.meta.env.TEST) {
|
|
2549
|
+
this.write(EMPTY_ATTR);
|
|
2550
|
+
}
|
|
2551
|
+
if (constAttrs && !isObjectEmpty(constAttrs)) {
|
|
2552
|
+
innerHTML = this.writeAttrs(
|
|
2553
|
+
elementName,
|
|
2554
|
+
constAttrs,
|
|
2555
|
+
true,
|
|
2556
|
+
styleScopedId,
|
|
2557
|
+
currentFile,
|
|
2558
|
+
hasMovedCaptures
|
|
2559
|
+
) || innerHTML;
|
|
2560
|
+
}
|
|
2561
|
+
this.write(GT);
|
|
2562
|
+
if (lastNode) {
|
|
2563
|
+
lastNode.setTreeNonUpdatable();
|
|
2123
2564
|
}
|
|
2124
|
-
this.write(">");
|
|
2125
|
-
this.lastNode = null;
|
|
2126
2565
|
return innerHTML;
|
|
2127
2566
|
}
|
|
2128
2567
|
/** Renders closing tag for DOM element */
|
|
2129
2568
|
closeElement() {
|
|
2130
|
-
if (this.
|
|
2569
|
+
if (this.currentElementFrame === this.emitContainerDataFrame) {
|
|
2570
|
+
this.emitContainerDataFrame = null;
|
|
2131
2571
|
this.onRenderDone();
|
|
2132
2572
|
const snapshotTimer = createTimer();
|
|
2133
2573
|
return maybeThen(
|
|
@@ -2139,16 +2579,6 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2139
2579
|
}
|
|
2140
2580
|
this._closeElement();
|
|
2141
2581
|
}
|
|
2142
|
-
shouldEmitDataBeforeClosingElement() {
|
|
2143
|
-
const currentFrame = this.currentElementFrame;
|
|
2144
|
-
return (
|
|
2145
|
-
/**
|
|
2146
|
-
* - Micro-frontends don't have html tag, emit data before closing custom element
|
|
2147
|
-
* - Regular applications should emit data inside body
|
|
2148
|
-
*/
|
|
2149
|
-
currentFrame.parent === null && currentFrame.elementName !== "html" || currentFrame.elementName === "body"
|
|
2150
|
-
);
|
|
2151
|
-
}
|
|
2152
2582
|
onRenderDone() {
|
|
2153
2583
|
this.drainCleanupQueue();
|
|
2154
2584
|
this.timing.render = this.renderTimer();
|
|
@@ -2170,11 +2600,14 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2170
2600
|
const currentFrame = this.popFrame();
|
|
2171
2601
|
const elementName = currentFrame.elementName;
|
|
2172
2602
|
if (!isSelfClosingTag(elementName)) {
|
|
2173
|
-
this.write(
|
|
2603
|
+
this.write(CLOSE_TAG);
|
|
2174
2604
|
this.write(elementName);
|
|
2175
|
-
this.write(
|
|
2605
|
+
this.write(GT);
|
|
2176
2606
|
}
|
|
2177
2607
|
this.lastNode = null;
|
|
2608
|
+
if (elementName === "noscript" || elementName === "template" || elementName === "script") {
|
|
2609
|
+
this.$noScriptHere$--;
|
|
2610
|
+
}
|
|
2178
2611
|
}
|
|
2179
2612
|
/** Writes opening data to vNodeData for fragment boundaries */
|
|
2180
2613
|
openFragment(attrs) {
|
|
@@ -2185,6 +2618,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2185
2618
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
2186
2619
|
closeFragment() {
|
|
2187
2620
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
2621
|
+
if (this.currentComponentNode) {
|
|
2622
|
+
this.currentComponentNode.setTreeNonUpdatable();
|
|
2623
|
+
}
|
|
2188
2624
|
this.lastNode = null;
|
|
2189
2625
|
}
|
|
2190
2626
|
openProjection(attrs) {
|
|
@@ -2224,12 +2660,37 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2224
2660
|
const localProjectionDepth = this.getComponentFrame()?.projectionDepth || 0;
|
|
2225
2661
|
return this.getComponentFrame(localProjectionDepth);
|
|
2226
2662
|
}
|
|
2227
|
-
/** Writes closing data to vNodeData for component boundaries and
|
|
2228
|
-
closeComponent() {
|
|
2663
|
+
/** Writes closing data to vNodeData for component boundaries and emit unclaimed projections inline */
|
|
2664
|
+
async closeComponent() {
|
|
2229
2665
|
const componentFrame = this.componentStack.pop();
|
|
2230
|
-
|
|
2666
|
+
await this.emitUnclaimedProjectionForComponent(componentFrame);
|
|
2231
2667
|
this.closeFragment();
|
|
2232
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2668
|
+
this.currentComponentNode = this.currentComponentNode?.parentComponent || null;
|
|
2669
|
+
}
|
|
2670
|
+
async emitUnclaimedProjectionForComponent(componentFrame) {
|
|
2671
|
+
if (componentFrame.slots.length === 0) {
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
this.openElement(QTemplate, null, QTemplateProps, null);
|
|
2675
|
+
const scopedStyleId = componentFrame.projectionScopedStyle;
|
|
2676
|
+
for (let i = 0; i < componentFrame.slots.length; i += 2) {
|
|
2677
|
+
const slotName = componentFrame.slots[i];
|
|
2678
|
+
const children = componentFrame.slots[i + 1];
|
|
2679
|
+
this.openFragment(
|
|
2680
|
+
isDev7 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
|
|
2681
|
+
);
|
|
2682
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2683
|
+
if (lastNode.vnodeData) {
|
|
2684
|
+
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2685
|
+
}
|
|
2686
|
+
componentFrame.componentNode.setProp(slotName, lastNode.id);
|
|
2687
|
+
await this.renderJSX(children, {
|
|
2688
|
+
currentStyleScoped: scopedStyleId,
|
|
2689
|
+
parentComponentFrame: componentFrame.projectionComponentFrame
|
|
2690
|
+
});
|
|
2691
|
+
this.closeFragment();
|
|
2692
|
+
}
|
|
2693
|
+
this.closeElement();
|
|
2233
2694
|
}
|
|
2234
2695
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2235
2696
|
textNode(text) {
|
|
@@ -2256,13 +2717,14 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2256
2717
|
this.currentElementFrame.vNodeData,
|
|
2257
2718
|
// we start at -1, so we need to add +1
|
|
2258
2719
|
this.currentElementFrame.depthFirstElementIdx + 1,
|
|
2259
|
-
this.cleanupQueue
|
|
2720
|
+
this.cleanupQueue,
|
|
2721
|
+
this.currentElementFrame.currentFile
|
|
2260
2722
|
);
|
|
2261
2723
|
}
|
|
2262
2724
|
return this.lastNode;
|
|
2263
2725
|
}
|
|
2264
2726
|
addUnclaimedProjection(frame, name, children) {
|
|
2265
|
-
|
|
2727
|
+
frame.slots.push(name, children);
|
|
2266
2728
|
}
|
|
2267
2729
|
$processInjectionsFromManifest$() {
|
|
2268
2730
|
const injections = this.resolvedManifest.manifest.injections;
|
|
@@ -2305,19 +2767,23 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2305
2767
|
}
|
|
2306
2768
|
}
|
|
2307
2769
|
_styleNode(styleId, content) {
|
|
2308
|
-
this.openElement("style",
|
|
2770
|
+
this.openElement("style", null, {
|
|
2771
|
+
[QStyle]: styleId
|
|
2772
|
+
});
|
|
2309
2773
|
this.write(content);
|
|
2310
2774
|
this.closeElement();
|
|
2311
2775
|
}
|
|
2312
2776
|
////////////////////////////////////
|
|
2313
2777
|
emitContainerData() {
|
|
2314
2778
|
return maybeThen(
|
|
2315
|
-
this.
|
|
2779
|
+
this.resolvePromiseAttributes(),
|
|
2316
2780
|
() => maybeThen(this.emitStateData(), () => {
|
|
2317
2781
|
this.$noMoreRoots$ = true;
|
|
2318
2782
|
this.emitVNodeData();
|
|
2319
2783
|
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2320
2784
|
this.emitSyncFnsData();
|
|
2785
|
+
this.emitPatchDataIfNeeded();
|
|
2786
|
+
this.emitExecutorIfNeeded();
|
|
2321
2787
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2322
2788
|
})
|
|
2323
2789
|
);
|
|
@@ -2344,7 +2810,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2344
2810
|
if (!this.serializationCtx.$roots$.length) {
|
|
2345
2811
|
return;
|
|
2346
2812
|
}
|
|
2347
|
-
this.openElement("script",
|
|
2813
|
+
this.openElement("script", null, { type: "qwik/vnode" });
|
|
2348
2814
|
const vNodeAttrsStack = [];
|
|
2349
2815
|
const vNodeData = this.vNodeDatas;
|
|
2350
2816
|
let lastSerializedIdx = 0;
|
|
@@ -2361,7 +2827,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2361
2827
|
let depth = 0;
|
|
2362
2828
|
for (let i = 1; i < vNode.length; i++) {
|
|
2363
2829
|
const value = vNode[i];
|
|
2364
|
-
if (
|
|
2830
|
+
if (typeof value === "object" && value !== null) {
|
|
2365
2831
|
vNodeAttrsStack.push(fragmentAttrs);
|
|
2366
2832
|
fragmentAttrs = value;
|
|
2367
2833
|
} else if (value === OPEN_FRAGMENT) {
|
|
@@ -2369,15 +2835,17 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2369
2835
|
this.write(VNodeDataChar.OPEN_CHAR);
|
|
2370
2836
|
} else if (value === CLOSE_FRAGMENT) {
|
|
2371
2837
|
if (fragmentAttrs) {
|
|
2372
|
-
|
|
2838
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2373
2839
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2374
2840
|
}
|
|
2375
2841
|
depth--;
|
|
2376
2842
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
2377
2843
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2378
|
-
if (fragmentAttrs && fragmentAttrs
|
|
2844
|
+
if (fragmentAttrs && !isObjectEmpty(fragmentAttrs)) {
|
|
2845
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2846
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2847
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2379
2848
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2380
|
-
writeFragmentAttrs(this.write.bind(this), this.addRoot.bind(this), fragmentAttrs);
|
|
2381
2849
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2382
2850
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2383
2851
|
}
|
|
@@ -2389,7 +2857,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2389
2857
|
}
|
|
2390
2858
|
while (depth-- > 0) {
|
|
2391
2859
|
if (fragmentAttrs) {
|
|
2392
|
-
|
|
2860
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2393
2861
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2394
2862
|
}
|
|
2395
2863
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
@@ -2397,206 +2865,215 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2397
2865
|
}
|
|
2398
2866
|
}
|
|
2399
2867
|
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
value = String(rootId);
|
|
2411
|
-
}
|
|
2412
|
-
switch (key) {
|
|
2413
|
-
case QScopedStyle:
|
|
2414
|
-
write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2415
|
-
break;
|
|
2416
|
-
case OnRenderProp:
|
|
2417
|
-
write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2418
|
-
break;
|
|
2419
|
-
case ELEMENT_ID:
|
|
2420
|
-
write(VNodeDataChar.ID_CHAR);
|
|
2421
|
-
break;
|
|
2422
|
-
case ELEMENT_PROPS:
|
|
2423
|
-
write(VNodeDataChar.PROPS_CHAR);
|
|
2424
|
-
break;
|
|
2425
|
-
case ELEMENT_KEY:
|
|
2426
|
-
encodeValue = true;
|
|
2427
|
-
write(VNodeDataChar.KEY_CHAR);
|
|
2428
|
-
break;
|
|
2429
|
-
case ELEMENT_SEQ:
|
|
2430
|
-
write(VNodeDataChar.SEQ_CHAR);
|
|
2431
|
-
break;
|
|
2432
|
-
case ELEMENT_SEQ_IDX:
|
|
2433
|
-
write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2434
|
-
break;
|
|
2435
|
-
case QBackRefs:
|
|
2436
|
-
write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2437
|
-
break;
|
|
2438
|
-
case QSlotParent:
|
|
2439
|
-
write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2440
|
-
break;
|
|
2441
|
-
// Skipping `\` character for now because it is used for escaping.
|
|
2442
|
-
case QCtxAttr:
|
|
2443
|
-
write(VNodeDataChar.CONTEXT_CHAR);
|
|
2444
|
-
break;
|
|
2445
|
-
case QSlot:
|
|
2446
|
-
write(VNodeDataChar.SLOT_CHAR);
|
|
2447
|
-
break;
|
|
2448
|
-
default:
|
|
2449
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2450
|
-
write(key);
|
|
2451
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2868
|
+
this.closeElement();
|
|
2869
|
+
}
|
|
2870
|
+
writeFragmentAttrs(fragmentAttrs) {
|
|
2871
|
+
for (const key in fragmentAttrs) {
|
|
2872
|
+
let value = fragmentAttrs[key];
|
|
2873
|
+
let encodeValue = false;
|
|
2874
|
+
if (typeof value !== "string") {
|
|
2875
|
+
const rootId = this.addRoot(value);
|
|
2876
|
+
if (rootId === void 0) {
|
|
2877
|
+
continue;
|
|
2452
2878
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
write(
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
write(
|
|
2879
|
+
value = String(rootId);
|
|
2880
|
+
}
|
|
2881
|
+
switch (key) {
|
|
2882
|
+
case QScopedStyle:
|
|
2883
|
+
this.write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2884
|
+
break;
|
|
2885
|
+
case OnRenderProp:
|
|
2886
|
+
this.write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2887
|
+
break;
|
|
2888
|
+
case ELEMENT_ID:
|
|
2889
|
+
this.write(VNodeDataChar.ID_CHAR);
|
|
2890
|
+
break;
|
|
2891
|
+
case ELEMENT_PROPS:
|
|
2892
|
+
this.write(VNodeDataChar.PROPS_CHAR);
|
|
2893
|
+
break;
|
|
2894
|
+
case ELEMENT_KEY:
|
|
2895
|
+
encodeValue = true;
|
|
2896
|
+
this.write(VNodeDataChar.KEY_CHAR);
|
|
2897
|
+
break;
|
|
2898
|
+
case ELEMENT_SEQ:
|
|
2899
|
+
this.write(VNodeDataChar.SEQ_CHAR);
|
|
2900
|
+
break;
|
|
2901
|
+
case ELEMENT_SEQ_IDX:
|
|
2902
|
+
this.write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2903
|
+
break;
|
|
2904
|
+
case QBackRefs:
|
|
2905
|
+
this.write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2906
|
+
break;
|
|
2907
|
+
case QSlotParent:
|
|
2908
|
+
this.write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2909
|
+
break;
|
|
2910
|
+
// Skipping `\` character for now because it is used for escaping.
|
|
2911
|
+
case QCtxAttr:
|
|
2912
|
+
this.write(VNodeDataChar.CONTEXT_CHAR);
|
|
2913
|
+
break;
|
|
2914
|
+
case QSlot:
|
|
2915
|
+
this.write(VNodeDataChar.SLOT_CHAR);
|
|
2916
|
+
break;
|
|
2917
|
+
default: {
|
|
2918
|
+
encodeValue = true;
|
|
2919
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2920
|
+
this.write(encodeVNodeDataString(key));
|
|
2921
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2461
2922
|
}
|
|
2462
2923
|
}
|
|
2924
|
+
const encodedValue = encodeVNodeDataString(encodeValue ? encodeURI(value) : value);
|
|
2925
|
+
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2926
|
+
if (isEncoded) {
|
|
2927
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2928
|
+
this.write(encodedValue);
|
|
2929
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2930
|
+
} else {
|
|
2931
|
+
this.write(value);
|
|
2932
|
+
}
|
|
2463
2933
|
}
|
|
2464
|
-
this.closeElement();
|
|
2465
2934
|
}
|
|
2466
2935
|
emitStateData() {
|
|
2467
2936
|
if (!this.serializationCtx.$roots$.length) {
|
|
2468
2937
|
return;
|
|
2469
2938
|
}
|
|
2470
|
-
this.
|
|
2939
|
+
const attrs = this.stateScriptAttrs();
|
|
2940
|
+
this.openElement("script", null, attrs);
|
|
2471
2941
|
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2472
2942
|
this.closeElement();
|
|
2473
2943
|
});
|
|
2474
2944
|
}
|
|
2945
|
+
/** Add q-d:qidle attribute to eagerly resume some state if needed */
|
|
2946
|
+
stateScriptAttrs() {
|
|
2947
|
+
const attrs = { type: "qwik/state" };
|
|
2948
|
+
const eagerResume = this.serializationCtx.$eagerResume$;
|
|
2949
|
+
if (eagerResume.size > 0) {
|
|
2950
|
+
attrs["q-d:qidle"] = createQRL(null, "_res", _res, null, [...eagerResume]);
|
|
2951
|
+
}
|
|
2952
|
+
return attrs;
|
|
2953
|
+
}
|
|
2475
2954
|
emitSyncFnsData() {
|
|
2476
2955
|
const fns = this.serializationCtx.$syncFns$;
|
|
2477
2956
|
if (fns.length) {
|
|
2478
|
-
const scriptAttrs =
|
|
2957
|
+
const scriptAttrs = { "q:func": "qwik/json" };
|
|
2479
2958
|
if (this.renderOptions.serverData?.nonce) {
|
|
2480
|
-
scriptAttrs
|
|
2959
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2481
2960
|
}
|
|
2482
|
-
this.openElement("script", scriptAttrs);
|
|
2961
|
+
this.openElement("script", null, scriptAttrs);
|
|
2483
2962
|
this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
|
|
2484
|
-
this.write(
|
|
2485
|
-
this.writeArray(fns,
|
|
2486
|
-
this.write(
|
|
2963
|
+
this.write(BRACKET_OPEN);
|
|
2964
|
+
this.writeArray(fns, COMMA);
|
|
2965
|
+
this.write(BRACKET_CLOSE);
|
|
2966
|
+
this.closeElement();
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
emitPatchDataIfNeeded() {
|
|
2970
|
+
const patches = [];
|
|
2971
|
+
for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
|
|
2972
|
+
for (let i = 0; i < backpatchEntries.length; i++) {
|
|
2973
|
+
const backpatchEntry = backpatchEntries[i];
|
|
2974
|
+
patches.push(
|
|
2975
|
+
elementIndex,
|
|
2976
|
+
backpatchEntry.attrName,
|
|
2977
|
+
isSignal(backpatchEntry.value) ? backpatchEntry.value.untrackedValue : backpatchEntry.value
|
|
2978
|
+
);
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
this.backpatchMap.clear();
|
|
2982
|
+
if (patches.length > 0) {
|
|
2983
|
+
this.isBackpatchExecutorEmitted = true;
|
|
2984
|
+
const scriptAttrs = { type: ELEMENT_BACKPATCH_DATA };
|
|
2985
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2986
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2987
|
+
}
|
|
2988
|
+
this.openElement("script", null, scriptAttrs);
|
|
2989
|
+
this.write(JSON.stringify(patches));
|
|
2487
2990
|
this.closeElement();
|
|
2488
2991
|
}
|
|
2489
2992
|
}
|
|
2993
|
+
emitExecutorIfNeeded() {
|
|
2994
|
+
if (!this.isBackpatchExecutorEmitted) {
|
|
2995
|
+
return;
|
|
2996
|
+
}
|
|
2997
|
+
const scriptAttrs = { type: "text/javascript" };
|
|
2998
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2999
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
3000
|
+
}
|
|
3001
|
+
this.openElement("script", null, scriptAttrs);
|
|
3002
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev7 });
|
|
3003
|
+
this.write(backpatchScript);
|
|
3004
|
+
this.closeElement();
|
|
3005
|
+
}
|
|
2490
3006
|
emitPreloaderPre() {
|
|
2491
3007
|
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2492
3008
|
}
|
|
2493
3009
|
isStatic() {
|
|
2494
3010
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2495
3011
|
}
|
|
2496
|
-
getQwikLoaderIncludeMode() {
|
|
2497
|
-
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2498
|
-
}
|
|
2499
3012
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
3013
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
3014
|
+
this.qlInclude = 2 /* Done */;
|
|
3015
|
+
const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
|
|
3016
|
+
const linkAttrs = { rel: "modulepreload", href: qwikLoaderBundle };
|
|
3017
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
3018
|
+
if (nonce) {
|
|
3019
|
+
linkAttrs["nonce"] = nonce;
|
|
3020
|
+
}
|
|
3021
|
+
this.openElement("link", null, linkAttrs);
|
|
3022
|
+
this.closeElement();
|
|
3023
|
+
const scriptAttrs = {
|
|
3024
|
+
async: true,
|
|
3025
|
+
type: "module",
|
|
3026
|
+
src: qwikLoaderBundle
|
|
3027
|
+
};
|
|
3028
|
+
if (nonce) {
|
|
3029
|
+
scriptAttrs["nonce"] = nonce;
|
|
2510
3030
|
}
|
|
3031
|
+
this.openElement("script", null, scriptAttrs);
|
|
3032
|
+
this.closeElement();
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
emitQwikLoaderInline() {
|
|
3036
|
+
this.qlInclude = 2 /* Done */;
|
|
3037
|
+
const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
|
|
3038
|
+
const scriptAttrs = {
|
|
3039
|
+
id: "qwikloader",
|
|
3040
|
+
async: true,
|
|
3041
|
+
type: "module"
|
|
3042
|
+
};
|
|
3043
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
3044
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2511
3045
|
}
|
|
3046
|
+
this.openElement("script", null, scriptAttrs);
|
|
3047
|
+
this.write(qwikLoaderScript);
|
|
3048
|
+
this.closeElement();
|
|
2512
3049
|
}
|
|
2513
3050
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2518
|
-
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2519
|
-
if (includeLoader) {
|
|
2520
|
-
const qwikLoaderScript = getQwikLoaderScript({
|
|
2521
|
-
debug: this.renderOptions.debug
|
|
2522
|
-
});
|
|
2523
|
-
const scriptAttrs = ["id", "qwikloader", "async", true];
|
|
2524
|
-
const nonce = this.renderOptions.serverData?.nonce;
|
|
2525
|
-
if (nonce) {
|
|
2526
|
-
scriptAttrs.push("nonce", nonce);
|
|
2527
|
-
}
|
|
2528
|
-
this.openElement("script", scriptAttrs);
|
|
2529
|
-
this.write(qwikLoaderScript);
|
|
2530
|
-
this.closeElement();
|
|
3051
|
+
if (!this.isStatic()) {
|
|
3052
|
+
if (this.qlInclude !== 2 /* Done */) {
|
|
3053
|
+
this.emitQwikLoaderInline();
|
|
2531
3054
|
}
|
|
3055
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2532
3056
|
}
|
|
2533
|
-
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2534
3057
|
}
|
|
2535
3058
|
emitQwikEvents(eventNames) {
|
|
2536
3059
|
if (eventNames.length > 0) {
|
|
2537
|
-
const scriptAttrs =
|
|
2538
|
-
this.
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
this.write(")");
|
|
2542
|
-
this.closeElement();
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
async emitUnclaimedProjection() {
|
|
2546
|
-
const unclaimedProjections = this.unclaimedProjections;
|
|
2547
|
-
if (unclaimedProjections.length) {
|
|
2548
|
-
const previousCurrentComponentNode = this.currentComponentNode;
|
|
2549
|
-
try {
|
|
2550
|
-
this.openElement(QTemplate, ["hidden", true, "aria-hidden", "true"], null);
|
|
2551
|
-
let idx = 0;
|
|
2552
|
-
let ssrComponentNode = null;
|
|
2553
|
-
let ssrComponentFrame = null;
|
|
2554
|
-
let scopedStyleId = null;
|
|
2555
|
-
for (let i = 0; i < unclaimedProjections.length; i += 4) {
|
|
2556
|
-
this.unclaimedProjectionComponentFrameQueue.push(
|
|
2557
|
-
unclaimedProjections[i]
|
|
2558
|
-
);
|
|
2559
|
-
}
|
|
2560
|
-
while (idx < unclaimedProjections.length) {
|
|
2561
|
-
const value = unclaimedProjections[idx++];
|
|
2562
|
-
if (value instanceof SsrComponentFrame) {
|
|
2563
|
-
ssrComponentNode = this.currentComponentNode = value.componentNode;
|
|
2564
|
-
ssrComponentFrame = value;
|
|
2565
|
-
scopedStyleId = unclaimedProjections[idx++];
|
|
2566
|
-
} else if (typeof value === "string") {
|
|
2567
|
-
const children = unclaimedProjections[idx++];
|
|
2568
|
-
if (!ssrComponentFrame?.hasSlot(value)) {
|
|
2569
|
-
ssrComponentFrame && ssrComponentFrame.componentNode.removeProp(value);
|
|
2570
|
-
continue;
|
|
2571
|
-
}
|
|
2572
|
-
this.unclaimedProjectionComponentFrameQueue.shift();
|
|
2573
|
-
this.openFragment(
|
|
2574
|
-
isDev4 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
|
|
2575
|
-
);
|
|
2576
|
-
const lastNode = this.getOrCreateLastNode();
|
|
2577
|
-
if (lastNode.vnodeData) {
|
|
2578
|
-
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2579
|
-
}
|
|
2580
|
-
ssrComponentNode?.setProp(value, lastNode.id);
|
|
2581
|
-
await _walkJSX(this, children, {
|
|
2582
|
-
currentStyleScoped: scopedStyleId,
|
|
2583
|
-
parentComponentFrame: null
|
|
2584
|
-
});
|
|
2585
|
-
this.closeFragment();
|
|
2586
|
-
} else {
|
|
2587
|
-
throw Error();
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
this.closeElement();
|
|
2591
|
-
} finally {
|
|
2592
|
-
this.currentComponentNode = previousCurrentComponentNode;
|
|
3060
|
+
const scriptAttrs = {};
|
|
3061
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
3062
|
+
if (nonce) {
|
|
3063
|
+
scriptAttrs["nonce"] = nonce;
|
|
2593
3064
|
}
|
|
3065
|
+
this.openElement("script", null, scriptAttrs);
|
|
3066
|
+
this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
|
|
3067
|
+
this.writeArray(eventNames, COMMA);
|
|
3068
|
+
this.write(PAREN_CLOSE);
|
|
3069
|
+
this.closeElement();
|
|
2594
3070
|
}
|
|
2595
3071
|
}
|
|
3072
|
+
// Keep in sync with process-vnode-data.unit.ts
|
|
2596
3073
|
emitVNodeSeparators(lastSerializedIdx, elementIdx) {
|
|
2597
3074
|
let skipCount = elementIdx - lastSerializedIdx;
|
|
2598
3075
|
while (skipCount != 0) {
|
|
2599
|
-
if (skipCount
|
|
3076
|
+
if (skipCount >= 8192) {
|
|
2600
3077
|
this.write(VNodeDataSeparator.ADVANCE_8192_CH);
|
|
2601
3078
|
skipCount -= 8192;
|
|
2602
3079
|
} else {
|
|
@@ -2620,7 +3097,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2620
3097
|
}
|
|
2621
3098
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
2622
3099
|
let tagNesting = 10 /* ANYTHING */;
|
|
2623
|
-
if (
|
|
3100
|
+
if (isDev7) {
|
|
2624
3101
|
if (!this.currentElementFrame) {
|
|
2625
3102
|
tagNesting = initialTag(elementName);
|
|
2626
3103
|
} else {
|
|
@@ -2645,7 +3122,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2645
3122
|
);
|
|
2646
3123
|
let indent = " ";
|
|
2647
3124
|
let lastName = "";
|
|
2648
|
-
for (
|
|
3125
|
+
for (let i = 0; i < frames.length; i++) {
|
|
3126
|
+
const frame3 = frames[i];
|
|
2649
3127
|
const [name, example] = allowedContent(frame3.tagNesting);
|
|
2650
3128
|
text.push(
|
|
2651
3129
|
`${indent}<${frame3.elementName}>${lastName !== name ? ` [${name}]${example ? ` -> ${example}` : ""}` : ""}`
|
|
@@ -2656,7 +3134,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2656
3134
|
text.push(
|
|
2657
3135
|
`${indent}<${elementName}> <= is not allowed as a child of ${allowedContent(previousTagNesting)[0]}.`
|
|
2658
3136
|
);
|
|
2659
|
-
throw newTagError(text.join("\n"));
|
|
3137
|
+
throw newTagError(text.map(escapeHTML).join("\n"));
|
|
2660
3138
|
}
|
|
2661
3139
|
}
|
|
2662
3140
|
}
|
|
@@ -2665,7 +3143,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2665
3143
|
parent: this.currentElementFrame,
|
|
2666
3144
|
elementName,
|
|
2667
3145
|
depthFirstElementIdx,
|
|
2668
|
-
vNodeData: [0 /* NONE */]
|
|
3146
|
+
vNodeData: [0 /* NONE */],
|
|
3147
|
+
currentFile: isDev7 ? currentFile || null : null
|
|
2669
3148
|
};
|
|
2670
3149
|
this.currentElementFrame = frame;
|
|
2671
3150
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -2677,6 +3156,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2677
3156
|
}
|
|
2678
3157
|
////////////////////////////////////
|
|
2679
3158
|
write(text) {
|
|
3159
|
+
this.size += text.length;
|
|
2680
3160
|
this.writer.write(text);
|
|
2681
3161
|
}
|
|
2682
3162
|
writeArray(array, separator) {
|
|
@@ -2688,89 +3168,103 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2688
3168
|
this.write(element);
|
|
2689
3169
|
}
|
|
2690
3170
|
}
|
|
2691
|
-
writeAttrs(tag, attrs, isConst, currentFile) {
|
|
3171
|
+
writeAttrs(tag, attrs, isConst, styleScopedId, currentFile, hasMovedCaptures) {
|
|
2692
3172
|
let innerHTML = void 0;
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
if (isSSRUnsafeAttr(key)) {
|
|
2699
|
-
if (isDev4) {
|
|
2700
|
-
throw qError(32 /* unsafeAttr */);
|
|
2701
|
-
}
|
|
2702
|
-
continue;
|
|
2703
|
-
}
|
|
2704
|
-
if (isClassAttr(key) && Array.isArray(value)) {
|
|
2705
|
-
const [signalValue, styleId] = value;
|
|
2706
|
-
value = signalValue;
|
|
2707
|
-
styleScopedId = styleId;
|
|
2708
|
-
}
|
|
2709
|
-
if (key === "ref") {
|
|
2710
|
-
const lastNode = this.getOrCreateLastNode();
|
|
2711
|
-
if (isSignal(value)) {
|
|
2712
|
-
value.$untrackedValue$ = new DomRef(lastNode);
|
|
2713
|
-
continue;
|
|
2714
|
-
} else if (typeof value === "function") {
|
|
2715
|
-
value(new DomRef(lastNode));
|
|
2716
|
-
continue;
|
|
2717
|
-
} else if (value == null) {
|
|
2718
|
-
continue;
|
|
2719
|
-
} else {
|
|
2720
|
-
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2721
|
-
}
|
|
3173
|
+
for (let key in attrs) {
|
|
3174
|
+
let value = attrs[key];
|
|
3175
|
+
if (isSSRUnsafeAttr(key)) {
|
|
3176
|
+
if (isDev7) {
|
|
3177
|
+
throw qError(32 /* unsafeAttr */, [key]);
|
|
2722
3178
|
}
|
|
3179
|
+
continue;
|
|
3180
|
+
}
|
|
3181
|
+
if (isHtmlAttributeAnEventName(key)) {
|
|
3182
|
+
value = _setEvent(this.serializationCtx, key, value, hasMovedCaptures);
|
|
3183
|
+
} else if (key === "ref") {
|
|
3184
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2723
3185
|
if (isSignal(value)) {
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
3186
|
+
value.$untrackedValue$ = new DomRef(lastNode);
|
|
3187
|
+
continue;
|
|
3188
|
+
} else if (typeof value === "function") {
|
|
3189
|
+
value(new DomRef(lastNode));
|
|
3190
|
+
continue;
|
|
3191
|
+
} else if (value == null) {
|
|
3192
|
+
continue;
|
|
3193
|
+
} else {
|
|
3194
|
+
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2730
3195
|
}
|
|
2731
|
-
|
|
3196
|
+
} else if (key === ITERATION_ITEM_SINGLE || key === ITERATION_ITEM_MULTI) {
|
|
3197
|
+
value = this.serializationCtx.$addRoot$(value);
|
|
3198
|
+
} else if (isSignal(value)) {
|
|
3199
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3200
|
+
const signalData = new SubscriptionData({
|
|
3201
|
+
$scopedStyleIdPrefix$: styleScopedId,
|
|
3202
|
+
$isConst$: isConst
|
|
3203
|
+
});
|
|
3204
|
+
const signal = value;
|
|
3205
|
+
value = retryOnPromise(
|
|
3206
|
+
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
3207
|
+
);
|
|
3208
|
+
}
|
|
3209
|
+
if (isPromise(value)) {
|
|
3210
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3211
|
+
this.addPromiseAttribute(value);
|
|
3212
|
+
value.then((resolvedValue) => {
|
|
3213
|
+
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
3214
|
+
});
|
|
3215
|
+
continue;
|
|
3216
|
+
}
|
|
3217
|
+
if (key === dangerouslySetInnerHTML) {
|
|
3218
|
+
if (value) {
|
|
2732
3219
|
innerHTML = String(value);
|
|
2733
3220
|
key = QContainerAttr;
|
|
2734
3221
|
value = "html" /* HTML */;
|
|
2735
|
-
if (tag === "style") {
|
|
2736
|
-
continue;
|
|
2737
|
-
}
|
|
2738
3222
|
}
|
|
2739
|
-
if (tag === "
|
|
2740
|
-
|
|
2741
|
-
if (isDev4) {
|
|
2742
|
-
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2743
|
-
}
|
|
2744
|
-
continue;
|
|
2745
|
-
}
|
|
2746
|
-
innerHTML = escapeHTML(value || "");
|
|
2747
|
-
key = QContainerAttr;
|
|
2748
|
-
value = "text" /* TEXT */;
|
|
3223
|
+
if (tag === "style") {
|
|
3224
|
+
continue;
|
|
2749
3225
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
this.write(strValue);
|
|
2758
|
-
this.write('"');
|
|
3226
|
+
} else if (isPreventDefault(key)) {
|
|
3227
|
+
addPreventDefaultEventToSerializationContext(this.serializationCtx, key);
|
|
3228
|
+
}
|
|
3229
|
+
if (tag === "textarea" && key === "value") {
|
|
3230
|
+
if (value && typeof value !== "string") {
|
|
3231
|
+
if (isDev7) {
|
|
3232
|
+
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2759
3233
|
}
|
|
3234
|
+
continue;
|
|
3235
|
+
}
|
|
3236
|
+
innerHTML = escapeHTML(value || "");
|
|
3237
|
+
key = QContainerAttr;
|
|
3238
|
+
value = "text" /* TEXT */;
|
|
3239
|
+
}
|
|
3240
|
+
const serializedValue = serializeAttribute(key, value, styleScopedId);
|
|
3241
|
+
if (serializedValue != null && serializedValue !== false) {
|
|
3242
|
+
this.write(SPACE);
|
|
3243
|
+
this.write(key);
|
|
3244
|
+
if (serializedValue !== true) {
|
|
3245
|
+
this.write(ATTR_EQUALS_QUOTE);
|
|
3246
|
+
const strValue = escapeHTML(String(serializedValue));
|
|
3247
|
+
this.write(strValue);
|
|
3248
|
+
this.write(QUOTE);
|
|
2760
3249
|
}
|
|
2761
3250
|
}
|
|
2762
3251
|
}
|
|
2763
3252
|
return innerHTML;
|
|
2764
3253
|
}
|
|
3254
|
+
addPromiseAttribute(promise) {
|
|
3255
|
+
this.promiseAttributes ||= [];
|
|
3256
|
+
this.promiseAttributes.push(promise);
|
|
3257
|
+
}
|
|
3258
|
+
async resolvePromiseAttributes() {
|
|
3259
|
+
if (this.promiseAttributes) {
|
|
3260
|
+
await Promise.all(this.promiseAttributes);
|
|
3261
|
+
this.promiseAttributes = null;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
2765
3264
|
};
|
|
2766
3265
|
var isQwikStyleElement = (tag, attrs) => {
|
|
2767
3266
|
if (tag === "style" && attrs != null) {
|
|
2768
|
-
|
|
2769
|
-
const attr = attrs[i];
|
|
2770
|
-
if (attr === QStyle || attr === QScopedStyle) {
|
|
2771
|
-
return true;
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
3267
|
+
return Object.prototype.hasOwnProperty.call(attrs, QStyle) || Object.prototype.hasOwnProperty.call(attrs, QScopedStyle);
|
|
2774
3268
|
}
|
|
2775
3269
|
return false;
|
|
2776
3270
|
};
|
|
@@ -2789,12 +3283,128 @@ function isSSRUnsafeAttr(name) {
|
|
|
2789
3283
|
}
|
|
2790
3284
|
return false;
|
|
2791
3285
|
}
|
|
2792
|
-
function
|
|
2793
|
-
return Math.random().toString(36).slice(2);
|
|
3286
|
+
function randomStr() {
|
|
3287
|
+
return (Math.random().toString(36) + "000000").slice(2, 8);
|
|
3288
|
+
}
|
|
3289
|
+
function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
|
|
3290
|
+
const eventName = "e" + key.substring(14);
|
|
3291
|
+
if (eventName) {
|
|
3292
|
+
serializationCtx.$eventNames$.add(eventName);
|
|
3293
|
+
}
|
|
2794
3294
|
}
|
|
2795
3295
|
|
|
2796
3296
|
// packages/qwik/src/server/ssr-render.ts
|
|
2797
3297
|
import { manifest as builtManifest } from "@qwik-client-manifest";
|
|
3298
|
+
|
|
3299
|
+
// packages/qwik/src/server/ssr-stream-handler.ts
|
|
3300
|
+
var StreamHandler = class {
|
|
3301
|
+
constructor(opts, timing) {
|
|
3302
|
+
this.opts = opts;
|
|
3303
|
+
this.timing = timing;
|
|
3304
|
+
this.inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
3305
|
+
strategy: "auto",
|
|
3306
|
+
maximumInitialChunk: 2e4,
|
|
3307
|
+
maximumChunk: 1e4
|
|
3308
|
+
};
|
|
3309
|
+
this.nativeStream = opts.stream;
|
|
3310
|
+
this.stream = this.setupStreamWriter();
|
|
3311
|
+
}
|
|
3312
|
+
bufferSize = 0;
|
|
3313
|
+
buffer = "";
|
|
3314
|
+
networkFlushes = 0;
|
|
3315
|
+
inOrderStreaming;
|
|
3316
|
+
streamBlockDepth = 0;
|
|
3317
|
+
streamBlockBuffer = "";
|
|
3318
|
+
streamBlockBufferSize = 0;
|
|
3319
|
+
nativeStream;
|
|
3320
|
+
firstFlushTimer = createTimer();
|
|
3321
|
+
stream;
|
|
3322
|
+
setupStreamWriter() {
|
|
3323
|
+
const handler = this;
|
|
3324
|
+
let stream;
|
|
3325
|
+
switch (this.inOrderStreaming.strategy) {
|
|
3326
|
+
case "disabled":
|
|
3327
|
+
stream = {
|
|
3328
|
+
write(chunk) {
|
|
3329
|
+
if (chunk === void 0 || chunk === null) {
|
|
3330
|
+
return;
|
|
3331
|
+
}
|
|
3332
|
+
handler.enqueue(chunk);
|
|
3333
|
+
}
|
|
3334
|
+
};
|
|
3335
|
+
break;
|
|
3336
|
+
case "direct": {
|
|
3337
|
+
const originalStream = this.nativeStream;
|
|
3338
|
+
stream = {
|
|
3339
|
+
write(chunk) {
|
|
3340
|
+
if (chunk === void 0 || chunk === null) {
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3343
|
+
originalStream.write(chunk);
|
|
3344
|
+
}
|
|
3345
|
+
};
|
|
3346
|
+
break;
|
|
3347
|
+
}
|
|
3348
|
+
default:
|
|
3349
|
+
case "auto": {
|
|
3350
|
+
const minimumChunkSize = this.inOrderStreaming.maximumChunk ?? 0;
|
|
3351
|
+
const initialChunkSize = this.inOrderStreaming.maximumInitialChunk ?? 0;
|
|
3352
|
+
stream = {
|
|
3353
|
+
write(chunk) {
|
|
3354
|
+
if (chunk === void 0 || chunk === null) {
|
|
3355
|
+
return;
|
|
3356
|
+
}
|
|
3357
|
+
handler.enqueue(chunk);
|
|
3358
|
+
if (handler.streamBlockDepth === 0) {
|
|
3359
|
+
const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3360
|
+
if (handler.bufferSize >= maxBufferSize) {
|
|
3361
|
+
handler.flush();
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
};
|
|
3366
|
+
break;
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
return stream;
|
|
3370
|
+
}
|
|
3371
|
+
enqueue(chunk) {
|
|
3372
|
+
const len = chunk.length;
|
|
3373
|
+
if (this.streamBlockDepth > 0) {
|
|
3374
|
+
this.streamBlockBuffer += chunk;
|
|
3375
|
+
this.streamBlockBufferSize += len;
|
|
3376
|
+
} else {
|
|
3377
|
+
this.bufferSize += len;
|
|
3378
|
+
this.buffer += chunk;
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
flush() {
|
|
3382
|
+
if (this.buffer) {
|
|
3383
|
+
this.nativeStream.write(this.buffer);
|
|
3384
|
+
this.buffer = "";
|
|
3385
|
+
this.bufferSize = 0;
|
|
3386
|
+
this.networkFlushes++;
|
|
3387
|
+
if (this.networkFlushes === 1) {
|
|
3388
|
+
this.timing.firstFlush = this.firstFlushTimer();
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
streamBlockStart() {
|
|
3393
|
+
this.streamBlockDepth++;
|
|
3394
|
+
}
|
|
3395
|
+
streamBlockEnd() {
|
|
3396
|
+
this.streamBlockDepth--;
|
|
3397
|
+
if (this.streamBlockDepth === 0 && this.streamBlockBuffer) {
|
|
3398
|
+
this.buffer += this.streamBlockBuffer;
|
|
3399
|
+
this.bufferSize += this.streamBlockBufferSize;
|
|
3400
|
+
this.streamBlockBuffer = "";
|
|
3401
|
+
this.streamBlockBufferSize = 0;
|
|
3402
|
+
this.flush();
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
};
|
|
3406
|
+
|
|
3407
|
+
// packages/qwik/src/server/ssr-render.ts
|
|
2798
3408
|
var renderToString = async (jsx, opts = {}) => {
|
|
2799
3409
|
const chunks = [];
|
|
2800
3410
|
const stream = {
|
|
@@ -2821,11 +3431,12 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2821
3431
|
const buildBase = getBuildBase(opts);
|
|
2822
3432
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
2823
3433
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
2824
|
-
const
|
|
3434
|
+
const streamHandler = new StreamHandler(opts, timing);
|
|
2825
3435
|
const ssrContainer = ssrCreateContainer({
|
|
2826
3436
|
tagName: containerTagName,
|
|
2827
3437
|
locale,
|
|
2828
|
-
writer: stream,
|
|
3438
|
+
writer: streamHandler.stream,
|
|
3439
|
+
streamHandler,
|
|
2829
3440
|
timing,
|
|
2830
3441
|
buildBase,
|
|
2831
3442
|
resolvedManifest,
|
|
@@ -2833,126 +3444,17 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2833
3444
|
});
|
|
2834
3445
|
await setServerPlatform(opts, resolvedManifest);
|
|
2835
3446
|
await ssrContainer.render(jsx);
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
3447
|
+
await ssrContainer.$renderPromise$;
|
|
3448
|
+
streamHandler.flush();
|
|
2839
3449
|
const result = {
|
|
2840
|
-
|
|
2841
|
-
flushes: networkFlushes,
|
|
3450
|
+
flushes: streamHandler.networkFlushes,
|
|
2842
3451
|
manifest: resolvedManifest?.manifest,
|
|
2843
|
-
size:
|
|
2844
|
-
isStatic:
|
|
3452
|
+
size: ssrContainer.size,
|
|
3453
|
+
isStatic: false,
|
|
2845
3454
|
timing
|
|
2846
3455
|
};
|
|
2847
3456
|
return result;
|
|
2848
3457
|
};
|
|
2849
|
-
function getSnapshotResult(ssrContainer) {
|
|
2850
|
-
const hasListeners = !ssrContainer.isStatic();
|
|
2851
|
-
const canRender = false;
|
|
2852
|
-
return hasListeners ? {
|
|
2853
|
-
funcs: Array.from(ssrContainer.serializationCtx.$syncFns$),
|
|
2854
|
-
mode: canRender ? "render" : "listeners",
|
|
2855
|
-
qrls: Array.from(ssrContainer.serializationCtx.$eventQrls$),
|
|
2856
|
-
resources: Array.from(ssrContainer.serializationCtx.$resources$)
|
|
2857
|
-
} : {
|
|
2858
|
-
funcs: [],
|
|
2859
|
-
mode: "static",
|
|
2860
|
-
qrls: [],
|
|
2861
|
-
resources: Array.from(ssrContainer.serializationCtx.$resources$)
|
|
2862
|
-
};
|
|
2863
|
-
}
|
|
2864
|
-
function handleStreaming(opts, timing) {
|
|
2865
|
-
const firstFlushTimer = createTimer();
|
|
2866
|
-
let stream = opts.stream;
|
|
2867
|
-
let bufferSize = 0;
|
|
2868
|
-
let buffer = "";
|
|
2869
|
-
let totalSize = 0;
|
|
2870
|
-
let networkFlushes = 0;
|
|
2871
|
-
const inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
2872
|
-
strategy: "auto",
|
|
2873
|
-
maximumInitialChunk: 2e4,
|
|
2874
|
-
maximumChunk: 1e4
|
|
2875
|
-
};
|
|
2876
|
-
const nativeStream = stream;
|
|
2877
|
-
function flush() {
|
|
2878
|
-
if (buffer) {
|
|
2879
|
-
nativeStream.write(buffer);
|
|
2880
|
-
buffer = "";
|
|
2881
|
-
bufferSize = 0;
|
|
2882
|
-
networkFlushes++;
|
|
2883
|
-
if (networkFlushes === 1) {
|
|
2884
|
-
timing.firstFlush = firstFlushTimer();
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
}
|
|
2888
|
-
function enqueue(chunk) {
|
|
2889
|
-
const len = chunk.length;
|
|
2890
|
-
bufferSize += len;
|
|
2891
|
-
totalSize += len;
|
|
2892
|
-
buffer += chunk;
|
|
2893
|
-
}
|
|
2894
|
-
switch (inOrderStreaming.strategy) {
|
|
2895
|
-
case "disabled":
|
|
2896
|
-
stream = {
|
|
2897
|
-
write(chunk) {
|
|
2898
|
-
if (shouldSkipChunk(chunk)) {
|
|
2899
|
-
return;
|
|
2900
|
-
}
|
|
2901
|
-
enqueue(chunk);
|
|
2902
|
-
}
|
|
2903
|
-
};
|
|
2904
|
-
break;
|
|
2905
|
-
case "direct":
|
|
2906
|
-
stream = {
|
|
2907
|
-
write(chunk) {
|
|
2908
|
-
if (shouldSkipChunk(chunk)) {
|
|
2909
|
-
return;
|
|
2910
|
-
}
|
|
2911
|
-
nativeStream.write(chunk);
|
|
2912
|
-
}
|
|
2913
|
-
};
|
|
2914
|
-
break;
|
|
2915
|
-
case "auto":
|
|
2916
|
-
let openedSSRStreamBlocks = 0;
|
|
2917
|
-
let forceFlush = false;
|
|
2918
|
-
const minimumChunkSize = inOrderStreaming.maximumChunk ?? 0;
|
|
2919
|
-
const initialChunkSize = inOrderStreaming.maximumInitialChunk ?? 0;
|
|
2920
|
-
stream = {
|
|
2921
|
-
write(chunk) {
|
|
2922
|
-
if (chunk === void 0 || chunk === null) {
|
|
2923
|
-
return;
|
|
2924
|
-
}
|
|
2925
|
-
if (chunk === "<!--" + FLUSH_COMMENT + "-->") {
|
|
2926
|
-
forceFlush = true;
|
|
2927
|
-
} else if (chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->") {
|
|
2928
|
-
openedSSRStreamBlocks++;
|
|
2929
|
-
} else if (chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->") {
|
|
2930
|
-
openedSSRStreamBlocks--;
|
|
2931
|
-
if (openedSSRStreamBlocks === 0) {
|
|
2932
|
-
forceFlush = true;
|
|
2933
|
-
}
|
|
2934
|
-
} else {
|
|
2935
|
-
enqueue(chunk);
|
|
2936
|
-
}
|
|
2937
|
-
const maxBufferSize = networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
2938
|
-
if (openedSSRStreamBlocks === 0 && (forceFlush || bufferSize >= maxBufferSize)) {
|
|
2939
|
-
forceFlush = false;
|
|
2940
|
-
flush();
|
|
2941
|
-
}
|
|
2942
|
-
}
|
|
2943
|
-
};
|
|
2944
|
-
break;
|
|
2945
|
-
}
|
|
2946
|
-
return {
|
|
2947
|
-
stream,
|
|
2948
|
-
flush,
|
|
2949
|
-
networkFlushes,
|
|
2950
|
-
totalSize
|
|
2951
|
-
};
|
|
2952
|
-
}
|
|
2953
|
-
function shouldSkipChunk(chunk) {
|
|
2954
|
-
return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
|
|
2955
|
-
}
|
|
2956
3458
|
function resolveManifest(manifest) {
|
|
2957
3459
|
const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
|
|
2958
3460
|
if (!mergedManifest || "mapper" in mergedManifest) {
|
|
@@ -2960,9 +3462,10 @@ function resolveManifest(manifest) {
|
|
|
2960
3462
|
}
|
|
2961
3463
|
if (mergedManifest.mapping) {
|
|
2962
3464
|
const mapper = {};
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
3465
|
+
for (const symbol in mergedManifest.mapping) {
|
|
3466
|
+
const bundleFilename = mergedManifest.mapping[symbol];
|
|
3467
|
+
mapper[getSymbolHash2(symbol)] = [symbol, bundleFilename];
|
|
3468
|
+
}
|
|
2966
3469
|
return {
|
|
2967
3470
|
mapper,
|
|
2968
3471
|
manifest: mergedManifest,
|
|
@@ -2975,10 +3478,11 @@ var Q_FUNCS_PREFIX = 'document["qFuncs_HASH"]=';
|
|
|
2975
3478
|
|
|
2976
3479
|
// packages/qwik/src/server/index.ts
|
|
2977
3480
|
async function setServerPlatform2(manifest) {
|
|
2978
|
-
const platform =
|
|
3481
|
+
const platform = createPlatform2({ manifest }, resolveManifest(manifest));
|
|
2979
3482
|
setPlatform2(platform);
|
|
2980
3483
|
}
|
|
2981
3484
|
export {
|
|
3485
|
+
getQwikBackpatchExecutorScript,
|
|
2982
3486
|
getQwikLoaderScript,
|
|
2983
3487
|
getQwikPrefetchWorkerScript,
|
|
2984
3488
|
renderToStream,
|