@qwik.dev/core 2.0.0-beta.8 → 2.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/index.cjs +6 -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 +34 -0
- package/dist/backpatch-executor.js +1 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +105 -55
- package/dist/core.cjs +976 -456
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +974 -456
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +638 -351
- package/dist/core.prod.mjs +709 -362
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +75 -73
- package/dist/optimizer.mjs +75 -75
- package/dist/server.cjs +143 -42
- package/dist/server.d.ts +9 -0
- package/dist/server.mjs +140 -42
- package/dist/testing/index.cjs +3749 -927
- package/dist/testing/index.d.ts +972 -1
- package/dist/testing/index.mjs +3735 -921
- package/dist/testing/package.json +1 -1
- package/package.json +4 -2
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.9-dev+6b582c7
|
|
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
|
|
@@ -291,6 +291,7 @@ var ELEMENT_KEY = "q:key";
|
|
|
291
291
|
var ELEMENT_PROPS = "q:props";
|
|
292
292
|
var ELEMENT_SEQ = "q:seq";
|
|
293
293
|
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
294
|
+
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
294
295
|
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
295
296
|
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
296
297
|
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
@@ -1090,13 +1091,6 @@ function createPlatform(opts, resolvedManifest) {
|
|
|
1090
1091
|
console.error("server can not rerender");
|
|
1091
1092
|
return Promise.resolve();
|
|
1092
1093
|
},
|
|
1093
|
-
nextTick: (fn) => {
|
|
1094
|
-
return new Promise((resolve) => {
|
|
1095
|
-
setTimeout(() => {
|
|
1096
|
-
resolve(fn());
|
|
1097
|
-
});
|
|
1098
|
-
});
|
|
1099
|
-
},
|
|
1100
1094
|
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1101
1095
|
return mapperFn(symbolName, mapper, parent);
|
|
1102
1096
|
}
|
|
@@ -1141,7 +1135,7 @@ function getBuildBase(opts) {
|
|
|
1141
1135
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1142
1136
|
}
|
|
1143
1137
|
var versions = {
|
|
1144
|
-
qwik: "2.0.0-beta.
|
|
1138
|
+
qwik: "2.0.0-beta.9-dev+6b582c7",
|
|
1145
1139
|
qwikDom: "2.1.19"
|
|
1146
1140
|
};
|
|
1147
1141
|
|
|
@@ -1159,6 +1153,41 @@ import { isDev as isDev5 } from "@qwik.dev/core/build";
|
|
|
1159
1153
|
// packages/qwik/src/server/scripts.ts
|
|
1160
1154
|
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]);let r;const s=(t,e)=>Array.from(t.querySelectorAll(e)),a=t=>{const e=[];return o.forEach(n=>e.push(...s(n,t))),e},i=t=>{m(t),s(t,"[q\\\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&i(e)})},c=t=>t&&"function"==typeof t.then,l=(t,e,n=e.type)=>{a("[on"+t+"\\\\:"+n+"]").forEach(o=>{u(o,t,e,n)})},f=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},p=(t,e)=>new CustomEvent(t,{detail:e}),u=async(e,n,o,r=o.type)=>{const s="on"+n+":"+r;e.hasAttribute("preventdefault:"+r)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+r)&&o.stopPropagation();const a=e._qc_,i=a&&a.li.filter(t=>t[0]===s);if(i&&i.length>0){for(const t of i){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;c(n)&&await n,r&&o.stopPropagation()}return}const l=e.getAttribute(s),p=e.qDispatchEvent;if(p)return p(o,n);if(l){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=n.getAttribute("q:version")||"unknown",a=n.getAttribute("q:manifest-hash")||"dev",i=new URL(r,t.baseURI);for(const p of l.split("\\n")){const l=new URL(p,i),u=l.href,q=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,y;const m=p.startsWith("#"),w={qBase:r,qManifest:a,qVersion:s,href:u,symbol:q,element:e,reqTime:h};if(m){const e=n.getAttribute("q:instance");_=(t["qFuncs_"+e]||[])[Number.parseInt(q)],_||(d="sync",y=Error("sym:"+q))}else{b("qsymbol",w);const t=l.href.split("#")[0];try{const e=import(t);f(n),_=(await e)[q],_||(d="no-symbol",y=Error(`${q} not in ${t}`))}catch(t){d||(d="async"),y=t}}if(!_){b("qerror",{importError:d,error:y,...w}),console.error(y);break}const g=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,l];const n=_(o,e);c(n)&&await n}catch(t){b("qerror",{error:t,...w})}finally{t.__q_context__=g}}}},b=(e,n)=>{t.dispatchEvent(p(e,n))},q=t=>t.replace(/([A-Z])/g,t=>"-"+t.toLowerCase()),h=async t=>{let e=q(t.type),n=t.target;for(l("-document",t,e);n&&n.getAttribute;){const o=u(n,"",t,e);let r=t.cancelBubble;c(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute("stoppropagation:"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},_=t=>{l("-window",t,q(t.type))},d=()=>{var s;const c=t.readyState;if(!r&&("interactive"==c||"complete"==c)&&(o.forEach(i),r=1,b("qinit"),(null!=(s=e.requestIdleCallback)?s:e.setTimeout).bind(e)(()=>b("qidle")),n.has("qvisible"))){const t=a("[on\\\\:qvisible]"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),u(n.target,"",p("qvisible",n)))});t.forEach(t=>e.observe(t))}},y=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},m=(...t)=>{for(const r of t)"string"==typeof r?n.has(r)||(o.forEach(t=>y(t,r,h,!0)),y(e,r,_,!0),n.add(r)):o.has(r)||(n.forEach(t=>y(r,t,h,!0)),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?m(...r):m("click","input")),e.qwikevents={events:n,roots:o,push:m},y(t,"readystatechange",d),d()}';
|
|
1161
1155
|
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 processEventOrNode(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 broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n dispatch(el, infix, ev, type);\n });\n};\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, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n if (element.hasAttribute("preventdefault:" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\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 qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\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 emitEvent("qsymbol", eventData);\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z])/g, (a) => "-" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast("-window", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = (_a = win.requestIdleCallback) != null ? _a : win.setTimeout;\n riC.bind(win)(() => emitEvent("qidle"));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const 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));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nconst processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n roots.forEach(\n (root) => addEventListener(root, eventNameOrNode, processDocumentEvent, true)\n );\n addEventListener(win, eventNameOrNode, processWindowEvent, true);\n events.add(eventNameOrNode);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach(\n (eventName) => addEventListener(eventNameOrNode, eventName, processDocumentEvent, true)\n );\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!("__q_context__" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode("click", "input");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1156
|
+
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=0;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let l=t[e+2];for(;c<o;)r=n.nextNode(),c++;const s=r;null==l||!1===l?s.removeAttribute(i):("boolean"==typeof l&&(l=""),s.setAttribute(i,l))}}}}`;
|
|
1157
|
+
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1158
|
+
const executorScript = document.currentScript;
|
|
1159
|
+
if (executorScript) {
|
|
1160
|
+
const container = executorScript.closest(
|
|
1161
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1162
|
+
);
|
|
1163
|
+
if (container) {
|
|
1164
|
+
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1165
|
+
if (script) {
|
|
1166
|
+
const data = JSON.parse(script.textContent || "[]");
|
|
1167
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1168
|
+
let currentNode = walker.currentNode;
|
|
1169
|
+
let currentNodeIdx = 0;
|
|
1170
|
+
for (let i = 0; i < data.length; i += 3) {
|
|
1171
|
+
const elementIdx = data[i];
|
|
1172
|
+
const attrName = data[i + 1];
|
|
1173
|
+
let value = data[i + 2];
|
|
1174
|
+
while (currentNodeIdx < elementIdx) {
|
|
1175
|
+
currentNode = walker.nextNode();
|
|
1176
|
+
currentNodeIdx++;
|
|
1177
|
+
}
|
|
1178
|
+
const element = currentNode;
|
|
1179
|
+
if (value == null || value === false) {
|
|
1180
|
+
element.removeAttribute(attrName);
|
|
1181
|
+
} else {
|
|
1182
|
+
if (typeof value === "boolean") {
|
|
1183
|
+
value = "";
|
|
1184
|
+
}
|
|
1185
|
+
element.setAttribute(attrName, value);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
}`;
|
|
1162
1191
|
function getQwikLoaderScript(opts = {}) {
|
|
1163
1192
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1164
1193
|
}
|
|
@@ -1167,6 +1196,9 @@ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
|
1167
1196
|
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1168
1197
|
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1169
1198
|
}
|
|
1199
|
+
function getQwikBackpatchExecutorScript(opts = {}) {
|
|
1200
|
+
return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
|
|
1201
|
+
}
|
|
1170
1202
|
|
|
1171
1203
|
// packages/qwik/src/server/ssr-node.ts
|
|
1172
1204
|
import {
|
|
@@ -1176,10 +1208,12 @@ import {
|
|
|
1176
1208
|
} from "@qwik.dev/core";
|
|
1177
1209
|
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
1178
1210
|
var SsrNode = class {
|
|
1179
|
-
constructor(
|
|
1211
|
+
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1212
|
+
this.parentComponent = parentComponent;
|
|
1180
1213
|
this.attributesIndex = attributesIndex;
|
|
1181
1214
|
this.cleanupQueue = cleanupQueue;
|
|
1182
1215
|
this.vnodeData = vnodeData;
|
|
1216
|
+
this.currentFile = currentFile;
|
|
1183
1217
|
__publicField(this, "__brand__", "SsrNode");
|
|
1184
1218
|
/**
|
|
1185
1219
|
* ID which the deserialize will use to retrieve the node.
|
|
@@ -1187,15 +1221,15 @@ var SsrNode = class {
|
|
|
1187
1221
|
* @param id - Unique id for the node.
|
|
1188
1222
|
*/
|
|
1189
1223
|
__publicField(this, "id");
|
|
1190
|
-
__publicField(this, "
|
|
1224
|
+
__publicField(this, "flags");
|
|
1191
1225
|
__publicField(this, "children", null);
|
|
1192
1226
|
__publicField(this, "attrs");
|
|
1193
1227
|
/** Local props which don't serialize; */
|
|
1194
1228
|
__publicField(this, "localProps", null);
|
|
1195
|
-
this.parentSsrNode = parentSsrNode;
|
|
1196
|
-
this.parentSsrNode?.addChild(this);
|
|
1197
1229
|
this.id = id;
|
|
1230
|
+
this.flags = 1 /* Updatable */;
|
|
1198
1231
|
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_ARRAY;
|
|
1232
|
+
this.parentComponent?.addChild(this);
|
|
1199
1233
|
if (isDev4 && id.indexOf("undefined") != -1) {
|
|
1200
1234
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1201
1235
|
}
|
|
@@ -1249,18 +1283,30 @@ var SsrNode = class {
|
|
|
1249
1283
|
}
|
|
1250
1284
|
this.children.push(child);
|
|
1251
1285
|
}
|
|
1286
|
+
setTreeNonUpdatable() {
|
|
1287
|
+
this.flags &= ~1 /* Updatable */;
|
|
1288
|
+
if (this.children) {
|
|
1289
|
+
for (const child of this.children) {
|
|
1290
|
+
child.setTreeNonUpdatable();
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1252
1294
|
toString() {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1295
|
+
if (isDev4) {
|
|
1296
|
+
let stringifiedAttrs = "";
|
|
1297
|
+
for (let i = 0; i < this.attrs.length; i += 2) {
|
|
1298
|
+
const key = this.attrs[i];
|
|
1299
|
+
const value = this.attrs[i + 1];
|
|
1300
|
+
stringifiedAttrs += `${key}=`;
|
|
1301
|
+
stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
|
|
1302
|
+
if (i < this.attrs.length - 2) {
|
|
1303
|
+
stringifiedAttrs += ", ";
|
|
1304
|
+
}
|
|
1261
1305
|
}
|
|
1306
|
+
return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
|
|
1307
|
+
} else {
|
|
1308
|
+
return `<SSRNode id="${this.id}" />`;
|
|
1262
1309
|
}
|
|
1263
|
-
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1264
1310
|
}
|
|
1265
1311
|
};
|
|
1266
1312
|
var DomRef = class {
|
|
@@ -1680,7 +1726,7 @@ function vNodeData_openElement(vNodeData) {
|
|
|
1680
1726
|
vNodeData.push([], WRITE_ELEMENT_ATTRS);
|
|
1681
1727
|
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
1682
1728
|
}
|
|
1683
|
-
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
1729
|
+
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
|
|
1684
1730
|
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1685
1731
|
const stack = [-1];
|
|
1686
1732
|
let attributesIndex = -1;
|
|
@@ -1711,7 +1757,14 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1711
1757
|
}
|
|
1712
1758
|
}
|
|
1713
1759
|
}
|
|
1714
|
-
return new SsrNode(
|
|
1760
|
+
return new SsrNode(
|
|
1761
|
+
currentComponentNode,
|
|
1762
|
+
refId,
|
|
1763
|
+
attributesIndex,
|
|
1764
|
+
cleanupQueue,
|
|
1765
|
+
vNodeData,
|
|
1766
|
+
currentFile
|
|
1767
|
+
);
|
|
1715
1768
|
}
|
|
1716
1769
|
var ALPHANUMERIC = [];
|
|
1717
1770
|
function encodeAsAlphanumeric(value) {
|
|
@@ -2010,18 +2063,7 @@ var StringBufferWriter = class {
|
|
|
2010
2063
|
var EMPTY_OBJ = {};
|
|
2011
2064
|
var SSRContainer = class extends _SharedContainer {
|
|
2012
2065
|
constructor(opts) {
|
|
2013
|
-
super(
|
|
2014
|
-
() => {
|
|
2015
|
-
try {
|
|
2016
|
-
return this.$scheduler$(255 /* WAIT_FOR_ALL */);
|
|
2017
|
-
} catch (e) {
|
|
2018
|
-
this.handleError(e, null);
|
|
2019
|
-
}
|
|
2020
|
-
},
|
|
2021
|
-
() => null,
|
|
2022
|
-
opts.renderOptions.serverData ?? EMPTY_OBJ,
|
|
2023
|
-
opts.locale
|
|
2024
|
-
);
|
|
2066
|
+
super(() => null, opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
|
|
2025
2067
|
__publicField(this, "tag");
|
|
2026
2068
|
__publicField(this, "isHtml");
|
|
2027
2069
|
__publicField(this, "writer");
|
|
@@ -2046,6 +2088,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2046
2088
|
__publicField(this, "lastNode", null);
|
|
2047
2089
|
__publicField(this, "currentComponentNode", null);
|
|
2048
2090
|
__publicField(this, "styleIds", /* @__PURE__ */ new Set());
|
|
2091
|
+
__publicField(this, "isBackpatchExecutorEmitted", false);
|
|
2092
|
+
__publicField(this, "backpatchMap", /* @__PURE__ */ new Map());
|
|
2049
2093
|
__publicField(this, "currentElementFrame", null);
|
|
2050
2094
|
__publicField(this, "renderTimer");
|
|
2051
2095
|
/**
|
|
@@ -2089,6 +2133,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2089
2133
|
handleError(err, _$host$) {
|
|
2090
2134
|
throw err;
|
|
2091
2135
|
}
|
|
2136
|
+
addBackpatchEntry(ssrNodeId, attrName, serializedValue) {
|
|
2137
|
+
const elementIndex = parseInt(ssrNodeId, 10);
|
|
2138
|
+
const entry = {
|
|
2139
|
+
attrName,
|
|
2140
|
+
value: serializedValue
|
|
2141
|
+
};
|
|
2142
|
+
const entries = this.backpatchMap.get(elementIndex) || [];
|
|
2143
|
+
entries.push(entry);
|
|
2144
|
+
this.backpatchMap.set(elementIndex, entries);
|
|
2145
|
+
}
|
|
2092
2146
|
async render(jsx) {
|
|
2093
2147
|
this.openContainer();
|
|
2094
2148
|
await _walkJSX(this, jsx, {
|
|
@@ -2113,13 +2167,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2113
2167
|
if (ctx != null && mapArray_has(ctx, contextId.id, 0)) {
|
|
2114
2168
|
return mapArray_get(ctx, contextId.id, 0);
|
|
2115
2169
|
}
|
|
2116
|
-
ssrNode = ssrNode.
|
|
2170
|
+
ssrNode = ssrNode.parentComponent;
|
|
2117
2171
|
}
|
|
2118
2172
|
return void 0;
|
|
2119
2173
|
}
|
|
2120
2174
|
getParentHost(host) {
|
|
2121
2175
|
const ssrNode = host;
|
|
2122
|
-
return ssrNode.
|
|
2176
|
+
return ssrNode.parentComponent;
|
|
2123
2177
|
}
|
|
2124
2178
|
setHostProp(host, name, value) {
|
|
2125
2179
|
const ssrNode = host;
|
|
@@ -2173,6 +2227,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2173
2227
|
vNodeData_openElement(this.currentElementFrame.vNodeData);
|
|
2174
2228
|
this.write("<");
|
|
2175
2229
|
this.write(elementName);
|
|
2230
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2176
2231
|
if (varAttrs) {
|
|
2177
2232
|
innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
|
|
2178
2233
|
}
|
|
@@ -2182,7 +2237,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2182
2237
|
innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
|
|
2183
2238
|
}
|
|
2184
2239
|
this.write(">");
|
|
2185
|
-
|
|
2240
|
+
if (lastNode) {
|
|
2241
|
+
lastNode.setTreeNonUpdatable();
|
|
2242
|
+
}
|
|
2186
2243
|
return innerHTML;
|
|
2187
2244
|
}
|
|
2188
2245
|
/** Renders closing tag for DOM element */
|
|
@@ -2245,6 +2302,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2245
2302
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
2246
2303
|
closeFragment() {
|
|
2247
2304
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
2305
|
+
if (this.currentComponentNode) {
|
|
2306
|
+
this.currentComponentNode.setTreeNonUpdatable();
|
|
2307
|
+
}
|
|
2248
2308
|
this.lastNode = null;
|
|
2249
2309
|
}
|
|
2250
2310
|
openProjection(attrs) {
|
|
@@ -2289,7 +2349,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2289
2349
|
const componentFrame = this.componentStack.pop();
|
|
2290
2350
|
componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
|
|
2291
2351
|
this.closeFragment();
|
|
2292
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2352
|
+
this.currentComponentNode = this.currentComponentNode?.parentComponent || null;
|
|
2293
2353
|
}
|
|
2294
2354
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2295
2355
|
textNode(text) {
|
|
@@ -2316,7 +2376,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2316
2376
|
this.currentElementFrame.vNodeData,
|
|
2317
2377
|
// we start at -1, so we need to add +1
|
|
2318
2378
|
this.currentElementFrame.depthFirstElementIdx + 1,
|
|
2319
|
-
this.cleanupQueue
|
|
2379
|
+
this.cleanupQueue,
|
|
2380
|
+
this.currentElementFrame.currentFile
|
|
2320
2381
|
);
|
|
2321
2382
|
}
|
|
2322
2383
|
return this.lastNode;
|
|
@@ -2378,6 +2439,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2378
2439
|
this.emitVNodeData();
|
|
2379
2440
|
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2380
2441
|
this.emitSyncFnsData();
|
|
2442
|
+
this.emitPatchDataIfNeeded();
|
|
2443
|
+
this.emitExecutorIfNeeded();
|
|
2381
2444
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2382
2445
|
})
|
|
2383
2446
|
);
|
|
@@ -2547,6 +2610,38 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2547
2610
|
this.closeElement();
|
|
2548
2611
|
}
|
|
2549
2612
|
}
|
|
2613
|
+
emitPatchDataIfNeeded() {
|
|
2614
|
+
const patches = [];
|
|
2615
|
+
for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
|
|
2616
|
+
for (const backpatchEntry of backpatchEntries) {
|
|
2617
|
+
patches.push(elementIndex, backpatchEntry.attrName, backpatchEntry.value);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
this.backpatchMap.clear();
|
|
2621
|
+
if (patches.length > 0) {
|
|
2622
|
+
this.isBackpatchExecutorEmitted = true;
|
|
2623
|
+
const scriptAttrs = ["type", ELEMENT_BACKPATCH_DATA];
|
|
2624
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2625
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2626
|
+
}
|
|
2627
|
+
this.openElement("script", scriptAttrs);
|
|
2628
|
+
this.write(JSON.stringify(patches));
|
|
2629
|
+
this.closeElement();
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
emitExecutorIfNeeded() {
|
|
2633
|
+
if (!this.isBackpatchExecutorEmitted) {
|
|
2634
|
+
return;
|
|
2635
|
+
}
|
|
2636
|
+
const scriptAttrs = ["type", "text/javascript"];
|
|
2637
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2638
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2639
|
+
}
|
|
2640
|
+
this.openElement("script", scriptAttrs);
|
|
2641
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev5 });
|
|
2642
|
+
this.write(backpatchScript);
|
|
2643
|
+
this.closeElement();
|
|
2644
|
+
}
|
|
2550
2645
|
emitPreloaderPre() {
|
|
2551
2646
|
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2552
2647
|
}
|
|
@@ -2734,7 +2829,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2734
2829
|
parent: this.currentElementFrame,
|
|
2735
2830
|
elementName,
|
|
2736
2831
|
depthFirstElementIdx,
|
|
2737
|
-
vNodeData: [0 /* NONE */]
|
|
2832
|
+
vNodeData: [0 /* NONE */],
|
|
2833
|
+
currentFile: isDev5 ? currentFile || null : null
|
|
2738
2834
|
};
|
|
2739
2835
|
this.currentElementFrame = frame;
|
|
2740
2836
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -2904,6 +3000,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2904
3000
|
});
|
|
2905
3001
|
await setServerPlatform(opts, resolvedManifest);
|
|
2906
3002
|
await ssrContainer.render(jsx);
|
|
3003
|
+
await ssrContainer.$scheduler$(255 /* WAIT_FOR_QUEUE */).$returnValue$;
|
|
2907
3004
|
flush();
|
|
2908
3005
|
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
2909
3006
|
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
@@ -3050,6 +3147,7 @@ async function setServerPlatform2(manifest) {
|
|
|
3050
3147
|
setPlatform2(platform);
|
|
3051
3148
|
}
|
|
3052
3149
|
export {
|
|
3150
|
+
getQwikBackpatchExecutorScript,
|
|
3053
3151
|
getQwikLoaderScript,
|
|
3054
3152
|
getQwikPrefetchWorkerScript,
|
|
3055
3153
|
renderToStream,
|