@qwik.dev/core 2.0.0-beta.3 → 2.0.0-beta.30
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 +12916 -0
- package/dist/core-internal.d.ts +1077 -707
- package/dist/core.min.mjs +2 -1
- package/dist/core.mjs +11616 -8673
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +8266 -5225
- package/dist/insights/index.qwik.mjs +80 -57
- 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 +2403 -3791
- package/dist/preloader.mjs +5 -8
- package/dist/qwikloader.debug.js +156 -131
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +51 -203
- package/dist/server.mjs +1418 -1088
- package/dist/server.prod.mjs +3264 -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 +925 -6
- package/dist/testing/index.mjs +15796 -11480
- 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.30-dev+5421ed4
|
|
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,12 @@ 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>";
|
|
216
230
|
|
|
217
231
|
// packages/qwik/src/core/shared/types.ts
|
|
218
232
|
var DEBUG_TYPE = "q:type";
|
|
219
233
|
|
|
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
234
|
// packages/qwik/src/core/shared/vnode-data-types.ts
|
|
464
235
|
var VNodeDataSeparator = {
|
|
465
236
|
REFERENCE_CH: (
|
|
@@ -748,10 +519,315 @@ var VNodeDataChar = {
|
|
|
748
519
|
)
|
|
749
520
|
};
|
|
750
521
|
|
|
751
|
-
// packages/qwik/src/core/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
522
|
+
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
523
|
+
function escapeHTML(html) {
|
|
524
|
+
let escapedHTML = "";
|
|
525
|
+
const length = html.length;
|
|
526
|
+
let idx = 0;
|
|
527
|
+
let lastIdx = idx;
|
|
528
|
+
for (; idx < length; idx++) {
|
|
529
|
+
const ch = html.charCodeAt(idx);
|
|
530
|
+
if (ch === 60) {
|
|
531
|
+
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
532
|
+
} else if (ch === 62) {
|
|
533
|
+
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
534
|
+
} else if (ch === 38) {
|
|
535
|
+
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
536
|
+
} else if (ch === 34) {
|
|
537
|
+
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
538
|
+
} else if (ch === 39) {
|
|
539
|
+
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
540
|
+
} else {
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
lastIdx = idx + 1;
|
|
544
|
+
}
|
|
545
|
+
if (lastIdx === 0) {
|
|
546
|
+
return html;
|
|
547
|
+
} else {
|
|
548
|
+
return escapedHTML + html.substring(lastIdx);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function encodeVNodeDataString(str) {
|
|
552
|
+
let escapedHTML = "";
|
|
553
|
+
const length = str.length;
|
|
554
|
+
let idx = 0;
|
|
555
|
+
let lastIdx = idx;
|
|
556
|
+
for (; idx < length; idx++) {
|
|
557
|
+
const ch = str.charCodeAt(idx);
|
|
558
|
+
if (ch >= VNodeDataSeparator.ADVANCE_1 && ch <= VNodeDataSeparator.ADVANCE_8192) {
|
|
559
|
+
escapedHTML += str.substring(lastIdx, idx) + "\\" + str.charAt(idx);
|
|
560
|
+
} else {
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
lastIdx = idx + 1;
|
|
564
|
+
}
|
|
565
|
+
if (lastIdx === 0) {
|
|
566
|
+
return str;
|
|
567
|
+
} else {
|
|
568
|
+
return escapedHTML + str.substring(lastIdx);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// packages/qwik/src/core/shared/utils/markers.ts
|
|
573
|
+
var OnRenderProp = "q:renderFn";
|
|
574
|
+
var QSlot = "q:slot";
|
|
575
|
+
var QSlotParent = "q:sparent";
|
|
576
|
+
var QStyle = "q:style";
|
|
577
|
+
var QStyleSelector = "style[q\\:style]";
|
|
578
|
+
var QStyleSSelector = "style[q\\:sstyle]";
|
|
579
|
+
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
580
|
+
var QScopedStyle = "q:sstyle";
|
|
581
|
+
var QCtxAttr = "q:ctx";
|
|
582
|
+
var QBackRefs = "q:brefs";
|
|
583
|
+
var QRenderAttr = "q:render";
|
|
584
|
+
var QRuntimeAttr = "q:runtime";
|
|
585
|
+
var QVersionAttr = "q:version";
|
|
586
|
+
var QBaseAttr = "q:base";
|
|
587
|
+
var QLocaleAttr = "q:locale";
|
|
588
|
+
var QManifestHashAttr = "q:manifest-hash";
|
|
589
|
+
var QInstanceAttr = "q:instance";
|
|
590
|
+
var QContainerIsland = "q:container-island";
|
|
591
|
+
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
592
|
+
var QIgnore = "q:ignore";
|
|
593
|
+
var QIgnoreEnd = "/" + QIgnore;
|
|
594
|
+
var QContainerAttr = "q:container";
|
|
595
|
+
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
596
|
+
var QTemplate = "q:template";
|
|
597
|
+
var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
|
|
598
|
+
var QDefaultSlot = "";
|
|
599
|
+
var ELEMENT_ID = "q:id";
|
|
600
|
+
var ELEMENT_KEY = "q:key";
|
|
601
|
+
var ELEMENT_PROPS = "q:props";
|
|
602
|
+
var ELEMENT_SEQ = "q:seq";
|
|
603
|
+
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
604
|
+
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
605
|
+
var ITERATION_ITEM_SINGLE = "q:p";
|
|
606
|
+
var ITERATION_ITEM_MULTI = "q:ps";
|
|
607
|
+
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
608
|
+
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
609
|
+
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
610
|
+
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
611
|
+
var Q_PROPS_SEPARATOR = ":";
|
|
612
|
+
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
613
|
+
|
|
614
|
+
// packages/qwik/src/core/shared/utils/promises.ts
|
|
615
|
+
import { isDev as isDev4, isServer } from "@qwik.dev/core/build";
|
|
616
|
+
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
617
|
+
var isPromise = (value) => {
|
|
618
|
+
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
619
|
+
};
|
|
620
|
+
var maybeThen = (valueOrPromise, thenFn) => {
|
|
621
|
+
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
622
|
+
};
|
|
623
|
+
var checkError = (e) => {
|
|
624
|
+
if (isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
625
|
+
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
var justThrow = (e) => {
|
|
629
|
+
throw e;
|
|
630
|
+
};
|
|
631
|
+
function retryOnPromise(fn, onError = justThrow) {
|
|
632
|
+
let ok = false;
|
|
633
|
+
let result;
|
|
634
|
+
try {
|
|
635
|
+
result = fn();
|
|
636
|
+
ok = true;
|
|
637
|
+
} catch (e) {
|
|
638
|
+
result = e;
|
|
639
|
+
}
|
|
640
|
+
if (!isPromise(result)) {
|
|
641
|
+
if (ok) {
|
|
642
|
+
return result;
|
|
643
|
+
}
|
|
644
|
+
isDev4 && checkError(result);
|
|
645
|
+
return onError(result);
|
|
646
|
+
}
|
|
647
|
+
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
648
|
+
const retry = async (p) => {
|
|
649
|
+
while (isPromise(p)) {
|
|
650
|
+
try {
|
|
651
|
+
await p;
|
|
652
|
+
return await fn();
|
|
653
|
+
} catch (err) {
|
|
654
|
+
if (isPromise(err)) {
|
|
655
|
+
if (!--retryCount) {
|
|
656
|
+
p = new Error("Exceeded max retry count in retryOnPromise");
|
|
657
|
+
break;
|
|
658
|
+
} else {
|
|
659
|
+
p = err;
|
|
660
|
+
}
|
|
661
|
+
} else {
|
|
662
|
+
p = err;
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
isDev4 && checkError(p);
|
|
668
|
+
return onError(p);
|
|
669
|
+
};
|
|
670
|
+
return ok ? result.catch(retry) : retry(result);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
674
|
+
function isClassAttr(key) {
|
|
675
|
+
return key === "class";
|
|
676
|
+
}
|
|
677
|
+
function convertStyleIdsToString(scopedStyleIds) {
|
|
678
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
682
|
+
var isHtmlAttributeAnEventName = (name) => {
|
|
683
|
+
return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && name.charCodeAt(3) === 58;
|
|
684
|
+
};
|
|
685
|
+
function isPreventDefault(key) {
|
|
686
|
+
return key.startsWith("preventdefault:");
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// packages/qwik/src/core/shared/utils/unitless_number.ts
|
|
690
|
+
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
691
|
+
"animationIterationCount",
|
|
692
|
+
"aspectRatio",
|
|
693
|
+
"borderImageOutset",
|
|
694
|
+
"borderImageSlice",
|
|
695
|
+
"borderImageWidth",
|
|
696
|
+
"boxFlex",
|
|
697
|
+
"boxFlexGroup",
|
|
698
|
+
"boxOrdinalGroup",
|
|
699
|
+
"columnCount",
|
|
700
|
+
"columns",
|
|
701
|
+
"flex",
|
|
702
|
+
"flexGrow",
|
|
703
|
+
"flexShrink",
|
|
704
|
+
"gridArea",
|
|
705
|
+
"gridRow",
|
|
706
|
+
"gridRowEnd",
|
|
707
|
+
"gridRowStart",
|
|
708
|
+
"gridColumn",
|
|
709
|
+
"gridColumnEnd",
|
|
710
|
+
"gridColumnStart",
|
|
711
|
+
"fontWeight",
|
|
712
|
+
"lineClamp",
|
|
713
|
+
"lineHeight",
|
|
714
|
+
"opacity",
|
|
715
|
+
"order",
|
|
716
|
+
"orphans",
|
|
717
|
+
"scale",
|
|
718
|
+
"tabSize",
|
|
719
|
+
"widows",
|
|
720
|
+
"zIndex",
|
|
721
|
+
"zoom",
|
|
722
|
+
"MozAnimationIterationCount",
|
|
723
|
+
// Known Prefixed Properties
|
|
724
|
+
"MozBoxFlex",
|
|
725
|
+
// TODO: Remove these since they shouldn't be used in modern code
|
|
726
|
+
"msFlex",
|
|
727
|
+
"msFlexPositive",
|
|
728
|
+
"WebkitAnimationIterationCount",
|
|
729
|
+
"WebkitBoxFlex",
|
|
730
|
+
"WebkitBoxOrdinalGroup",
|
|
731
|
+
"WebkitColumnCount",
|
|
732
|
+
"WebkitColumns",
|
|
733
|
+
"WebkitFlex",
|
|
734
|
+
"WebkitFlexGrow",
|
|
735
|
+
"WebkitFlexShrink",
|
|
736
|
+
"WebkitLineClamp"
|
|
737
|
+
]);
|
|
738
|
+
var isUnitlessNumber = (name) => {
|
|
739
|
+
return unitlessNumbers.has(name);
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
// packages/qwik/src/core/shared/utils/styles.ts
|
|
743
|
+
var serializeClass = (obj) => {
|
|
744
|
+
if (!obj) {
|
|
745
|
+
return "";
|
|
746
|
+
}
|
|
747
|
+
if (isString(obj)) {
|
|
748
|
+
return obj.trim();
|
|
749
|
+
}
|
|
750
|
+
const classes = [];
|
|
751
|
+
if (isArray(obj)) {
|
|
752
|
+
for (const o of obj) {
|
|
753
|
+
const classList = serializeClass(o);
|
|
754
|
+
if (classList) {
|
|
755
|
+
classes.push(classList);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
} else {
|
|
759
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
760
|
+
if (value) {
|
|
761
|
+
classes.push(key.trim());
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return classes.join(" ");
|
|
766
|
+
};
|
|
767
|
+
var fromCamelToKebabCaseWithDash = (text) => {
|
|
768
|
+
return text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
769
|
+
};
|
|
770
|
+
var stringifyStyle = (obj) => {
|
|
771
|
+
if (obj == null) {
|
|
772
|
+
return "";
|
|
773
|
+
}
|
|
774
|
+
if (typeof obj == "object") {
|
|
775
|
+
if (isArray(obj)) {
|
|
776
|
+
throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]);
|
|
777
|
+
} else {
|
|
778
|
+
const chunks = [];
|
|
779
|
+
for (const key in obj) {
|
|
780
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
781
|
+
const value = obj[key];
|
|
782
|
+
if (value != null && typeof value !== "function") {
|
|
783
|
+
if (key.startsWith("--")) {
|
|
784
|
+
chunks.push(key + ":" + value);
|
|
785
|
+
} else {
|
|
786
|
+
chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value));
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return chunks.join(";");
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return String(obj);
|
|
795
|
+
};
|
|
796
|
+
var serializeBooleanOrNumberAttribute = (value) => {
|
|
797
|
+
return value != null ? String(value) : null;
|
|
798
|
+
};
|
|
799
|
+
function serializeAttribute(key, value, styleScopedId) {
|
|
800
|
+
if (isClassAttr(key)) {
|
|
801
|
+
const serializedClass = serializeClass(value);
|
|
802
|
+
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
803
|
+
} else if (key === "style") {
|
|
804
|
+
value = stringifyStyle(value);
|
|
805
|
+
} else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") {
|
|
806
|
+
value = serializeBooleanOrNumberAttribute(value);
|
|
807
|
+
} else if (value === false || value == null) {
|
|
808
|
+
value = null;
|
|
809
|
+
} else if (value === true && isPreventDefault(key)) {
|
|
810
|
+
value = "";
|
|
811
|
+
}
|
|
812
|
+
return value;
|
|
813
|
+
}
|
|
814
|
+
function isEnumeratedBooleanAttribute(key) {
|
|
815
|
+
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
816
|
+
}
|
|
817
|
+
var setValueForStyle = (styleName, value) => {
|
|
818
|
+
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) {
|
|
819
|
+
return value + "px";
|
|
820
|
+
}
|
|
821
|
+
return value;
|
|
822
|
+
};
|
|
823
|
+
function isAriaAttribute(prop) {
|
|
824
|
+
return prop.startsWith("aria-");
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
828
|
+
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
829
|
+
|
|
830
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
755
831
|
import { isBrowser as isBrowser2 } from "@qwik.dev/core/build";
|
|
756
832
|
|
|
757
833
|
// packages/qwik/src/core/preloader/constants.ts
|
|
@@ -893,12 +969,9 @@ var trigger = () => {
|
|
|
893
969
|
const bundle = queue[0];
|
|
894
970
|
const inverseProbability = bundle.$inverseProbability$;
|
|
895
971
|
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
|
|
972
|
+
const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
|
|
973
|
+
// While the graph is not available, we limit to 5 preloads
|
|
974
|
+
5
|
|
902
975
|
);
|
|
903
976
|
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
904
977
|
queue.shift();
|
|
@@ -954,7 +1027,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
954
1027
|
}
|
|
955
1028
|
if (
|
|
956
1029
|
// don't queue until we have initialized the preloader
|
|
957
|
-
base != null && bundle.$state$ < BundleImportState_Preload
|
|
1030
|
+
base != null && bundle.$state$ < BundleImportState_Preload
|
|
958
1031
|
) {
|
|
959
1032
|
if (bundle.$state$ === BundleImportState_None) {
|
|
960
1033
|
bundle.$state$ = BundleImportState_Queued;
|
|
@@ -964,7 +1037,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
964
1037
|
queueDirty = true;
|
|
965
1038
|
}
|
|
966
1039
|
if (bundle.$deps$) {
|
|
967
|
-
seen
|
|
1040
|
+
seen ||= /* @__PURE__ */ new Set();
|
|
968
1041
|
seen.add(bundle);
|
|
969
1042
|
const probability = 1 - bundle.$inverseProbability$;
|
|
970
1043
|
for (const dep of bundle.$deps$) {
|
|
@@ -973,7 +1046,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
973
1046
|
continue;
|
|
974
1047
|
}
|
|
975
1048
|
let newInverseProbability2;
|
|
976
|
-
if (
|
|
1049
|
+
if (probability === 1 || probability >= 0.99 && depsCount < 100) {
|
|
977
1050
|
depsCount++;
|
|
978
1051
|
newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
|
|
979
1052
|
} else {
|
|
@@ -1020,30 +1093,68 @@ if (isBrowser3) {
|
|
|
1020
1093
|
document.addEventListener("qsymbol", (ev) => {
|
|
1021
1094
|
const { symbol, href } = ev.detail;
|
|
1022
1095
|
if (href) {
|
|
1023
|
-
const
|
|
1024
|
-
preload(
|
|
1096
|
+
const hash = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1097
|
+
preload(hash, 1);
|
|
1025
1098
|
}
|
|
1026
1099
|
});
|
|
1027
1100
|
}
|
|
1028
1101
|
|
|
1102
|
+
// packages/qwik/src/core/shared/utils/objects.ts
|
|
1103
|
+
var isObjectEmpty = (obj) => {
|
|
1104
|
+
for (const key in obj) {
|
|
1105
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1106
|
+
return false;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
return true;
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
// packages/qwik/src/core/shared/ssr-const.ts
|
|
1113
|
+
var LT = "<";
|
|
1114
|
+
var GT = ">";
|
|
1115
|
+
var CLOSE_TAG = "</";
|
|
1116
|
+
var SPACE = " ";
|
|
1117
|
+
var ATTR_EQUALS_QUOTE = '="';
|
|
1118
|
+
var QUOTE = '"';
|
|
1119
|
+
var EMPTY_ATTR = '=""';
|
|
1120
|
+
var BRACKET_OPEN = "[";
|
|
1121
|
+
var BRACKET_CLOSE = "]";
|
|
1122
|
+
var PAREN_CLOSE = ")";
|
|
1123
|
+
var COMMA = ",";
|
|
1124
|
+
|
|
1029
1125
|
// packages/qwik/src/server/platform.ts
|
|
1126
|
+
var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
|
|
1127
|
+
const existing = mapper?.[hash];
|
|
1128
|
+
if (existing) {
|
|
1129
|
+
return existing;
|
|
1130
|
+
}
|
|
1131
|
+
if (symbolName === SYNC_QRL) {
|
|
1132
|
+
return [symbolName, ""];
|
|
1133
|
+
}
|
|
1134
|
+
if (!parent) {
|
|
1135
|
+
if (symbolName.startsWith("_") && symbolName.length < 6) {
|
|
1136
|
+
return [symbolName, `${import.meta.env.BASE_URL}@qwik-handlers`];
|
|
1137
|
+
}
|
|
1138
|
+
console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
|
|
1139
|
+
return [symbolName, `${import.meta.env.BASE_URL}${symbolName}.js`];
|
|
1140
|
+
}
|
|
1141
|
+
const qrlFile = `${import.meta.env.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
|
|
1142
|
+
return [symbolName, qrlFile];
|
|
1143
|
+
};
|
|
1030
1144
|
function createPlatform(opts, resolvedManifest) {
|
|
1031
1145
|
const mapper = resolvedManifest?.mapper;
|
|
1032
1146
|
const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
|
|
1033
|
-
if (mapper) {
|
|
1034
|
-
const
|
|
1035
|
-
const result = mapper[
|
|
1147
|
+
if (mapper || isDev5 && import.meta.env.MODE !== "test") {
|
|
1148
|
+
const hash = getSymbolHash(symbolName);
|
|
1149
|
+
const result = !isDev5 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
|
|
1036
1150
|
if (!result) {
|
|
1037
|
-
if (
|
|
1038
|
-
return [
|
|
1151
|
+
if (hash === SYNC_QRL) {
|
|
1152
|
+
return [hash, ""];
|
|
1039
1153
|
}
|
|
1040
|
-
const isRegistered = globalThis.__qwik_reg_symbols?.has(
|
|
1154
|
+
const isRegistered = globalThis.__qwik_reg_symbols?.has(hash);
|
|
1041
1155
|
if (isRegistered) {
|
|
1042
1156
|
return [symbolName, "_"];
|
|
1043
1157
|
}
|
|
1044
|
-
if (parent) {
|
|
1045
|
-
return [symbolName, `${parent}?qrl=${symbolName}`];
|
|
1046
|
-
}
|
|
1047
1158
|
console.error("Cannot resolve symbol", symbolName, "in", mapper, parent);
|
|
1048
1159
|
}
|
|
1049
1160
|
return result;
|
|
@@ -1052,32 +1163,17 @@ function createPlatform(opts, resolvedManifest) {
|
|
|
1052
1163
|
const serverPlatform = {
|
|
1053
1164
|
isServer: true,
|
|
1054
1165
|
async importSymbol(_containerEl, url, symbolName) {
|
|
1055
|
-
const
|
|
1056
|
-
const regSym = globalThis.__qwik_reg_symbols?.get(
|
|
1166
|
+
const hash = getSymbolHash(symbolName);
|
|
1167
|
+
const regSym = globalThis.__qwik_reg_symbols?.get(hash);
|
|
1057
1168
|
if (regSym) {
|
|
1058
1169
|
return regSym;
|
|
1059
1170
|
}
|
|
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];
|
|
1171
|
+
throw qError(6 /* dynamicImportFailed */, [symbolName]);
|
|
1069
1172
|
},
|
|
1070
1173
|
raf: () => {
|
|
1071
1174
|
console.error("server can not rerender");
|
|
1072
1175
|
return Promise.resolve();
|
|
1073
1176
|
},
|
|
1074
|
-
nextTick: (fn) => {
|
|
1075
|
-
return new Promise((resolve) => {
|
|
1076
|
-
setTimeout(() => {
|
|
1077
|
-
resolve(fn());
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
},
|
|
1081
1177
|
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1082
1178
|
return mapperFn(symbolName, mapper, parent);
|
|
1083
1179
|
}
|
|
@@ -1122,24 +1218,314 @@ function getBuildBase(opts) {
|
|
|
1122
1218
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1123
1219
|
}
|
|
1124
1220
|
var versions = {
|
|
1125
|
-
qwik: "2.0.0-beta.
|
|
1221
|
+
qwik: "2.0.0-beta.30-dev+5421ed4",
|
|
1126
1222
|
qwikDom: "2.1.19"
|
|
1127
1223
|
};
|
|
1128
1224
|
|
|
1129
1225
|
// packages/qwik/src/server/ssr-container.ts
|
|
1226
|
+
import { isDev as isDev7 } from "@qwik.dev/core/build";
|
|
1130
1227
|
import {
|
|
1131
1228
|
_SubscriptionData as SubscriptionData,
|
|
1132
1229
|
_SharedContainer,
|
|
1133
1230
|
_jsxSorted,
|
|
1134
1231
|
_jsxSplit,
|
|
1232
|
+
_res,
|
|
1233
|
+
_setEvent,
|
|
1135
1234
|
_walkJSX,
|
|
1235
|
+
_createQRL as createQRL,
|
|
1136
1236
|
isSignal
|
|
1137
|
-
} from "@qwik.dev/core";
|
|
1138
|
-
|
|
1237
|
+
} from "@qwik.dev/core/internal";
|
|
1238
|
+
|
|
1239
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1240
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1241
|
+
|
|
1242
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1243
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1244
|
+
const urls = [];
|
|
1245
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1246
|
+
if (prefetchResources2) {
|
|
1247
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1248
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1249
|
+
urls.push(prefetchResource.url);
|
|
1250
|
+
if (prefetchResource.imports) {
|
|
1251
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
addPrefetchResource(prefetchResources);
|
|
1258
|
+
return urls;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1262
|
+
var getBundles = (qrls) => {
|
|
1263
|
+
const platform = getPlatform();
|
|
1264
|
+
const bundles2 = qrls?.map((qrl) => {
|
|
1265
|
+
const symbol = qrl.$symbol$;
|
|
1266
|
+
const chunk = qrl.$chunk$;
|
|
1267
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1268
|
+
if (result) {
|
|
1269
|
+
return result[1];
|
|
1270
|
+
}
|
|
1271
|
+
return chunk;
|
|
1272
|
+
}).filter(Boolean);
|
|
1273
|
+
return [...new Set(bundles2)];
|
|
1274
|
+
};
|
|
1275
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1276
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1277
|
+
if (prefetchStrategy === null) {
|
|
1278
|
+
return [];
|
|
1279
|
+
}
|
|
1280
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1281
|
+
return getBundles(qrls);
|
|
1282
|
+
}
|
|
1283
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1284
|
+
try {
|
|
1285
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1286
|
+
manifest: resolvedManifest.manifest
|
|
1287
|
+
});
|
|
1288
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1289
|
+
} catch (e) {
|
|
1290
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1294
|
+
for (const qrl of qrls) {
|
|
1295
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1296
|
+
if (symbol && symbol.length >= 10) {
|
|
1297
|
+
symbols.add(symbol);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
return [...symbols];
|
|
1301
|
+
}
|
|
1302
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1303
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1304
|
+
return [...new Set(names)];
|
|
1305
|
+
}
|
|
1306
|
+
resetQueue();
|
|
1307
|
+
let probability = 0.99;
|
|
1308
|
+
for (const name of names) {
|
|
1309
|
+
preload(name, probability);
|
|
1310
|
+
probability *= 0.95;
|
|
1311
|
+
}
|
|
1312
|
+
return getQueue();
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1316
|
+
var simplifyPath = (base2, path) => {
|
|
1317
|
+
if (path == null) {
|
|
1318
|
+
return null;
|
|
1319
|
+
}
|
|
1320
|
+
const segments = `${base2}${path}`.split("/");
|
|
1321
|
+
const simplified = [];
|
|
1322
|
+
for (const segment of segments) {
|
|
1323
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1324
|
+
simplified.pop();
|
|
1325
|
+
} else {
|
|
1326
|
+
simplified.push(segment);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return simplified.join("/");
|
|
1330
|
+
};
|
|
1331
|
+
var getBase = (container) => {
|
|
1332
|
+
let base2 = container.$buildBase$;
|
|
1333
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1334
|
+
base2 = import.meta.env.BASE_URL;
|
|
1335
|
+
}
|
|
1336
|
+
return base2;
|
|
1337
|
+
};
|
|
1338
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1339
|
+
const { resolvedManifest } = container;
|
|
1340
|
+
const base2 = getBase(container);
|
|
1341
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1342
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1343
|
+
if (bundleGraphPath) {
|
|
1344
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1345
|
+
}
|
|
1346
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1347
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1348
|
+
debug: options.debug,
|
|
1349
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1350
|
+
} : void 0;
|
|
1351
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1352
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1353
|
+
const opts = [];
|
|
1354
|
+
if (options) {
|
|
1355
|
+
if (options.debug) {
|
|
1356
|
+
opts.push("d:1");
|
|
1357
|
+
}
|
|
1358
|
+
if (options.maxIdlePreloads) {
|
|
1359
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1360
|
+
}
|
|
1361
|
+
if (options.preloadProbability) {
|
|
1362
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1366
|
+
const preloaderLinkAttrs = {
|
|
1367
|
+
rel: "modulepreload",
|
|
1368
|
+
href: preloaderBundle
|
|
1369
|
+
};
|
|
1370
|
+
if (nonce) {
|
|
1371
|
+
preloaderLinkAttrs["nonce"] = nonce;
|
|
1372
|
+
}
|
|
1373
|
+
container.openElement("link", null, preloaderLinkAttrs, null, null, null);
|
|
1374
|
+
container.closeElement();
|
|
1375
|
+
container.openElement(
|
|
1376
|
+
"link",
|
|
1377
|
+
null,
|
|
1378
|
+
{ rel: "preload", href: bundleGraphPath, as: "fetch", crossorigin: "anonymous" },
|
|
1379
|
+
null,
|
|
1380
|
+
null,
|
|
1381
|
+
null
|
|
1382
|
+
);
|
|
1383
|
+
container.closeElement();
|
|
1384
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1385
|
+
const scriptAttrs = {
|
|
1386
|
+
type: "module",
|
|
1387
|
+
async: true,
|
|
1388
|
+
crossorigin: "anonymous"
|
|
1389
|
+
};
|
|
1390
|
+
if (nonce) {
|
|
1391
|
+
scriptAttrs["nonce"] = nonce;
|
|
1392
|
+
}
|
|
1393
|
+
container.openElement("script", null, scriptAttrs, null, null, null);
|
|
1394
|
+
container.write(script);
|
|
1395
|
+
container.closeElement();
|
|
1396
|
+
}
|
|
1397
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1398
|
+
if (corePath) {
|
|
1399
|
+
const linkAttrs = { rel: "modulepreload", href: corePath };
|
|
1400
|
+
if (nonce) {
|
|
1401
|
+
linkAttrs["nonce"] = nonce;
|
|
1402
|
+
}
|
|
1403
|
+
container.openElement("link", null, linkAttrs, null, null, null);
|
|
1404
|
+
container.closeElement();
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1408
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1409
|
+
return null;
|
|
1410
|
+
}
|
|
1411
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1412
|
+
typeof options === "boolean" ? void 0 : options
|
|
1413
|
+
);
|
|
1414
|
+
let allowed = ssrPreloads;
|
|
1415
|
+
const base2 = getBase(container);
|
|
1416
|
+
const links = [];
|
|
1417
|
+
const { resolvedManifest } = container;
|
|
1418
|
+
if (allowed) {
|
|
1419
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1420
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1421
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1422
|
+
let probability = 4;
|
|
1423
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1424
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1425
|
+
if (typeof hrefOrProbability === "string") {
|
|
1426
|
+
if (probability < tenXMinProbability) {
|
|
1427
|
+
break;
|
|
1428
|
+
}
|
|
1429
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1430
|
+
continue;
|
|
1431
|
+
}
|
|
1432
|
+
links.push(hrefOrProbability);
|
|
1433
|
+
if (--allowed === 0) {
|
|
1434
|
+
break;
|
|
1435
|
+
}
|
|
1436
|
+
} else {
|
|
1437
|
+
probability = hrefOrProbability;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1442
|
+
const insertLinks = links.length ? (
|
|
1443
|
+
/**
|
|
1444
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1445
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1446
|
+
* links.
|
|
1447
|
+
*/
|
|
1448
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1449
|
+
) : "";
|
|
1450
|
+
let script = insertLinks;
|
|
1451
|
+
if (preloaderBundle) {
|
|
1452
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1453
|
+
}
|
|
1454
|
+
if (script) {
|
|
1455
|
+
const attrs = { type: "module", async: "true", "q:type": "preload" };
|
|
1456
|
+
if (nonce) {
|
|
1457
|
+
attrs["nonce"] = nonce;
|
|
1458
|
+
}
|
|
1459
|
+
container.openElement("script", null, attrs, null, null, null);
|
|
1460
|
+
container.write(script);
|
|
1461
|
+
container.closeElement();
|
|
1462
|
+
}
|
|
1463
|
+
return null;
|
|
1464
|
+
};
|
|
1465
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1466
|
+
if (opts.preloader !== false) {
|
|
1467
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1468
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1469
|
+
if (preloadBundles.length > 0) {
|
|
1470
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
function normalizePreLoaderOptions(input) {
|
|
1475
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1476
|
+
}
|
|
1477
|
+
var preLoaderOptionsDefault = {
|
|
1478
|
+
ssrPreloads: 7,
|
|
1479
|
+
ssrPreloadProbability: 0.5,
|
|
1480
|
+
debug: false,
|
|
1481
|
+
maxIdlePreloads: 25,
|
|
1482
|
+
preloadProbability: 0.35
|
|
1483
|
+
// deprecated
|
|
1484
|
+
};
|
|
1139
1485
|
|
|
1140
1486
|
// 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
|
|
1487
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",n="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(o=>t.push(...l(o,e))),t},d=(e,t,o,n=!1)=>e.addEventListener(t,o,{capture:n,passive:!1}),b=e=>{_(e),l(e,"[q\\\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,n,r)=>{r&&(t.hasAttribute("preventdefault:"+r)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+r)&&o.stopPropagation());const s=t._qDispatch?.[n];if(s){if("function"==typeof s){const e=s(o,t);f(e)&&await e}else if(s.length)for(let e=0;e<s.length;e++){const n=s[e],r=n?.(o,t);f(r)&&await r}return}const a=t.getAttribute("q-"+n);if(a){const n=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=new URL(r,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:r,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=n.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${r}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(n),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},g=async e=>{const t=m(e.type),o="e:"+t;let n=e.target;for(;n&&n.getAttribute;){const r=y(n,e,o,t),s=e.bubbles&&!e.cancelBubble;f(r)&&await r,n=s&&e.bubbles&&!e.cancelBubble?n.parentElement:null}},E=(e,t)=>{const o=m(t.type),n=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,n,o))},A=async e=>{E(n,e)},C=e=>{E(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),r.has("d:qinit")){r.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}r.has("d:qidle")&&(r.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),r.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach(e=>{a.observe(e),e.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}=w(a);e===o?d(t,i,C,!0):s.forEach(t=>d(t,i,e===n?A:g,!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}=w(e);t!==o&&d(a,r,t===n?A:g,!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())';
|
|
1488
|
+
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 nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\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 for (const qrl of attrValue.split("|")) {\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 querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]").forEach(\n (el) => 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 querySelectorAll("[q-d\\\\:qinit]").forEach((el) => {\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 querySelectorAll("[q-d\\\\:qidle]").forEach((el) => {\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 (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\n }));\n querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach((el) => {\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}';
|
|
1489
|
+
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))}}}}`;
|
|
1490
|
+
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1491
|
+
const executorScript = document.currentScript;
|
|
1492
|
+
if (executorScript) {
|
|
1493
|
+
const container = executorScript.closest(
|
|
1494
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1495
|
+
);
|
|
1496
|
+
if (container) {
|
|
1497
|
+
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1498
|
+
if (script) {
|
|
1499
|
+
const data = JSON.parse(script.textContent || "[]");
|
|
1500
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1501
|
+
let currentNode = walker.currentNode;
|
|
1502
|
+
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1503
|
+
for (let i = 0; i < data.length; i += 3) {
|
|
1504
|
+
const elementIdx = data[i];
|
|
1505
|
+
const attrName = data[i + 1];
|
|
1506
|
+
let value = data[i + 2];
|
|
1507
|
+
while (currentNodeIdx < elementIdx) {
|
|
1508
|
+
currentNode = walker.nextNode();
|
|
1509
|
+
if (!currentNode) {
|
|
1510
|
+
break;
|
|
1511
|
+
}
|
|
1512
|
+
if (currentNode.hasAttribute(":")) {
|
|
1513
|
+
currentNodeIdx++;
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
const element = currentNode;
|
|
1517
|
+
if (value == null || value === false) {
|
|
1518
|
+
element.removeAttribute(attrName);
|
|
1519
|
+
} else {
|
|
1520
|
+
if (typeof value === "boolean") {
|
|
1521
|
+
value = "";
|
|
1522
|
+
}
|
|
1523
|
+
element.setAttribute(attrName, value);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}`;
|
|
1143
1529
|
function getQwikLoaderScript(opts = {}) {
|
|
1144
1530
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1145
1531
|
}
|
|
@@ -1148,50 +1534,56 @@ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
|
1148
1534
|
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1149
1535
|
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1150
1536
|
}
|
|
1537
|
+
function getQwikBackpatchExecutorScript(opts = {}) {
|
|
1538
|
+
return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
|
|
1539
|
+
}
|
|
1151
1540
|
|
|
1152
1541
|
// packages/qwik/src/server/ssr-node.ts
|
|
1153
1542
|
import {
|
|
1154
1543
|
_isJSXNode as isJSXNode,
|
|
1155
|
-
|
|
1544
|
+
_EMPTY_OBJ,
|
|
1156
1545
|
_EFFECT_BACK_REF
|
|
1157
|
-
} from "@qwik.dev/core";
|
|
1158
|
-
import { isDev as
|
|
1546
|
+
} from "@qwik.dev/core/internal";
|
|
1547
|
+
import { isDev as isDev6 } from "@qwik.dev/core/build";
|
|
1159
1548
|
var SsrNode = class {
|
|
1160
|
-
constructor(
|
|
1549
|
+
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1550
|
+
this.parentComponent = parentComponent;
|
|
1161
1551
|
this.attributesIndex = attributesIndex;
|
|
1162
1552
|
this.cleanupQueue = cleanupQueue;
|
|
1163
1553
|
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);
|
|
1554
|
+
this.currentFile = currentFile;
|
|
1178
1555
|
this.id = id;
|
|
1179
|
-
this.
|
|
1180
|
-
|
|
1556
|
+
this.flags = 1 /* Updatable */;
|
|
1557
|
+
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
|
|
1558
|
+
this.parentComponent?.addChild(this);
|
|
1559
|
+
if (isDev6 && id.indexOf("undefined") != -1) {
|
|
1181
1560
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1182
1561
|
}
|
|
1183
1562
|
}
|
|
1563
|
+
__brand__ = "SsrNode";
|
|
1564
|
+
/**
|
|
1565
|
+
* ID which the deserialize will use to retrieve the node.
|
|
1566
|
+
*
|
|
1567
|
+
* @param id - Unique id for the node.
|
|
1568
|
+
*/
|
|
1569
|
+
id;
|
|
1570
|
+
flags;
|
|
1571
|
+
dirty = 0 /* NONE */;
|
|
1572
|
+
children = null;
|
|
1573
|
+
attrs;
|
|
1574
|
+
/** Local props which don't serialize; */
|
|
1575
|
+
localProps = null;
|
|
1184
1576
|
get [_EFFECT_BACK_REF]() {
|
|
1185
1577
|
return this.getProp(QBackRefs);
|
|
1186
1578
|
}
|
|
1187
1579
|
setProp(name, value) {
|
|
1188
|
-
if (this.attrs ===
|
|
1580
|
+
if (this.attrs === _EMPTY_OBJ) {
|
|
1189
1581
|
this.setEmptyArrayAsVNodeDataAttributes();
|
|
1190
1582
|
}
|
|
1191
1583
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1192
|
-
|
|
1584
|
+
(this.localProps ||= {})[name] = value;
|
|
1193
1585
|
} else {
|
|
1194
|
-
|
|
1586
|
+
this.attrs[name] = value;
|
|
1195
1587
|
}
|
|
1196
1588
|
if (name == ELEMENT_SEQ && value) {
|
|
1197
1589
|
this.cleanupQueue.push(value);
|
|
@@ -1199,29 +1591,29 @@ var SsrNode = class {
|
|
|
1199
1591
|
}
|
|
1200
1592
|
setEmptyArrayAsVNodeDataAttributes() {
|
|
1201
1593
|
if (this.attributesIndex >= 0) {
|
|
1202
|
-
this.vnodeData[this.attributesIndex] =
|
|
1594
|
+
this.vnodeData[this.attributesIndex] = {};
|
|
1203
1595
|
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1204
1596
|
} else {
|
|
1205
1597
|
const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
|
|
1206
|
-
this.vnodeData.splice(newAttributesIndex, 0,
|
|
1598
|
+
this.vnodeData.splice(newAttributesIndex, 0, {});
|
|
1207
1599
|
this.attributesIndex = newAttributesIndex;
|
|
1208
1600
|
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1209
1601
|
}
|
|
1210
1602
|
}
|
|
1211
1603
|
getProp(name) {
|
|
1212
1604
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1213
|
-
return this.localProps ?
|
|
1605
|
+
return this.localProps ? this.localProps[name] ?? null : null;
|
|
1214
1606
|
} else {
|
|
1215
|
-
return
|
|
1607
|
+
return this.attrs[name] ?? null;
|
|
1216
1608
|
}
|
|
1217
1609
|
}
|
|
1218
1610
|
removeProp(name) {
|
|
1219
1611
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1220
1612
|
if (this.localProps) {
|
|
1221
|
-
|
|
1613
|
+
delete this.localProps[name];
|
|
1222
1614
|
}
|
|
1223
1615
|
} else {
|
|
1224
|
-
|
|
1616
|
+
delete this.attrs[name];
|
|
1225
1617
|
}
|
|
1226
1618
|
}
|
|
1227
1619
|
addChild(child) {
|
|
@@ -1230,35 +1622,46 @@ var SsrNode = class {
|
|
|
1230
1622
|
}
|
|
1231
1623
|
this.children.push(child);
|
|
1232
1624
|
}
|
|
1625
|
+
setTreeNonUpdatable() {
|
|
1626
|
+
if (this.flags & 1 /* Updatable */) {
|
|
1627
|
+
this.flags &= ~1 /* Updatable */;
|
|
1628
|
+
if (this.children) {
|
|
1629
|
+
for (const child of this.children) {
|
|
1630
|
+
child.setTreeNonUpdatable();
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1233
1635
|
toString() {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
const key
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
if (i < this.attrs.length - 2) {
|
|
1636
|
+
if (isDev6) {
|
|
1637
|
+
let stringifiedAttrs = "";
|
|
1638
|
+
for (const key in this.attrs) {
|
|
1639
|
+
const value = this.attrs[key];
|
|
1640
|
+
stringifiedAttrs += `${key}=`;
|
|
1641
|
+
stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
|
|
1241
1642
|
stringifiedAttrs += ", ";
|
|
1242
1643
|
}
|
|
1644
|
+
return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
|
|
1645
|
+
} else {
|
|
1646
|
+
return `<SSRNode id="${this.id}" />`;
|
|
1243
1647
|
}
|
|
1244
|
-
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1245
1648
|
}
|
|
1246
1649
|
};
|
|
1247
1650
|
var DomRef = class {
|
|
1248
1651
|
constructor($ssrNode$) {
|
|
1249
1652
|
this.$ssrNode$ = $ssrNode$;
|
|
1250
|
-
__publicField(this, "__brand__", "DomRef");
|
|
1251
1653
|
}
|
|
1654
|
+
__brand__ = "DomRef";
|
|
1252
1655
|
};
|
|
1253
1656
|
var SsrComponentFrame = class {
|
|
1254
1657
|
constructor(componentNode) {
|
|
1255
1658
|
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
1659
|
}
|
|
1660
|
+
slots = [];
|
|
1661
|
+
projectionDepth = 0;
|
|
1662
|
+
scopedStyleIds = /* @__PURE__ */ new Set();
|
|
1663
|
+
projectionScopedStyle = null;
|
|
1664
|
+
projectionComponentFrame = null;
|
|
1262
1665
|
distributeChildrenIntoSlots(children, projectionScopedStyle, projectionComponentFrame) {
|
|
1263
1666
|
this.projectionScopedStyle = projectionScopedStyle;
|
|
1264
1667
|
this.projectionComponentFrame = projectionComponentFrame;
|
|
@@ -1309,14 +1712,7 @@ var SsrComponentFrame = class {
|
|
|
1309
1712
|
const children = mapApp_remove(this.slots, slotName, 0);
|
|
1310
1713
|
this.componentNode.setProp(slotName, projectionNode.id);
|
|
1311
1714
|
projectionNode.setProp(QSlotParent, this.componentNode.id);
|
|
1312
|
-
return children;
|
|
1313
|
-
}
|
|
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
|
-
}
|
|
1715
|
+
return children;
|
|
1320
1716
|
}
|
|
1321
1717
|
};
|
|
1322
1718
|
|
|
@@ -1352,6 +1748,10 @@ var allowedContent = (state) => {
|
|
|
1352
1748
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1353
1749
|
case 1026 /* PHRASING_CONTAINER */:
|
|
1354
1750
|
return ["phrasing content", "<a>, <b>, <img>, <input> ... (no <div>, <p> ...)"];
|
|
1751
|
+
case 2050 /* PICTURE */:
|
|
1752
|
+
return ["picture content", "<source>, <img>"];
|
|
1753
|
+
case 4098 /* BUTTON */:
|
|
1754
|
+
return ["button content", "phrasing content except interactive elements"];
|
|
1355
1755
|
case 1 /* DOCUMENT */:
|
|
1356
1756
|
return ["document", "<html>"];
|
|
1357
1757
|
}
|
|
@@ -1393,6 +1793,10 @@ function isTagAllowed(state, tag) {
|
|
|
1393
1793
|
return isInPhrasing(tag, true);
|
|
1394
1794
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1395
1795
|
return isInPhrasing(tag, false);
|
|
1796
|
+
case 2050 /* PICTURE */:
|
|
1797
|
+
return isInPicture(tag);
|
|
1798
|
+
case 4098 /* BUTTON */:
|
|
1799
|
+
return isInButton(tag);
|
|
1396
1800
|
case 1 /* DOCUMENT */:
|
|
1397
1801
|
if (tag === "html") {
|
|
1398
1802
|
return 32 /* HTML */;
|
|
@@ -1472,9 +1876,12 @@ function isInAnything(text) {
|
|
|
1472
1876
|
case "body":
|
|
1473
1877
|
return 0 /* NOT_ALLOWED */;
|
|
1474
1878
|
case "button":
|
|
1879
|
+
return 4098 /* BUTTON */;
|
|
1475
1880
|
case "input":
|
|
1476
1881
|
case "textarea":
|
|
1477
1882
|
return 514 /* PHRASING_INSIDE_INPUT */;
|
|
1883
|
+
case "picture":
|
|
1884
|
+
return 2050 /* PICTURE */;
|
|
1478
1885
|
default:
|
|
1479
1886
|
return 10 /* ANYTHING */;
|
|
1480
1887
|
}
|
|
@@ -1489,6 +1896,8 @@ function isInTable(text) {
|
|
|
1489
1896
|
case "tbody":
|
|
1490
1897
|
case "tfoot":
|
|
1491
1898
|
return 8192 /* TABLE_BODY */;
|
|
1899
|
+
case "script":
|
|
1900
|
+
return 2 /* TEXT */;
|
|
1492
1901
|
default:
|
|
1493
1902
|
return 0 /* NOT_ALLOWED */;
|
|
1494
1903
|
}
|
|
@@ -1497,6 +1906,8 @@ function isInTableBody(text) {
|
|
|
1497
1906
|
switch (text) {
|
|
1498
1907
|
case "tr":
|
|
1499
1908
|
return 16384 /* TABLE_ROW */;
|
|
1909
|
+
case "script":
|
|
1910
|
+
return 2 /* TEXT */;
|
|
1500
1911
|
default:
|
|
1501
1912
|
return 0 /* NOT_ALLOWED */;
|
|
1502
1913
|
}
|
|
@@ -1506,6 +1917,8 @@ function isInTableRow(text) {
|
|
|
1506
1917
|
case "td":
|
|
1507
1918
|
case "th":
|
|
1508
1919
|
return 10 /* ANYTHING */;
|
|
1920
|
+
case "script":
|
|
1921
|
+
return 2 /* TEXT */;
|
|
1509
1922
|
default:
|
|
1510
1923
|
return 0 /* NOT_ALLOWED */;
|
|
1511
1924
|
}
|
|
@@ -1514,16 +1927,43 @@ function isInTableColGroup(text) {
|
|
|
1514
1927
|
switch (text) {
|
|
1515
1928
|
case "col":
|
|
1516
1929
|
return 4 /* EMPTY */;
|
|
1930
|
+
case "script":
|
|
1931
|
+
return 2 /* TEXT */;
|
|
1932
|
+
default:
|
|
1933
|
+
return 0 /* NOT_ALLOWED */;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
function isInPicture(text) {
|
|
1937
|
+
switch (text) {
|
|
1938
|
+
case "source":
|
|
1939
|
+
return 4 /* EMPTY */;
|
|
1940
|
+
case "img":
|
|
1941
|
+
return 4 /* EMPTY */;
|
|
1942
|
+
case "script":
|
|
1943
|
+
return 2 /* TEXT */;
|
|
1517
1944
|
default:
|
|
1518
1945
|
return 0 /* NOT_ALLOWED */;
|
|
1519
1946
|
}
|
|
1520
1947
|
}
|
|
1948
|
+
function isInButton(text) {
|
|
1949
|
+
switch (text) {
|
|
1950
|
+
case "button":
|
|
1951
|
+
case "input":
|
|
1952
|
+
case "textarea":
|
|
1953
|
+
case "select":
|
|
1954
|
+
case "a":
|
|
1955
|
+
return 0 /* NOT_ALLOWED */;
|
|
1956
|
+
case "picture":
|
|
1957
|
+
return 2050 /* PICTURE */;
|
|
1958
|
+
default:
|
|
1959
|
+
return isInPhrasing(text, false);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1521
1962
|
function isInPhrasing(text, allowInput) {
|
|
1522
1963
|
switch (text) {
|
|
1523
1964
|
case "svg":
|
|
1524
1965
|
case "math":
|
|
1525
1966
|
return 1026 /* PHRASING_CONTAINER */;
|
|
1526
|
-
case "button":
|
|
1527
1967
|
case "input":
|
|
1528
1968
|
case "textarea":
|
|
1529
1969
|
return allowInput ? 514 /* PHRASING_INSIDE_INPUT */ : 0 /* NOT_ALLOWED */;
|
|
@@ -1535,6 +1975,7 @@ function isInPhrasing(text, allowInput) {
|
|
|
1535
1975
|
case "bdi":
|
|
1536
1976
|
case "bdo":
|
|
1537
1977
|
case "br":
|
|
1978
|
+
case "button":
|
|
1538
1979
|
case "canvas":
|
|
1539
1980
|
case "cite":
|
|
1540
1981
|
case "code":
|
|
@@ -1562,13 +2003,11 @@ function isInPhrasing(text, allowInput) {
|
|
|
1562
2003
|
case "object":
|
|
1563
2004
|
case "option":
|
|
1564
2005
|
case "output":
|
|
1565
|
-
case "picture":
|
|
1566
2006
|
case "progress":
|
|
1567
2007
|
case "q":
|
|
1568
2008
|
case "ruby":
|
|
1569
2009
|
case "s":
|
|
1570
2010
|
case "samp":
|
|
1571
|
-
case "script":
|
|
1572
2011
|
case "select":
|
|
1573
2012
|
case "slot":
|
|
1574
2013
|
case "small":
|
|
@@ -1583,8 +2022,11 @@ function isInPhrasing(text, allowInput) {
|
|
|
1583
2022
|
case "video":
|
|
1584
2023
|
case "wbr":
|
|
1585
2024
|
return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
|
|
2025
|
+
case "script":
|
|
1586
2026
|
case "style":
|
|
1587
2027
|
return 2 /* TEXT */;
|
|
2028
|
+
case "picture":
|
|
2029
|
+
return 2050 /* PICTURE */;
|
|
1588
2030
|
default:
|
|
1589
2031
|
return 0 /* NOT_ALLOWED */;
|
|
1590
2032
|
}
|
|
@@ -1622,16 +2064,16 @@ function vNodeData_closeFragment(vNodeData) {
|
|
|
1622
2064
|
vNodeData.push(CLOSE_FRAGMENT);
|
|
1623
2065
|
}
|
|
1624
2066
|
function vNodeData_openElement(vNodeData) {
|
|
1625
|
-
vNodeData.push(
|
|
2067
|
+
vNodeData.push({}, WRITE_ELEMENT_ATTRS);
|
|
1626
2068
|
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
1627
2069
|
}
|
|
1628
|
-
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
2070
|
+
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
|
|
1629
2071
|
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1630
2072
|
const stack = [-1];
|
|
1631
2073
|
let attributesIndex = -1;
|
|
1632
2074
|
for (let i = 1; i < vNodeData.length; i++) {
|
|
1633
2075
|
const value = vNodeData[i];
|
|
1634
|
-
if (
|
|
2076
|
+
if (typeof value === "object" && value !== null) {
|
|
1635
2077
|
attributesIndex = i;
|
|
1636
2078
|
i++;
|
|
1637
2079
|
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
@@ -1644,278 +2086,54 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1644
2086
|
const numberOfElements = 0 - value;
|
|
1645
2087
|
stack[stack.length - 1] += numberOfElements;
|
|
1646
2088
|
} else {
|
|
1647
|
-
stack[stack.length - 1]++;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
let refId = String(depthFirstElementIdx);
|
|
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);
|
|
2089
|
+
stack[stack.length - 1]++;
|
|
1886
2090
|
}
|
|
1887
|
-
container.openElement("script", null, attrs);
|
|
1888
|
-
container.writer.write(script);
|
|
1889
|
-
container.closeElement();
|
|
1890
2091
|
}
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
2092
|
+
let refId = depthFirstElementIdx + "";
|
|
2093
|
+
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
2094
|
+
for (let i = 0; i < stack.length; i++) {
|
|
2095
|
+
const childCount = stack[i];
|
|
2096
|
+
if (childCount >= 0) {
|
|
2097
|
+
refId += encodeAsAlphanumeric(childCount);
|
|
2098
|
+
}
|
|
1899
2099
|
}
|
|
1900
2100
|
}
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
2101
|
+
return new SsrNode(
|
|
2102
|
+
currentComponentNode,
|
|
2103
|
+
refId,
|
|
2104
|
+
attributesIndex,
|
|
2105
|
+
cleanupQueue,
|
|
2106
|
+
vNodeData,
|
|
2107
|
+
currentFile
|
|
2108
|
+
);
|
|
2109
|
+
}
|
|
2110
|
+
var ALPHANUMERIC = [];
|
|
2111
|
+
function encodeAsAlphanumeric(value) {
|
|
2112
|
+
while (ALPHANUMERIC.length <= value) {
|
|
2113
|
+
let value2 = ALPHANUMERIC.length;
|
|
2114
|
+
let text = "";
|
|
2115
|
+
do {
|
|
2116
|
+
text = String.fromCharCode(
|
|
2117
|
+
(text.length === 0 ? 65 : 97) + value2 % 26
|
|
2118
|
+
/* A-Z */
|
|
2119
|
+
) + text;
|
|
2120
|
+
value2 = Math.floor(
|
|
2121
|
+
value2 / 26
|
|
2122
|
+
/* A-Z */
|
|
2123
|
+
);
|
|
2124
|
+
} while (value2 !== 0);
|
|
2125
|
+
ALPHANUMERIC.push(text);
|
|
2126
|
+
}
|
|
2127
|
+
return ALPHANUMERIC[value];
|
|
1904
2128
|
}
|
|
1905
|
-
var preLoaderOptionsDefault = {
|
|
1906
|
-
ssrPreloads: 7,
|
|
1907
|
-
ssrPreloadProbability: 0.5,
|
|
1908
|
-
debug: false,
|
|
1909
|
-
maxIdlePreloads: 25,
|
|
1910
|
-
preloadProbability: 0.35
|
|
1911
|
-
};
|
|
1912
2129
|
|
|
1913
2130
|
// packages/qwik/src/server/ssr-container.ts
|
|
1914
2131
|
function ssrCreateContainer(opts) {
|
|
1915
|
-
opts.renderOptions
|
|
2132
|
+
opts.renderOptions ||= {};
|
|
1916
2133
|
return new SSRContainer({
|
|
1917
2134
|
tagName: opts.tagName || "div",
|
|
1918
2135
|
writer: opts.writer || new StringBufferWriter(),
|
|
2136
|
+
streamHandler: opts.streamHandler,
|
|
1919
2137
|
locale: opts.locale || "",
|
|
1920
2138
|
timing: opts.timing || {
|
|
1921
2139
|
firstFlush: 0,
|
|
@@ -1934,9 +2152,7 @@ function ssrCreateContainer(opts) {
|
|
|
1934
2152
|
});
|
|
1935
2153
|
}
|
|
1936
2154
|
var StringBufferWriter = class {
|
|
1937
|
-
|
|
1938
|
-
__publicField(this, "buffer", []);
|
|
1939
|
-
}
|
|
2155
|
+
buffer = [];
|
|
1940
2156
|
write(text) {
|
|
1941
2157
|
this.buffer.push(text);
|
|
1942
2158
|
}
|
|
@@ -1945,61 +2161,59 @@ var StringBufferWriter = class {
|
|
|
1945
2161
|
}
|
|
1946
2162
|
};
|
|
1947
2163
|
var EMPTY_OBJ = {};
|
|
2164
|
+
var QTemplateProps = {
|
|
2165
|
+
hidden: true,
|
|
2166
|
+
"aria-hidden": true
|
|
2167
|
+
};
|
|
1948
2168
|
var SSRContainer = class extends _SharedContainer {
|
|
2169
|
+
tag;
|
|
2170
|
+
isHtml;
|
|
2171
|
+
writer;
|
|
2172
|
+
streamHandler;
|
|
2173
|
+
timing;
|
|
2174
|
+
size = 0;
|
|
2175
|
+
resolvedManifest;
|
|
2176
|
+
symbolToChunkResolver;
|
|
2177
|
+
renderOptions;
|
|
2178
|
+
serializationCtx;
|
|
2179
|
+
/**
|
|
2180
|
+
* We use this to append additional nodes in the head node
|
|
2181
|
+
*
|
|
2182
|
+
* - From manifest injections
|
|
2183
|
+
* - From useStyles and useScopedStyles hooks
|
|
2184
|
+
*/
|
|
2185
|
+
additionalHeadNodes = new Array();
|
|
2186
|
+
/**
|
|
2187
|
+
* We use this to append additional nodes in the body node
|
|
2188
|
+
*
|
|
2189
|
+
* - From manifest injections
|
|
2190
|
+
*/
|
|
2191
|
+
additionalBodyNodes = new Array();
|
|
2192
|
+
lastNode = null;
|
|
2193
|
+
currentComponentNode = null;
|
|
2194
|
+
styleIds = /* @__PURE__ */ new Set();
|
|
2195
|
+
isBackpatchExecutorEmitted = false;
|
|
2196
|
+
backpatchMap = /* @__PURE__ */ new Map();
|
|
2197
|
+
currentElementFrame = null;
|
|
2198
|
+
renderTimer;
|
|
2199
|
+
/**
|
|
2200
|
+
* Current element index.
|
|
2201
|
+
*
|
|
2202
|
+
* This number must match the depth-first traversal of the DOM elements as returned by the
|
|
2203
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
2204
|
+
*/
|
|
2205
|
+
depthFirstElementCount = -1;
|
|
2206
|
+
vNodeDatas = [];
|
|
2207
|
+
componentStack = [];
|
|
2208
|
+
cleanupQueue = [];
|
|
2209
|
+
emitContainerDataFrame = null;
|
|
2210
|
+
$instanceHash$ = randomStr();
|
|
2211
|
+
// Temporary flag to find missing roots after the state was serialized
|
|
2212
|
+
$noMoreRoots$ = false;
|
|
2213
|
+
qlInclude;
|
|
2214
|
+
promiseAttributes = null;
|
|
1949
2215
|
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);
|
|
2216
|
+
super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
|
|
2003
2217
|
this.symbolToChunkResolver = (symbol) => {
|
|
2004
2218
|
const idx = symbol.lastIndexOf("_");
|
|
2005
2219
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2015,10 +2229,20 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2015
2229
|
this.tag = opts.tagName;
|
|
2016
2230
|
this.isHtml = opts.tagName === "html";
|
|
2017
2231
|
this.writer = opts.writer;
|
|
2232
|
+
this.streamHandler = opts.streamHandler;
|
|
2018
2233
|
this.timing = opts.timing;
|
|
2019
2234
|
this.$buildBase$ = opts.buildBase;
|
|
2020
2235
|
this.resolvedManifest = opts.resolvedManifest;
|
|
2021
2236
|
this.renderOptions = opts.renderOptions;
|
|
2237
|
+
this.$currentUniqueId$ = 1e5;
|
|
2238
|
+
const qlOpt = this.renderOptions.qwikLoader;
|
|
2239
|
+
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 */;
|
|
2240
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2241
|
+
const qwikLoaderChunk = this.resolvedManifest?.manifest.qwikLoader;
|
|
2242
|
+
if (!qwikLoaderChunk) {
|
|
2243
|
+
this.qlInclude = 1 /* Inline */;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2022
2246
|
this.$processInjectionsFromManifest$();
|
|
2023
2247
|
}
|
|
2024
2248
|
ensureProjectionResolved(_host) {
|
|
@@ -2026,40 +2250,50 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2026
2250
|
handleError(err, _$host$) {
|
|
2027
2251
|
throw err;
|
|
2028
2252
|
}
|
|
2253
|
+
addBackpatchEntry(ssrNodeId, attrName, serializedValue) {
|
|
2254
|
+
const elementIndex = parseInt(ssrNodeId, 10);
|
|
2255
|
+
const entry = {
|
|
2256
|
+
attrName,
|
|
2257
|
+
value: serializedValue
|
|
2258
|
+
};
|
|
2259
|
+
const entries = this.backpatchMap.get(elementIndex) || [];
|
|
2260
|
+
entries.push(entry);
|
|
2261
|
+
this.backpatchMap.set(elementIndex, entries);
|
|
2262
|
+
}
|
|
2029
2263
|
async render(jsx) {
|
|
2030
2264
|
this.openContainer();
|
|
2031
|
-
await
|
|
2265
|
+
await this.renderJSX(jsx, {
|
|
2032
2266
|
currentStyleScoped: null,
|
|
2033
2267
|
parentComponentFrame: this.getComponentFrame()
|
|
2034
2268
|
});
|
|
2035
2269
|
await this.closeContainer();
|
|
2036
2270
|
}
|
|
2271
|
+
async renderJSX(jsx, options) {
|
|
2272
|
+
await _walkJSX(this, jsx, options);
|
|
2273
|
+
}
|
|
2037
2274
|
setContext(host, context, value) {
|
|
2038
2275
|
const ssrNode = host;
|
|
2039
2276
|
let ctx = ssrNode.getProp(QCtxAttr);
|
|
2040
|
-
if (
|
|
2277
|
+
if (ctx == null) {
|
|
2041
2278
|
ssrNode.setProp(QCtxAttr, ctx = []);
|
|
2042
2279
|
}
|
|
2043
|
-
mapArray_set(ctx, context.id, value, 0);
|
|
2280
|
+
mapArray_set(ctx, context.id, value, 0, true);
|
|
2044
2281
|
this.addRoot(ssrNode);
|
|
2045
2282
|
}
|
|
2046
2283
|
resolveContext(host, contextId) {
|
|
2047
2284
|
let ssrNode = host;
|
|
2048
2285
|
while (ssrNode) {
|
|
2049
2286
|
const ctx = ssrNode.getProp(QCtxAttr);
|
|
2050
|
-
if (ctx) {
|
|
2051
|
-
|
|
2052
|
-
if (value) {
|
|
2053
|
-
return value;
|
|
2054
|
-
}
|
|
2287
|
+
if (ctx != null && mapArray_has(ctx, contextId.id, 0)) {
|
|
2288
|
+
return mapArray_get(ctx, contextId.id, 0);
|
|
2055
2289
|
}
|
|
2056
|
-
ssrNode = ssrNode.
|
|
2290
|
+
ssrNode = ssrNode.parentComponent;
|
|
2057
2291
|
}
|
|
2058
2292
|
return void 0;
|
|
2059
2293
|
}
|
|
2060
2294
|
getParentHost(host) {
|
|
2061
2295
|
const ssrNode = host;
|
|
2062
|
-
return ssrNode.
|
|
2296
|
+
return ssrNode.parentComponent;
|
|
2063
2297
|
}
|
|
2064
2298
|
setHostProp(host, name, value) {
|
|
2065
2299
|
const ssrNode = host;
|
|
@@ -2082,52 +2316,85 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2082
2316
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
2083
2317
|
containerAttributes[QRuntimeAttr] = "2";
|
|
2084
2318
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
2085
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
2319
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev7 ? "ssr-dev" : "ssr");
|
|
2086
2320
|
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
2087
2321
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
2088
2322
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
2089
2323
|
containerAttributes[QInstanceAttr] = this.$instanceHash$;
|
|
2090
2324
|
this.$serverData$.containerAttributes = containerAttributes;
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
},
|
|
2096
|
-
[]
|
|
2097
|
-
);
|
|
2098
|
-
this.openElement(this.tag, containerAttributeArray);
|
|
2325
|
+
this.openElement(this.tag, null, containerAttributes);
|
|
2326
|
+
if (!this.isHtml) {
|
|
2327
|
+
this.emitContainerDataFrame = this.currentElementFrame;
|
|
2328
|
+
}
|
|
2099
2329
|
}
|
|
2100
2330
|
/** Renders closing tag for current container */
|
|
2101
2331
|
closeContainer() {
|
|
2102
2332
|
return this.closeElement();
|
|
2103
2333
|
}
|
|
2334
|
+
$noScriptHere$ = 0;
|
|
2104
2335
|
/** Renders opening tag for DOM element */
|
|
2105
|
-
openElement(elementName, varAttrs, constAttrs, currentFile) {
|
|
2336
|
+
openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
|
|
2337
|
+
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2338
|
+
if (
|
|
2339
|
+
// don't append qwik loader before qwik style elements
|
|
2340
|
+
// it will confuse the resuming, because styles are expected to be the first nodes in subtree
|
|
2341
|
+
!isQwikStyle && this.qlInclude === 1 /* Inline */
|
|
2342
|
+
) {
|
|
2343
|
+
if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
|
|
2344
|
+
this.emitQwikLoaderInline();
|
|
2345
|
+
} else if (elementName === "noscript" || elementName === "template") {
|
|
2346
|
+
this.$noScriptHere$++;
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2106
2349
|
let innerHTML = void 0;
|
|
2107
2350
|
this.lastNode = null;
|
|
2108
|
-
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2109
2351
|
if (!isQwikStyle && this.currentElementFrame) {
|
|
2110
2352
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2111
2353
|
}
|
|
2112
2354
|
this.createAndPushFrame(elementName, this.depthFirstElementCount++, currentFile);
|
|
2355
|
+
if (this.isHtml && elementName === "body" && this.emitContainerDataFrame === null) {
|
|
2356
|
+
this.emitContainerDataFrame = this.currentElementFrame;
|
|
2357
|
+
}
|
|
2113
2358
|
vNodeData_openElement(this.currentElementFrame.vNodeData);
|
|
2114
|
-
this.write(
|
|
2359
|
+
this.write(LT);
|
|
2115
2360
|
this.write(elementName);
|
|
2361
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2116
2362
|
if (varAttrs) {
|
|
2117
|
-
innerHTML = this.writeAttrs(
|
|
2363
|
+
innerHTML = this.writeAttrs(
|
|
2364
|
+
elementName,
|
|
2365
|
+
varAttrs,
|
|
2366
|
+
false,
|
|
2367
|
+
styleScopedId,
|
|
2368
|
+
currentFile,
|
|
2369
|
+
hasMovedCaptures
|
|
2370
|
+
);
|
|
2118
2371
|
}
|
|
2119
2372
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2373
|
+
if (key !== null) {
|
|
2374
|
+
this.write(`="${key}"`);
|
|
2375
|
+
} else if (import.meta.env.TEST) {
|
|
2376
|
+
this.write(EMPTY_ATTR);
|
|
2377
|
+
}
|
|
2378
|
+
if (constAttrs && !isObjectEmpty(constAttrs)) {
|
|
2379
|
+
innerHTML = this.writeAttrs(
|
|
2380
|
+
elementName,
|
|
2381
|
+
constAttrs,
|
|
2382
|
+
true,
|
|
2383
|
+
styleScopedId,
|
|
2384
|
+
currentFile,
|
|
2385
|
+
hasMovedCaptures
|
|
2386
|
+
) || innerHTML;
|
|
2387
|
+
}
|
|
2388
|
+
this.write(GT);
|
|
2389
|
+
if (lastNode) {
|
|
2390
|
+
lastNode.setTreeNonUpdatable();
|
|
2123
2391
|
}
|
|
2124
|
-
this.write(">");
|
|
2125
|
-
this.lastNode = null;
|
|
2126
2392
|
return innerHTML;
|
|
2127
2393
|
}
|
|
2128
2394
|
/** Renders closing tag for DOM element */
|
|
2129
2395
|
closeElement() {
|
|
2130
|
-
if (this.
|
|
2396
|
+
if (this.currentElementFrame === this.emitContainerDataFrame) {
|
|
2397
|
+
this.emitContainerDataFrame = null;
|
|
2131
2398
|
this.onRenderDone();
|
|
2132
2399
|
const snapshotTimer = createTimer();
|
|
2133
2400
|
return maybeThen(
|
|
@@ -2139,16 +2406,6 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2139
2406
|
}
|
|
2140
2407
|
this._closeElement();
|
|
2141
2408
|
}
|
|
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
2409
|
onRenderDone() {
|
|
2153
2410
|
this.drainCleanupQueue();
|
|
2154
2411
|
this.timing.render = this.renderTimer();
|
|
@@ -2170,11 +2427,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2170
2427
|
const currentFrame = this.popFrame();
|
|
2171
2428
|
const elementName = currentFrame.elementName;
|
|
2172
2429
|
if (!isSelfClosingTag(elementName)) {
|
|
2173
|
-
this.write(
|
|
2430
|
+
this.write(CLOSE_TAG);
|
|
2174
2431
|
this.write(elementName);
|
|
2175
|
-
this.write(
|
|
2432
|
+
this.write(GT);
|
|
2176
2433
|
}
|
|
2177
2434
|
this.lastNode = null;
|
|
2435
|
+
if (this.qlInclude === 1 /* Inline */) {
|
|
2436
|
+
if (elementName === "noscript" || elementName === "template") {
|
|
2437
|
+
this.$noScriptHere$--;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2178
2440
|
}
|
|
2179
2441
|
/** Writes opening data to vNodeData for fragment boundaries */
|
|
2180
2442
|
openFragment(attrs) {
|
|
@@ -2185,6 +2447,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2185
2447
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
2186
2448
|
closeFragment() {
|
|
2187
2449
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
2450
|
+
if (this.currentComponentNode) {
|
|
2451
|
+
this.currentComponentNode.setTreeNonUpdatable();
|
|
2452
|
+
}
|
|
2188
2453
|
this.lastNode = null;
|
|
2189
2454
|
}
|
|
2190
2455
|
openProjection(attrs) {
|
|
@@ -2224,12 +2489,37 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2224
2489
|
const localProjectionDepth = this.getComponentFrame()?.projectionDepth || 0;
|
|
2225
2490
|
return this.getComponentFrame(localProjectionDepth);
|
|
2226
2491
|
}
|
|
2227
|
-
/** Writes closing data to vNodeData for component boundaries and
|
|
2228
|
-
closeComponent() {
|
|
2492
|
+
/** Writes closing data to vNodeData for component boundaries and emit unclaimed projections inline */
|
|
2493
|
+
async closeComponent() {
|
|
2229
2494
|
const componentFrame = this.componentStack.pop();
|
|
2230
|
-
|
|
2495
|
+
await this.emitUnclaimedProjectionForComponent(componentFrame);
|
|
2231
2496
|
this.closeFragment();
|
|
2232
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2497
|
+
this.currentComponentNode = this.currentComponentNode?.parentComponent || null;
|
|
2498
|
+
}
|
|
2499
|
+
async emitUnclaimedProjectionForComponent(componentFrame) {
|
|
2500
|
+
if (componentFrame.slots.length === 0) {
|
|
2501
|
+
return;
|
|
2502
|
+
}
|
|
2503
|
+
this.openElement(QTemplate, null, QTemplateProps, null);
|
|
2504
|
+
const scopedStyleId = componentFrame.projectionScopedStyle;
|
|
2505
|
+
for (let i = 0; i < componentFrame.slots.length; i += 2) {
|
|
2506
|
+
const slotName = componentFrame.slots[i];
|
|
2507
|
+
const children = componentFrame.slots[i + 1];
|
|
2508
|
+
this.openFragment(
|
|
2509
|
+
isDev7 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
|
|
2510
|
+
);
|
|
2511
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2512
|
+
if (lastNode.vnodeData) {
|
|
2513
|
+
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2514
|
+
}
|
|
2515
|
+
componentFrame.componentNode.setProp(slotName, lastNode.id);
|
|
2516
|
+
await this.renderJSX(children, {
|
|
2517
|
+
currentStyleScoped: scopedStyleId,
|
|
2518
|
+
parentComponentFrame: componentFrame.projectionComponentFrame
|
|
2519
|
+
});
|
|
2520
|
+
this.closeFragment();
|
|
2521
|
+
}
|
|
2522
|
+
this.closeElement();
|
|
2233
2523
|
}
|
|
2234
2524
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2235
2525
|
textNode(text) {
|
|
@@ -2256,13 +2546,14 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2256
2546
|
this.currentElementFrame.vNodeData,
|
|
2257
2547
|
// we start at -1, so we need to add +1
|
|
2258
2548
|
this.currentElementFrame.depthFirstElementIdx + 1,
|
|
2259
|
-
this.cleanupQueue
|
|
2549
|
+
this.cleanupQueue,
|
|
2550
|
+
this.currentElementFrame.currentFile
|
|
2260
2551
|
);
|
|
2261
2552
|
}
|
|
2262
2553
|
return this.lastNode;
|
|
2263
2554
|
}
|
|
2264
2555
|
addUnclaimedProjection(frame, name, children) {
|
|
2265
|
-
|
|
2556
|
+
frame.slots.push(name, children);
|
|
2266
2557
|
}
|
|
2267
2558
|
$processInjectionsFromManifest$() {
|
|
2268
2559
|
const injections = this.resolvedManifest.manifest.injections;
|
|
@@ -2305,19 +2596,23 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2305
2596
|
}
|
|
2306
2597
|
}
|
|
2307
2598
|
_styleNode(styleId, content) {
|
|
2308
|
-
this.openElement("style",
|
|
2599
|
+
this.openElement("style", null, {
|
|
2600
|
+
[QStyle]: styleId
|
|
2601
|
+
});
|
|
2309
2602
|
this.write(content);
|
|
2310
2603
|
this.closeElement();
|
|
2311
2604
|
}
|
|
2312
2605
|
////////////////////////////////////
|
|
2313
2606
|
emitContainerData() {
|
|
2314
2607
|
return maybeThen(
|
|
2315
|
-
this.
|
|
2608
|
+
this.resolvePromiseAttributes(),
|
|
2316
2609
|
() => maybeThen(this.emitStateData(), () => {
|
|
2317
2610
|
this.$noMoreRoots$ = true;
|
|
2318
2611
|
this.emitVNodeData();
|
|
2319
2612
|
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2320
2613
|
this.emitSyncFnsData();
|
|
2614
|
+
this.emitPatchDataIfNeeded();
|
|
2615
|
+
this.emitExecutorIfNeeded();
|
|
2321
2616
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2322
2617
|
})
|
|
2323
2618
|
);
|
|
@@ -2344,7 +2639,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2344
2639
|
if (!this.serializationCtx.$roots$.length) {
|
|
2345
2640
|
return;
|
|
2346
2641
|
}
|
|
2347
|
-
this.openElement("script",
|
|
2642
|
+
this.openElement("script", null, { type: "qwik/vnode" });
|
|
2348
2643
|
const vNodeAttrsStack = [];
|
|
2349
2644
|
const vNodeData = this.vNodeDatas;
|
|
2350
2645
|
let lastSerializedIdx = 0;
|
|
@@ -2361,7 +2656,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2361
2656
|
let depth = 0;
|
|
2362
2657
|
for (let i = 1; i < vNode.length; i++) {
|
|
2363
2658
|
const value = vNode[i];
|
|
2364
|
-
if (
|
|
2659
|
+
if (typeof value === "object" && value !== null) {
|
|
2365
2660
|
vNodeAttrsStack.push(fragmentAttrs);
|
|
2366
2661
|
fragmentAttrs = value;
|
|
2367
2662
|
} else if (value === OPEN_FRAGMENT) {
|
|
@@ -2369,15 +2664,17 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2369
2664
|
this.write(VNodeDataChar.OPEN_CHAR);
|
|
2370
2665
|
} else if (value === CLOSE_FRAGMENT) {
|
|
2371
2666
|
if (fragmentAttrs) {
|
|
2372
|
-
|
|
2667
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2373
2668
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2374
2669
|
}
|
|
2375
2670
|
depth--;
|
|
2376
2671
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
2377
2672
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2378
|
-
if (fragmentAttrs && fragmentAttrs
|
|
2673
|
+
if (fragmentAttrs && !isObjectEmpty(fragmentAttrs)) {
|
|
2674
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2675
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2676
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2379
2677
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2380
|
-
writeFragmentAttrs(this.write.bind(this), this.addRoot.bind(this), fragmentAttrs);
|
|
2381
2678
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2382
2679
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2383
2680
|
}
|
|
@@ -2389,7 +2686,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2389
2686
|
}
|
|
2390
2687
|
while (depth-- > 0) {
|
|
2391
2688
|
if (fragmentAttrs) {
|
|
2392
|
-
|
|
2689
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2393
2690
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2394
2691
|
}
|
|
2395
2692
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
@@ -2397,206 +2694,214 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2397
2694
|
}
|
|
2398
2695
|
}
|
|
2399
2696
|
}
|
|
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);
|
|
2697
|
+
this.closeElement();
|
|
2698
|
+
}
|
|
2699
|
+
writeFragmentAttrs(fragmentAttrs) {
|
|
2700
|
+
for (const key in fragmentAttrs) {
|
|
2701
|
+
let value = fragmentAttrs[key];
|
|
2702
|
+
let encodeValue = false;
|
|
2703
|
+
if (typeof value !== "string") {
|
|
2704
|
+
const rootId = this.addRoot(value);
|
|
2705
|
+
if (rootId === void 0) {
|
|
2706
|
+
continue;
|
|
2452
2707
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
write(
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
write(
|
|
2708
|
+
value = String(rootId);
|
|
2709
|
+
}
|
|
2710
|
+
switch (key) {
|
|
2711
|
+
case QScopedStyle:
|
|
2712
|
+
this.write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2713
|
+
break;
|
|
2714
|
+
case OnRenderProp:
|
|
2715
|
+
this.write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2716
|
+
break;
|
|
2717
|
+
case ELEMENT_ID:
|
|
2718
|
+
this.write(VNodeDataChar.ID_CHAR);
|
|
2719
|
+
break;
|
|
2720
|
+
case ELEMENT_PROPS:
|
|
2721
|
+
this.write(VNodeDataChar.PROPS_CHAR);
|
|
2722
|
+
break;
|
|
2723
|
+
case ELEMENT_KEY:
|
|
2724
|
+
encodeValue = true;
|
|
2725
|
+
this.write(VNodeDataChar.KEY_CHAR);
|
|
2726
|
+
break;
|
|
2727
|
+
case ELEMENT_SEQ:
|
|
2728
|
+
this.write(VNodeDataChar.SEQ_CHAR);
|
|
2729
|
+
break;
|
|
2730
|
+
case ELEMENT_SEQ_IDX:
|
|
2731
|
+
this.write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2732
|
+
break;
|
|
2733
|
+
case QBackRefs:
|
|
2734
|
+
this.write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2735
|
+
break;
|
|
2736
|
+
case QSlotParent:
|
|
2737
|
+
this.write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2738
|
+
break;
|
|
2739
|
+
// Skipping `\` character for now because it is used for escaping.
|
|
2740
|
+
case QCtxAttr:
|
|
2741
|
+
this.write(VNodeDataChar.CONTEXT_CHAR);
|
|
2742
|
+
break;
|
|
2743
|
+
case QSlot:
|
|
2744
|
+
this.write(VNodeDataChar.SLOT_CHAR);
|
|
2745
|
+
break;
|
|
2746
|
+
default: {
|
|
2747
|
+
encodeValue = true;
|
|
2748
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2749
|
+
this.write(encodeVNodeDataString(key));
|
|
2750
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2461
2751
|
}
|
|
2462
2752
|
}
|
|
2753
|
+
const encodedValue = encodeVNodeDataString(encodeValue ? encodeURI(value) : value);
|
|
2754
|
+
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2755
|
+
if (isEncoded) {
|
|
2756
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2757
|
+
this.write(encodedValue);
|
|
2758
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2759
|
+
} else {
|
|
2760
|
+
this.write(value);
|
|
2761
|
+
}
|
|
2463
2762
|
}
|
|
2464
|
-
this.closeElement();
|
|
2465
2763
|
}
|
|
2466
2764
|
emitStateData() {
|
|
2467
2765
|
if (!this.serializationCtx.$roots$.length) {
|
|
2468
2766
|
return;
|
|
2469
2767
|
}
|
|
2470
|
-
this.
|
|
2768
|
+
const attrs = this.stateScriptAttrs();
|
|
2769
|
+
this.openElement("script", null, attrs);
|
|
2471
2770
|
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2472
2771
|
this.closeElement();
|
|
2473
2772
|
});
|
|
2474
2773
|
}
|
|
2774
|
+
/** Add q-d:qidle attribute to eagerly resume some state if needed */
|
|
2775
|
+
stateScriptAttrs() {
|
|
2776
|
+
const attrs = { type: "qwik/state" };
|
|
2777
|
+
const eagerResume = this.serializationCtx.$eagerResume$;
|
|
2778
|
+
if (eagerResume.size > 0) {
|
|
2779
|
+
attrs["q-d:qidle"] = createQRL(null, "_res", _res, null, [...eagerResume]);
|
|
2780
|
+
}
|
|
2781
|
+
return attrs;
|
|
2782
|
+
}
|
|
2475
2783
|
emitSyncFnsData() {
|
|
2476
2784
|
const fns = this.serializationCtx.$syncFns$;
|
|
2477
2785
|
if (fns.length) {
|
|
2478
|
-
const scriptAttrs =
|
|
2786
|
+
const scriptAttrs = { "q:func": "qwik/json" };
|
|
2479
2787
|
if (this.renderOptions.serverData?.nonce) {
|
|
2480
|
-
scriptAttrs
|
|
2788
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2481
2789
|
}
|
|
2482
|
-
this.openElement("script", scriptAttrs);
|
|
2790
|
+
this.openElement("script", null, scriptAttrs);
|
|
2483
2791
|
this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
|
|
2484
|
-
this.write(
|
|
2485
|
-
this.writeArray(fns,
|
|
2486
|
-
this.write(
|
|
2792
|
+
this.write(BRACKET_OPEN);
|
|
2793
|
+
this.writeArray(fns, COMMA);
|
|
2794
|
+
this.write(BRACKET_CLOSE);
|
|
2795
|
+
this.closeElement();
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
emitPatchDataIfNeeded() {
|
|
2799
|
+
const patches = [];
|
|
2800
|
+
for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
|
|
2801
|
+
for (const backpatchEntry of backpatchEntries) {
|
|
2802
|
+
patches.push(
|
|
2803
|
+
elementIndex,
|
|
2804
|
+
backpatchEntry.attrName,
|
|
2805
|
+
isSignal(backpatchEntry.value) ? backpatchEntry.value.untrackedValue : backpatchEntry.value
|
|
2806
|
+
);
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
this.backpatchMap.clear();
|
|
2810
|
+
if (patches.length > 0) {
|
|
2811
|
+
this.isBackpatchExecutorEmitted = true;
|
|
2812
|
+
const scriptAttrs = { type: ELEMENT_BACKPATCH_DATA };
|
|
2813
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2814
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2815
|
+
}
|
|
2816
|
+
this.openElement("script", null, scriptAttrs);
|
|
2817
|
+
this.write(JSON.stringify(patches));
|
|
2487
2818
|
this.closeElement();
|
|
2488
2819
|
}
|
|
2489
2820
|
}
|
|
2821
|
+
emitExecutorIfNeeded() {
|
|
2822
|
+
if (!this.isBackpatchExecutorEmitted) {
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
const scriptAttrs = { type: "text/javascript" };
|
|
2826
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2827
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2828
|
+
}
|
|
2829
|
+
this.openElement("script", null, scriptAttrs);
|
|
2830
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev7 });
|
|
2831
|
+
this.write(backpatchScript);
|
|
2832
|
+
this.closeElement();
|
|
2833
|
+
}
|
|
2490
2834
|
emitPreloaderPre() {
|
|
2491
2835
|
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2492
2836
|
}
|
|
2493
2837
|
isStatic() {
|
|
2494
2838
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2495
2839
|
}
|
|
2496
|
-
getQwikLoaderIncludeMode() {
|
|
2497
|
-
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2498
|
-
}
|
|
2499
2840
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2841
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2842
|
+
this.qlInclude = 2 /* Done */;
|
|
2843
|
+
const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
|
|
2844
|
+
const linkAttrs = { rel: "modulepreload", href: qwikLoaderBundle };
|
|
2845
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2846
|
+
if (nonce) {
|
|
2847
|
+
linkAttrs["nonce"] = nonce;
|
|
2848
|
+
}
|
|
2849
|
+
this.openElement("link", null, linkAttrs);
|
|
2850
|
+
this.closeElement();
|
|
2851
|
+
const scriptAttrs = {
|
|
2852
|
+
async: true,
|
|
2853
|
+
type: "module",
|
|
2854
|
+
src: qwikLoaderBundle
|
|
2855
|
+
};
|
|
2856
|
+
if (nonce) {
|
|
2857
|
+
scriptAttrs["nonce"] = nonce;
|
|
2510
2858
|
}
|
|
2859
|
+
this.openElement("script", null, scriptAttrs);
|
|
2860
|
+
this.closeElement();
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
emitQwikLoaderInline() {
|
|
2864
|
+
this.qlInclude = 2 /* Done */;
|
|
2865
|
+
const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
|
|
2866
|
+
const scriptAttrs = {
|
|
2867
|
+
id: "qwikloader",
|
|
2868
|
+
async: true,
|
|
2869
|
+
type: "module"
|
|
2870
|
+
};
|
|
2871
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2872
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2511
2873
|
}
|
|
2874
|
+
this.openElement("script", null, scriptAttrs);
|
|
2875
|
+
this.write(qwikLoaderScript);
|
|
2876
|
+
this.closeElement();
|
|
2512
2877
|
}
|
|
2513
2878
|
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();
|
|
2879
|
+
if (!this.isStatic()) {
|
|
2880
|
+
if (this.qlInclude !== 2 /* Done */) {
|
|
2881
|
+
this.emitQwikLoaderInline();
|
|
2531
2882
|
}
|
|
2883
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2532
2884
|
}
|
|
2533
|
-
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2534
2885
|
}
|
|
2535
2886
|
emitQwikEvents(eventNames) {
|
|
2536
2887
|
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;
|
|
2888
|
+
const scriptAttrs = {};
|
|
2889
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2890
|
+
if (nonce) {
|
|
2891
|
+
scriptAttrs["nonce"] = nonce;
|
|
2593
2892
|
}
|
|
2893
|
+
this.openElement("script", null, scriptAttrs);
|
|
2894
|
+
this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
|
|
2895
|
+
this.writeArray(eventNames, COMMA);
|
|
2896
|
+
this.write(PAREN_CLOSE);
|
|
2897
|
+
this.closeElement();
|
|
2594
2898
|
}
|
|
2595
2899
|
}
|
|
2900
|
+
// Keep in sync with process-vnode-data.unit.ts
|
|
2596
2901
|
emitVNodeSeparators(lastSerializedIdx, elementIdx) {
|
|
2597
2902
|
let skipCount = elementIdx - lastSerializedIdx;
|
|
2598
2903
|
while (skipCount != 0) {
|
|
2599
|
-
if (skipCount
|
|
2904
|
+
if (skipCount >= 8192) {
|
|
2600
2905
|
this.write(VNodeDataSeparator.ADVANCE_8192_CH);
|
|
2601
2906
|
skipCount -= 8192;
|
|
2602
2907
|
} else {
|
|
@@ -2620,7 +2925,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2620
2925
|
}
|
|
2621
2926
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
2622
2927
|
let tagNesting = 10 /* ANYTHING */;
|
|
2623
|
-
if (
|
|
2928
|
+
if (isDev7) {
|
|
2624
2929
|
if (!this.currentElementFrame) {
|
|
2625
2930
|
tagNesting = initialTag(elementName);
|
|
2626
2931
|
} else {
|
|
@@ -2665,7 +2970,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2665
2970
|
parent: this.currentElementFrame,
|
|
2666
2971
|
elementName,
|
|
2667
2972
|
depthFirstElementIdx,
|
|
2668
|
-
vNodeData: [0 /* NONE */]
|
|
2973
|
+
vNodeData: [0 /* NONE */],
|
|
2974
|
+
currentFile: isDev7 ? currentFile || null : null
|
|
2669
2975
|
};
|
|
2670
2976
|
this.currentElementFrame = frame;
|
|
2671
2977
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -2677,6 +2983,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2677
2983
|
}
|
|
2678
2984
|
////////////////////////////////////
|
|
2679
2985
|
write(text) {
|
|
2986
|
+
this.size += text.length;
|
|
2680
2987
|
this.writer.write(text);
|
|
2681
2988
|
}
|
|
2682
2989
|
writeArray(array, separator) {
|
|
@@ -2688,89 +2995,103 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2688
2995
|
this.write(element);
|
|
2689
2996
|
}
|
|
2690
2997
|
}
|
|
2691
|
-
writeAttrs(tag, attrs, isConst, currentFile) {
|
|
2998
|
+
writeAttrs(tag, attrs, isConst, styleScopedId, currentFile, hasMovedCaptures) {
|
|
2692
2999
|
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
|
-
}
|
|
3000
|
+
for (let key in attrs) {
|
|
3001
|
+
let value = attrs[key];
|
|
3002
|
+
if (isSSRUnsafeAttr(key)) {
|
|
3003
|
+
if (isDev7) {
|
|
3004
|
+
throw qError(32 /* unsafeAttr */, [key]);
|
|
2722
3005
|
}
|
|
3006
|
+
continue;
|
|
3007
|
+
}
|
|
3008
|
+
if (isHtmlAttributeAnEventName(key)) {
|
|
3009
|
+
value = _setEvent(this.serializationCtx, key, value, hasMovedCaptures);
|
|
3010
|
+
} else if (key === "ref") {
|
|
3011
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2723
3012
|
if (isSignal(value)) {
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
3013
|
+
value.$untrackedValue$ = new DomRef(lastNode);
|
|
3014
|
+
continue;
|
|
3015
|
+
} else if (typeof value === "function") {
|
|
3016
|
+
value(new DomRef(lastNode));
|
|
3017
|
+
continue;
|
|
3018
|
+
} else if (value == null) {
|
|
3019
|
+
continue;
|
|
3020
|
+
} else {
|
|
3021
|
+
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2730
3022
|
}
|
|
2731
|
-
|
|
3023
|
+
} else if (key === ITERATION_ITEM_SINGLE || key === ITERATION_ITEM_MULTI) {
|
|
3024
|
+
value = this.serializationCtx.$addRoot$(value);
|
|
3025
|
+
} else if (isSignal(value)) {
|
|
3026
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3027
|
+
const signalData = new SubscriptionData({
|
|
3028
|
+
$scopedStyleIdPrefix$: styleScopedId,
|
|
3029
|
+
$isConst$: isConst
|
|
3030
|
+
});
|
|
3031
|
+
const signal = value;
|
|
3032
|
+
value = retryOnPromise(
|
|
3033
|
+
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
3034
|
+
);
|
|
3035
|
+
}
|
|
3036
|
+
if (isPromise(value)) {
|
|
3037
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3038
|
+
this.addPromiseAttribute(value);
|
|
3039
|
+
value.then((resolvedValue) => {
|
|
3040
|
+
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
3041
|
+
});
|
|
3042
|
+
continue;
|
|
3043
|
+
}
|
|
3044
|
+
if (key === dangerouslySetInnerHTML) {
|
|
3045
|
+
if (value) {
|
|
2732
3046
|
innerHTML = String(value);
|
|
2733
3047
|
key = QContainerAttr;
|
|
2734
3048
|
value = "html" /* HTML */;
|
|
2735
|
-
if (tag === "style") {
|
|
2736
|
-
continue;
|
|
2737
|
-
}
|
|
2738
3049
|
}
|
|
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 */;
|
|
3050
|
+
if (tag === "style") {
|
|
3051
|
+
continue;
|
|
2749
3052
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
this.write(strValue);
|
|
2758
|
-
this.write('"');
|
|
3053
|
+
} else if (isPreventDefault(key)) {
|
|
3054
|
+
addPreventDefaultEventToSerializationContext(this.serializationCtx, key);
|
|
3055
|
+
}
|
|
3056
|
+
if (tag === "textarea" && key === "value") {
|
|
3057
|
+
if (value && typeof value !== "string") {
|
|
3058
|
+
if (isDev7) {
|
|
3059
|
+
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2759
3060
|
}
|
|
3061
|
+
continue;
|
|
3062
|
+
}
|
|
3063
|
+
innerHTML = escapeHTML(value || "");
|
|
3064
|
+
key = QContainerAttr;
|
|
3065
|
+
value = "text" /* TEXT */;
|
|
3066
|
+
}
|
|
3067
|
+
const serializedValue = serializeAttribute(key, value, styleScopedId);
|
|
3068
|
+
if (serializedValue != null && serializedValue !== false) {
|
|
3069
|
+
this.write(SPACE);
|
|
3070
|
+
this.write(key);
|
|
3071
|
+
if (serializedValue !== true) {
|
|
3072
|
+
this.write(ATTR_EQUALS_QUOTE);
|
|
3073
|
+
const strValue = escapeHTML(String(serializedValue));
|
|
3074
|
+
this.write(strValue);
|
|
3075
|
+
this.write(QUOTE);
|
|
2760
3076
|
}
|
|
2761
3077
|
}
|
|
2762
3078
|
}
|
|
2763
3079
|
return innerHTML;
|
|
2764
3080
|
}
|
|
3081
|
+
addPromiseAttribute(promise) {
|
|
3082
|
+
this.promiseAttributes ||= [];
|
|
3083
|
+
this.promiseAttributes.push(promise);
|
|
3084
|
+
}
|
|
3085
|
+
async resolvePromiseAttributes() {
|
|
3086
|
+
if (this.promiseAttributes) {
|
|
3087
|
+
await Promise.all(this.promiseAttributes);
|
|
3088
|
+
this.promiseAttributes = null;
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
2765
3091
|
};
|
|
2766
3092
|
var isQwikStyleElement = (tag, attrs) => {
|
|
2767
3093
|
if (tag === "style" && attrs != null) {
|
|
2768
|
-
|
|
2769
|
-
const attr = attrs[i];
|
|
2770
|
-
if (attr === QStyle || attr === QScopedStyle) {
|
|
2771
|
-
return true;
|
|
2772
|
-
}
|
|
2773
|
-
}
|
|
3094
|
+
return Object.prototype.hasOwnProperty.call(attrs, QStyle) || Object.prototype.hasOwnProperty.call(attrs, QScopedStyle);
|
|
2774
3095
|
}
|
|
2775
3096
|
return false;
|
|
2776
3097
|
};
|
|
@@ -2789,12 +3110,128 @@ function isSSRUnsafeAttr(name) {
|
|
|
2789
3110
|
}
|
|
2790
3111
|
return false;
|
|
2791
3112
|
}
|
|
2792
|
-
function
|
|
2793
|
-
return Math.random().toString(36).slice(2);
|
|
3113
|
+
function randomStr() {
|
|
3114
|
+
return (Math.random().toString(36) + "000000").slice(2, 8);
|
|
3115
|
+
}
|
|
3116
|
+
function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
|
|
3117
|
+
const eventName = "e" + key.substring(14);
|
|
3118
|
+
if (eventName) {
|
|
3119
|
+
serializationCtx.$eventNames$.add(eventName);
|
|
3120
|
+
}
|
|
2794
3121
|
}
|
|
2795
3122
|
|
|
2796
3123
|
// packages/qwik/src/server/ssr-render.ts
|
|
2797
3124
|
import { manifest as builtManifest } from "@qwik-client-manifest";
|
|
3125
|
+
|
|
3126
|
+
// packages/qwik/src/server/ssr-stream-handler.ts
|
|
3127
|
+
var StreamHandler = class {
|
|
3128
|
+
constructor(opts, timing) {
|
|
3129
|
+
this.opts = opts;
|
|
3130
|
+
this.timing = timing;
|
|
3131
|
+
this.inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
3132
|
+
strategy: "auto",
|
|
3133
|
+
maximumInitialChunk: 2e4,
|
|
3134
|
+
maximumChunk: 1e4
|
|
3135
|
+
};
|
|
3136
|
+
this.nativeStream = opts.stream;
|
|
3137
|
+
this.stream = this.setupStreamWriter();
|
|
3138
|
+
}
|
|
3139
|
+
bufferSize = 0;
|
|
3140
|
+
buffer = "";
|
|
3141
|
+
networkFlushes = 0;
|
|
3142
|
+
inOrderStreaming;
|
|
3143
|
+
streamBlockDepth = 0;
|
|
3144
|
+
streamBlockBuffer = "";
|
|
3145
|
+
streamBlockBufferSize = 0;
|
|
3146
|
+
nativeStream;
|
|
3147
|
+
firstFlushTimer = createTimer();
|
|
3148
|
+
stream;
|
|
3149
|
+
setupStreamWriter() {
|
|
3150
|
+
const handler = this;
|
|
3151
|
+
let stream;
|
|
3152
|
+
switch (this.inOrderStreaming.strategy) {
|
|
3153
|
+
case "disabled":
|
|
3154
|
+
stream = {
|
|
3155
|
+
write(chunk) {
|
|
3156
|
+
if (chunk === void 0 || chunk === null) {
|
|
3157
|
+
return;
|
|
3158
|
+
}
|
|
3159
|
+
handler.enqueue(chunk);
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
break;
|
|
3163
|
+
case "direct": {
|
|
3164
|
+
const originalStream = this.nativeStream;
|
|
3165
|
+
stream = {
|
|
3166
|
+
write(chunk) {
|
|
3167
|
+
if (chunk === void 0 || chunk === null) {
|
|
3168
|
+
return;
|
|
3169
|
+
}
|
|
3170
|
+
originalStream.write(chunk);
|
|
3171
|
+
}
|
|
3172
|
+
};
|
|
3173
|
+
break;
|
|
3174
|
+
}
|
|
3175
|
+
default:
|
|
3176
|
+
case "auto": {
|
|
3177
|
+
const minimumChunkSize = this.inOrderStreaming.maximumChunk ?? 0;
|
|
3178
|
+
const initialChunkSize = this.inOrderStreaming.maximumInitialChunk ?? 0;
|
|
3179
|
+
stream = {
|
|
3180
|
+
write(chunk) {
|
|
3181
|
+
if (chunk === void 0 || chunk === null) {
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
handler.enqueue(chunk);
|
|
3185
|
+
if (handler.streamBlockDepth === 0) {
|
|
3186
|
+
const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3187
|
+
if (handler.bufferSize >= maxBufferSize) {
|
|
3188
|
+
handler.flush();
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
};
|
|
3193
|
+
break;
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
return stream;
|
|
3197
|
+
}
|
|
3198
|
+
enqueue(chunk) {
|
|
3199
|
+
const len = chunk.length;
|
|
3200
|
+
if (this.streamBlockDepth > 0) {
|
|
3201
|
+
this.streamBlockBuffer += chunk;
|
|
3202
|
+
this.streamBlockBufferSize += len;
|
|
3203
|
+
} else {
|
|
3204
|
+
this.bufferSize += len;
|
|
3205
|
+
this.buffer += chunk;
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
flush() {
|
|
3209
|
+
if (this.buffer) {
|
|
3210
|
+
this.nativeStream.write(this.buffer);
|
|
3211
|
+
this.buffer = "";
|
|
3212
|
+
this.bufferSize = 0;
|
|
3213
|
+
this.networkFlushes++;
|
|
3214
|
+
if (this.networkFlushes === 1) {
|
|
3215
|
+
this.timing.firstFlush = this.firstFlushTimer();
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
streamBlockStart() {
|
|
3220
|
+
this.streamBlockDepth++;
|
|
3221
|
+
}
|
|
3222
|
+
streamBlockEnd() {
|
|
3223
|
+
this.streamBlockDepth--;
|
|
3224
|
+
if (this.streamBlockDepth === 0 && this.streamBlockBuffer) {
|
|
3225
|
+
this.buffer += this.streamBlockBuffer;
|
|
3226
|
+
this.bufferSize += this.streamBlockBufferSize;
|
|
3227
|
+
this.streamBlockBuffer = "";
|
|
3228
|
+
this.streamBlockBufferSize = 0;
|
|
3229
|
+
this.flush();
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
};
|
|
3233
|
+
|
|
3234
|
+
// packages/qwik/src/server/ssr-render.ts
|
|
2798
3235
|
var renderToString = async (jsx, opts = {}) => {
|
|
2799
3236
|
const chunks = [];
|
|
2800
3237
|
const stream = {
|
|
@@ -2821,11 +3258,12 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2821
3258
|
const buildBase = getBuildBase(opts);
|
|
2822
3259
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
2823
3260
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
2824
|
-
const
|
|
3261
|
+
const streamHandler = new StreamHandler(opts, timing);
|
|
2825
3262
|
const ssrContainer = ssrCreateContainer({
|
|
2826
3263
|
tagName: containerTagName,
|
|
2827
3264
|
locale,
|
|
2828
|
-
writer: stream,
|
|
3265
|
+
writer: streamHandler.stream,
|
|
3266
|
+
streamHandler,
|
|
2829
3267
|
timing,
|
|
2830
3268
|
buildBase,
|
|
2831
3269
|
resolvedManifest,
|
|
@@ -2833,126 +3271,17 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2833
3271
|
});
|
|
2834
3272
|
await setServerPlatform(opts, resolvedManifest);
|
|
2835
3273
|
await ssrContainer.render(jsx);
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
3274
|
+
await ssrContainer.$renderPromise$;
|
|
3275
|
+
streamHandler.flush();
|
|
2839
3276
|
const result = {
|
|
2840
|
-
|
|
2841
|
-
flushes: networkFlushes,
|
|
3277
|
+
flushes: streamHandler.networkFlushes,
|
|
2842
3278
|
manifest: resolvedManifest?.manifest,
|
|
2843
|
-
size:
|
|
2844
|
-
isStatic:
|
|
3279
|
+
size: ssrContainer.size,
|
|
3280
|
+
isStatic: false,
|
|
2845
3281
|
timing
|
|
2846
3282
|
};
|
|
2847
3283
|
return result;
|
|
2848
3284
|
};
|
|
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
3285
|
function resolveManifest(manifest) {
|
|
2957
3286
|
const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
|
|
2958
3287
|
if (!mergedManifest || "mapper" in mergedManifest) {
|
|
@@ -2979,6 +3308,7 @@ async function setServerPlatform2(manifest) {
|
|
|
2979
3308
|
setPlatform2(platform);
|
|
2980
3309
|
}
|
|
2981
3310
|
export {
|
|
3311
|
+
getQwikBackpatchExecutorScript,
|
|
2982
3312
|
getQwikLoaderScript,
|
|
2983
3313
|
getQwikPrefetchWorkerScript,
|
|
2984
3314
|
renderToStream,
|