@qwik.dev/core 2.0.0-beta.23 → 2.0.0-beta.25
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/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +142 -179
- package/dist/core-internal.d.ts +81 -38
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +1484 -1195
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +4466 -3264
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +1076 -1077
- package/dist/qwikloader.debug.js +0 -2
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +11 -7
- package/dist/server.mjs +442 -395
- package/dist/testing/index.d.ts +149 -79
- package/dist/testing/index.mjs +1289 -1139
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
package/dist/server.mjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.25-dev+2677279
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
7
7
|
*/
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
8
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
9
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
10
|
}) : x)(function(x) {
|
|
13
11
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
13
|
});
|
|
16
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
17
14
|
|
|
18
15
|
// packages/qwik/src/server/index.ts
|
|
19
16
|
import { setPlatform as setPlatform2 } from "@qwik.dev/core";
|
|
20
17
|
|
|
21
18
|
// packages/qwik/src/server/platform.ts
|
|
22
19
|
import { setPlatform } from "@qwik.dev/core";
|
|
23
|
-
import { isDev as
|
|
20
|
+
import { isDev as isDev5 } from "@qwik.dev/core/build";
|
|
24
21
|
|
|
25
22
|
// packages/qwik/src/core/client/util-mapArray.ts
|
|
23
|
+
import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
24
|
+
|
|
25
|
+
// packages/qwik/src/core/shared/error/assert.ts
|
|
26
26
|
import { isDev } from "@qwik.dev/core/build";
|
|
27
27
|
|
|
28
28
|
// packages/qwik/src/core/shared/utils/qdev.ts
|
|
@@ -57,7 +57,7 @@ var createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
|
57
57
|
// packages/qwik/src/core/shared/error/assert.ts
|
|
58
58
|
var ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
|
|
59
59
|
function assertTrue(value1, text, ...parts) {
|
|
60
|
-
if (
|
|
60
|
+
if (isDev) {
|
|
61
61
|
if (value1 === true) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
@@ -67,7 +67,7 @@ function assertTrue(value1, text, ...parts) {
|
|
|
67
67
|
|
|
68
68
|
// packages/qwik/src/core/client/util-mapArray.ts
|
|
69
69
|
var mapApp_findIndx = (array, key, start) => {
|
|
70
|
-
|
|
70
|
+
isDev2 && assertTrue(start % 2 === 0, "Expecting even number.");
|
|
71
71
|
let bottom = start >> 1;
|
|
72
72
|
let top = array.length - 2 >> 1;
|
|
73
73
|
while (bottom <= top) {
|
|
@@ -194,7 +194,12 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
|
|
|
194
194
|
// 28
|
|
195
195
|
"useComputed$ QRL {{0}} {{1}} cannot return a Promise",
|
|
196
196
|
// 29
|
|
197
|
-
|
|
197
|
+
`===
|
|
198
|
+
Qwik version {{0}} already imported while importing {{1}}.
|
|
199
|
+
This can lead to issues due to duplicated shared structures.
|
|
200
|
+
Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude".
|
|
201
|
+
===
|
|
202
|
+
`,
|
|
198
203
|
// 30
|
|
199
204
|
"WrappedSignal is read-only",
|
|
200
205
|
// 31
|
|
@@ -217,7 +222,7 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
|
|
|
217
222
|
}
|
|
218
223
|
return `Code(Q${code}): ${text}`;
|
|
219
224
|
} else {
|
|
220
|
-
return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/
|
|
225
|
+
return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/build/v2/packages/qwik/src/core/shared/error/error.ts#${parts.join()}L${9 + code}`;
|
|
221
226
|
}
|
|
222
227
|
};
|
|
223
228
|
var qError = (code, errorMessageArgs = []) => {
|
|
@@ -226,7 +231,7 @@ var qError = (code, errorMessageArgs = []) => {
|
|
|
226
231
|
};
|
|
227
232
|
|
|
228
233
|
// packages/qwik/src/core/shared/qrl/qrl-utils.ts
|
|
229
|
-
import { isDev as
|
|
234
|
+
import { isDev as isDev3 } from "@qwik.dev/core/build";
|
|
230
235
|
var SYNC_QRL = "<sync>";
|
|
231
236
|
|
|
232
237
|
// packages/qwik/src/core/shared/types.ts
|
|
@@ -603,18 +608,17 @@ var ELEMENT_PROPS = "q:props";
|
|
|
603
608
|
var ELEMENT_SEQ = "q:seq";
|
|
604
609
|
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
605
610
|
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
611
|
+
var ITERATION_ITEM_SINGLE = "q:p";
|
|
612
|
+
var ITERATION_ITEM_MULTI = "q:ps";
|
|
606
613
|
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
607
614
|
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
608
615
|
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
609
616
|
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
617
|
var Q_PROPS_SEPARATOR = ":";
|
|
614
618
|
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
615
619
|
|
|
616
620
|
// packages/qwik/src/core/shared/utils/promises.ts
|
|
617
|
-
import { isDev as
|
|
621
|
+
import { isDev as isDev4, isServer } from "@qwik.dev/core/build";
|
|
618
622
|
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
619
623
|
var isPromise = (value) => {
|
|
620
624
|
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
@@ -643,7 +647,7 @@ function retryOnPromise(fn, onError = justThrow) {
|
|
|
643
647
|
if (ok) {
|
|
644
648
|
return result;
|
|
645
649
|
}
|
|
646
|
-
|
|
650
|
+
isDev4 && checkError(result);
|
|
647
651
|
return onError(result);
|
|
648
652
|
}
|
|
649
653
|
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
@@ -666,7 +670,7 @@ function retryOnPromise(fn, onError = justThrow) {
|
|
|
666
670
|
}
|
|
667
671
|
}
|
|
668
672
|
}
|
|
669
|
-
|
|
673
|
+
isDev4 && checkError(p);
|
|
670
674
|
return onError(p);
|
|
671
675
|
};
|
|
672
676
|
return ok ? result.catch(retry) : retry(result);
|
|
@@ -681,6 +685,9 @@ function convertStyleIdsToString(scopedStyleIds) {
|
|
|
681
685
|
}
|
|
682
686
|
|
|
683
687
|
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
688
|
+
var isHtmlAttributeAnEventName = (name) => {
|
|
689
|
+
return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && name.charCodeAt(3) === 58;
|
|
690
|
+
};
|
|
684
691
|
function isPreventDefault(key) {
|
|
685
692
|
return key.startsWith("preventdefault:");
|
|
686
693
|
}
|
|
@@ -1036,7 +1043,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
1036
1043
|
queueDirty = true;
|
|
1037
1044
|
}
|
|
1038
1045
|
if (bundle.$deps$) {
|
|
1039
|
-
seen
|
|
1046
|
+
seen ||= /* @__PURE__ */ new Set();
|
|
1040
1047
|
seen.add(bundle);
|
|
1041
1048
|
const probability = 1 - bundle.$inverseProbability$;
|
|
1042
1049
|
for (const dep of bundle.$deps$) {
|
|
@@ -1098,6 +1105,29 @@ if (isBrowser3) {
|
|
|
1098
1105
|
});
|
|
1099
1106
|
}
|
|
1100
1107
|
|
|
1108
|
+
// packages/qwik/src/core/shared/utils/objects.ts
|
|
1109
|
+
var isObjectEmpty = (obj) => {
|
|
1110
|
+
for (const key in obj) {
|
|
1111
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return true;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
// packages/qwik/src/core/shared/ssr-const.ts
|
|
1119
|
+
var LT = "<";
|
|
1120
|
+
var GT = ">";
|
|
1121
|
+
var CLOSE_TAG = "</";
|
|
1122
|
+
var SPACE = " ";
|
|
1123
|
+
var ATTR_EQUALS_QUOTE = '="';
|
|
1124
|
+
var QUOTE = '"';
|
|
1125
|
+
var EMPTY_ATTR = '=""';
|
|
1126
|
+
var BRACKET_OPEN = "[";
|
|
1127
|
+
var BRACKET_CLOSE = "]";
|
|
1128
|
+
var PAREN_CLOSE = ")";
|
|
1129
|
+
var COMMA = ",";
|
|
1130
|
+
|
|
1101
1131
|
// packages/qwik/src/server/platform.ts
|
|
1102
1132
|
var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
|
|
1103
1133
|
const existing = mapper?.[hash2];
|
|
@@ -1120,9 +1150,9 @@ var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
|
|
|
1120
1150
|
function createPlatform(opts, resolvedManifest) {
|
|
1121
1151
|
const mapper = resolvedManifest?.mapper;
|
|
1122
1152
|
const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
|
|
1123
|
-
if (mapper ||
|
|
1153
|
+
if (mapper || isDev5 && import.meta.env.MODE !== "test") {
|
|
1124
1154
|
const hash2 = getSymbolHash(symbolName);
|
|
1125
|
-
const result = !
|
|
1155
|
+
const result = !isDev5 ? mapper[hash2] : getDevSegmentPath(mapper, hash2, symbolName, parent);
|
|
1126
1156
|
if (!result) {
|
|
1127
1157
|
if (hash2 === SYNC_QRL) {
|
|
1128
1158
|
return [hash2, ""];
|
|
@@ -1202,21 +1232,21 @@ function getBuildBase(opts) {
|
|
|
1202
1232
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1203
1233
|
}
|
|
1204
1234
|
var versions = {
|
|
1205
|
-
qwik: "2.0.0-beta.
|
|
1235
|
+
qwik: "2.0.0-beta.25-dev+2677279",
|
|
1206
1236
|
qwikDom: "2.1.19"
|
|
1207
1237
|
};
|
|
1208
1238
|
|
|
1209
1239
|
// packages/qwik/src/server/ssr-container.ts
|
|
1210
|
-
import { isDev as
|
|
1240
|
+
import { isDev as isDev7 } from "@qwik.dev/core/build";
|
|
1211
1241
|
import {
|
|
1212
|
-
_createQRL as createQRL,
|
|
1213
|
-
_qrlToString as qrlToString,
|
|
1214
|
-
_res,
|
|
1215
1242
|
_SubscriptionData as SubscriptionData,
|
|
1216
1243
|
_SharedContainer,
|
|
1217
1244
|
_jsxSorted,
|
|
1218
1245
|
_jsxSplit,
|
|
1246
|
+
_res,
|
|
1247
|
+
_setEvent,
|
|
1219
1248
|
_walkJSX,
|
|
1249
|
+
_createQRL as createQRL,
|
|
1220
1250
|
isSignal
|
|
1221
1251
|
} from "@qwik.dev/core/internal";
|
|
1222
1252
|
|
|
@@ -1347,39 +1377,44 @@ var preloaderPre = (container, options, nonce) => {
|
|
|
1347
1377
|
}
|
|
1348
1378
|
}
|
|
1349
1379
|
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1350
|
-
const preloaderLinkAttrs =
|
|
1380
|
+
const preloaderLinkAttrs = {
|
|
1381
|
+
rel: "modulepreload",
|
|
1382
|
+
href: preloaderBundle
|
|
1383
|
+
};
|
|
1351
1384
|
if (nonce) {
|
|
1352
|
-
preloaderLinkAttrs
|
|
1385
|
+
preloaderLinkAttrs["nonce"] = nonce;
|
|
1353
1386
|
}
|
|
1354
|
-
container.openElement("link", null, preloaderLinkAttrs);
|
|
1387
|
+
container.openElement("link", null, preloaderLinkAttrs, null, null, null);
|
|
1355
1388
|
container.closeElement();
|
|
1356
|
-
container.openElement(
|
|
1357
|
-
"
|
|
1358
|
-
|
|
1359
|
-
"href",
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
"anonymous"
|
|
1365
|
-
]);
|
|
1389
|
+
container.openElement(
|
|
1390
|
+
"link",
|
|
1391
|
+
null,
|
|
1392
|
+
{ rel: "preload", href: bundleGraphPath, as: "fetch", crossorigin: "anonymous" },
|
|
1393
|
+
null,
|
|
1394
|
+
null,
|
|
1395
|
+
null
|
|
1396
|
+
);
|
|
1366
1397
|
container.closeElement();
|
|
1367
1398
|
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1368
|
-
const scriptAttrs =
|
|
1399
|
+
const scriptAttrs = {
|
|
1400
|
+
type: "module",
|
|
1401
|
+
async: true,
|
|
1402
|
+
crossorigin: "anonymous"
|
|
1403
|
+
};
|
|
1369
1404
|
if (nonce) {
|
|
1370
|
-
scriptAttrs
|
|
1405
|
+
scriptAttrs["nonce"] = nonce;
|
|
1371
1406
|
}
|
|
1372
|
-
container.openElement("script", null, scriptAttrs);
|
|
1407
|
+
container.openElement("script", null, scriptAttrs, null, null, null);
|
|
1373
1408
|
container.write(script);
|
|
1374
1409
|
container.closeElement();
|
|
1375
1410
|
}
|
|
1376
1411
|
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1377
1412
|
if (corePath) {
|
|
1378
|
-
const linkAttrs =
|
|
1413
|
+
const linkAttrs = { rel: "modulepreload", href: corePath };
|
|
1379
1414
|
if (nonce) {
|
|
1380
|
-
linkAttrs
|
|
1415
|
+
linkAttrs["nonce"] = nonce;
|
|
1381
1416
|
}
|
|
1382
|
-
container.openElement("link", null, linkAttrs);
|
|
1417
|
+
container.openElement("link", null, linkAttrs, null, null, null);
|
|
1383
1418
|
container.closeElement();
|
|
1384
1419
|
}
|
|
1385
1420
|
};
|
|
@@ -1431,11 +1466,11 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1431
1466
|
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1432
1467
|
}
|
|
1433
1468
|
if (script) {
|
|
1434
|
-
const attrs =
|
|
1469
|
+
const attrs = { type: "module", async: "true", "q:type": "preload" };
|
|
1435
1470
|
if (nonce) {
|
|
1436
|
-
attrs
|
|
1471
|
+
attrs["nonce"] = nonce;
|
|
1437
1472
|
}
|
|
1438
|
-
container.openElement("script", null, attrs);
|
|
1473
|
+
container.openElement("script", null, attrs, null, null, null);
|
|
1439
1474
|
container.write(script);
|
|
1440
1475
|
container.closeElement();
|
|
1441
1476
|
}
|
|
@@ -1463,8 +1498,8 @@ var preLoaderOptionsDefault = {
|
|
|
1463
1498
|
};
|
|
1464
1499
|
|
|
1465
1500
|
// packages/qwik/src/server/scripts.ts
|
|
1466
|
-
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}
|
|
1467
|
-
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 }
|
|
1501
|
+
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}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())';
|
|
1502
|
+
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 }\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}';
|
|
1468
1503
|
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))}}}}`;
|
|
1469
1504
|
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1470
1505
|
const executorScript = document.currentScript;
|
|
@@ -1518,8 +1553,12 @@ function getQwikBackpatchExecutorScript(opts = {}) {
|
|
|
1518
1553
|
}
|
|
1519
1554
|
|
|
1520
1555
|
// packages/qwik/src/server/ssr-node.ts
|
|
1521
|
-
import {
|
|
1522
|
-
|
|
1556
|
+
import {
|
|
1557
|
+
_isJSXNode as isJSXNode,
|
|
1558
|
+
_EMPTY_OBJ,
|
|
1559
|
+
_EFFECT_BACK_REF
|
|
1560
|
+
} from "@qwik.dev/core/internal";
|
|
1561
|
+
import { isDev as isDev6 } from "@qwik.dev/core/build";
|
|
1523
1562
|
var SsrNode = class {
|
|
1524
1563
|
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1525
1564
|
this.parentComponent = parentComponent;
|
|
@@ -1527,38 +1566,38 @@ var SsrNode = class {
|
|
|
1527
1566
|
this.cleanupQueue = cleanupQueue;
|
|
1528
1567
|
this.vnodeData = vnodeData;
|
|
1529
1568
|
this.currentFile = currentFile;
|
|
1530
|
-
__publicField(this, "__brand__", "SsrNode");
|
|
1531
|
-
/**
|
|
1532
|
-
* ID which the deserialize will use to retrieve the node.
|
|
1533
|
-
*
|
|
1534
|
-
* @param id - Unique id for the node.
|
|
1535
|
-
*/
|
|
1536
|
-
__publicField(this, "id");
|
|
1537
|
-
__publicField(this, "flags");
|
|
1538
|
-
__publicField(this, "dirty", 0 /* NONE */);
|
|
1539
|
-
__publicField(this, "children", null);
|
|
1540
|
-
__publicField(this, "attrs");
|
|
1541
|
-
/** Local props which don't serialize; */
|
|
1542
|
-
__publicField(this, "localProps", null);
|
|
1543
1569
|
this.id = id;
|
|
1544
1570
|
this.flags = 1 /* Updatable */;
|
|
1545
|
-
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] :
|
|
1571
|
+
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
|
|
1546
1572
|
this.parentComponent?.addChild(this);
|
|
1547
|
-
if (
|
|
1573
|
+
if (isDev6 && id.indexOf("undefined") != -1) {
|
|
1548
1574
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1549
1575
|
}
|
|
1550
1576
|
}
|
|
1577
|
+
__brand__ = "SsrNode";
|
|
1578
|
+
/**
|
|
1579
|
+
* ID which the deserialize will use to retrieve the node.
|
|
1580
|
+
*
|
|
1581
|
+
* @param id - Unique id for the node.
|
|
1582
|
+
*/
|
|
1583
|
+
id;
|
|
1584
|
+
flags;
|
|
1585
|
+
dirty = 0 /* NONE */;
|
|
1586
|
+
children = null;
|
|
1587
|
+
attrs;
|
|
1588
|
+
/** Local props which don't serialize; */
|
|
1589
|
+
localProps = null;
|
|
1551
1590
|
get [_EFFECT_BACK_REF]() {
|
|
1552
1591
|
return this.getProp(QBackRefs);
|
|
1553
1592
|
}
|
|
1554
1593
|
setProp(name, value) {
|
|
1555
|
-
if (this.attrs ===
|
|
1594
|
+
if (this.attrs === _EMPTY_OBJ) {
|
|
1556
1595
|
this.setEmptyArrayAsVNodeDataAttributes();
|
|
1557
1596
|
}
|
|
1558
1597
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1559
|
-
|
|
1598
|
+
(this.localProps ||= {})[name] = value;
|
|
1560
1599
|
} else {
|
|
1561
|
-
|
|
1600
|
+
this.attrs[name] = value;
|
|
1562
1601
|
}
|
|
1563
1602
|
if (name == ELEMENT_SEQ && value) {
|
|
1564
1603
|
this.cleanupQueue.push(value);
|
|
@@ -1566,29 +1605,29 @@ var SsrNode = class {
|
|
|
1566
1605
|
}
|
|
1567
1606
|
setEmptyArrayAsVNodeDataAttributes() {
|
|
1568
1607
|
if (this.attributesIndex >= 0) {
|
|
1569
|
-
this.vnodeData[this.attributesIndex] =
|
|
1608
|
+
this.vnodeData[this.attributesIndex] = {};
|
|
1570
1609
|
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1571
1610
|
} else {
|
|
1572
1611
|
const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
|
|
1573
|
-
this.vnodeData.splice(newAttributesIndex, 0,
|
|
1612
|
+
this.vnodeData.splice(newAttributesIndex, 0, {});
|
|
1574
1613
|
this.attributesIndex = newAttributesIndex;
|
|
1575
1614
|
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1576
1615
|
}
|
|
1577
1616
|
}
|
|
1578
1617
|
getProp(name) {
|
|
1579
1618
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1580
|
-
return this.localProps ?
|
|
1619
|
+
return this.localProps ? this.localProps[name] ?? null : null;
|
|
1581
1620
|
} else {
|
|
1582
|
-
return
|
|
1621
|
+
return this.attrs[name] ?? null;
|
|
1583
1622
|
}
|
|
1584
1623
|
}
|
|
1585
1624
|
removeProp(name) {
|
|
1586
1625
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1587
1626
|
if (this.localProps) {
|
|
1588
|
-
|
|
1627
|
+
delete this.localProps[name];
|
|
1589
1628
|
}
|
|
1590
1629
|
} else {
|
|
1591
|
-
|
|
1630
|
+
delete this.attrs[name];
|
|
1592
1631
|
}
|
|
1593
1632
|
}
|
|
1594
1633
|
addChild(child) {
|
|
@@ -1608,16 +1647,13 @@ var SsrNode = class {
|
|
|
1608
1647
|
}
|
|
1609
1648
|
}
|
|
1610
1649
|
toString() {
|
|
1611
|
-
if (
|
|
1650
|
+
if (isDev6) {
|
|
1612
1651
|
let stringifiedAttrs = "";
|
|
1613
|
-
for (
|
|
1614
|
-
const
|
|
1615
|
-
const value = this.attrs[i + 1];
|
|
1652
|
+
for (const key in this.attrs) {
|
|
1653
|
+
const value = this.attrs[key];
|
|
1616
1654
|
stringifiedAttrs += `${key}=`;
|
|
1617
1655
|
stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
|
|
1618
|
-
|
|
1619
|
-
stringifiedAttrs += ", ";
|
|
1620
|
-
}
|
|
1656
|
+
stringifiedAttrs += ", ";
|
|
1621
1657
|
}
|
|
1622
1658
|
return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
|
|
1623
1659
|
} else {
|
|
@@ -1628,18 +1664,18 @@ var SsrNode = class {
|
|
|
1628
1664
|
var DomRef = class {
|
|
1629
1665
|
constructor($ssrNode$) {
|
|
1630
1666
|
this.$ssrNode$ = $ssrNode$;
|
|
1631
|
-
__publicField(this, "__brand__", "DomRef");
|
|
1632
1667
|
}
|
|
1668
|
+
__brand__ = "DomRef";
|
|
1633
1669
|
};
|
|
1634
1670
|
var SsrComponentFrame = class {
|
|
1635
1671
|
constructor(componentNode) {
|
|
1636
1672
|
this.componentNode = componentNode;
|
|
1637
|
-
__publicField(this, "slots", []);
|
|
1638
|
-
__publicField(this, "projectionDepth", 0);
|
|
1639
|
-
__publicField(this, "scopedStyleIds", /* @__PURE__ */ new Set());
|
|
1640
|
-
__publicField(this, "projectionScopedStyle", null);
|
|
1641
|
-
__publicField(this, "projectionComponentFrame", null);
|
|
1642
1673
|
}
|
|
1674
|
+
slots = [];
|
|
1675
|
+
projectionDepth = 0;
|
|
1676
|
+
scopedStyleIds = /* @__PURE__ */ new Set();
|
|
1677
|
+
projectionScopedStyle = null;
|
|
1678
|
+
projectionComponentFrame = null;
|
|
1643
1679
|
distributeChildrenIntoSlots(children, projectionScopedStyle, projectionComponentFrame) {
|
|
1644
1680
|
this.projectionScopedStyle = projectionScopedStyle;
|
|
1645
1681
|
this.projectionComponentFrame = projectionComponentFrame;
|
|
@@ -2042,7 +2078,7 @@ function vNodeData_closeFragment(vNodeData) {
|
|
|
2042
2078
|
vNodeData.push(CLOSE_FRAGMENT);
|
|
2043
2079
|
}
|
|
2044
2080
|
function vNodeData_openElement(vNodeData) {
|
|
2045
|
-
vNodeData.push(
|
|
2081
|
+
vNodeData.push({}, WRITE_ELEMENT_ATTRS);
|
|
2046
2082
|
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
2047
2083
|
}
|
|
2048
2084
|
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
|
|
@@ -2051,7 +2087,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
2051
2087
|
let attributesIndex = -1;
|
|
2052
2088
|
for (let i = 1; i < vNodeData.length; i++) {
|
|
2053
2089
|
const value = vNodeData[i];
|
|
2054
|
-
if (
|
|
2090
|
+
if (typeof value === "object" && value !== null) {
|
|
2055
2091
|
attributesIndex = i;
|
|
2056
2092
|
i++;
|
|
2057
2093
|
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
@@ -2067,7 +2103,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
2067
2103
|
stack[stack.length - 1]++;
|
|
2068
2104
|
}
|
|
2069
2105
|
}
|
|
2070
|
-
let refId =
|
|
2106
|
+
let refId = depthFirstElementIdx + "";
|
|
2071
2107
|
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
2072
2108
|
for (let i = 0; i < stack.length; i++) {
|
|
2073
2109
|
const childCount = stack[i];
|
|
@@ -2107,10 +2143,11 @@ function encodeAsAlphanumeric(value) {
|
|
|
2107
2143
|
|
|
2108
2144
|
// packages/qwik/src/server/ssr-container.ts
|
|
2109
2145
|
function ssrCreateContainer(opts) {
|
|
2110
|
-
opts.renderOptions
|
|
2146
|
+
opts.renderOptions ||= {};
|
|
2111
2147
|
return new SSRContainer({
|
|
2112
2148
|
tagName: opts.tagName || "div",
|
|
2113
2149
|
writer: opts.writer || new StringBufferWriter(),
|
|
2150
|
+
streamHandler: opts.streamHandler,
|
|
2114
2151
|
locale: opts.locale || "",
|
|
2115
2152
|
timing: opts.timing || {
|
|
2116
2153
|
firstFlush: 0,
|
|
@@ -2129,9 +2166,7 @@ function ssrCreateContainer(opts) {
|
|
|
2129
2166
|
});
|
|
2130
2167
|
}
|
|
2131
2168
|
var StringBufferWriter = class {
|
|
2132
|
-
|
|
2133
|
-
__publicField(this, "buffer", []);
|
|
2134
|
-
}
|
|
2169
|
+
buffer = [];
|
|
2135
2170
|
write(text) {
|
|
2136
2171
|
this.buffer.push(text);
|
|
2137
2172
|
}
|
|
@@ -2140,54 +2175,59 @@ var StringBufferWriter = class {
|
|
|
2140
2175
|
}
|
|
2141
2176
|
};
|
|
2142
2177
|
var EMPTY_OBJ = {};
|
|
2178
|
+
var QTemplateProps = {
|
|
2179
|
+
hidden: true,
|
|
2180
|
+
"aria-hidden": true
|
|
2181
|
+
};
|
|
2143
2182
|
var SSRContainer = class extends _SharedContainer {
|
|
2183
|
+
tag;
|
|
2184
|
+
isHtml;
|
|
2185
|
+
writer;
|
|
2186
|
+
streamHandler;
|
|
2187
|
+
timing;
|
|
2188
|
+
size = 0;
|
|
2189
|
+
resolvedManifest;
|
|
2190
|
+
symbolToChunkResolver;
|
|
2191
|
+
renderOptions;
|
|
2192
|
+
serializationCtx;
|
|
2193
|
+
/**
|
|
2194
|
+
* We use this to append additional nodes in the head node
|
|
2195
|
+
*
|
|
2196
|
+
* - From manifest injections
|
|
2197
|
+
* - From useStyles and useScopedStyles hooks
|
|
2198
|
+
*/
|
|
2199
|
+
additionalHeadNodes = new Array();
|
|
2200
|
+
/**
|
|
2201
|
+
* We use this to append additional nodes in the body node
|
|
2202
|
+
*
|
|
2203
|
+
* - From manifest injections
|
|
2204
|
+
*/
|
|
2205
|
+
additionalBodyNodes = new Array();
|
|
2206
|
+
lastNode = null;
|
|
2207
|
+
currentComponentNode = null;
|
|
2208
|
+
styleIds = /* @__PURE__ */ new Set();
|
|
2209
|
+
isBackpatchExecutorEmitted = false;
|
|
2210
|
+
backpatchMap = /* @__PURE__ */ new Map();
|
|
2211
|
+
currentElementFrame = null;
|
|
2212
|
+
renderTimer;
|
|
2213
|
+
/**
|
|
2214
|
+
* Current element index.
|
|
2215
|
+
*
|
|
2216
|
+
* This number must match the depth-first traversal of the DOM elements as returned by the
|
|
2217
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
2218
|
+
*/
|
|
2219
|
+
depthFirstElementCount = -1;
|
|
2220
|
+
vNodeDatas = [];
|
|
2221
|
+
componentStack = [];
|
|
2222
|
+
cleanupQueue = [];
|
|
2223
|
+
emitContainerDataFrame = null;
|
|
2224
|
+
$instanceHash$ = hash();
|
|
2225
|
+
// Temporary flag to find missing roots after the state was serialized
|
|
2226
|
+
$noMoreRoots$ = false;
|
|
2227
|
+
qlInclude;
|
|
2228
|
+
promiseAttributes = null;
|
|
2144
2229
|
constructor(opts) {
|
|
2145
2230
|
super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
|
|
2146
|
-
__publicField(this, "tag");
|
|
2147
|
-
__publicField(this, "isHtml");
|
|
2148
|
-
__publicField(this, "writer");
|
|
2149
|
-
__publicField(this, "timing");
|
|
2150
|
-
__publicField(this, "size", 0);
|
|
2151
|
-
__publicField(this, "resolvedManifest");
|
|
2152
|
-
__publicField(this, "symbolToChunkResolver");
|
|
2153
|
-
__publicField(this, "renderOptions");
|
|
2154
|
-
__publicField(this, "serializationCtx");
|
|
2155
|
-
/**
|
|
2156
|
-
* We use this to append additional nodes in the head node
|
|
2157
|
-
*
|
|
2158
|
-
* - From manifest injections
|
|
2159
|
-
* - From useStyles and useScopedStyles hooks
|
|
2160
|
-
*/
|
|
2161
|
-
__publicField(this, "additionalHeadNodes", new Array());
|
|
2162
|
-
/**
|
|
2163
|
-
* We use this to append additional nodes in the body node
|
|
2164
|
-
*
|
|
2165
|
-
* - From manifest injections
|
|
2166
|
-
*/
|
|
2167
|
-
__publicField(this, "additionalBodyNodes", new Array());
|
|
2168
|
-
__publicField(this, "lastNode", null);
|
|
2169
|
-
__publicField(this, "currentComponentNode", null);
|
|
2170
|
-
__publicField(this, "styleIds", /* @__PURE__ */ new Set());
|
|
2171
|
-
__publicField(this, "isBackpatchExecutorEmitted", false);
|
|
2172
|
-
__publicField(this, "backpatchMap", /* @__PURE__ */ new Map());
|
|
2173
|
-
__publicField(this, "currentElementFrame", null);
|
|
2174
|
-
__publicField(this, "renderTimer");
|
|
2175
|
-
/**
|
|
2176
|
-
* Current element index.
|
|
2177
|
-
*
|
|
2178
|
-
* This number must match the depth-first traversal of the DOM elements as returned by the
|
|
2179
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
2180
|
-
*/
|
|
2181
|
-
__publicField(this, "depthFirstElementCount", -1);
|
|
2182
|
-
__publicField(this, "vNodeDatas", []);
|
|
2183
|
-
__publicField(this, "componentStack", []);
|
|
2184
|
-
__publicField(this, "cleanupQueue", []);
|
|
2185
|
-
__publicField(this, "$instanceHash$", hash());
|
|
2186
|
-
// Temporary flag to find missing roots after the state was serialized
|
|
2187
|
-
__publicField(this, "$noMoreRoots$", false);
|
|
2188
|
-
__publicField(this, "qlInclude");
|
|
2189
|
-
__publicField(this, "promiseAttributes", null);
|
|
2190
|
-
__publicField(this, "$noScriptHere$", 0);
|
|
2191
2231
|
this.symbolToChunkResolver = (symbol) => {
|
|
2192
2232
|
const idx = symbol.lastIndexOf("_");
|
|
2193
2233
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2203,6 +2243,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2203
2243
|
this.tag = opts.tagName;
|
|
2204
2244
|
this.isHtml = opts.tagName === "html";
|
|
2205
2245
|
this.writer = opts.writer;
|
|
2246
|
+
this.streamHandler = opts.streamHandler;
|
|
2206
2247
|
this.timing = opts.timing;
|
|
2207
2248
|
this.$buildBase$ = opts.buildBase;
|
|
2208
2249
|
this.resolvedManifest = opts.resolvedManifest;
|
|
@@ -2286,27 +2327,24 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2286
2327
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
2287
2328
|
containerAttributes[QRuntimeAttr] = "2";
|
|
2288
2329
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
2289
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
2330
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev7 ? "ssr-dev" : "ssr");
|
|
2290
2331
|
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
2291
2332
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
2292
2333
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
2293
2334
|
containerAttributes[QInstanceAttr] = this.$instanceHash$;
|
|
2294
2335
|
this.$serverData$.containerAttributes = containerAttributes;
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
},
|
|
2300
|
-
[]
|
|
2301
|
-
);
|
|
2302
|
-
this.openElement(this.tag, null, containerAttributeArray);
|
|
2336
|
+
this.openElement(this.tag, null, containerAttributes);
|
|
2337
|
+
if (!this.isHtml) {
|
|
2338
|
+
this.emitContainerDataFrame = this.currentElementFrame;
|
|
2339
|
+
}
|
|
2303
2340
|
}
|
|
2304
2341
|
/** Renders closing tag for current container */
|
|
2305
2342
|
closeContainer() {
|
|
2306
2343
|
return this.closeElement();
|
|
2307
2344
|
}
|
|
2345
|
+
$noScriptHere$ = 0;
|
|
2308
2346
|
/** Renders opening tag for DOM element */
|
|
2309
|
-
openElement(elementName, key, varAttrs, constAttrs, currentFile) {
|
|
2347
|
+
openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null) {
|
|
2310
2348
|
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2311
2349
|
if (
|
|
2312
2350
|
// don't append qwik loader before qwik style elements
|
|
@@ -2325,23 +2363,26 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2325
2363
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2326
2364
|
}
|
|
2327
2365
|
this.createAndPushFrame(elementName, this.depthFirstElementCount++, currentFile);
|
|
2366
|
+
if (this.isHtml && elementName === "body" && this.emitContainerDataFrame === null) {
|
|
2367
|
+
this.emitContainerDataFrame = this.currentElementFrame;
|
|
2368
|
+
}
|
|
2328
2369
|
vNodeData_openElement(this.currentElementFrame.vNodeData);
|
|
2329
|
-
this.write(
|
|
2370
|
+
this.write(LT);
|
|
2330
2371
|
this.write(elementName);
|
|
2331
2372
|
const lastNode = this.getOrCreateLastNode();
|
|
2332
2373
|
if (varAttrs) {
|
|
2333
|
-
innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
|
|
2374
|
+
innerHTML = this.writeAttrs(elementName, varAttrs, false, styleScopedId, currentFile);
|
|
2334
2375
|
}
|
|
2335
2376
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
2336
2377
|
if (key !== null) {
|
|
2337
2378
|
this.write(`="${key}"`);
|
|
2338
|
-
} else if (
|
|
2339
|
-
this.write(
|
|
2379
|
+
} else if (import.meta.env.TEST) {
|
|
2380
|
+
this.write(EMPTY_ATTR);
|
|
2340
2381
|
}
|
|
2341
|
-
if (constAttrs && constAttrs
|
|
2342
|
-
innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
|
|
2382
|
+
if (constAttrs && !isObjectEmpty(constAttrs)) {
|
|
2383
|
+
innerHTML = this.writeAttrs(elementName, constAttrs, true, styleScopedId, currentFile) || innerHTML;
|
|
2343
2384
|
}
|
|
2344
|
-
this.write(
|
|
2385
|
+
this.write(GT);
|
|
2345
2386
|
if (lastNode) {
|
|
2346
2387
|
lastNode.setTreeNonUpdatable();
|
|
2347
2388
|
}
|
|
@@ -2349,7 +2390,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2349
2390
|
}
|
|
2350
2391
|
/** Renders closing tag for DOM element */
|
|
2351
2392
|
closeElement() {
|
|
2352
|
-
if (this.
|
|
2393
|
+
if (this.currentElementFrame === this.emitContainerDataFrame) {
|
|
2394
|
+
this.emitContainerDataFrame = null;
|
|
2353
2395
|
this.onRenderDone();
|
|
2354
2396
|
const snapshotTimer = createTimer();
|
|
2355
2397
|
return maybeThen(
|
|
@@ -2361,16 +2403,6 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2361
2403
|
}
|
|
2362
2404
|
this._closeElement();
|
|
2363
2405
|
}
|
|
2364
|
-
shouldEmitDataBeforeClosingElement() {
|
|
2365
|
-
const currentFrame = this.currentElementFrame;
|
|
2366
|
-
return (
|
|
2367
|
-
/**
|
|
2368
|
-
* - Micro-frontends don't have html tag, emit data before closing custom element
|
|
2369
|
-
* - Regular applications should emit data inside body
|
|
2370
|
-
*/
|
|
2371
|
-
currentFrame.parent === null && currentFrame.elementName !== "html" || currentFrame.elementName === "body"
|
|
2372
|
-
);
|
|
2373
|
-
}
|
|
2374
2406
|
onRenderDone() {
|
|
2375
2407
|
this.drainCleanupQueue();
|
|
2376
2408
|
this.timing.render = this.renderTimer();
|
|
@@ -2392,9 +2424,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2392
2424
|
const currentFrame = this.popFrame();
|
|
2393
2425
|
const elementName = currentFrame.elementName;
|
|
2394
2426
|
if (!isSelfClosingTag(elementName)) {
|
|
2395
|
-
this.write(
|
|
2427
|
+
this.write(CLOSE_TAG);
|
|
2396
2428
|
this.write(elementName);
|
|
2397
|
-
this.write(
|
|
2429
|
+
this.write(GT);
|
|
2398
2430
|
}
|
|
2399
2431
|
this.lastNode = null;
|
|
2400
2432
|
if (this.qlInclude === 1 /* Inline */) {
|
|
@@ -2465,13 +2497,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2465
2497
|
if (componentFrame.slots.length === 0) {
|
|
2466
2498
|
return;
|
|
2467
2499
|
}
|
|
2468
|
-
this.openElement(QTemplate, null,
|
|
2500
|
+
this.openElement(QTemplate, null, QTemplateProps, null);
|
|
2469
2501
|
const scopedStyleId = componentFrame.projectionScopedStyle;
|
|
2470
2502
|
for (let i = 0; i < componentFrame.slots.length; i += 2) {
|
|
2471
2503
|
const slotName = componentFrame.slots[i];
|
|
2472
2504
|
const children = componentFrame.slots[i + 1];
|
|
2473
2505
|
this.openFragment(
|
|
2474
|
-
|
|
2506
|
+
isDev7 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
|
|
2475
2507
|
);
|
|
2476
2508
|
const lastNode = this.getOrCreateLastNode();
|
|
2477
2509
|
if (lastNode.vnodeData) {
|
|
@@ -2561,7 +2593,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2561
2593
|
}
|
|
2562
2594
|
}
|
|
2563
2595
|
_styleNode(styleId, content) {
|
|
2564
|
-
this.openElement("style", null,
|
|
2596
|
+
this.openElement("style", null, {
|
|
2597
|
+
[QStyle]: styleId
|
|
2598
|
+
});
|
|
2565
2599
|
this.write(content);
|
|
2566
2600
|
this.closeElement();
|
|
2567
2601
|
}
|
|
@@ -2602,7 +2636,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2602
2636
|
if (!this.serializationCtx.$roots$.length) {
|
|
2603
2637
|
return;
|
|
2604
2638
|
}
|
|
2605
|
-
this.openElement("script", null,
|
|
2639
|
+
this.openElement("script", null, { type: "qwik/vnode" });
|
|
2606
2640
|
const vNodeAttrsStack = [];
|
|
2607
2641
|
const vNodeData = this.vNodeDatas;
|
|
2608
2642
|
let lastSerializedIdx = 0;
|
|
@@ -2619,7 +2653,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2619
2653
|
let depth = 0;
|
|
2620
2654
|
for (let i = 1; i < vNode.length; i++) {
|
|
2621
2655
|
const value = vNode[i];
|
|
2622
|
-
if (
|
|
2656
|
+
if (typeof value === "object" && value !== null) {
|
|
2623
2657
|
vNodeAttrsStack.push(fragmentAttrs);
|
|
2624
2658
|
fragmentAttrs = value;
|
|
2625
2659
|
} else if (value === OPEN_FRAGMENT) {
|
|
@@ -2633,7 +2667,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2633
2667
|
depth--;
|
|
2634
2668
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
2635
2669
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2636
|
-
if (fragmentAttrs && fragmentAttrs
|
|
2670
|
+
if (fragmentAttrs && !isObjectEmpty(fragmentAttrs)) {
|
|
2637
2671
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2638
2672
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2639
2673
|
this.writeFragmentAttrs(fragmentAttrs);
|
|
@@ -2660,9 +2694,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2660
2694
|
this.closeElement();
|
|
2661
2695
|
}
|
|
2662
2696
|
writeFragmentAttrs(fragmentAttrs) {
|
|
2663
|
-
for (
|
|
2664
|
-
|
|
2665
|
-
let value = fragmentAttrs[i++];
|
|
2697
|
+
for (const key in fragmentAttrs) {
|
|
2698
|
+
let value = fragmentAttrs[key];
|
|
2666
2699
|
let encodeValue = false;
|
|
2667
2700
|
if (typeof value !== "string") {
|
|
2668
2701
|
const rootId = this.addRoot(value);
|
|
@@ -2737,28 +2770,25 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2737
2770
|
}
|
|
2738
2771
|
/** Add q-d:qidle attribute to eagerly resume some state if needed */
|
|
2739
2772
|
stateScriptAttrs() {
|
|
2740
|
-
const attrs =
|
|
2773
|
+
const attrs = { type: "qwik/state" };
|
|
2741
2774
|
const eagerResume = this.serializationCtx.$eagerResume$;
|
|
2742
2775
|
if (eagerResume.size > 0) {
|
|
2743
|
-
|
|
2744
|
-
const qrlStr = qrlToString(this.serializationCtx, qrl);
|
|
2745
|
-
attrs.push("q-d:qidle", qrlStr);
|
|
2746
|
-
this.serializationCtx.$eventNames$.add("d:qidle");
|
|
2776
|
+
attrs["q-d:qidle"] = createQRL(null, "_res", _res, null, [...eagerResume]);
|
|
2747
2777
|
}
|
|
2748
2778
|
return attrs;
|
|
2749
2779
|
}
|
|
2750
2780
|
emitSyncFnsData() {
|
|
2751
2781
|
const fns = this.serializationCtx.$syncFns$;
|
|
2752
2782
|
if (fns.length) {
|
|
2753
|
-
const scriptAttrs =
|
|
2783
|
+
const scriptAttrs = { "q:func": "qwik/json" };
|
|
2754
2784
|
if (this.renderOptions.serverData?.nonce) {
|
|
2755
|
-
scriptAttrs
|
|
2785
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2756
2786
|
}
|
|
2757
2787
|
this.openElement("script", null, scriptAttrs);
|
|
2758
2788
|
this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
|
|
2759
|
-
this.write(
|
|
2760
|
-
this.writeArray(fns,
|
|
2761
|
-
this.write(
|
|
2789
|
+
this.write(BRACKET_OPEN);
|
|
2790
|
+
this.writeArray(fns, COMMA);
|
|
2791
|
+
this.write(BRACKET_CLOSE);
|
|
2762
2792
|
this.closeElement();
|
|
2763
2793
|
}
|
|
2764
2794
|
}
|
|
@@ -2776,9 +2806,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2776
2806
|
this.backpatchMap.clear();
|
|
2777
2807
|
if (patches.length > 0) {
|
|
2778
2808
|
this.isBackpatchExecutorEmitted = true;
|
|
2779
|
-
const scriptAttrs =
|
|
2809
|
+
const scriptAttrs = { type: ELEMENT_BACKPATCH_DATA };
|
|
2780
2810
|
if (this.renderOptions.serverData?.nonce) {
|
|
2781
|
-
scriptAttrs
|
|
2811
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2782
2812
|
}
|
|
2783
2813
|
this.openElement("script", null, scriptAttrs);
|
|
2784
2814
|
this.write(JSON.stringify(patches));
|
|
@@ -2789,12 +2819,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2789
2819
|
if (!this.isBackpatchExecutorEmitted) {
|
|
2790
2820
|
return;
|
|
2791
2821
|
}
|
|
2792
|
-
const scriptAttrs =
|
|
2822
|
+
const scriptAttrs = { type: "text/javascript" };
|
|
2793
2823
|
if (this.renderOptions.serverData?.nonce) {
|
|
2794
|
-
scriptAttrs
|
|
2824
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2795
2825
|
}
|
|
2796
2826
|
this.openElement("script", null, scriptAttrs);
|
|
2797
|
-
const backpatchScript = getQwikBackpatchExecutorScript({ debug:
|
|
2827
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev7 });
|
|
2798
2828
|
this.write(backpatchScript);
|
|
2799
2829
|
this.closeElement();
|
|
2800
2830
|
}
|
|
@@ -2808,16 +2838,20 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2808
2838
|
if (this.qlInclude === 0 /* Module */) {
|
|
2809
2839
|
this.qlInclude = 2 /* Done */;
|
|
2810
2840
|
const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
|
|
2811
|
-
const linkAttrs =
|
|
2841
|
+
const linkAttrs = { rel: "modulepreload", href: qwikLoaderBundle };
|
|
2812
2842
|
const nonce = this.renderOptions.serverData?.nonce;
|
|
2813
2843
|
if (nonce) {
|
|
2814
|
-
linkAttrs
|
|
2844
|
+
linkAttrs["nonce"] = nonce;
|
|
2815
2845
|
}
|
|
2816
2846
|
this.openElement("link", null, linkAttrs);
|
|
2817
2847
|
this.closeElement();
|
|
2818
|
-
const scriptAttrs =
|
|
2848
|
+
const scriptAttrs = {
|
|
2849
|
+
async: true,
|
|
2850
|
+
type: "module",
|
|
2851
|
+
src: qwikLoaderBundle
|
|
2852
|
+
};
|
|
2819
2853
|
if (nonce) {
|
|
2820
|
-
scriptAttrs
|
|
2854
|
+
scriptAttrs["nonce"] = nonce;
|
|
2821
2855
|
}
|
|
2822
2856
|
this.openElement("script", null, scriptAttrs);
|
|
2823
2857
|
this.closeElement();
|
|
@@ -2826,9 +2860,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2826
2860
|
emitQwikLoaderInline() {
|
|
2827
2861
|
this.qlInclude = 2 /* Done */;
|
|
2828
2862
|
const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
|
|
2829
|
-
const scriptAttrs =
|
|
2863
|
+
const scriptAttrs = {
|
|
2864
|
+
id: "qwikloader",
|
|
2865
|
+
async: true,
|
|
2866
|
+
type: "module"
|
|
2867
|
+
};
|
|
2830
2868
|
if (this.renderOptions.serverData?.nonce) {
|
|
2831
|
-
scriptAttrs
|
|
2869
|
+
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
2832
2870
|
}
|
|
2833
2871
|
this.openElement("script", null, scriptAttrs);
|
|
2834
2872
|
this.write(qwikLoaderScript);
|
|
@@ -2844,15 +2882,15 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2844
2882
|
}
|
|
2845
2883
|
emitQwikEvents(eventNames) {
|
|
2846
2884
|
if (eventNames.length > 0) {
|
|
2847
|
-
const scriptAttrs =
|
|
2885
|
+
const scriptAttrs = {};
|
|
2848
2886
|
const nonce = this.renderOptions.serverData?.nonce;
|
|
2849
2887
|
if (nonce) {
|
|
2850
|
-
scriptAttrs
|
|
2888
|
+
scriptAttrs["nonce"] = nonce;
|
|
2851
2889
|
}
|
|
2852
2890
|
this.openElement("script", null, scriptAttrs);
|
|
2853
2891
|
this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
|
|
2854
|
-
this.writeArray(eventNames,
|
|
2855
|
-
this.write(
|
|
2892
|
+
this.writeArray(eventNames, COMMA);
|
|
2893
|
+
this.write(PAREN_CLOSE);
|
|
2856
2894
|
this.closeElement();
|
|
2857
2895
|
}
|
|
2858
2896
|
}
|
|
@@ -2884,7 +2922,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2884
2922
|
}
|
|
2885
2923
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
2886
2924
|
let tagNesting = 10 /* ANYTHING */;
|
|
2887
|
-
if (
|
|
2925
|
+
if (isDev7) {
|
|
2888
2926
|
if (!this.currentElementFrame) {
|
|
2889
2927
|
tagNesting = initialTag(elementName);
|
|
2890
2928
|
} else {
|
|
@@ -2930,7 +2968,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2930
2968
|
elementName,
|
|
2931
2969
|
depthFirstElementIdx,
|
|
2932
2970
|
vNodeData: [0 /* NONE */],
|
|
2933
|
-
currentFile:
|
|
2971
|
+
currentFile: isDev7 ? currentFile || null : null
|
|
2934
2972
|
};
|
|
2935
2973
|
this.currentElementFrame = frame;
|
|
2936
2974
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -2954,95 +2992,95 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2954
2992
|
this.write(element);
|
|
2955
2993
|
}
|
|
2956
2994
|
}
|
|
2957
|
-
writeAttrs(tag, attrs, isConst, currentFile) {
|
|
2995
|
+
writeAttrs(tag, attrs, isConst, styleScopedId, currentFile) {
|
|
2958
2996
|
let innerHTML = void 0;
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
if (isDev6) {
|
|
2966
|
-
throw qError(32 /* unsafeAttr */, [key]);
|
|
2967
|
-
}
|
|
2968
|
-
continue;
|
|
2997
|
+
let isLoopElement = null;
|
|
2998
|
+
for (let key in attrs) {
|
|
2999
|
+
let value = attrs[key];
|
|
3000
|
+
if (isSSRUnsafeAttr(key)) {
|
|
3001
|
+
if (isDev7) {
|
|
3002
|
+
throw qError(32 /* unsafeAttr */, [key]);
|
|
2969
3003
|
}
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
if (key === "ref") {
|
|
2976
|
-
const lastNode = this.getOrCreateLastNode();
|
|
2977
|
-
if (isSignal(value)) {
|
|
2978
|
-
value.$untrackedValue$ = new DomRef(lastNode);
|
|
2979
|
-
continue;
|
|
2980
|
-
} else if (typeof value === "function") {
|
|
2981
|
-
value(new DomRef(lastNode));
|
|
2982
|
-
continue;
|
|
2983
|
-
} else if (value == null) {
|
|
2984
|
-
continue;
|
|
2985
|
-
} else {
|
|
2986
|
-
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2987
|
-
}
|
|
3004
|
+
continue;
|
|
3005
|
+
}
|
|
3006
|
+
if (isHtmlAttributeAnEventName(key)) {
|
|
3007
|
+
if (isLoopElement === null) {
|
|
3008
|
+
isLoopElement = attributesContainsIterationProp(attrs);
|
|
2988
3009
|
}
|
|
3010
|
+
value = _setEvent(this.serializationCtx, key, value, isLoopElement);
|
|
3011
|
+
} else if (key === "ref") {
|
|
3012
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2989
3013
|
if (isSignal(value)) {
|
|
2990
|
-
|
|
2991
|
-
const signalData = new SubscriptionData({
|
|
2992
|
-
$scopedStyleIdPrefix$: styleScopedId,
|
|
2993
|
-
$isConst$: isConst
|
|
2994
|
-
});
|
|
2995
|
-
const signal = value;
|
|
2996
|
-
value = retryOnPromise(
|
|
2997
|
-
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
2998
|
-
);
|
|
2999
|
-
}
|
|
3000
|
-
if (isPromise(value)) {
|
|
3001
|
-
const lastNode = this.getOrCreateLastNode();
|
|
3002
|
-
this.addPromiseAttribute(value);
|
|
3003
|
-
value.then((resolvedValue) => {
|
|
3004
|
-
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
3005
|
-
});
|
|
3014
|
+
value.$untrackedValue$ = new DomRef(lastNode);
|
|
3006
3015
|
continue;
|
|
3016
|
+
} else if (typeof value === "function") {
|
|
3017
|
+
value(new DomRef(lastNode));
|
|
3018
|
+
continue;
|
|
3019
|
+
} else if (value == null) {
|
|
3020
|
+
continue;
|
|
3021
|
+
} else {
|
|
3022
|
+
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
3007
3023
|
}
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3024
|
+
} else if (key === ITERATION_ITEM_SINGLE || key === ITERATION_ITEM_MULTI) {
|
|
3025
|
+
value = this.serializationCtx.$addRoot$(value);
|
|
3026
|
+
} else if (isSignal(value)) {
|
|
3027
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3028
|
+
const signalData = new SubscriptionData({
|
|
3029
|
+
$scopedStyleIdPrefix$: styleScopedId,
|
|
3030
|
+
$isConst$: isConst
|
|
3031
|
+
});
|
|
3032
|
+
const signal = value;
|
|
3033
|
+
value = retryOnPromise(
|
|
3034
|
+
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
3035
|
+
);
|
|
3036
|
+
}
|
|
3037
|
+
if (isPromise(value)) {
|
|
3038
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3039
|
+
this.addPromiseAttribute(value);
|
|
3040
|
+
value.then((resolvedValue) => {
|
|
3041
|
+
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
3042
|
+
});
|
|
3043
|
+
continue;
|
|
3044
|
+
}
|
|
3045
|
+
if (key === dangerouslySetInnerHTML) {
|
|
3046
|
+
if (value) {
|
|
3047
|
+
innerHTML = String(value);
|
|
3026
3048
|
key = QContainerAttr;
|
|
3027
|
-
value = "
|
|
3049
|
+
value = "html" /* HTML */;
|
|
3050
|
+
}
|
|
3051
|
+
if (tag === "style") {
|
|
3052
|
+
continue;
|
|
3028
3053
|
}
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
this.write(strValue);
|
|
3037
|
-
this.write('"');
|
|
3054
|
+
} else if (isPreventDefault(key)) {
|
|
3055
|
+
addPreventDefaultEventToSerializationContext(this.serializationCtx, key);
|
|
3056
|
+
}
|
|
3057
|
+
if (tag === "textarea" && key === "value") {
|
|
3058
|
+
if (value && typeof value !== "string") {
|
|
3059
|
+
if (isDev7) {
|
|
3060
|
+
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
3038
3061
|
}
|
|
3062
|
+
continue;
|
|
3063
|
+
}
|
|
3064
|
+
innerHTML = escapeHTML(value || "");
|
|
3065
|
+
key = QContainerAttr;
|
|
3066
|
+
value = "text" /* TEXT */;
|
|
3067
|
+
}
|
|
3068
|
+
const serializedValue = serializeAttribute(key, value, styleScopedId);
|
|
3069
|
+
if (serializedValue != null && serializedValue !== false) {
|
|
3070
|
+
this.write(SPACE);
|
|
3071
|
+
this.write(key);
|
|
3072
|
+
if (serializedValue !== true) {
|
|
3073
|
+
this.write(ATTR_EQUALS_QUOTE);
|
|
3074
|
+
const strValue = escapeHTML(String(serializedValue));
|
|
3075
|
+
this.write(strValue);
|
|
3076
|
+
this.write(QUOTE);
|
|
3039
3077
|
}
|
|
3040
3078
|
}
|
|
3041
3079
|
}
|
|
3042
3080
|
return innerHTML;
|
|
3043
3081
|
}
|
|
3044
3082
|
addPromiseAttribute(promise) {
|
|
3045
|
-
this.promiseAttributes
|
|
3083
|
+
this.promiseAttributes ||= [];
|
|
3046
3084
|
this.promiseAttributes.push(promise);
|
|
3047
3085
|
}
|
|
3048
3086
|
async resolvePromiseAttributes() {
|
|
@@ -3054,15 +3092,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
3054
3092
|
};
|
|
3055
3093
|
var isQwikStyleElement = (tag, attrs) => {
|
|
3056
3094
|
if (tag === "style" && attrs != null) {
|
|
3057
|
-
|
|
3058
|
-
const attr = attrs[i];
|
|
3059
|
-
if (attr === QStyle || attr === QScopedStyle) {
|
|
3060
|
-
return true;
|
|
3061
|
-
}
|
|
3062
|
-
}
|
|
3095
|
+
return Object.prototype.hasOwnProperty.call(attrs, QStyle) || Object.prototype.hasOwnProperty.call(attrs, QScopedStyle);
|
|
3063
3096
|
}
|
|
3064
3097
|
return false;
|
|
3065
3098
|
};
|
|
3099
|
+
var attributesContainsIterationProp = (attrs) => {
|
|
3100
|
+
return Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_SINGLE) || Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_MULTI);
|
|
3101
|
+
};
|
|
3066
3102
|
function newTagError(text) {
|
|
3067
3103
|
return qError(12 /* tagError */, [text]);
|
|
3068
3104
|
}
|
|
@@ -3081,9 +3117,125 @@ function isSSRUnsafeAttr(name) {
|
|
|
3081
3117
|
function hash() {
|
|
3082
3118
|
return Math.random().toString(36).slice(2);
|
|
3083
3119
|
}
|
|
3120
|
+
function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
|
|
3121
|
+
const eventName = "e" + key.substring(14);
|
|
3122
|
+
if (eventName) {
|
|
3123
|
+
serializationCtx.$eventNames$.add(eventName);
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3084
3126
|
|
|
3085
3127
|
// packages/qwik/src/server/ssr-render.ts
|
|
3086
3128
|
import { manifest as builtManifest } from "@qwik-client-manifest";
|
|
3129
|
+
|
|
3130
|
+
// packages/qwik/src/server/ssr-stream-handler.ts
|
|
3131
|
+
var StreamHandler = class {
|
|
3132
|
+
constructor(opts, timing) {
|
|
3133
|
+
this.opts = opts;
|
|
3134
|
+
this.timing = timing;
|
|
3135
|
+
this.inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
3136
|
+
strategy: "auto",
|
|
3137
|
+
maximumInitialChunk: 2e4,
|
|
3138
|
+
maximumChunk: 1e4
|
|
3139
|
+
};
|
|
3140
|
+
this.nativeStream = opts.stream;
|
|
3141
|
+
this.stream = this.setupStreamWriter();
|
|
3142
|
+
}
|
|
3143
|
+
bufferSize = 0;
|
|
3144
|
+
buffer = "";
|
|
3145
|
+
networkFlushes = 0;
|
|
3146
|
+
inOrderStreaming;
|
|
3147
|
+
streamBlockDepth = 0;
|
|
3148
|
+
streamBlockBuffer = "";
|
|
3149
|
+
streamBlockBufferSize = 0;
|
|
3150
|
+
nativeStream;
|
|
3151
|
+
firstFlushTimer = createTimer();
|
|
3152
|
+
stream;
|
|
3153
|
+
setupStreamWriter() {
|
|
3154
|
+
const handler = this;
|
|
3155
|
+
let stream;
|
|
3156
|
+
switch (this.inOrderStreaming.strategy) {
|
|
3157
|
+
case "disabled":
|
|
3158
|
+
stream = {
|
|
3159
|
+
write(chunk) {
|
|
3160
|
+
if (chunk === void 0 || chunk === null) {
|
|
3161
|
+
return;
|
|
3162
|
+
}
|
|
3163
|
+
handler.enqueue(chunk);
|
|
3164
|
+
}
|
|
3165
|
+
};
|
|
3166
|
+
break;
|
|
3167
|
+
case "direct": {
|
|
3168
|
+
const originalStream = this.nativeStream;
|
|
3169
|
+
stream = {
|
|
3170
|
+
write(chunk) {
|
|
3171
|
+
if (chunk === void 0 || chunk === null) {
|
|
3172
|
+
return;
|
|
3173
|
+
}
|
|
3174
|
+
originalStream.write(chunk);
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
break;
|
|
3178
|
+
}
|
|
3179
|
+
default:
|
|
3180
|
+
case "auto": {
|
|
3181
|
+
const minimumChunkSize = this.inOrderStreaming.maximumChunk ?? 0;
|
|
3182
|
+
const initialChunkSize = this.inOrderStreaming.maximumInitialChunk ?? 0;
|
|
3183
|
+
stream = {
|
|
3184
|
+
write(chunk) {
|
|
3185
|
+
if (chunk === void 0 || chunk === null) {
|
|
3186
|
+
return;
|
|
3187
|
+
}
|
|
3188
|
+
handler.enqueue(chunk);
|
|
3189
|
+
if (handler.streamBlockDepth === 0) {
|
|
3190
|
+
const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3191
|
+
if (handler.bufferSize >= maxBufferSize) {
|
|
3192
|
+
handler.flush();
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
break;
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
return stream;
|
|
3201
|
+
}
|
|
3202
|
+
enqueue(chunk) {
|
|
3203
|
+
const len = chunk.length;
|
|
3204
|
+
if (this.streamBlockDepth > 0) {
|
|
3205
|
+
this.streamBlockBuffer += chunk;
|
|
3206
|
+
this.streamBlockBufferSize += len;
|
|
3207
|
+
} else {
|
|
3208
|
+
this.bufferSize += len;
|
|
3209
|
+
this.buffer += chunk;
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
flush() {
|
|
3213
|
+
if (this.buffer) {
|
|
3214
|
+
this.nativeStream.write(this.buffer);
|
|
3215
|
+
this.buffer = "";
|
|
3216
|
+
this.bufferSize = 0;
|
|
3217
|
+
this.networkFlushes++;
|
|
3218
|
+
if (this.networkFlushes === 1) {
|
|
3219
|
+
this.timing.firstFlush = this.firstFlushTimer();
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
streamBlockStart() {
|
|
3224
|
+
this.streamBlockDepth++;
|
|
3225
|
+
}
|
|
3226
|
+
streamBlockEnd() {
|
|
3227
|
+
this.streamBlockDepth--;
|
|
3228
|
+
if (this.streamBlockDepth === 0 && this.streamBlockBuffer) {
|
|
3229
|
+
this.buffer += this.streamBlockBuffer;
|
|
3230
|
+
this.bufferSize += this.streamBlockBufferSize;
|
|
3231
|
+
this.streamBlockBuffer = "";
|
|
3232
|
+
this.streamBlockBufferSize = 0;
|
|
3233
|
+
this.flush();
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
|
|
3238
|
+
// packages/qwik/src/server/ssr-render.ts
|
|
3087
3239
|
var renderToString = async (jsx, opts = {}) => {
|
|
3088
3240
|
const chunks = [];
|
|
3089
3241
|
const stream = {
|
|
@@ -3110,11 +3262,12 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3110
3262
|
const buildBase = getBuildBase(opts);
|
|
3111
3263
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
3112
3264
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
3113
|
-
const
|
|
3265
|
+
const streamHandler = new StreamHandler(opts, timing);
|
|
3114
3266
|
const ssrContainer = ssrCreateContainer({
|
|
3115
3267
|
tagName: containerTagName,
|
|
3116
3268
|
locale,
|
|
3117
|
-
writer: stream,
|
|
3269
|
+
writer: streamHandler.stream,
|
|
3270
|
+
streamHandler,
|
|
3118
3271
|
timing,
|
|
3119
3272
|
buildBase,
|
|
3120
3273
|
resolvedManifest,
|
|
@@ -3123,11 +3276,9 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3123
3276
|
await setServerPlatform(opts, resolvedManifest);
|
|
3124
3277
|
await ssrContainer.render(jsx);
|
|
3125
3278
|
await ssrContainer.$renderPromise$;
|
|
3126
|
-
flush();
|
|
3127
|
-
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
3279
|
+
streamHandler.flush();
|
|
3128
3280
|
const result = {
|
|
3129
|
-
|
|
3130
|
-
flushes: networkFlushes,
|
|
3281
|
+
flushes: streamHandler.networkFlushes,
|
|
3131
3282
|
manifest: resolvedManifest?.manifest,
|
|
3132
3283
|
size: ssrContainer.size,
|
|
3133
3284
|
isStatic: false,
|
|
@@ -3135,110 +3286,6 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3135
3286
|
};
|
|
3136
3287
|
return result;
|
|
3137
3288
|
};
|
|
3138
|
-
function getSnapshotResult(ssrContainer) {
|
|
3139
|
-
const hasListeners = !ssrContainer.isStatic();
|
|
3140
|
-
const canRender = false;
|
|
3141
|
-
return hasListeners ? {
|
|
3142
|
-
funcs: Array.from(ssrContainer.serializationCtx.$syncFns$),
|
|
3143
|
-
mode: canRender ? "render" : "listeners",
|
|
3144
|
-
qrls: Array.from(ssrContainer.serializationCtx.$eventQrls$),
|
|
3145
|
-
resources: Array.from(ssrContainer.serializationCtx.$resources$)
|
|
3146
|
-
} : {
|
|
3147
|
-
funcs: [],
|
|
3148
|
-
mode: "static",
|
|
3149
|
-
qrls: [],
|
|
3150
|
-
resources: Array.from(ssrContainer.serializationCtx.$resources$)
|
|
3151
|
-
};
|
|
3152
|
-
}
|
|
3153
|
-
function handleStreaming(opts, timing) {
|
|
3154
|
-
const firstFlushTimer = createTimer();
|
|
3155
|
-
let stream = opts.stream;
|
|
3156
|
-
let bufferSize = 0;
|
|
3157
|
-
let buffer = "";
|
|
3158
|
-
let networkFlushes = 0;
|
|
3159
|
-
const inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
3160
|
-
strategy: "auto",
|
|
3161
|
-
maximumInitialChunk: 2e4,
|
|
3162
|
-
maximumChunk: 1e4
|
|
3163
|
-
};
|
|
3164
|
-
const nativeStream = stream;
|
|
3165
|
-
function flush() {
|
|
3166
|
-
if (buffer) {
|
|
3167
|
-
nativeStream.write(buffer);
|
|
3168
|
-
buffer = "";
|
|
3169
|
-
bufferSize = 0;
|
|
3170
|
-
networkFlushes++;
|
|
3171
|
-
if (networkFlushes === 1) {
|
|
3172
|
-
timing.firstFlush = firstFlushTimer();
|
|
3173
|
-
}
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
function enqueue(chunk) {
|
|
3177
|
-
const len = chunk.length;
|
|
3178
|
-
bufferSize += len;
|
|
3179
|
-
buffer += chunk;
|
|
3180
|
-
}
|
|
3181
|
-
switch (inOrderStreaming.strategy) {
|
|
3182
|
-
case "disabled":
|
|
3183
|
-
stream = {
|
|
3184
|
-
write(chunk) {
|
|
3185
|
-
if (shouldSkipChunk(chunk)) {
|
|
3186
|
-
return;
|
|
3187
|
-
}
|
|
3188
|
-
enqueue(chunk);
|
|
3189
|
-
}
|
|
3190
|
-
};
|
|
3191
|
-
break;
|
|
3192
|
-
case "direct":
|
|
3193
|
-
stream = {
|
|
3194
|
-
write(chunk) {
|
|
3195
|
-
if (shouldSkipChunk(chunk)) {
|
|
3196
|
-
return;
|
|
3197
|
-
}
|
|
3198
|
-
nativeStream.write(chunk);
|
|
3199
|
-
}
|
|
3200
|
-
};
|
|
3201
|
-
break;
|
|
3202
|
-
case "auto":
|
|
3203
|
-
let openedSSRStreamBlocks = 0;
|
|
3204
|
-
let forceFlush = false;
|
|
3205
|
-
const minimumChunkSize = inOrderStreaming.maximumChunk ?? 0;
|
|
3206
|
-
const initialChunkSize = inOrderStreaming.maximumInitialChunk ?? 0;
|
|
3207
|
-
stream = {
|
|
3208
|
-
write(chunk) {
|
|
3209
|
-
if (chunk === void 0 || chunk === null) {
|
|
3210
|
-
return;
|
|
3211
|
-
}
|
|
3212
|
-
if (chunk === "<!--" + FLUSH_COMMENT + "-->") {
|
|
3213
|
-
forceFlush = true;
|
|
3214
|
-
} else if (chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->") {
|
|
3215
|
-
openedSSRStreamBlocks++;
|
|
3216
|
-
} else if (chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->") {
|
|
3217
|
-
openedSSRStreamBlocks--;
|
|
3218
|
-
if (openedSSRStreamBlocks === 0) {
|
|
3219
|
-
forceFlush = true;
|
|
3220
|
-
}
|
|
3221
|
-
} else {
|
|
3222
|
-
enqueue(chunk);
|
|
3223
|
-
}
|
|
3224
|
-
const maxBufferSize = networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3225
|
-
if (openedSSRStreamBlocks === 0 && (forceFlush || bufferSize >= maxBufferSize)) {
|
|
3226
|
-
forceFlush = false;
|
|
3227
|
-
flush();
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
|
-
};
|
|
3231
|
-
break;
|
|
3232
|
-
}
|
|
3233
|
-
return {
|
|
3234
|
-
stream,
|
|
3235
|
-
flush,
|
|
3236
|
-
networkFlushes
|
|
3237
|
-
};
|
|
3238
|
-
}
|
|
3239
|
-
function shouldSkipChunk(chunk) {
|
|
3240
|
-
return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
|
|
3241
|
-
}
|
|
3242
3289
|
function resolveManifest(manifest) {
|
|
3243
3290
|
const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
|
|
3244
3291
|
if (!mergedManifest || "mapper" in mergedManifest) {
|