@qwik.dev/core 2.0.0-beta.2 → 2.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/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 +5633 -0
- package/dist/core-internal.d.ts +673 -396
- package/dist/core.min.mjs +2 -1
- package/dist/core.mjs +10168 -8294
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +5745 -4592
- package/dist/insights/vite/index.mjs +10 -10
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +16 -38
- package/dist/optimizer.mjs +2608 -3719
- package/dist/preloader.mjs +8 -11
- package/dist/qwikloader.debug.js +152 -132
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +38 -15
- package/dist/server.mjs +1209 -927
- 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 +3 -2
- 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 +3 -2
- 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 +23 -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/playwright/playwright-report/index.html +953 -930
- 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 +775 -6
- package/dist/testing/index.mjs +14298 -10837
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +1 -1
- package/package.json +30 -55
- package/public.d.ts +3 -1
- package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
- package/server.d.ts +2 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.wasm.cjs +0 -471
- 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 -11754
- package/dist/core.cjs.map +0 -1
- package/dist/core.prod.cjs +0 -5647
- 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 -3027
- 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/tailwind/.prettierrc.js +0 -3
- package/dist/testing/index.cjs +0 -33287
- /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
package/dist/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.21-dev+c008e88
|
|
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
|
|
@@ -20,6 +20,10 @@ import { setPlatform as setPlatform2 } from "@qwik.dev/core";
|
|
|
20
20
|
|
|
21
21
|
// packages/qwik/src/server/platform.ts
|
|
22
22
|
import { setPlatform } from "@qwik.dev/core";
|
|
23
|
+
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
24
|
+
|
|
25
|
+
// packages/qwik/src/core/client/util-mapArray.ts
|
|
26
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
23
27
|
|
|
24
28
|
// packages/qwik/src/core/shared/utils/qdev.ts
|
|
25
29
|
var qDev = globalThis.qDev !== false;
|
|
@@ -63,7 +67,7 @@ function assertTrue(value1, text, ...parts) {
|
|
|
63
67
|
|
|
64
68
|
// packages/qwik/src/core/client/util-mapArray.ts
|
|
65
69
|
var mapApp_findIndx = (array, key, start) => {
|
|
66
|
-
assertTrue(start % 2 === 0, "Expecting even number.");
|
|
70
|
+
isDev && assertTrue(start % 2 === 0, "Expecting even number.");
|
|
67
71
|
let bottom = start >> 1;
|
|
68
72
|
let top = array.length - 2 >> 1;
|
|
69
73
|
while (bottom <= top) {
|
|
@@ -80,15 +84,15 @@ var mapApp_findIndx = (array, key, start) => {
|
|
|
80
84
|
}
|
|
81
85
|
return bottom << 1 ^ -1;
|
|
82
86
|
};
|
|
83
|
-
var mapArray_set = (array, key, value, start) => {
|
|
87
|
+
var mapArray_set = (array, key, value, start, allowNullValue = false) => {
|
|
84
88
|
const indx = mapApp_findIndx(array, key, start);
|
|
85
89
|
if (indx >= 0) {
|
|
86
|
-
if (value == null) {
|
|
90
|
+
if (value == null && !allowNullValue) {
|
|
87
91
|
array.splice(indx, 2);
|
|
88
92
|
} else {
|
|
89
93
|
array[indx + 1] = value;
|
|
90
94
|
}
|
|
91
|
-
} else if (value != null) {
|
|
95
|
+
} else if (value != null || allowNullValue) {
|
|
92
96
|
array.splice(indx ^ -1, 0, key, value);
|
|
93
97
|
}
|
|
94
98
|
};
|
|
@@ -114,6 +118,17 @@ var mapArray_has = (array, key, start) => {
|
|
|
114
118
|
return mapApp_findIndx(array, key, start) >= 0;
|
|
115
119
|
};
|
|
116
120
|
|
|
121
|
+
// packages/qwik/src/core/shared/utils/types.ts
|
|
122
|
+
var isObject = (v) => {
|
|
123
|
+
return typeof v === "object" && v !== null;
|
|
124
|
+
};
|
|
125
|
+
var isArray = (v) => {
|
|
126
|
+
return Array.isArray(v);
|
|
127
|
+
};
|
|
128
|
+
var isString = (v) => {
|
|
129
|
+
return typeof v === "string";
|
|
130
|
+
};
|
|
131
|
+
|
|
117
132
|
// packages/qwik/src/core/shared/error/error.ts
|
|
118
133
|
var codeToText = (code, ...parts) => {
|
|
119
134
|
if (qDev) {
|
|
@@ -139,7 +154,7 @@ var codeToText = (code, ...parts) => {
|
|
|
139
154
|
"Invoking 'use*()' method outside of invocation context.",
|
|
140
155
|
// 9
|
|
141
156
|
`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/
|
|
157
|
+
See https://qwik.dev/docs/core/tasks/#use-method-rules`,
|
|
143
158
|
// 10
|
|
144
159
|
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
|
|
145
160
|
// 11
|
|
@@ -183,7 +198,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
183
198
|
// 30
|
|
184
199
|
"WrappedSignal is read-only",
|
|
185
200
|
// 31
|
|
186
|
-
"Attribute value is unsafe for SSR",
|
|
201
|
+
"Attribute value is unsafe for SSR {{0}}",
|
|
187
202
|
// 32
|
|
188
203
|
"SerializerSymbol function returned rejected promise",
|
|
189
204
|
// 33
|
|
@@ -194,7 +209,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
194
209
|
if (parts.length) {
|
|
195
210
|
text = text.replaceAll(/{{(\d+)}}/g, (_, index) => {
|
|
196
211
|
let v = parts[index];
|
|
197
|
-
if (v &&
|
|
212
|
+
if (v && isObject(v) && v.constructor === Object) {
|
|
198
213
|
v = JSON.stringify(v).slice(0, 50);
|
|
199
214
|
}
|
|
200
215
|
return v;
|
|
@@ -211,255 +226,12 @@ var qError = (code, errorMessageArgs = []) => {
|
|
|
211
226
|
};
|
|
212
227
|
|
|
213
228
|
// packages/qwik/src/core/shared/qrl/qrl-utils.ts
|
|
214
|
-
import { isDev } from "@qwik.dev/core/build";
|
|
229
|
+
import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
215
230
|
var SYNC_QRL = "<sync>";
|
|
216
231
|
|
|
217
232
|
// packages/qwik/src/core/shared/types.ts
|
|
218
233
|
var DEBUG_TYPE = "q:type";
|
|
219
234
|
|
|
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
235
|
// packages/qwik/src/core/shared/vnode-data-types.ts
|
|
464
236
|
var VNodeDataSeparator = {
|
|
465
237
|
REFERENCE_CH: (
|
|
@@ -748,10 +520,313 @@ var VNodeDataChar = {
|
|
|
748
520
|
)
|
|
749
521
|
};
|
|
750
522
|
|
|
751
|
-
// packages/qwik/src/core/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
523
|
+
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
524
|
+
function escapeHTML(html) {
|
|
525
|
+
let escapedHTML = "";
|
|
526
|
+
const length = html.length;
|
|
527
|
+
let idx = 0;
|
|
528
|
+
let lastIdx = idx;
|
|
529
|
+
for (; idx < length; idx++) {
|
|
530
|
+
const ch = html.charCodeAt(idx);
|
|
531
|
+
if (ch === 60) {
|
|
532
|
+
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
533
|
+
} else if (ch === 62) {
|
|
534
|
+
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
535
|
+
} else if (ch === 38) {
|
|
536
|
+
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
537
|
+
} else if (ch === 34) {
|
|
538
|
+
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
539
|
+
} else if (ch === 39) {
|
|
540
|
+
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
541
|
+
} else {
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
lastIdx = idx + 1;
|
|
545
|
+
}
|
|
546
|
+
if (lastIdx === 0) {
|
|
547
|
+
return html;
|
|
548
|
+
} else {
|
|
549
|
+
return escapedHTML + html.substring(lastIdx);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function encodeVNodeDataString(str) {
|
|
553
|
+
let escapedHTML = "";
|
|
554
|
+
const length = str.length;
|
|
555
|
+
let idx = 0;
|
|
556
|
+
let lastIdx = idx;
|
|
557
|
+
for (; idx < length; idx++) {
|
|
558
|
+
const ch = str.charCodeAt(idx);
|
|
559
|
+
if (ch >= VNodeDataSeparator.ADVANCE_1 && ch <= VNodeDataSeparator.ADVANCE_8192) {
|
|
560
|
+
escapedHTML += str.substring(lastIdx, idx) + "\\" + str.charAt(idx);
|
|
561
|
+
} else {
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
lastIdx = idx + 1;
|
|
565
|
+
}
|
|
566
|
+
if (lastIdx === 0) {
|
|
567
|
+
return str;
|
|
568
|
+
} else {
|
|
569
|
+
return escapedHTML + str.substring(lastIdx);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// packages/qwik/src/core/shared/utils/markers.ts
|
|
574
|
+
var OnRenderProp = "q:renderFn";
|
|
575
|
+
var QSlot = "q:slot";
|
|
576
|
+
var QSlotParent = "q:sparent";
|
|
577
|
+
var QStyle = "q:style";
|
|
578
|
+
var QStyleSelector = "style[q\\:style]";
|
|
579
|
+
var QStyleSSelector = "style[q\\:sstyle]";
|
|
580
|
+
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
581
|
+
var QScopedStyle = "q:sstyle";
|
|
582
|
+
var QCtxAttr = "q:ctx";
|
|
583
|
+
var QBackRefs = "q:brefs";
|
|
584
|
+
var QRenderAttr = "q:render";
|
|
585
|
+
var QRuntimeAttr = "q:runtime";
|
|
586
|
+
var QVersionAttr = "q:version";
|
|
587
|
+
var QBaseAttr = "q:base";
|
|
588
|
+
var QLocaleAttr = "q:locale";
|
|
589
|
+
var QManifestHashAttr = "q:manifest-hash";
|
|
590
|
+
var QInstanceAttr = "q:instance";
|
|
591
|
+
var QContainerIsland = "q:container-island";
|
|
592
|
+
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
593
|
+
var QIgnore = "q:ignore";
|
|
594
|
+
var QIgnoreEnd = "/" + QIgnore;
|
|
595
|
+
var QContainerAttr = "q:container";
|
|
596
|
+
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
597
|
+
var QTemplate = "q:template";
|
|
598
|
+
var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
|
|
599
|
+
var QDefaultSlot = "";
|
|
600
|
+
var ELEMENT_ID = "q:id";
|
|
601
|
+
var ELEMENT_KEY = "q:key";
|
|
602
|
+
var ELEMENT_PROPS = "q:props";
|
|
603
|
+
var ELEMENT_SEQ = "q:seq";
|
|
604
|
+
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
605
|
+
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
606
|
+
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
607
|
+
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
608
|
+
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
609
|
+
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
610
|
+
var FLUSH_COMMENT = "qkssr-f";
|
|
611
|
+
var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
|
|
612
|
+
var STREAM_BLOCK_END_COMMENT = "qkssr-po";
|
|
613
|
+
var Q_PROPS_SEPARATOR = ":";
|
|
614
|
+
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
615
|
+
|
|
616
|
+
// packages/qwik/src/core/shared/utils/promises.ts
|
|
617
|
+
import { isDev as isDev3, isServer } from "@qwik.dev/core/build";
|
|
618
|
+
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
619
|
+
var isPromise = (value) => {
|
|
620
|
+
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
621
|
+
};
|
|
622
|
+
var maybeThen = (valueOrPromise, thenFn) => {
|
|
623
|
+
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
624
|
+
};
|
|
625
|
+
var checkError = (e) => {
|
|
626
|
+
if (isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
627
|
+
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
var justThrow = (e) => {
|
|
631
|
+
throw e;
|
|
632
|
+
};
|
|
633
|
+
function retryOnPromise(fn, onError = justThrow) {
|
|
634
|
+
let ok = false;
|
|
635
|
+
let result;
|
|
636
|
+
try {
|
|
637
|
+
result = fn();
|
|
638
|
+
ok = true;
|
|
639
|
+
} catch (e) {
|
|
640
|
+
result = e;
|
|
641
|
+
}
|
|
642
|
+
if (!isPromise(result)) {
|
|
643
|
+
if (ok) {
|
|
644
|
+
return result;
|
|
645
|
+
}
|
|
646
|
+
isDev3 && checkError(result);
|
|
647
|
+
return onError(result);
|
|
648
|
+
}
|
|
649
|
+
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
650
|
+
const retry = async (p) => {
|
|
651
|
+
while (isPromise(p)) {
|
|
652
|
+
try {
|
|
653
|
+
await p;
|
|
654
|
+
return await fn();
|
|
655
|
+
} catch (err) {
|
|
656
|
+
if (isPromise(err)) {
|
|
657
|
+
if (!--retryCount) {
|
|
658
|
+
p = new Error("Exceeded max retry count in retryOnPromise");
|
|
659
|
+
break;
|
|
660
|
+
} else {
|
|
661
|
+
p = err;
|
|
662
|
+
}
|
|
663
|
+
} else {
|
|
664
|
+
p = err;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
isDev3 && checkError(p);
|
|
670
|
+
return onError(p);
|
|
671
|
+
};
|
|
672
|
+
return ok ? result.catch(retry) : retry(result);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
676
|
+
function isClassAttr(key) {
|
|
677
|
+
return key === "class";
|
|
678
|
+
}
|
|
679
|
+
function convertStyleIdsToString(scopedStyleIds) {
|
|
680
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
684
|
+
function isPreventDefault(key) {
|
|
685
|
+
return key.startsWith("preventdefault:");
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// packages/qwik/src/core/shared/utils/unitless_number.ts
|
|
689
|
+
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
690
|
+
"animationIterationCount",
|
|
691
|
+
"aspectRatio",
|
|
692
|
+
"borderImageOutset",
|
|
693
|
+
"borderImageSlice",
|
|
694
|
+
"borderImageWidth",
|
|
695
|
+
"boxFlex",
|
|
696
|
+
"boxFlexGroup",
|
|
697
|
+
"boxOrdinalGroup",
|
|
698
|
+
"columnCount",
|
|
699
|
+
"columns",
|
|
700
|
+
"flex",
|
|
701
|
+
"flexGrow",
|
|
702
|
+
"flexShrink",
|
|
703
|
+
"gridArea",
|
|
704
|
+
"gridRow",
|
|
705
|
+
"gridRowEnd",
|
|
706
|
+
"gridRowStart",
|
|
707
|
+
"gridColumn",
|
|
708
|
+
"gridColumnEnd",
|
|
709
|
+
"gridColumnStart",
|
|
710
|
+
"fontWeight",
|
|
711
|
+
"lineClamp",
|
|
712
|
+
"lineHeight",
|
|
713
|
+
"opacity",
|
|
714
|
+
"order",
|
|
715
|
+
"orphans",
|
|
716
|
+
"scale",
|
|
717
|
+
"tabSize",
|
|
718
|
+
"widows",
|
|
719
|
+
"zIndex",
|
|
720
|
+
"zoom",
|
|
721
|
+
"MozAnimationIterationCount",
|
|
722
|
+
// Known Prefixed Properties
|
|
723
|
+
"MozBoxFlex",
|
|
724
|
+
// TODO: Remove these since they shouldn't be used in modern code
|
|
725
|
+
"msFlex",
|
|
726
|
+
"msFlexPositive",
|
|
727
|
+
"WebkitAnimationIterationCount",
|
|
728
|
+
"WebkitBoxFlex",
|
|
729
|
+
"WebkitBoxOrdinalGroup",
|
|
730
|
+
"WebkitColumnCount",
|
|
731
|
+
"WebkitColumns",
|
|
732
|
+
"WebkitFlex",
|
|
733
|
+
"WebkitFlexGrow",
|
|
734
|
+
"WebkitFlexShrink",
|
|
735
|
+
"WebkitLineClamp"
|
|
736
|
+
]);
|
|
737
|
+
var isUnitlessNumber = (name) => {
|
|
738
|
+
return unitlessNumbers.has(name);
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
// packages/qwik/src/core/shared/utils/styles.ts
|
|
742
|
+
var serializeClass = (obj) => {
|
|
743
|
+
if (!obj) {
|
|
744
|
+
return "";
|
|
745
|
+
}
|
|
746
|
+
if (isString(obj)) {
|
|
747
|
+
return obj.trim();
|
|
748
|
+
}
|
|
749
|
+
const classes = [];
|
|
750
|
+
if (isArray(obj)) {
|
|
751
|
+
for (const o of obj) {
|
|
752
|
+
const classList = serializeClass(o);
|
|
753
|
+
if (classList) {
|
|
754
|
+
classes.push(classList);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
} else {
|
|
758
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
759
|
+
if (value) {
|
|
760
|
+
classes.push(key.trim());
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return classes.join(" ");
|
|
765
|
+
};
|
|
766
|
+
var fromCamelToKebabCaseWithDash = (text) => {
|
|
767
|
+
return text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
768
|
+
};
|
|
769
|
+
var stringifyStyle = (obj) => {
|
|
770
|
+
if (obj == null) {
|
|
771
|
+
return "";
|
|
772
|
+
}
|
|
773
|
+
if (typeof obj == "object") {
|
|
774
|
+
if (isArray(obj)) {
|
|
775
|
+
throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]);
|
|
776
|
+
} else {
|
|
777
|
+
const chunks = [];
|
|
778
|
+
for (const key in obj) {
|
|
779
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
780
|
+
const value = obj[key];
|
|
781
|
+
if (value != null && typeof value !== "function") {
|
|
782
|
+
if (key.startsWith("--")) {
|
|
783
|
+
chunks.push(key + ":" + value);
|
|
784
|
+
} else {
|
|
785
|
+
chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value));
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return chunks.join(";");
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return String(obj);
|
|
794
|
+
};
|
|
795
|
+
var serializeBooleanOrNumberAttribute = (value) => {
|
|
796
|
+
return value != null ? String(value) : null;
|
|
797
|
+
};
|
|
798
|
+
function serializeAttribute(key, value, styleScopedId) {
|
|
799
|
+
if (isClassAttr(key)) {
|
|
800
|
+
const serializedClass = serializeClass(value);
|
|
801
|
+
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
802
|
+
} else if (key === "style") {
|
|
803
|
+
value = stringifyStyle(value);
|
|
804
|
+
} else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") {
|
|
805
|
+
value = serializeBooleanOrNumberAttribute(value);
|
|
806
|
+
} else if (value === false || value == null) {
|
|
807
|
+
value = null;
|
|
808
|
+
} else if (value === true && isPreventDefault(key)) {
|
|
809
|
+
value = "";
|
|
810
|
+
}
|
|
811
|
+
return value;
|
|
812
|
+
}
|
|
813
|
+
function isEnumeratedBooleanAttribute(key) {
|
|
814
|
+
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
815
|
+
}
|
|
816
|
+
var setValueForStyle = (styleName, value) => {
|
|
817
|
+
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) {
|
|
818
|
+
return value + "px";
|
|
819
|
+
}
|
|
820
|
+
return value;
|
|
821
|
+
};
|
|
822
|
+
function isAriaAttribute(prop) {
|
|
823
|
+
return prop.startsWith("aria-");
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
827
|
+
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
828
|
+
|
|
829
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
755
830
|
import { isBrowser as isBrowser2 } from "@qwik.dev/core/build";
|
|
756
831
|
|
|
757
832
|
// packages/qwik/src/core/preloader/constants.ts
|
|
@@ -893,12 +968,9 @@ var trigger = () => {
|
|
|
893
968
|
const bundle = queue[0];
|
|
894
969
|
const inverseProbability = bundle.$inverseProbability$;
|
|
895
970
|
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
|
|
971
|
+
const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
|
|
972
|
+
// While the graph is not available, we limit to 5 preloads
|
|
973
|
+
5
|
|
902
974
|
);
|
|
903
975
|
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
904
976
|
queue.shift();
|
|
@@ -954,7 +1026,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
954
1026
|
}
|
|
955
1027
|
if (
|
|
956
1028
|
// don't queue until we have initialized the preloader
|
|
957
|
-
base != null && bundle.$state$ < BundleImportState_Preload
|
|
1029
|
+
base != null && bundle.$state$ < BundleImportState_Preload
|
|
958
1030
|
) {
|
|
959
1031
|
if (bundle.$state$ === BundleImportState_None) {
|
|
960
1032
|
bundle.$state$ = BundleImportState_Queued;
|
|
@@ -973,7 +1045,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
973
1045
|
continue;
|
|
974
1046
|
}
|
|
975
1047
|
let newInverseProbability2;
|
|
976
|
-
if (
|
|
1048
|
+
if (probability === 1 || probability >= 0.99 && depsCount < 100) {
|
|
977
1049
|
depsCount++;
|
|
978
1050
|
newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
|
|
979
1051
|
} else {
|
|
@@ -998,148 +1070,438 @@ var preload = (name, probability) => {
|
|
|
998
1070
|
if (!name?.length) {
|
|
999
1071
|
return;
|
|
1000
1072
|
}
|
|
1001
|
-
depsCount = 0;
|
|
1002
|
-
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1003
|
-
if (Array.isArray(name)) {
|
|
1004
|
-
for (let i = name.length - 1; i >= 0; i--) {
|
|
1005
|
-
const item = name[i];
|
|
1006
|
-
if (typeof item === "number") {
|
|
1007
|
-
inverseProbability = 1 - item / 10;
|
|
1008
|
-
} else {
|
|
1009
|
-
handleBundle(item, inverseProbability);
|
|
1073
|
+
depsCount = 0;
|
|
1074
|
+
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1075
|
+
if (Array.isArray(name)) {
|
|
1076
|
+
for (let i = name.length - 1; i >= 0; i--) {
|
|
1077
|
+
const item = name[i];
|
|
1078
|
+
if (typeof item === "number") {
|
|
1079
|
+
inverseProbability = 1 - item / 10;
|
|
1080
|
+
} else {
|
|
1081
|
+
handleBundle(item, inverseProbability);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
} else {
|
|
1085
|
+
handleBundle(name, inverseProbability);
|
|
1086
|
+
}
|
|
1087
|
+
if (isBrowser3) {
|
|
1088
|
+
trigger();
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
if (isBrowser3) {
|
|
1092
|
+
document.addEventListener("qsymbol", (ev) => {
|
|
1093
|
+
const { symbol, href } = ev.detail;
|
|
1094
|
+
if (href) {
|
|
1095
|
+
const hash2 = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1096
|
+
preload(hash2, 1);
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// packages/qwik/src/server/platform.ts
|
|
1102
|
+
var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
|
|
1103
|
+
const existing = mapper?.[hash2];
|
|
1104
|
+
if (existing) {
|
|
1105
|
+
return existing;
|
|
1106
|
+
}
|
|
1107
|
+
if (symbolName === SYNC_QRL) {
|
|
1108
|
+
return [symbolName, ""];
|
|
1109
|
+
}
|
|
1110
|
+
if (!parent) {
|
|
1111
|
+
if (symbolName.startsWith("_") && symbolName.length < 6) {
|
|
1112
|
+
return [symbolName, `${import.meta.env.BASE_URL}@qwik-handlers`];
|
|
1113
|
+
}
|
|
1114
|
+
console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
|
|
1115
|
+
return [symbolName, `${import.meta.env.BASE_URL}${symbolName}.js`];
|
|
1116
|
+
}
|
|
1117
|
+
const qrlFile = `${import.meta.env.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
|
|
1118
|
+
return [symbolName, qrlFile];
|
|
1119
|
+
};
|
|
1120
|
+
function createPlatform(opts, resolvedManifest) {
|
|
1121
|
+
const mapper = resolvedManifest?.mapper;
|
|
1122
|
+
const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
|
|
1123
|
+
if (mapper || isDev4 && import.meta.env.MODE !== "test") {
|
|
1124
|
+
const hash2 = getSymbolHash(symbolName);
|
|
1125
|
+
const result = !isDev4 ? mapper[hash2] : getDevSegmentPath(mapper, hash2, symbolName, parent);
|
|
1126
|
+
if (!result) {
|
|
1127
|
+
if (hash2 === SYNC_QRL) {
|
|
1128
|
+
return [hash2, ""];
|
|
1129
|
+
}
|
|
1130
|
+
const isRegistered = globalThis.__qwik_reg_symbols?.has(hash2);
|
|
1131
|
+
if (isRegistered) {
|
|
1132
|
+
return [symbolName, "_"];
|
|
1133
|
+
}
|
|
1134
|
+
console.error("Cannot resolve symbol", symbolName, "in", mapper, parent);
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
const serverPlatform = {
|
|
1140
|
+
isServer: true,
|
|
1141
|
+
async importSymbol(_containerEl, url, symbolName) {
|
|
1142
|
+
const hash2 = getSymbolHash(symbolName);
|
|
1143
|
+
const regSym = globalThis.__qwik_reg_symbols?.get(hash2);
|
|
1144
|
+
if (regSym) {
|
|
1145
|
+
return regSym;
|
|
1146
|
+
}
|
|
1147
|
+
let modulePath = String(url);
|
|
1148
|
+
if (!modulePath.endsWith(".js")) {
|
|
1149
|
+
modulePath += ".js";
|
|
1150
|
+
}
|
|
1151
|
+
const module = __require(modulePath);
|
|
1152
|
+
if (!(symbolName in module)) {
|
|
1153
|
+
throw new Error(`Q-ERROR: missing symbol '${symbolName}' in module '${modulePath}'.`);
|
|
1154
|
+
}
|
|
1155
|
+
return module[symbolName];
|
|
1156
|
+
},
|
|
1157
|
+
raf: () => {
|
|
1158
|
+
console.error("server can not rerender");
|
|
1159
|
+
return Promise.resolve();
|
|
1160
|
+
},
|
|
1161
|
+
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1162
|
+
return mapperFn(symbolName, mapper, parent);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
return serverPlatform;
|
|
1166
|
+
}
|
|
1167
|
+
async function setServerPlatform(opts, manifest) {
|
|
1168
|
+
const platform = createPlatform(opts, manifest);
|
|
1169
|
+
setPlatform(platform);
|
|
1170
|
+
}
|
|
1171
|
+
var getSymbolHash = (symbolName) => {
|
|
1172
|
+
const index = symbolName.lastIndexOf("_");
|
|
1173
|
+
if (index > -1) {
|
|
1174
|
+
return symbolName.slice(index + 1);
|
|
1175
|
+
}
|
|
1176
|
+
return symbolName;
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
// packages/qwik/src/server/utils.ts
|
|
1180
|
+
function createTimer() {
|
|
1181
|
+
if (typeof performance === "undefined") {
|
|
1182
|
+
return () => 0;
|
|
1183
|
+
}
|
|
1184
|
+
const start = performance.now();
|
|
1185
|
+
return () => {
|
|
1186
|
+
const end = performance.now();
|
|
1187
|
+
const delta = end - start;
|
|
1188
|
+
return delta / 1e6;
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
function getBuildBase(opts) {
|
|
1192
|
+
let base2 = opts.base;
|
|
1193
|
+
if (typeof opts.base === "function") {
|
|
1194
|
+
base2 = opts.base(opts);
|
|
1195
|
+
}
|
|
1196
|
+
if (typeof base2 === "string") {
|
|
1197
|
+
if (!base2.endsWith("/")) {
|
|
1198
|
+
base2 += "/";
|
|
1199
|
+
}
|
|
1200
|
+
return base2;
|
|
1201
|
+
}
|
|
1202
|
+
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1203
|
+
}
|
|
1204
|
+
var versions = {
|
|
1205
|
+
qwik: "2.0.0-beta.21-dev+c008e88",
|
|
1206
|
+
qwikDom: "2.1.19"
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
// packages/qwik/src/server/ssr-container.ts
|
|
1210
|
+
import { isDev as isDev6 } from "@qwik.dev/core/build";
|
|
1211
|
+
import {
|
|
1212
|
+
_SubscriptionData as SubscriptionData,
|
|
1213
|
+
_SharedContainer,
|
|
1214
|
+
_jsxSorted,
|
|
1215
|
+
_jsxSplit,
|
|
1216
|
+
_walkJSX,
|
|
1217
|
+
isSignal
|
|
1218
|
+
} from "@qwik.dev/core/internal";
|
|
1219
|
+
|
|
1220
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1221
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1222
|
+
|
|
1223
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1224
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1225
|
+
const urls = [];
|
|
1226
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1227
|
+
if (prefetchResources2) {
|
|
1228
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1229
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1230
|
+
urls.push(prefetchResource.url);
|
|
1231
|
+
if (prefetchResource.imports) {
|
|
1232
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
addPrefetchResource(prefetchResources);
|
|
1239
|
+
return urls;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1243
|
+
var getBundles = (qrls) => {
|
|
1244
|
+
const platform = getPlatform();
|
|
1245
|
+
const bundles2 = qrls?.map((qrl) => {
|
|
1246
|
+
const symbol = qrl.$symbol$;
|
|
1247
|
+
const chunk = qrl.$chunk$;
|
|
1248
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1249
|
+
if (result) {
|
|
1250
|
+
return result[1];
|
|
1251
|
+
}
|
|
1252
|
+
return chunk;
|
|
1253
|
+
}).filter(Boolean);
|
|
1254
|
+
return [...new Set(bundles2)];
|
|
1255
|
+
};
|
|
1256
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1257
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1258
|
+
if (prefetchStrategy === null) {
|
|
1259
|
+
return [];
|
|
1260
|
+
}
|
|
1261
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1262
|
+
return getBundles(qrls);
|
|
1263
|
+
}
|
|
1264
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1265
|
+
try {
|
|
1266
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1267
|
+
manifest: resolvedManifest.manifest
|
|
1268
|
+
});
|
|
1269
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1270
|
+
} catch (e) {
|
|
1271
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1275
|
+
for (const qrl of qrls) {
|
|
1276
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1277
|
+
if (symbol && symbol.length >= 10) {
|
|
1278
|
+
symbols.add(symbol);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
return [...symbols];
|
|
1282
|
+
}
|
|
1283
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1284
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1285
|
+
return [...new Set(names)];
|
|
1286
|
+
}
|
|
1287
|
+
resetQueue();
|
|
1288
|
+
let probability = 0.99;
|
|
1289
|
+
for (const name of names) {
|
|
1290
|
+
preload(name, probability);
|
|
1291
|
+
probability *= 0.95;
|
|
1292
|
+
}
|
|
1293
|
+
return getQueue();
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1296
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1297
|
+
var simplifyPath = (base2, path) => {
|
|
1298
|
+
if (path == null) {
|
|
1299
|
+
return null;
|
|
1300
|
+
}
|
|
1301
|
+
const segments = `${base2}${path}`.split("/");
|
|
1302
|
+
const simplified = [];
|
|
1303
|
+
for (const segment of segments) {
|
|
1304
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1305
|
+
simplified.pop();
|
|
1306
|
+
} else {
|
|
1307
|
+
simplified.push(segment);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
return simplified.join("/");
|
|
1311
|
+
};
|
|
1312
|
+
var getBase = (container) => {
|
|
1313
|
+
let base2 = container.$buildBase$;
|
|
1314
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1315
|
+
base2 = import.meta.env.BASE_URL;
|
|
1316
|
+
}
|
|
1317
|
+
return base2;
|
|
1318
|
+
};
|
|
1319
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1320
|
+
const { resolvedManifest } = container;
|
|
1321
|
+
const base2 = getBase(container);
|
|
1322
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1323
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1324
|
+
if (bundleGraphPath) {
|
|
1325
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1326
|
+
}
|
|
1327
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1328
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1329
|
+
debug: options.debug,
|
|
1330
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1331
|
+
} : void 0;
|
|
1332
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1333
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1334
|
+
const opts = [];
|
|
1335
|
+
if (options) {
|
|
1336
|
+
if (options.debug) {
|
|
1337
|
+
opts.push("d:1");
|
|
1338
|
+
}
|
|
1339
|
+
if (options.maxIdlePreloads) {
|
|
1340
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1341
|
+
}
|
|
1342
|
+
if (options.preloadProbability) {
|
|
1343
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1010
1344
|
}
|
|
1011
1345
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1346
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1347
|
+
const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
|
|
1348
|
+
if (nonce) {
|
|
1349
|
+
preloaderLinkAttrs.push("nonce", nonce);
|
|
1350
|
+
}
|
|
1351
|
+
container.openElement("link", null, preloaderLinkAttrs);
|
|
1352
|
+
container.closeElement();
|
|
1353
|
+
container.openElement("link", null, [
|
|
1354
|
+
"rel",
|
|
1355
|
+
"preload",
|
|
1356
|
+
"href",
|
|
1357
|
+
bundleGraphPath,
|
|
1358
|
+
"as",
|
|
1359
|
+
"fetch",
|
|
1360
|
+
"crossorigin",
|
|
1361
|
+
"anonymous"
|
|
1362
|
+
]);
|
|
1363
|
+
container.closeElement();
|
|
1364
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1365
|
+
const scriptAttrs = ["type", "module", "async", true, "crossorigin", "anonymous"];
|
|
1366
|
+
if (nonce) {
|
|
1367
|
+
scriptAttrs.push("nonce", nonce);
|
|
1368
|
+
}
|
|
1369
|
+
container.openElement("script", null, scriptAttrs);
|
|
1370
|
+
container.write(script);
|
|
1371
|
+
container.closeElement();
|
|
1014
1372
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1373
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1374
|
+
if (corePath) {
|
|
1375
|
+
const linkAttrs = ["rel", "modulepreload", "href", corePath];
|
|
1376
|
+
if (nonce) {
|
|
1377
|
+
linkAttrs.push("nonce", nonce);
|
|
1378
|
+
}
|
|
1379
|
+
container.openElement("link", null, linkAttrs);
|
|
1380
|
+
container.closeElement();
|
|
1017
1381
|
}
|
|
1018
1382
|
};
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1383
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1384
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1385
|
+
return null;
|
|
1386
|
+
}
|
|
1387
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1388
|
+
typeof options === "boolean" ? void 0 : options
|
|
1389
|
+
);
|
|
1390
|
+
let allowed = ssrPreloads;
|
|
1391
|
+
const base2 = getBase(container);
|
|
1392
|
+
const links = [];
|
|
1393
|
+
const { resolvedManifest } = container;
|
|
1394
|
+
if (allowed) {
|
|
1395
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1396
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1397
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1398
|
+
let probability = 4;
|
|
1399
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1400
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1401
|
+
if (typeof hrefOrProbability === "string") {
|
|
1402
|
+
if (probability < tenXMinProbability) {
|
|
1403
|
+
break;
|
|
1039
1404
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
return [symbolName, "_"];
|
|
1405
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1406
|
+
continue;
|
|
1043
1407
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1408
|
+
links.push(hrefOrProbability);
|
|
1409
|
+
if (--allowed === 0) {
|
|
1410
|
+
break;
|
|
1046
1411
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
return result;
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
const serverPlatform = {
|
|
1053
|
-
isServer: true,
|
|
1054
|
-
async importSymbol(_containerEl, url, symbolName) {
|
|
1055
|
-
const hash2 = getSymbolHash(symbolName);
|
|
1056
|
-
const regSym = globalThis.__qwik_reg_symbols?.get(hash2);
|
|
1057
|
-
if (regSym) {
|
|
1058
|
-
return regSym;
|
|
1059
|
-
}
|
|
1060
|
-
let modulePath = String(url);
|
|
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}'.`);
|
|
1412
|
+
} else {
|
|
1413
|
+
probability = hrefOrProbability;
|
|
1067
1414
|
}
|
|
1068
|
-
return module[symbolName];
|
|
1069
|
-
},
|
|
1070
|
-
raf: () => {
|
|
1071
|
-
console.error("server can not rerender");
|
|
1072
|
-
return Promise.resolve();
|
|
1073
|
-
},
|
|
1074
|
-
nextTick: (fn) => {
|
|
1075
|
-
return new Promise((resolve) => {
|
|
1076
|
-
setTimeout(() => {
|
|
1077
|
-
resolve(fn());
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
},
|
|
1081
|
-
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1082
|
-
return mapperFn(symbolName, mapper, parent);
|
|
1083
1415
|
}
|
|
1084
|
-
};
|
|
1085
|
-
return serverPlatform;
|
|
1086
|
-
}
|
|
1087
|
-
async function setServerPlatform(opts, manifest) {
|
|
1088
|
-
const platform = createPlatform(opts, manifest);
|
|
1089
|
-
setPlatform(platform);
|
|
1090
|
-
}
|
|
1091
|
-
var getSymbolHash = (symbolName) => {
|
|
1092
|
-
const index = symbolName.lastIndexOf("_");
|
|
1093
|
-
if (index > -1) {
|
|
1094
|
-
return symbolName.slice(index + 1);
|
|
1095
1416
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1417
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1418
|
+
const insertLinks = links.length ? (
|
|
1419
|
+
/**
|
|
1420
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1421
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1422
|
+
* links.
|
|
1423
|
+
*/
|
|
1424
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1425
|
+
) : "";
|
|
1426
|
+
let script = insertLinks;
|
|
1427
|
+
if (preloaderBundle) {
|
|
1428
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1103
1429
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
let base2 = opts.base;
|
|
1113
|
-
if (typeof opts.base === "function") {
|
|
1114
|
-
base2 = opts.base(opts);
|
|
1430
|
+
if (script) {
|
|
1431
|
+
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1432
|
+
if (nonce) {
|
|
1433
|
+
attrs.push("nonce", nonce);
|
|
1434
|
+
}
|
|
1435
|
+
container.openElement("script", null, attrs);
|
|
1436
|
+
container.write(script);
|
|
1437
|
+
container.closeElement();
|
|
1115
1438
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1439
|
+
return null;
|
|
1440
|
+
};
|
|
1441
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1442
|
+
if (opts.preloader !== false) {
|
|
1443
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1444
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1445
|
+
if (preloadBundles.length > 0) {
|
|
1446
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1119
1447
|
}
|
|
1120
|
-
return base2;
|
|
1121
1448
|
}
|
|
1122
|
-
|
|
1449
|
+
};
|
|
1450
|
+
function normalizePreLoaderOptions(input) {
|
|
1451
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1123
1452
|
}
|
|
1124
|
-
var
|
|
1125
|
-
|
|
1126
|
-
|
|
1453
|
+
var preLoaderOptionsDefault = {
|
|
1454
|
+
ssrPreloads: 7,
|
|
1455
|
+
ssrPreloadProbability: 0.5,
|
|
1456
|
+
debug: false,
|
|
1457
|
+
maxIdlePreloads: 25,
|
|
1458
|
+
preloadProbability: 0.35
|
|
1459
|
+
// deprecated
|
|
1127
1460
|
};
|
|
1128
1461
|
|
|
1129
|
-
// packages/qwik/src/server/ssr-container.ts
|
|
1130
|
-
import {
|
|
1131
|
-
_SubscriptionData as SubscriptionData,
|
|
1132
|
-
_SharedContainer,
|
|
1133
|
-
_jsxSorted,
|
|
1134
|
-
_jsxSplit,
|
|
1135
|
-
_walkJSX,
|
|
1136
|
-
isSignal
|
|
1137
|
-
} from "@qwik.dev/core";
|
|
1138
|
-
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
1139
|
-
|
|
1140
1462
|
// 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
|
|
1463
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",r="d",n=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,r=!1)=>e.addEventListener(t,o,{capture:r,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,r,n)=>{n&&(t.hasAttribute("preventdefault:"+n)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+n)&&o.stopPropagation());const s=t._qDispatch?.[r];if(s){if(s.length)for(const e of s){const r=e?.(o,t);f(r)&&await r}else await s(o,t);return}const a=t.getAttribute("q-"+r);if(a){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),n=r.getAttribute("q:base"),s=new URL(n,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:n,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=r.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${n}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(r),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)}}},E=async e=>{const t=m(e.type),o="e:"+t;let r=e.target;for(;r&&r.getAttribute;){const n=y(r,e,o,t),s=e.bubbles&&!e.cancelBubble;f(n)&&await n,r=s&&e.bubbles&&!e.cancelBubble?r.parentElement:null}},g=(e,t)=>{const o=m(t.type),r=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,r,o))},A=async e=>{g(r,e)},C=e=>{g(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),n.has("d:qinit")){n.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}n.has("d:qidle")&&(n.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")})})),n.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(const i of e)if("string"==typeof i){if(!n.has(i)){n.add(i);const{scope:e,eventName:a}=w(i);e===o?d(t,a,C,!0):s.forEach(t=>d(t,a,e===r?A:E,!0)),1!==c||"e:qvisible"!==i&&"d:qinit"!==i&&"d:qidle"!==i||k()}}else s.has(i)||(n.forEach(e=>{const{scope:t,eventName:n}=w(e);t!==o&&d(i,n,t===r?A:E,!0)}),s.add(i))},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:n,roots:s,push:_},d(e,"readystatechange",k),k())';
|
|
1464
|
+
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 (handlers.length) {\n for (const handler of handlers) {\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n } else {\n await handlers(ev, element);\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 (const eventNameOrRoot of eventNames) {\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}';
|
|
1465
|
+
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))}}}}`;
|
|
1466
|
+
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1467
|
+
const executorScript = document.currentScript;
|
|
1468
|
+
if (executorScript) {
|
|
1469
|
+
const container = executorScript.closest(
|
|
1470
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1471
|
+
);
|
|
1472
|
+
if (container) {
|
|
1473
|
+
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1474
|
+
if (script) {
|
|
1475
|
+
const data = JSON.parse(script.textContent || "[]");
|
|
1476
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1477
|
+
let currentNode = walker.currentNode;
|
|
1478
|
+
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1479
|
+
for (let i = 0; i < data.length; i += 3) {
|
|
1480
|
+
const elementIdx = data[i];
|
|
1481
|
+
const attrName = data[i + 1];
|
|
1482
|
+
let value = data[i + 2];
|
|
1483
|
+
while (currentNodeIdx < elementIdx) {
|
|
1484
|
+
currentNode = walker.nextNode();
|
|
1485
|
+
if (!currentNode) {
|
|
1486
|
+
break;
|
|
1487
|
+
}
|
|
1488
|
+
if (currentNode.hasAttribute(":")) {
|
|
1489
|
+
currentNodeIdx++;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
const element = currentNode;
|
|
1493
|
+
if (value == null || value === false) {
|
|
1494
|
+
element.removeAttribute(attrName);
|
|
1495
|
+
} else {
|
|
1496
|
+
if (typeof value === "boolean") {
|
|
1497
|
+
value = "";
|
|
1498
|
+
}
|
|
1499
|
+
element.setAttribute(attrName, value);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
}`;
|
|
1143
1505
|
function getQwikLoaderScript(opts = {}) {
|
|
1144
1506
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1145
1507
|
}
|
|
@@ -1148,19 +1510,20 @@ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
|
1148
1510
|
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1149
1511
|
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1150
1512
|
}
|
|
1513
|
+
function getQwikBackpatchExecutorScript(opts = {}) {
|
|
1514
|
+
return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
|
|
1515
|
+
}
|
|
1151
1516
|
|
|
1152
1517
|
// packages/qwik/src/server/ssr-node.ts
|
|
1153
|
-
import {
|
|
1154
|
-
|
|
1155
|
-
_EMPTY_ARRAY,
|
|
1156
|
-
_EFFECT_BACK_REF
|
|
1157
|
-
} from "@qwik.dev/core";
|
|
1158
|
-
import { isDev as isDev3 } from "@qwik.dev/core/build";
|
|
1518
|
+
import { _isJSXNode as isJSXNode, _EMPTY_ARRAY, _EFFECT_BACK_REF } from "@qwik.dev/core/internal";
|
|
1519
|
+
import { isDev as isDev5 } from "@qwik.dev/core/build";
|
|
1159
1520
|
var SsrNode = class {
|
|
1160
|
-
constructor(
|
|
1521
|
+
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1522
|
+
this.parentComponent = parentComponent;
|
|
1161
1523
|
this.attributesIndex = attributesIndex;
|
|
1162
1524
|
this.cleanupQueue = cleanupQueue;
|
|
1163
1525
|
this.vnodeData = vnodeData;
|
|
1526
|
+
this.currentFile = currentFile;
|
|
1164
1527
|
__publicField(this, "__brand__", "SsrNode");
|
|
1165
1528
|
/**
|
|
1166
1529
|
* ID which the deserialize will use to retrieve the node.
|
|
@@ -1168,16 +1531,17 @@ var SsrNode = class {
|
|
|
1168
1531
|
* @param id - Unique id for the node.
|
|
1169
1532
|
*/
|
|
1170
1533
|
__publicField(this, "id");
|
|
1171
|
-
__publicField(this, "
|
|
1534
|
+
__publicField(this, "flags");
|
|
1535
|
+
__publicField(this, "dirty", 0 /* NONE */);
|
|
1172
1536
|
__publicField(this, "children", null);
|
|
1173
1537
|
__publicField(this, "attrs");
|
|
1174
1538
|
/** Local props which don't serialize; */
|
|
1175
1539
|
__publicField(this, "localProps", null);
|
|
1176
|
-
this.parentSsrNode = parentSsrNode;
|
|
1177
|
-
this.parentSsrNode?.addChild(this);
|
|
1178
1540
|
this.id = id;
|
|
1541
|
+
this.flags = 1 /* Updatable */;
|
|
1179
1542
|
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_ARRAY;
|
|
1180
|
-
|
|
1543
|
+
this.parentComponent?.addChild(this);
|
|
1544
|
+
if (isDev5 && id.indexOf("undefined") != -1) {
|
|
1181
1545
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1182
1546
|
}
|
|
1183
1547
|
}
|
|
@@ -1230,18 +1594,32 @@ var SsrNode = class {
|
|
|
1230
1594
|
}
|
|
1231
1595
|
this.children.push(child);
|
|
1232
1596
|
}
|
|
1597
|
+
setTreeNonUpdatable() {
|
|
1598
|
+
if (this.flags & 1 /* Updatable */) {
|
|
1599
|
+
this.flags &= ~1 /* Updatable */;
|
|
1600
|
+
if (this.children) {
|
|
1601
|
+
for (const child of this.children) {
|
|
1602
|
+
child.setTreeNonUpdatable();
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1233
1607
|
toString() {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1608
|
+
if (isDev5) {
|
|
1609
|
+
let stringifiedAttrs = "";
|
|
1610
|
+
for (let i = 0; i < this.attrs.length; i += 2) {
|
|
1611
|
+
const key = this.attrs[i];
|
|
1612
|
+
const value = this.attrs[i + 1];
|
|
1613
|
+
stringifiedAttrs += `${key}=`;
|
|
1614
|
+
stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
|
|
1615
|
+
if (i < this.attrs.length - 2) {
|
|
1616
|
+
stringifiedAttrs += ", ";
|
|
1617
|
+
}
|
|
1242
1618
|
}
|
|
1619
|
+
return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
|
|
1620
|
+
} else {
|
|
1621
|
+
return `<SSRNode id="${this.id}" />`;
|
|
1243
1622
|
}
|
|
1244
|
-
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1245
1623
|
}
|
|
1246
1624
|
};
|
|
1247
1625
|
var DomRef = class {
|
|
@@ -1311,13 +1689,6 @@ var SsrComponentFrame = class {
|
|
|
1311
1689
|
projectionNode.setProp(QSlotParent, this.componentNode.id);
|
|
1312
1690
|
return children;
|
|
1313
1691
|
}
|
|
1314
|
-
releaseUnclaimedProjections(unclaimedProjections) {
|
|
1315
|
-
if (this.slots.length) {
|
|
1316
|
-
unclaimedProjections.push(this);
|
|
1317
|
-
unclaimedProjections.push(this.projectionScopedStyle);
|
|
1318
|
-
unclaimedProjections.push.apply(unclaimedProjections, this.slots);
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
1692
|
};
|
|
1322
1693
|
|
|
1323
1694
|
// packages/qwik/src/server/tag-nesting.ts
|
|
@@ -1352,6 +1723,10 @@ var allowedContent = (state) => {
|
|
|
1352
1723
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1353
1724
|
case 1026 /* PHRASING_CONTAINER */:
|
|
1354
1725
|
return ["phrasing content", "<a>, <b>, <img>, <input> ... (no <div>, <p> ...)"];
|
|
1726
|
+
case 2050 /* PICTURE */:
|
|
1727
|
+
return ["picture content", "<source>, <img>"];
|
|
1728
|
+
case 4098 /* BUTTON */:
|
|
1729
|
+
return ["button content", "phrasing content except interactive elements"];
|
|
1355
1730
|
case 1 /* DOCUMENT */:
|
|
1356
1731
|
return ["document", "<html>"];
|
|
1357
1732
|
}
|
|
@@ -1393,6 +1768,10 @@ function isTagAllowed(state, tag) {
|
|
|
1393
1768
|
return isInPhrasing(tag, true);
|
|
1394
1769
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1395
1770
|
return isInPhrasing(tag, false);
|
|
1771
|
+
case 2050 /* PICTURE */:
|
|
1772
|
+
return isInPicture(tag);
|
|
1773
|
+
case 4098 /* BUTTON */:
|
|
1774
|
+
return isInButton(tag);
|
|
1396
1775
|
case 1 /* DOCUMENT */:
|
|
1397
1776
|
if (tag === "html") {
|
|
1398
1777
|
return 32 /* HTML */;
|
|
@@ -1472,9 +1851,12 @@ function isInAnything(text) {
|
|
|
1472
1851
|
case "body":
|
|
1473
1852
|
return 0 /* NOT_ALLOWED */;
|
|
1474
1853
|
case "button":
|
|
1854
|
+
return 4098 /* BUTTON */;
|
|
1475
1855
|
case "input":
|
|
1476
1856
|
case "textarea":
|
|
1477
1857
|
return 514 /* PHRASING_INSIDE_INPUT */;
|
|
1858
|
+
case "picture":
|
|
1859
|
+
return 2050 /* PICTURE */;
|
|
1478
1860
|
default:
|
|
1479
1861
|
return 10 /* ANYTHING */;
|
|
1480
1862
|
}
|
|
@@ -1489,6 +1871,8 @@ function isInTable(text) {
|
|
|
1489
1871
|
case "tbody":
|
|
1490
1872
|
case "tfoot":
|
|
1491
1873
|
return 8192 /* TABLE_BODY */;
|
|
1874
|
+
case "script":
|
|
1875
|
+
return 2 /* TEXT */;
|
|
1492
1876
|
default:
|
|
1493
1877
|
return 0 /* NOT_ALLOWED */;
|
|
1494
1878
|
}
|
|
@@ -1497,6 +1881,8 @@ function isInTableBody(text) {
|
|
|
1497
1881
|
switch (text) {
|
|
1498
1882
|
case "tr":
|
|
1499
1883
|
return 16384 /* TABLE_ROW */;
|
|
1884
|
+
case "script":
|
|
1885
|
+
return 2 /* TEXT */;
|
|
1500
1886
|
default:
|
|
1501
1887
|
return 0 /* NOT_ALLOWED */;
|
|
1502
1888
|
}
|
|
@@ -1506,24 +1892,53 @@ function isInTableRow(text) {
|
|
|
1506
1892
|
case "td":
|
|
1507
1893
|
case "th":
|
|
1508
1894
|
return 10 /* ANYTHING */;
|
|
1895
|
+
case "script":
|
|
1896
|
+
return 2 /* TEXT */;
|
|
1897
|
+
default:
|
|
1898
|
+
return 0 /* NOT_ALLOWED */;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
function isInTableColGroup(text) {
|
|
1902
|
+
switch (text) {
|
|
1903
|
+
case "col":
|
|
1904
|
+
return 4 /* EMPTY */;
|
|
1905
|
+
case "script":
|
|
1906
|
+
return 2 /* TEXT */;
|
|
1509
1907
|
default:
|
|
1510
1908
|
return 0 /* NOT_ALLOWED */;
|
|
1511
1909
|
}
|
|
1512
1910
|
}
|
|
1513
|
-
function
|
|
1911
|
+
function isInPicture(text) {
|
|
1514
1912
|
switch (text) {
|
|
1515
|
-
case "
|
|
1913
|
+
case "source":
|
|
1914
|
+
return 4 /* EMPTY */;
|
|
1915
|
+
case "img":
|
|
1516
1916
|
return 4 /* EMPTY */;
|
|
1917
|
+
case "script":
|
|
1918
|
+
return 2 /* TEXT */;
|
|
1517
1919
|
default:
|
|
1518
1920
|
return 0 /* NOT_ALLOWED */;
|
|
1519
1921
|
}
|
|
1520
1922
|
}
|
|
1923
|
+
function isInButton(text) {
|
|
1924
|
+
switch (text) {
|
|
1925
|
+
case "button":
|
|
1926
|
+
case "input":
|
|
1927
|
+
case "textarea":
|
|
1928
|
+
case "select":
|
|
1929
|
+
case "a":
|
|
1930
|
+
return 0 /* NOT_ALLOWED */;
|
|
1931
|
+
case "picture":
|
|
1932
|
+
return 2050 /* PICTURE */;
|
|
1933
|
+
default:
|
|
1934
|
+
return isInPhrasing(text, false);
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1521
1937
|
function isInPhrasing(text, allowInput) {
|
|
1522
1938
|
switch (text) {
|
|
1523
1939
|
case "svg":
|
|
1524
1940
|
case "math":
|
|
1525
1941
|
return 1026 /* PHRASING_CONTAINER */;
|
|
1526
|
-
case "button":
|
|
1527
1942
|
case "input":
|
|
1528
1943
|
case "textarea":
|
|
1529
1944
|
return allowInput ? 514 /* PHRASING_INSIDE_INPUT */ : 0 /* NOT_ALLOWED */;
|
|
@@ -1535,6 +1950,7 @@ function isInPhrasing(text, allowInput) {
|
|
|
1535
1950
|
case "bdi":
|
|
1536
1951
|
case "bdo":
|
|
1537
1952
|
case "br":
|
|
1953
|
+
case "button":
|
|
1538
1954
|
case "canvas":
|
|
1539
1955
|
case "cite":
|
|
1540
1956
|
case "code":
|
|
@@ -1562,13 +1978,11 @@ function isInPhrasing(text, allowInput) {
|
|
|
1562
1978
|
case "object":
|
|
1563
1979
|
case "option":
|
|
1564
1980
|
case "output":
|
|
1565
|
-
case "picture":
|
|
1566
1981
|
case "progress":
|
|
1567
1982
|
case "q":
|
|
1568
1983
|
case "ruby":
|
|
1569
1984
|
case "s":
|
|
1570
1985
|
case "samp":
|
|
1571
|
-
case "script":
|
|
1572
1986
|
case "select":
|
|
1573
1987
|
case "slot":
|
|
1574
1988
|
case "small":
|
|
@@ -1583,332 +1997,110 @@ function isInPhrasing(text, allowInput) {
|
|
|
1583
1997
|
case "video":
|
|
1584
1998
|
case "wbr":
|
|
1585
1999
|
return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
|
|
2000
|
+
case "script":
|
|
1586
2001
|
case "style":
|
|
1587
2002
|
return 2 /* TEXT */;
|
|
2003
|
+
case "picture":
|
|
2004
|
+
return 2050 /* PICTURE */;
|
|
1588
2005
|
default:
|
|
1589
2006
|
return 0 /* NOT_ALLOWED */;
|
|
1590
2007
|
}
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
// packages/qwik/src/server/vnode-data.ts
|
|
1594
|
-
var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
|
|
1595
|
-
var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
|
|
1596
|
-
var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
|
|
1597
|
-
function vNodeData_incrementElementCount(vNodeData) {
|
|
1598
|
-
const length = vNodeData.length;
|
|
1599
|
-
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
1600
|
-
if (lastValue >= 0) {
|
|
1601
|
-
vNodeData.push(-1);
|
|
1602
|
-
} else {
|
|
1603
|
-
vNodeData[length - 1] = lastValue - 1;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
function vNodeData_addTextSize(vNodeData, size) {
|
|
1607
|
-
const length = vNodeData.length;
|
|
1608
|
-
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
1609
|
-
if (length > 1 && lastValue >= 0) {
|
|
1610
|
-
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1611
|
-
}
|
|
1612
|
-
vNodeData.push(size);
|
|
1613
|
-
if (size == 0) {
|
|
1614
|
-
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
function vNodeData_openFragment(vNodeData, attrs) {
|
|
1618
|
-
vNodeData.push(attrs, OPEN_FRAGMENT);
|
|
1619
|
-
vNodeData[0] |= 2 /* VIRTUAL_NODE */;
|
|
1620
|
-
}
|
|
1621
|
-
function vNodeData_closeFragment(vNodeData) {
|
|
1622
|
-
vNodeData.push(CLOSE_FRAGMENT);
|
|
1623
|
-
}
|
|
1624
|
-
function vNodeData_openElement(vNodeData) {
|
|
1625
|
-
vNodeData.push([], WRITE_ELEMENT_ATTRS);
|
|
1626
|
-
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
1627
|
-
}
|
|
1628
|
-
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
1629
|
-
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1630
|
-
const stack = [-1];
|
|
1631
|
-
let attributesIndex = -1;
|
|
1632
|
-
for (let i = 1; i < vNodeData.length; i++) {
|
|
1633
|
-
const value = vNodeData[i];
|
|
1634
|
-
if (Array.isArray(value)) {
|
|
1635
|
-
attributesIndex = i;
|
|
1636
|
-
i++;
|
|
1637
|
-
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
1638
|
-
stack[stack.length - 1]++;
|
|
1639
|
-
stack.push(-1);
|
|
1640
|
-
}
|
|
1641
|
-
} else if (value === CLOSE_FRAGMENT) {
|
|
1642
|
-
stack.pop();
|
|
1643
|
-
} else if (value < 0) {
|
|
1644
|
-
const numberOfElements = 0 - value;
|
|
1645
|
-
stack[stack.length - 1] += numberOfElements;
|
|
1646
|
-
} 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();
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
// packages/qwik/src/server/vnode-data.ts
|
|
2011
|
+
var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
|
|
2012
|
+
var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
|
|
2013
|
+
var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
|
|
2014
|
+
function vNodeData_incrementElementCount(vNodeData) {
|
|
2015
|
+
const length = vNodeData.length;
|
|
2016
|
+
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
2017
|
+
if (lastValue >= 0) {
|
|
2018
|
+
vNodeData.push(-1);
|
|
2019
|
+
} else {
|
|
2020
|
+
vNodeData[length - 1] = lastValue - 1;
|
|
1833
2021
|
}
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
2022
|
+
}
|
|
2023
|
+
function vNodeData_addTextSize(vNodeData, size) {
|
|
2024
|
+
const length = vNodeData.length;
|
|
2025
|
+
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
2026
|
+
if (length > 1 && lastValue >= 0) {
|
|
2027
|
+
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1838
2028
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2029
|
+
vNodeData.push(size);
|
|
2030
|
+
if (size == 0) {
|
|
2031
|
+
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
function vNodeData_openFragment(vNodeData, attrs) {
|
|
2035
|
+
vNodeData.push(attrs, OPEN_FRAGMENT);
|
|
2036
|
+
vNodeData[0] |= 2 /* VIRTUAL_NODE */;
|
|
2037
|
+
}
|
|
2038
|
+
function vNodeData_closeFragment(vNodeData) {
|
|
2039
|
+
vNodeData.push(CLOSE_FRAGMENT);
|
|
2040
|
+
}
|
|
2041
|
+
function vNodeData_openElement(vNodeData) {
|
|
2042
|
+
vNodeData.push([], WRITE_ELEMENT_ATTRS);
|
|
2043
|
+
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
2044
|
+
}
|
|
2045
|
+
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
|
|
2046
|
+
vNodeData[0] |= 8 /* REFERENCE */;
|
|
2047
|
+
const stack = [-1];
|
|
2048
|
+
let attributesIndex = -1;
|
|
2049
|
+
for (let i = 1; i < vNodeData.length; i++) {
|
|
2050
|
+
const value = vNodeData[i];
|
|
2051
|
+
if (Array.isArray(value)) {
|
|
2052
|
+
attributesIndex = i;
|
|
2053
|
+
i++;
|
|
2054
|
+
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
2055
|
+
stack[stack.length - 1]++;
|
|
2056
|
+
stack.push(-1);
|
|
1866
2057
|
}
|
|
2058
|
+
} else if (value === CLOSE_FRAGMENT) {
|
|
2059
|
+
stack.pop();
|
|
2060
|
+
} else if (value < 0) {
|
|
2061
|
+
const numberOfElements = 0 - value;
|
|
2062
|
+
stack[stack.length - 1] += numberOfElements;
|
|
2063
|
+
} else {
|
|
2064
|
+
stack[stack.length - 1]++;
|
|
1867
2065
|
}
|
|
1868
2066
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
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);
|
|
2067
|
+
let refId = String(depthFirstElementIdx);
|
|
2068
|
+
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
2069
|
+
for (let i = 0; i < stack.length; i++) {
|
|
2070
|
+
const childCount = stack[i];
|
|
2071
|
+
if (childCount >= 0) {
|
|
2072
|
+
refId += encodeAsAlphanumeric(childCount);
|
|
2073
|
+
}
|
|
1886
2074
|
}
|
|
1887
|
-
container.openElement("script", null, attrs);
|
|
1888
|
-
container.writer.write(script);
|
|
1889
|
-
container.closeElement();
|
|
1890
2075
|
}
|
|
1891
|
-
return
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
2076
|
+
return new SsrNode(
|
|
2077
|
+
currentComponentNode,
|
|
2078
|
+
refId,
|
|
2079
|
+
attributesIndex,
|
|
2080
|
+
cleanupQueue,
|
|
2081
|
+
vNodeData,
|
|
2082
|
+
currentFile
|
|
2083
|
+
);
|
|
2084
|
+
}
|
|
2085
|
+
var ALPHANUMERIC = [];
|
|
2086
|
+
function encodeAsAlphanumeric(value) {
|
|
2087
|
+
while (ALPHANUMERIC.length <= value) {
|
|
2088
|
+
let value2 = ALPHANUMERIC.length;
|
|
2089
|
+
let text = "";
|
|
2090
|
+
do {
|
|
2091
|
+
text = String.fromCharCode(
|
|
2092
|
+
(text.length === 0 ? 65 : 97) + value2 % 26
|
|
2093
|
+
/* A-Z */
|
|
2094
|
+
) + text;
|
|
2095
|
+
value2 = Math.floor(
|
|
2096
|
+
value2 / 26
|
|
2097
|
+
/* A-Z */
|
|
2098
|
+
);
|
|
2099
|
+
} while (value2 !== 0);
|
|
2100
|
+
ALPHANUMERIC.push(text);
|
|
1900
2101
|
}
|
|
1901
|
-
|
|
1902
|
-
function normalizePreLoaderOptions(input) {
|
|
1903
|
-
return { ...preLoaderOptionsDefault, ...input };
|
|
2102
|
+
return ALPHANUMERIC[value];
|
|
1904
2103
|
}
|
|
1905
|
-
var preLoaderOptionsDefault = {
|
|
1906
|
-
ssrPreloads: 7,
|
|
1907
|
-
ssrPreloadProbability: 0.5,
|
|
1908
|
-
debug: false,
|
|
1909
|
-
maxIdlePreloads: 25,
|
|
1910
|
-
preloadProbability: 0.35
|
|
1911
|
-
};
|
|
1912
2104
|
|
|
1913
2105
|
// packages/qwik/src/server/ssr-container.ts
|
|
1914
2106
|
function ssrCreateContainer(opts) {
|
|
@@ -1947,22 +2139,12 @@ var StringBufferWriter = class {
|
|
|
1947
2139
|
var EMPTY_OBJ = {};
|
|
1948
2140
|
var SSRContainer = class extends _SharedContainer {
|
|
1949
2141
|
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
|
-
);
|
|
2142
|
+
super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
|
|
1962
2143
|
__publicField(this, "tag");
|
|
1963
2144
|
__publicField(this, "isHtml");
|
|
1964
2145
|
__publicField(this, "writer");
|
|
1965
2146
|
__publicField(this, "timing");
|
|
2147
|
+
__publicField(this, "size", 0);
|
|
1966
2148
|
__publicField(this, "resolvedManifest");
|
|
1967
2149
|
__publicField(this, "symbolToChunkResolver");
|
|
1968
2150
|
__publicField(this, "renderOptions");
|
|
@@ -1983,6 +2165,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1983
2165
|
__publicField(this, "lastNode", null);
|
|
1984
2166
|
__publicField(this, "currentComponentNode", null);
|
|
1985
2167
|
__publicField(this, "styleIds", /* @__PURE__ */ new Set());
|
|
2168
|
+
__publicField(this, "isBackpatchExecutorEmitted", false);
|
|
2169
|
+
__publicField(this, "backpatchMap", /* @__PURE__ */ new Map());
|
|
1986
2170
|
__publicField(this, "currentElementFrame", null);
|
|
1987
2171
|
__publicField(this, "renderTimer");
|
|
1988
2172
|
/**
|
|
@@ -1994,12 +2178,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1994
2178
|
__publicField(this, "depthFirstElementCount", -1);
|
|
1995
2179
|
__publicField(this, "vNodeDatas", []);
|
|
1996
2180
|
__publicField(this, "componentStack", []);
|
|
1997
|
-
__publicField(this, "unclaimedProjections", []);
|
|
1998
|
-
__publicField(this, "unclaimedProjectionComponentFrameQueue", []);
|
|
1999
2181
|
__publicField(this, "cleanupQueue", []);
|
|
2000
2182
|
__publicField(this, "$instanceHash$", hash());
|
|
2001
2183
|
// Temporary flag to find missing roots after the state was serialized
|
|
2002
2184
|
__publicField(this, "$noMoreRoots$", false);
|
|
2185
|
+
__publicField(this, "qlInclude");
|
|
2186
|
+
__publicField(this, "promiseAttributes", null);
|
|
2187
|
+
__publicField(this, "$noScriptHere$", 0);
|
|
2003
2188
|
this.symbolToChunkResolver = (symbol) => {
|
|
2004
2189
|
const idx = symbol.lastIndexOf("_");
|
|
2005
2190
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2019,6 +2204,15 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2019
2204
|
this.$buildBase$ = opts.buildBase;
|
|
2020
2205
|
this.resolvedManifest = opts.resolvedManifest;
|
|
2021
2206
|
this.renderOptions = opts.renderOptions;
|
|
2207
|
+
this.$currentUniqueId$ = 1e5;
|
|
2208
|
+
const qlOpt = this.renderOptions.qwikLoader;
|
|
2209
|
+
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 */;
|
|
2210
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2211
|
+
const qwikLoaderChunk = this.resolvedManifest?.manifest.qwikLoader;
|
|
2212
|
+
if (!qwikLoaderChunk) {
|
|
2213
|
+
this.qlInclude = 1 /* Inline */;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2022
2216
|
this.$processInjectionsFromManifest$();
|
|
2023
2217
|
}
|
|
2024
2218
|
ensureProjectionResolved(_host) {
|
|
@@ -2026,6 +2220,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2026
2220
|
handleError(err, _$host$) {
|
|
2027
2221
|
throw err;
|
|
2028
2222
|
}
|
|
2223
|
+
addBackpatchEntry(ssrNodeId, attrName, serializedValue) {
|
|
2224
|
+
const elementIndex = parseInt(ssrNodeId, 10);
|
|
2225
|
+
const entry = {
|
|
2226
|
+
attrName,
|
|
2227
|
+
value: serializedValue
|
|
2228
|
+
};
|
|
2229
|
+
const entries = this.backpatchMap.get(elementIndex) || [];
|
|
2230
|
+
entries.push(entry);
|
|
2231
|
+
this.backpatchMap.set(elementIndex, entries);
|
|
2232
|
+
}
|
|
2029
2233
|
async render(jsx) {
|
|
2030
2234
|
this.openContainer();
|
|
2031
2235
|
await _walkJSX(this, jsx, {
|
|
@@ -2037,29 +2241,26 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2037
2241
|
setContext(host, context, value) {
|
|
2038
2242
|
const ssrNode = host;
|
|
2039
2243
|
let ctx = ssrNode.getProp(QCtxAttr);
|
|
2040
|
-
if (
|
|
2244
|
+
if (ctx == null) {
|
|
2041
2245
|
ssrNode.setProp(QCtxAttr, ctx = []);
|
|
2042
2246
|
}
|
|
2043
|
-
mapArray_set(ctx, context.id, value, 0);
|
|
2247
|
+
mapArray_set(ctx, context.id, value, 0, true);
|
|
2044
2248
|
this.addRoot(ssrNode);
|
|
2045
2249
|
}
|
|
2046
2250
|
resolveContext(host, contextId) {
|
|
2047
2251
|
let ssrNode = host;
|
|
2048
2252
|
while (ssrNode) {
|
|
2049
2253
|
const ctx = ssrNode.getProp(QCtxAttr);
|
|
2050
|
-
if (ctx) {
|
|
2051
|
-
|
|
2052
|
-
if (value) {
|
|
2053
|
-
return value;
|
|
2054
|
-
}
|
|
2254
|
+
if (ctx != null && mapArray_has(ctx, contextId.id, 0)) {
|
|
2255
|
+
return mapArray_get(ctx, contextId.id, 0);
|
|
2055
2256
|
}
|
|
2056
|
-
ssrNode = ssrNode.
|
|
2257
|
+
ssrNode = ssrNode.parentComponent;
|
|
2057
2258
|
}
|
|
2058
2259
|
return void 0;
|
|
2059
2260
|
}
|
|
2060
2261
|
getParentHost(host) {
|
|
2061
2262
|
const ssrNode = host;
|
|
2062
|
-
return ssrNode.
|
|
2263
|
+
return ssrNode.parentComponent;
|
|
2063
2264
|
}
|
|
2064
2265
|
setHostProp(host, name, value) {
|
|
2065
2266
|
const ssrNode = host;
|
|
@@ -2082,7 +2283,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2082
2283
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
2083
2284
|
containerAttributes[QRuntimeAttr] = "2";
|
|
2084
2285
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
2085
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
2286
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev6 ? "ssr-dev" : "ssr");
|
|
2086
2287
|
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
2087
2288
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
2088
2289
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
@@ -2095,17 +2296,28 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2095
2296
|
},
|
|
2096
2297
|
[]
|
|
2097
2298
|
);
|
|
2098
|
-
this.openElement(this.tag, containerAttributeArray);
|
|
2299
|
+
this.openElement(this.tag, null, containerAttributeArray);
|
|
2099
2300
|
}
|
|
2100
2301
|
/** Renders closing tag for current container */
|
|
2101
2302
|
closeContainer() {
|
|
2102
2303
|
return this.closeElement();
|
|
2103
2304
|
}
|
|
2104
2305
|
/** Renders opening tag for DOM element */
|
|
2105
|
-
openElement(elementName, varAttrs, constAttrs, currentFile) {
|
|
2306
|
+
openElement(elementName, key, varAttrs, constAttrs, currentFile) {
|
|
2307
|
+
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2308
|
+
if (
|
|
2309
|
+
// don't append qwik loader before qwik style elements
|
|
2310
|
+
// it will confuse the resuming, because styles are expected to be the first nodes in subtree
|
|
2311
|
+
!isQwikStyle && this.qlInclude === 1 /* Inline */
|
|
2312
|
+
) {
|
|
2313
|
+
if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
|
|
2314
|
+
this.emitQwikLoaderInline();
|
|
2315
|
+
} else if (elementName === "noscript" || elementName === "template") {
|
|
2316
|
+
this.$noScriptHere$++;
|
|
2317
|
+
}
|
|
2318
|
+
}
|
|
2106
2319
|
let innerHTML = void 0;
|
|
2107
2320
|
this.lastNode = null;
|
|
2108
|
-
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2109
2321
|
if (!isQwikStyle && this.currentElementFrame) {
|
|
2110
2322
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2111
2323
|
}
|
|
@@ -2113,16 +2325,23 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2113
2325
|
vNodeData_openElement(this.currentElementFrame.vNodeData);
|
|
2114
2326
|
this.write("<");
|
|
2115
2327
|
this.write(elementName);
|
|
2328
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2116
2329
|
if (varAttrs) {
|
|
2117
2330
|
innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
|
|
2118
2331
|
}
|
|
2119
2332
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
2120
|
-
|
|
2333
|
+
if (key !== null) {
|
|
2334
|
+
this.write(`="${key}"`);
|
|
2335
|
+
} else if (isDev6) {
|
|
2336
|
+
this.write('=""');
|
|
2337
|
+
}
|
|
2121
2338
|
if (constAttrs && constAttrs.length) {
|
|
2122
2339
|
innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
|
|
2123
2340
|
}
|
|
2124
2341
|
this.write(">");
|
|
2125
|
-
|
|
2342
|
+
if (lastNode) {
|
|
2343
|
+
lastNode.setTreeNonUpdatable();
|
|
2344
|
+
}
|
|
2126
2345
|
return innerHTML;
|
|
2127
2346
|
}
|
|
2128
2347
|
/** Renders closing tag for DOM element */
|
|
@@ -2175,6 +2394,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2175
2394
|
this.write(">");
|
|
2176
2395
|
}
|
|
2177
2396
|
this.lastNode = null;
|
|
2397
|
+
if (this.qlInclude === 1 /* Inline */) {
|
|
2398
|
+
if (elementName === "noscript" || elementName === "template") {
|
|
2399
|
+
this.$noScriptHere$--;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2178
2402
|
}
|
|
2179
2403
|
/** Writes opening data to vNodeData for fragment boundaries */
|
|
2180
2404
|
openFragment(attrs) {
|
|
@@ -2185,6 +2409,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2185
2409
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
2186
2410
|
closeFragment() {
|
|
2187
2411
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
2412
|
+
if (this.currentComponentNode) {
|
|
2413
|
+
this.currentComponentNode.setTreeNonUpdatable();
|
|
2414
|
+
}
|
|
2188
2415
|
this.lastNode = null;
|
|
2189
2416
|
}
|
|
2190
2417
|
openProjection(attrs) {
|
|
@@ -2224,12 +2451,37 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2224
2451
|
const localProjectionDepth = this.getComponentFrame()?.projectionDepth || 0;
|
|
2225
2452
|
return this.getComponentFrame(localProjectionDepth);
|
|
2226
2453
|
}
|
|
2227
|
-
/** Writes closing data to vNodeData for component boundaries and
|
|
2228
|
-
closeComponent() {
|
|
2454
|
+
/** Writes closing data to vNodeData for component boundaries and emit unclaimed projections inline */
|
|
2455
|
+
async closeComponent() {
|
|
2229
2456
|
const componentFrame = this.componentStack.pop();
|
|
2230
|
-
|
|
2457
|
+
await this.emitUnclaimedProjectionForComponent(componentFrame);
|
|
2231
2458
|
this.closeFragment();
|
|
2232
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2459
|
+
this.currentComponentNode = this.currentComponentNode?.parentComponent || null;
|
|
2460
|
+
}
|
|
2461
|
+
async emitUnclaimedProjectionForComponent(componentFrame) {
|
|
2462
|
+
if (componentFrame.slots.length === 0) {
|
|
2463
|
+
return;
|
|
2464
|
+
}
|
|
2465
|
+
this.openElement(QTemplate, null, ["hidden", true, "aria-hidden", "true"], null);
|
|
2466
|
+
const scopedStyleId = componentFrame.projectionScopedStyle;
|
|
2467
|
+
for (let i = 0; i < componentFrame.slots.length; i += 2) {
|
|
2468
|
+
const slotName = componentFrame.slots[i];
|
|
2469
|
+
const children = componentFrame.slots[i + 1];
|
|
2470
|
+
this.openFragment(
|
|
2471
|
+
isDev6 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, componentFrame.componentNode.id] : [QSlotParent, componentFrame.componentNode.id]
|
|
2472
|
+
);
|
|
2473
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2474
|
+
if (lastNode.vnodeData) {
|
|
2475
|
+
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2476
|
+
}
|
|
2477
|
+
componentFrame.componentNode.setProp(slotName, lastNode.id);
|
|
2478
|
+
await _walkJSX(this, children, {
|
|
2479
|
+
currentStyleScoped: scopedStyleId,
|
|
2480
|
+
parentComponentFrame: componentFrame.projectionComponentFrame
|
|
2481
|
+
});
|
|
2482
|
+
this.closeFragment();
|
|
2483
|
+
}
|
|
2484
|
+
this.closeElement();
|
|
2233
2485
|
}
|
|
2234
2486
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2235
2487
|
textNode(text) {
|
|
@@ -2256,13 +2508,14 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2256
2508
|
this.currentElementFrame.vNodeData,
|
|
2257
2509
|
// we start at -1, so we need to add +1
|
|
2258
2510
|
this.currentElementFrame.depthFirstElementIdx + 1,
|
|
2259
|
-
this.cleanupQueue
|
|
2511
|
+
this.cleanupQueue,
|
|
2512
|
+
this.currentElementFrame.currentFile
|
|
2260
2513
|
);
|
|
2261
2514
|
}
|
|
2262
2515
|
return this.lastNode;
|
|
2263
2516
|
}
|
|
2264
2517
|
addUnclaimedProjection(frame, name, children) {
|
|
2265
|
-
|
|
2518
|
+
frame.slots.push(name, children);
|
|
2266
2519
|
}
|
|
2267
2520
|
$processInjectionsFromManifest$() {
|
|
2268
2521
|
const injections = this.resolvedManifest.manifest.injections;
|
|
@@ -2305,19 +2558,21 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2305
2558
|
}
|
|
2306
2559
|
}
|
|
2307
2560
|
_styleNode(styleId, content) {
|
|
2308
|
-
this.openElement("style", [QStyle, styleId]);
|
|
2561
|
+
this.openElement("style", null, [QStyle, styleId]);
|
|
2309
2562
|
this.write(content);
|
|
2310
2563
|
this.closeElement();
|
|
2311
2564
|
}
|
|
2312
2565
|
////////////////////////////////////
|
|
2313
2566
|
emitContainerData() {
|
|
2314
2567
|
return maybeThen(
|
|
2315
|
-
this.
|
|
2568
|
+
this.resolvePromiseAttributes(),
|
|
2316
2569
|
() => maybeThen(this.emitStateData(), () => {
|
|
2317
2570
|
this.$noMoreRoots$ = true;
|
|
2318
2571
|
this.emitVNodeData();
|
|
2319
2572
|
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2320
2573
|
this.emitSyncFnsData();
|
|
2574
|
+
this.emitPatchDataIfNeeded();
|
|
2575
|
+
this.emitExecutorIfNeeded();
|
|
2321
2576
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2322
2577
|
})
|
|
2323
2578
|
);
|
|
@@ -2344,7 +2599,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2344
2599
|
if (!this.serializationCtx.$roots$.length) {
|
|
2345
2600
|
return;
|
|
2346
2601
|
}
|
|
2347
|
-
this.openElement("script", ["type", "qwik/vnode"]);
|
|
2602
|
+
this.openElement("script", null, ["type", "qwik/vnode"]);
|
|
2348
2603
|
const vNodeAttrsStack = [];
|
|
2349
2604
|
const vNodeData = this.vNodeDatas;
|
|
2350
2605
|
let lastSerializedIdx = 0;
|
|
@@ -2369,7 +2624,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2369
2624
|
this.write(VNodeDataChar.OPEN_CHAR);
|
|
2370
2625
|
} else if (value === CLOSE_FRAGMENT) {
|
|
2371
2626
|
if (fragmentAttrs) {
|
|
2372
|
-
|
|
2627
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2373
2628
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2374
2629
|
}
|
|
2375
2630
|
depth--;
|
|
@@ -2377,7 +2632,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2377
2632
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2378
2633
|
if (fragmentAttrs && fragmentAttrs.length) {
|
|
2379
2634
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2380
|
-
|
|
2635
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2636
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2637
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2381
2638
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2382
2639
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2383
2640
|
}
|
|
@@ -2389,7 +2646,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2389
2646
|
}
|
|
2390
2647
|
while (depth-- > 0) {
|
|
2391
2648
|
if (fragmentAttrs) {
|
|
2392
|
-
|
|
2649
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2393
2650
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2394
2651
|
}
|
|
2395
2652
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
@@ -2397,67 +2654,79 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2397
2654
|
}
|
|
2398
2655
|
}
|
|
2399
2656
|
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2657
|
+
this.closeElement();
|
|
2658
|
+
}
|
|
2659
|
+
writeFragmentAttrs(fragmentAttrs) {
|
|
2660
|
+
for (let i = 0; i < fragmentAttrs.length; ) {
|
|
2661
|
+
const key = fragmentAttrs[i++];
|
|
2662
|
+
let value = fragmentAttrs[i++];
|
|
2663
|
+
let encodeValue = false;
|
|
2664
|
+
if (typeof value !== "string") {
|
|
2665
|
+
const rootId = this.addRoot(value);
|
|
2666
|
+
if (rootId === void 0) {
|
|
2667
|
+
continue;
|
|
2410
2668
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2669
|
+
value = String(rootId);
|
|
2670
|
+
}
|
|
2671
|
+
switch (key) {
|
|
2672
|
+
case QScopedStyle:
|
|
2673
|
+
this.write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2674
|
+
break;
|
|
2675
|
+
case OnRenderProp:
|
|
2676
|
+
this.write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2677
|
+
break;
|
|
2678
|
+
case ELEMENT_ID:
|
|
2679
|
+
this.write(VNodeDataChar.ID_CHAR);
|
|
2680
|
+
break;
|
|
2681
|
+
case ELEMENT_PROPS:
|
|
2682
|
+
this.write(VNodeDataChar.PROPS_CHAR);
|
|
2683
|
+
break;
|
|
2684
|
+
case ELEMENT_KEY:
|
|
2685
|
+
encodeValue = true;
|
|
2686
|
+
this.write(VNodeDataChar.KEY_CHAR);
|
|
2687
|
+
break;
|
|
2688
|
+
case ELEMENT_SEQ:
|
|
2689
|
+
this.write(VNodeDataChar.SEQ_CHAR);
|
|
2690
|
+
break;
|
|
2691
|
+
case ELEMENT_SEQ_IDX:
|
|
2692
|
+
this.write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2693
|
+
break;
|
|
2694
|
+
case QBackRefs:
|
|
2695
|
+
this.write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2696
|
+
break;
|
|
2697
|
+
case QSlotParent:
|
|
2698
|
+
this.write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2699
|
+
break;
|
|
2700
|
+
// Skipping `\` character for now because it is used for escaping.
|
|
2701
|
+
case QCtxAttr:
|
|
2702
|
+
this.write(VNodeDataChar.CONTEXT_CHAR);
|
|
2703
|
+
break;
|
|
2704
|
+
case QSlot:
|
|
2705
|
+
this.write(VNodeDataChar.SLOT_CHAR);
|
|
2706
|
+
break;
|
|
2707
|
+
default: {
|
|
2708
|
+
encodeValue = true;
|
|
2709
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2710
|
+
this.write(encodeVNodeDataString(key));
|
|
2711
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2450
2712
|
}
|
|
2451
|
-
|
|
2713
|
+
}
|
|
2714
|
+
const encodedValue = encodeVNodeDataString(encodeValue ? encodeURI(value) : value);
|
|
2715
|
+
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2716
|
+
if (isEncoded) {
|
|
2717
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2718
|
+
this.write(encodedValue);
|
|
2719
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2720
|
+
} else {
|
|
2721
|
+
this.write(value);
|
|
2452
2722
|
}
|
|
2453
2723
|
}
|
|
2454
|
-
this.closeElement();
|
|
2455
2724
|
}
|
|
2456
2725
|
emitStateData() {
|
|
2457
2726
|
if (!this.serializationCtx.$roots$.length) {
|
|
2458
2727
|
return;
|
|
2459
2728
|
}
|
|
2460
|
-
this.openElement("script", ["type", "qwik/state"]);
|
|
2729
|
+
this.openElement("script", null, ["type", "qwik/state"]);
|
|
2461
2730
|
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2462
2731
|
this.closeElement();
|
|
2463
2732
|
});
|
|
@@ -2469,7 +2738,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2469
2738
|
if (this.renderOptions.serverData?.nonce) {
|
|
2470
2739
|
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2471
2740
|
}
|
|
2472
|
-
this.openElement("script", scriptAttrs);
|
|
2741
|
+
this.openElement("script", null, scriptAttrs);
|
|
2473
2742
|
this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
|
|
2474
2743
|
this.write("[");
|
|
2475
2744
|
this.writeArray(fns, ",");
|
|
@@ -2477,116 +2746,105 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2477
2746
|
this.closeElement();
|
|
2478
2747
|
}
|
|
2479
2748
|
}
|
|
2749
|
+
emitPatchDataIfNeeded() {
|
|
2750
|
+
const patches = [];
|
|
2751
|
+
for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
|
|
2752
|
+
for (const backpatchEntry of backpatchEntries) {
|
|
2753
|
+
patches.push(
|
|
2754
|
+
elementIndex,
|
|
2755
|
+
backpatchEntry.attrName,
|
|
2756
|
+
isSignal(backpatchEntry.value) ? backpatchEntry.value.untrackedValue : backpatchEntry.value
|
|
2757
|
+
);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
this.backpatchMap.clear();
|
|
2761
|
+
if (patches.length > 0) {
|
|
2762
|
+
this.isBackpatchExecutorEmitted = true;
|
|
2763
|
+
const scriptAttrs = ["type", ELEMENT_BACKPATCH_DATA];
|
|
2764
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2765
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2766
|
+
}
|
|
2767
|
+
this.openElement("script", null, scriptAttrs);
|
|
2768
|
+
this.write(JSON.stringify(patches));
|
|
2769
|
+
this.closeElement();
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
emitExecutorIfNeeded() {
|
|
2773
|
+
if (!this.isBackpatchExecutorEmitted) {
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
const scriptAttrs = ["type", "text/javascript"];
|
|
2777
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2778
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2779
|
+
}
|
|
2780
|
+
this.openElement("script", null, scriptAttrs);
|
|
2781
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev6 });
|
|
2782
|
+
this.write(backpatchScript);
|
|
2783
|
+
this.closeElement();
|
|
2784
|
+
}
|
|
2480
2785
|
emitPreloaderPre() {
|
|
2481
2786
|
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2482
2787
|
}
|
|
2483
2788
|
isStatic() {
|
|
2484
2789
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2485
2790
|
}
|
|
2486
|
-
getQwikLoaderIncludeMode() {
|
|
2487
|
-
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2488
|
-
}
|
|
2489
2791
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2792
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2793
|
+
this.qlInclude = 2 /* Done */;
|
|
2794
|
+
const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
|
|
2795
|
+
const linkAttrs = ["rel", "modulepreload", "href", qwikLoaderBundle];
|
|
2796
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2797
|
+
if (nonce) {
|
|
2798
|
+
linkAttrs.push("nonce", nonce);
|
|
2799
|
+
}
|
|
2800
|
+
this.openElement("link", null, linkAttrs);
|
|
2801
|
+
this.closeElement();
|
|
2802
|
+
const scriptAttrs = ["async", true, "type", "module", "src", qwikLoaderBundle];
|
|
2803
|
+
if (nonce) {
|
|
2804
|
+
scriptAttrs.push("nonce", nonce);
|
|
2500
2805
|
}
|
|
2806
|
+
this.openElement("script", null, scriptAttrs);
|
|
2807
|
+
this.closeElement();
|
|
2501
2808
|
}
|
|
2502
2809
|
}
|
|
2810
|
+
emitQwikLoaderInline() {
|
|
2811
|
+
this.qlInclude = 2 /* Done */;
|
|
2812
|
+
const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
|
|
2813
|
+
const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
|
|
2814
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2815
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2816
|
+
}
|
|
2817
|
+
this.openElement("script", null, scriptAttrs);
|
|
2818
|
+
this.write(qwikLoaderScript);
|
|
2819
|
+
this.closeElement();
|
|
2820
|
+
}
|
|
2503
2821
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2508
|
-
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2509
|
-
if (includeLoader) {
|
|
2510
|
-
const qwikLoaderScript = getQwikLoaderScript({
|
|
2511
|
-
debug: this.renderOptions.debug
|
|
2512
|
-
});
|
|
2513
|
-
const scriptAttrs = ["id", "qwikloader", "async", true];
|
|
2514
|
-
const nonce = this.renderOptions.serverData?.nonce;
|
|
2515
|
-
if (nonce) {
|
|
2516
|
-
scriptAttrs.push("nonce", nonce);
|
|
2517
|
-
}
|
|
2518
|
-
this.openElement("script", scriptAttrs);
|
|
2519
|
-
this.write(qwikLoaderScript);
|
|
2520
|
-
this.closeElement();
|
|
2822
|
+
if (!this.isStatic()) {
|
|
2823
|
+
if (this.qlInclude !== 2 /* Done */) {
|
|
2824
|
+
this.emitQwikLoaderInline();
|
|
2521
2825
|
}
|
|
2826
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2522
2827
|
}
|
|
2523
|
-
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2524
2828
|
}
|
|
2525
2829
|
emitQwikEvents(eventNames) {
|
|
2526
2830
|
if (eventNames.length > 0) {
|
|
2527
|
-
const scriptAttrs =
|
|
2528
|
-
this.
|
|
2529
|
-
|
|
2831
|
+
const scriptAttrs = [];
|
|
2832
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2833
|
+
if (nonce) {
|
|
2834
|
+
scriptAttrs.push("nonce", nonce);
|
|
2835
|
+
}
|
|
2836
|
+
this.openElement("script", null, scriptAttrs);
|
|
2837
|
+
this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
|
|
2530
2838
|
this.writeArray(eventNames, ", ");
|
|
2531
2839
|
this.write(")");
|
|
2532
2840
|
this.closeElement();
|
|
2533
2841
|
}
|
|
2534
2842
|
}
|
|
2535
|
-
|
|
2536
|
-
const unclaimedProjections = this.unclaimedProjections;
|
|
2537
|
-
if (unclaimedProjections.length) {
|
|
2538
|
-
const previousCurrentComponentNode = this.currentComponentNode;
|
|
2539
|
-
try {
|
|
2540
|
-
this.openElement(QTemplate, ["style", "display:none"], null);
|
|
2541
|
-
let idx = 0;
|
|
2542
|
-
let ssrComponentNode = null;
|
|
2543
|
-
let ssrComponentFrame = null;
|
|
2544
|
-
let scopedStyleId = null;
|
|
2545
|
-
for (let i = 0; i < unclaimedProjections.length; i += 4) {
|
|
2546
|
-
this.unclaimedProjectionComponentFrameQueue.push(
|
|
2547
|
-
unclaimedProjections[i]
|
|
2548
|
-
);
|
|
2549
|
-
}
|
|
2550
|
-
while (idx < unclaimedProjections.length) {
|
|
2551
|
-
const value = unclaimedProjections[idx++];
|
|
2552
|
-
if (value instanceof SsrComponentFrame) {
|
|
2553
|
-
ssrComponentNode = this.currentComponentNode = value.componentNode;
|
|
2554
|
-
ssrComponentFrame = value;
|
|
2555
|
-
scopedStyleId = unclaimedProjections[idx++];
|
|
2556
|
-
} else if (typeof value === "string") {
|
|
2557
|
-
const children = unclaimedProjections[idx++];
|
|
2558
|
-
if (!ssrComponentFrame?.hasSlot(value)) {
|
|
2559
|
-
ssrComponentFrame && ssrComponentFrame.componentNode.removeProp(value);
|
|
2560
|
-
continue;
|
|
2561
|
-
}
|
|
2562
|
-
this.unclaimedProjectionComponentFrameQueue.shift();
|
|
2563
|
-
this.openFragment(
|
|
2564
|
-
isDev4 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
|
|
2565
|
-
);
|
|
2566
|
-
const lastNode = this.getOrCreateLastNode();
|
|
2567
|
-
if (lastNode.vnodeData) {
|
|
2568
|
-
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2569
|
-
}
|
|
2570
|
-
ssrComponentNode?.setProp(value, lastNode.id);
|
|
2571
|
-
await _walkJSX(this, children, {
|
|
2572
|
-
currentStyleScoped: scopedStyleId,
|
|
2573
|
-
parentComponentFrame: null
|
|
2574
|
-
});
|
|
2575
|
-
this.closeFragment();
|
|
2576
|
-
} else {
|
|
2577
|
-
throw Error();
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
this.closeElement();
|
|
2581
|
-
} finally {
|
|
2582
|
-
this.currentComponentNode = previousCurrentComponentNode;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2843
|
+
// Keep in sync with process-vnode-data.unit.ts
|
|
2586
2844
|
emitVNodeSeparators(lastSerializedIdx, elementIdx) {
|
|
2587
2845
|
let skipCount = elementIdx - lastSerializedIdx;
|
|
2588
2846
|
while (skipCount != 0) {
|
|
2589
|
-
if (skipCount
|
|
2847
|
+
if (skipCount >= 8192) {
|
|
2590
2848
|
this.write(VNodeDataSeparator.ADVANCE_8192_CH);
|
|
2591
2849
|
skipCount -= 8192;
|
|
2592
2850
|
} else {
|
|
@@ -2610,7 +2868,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2610
2868
|
}
|
|
2611
2869
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
2612
2870
|
let tagNesting = 10 /* ANYTHING */;
|
|
2613
|
-
if (
|
|
2871
|
+
if (isDev6) {
|
|
2614
2872
|
if (!this.currentElementFrame) {
|
|
2615
2873
|
tagNesting = initialTag(elementName);
|
|
2616
2874
|
} else {
|
|
@@ -2655,7 +2913,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2655
2913
|
parent: this.currentElementFrame,
|
|
2656
2914
|
elementName,
|
|
2657
2915
|
depthFirstElementIdx,
|
|
2658
|
-
vNodeData: [0 /* NONE */]
|
|
2916
|
+
vNodeData: [0 /* NONE */],
|
|
2917
|
+
currentFile: isDev6 ? currentFile || null : null
|
|
2659
2918
|
};
|
|
2660
2919
|
this.currentElementFrame = frame;
|
|
2661
2920
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -2667,6 +2926,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2667
2926
|
}
|
|
2668
2927
|
////////////////////////////////////
|
|
2669
2928
|
write(text) {
|
|
2929
|
+
this.size += text.length;
|
|
2670
2930
|
this.writer.write(text);
|
|
2671
2931
|
}
|
|
2672
2932
|
writeArray(array, separator) {
|
|
@@ -2686,12 +2946,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2686
2946
|
let value = attrs[i];
|
|
2687
2947
|
let styleScopedId = null;
|
|
2688
2948
|
if (isSSRUnsafeAttr(key)) {
|
|
2689
|
-
if (
|
|
2690
|
-
throw qError(32 /* unsafeAttr
|
|
2949
|
+
if (isDev6) {
|
|
2950
|
+
throw qError(32 /* unsafeAttr */, [key]);
|
|
2691
2951
|
}
|
|
2692
2952
|
continue;
|
|
2693
2953
|
}
|
|
2694
|
-
if (
|
|
2954
|
+
if (key === "class" && Array.isArray(value)) {
|
|
2695
2955
|
const [signalValue, styleId] = value;
|
|
2696
2956
|
value = signalValue;
|
|
2697
2957
|
styleScopedId = styleId;
|
|
@@ -2716,19 +2976,32 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2716
2976
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2717
2977
|
$isConst$: isConst
|
|
2718
2978
|
});
|
|
2719
|
-
|
|
2979
|
+
const signal = value;
|
|
2980
|
+
value = retryOnPromise(
|
|
2981
|
+
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
2982
|
+
);
|
|
2983
|
+
}
|
|
2984
|
+
if (isPromise(value)) {
|
|
2985
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2986
|
+
this.addPromiseAttribute(value);
|
|
2987
|
+
value.then((resolvedValue) => {
|
|
2988
|
+
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
2989
|
+
});
|
|
2990
|
+
continue;
|
|
2720
2991
|
}
|
|
2721
2992
|
if (key === dangerouslySetInnerHTML) {
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2993
|
+
if (value) {
|
|
2994
|
+
innerHTML = String(value);
|
|
2995
|
+
key = QContainerAttr;
|
|
2996
|
+
value = "html" /* HTML */;
|
|
2997
|
+
}
|
|
2725
2998
|
if (tag === "style") {
|
|
2726
2999
|
continue;
|
|
2727
3000
|
}
|
|
2728
3001
|
}
|
|
2729
3002
|
if (tag === "textarea" && key === "value") {
|
|
2730
3003
|
if (value && typeof value !== "string") {
|
|
2731
|
-
if (
|
|
3004
|
+
if (isDev6) {
|
|
2732
3005
|
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2733
3006
|
}
|
|
2734
3007
|
continue;
|
|
@@ -2752,6 +3025,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2752
3025
|
}
|
|
2753
3026
|
return innerHTML;
|
|
2754
3027
|
}
|
|
3028
|
+
addPromiseAttribute(promise) {
|
|
3029
|
+
this.promiseAttributes || (this.promiseAttributes = []);
|
|
3030
|
+
this.promiseAttributes.push(promise);
|
|
3031
|
+
}
|
|
3032
|
+
async resolvePromiseAttributes() {
|
|
3033
|
+
if (this.promiseAttributes) {
|
|
3034
|
+
await Promise.all(this.promiseAttributes);
|
|
3035
|
+
this.promiseAttributes = null;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
2755
3038
|
};
|
|
2756
3039
|
var isQwikStyleElement = (tag, attrs) => {
|
|
2757
3040
|
if (tag === "style" && attrs != null) {
|
|
@@ -2811,7 +3094,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2811
3094
|
const buildBase = getBuildBase(opts);
|
|
2812
3095
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
2813
3096
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
2814
|
-
const { stream, flush, networkFlushes
|
|
3097
|
+
const { stream, flush, networkFlushes } = handleStreaming(opts, timing);
|
|
2815
3098
|
const ssrContainer = ssrCreateContainer({
|
|
2816
3099
|
tagName: containerTagName,
|
|
2817
3100
|
locale,
|
|
@@ -2823,6 +3106,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2823
3106
|
});
|
|
2824
3107
|
await setServerPlatform(opts, resolvedManifest);
|
|
2825
3108
|
await ssrContainer.render(jsx);
|
|
3109
|
+
await ssrContainer.$renderPromise$;
|
|
2826
3110
|
flush();
|
|
2827
3111
|
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
2828
3112
|
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
@@ -2830,7 +3114,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2830
3114
|
snapshotResult,
|
|
2831
3115
|
flushes: networkFlushes,
|
|
2832
3116
|
manifest: resolvedManifest?.manifest,
|
|
2833
|
-
size:
|
|
3117
|
+
size: ssrContainer.size,
|
|
2834
3118
|
isStatic: !isDynamic,
|
|
2835
3119
|
timing
|
|
2836
3120
|
};
|
|
@@ -2856,7 +3140,6 @@ function handleStreaming(opts, timing) {
|
|
|
2856
3140
|
let stream = opts.stream;
|
|
2857
3141
|
let bufferSize = 0;
|
|
2858
3142
|
let buffer = "";
|
|
2859
|
-
let totalSize = 0;
|
|
2860
3143
|
let networkFlushes = 0;
|
|
2861
3144
|
const inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
2862
3145
|
strategy: "auto",
|
|
@@ -2878,7 +3161,6 @@ function handleStreaming(opts, timing) {
|
|
|
2878
3161
|
function enqueue(chunk) {
|
|
2879
3162
|
const len = chunk.length;
|
|
2880
3163
|
bufferSize += len;
|
|
2881
|
-
totalSize += len;
|
|
2882
3164
|
buffer += chunk;
|
|
2883
3165
|
}
|
|
2884
3166
|
switch (inOrderStreaming.strategy) {
|
|
@@ -2936,8 +3218,7 @@ function handleStreaming(opts, timing) {
|
|
|
2936
3218
|
return {
|
|
2937
3219
|
stream,
|
|
2938
3220
|
flush,
|
|
2939
|
-
networkFlushes
|
|
2940
|
-
totalSize
|
|
3221
|
+
networkFlushes
|
|
2941
3222
|
};
|
|
2942
3223
|
}
|
|
2943
3224
|
function shouldSkipChunk(chunk) {
|
|
@@ -2969,6 +3250,7 @@ async function setServerPlatform2(manifest) {
|
|
|
2969
3250
|
setPlatform2(platform);
|
|
2970
3251
|
}
|
|
2971
3252
|
export {
|
|
3253
|
+
getQwikBackpatchExecutorScript,
|
|
2972
3254
|
getQwikLoaderScript,
|
|
2973
3255
|
getQwikPrefetchWorkerScript,
|
|
2974
3256
|
renderToStream,
|