@qwik.dev/core 2.0.0-beta.19 → 2.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +175 -94
- package/dist/core.min.mjs +2 -1
- package/dist/core.mjs +969 -935
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +620 -666
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +841 -842
- package/dist/qwikloader.debug.js +144 -144
- package/dist/qwikloader.js +1 -1
- package/dist/server.mjs +55 -23
- package/dist/testing/index.d.ts +28 -20
- package/dist/testing/index.mjs +3547 -3572
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
- package/public.d.ts +2 -2
package/dist/qwikloader.debug.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const doc = document;
|
|
2
2
|
const win = window;
|
|
3
|
+
const windowPrefix = "w";
|
|
4
|
+
const documentPrefix = "d";
|
|
3
5
|
const events = /* @__PURE__ */ new Set();
|
|
4
6
|
const roots = /* @__PURE__ */ new Set([doc]);
|
|
5
|
-
const symbols =
|
|
6
|
-
|
|
7
|
-
const documentPrefix = "-document";
|
|
7
|
+
const symbols = /* @__PURE__ */ new Map();
|
|
8
|
+
let observer;
|
|
8
9
|
let hasInitialized;
|
|
9
10
|
const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));
|
|
10
11
|
const querySelectorAll = (query) => {
|
|
@@ -12,19 +13,15 @@ const querySelectorAll = (query) => {
|
|
|
12
13
|
roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));
|
|
13
14
|
return elements;
|
|
14
15
|
};
|
|
16
|
+
const addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });
|
|
15
17
|
const findShadowRoots = (fragment) => {
|
|
16
|
-
|
|
18
|
+
addEventOrRoot(fragment);
|
|
17
19
|
nativeQuerySelectorAll(fragment, "[q\\:shadowroot]").forEach((parent) => {
|
|
18
20
|
const shadowRoot = parent.shadowRoot;
|
|
19
21
|
shadowRoot && findShadowRoots(shadowRoot);
|
|
20
22
|
});
|
|
21
23
|
};
|
|
22
24
|
const isPromise = (promise) => promise && typeof promise.then === "function";
|
|
23
|
-
const broadcast = (infix, ev, type = ev.type) => {
|
|
24
|
-
querySelectorAll("[on" + infix + "\\:" + type + "]").forEach((el) => {
|
|
25
|
-
dispatch(el, infix, ev, type);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
25
|
const resolveContainer = (containerEl) => {
|
|
29
26
|
if (containerEl._qwikjson_ === void 0) {
|
|
30
27
|
const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;
|
|
@@ -40,91 +37,88 @@ const resolveContainer = (containerEl) => {
|
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
39
|
};
|
|
43
|
-
const createEvent = (eventName, detail) => new CustomEvent(eventName, {
|
|
44
|
-
|
|
40
|
+
const createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });
|
|
41
|
+
const emitEvent = (eventName, detail) => {
|
|
42
|
+
doc.dispatchEvent(createEvent(eventName, detail));
|
|
43
|
+
};
|
|
44
|
+
const camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());
|
|
45
|
+
const kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());
|
|
46
|
+
const parseKebabEvent = (event) => ({
|
|
47
|
+
scope: event.charAt(0),
|
|
48
|
+
eventName: kebabToCamel(event.slice(2))
|
|
45
49
|
});
|
|
46
|
-
const dispatch = async (element,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const dispatch = async (element, ev, scopedKebabName, kebabName) => {
|
|
51
|
+
if (kebabName) {
|
|
52
|
+
if (element.hasAttribute("preventdefault:" + kebabName)) {
|
|
53
|
+
ev.preventDefault();
|
|
54
|
+
}
|
|
55
|
+
if (element.hasAttribute("stoppropagation:" + kebabName)) {
|
|
56
|
+
ev.stopPropagation();
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
if (cancelBubble) {
|
|
64
|
-
ev.stopPropagation();
|
|
59
|
+
const handlers = element._qDispatch?.[scopedKebabName];
|
|
60
|
+
if (handlers) {
|
|
61
|
+
if (handlers.length) {
|
|
62
|
+
for (const handler of handlers) {
|
|
63
|
+
const result = handler?.(ev, element);
|
|
64
|
+
if (isPromise(result)) {
|
|
65
|
+
await result;
|
|
66
|
+
}
|
|
65
67
|
}
|
|
68
|
+
} else {
|
|
69
|
+
await handlers(ev, element);
|
|
66
70
|
}
|
|
67
71
|
return;
|
|
68
72
|
}
|
|
69
|
-
const
|
|
70
|
-
if (qDispatchEvent) {
|
|
71
|
-
return qDispatchEvent(ev, scope);
|
|
72
|
-
}
|
|
73
|
-
const attrValue = element.getAttribute(attrName);
|
|
73
|
+
const attrValue = element.getAttribute("q-" + scopedKebabName);
|
|
74
74
|
if (attrValue) {
|
|
75
75
|
const container = element.closest(
|
|
76
76
|
"[q\\:container]:not([q\\:container=html]):not([q\\:container=text])"
|
|
77
77
|
);
|
|
78
78
|
const qBase = container.getAttribute("q:base");
|
|
79
|
-
const qVersion = container.getAttribute("q:version") || "unknown";
|
|
80
|
-
const qManifest = container.getAttribute("q:manifest-hash") || "dev";
|
|
81
79
|
const base = new URL(qBase, doc.baseURI);
|
|
82
|
-
for (const qrl of attrValue.split("
|
|
83
|
-
const url = new URL(qrl, base);
|
|
84
|
-
const href = url.href;
|
|
85
|
-
const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";
|
|
80
|
+
for (const qrl of attrValue.split("|")) {
|
|
86
81
|
const reqTime = performance.now();
|
|
87
|
-
|
|
88
|
-
let importError;
|
|
89
|
-
let error;
|
|
90
|
-
const isSync = qrl.startsWith("#");
|
|
82
|
+
const [chunk, symbol, capturedIds] = qrl.split("#");
|
|
91
83
|
const eventData = {
|
|
92
84
|
qBase,
|
|
93
|
-
qManifest,
|
|
94
|
-
qVersion,
|
|
95
|
-
href,
|
|
96
85
|
symbol,
|
|
97
86
|
element,
|
|
98
87
|
reqTime
|
|
99
88
|
};
|
|
100
|
-
|
|
89
|
+
let handler;
|
|
90
|
+
let importError;
|
|
91
|
+
let error;
|
|
92
|
+
if (chunk === "") {
|
|
101
93
|
const hash = container.getAttribute("q:instance");
|
|
102
94
|
handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];
|
|
103
95
|
if (!handler) {
|
|
104
96
|
importError = "sync";
|
|
105
97
|
error = new Error("sym:" + symbol);
|
|
106
98
|
}
|
|
107
|
-
} else if (symbol in symbols) {
|
|
108
|
-
handler = symbols[symbol];
|
|
109
99
|
} else {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
100
|
+
const key = `${symbol}|${qBase}|${chunk}`;
|
|
101
|
+
handler = symbols.get(key);
|
|
102
|
+
if (!handler) {
|
|
103
|
+
const href = new URL(chunk, base).href;
|
|
104
|
+
try {
|
|
105
|
+
const module = import(
|
|
106
|
+
/* @vite-ignore */
|
|
107
|
+
href
|
|
108
|
+
);
|
|
109
|
+
resolveContainer(container);
|
|
110
|
+
handler = (await module)[symbol];
|
|
111
|
+
if (!handler) {
|
|
112
|
+
importError = "no-symbol";
|
|
113
|
+
error = new Error(`${symbol} not in ${href}`);
|
|
114
|
+
} else {
|
|
115
|
+
symbols.set(key, handler);
|
|
116
|
+
emitEvent("qsymbol", eventData);
|
|
117
|
+
}
|
|
118
|
+
} catch (err) {
|
|
119
|
+
importError = "async";
|
|
120
|
+
error = err;
|
|
124
121
|
}
|
|
125
|
-
} catch (err) {
|
|
126
|
-
importError || (importError = "async");
|
|
127
|
-
error = err;
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
124
|
if (!handler) {
|
|
@@ -134,132 +128,138 @@ const dispatch = async (element, scope, ev, eventName = ev.type) => {
|
|
|
134
128
|
...eventData
|
|
135
129
|
});
|
|
136
130
|
console.error(error);
|
|
137
|
-
|
|
131
|
+
continue;
|
|
138
132
|
}
|
|
139
|
-
const previousCtx = doc.__q_context__;
|
|
140
133
|
if (element.isConnected) {
|
|
141
134
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
await results;
|
|
135
|
+
const result = handler.call(capturedIds, ev, element);
|
|
136
|
+
if (isPromise(result)) {
|
|
137
|
+
await result;
|
|
146
138
|
}
|
|
147
139
|
} catch (error2) {
|
|
148
140
|
emitEvent("qerror", { error: error2, ...eventData });
|
|
149
|
-
} finally {
|
|
150
|
-
doc.__q_context__ = previousCtx;
|
|
151
141
|
}
|
|
152
142
|
}
|
|
153
143
|
}
|
|
154
144
|
}
|
|
155
145
|
};
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());
|
|
160
|
-
const processDocumentEvent = async (ev, scope) => {
|
|
161
|
-
let type = camelToKebab(ev.type);
|
|
146
|
+
const processElementEvent = async (ev) => {
|
|
147
|
+
const kebabName = camelToKebab(ev.type);
|
|
148
|
+
const scopedKebabName = "e:" + kebabName;
|
|
162
149
|
let element = ev.target;
|
|
163
|
-
if (scope === documentPrefix) {
|
|
164
|
-
broadcast(documentPrefix, ev, type);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
150
|
while (element && element.getAttribute) {
|
|
168
|
-
const results = dispatch(element,
|
|
169
|
-
|
|
151
|
+
const results = dispatch(element, ev, scopedKebabName, kebabName);
|
|
152
|
+
const doBubble = ev.bubbles && !ev.cancelBubble;
|
|
170
153
|
if (isPromise(results)) {
|
|
171
154
|
await results;
|
|
172
155
|
}
|
|
173
|
-
|
|
174
|
-
element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;
|
|
156
|
+
element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;
|
|
175
157
|
}
|
|
176
158
|
};
|
|
159
|
+
const broadcast = (infix, ev) => {
|
|
160
|
+
const kebabName = camelToKebab(ev.type);
|
|
161
|
+
const scopedKebabName = infix + ":" + kebabName;
|
|
162
|
+
querySelectorAll("[q-" + infix + "\\:" + kebabName + "]").forEach(
|
|
163
|
+
(el) => dispatch(el, ev, scopedKebabName, kebabName)
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
const processDocumentEvent = async (ev) => {
|
|
167
|
+
broadcast(documentPrefix, ev);
|
|
168
|
+
};
|
|
177
169
|
const processWindowEvent = (ev) => {
|
|
178
|
-
broadcast(windowPrefix, ev
|
|
170
|
+
broadcast(windowPrefix, ev);
|
|
179
171
|
};
|
|
180
172
|
const processReadyStateChange = () => {
|
|
181
173
|
const readyState = doc.readyState;
|
|
182
|
-
if (
|
|
183
|
-
roots.forEach(findShadowRoots);
|
|
174
|
+
if (readyState == "interactive" || readyState == "complete") {
|
|
184
175
|
hasInitialized = 1;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
176
|
+
roots.forEach(findShadowRoots);
|
|
177
|
+
if (events.has("d:qinit")) {
|
|
178
|
+
events.delete("d:qinit");
|
|
179
|
+
const ev = createEvent("qinit");
|
|
180
|
+
querySelectorAll("[q-d\\:qinit]").forEach((el) => {
|
|
181
|
+
dispatch(el, ev, "d:qinit");
|
|
182
|
+
el.removeAttribute("q-d:qinit");
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (events.has("d:qidle")) {
|
|
186
|
+
events.delete("d:qidle");
|
|
187
|
+
const riC = win.requestIdleCallback ?? win.setTimeout;
|
|
188
|
+
riC.bind(win)(() => {
|
|
189
|
+
const ev = createEvent("qidle");
|
|
190
|
+
querySelectorAll("[q-d\\:qidle]").forEach((el) => {
|
|
191
|
+
dispatch(el, ev, "d:qidle");
|
|
192
|
+
el.removeAttribute("q-d:qidle");
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
if (events.has("e:qvisible")) {
|
|
197
|
+
observer || (observer = new IntersectionObserver((entries) => {
|
|
191
198
|
for (const entry of entries) {
|
|
192
199
|
if (entry.isIntersecting) {
|
|
193
200
|
observer.unobserve(entry.target);
|
|
194
|
-
dispatch(entry.target,
|
|
201
|
+
dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");
|
|
195
202
|
}
|
|
196
203
|
}
|
|
204
|
+
}));
|
|
205
|
+
querySelectorAll("[q-e\\:qvisible]:not([q\\:observed])").forEach((el) => {
|
|
206
|
+
observer.observe(el);
|
|
207
|
+
el.setAttribute("q:observed", "true");
|
|
197
208
|
});
|
|
198
|
-
results.forEach((el) => observer.observe(el));
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
const addEventListener = (el, eventName, handler, capture = false) => {
|
|
203
|
-
el.addEventListener(eventName, handler, { capture, passive: false });
|
|
204
|
-
};
|
|
205
|
-
const kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());
|
|
206
|
-
const processEventName = (event) => {
|
|
207
|
-
const i = event.indexOf(":");
|
|
208
|
-
let scope = "";
|
|
209
|
-
let eventName = event;
|
|
210
|
-
if (i >= 0) {
|
|
211
|
-
const s = event.substring(0, i);
|
|
212
|
-
if (s === "" || s === windowPrefix || s === documentPrefix) {
|
|
213
|
-
scope = s;
|
|
214
|
-
eventName = event.substring(i + 1);
|
|
215
209
|
}
|
|
216
210
|
}
|
|
217
|
-
return { scope, eventName: kebabToCamel(eventName) };
|
|
218
211
|
};
|
|
219
|
-
const
|
|
220
|
-
for (const
|
|
221
|
-
if (typeof
|
|
222
|
-
if (!events.has(
|
|
223
|
-
events.add(
|
|
224
|
-
const { scope, eventName } =
|
|
212
|
+
const addEventOrRoot = (...eventNames) => {
|
|
213
|
+
for (const eventNameOrRoot of eventNames) {
|
|
214
|
+
if (typeof eventNameOrRoot === "string") {
|
|
215
|
+
if (!events.has(eventNameOrRoot)) {
|
|
216
|
+
events.add(eventNameOrRoot);
|
|
217
|
+
const { scope, eventName } = parseKebabEvent(eventNameOrRoot);
|
|
225
218
|
if (scope === windowPrefix) {
|
|
226
219
|
addEventListener(win, eventName, processWindowEvent, true);
|
|
227
220
|
} else {
|
|
228
221
|
roots.forEach(
|
|
229
|
-
(root) => addEventListener(
|
|
222
|
+
(root) => addEventListener(
|
|
223
|
+
root,
|
|
224
|
+
eventName,
|
|
225
|
+
scope === documentPrefix ? processDocumentEvent : processElementEvent,
|
|
226
|
+
true
|
|
227
|
+
)
|
|
230
228
|
);
|
|
231
229
|
}
|
|
230
|
+
if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {
|
|
231
|
+
processReadyStateChange();
|
|
232
|
+
}
|
|
232
233
|
}
|
|
233
234
|
} else {
|
|
234
|
-
if (!roots.has(
|
|
235
|
+
if (!roots.has(eventNameOrRoot)) {
|
|
235
236
|
events.forEach((kebabEventName) => {
|
|
236
|
-
const { scope, eventName } =
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
const { scope, eventName } = parseKebabEvent(kebabEventName);
|
|
238
|
+
if (scope !== windowPrefix) {
|
|
239
|
+
addEventListener(
|
|
240
|
+
eventNameOrRoot,
|
|
241
|
+
eventName,
|
|
242
|
+
scope === documentPrefix ? processDocumentEvent : processElementEvent,
|
|
243
|
+
true
|
|
244
|
+
);
|
|
245
|
+
}
|
|
243
246
|
});
|
|
244
|
-
roots.add(
|
|
247
|
+
roots.add(eventNameOrRoot);
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
250
|
}
|
|
248
251
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
} else {
|
|
256
|
-
processEventOrNode(":click", ":input");
|
|
257
|
-
}
|
|
252
|
+
const _qwikEv = win._qwikEv;
|
|
253
|
+
if (!_qwikEv?.roots) {
|
|
254
|
+
if (Array.isArray(_qwikEv)) {
|
|
255
|
+
addEventOrRoot(..._qwikEv);
|
|
256
|
+
} else {
|
|
257
|
+
addEventOrRoot("e:click", "e:input");
|
|
258
258
|
}
|
|
259
|
-
win.
|
|
259
|
+
win._qwikEv = {
|
|
260
260
|
events,
|
|
261
261
|
roots,
|
|
262
|
-
push:
|
|
262
|
+
push: addEventOrRoot
|
|
263
263
|
};
|
|
264
264
|
addEventListener(doc, "readystatechange", processReadyStateChange);
|
|
265
265
|
processReadyStateChange();
|
package/dist/qwikloader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e=document,t=window,o="w",r="d",n=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(o=>t.push(...l(o,e))),t},d=(e,t,o,r=!1)=>e.addEventListener(t,o,{capture:r,passive:!1}),b=e=>{_(e),l(e,"[q\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\x3C(\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,r,n)=>{n&&(t.hasAttribute("preventdefault:"+n)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+n)&&o.stopPropagation());const s=t._qDispatch?.[r];if(s){if(s.length)for(const e of s){const r=e?.(o,t);f(r)&&await r}else await s(o,t);return}const a=t.getAttribute("q-"+r);if(a){const r=t.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])"),n=r.getAttribute("q:base"),s=new URL(n,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:n,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=r.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${n}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(r),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},E=async e=>{const t=m(e.type),o="e:"+t;let r=e.target;for(;r&&r.getAttribute;){const n=y(r,e,o,t),s=e.bubbles&&!e.cancelBubble;f(n)&&await n,r=s&&e.bubbles&&!e.cancelBubble?r.parentElement:null}},g=(e,t)=>{const o=m(t.type),r=e+":"+o;q("[q-"+e+"\\:"+o+"]").forEach(e=>y(e,t,r,o))},A=async e=>{g(r,e)},C=e=>{g(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),n.has("d:qinit")){n.delete("d:qinit");const e=u("qinit");q("[q-d\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}n.has("d:qidle")&&(n.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),n.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\:qvisible]:not([q\\:observed])").forEach(e=>{a.observe(e),e.setAttribute("q:observed","true")}))}},_=(...e)=>{for(const i of e)if("string"==typeof i){if(!n.has(i)){n.add(i);const{scope:e,eventName:a}=w(i);e===o?d(t,a,C,!0):s.forEach(t=>d(t,a,e===r?A:E,!0)),1!==c||"e:qvisible"!==i&&"d:qinit"!==i&&"d:qidle"!==i||k()}}else s.has(i)||(n.forEach(e=>{const{scope:t,eventName:n}=w(e);t!==o&&d(i,n,t===r?A:E,!0)}),s.add(i))},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:n,roots:s,push:_},d(e,"readystatechange",k),k());
|
package/dist/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.21-dev+c008e88
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -622,26 +622,54 @@ var isPromise = (value) => {
|
|
|
622
622
|
var maybeThen = (valueOrPromise, thenFn) => {
|
|
623
623
|
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
624
624
|
};
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
if (
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
625
|
+
var checkError = (e) => {
|
|
626
|
+
if (isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
627
|
+
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
var justThrow = (e) => {
|
|
631
|
+
throw e;
|
|
632
|
+
};
|
|
633
|
+
function retryOnPromise(fn, onError = justThrow) {
|
|
634
|
+
let ok = false;
|
|
635
|
+
let result;
|
|
632
636
|
try {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
return result.catch((e) => retryOrThrow(e));
|
|
636
|
-
}
|
|
637
|
-
return result;
|
|
637
|
+
result = fn();
|
|
638
|
+
ok = true;
|
|
638
639
|
} catch (e) {
|
|
639
|
-
|
|
640
|
-
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
641
|
-
throw e;
|
|
642
|
-
}
|
|
643
|
-
return retryOrThrow(e);
|
|
640
|
+
result = e;
|
|
644
641
|
}
|
|
642
|
+
if (!isPromise(result)) {
|
|
643
|
+
if (ok) {
|
|
644
|
+
return result;
|
|
645
|
+
}
|
|
646
|
+
isDev3 && checkError(result);
|
|
647
|
+
return onError(result);
|
|
648
|
+
}
|
|
649
|
+
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
650
|
+
const retry = async (p) => {
|
|
651
|
+
while (isPromise(p)) {
|
|
652
|
+
try {
|
|
653
|
+
await p;
|
|
654
|
+
return await fn();
|
|
655
|
+
} catch (err) {
|
|
656
|
+
if (isPromise(err)) {
|
|
657
|
+
if (!--retryCount) {
|
|
658
|
+
p = new Error("Exceeded max retry count in retryOnPromise");
|
|
659
|
+
break;
|
|
660
|
+
} else {
|
|
661
|
+
p = err;
|
|
662
|
+
}
|
|
663
|
+
} else {
|
|
664
|
+
p = err;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
isDev3 && checkError(p);
|
|
670
|
+
return onError(p);
|
|
671
|
+
};
|
|
672
|
+
return ok ? result.catch(retry) : retry(result);
|
|
645
673
|
}
|
|
646
674
|
|
|
647
675
|
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
@@ -1174,7 +1202,7 @@ function getBuildBase(opts) {
|
|
|
1174
1202
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1175
1203
|
}
|
|
1176
1204
|
var versions = {
|
|
1177
|
-
qwik: "2.0.0-beta.
|
|
1205
|
+
qwik: "2.0.0-beta.21-dev+c008e88",
|
|
1178
1206
|
qwikDom: "2.1.19"
|
|
1179
1207
|
};
|
|
1180
1208
|
|
|
@@ -1432,8 +1460,8 @@ var preLoaderOptionsDefault = {
|
|
|
1432
1460
|
};
|
|
1433
1461
|
|
|
1434
1462
|
// packages/qwik/src/server/scripts.ts
|
|
1435
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = 'const
|
|
1436
|
-
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols =
|
|
1463
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",r="d",n=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(o=>t.push(...l(o,e))),t},d=(e,t,o,r=!1)=>e.addEventListener(t,o,{capture:r,passive:!1}),b=e=>{_(e),l(e,"[q\\\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,r,n)=>{n&&(t.hasAttribute("preventdefault:"+n)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+n)&&o.stopPropagation());const s=t._qDispatch?.[r];if(s){if(s.length)for(const e of s){const r=e?.(o,t);f(r)&&await r}else await s(o,t);return}const a=t.getAttribute("q-"+r);if(a){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),n=r.getAttribute("q:base"),s=new URL(n,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:n,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=r.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${n}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(r),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},E=async e=>{const t=m(e.type),o="e:"+t;let r=e.target;for(;r&&r.getAttribute;){const n=y(r,e,o,t),s=e.bubbles&&!e.cancelBubble;f(n)&&await n,r=s&&e.bubbles&&!e.cancelBubble?r.parentElement:null}},g=(e,t)=>{const o=m(t.type),r=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,r,o))},A=async e=>{g(r,e)},C=e=>{g(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),n.has("d:qinit")){n.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}n.has("d:qidle")&&(n.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),n.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach(e=>{a.observe(e),e.setAttribute("q:observed","true")}))}},_=(...e)=>{for(const i of e)if("string"==typeof i){if(!n.has(i)){n.add(i);const{scope:e,eventName:a}=w(i);e===o?d(t,a,C,!0):s.forEach(t=>d(t,a,e===r?A:E,!0)),1!==c||"e:qvisible"!==i&&"d:qinit"!==i&&"d:qidle"!==i||k()}}else s.has(i)||(n.forEach(e=>{const{scope:t,eventName:n}=w(e);t!==o&&d(i,n,t===r?A:E,!0)}),s.add(i))},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:n,roots:s,push:_},d(e,"readystatechange",k),k())';
|
|
1464
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (handlers.length) {\n for (const handler of handlers) {\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n } else {\n await handlers(ev, element);\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("|")) {\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]").forEach(\n (el) => dispatch(el, ev, scopedKebabName, kebabName)\n );\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n querySelectorAll("[q-d\\\\:qinit]").forEach((el) => {\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n });\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n querySelectorAll("[q-d\\\\:qidle]").forEach((el) => {\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n });\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\n }));\n querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach((el) => {\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n });\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (const eventNameOrRoot of eventNames) {\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1437
1465
|
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]',e=document.currentScript;if(e){const o=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const e=o.querySelector(t);if(e){const t=JSON.parse(e.textContent||"[]"),n=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let r=n.currentNode,c=r.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let s=t[e+2];for(;c<o&&(r=n.nextNode(),r);)r.hasAttribute(":")&&c++;const l=r;null==s||!1===s?l.removeAttribute(i):("boolean"==typeof s&&(s=""),l.setAttribute(i,s))}}}}`;
|
|
1438
1466
|
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1439
1467
|
const executorScript = document.currentScript;
|
|
@@ -2722,7 +2750,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2722
2750
|
const patches = [];
|
|
2723
2751
|
for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
|
|
2724
2752
|
for (const backpatchEntry of backpatchEntries) {
|
|
2725
|
-
patches.push(
|
|
2753
|
+
patches.push(
|
|
2754
|
+
elementIndex,
|
|
2755
|
+
backpatchEntry.attrName,
|
|
2756
|
+
isSignal(backpatchEntry.value) ? backpatchEntry.value.untrackedValue : backpatchEntry.value
|
|
2757
|
+
);
|
|
2726
2758
|
}
|
|
2727
2759
|
}
|
|
2728
2760
|
this.backpatchMap.clear();
|
|
@@ -2802,7 +2834,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2802
2834
|
scriptAttrs.push("nonce", nonce);
|
|
2803
2835
|
}
|
|
2804
2836
|
this.openElement("script", null, scriptAttrs);
|
|
2805
|
-
this.write(`(window.
|
|
2837
|
+
this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
|
|
2806
2838
|
this.writeArray(eventNames, ", ");
|
|
2807
2839
|
this.write(")");
|
|
2808
2840
|
this.closeElement();
|