@qwik.dev/core 2.0.0-beta.39 → 2.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backpatch/index.mjs +2 -2
- package/dist/backpatch/package.json +1 -1
- package/dist/backpatch-executor.debug.js +55 -42
- package/dist/backpatch-executor.js +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +1 -1
- package/dist/core.min.mjs +6 -6
- package/dist/core.mjs +2 -2
- package/dist/core.prod.mjs +152 -152
- package/dist/insights/index.qwik.mjs +81 -93
- package/dist/insights/vite/index.mjs +79 -84
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +19 -3
- package/dist/optimizer.mjs +2992 -3624
- package/dist/out-of-order-executor.debug.js +138 -161
- package/dist/out-of-order-executor.js +1 -1
- package/dist/preloader.mjs +178 -1
- package/dist/qwikloader.debug.js +384 -433
- package/dist/qwikloader.js +1 -1
- package/dist/server.mjs +10 -216
- package/dist/server.prod.mjs +1046 -1046
- package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/vite.config.ts +1 -1
- package/dist/starters/adapters/azure-swa/adapters/azure-swa/vite.config.ts +1 -1
- package/dist/starters/adapters/bun/adapters/bun/vite.config.ts +1 -1
- package/dist/starters/adapters/cloud-run/adapters/cloud-run/vite.config.ts +1 -1
- package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/vite.config.ts +1 -1
- package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +1 -1
- package/dist/starters/adapters/deno/adapters/deno/vite.config.ts +1 -1
- package/dist/starters/adapters/express/adapters/express/vite.config.ts +1 -1
- package/dist/starters/adapters/fastify/adapters/fastify/vite.config.ts +1 -1
- package/dist/starters/adapters/firebase/adapters/firebase/vite.config.ts +1 -1
- package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/vite.config.ts +1 -1
- package/dist/starters/adapters/node-server/adapters/node-server/vite.config.ts +1 -1
- package/dist/starters/adapters/ssg/adapters/ssg/vite.config.ts +1 -1
- package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/vite.config.ts +1 -1
- package/dist/starters/features/csr/package.json +1 -1
- package/dist/testing/index.mjs +3 -2
- package/dist/testing/package.json +1 -1
- package/dist/worker/index.mjs +248 -315
- package/dist/worker/package.json +1 -1
- package/package.json +5 -5
package/dist/qwikloader.debug.js
CHANGED
|
@@ -1,454 +1,405 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
//#region packages/qwik/src/qwikloader.ts
|
|
2
|
+
var doc = document;
|
|
3
|
+
var win = window;
|
|
4
|
+
var windowPrefix = "w";
|
|
5
|
+
var passiveWindowPrefix = "wp";
|
|
6
|
+
var documentPrefix = "d";
|
|
7
|
+
var passiveDocumentPrefix = "dp";
|
|
8
|
+
var elementPrefix = "e";
|
|
9
|
+
var passiveElementPrefix = "ep";
|
|
10
|
+
var capturePrefix = "capture:";
|
|
11
|
+
var readyStateChange = "readystatechange";
|
|
12
|
+
var QwikEvContainerReady = 0;
|
|
13
|
+
var events = /* @__PURE__ */ new Set();
|
|
14
|
+
var roots = /* @__PURE__ */ new Set([doc]);
|
|
15
|
+
var symbols = /* @__PURE__ */ new Map();
|
|
16
|
+
var readyContainers = {};
|
|
17
|
+
var observer;
|
|
18
|
+
var hasInitialized;
|
|
19
|
+
var queuedTasks;
|
|
20
|
+
var nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));
|
|
21
|
+
var querySelectorAll = (query) => {
|
|
22
|
+
const elements = [];
|
|
23
|
+
roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));
|
|
24
|
+
return elements;
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
var addEventListener = (el, eventName, handler, capture = false, passive = false) => el.addEventListener(eventName, handler, {
|
|
27
|
+
capture,
|
|
28
|
+
passive
|
|
29
|
+
});
|
|
30
|
+
var findShadowRoots = (fragment) => {
|
|
31
|
+
addEventOrRoot(fragment);
|
|
32
|
+
const shadowRoots = nativeQuerySelectorAll(fragment, "[q\\:shadowroot]");
|
|
33
|
+
for (let i = 0; i < shadowRoots.length; i++) {
|
|
34
|
+
const shadowRoot = shadowRoots[i].shadowRoot;
|
|
35
|
+
shadowRoot && findShadowRoots(shadowRoot);
|
|
36
|
+
}
|
|
34
37
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await tasks[i]();
|
|
39
|
-
}
|
|
38
|
+
var isPromise = (promise) => promise && typeof promise.then === "function";
|
|
39
|
+
var runTasks = async (tasks) => {
|
|
40
|
+
for (let i = 0; i < tasks.length; i++) await tasks[i]();
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
var queueTasks = (tasks) => {
|
|
43
|
+
if (tasks.length) {
|
|
44
|
+
const run = () => runTasks(tasks);
|
|
45
|
+
queuedTasks = queuedTasks ? queuedTasks.then(run, run) : run();
|
|
46
|
+
}
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
script = script.previousElementSibling;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
48
|
+
var resolveContainer = (containerEl) => {
|
|
49
|
+
if (containerEl._qwikjson_ === void 0) {
|
|
50
|
+
let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;
|
|
51
|
+
while (script) {
|
|
52
|
+
if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {
|
|
53
|
+
containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\x3C(\/?script)/gi, "<$1"));
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
script = script.previousElementSibling;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
61
59
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
var markContainerReady = (hash) => {
|
|
61
|
+
readyContainers[hash] = 1;
|
|
62
|
+
emitEvent(readyStateChange);
|
|
65
63
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
addEventListener(doc, readyStateChange, ready);
|
|
75
|
-
});
|
|
64
|
+
var waitForContainerReady = (container) => {
|
|
65
|
+
const hash = container.getAttribute("q:instance");
|
|
66
|
+
return container.getAttribute("q:container") === "paused" && doc.readyState === "loading" && !readyContainers[hash] && new Promise((resolve) => {
|
|
67
|
+
const ready = () => {
|
|
68
|
+
if (doc.readyState !== "loading" || readyContainers[hash]) resolve();
|
|
69
|
+
};
|
|
70
|
+
addEventListener(doc, readyStateChange, ready);
|
|
71
|
+
});
|
|
76
72
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
var createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });
|
|
74
|
+
var emitEvent = (eventName, detail) => {
|
|
75
|
+
doc.dispatchEvent(createEvent(eventName, detail));
|
|
80
76
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
77
|
+
var camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());
|
|
78
|
+
var kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());
|
|
79
|
+
var parseKebabEvent = (event) => {
|
|
80
|
+
const separatorIndex = event.indexOf(":");
|
|
81
|
+
return {
|
|
82
|
+
scope: event.slice(0, separatorIndex),
|
|
83
|
+
eventName: kebabToCamel(event.slice(separatorIndex + 1))
|
|
84
|
+
};
|
|
90
85
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
...eventData
|
|
148
|
-
});
|
|
149
|
-
console.error(error);
|
|
150
|
-
return void 0;
|
|
151
|
-
}
|
|
152
|
-
);
|
|
86
|
+
var isPassiveScope = (scope) => scope.length === 2;
|
|
87
|
+
var getRootScope = (scope) => scope.charAt(0);
|
|
88
|
+
var isElementNode = (node) => !!node && node.nodeType === 1;
|
|
89
|
+
var isCaptureHandlerElement = (element, scopedKebabName, captureAttribute) => element.hasAttribute(captureAttribute) && (!!element._qDispatch?.[scopedKebabName] || element.hasAttribute("q-" + scopedKebabName));
|
|
90
|
+
var resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime, reportSyncError = true) => {
|
|
91
|
+
const eventData = {
|
|
92
|
+
qBase,
|
|
93
|
+
symbol,
|
|
94
|
+
element,
|
|
95
|
+
reqTime
|
|
96
|
+
};
|
|
97
|
+
if (!chunk) {
|
|
98
|
+
const handler = (doc["qFuncs_" + container.getAttribute("q:instance")] || [])[+symbol];
|
|
99
|
+
if (!handler && reportSyncError) {
|
|
100
|
+
const error = /* @__PURE__ */ new Error("sym:" + symbol);
|
|
101
|
+
emitEvent("qerror", {
|
|
102
|
+
importError: "sync",
|
|
103
|
+
error,
|
|
104
|
+
...eventData
|
|
105
|
+
});
|
|
106
|
+
console.error(error);
|
|
107
|
+
}
|
|
108
|
+
return handler;
|
|
109
|
+
}
|
|
110
|
+
const key = `${symbol}|${qBase}|${chunk}`;
|
|
111
|
+
const handler = symbols.get(key);
|
|
112
|
+
if (handler) return handler;
|
|
113
|
+
const href = new URL(chunk, base).href;
|
|
114
|
+
const module = import(
|
|
115
|
+
/* @vite-ignore */
|
|
116
|
+
href
|
|
117
|
+
);
|
|
118
|
+
resolveContainer(container);
|
|
119
|
+
return module.then((module) => {
|
|
120
|
+
const handler = module[symbol];
|
|
121
|
+
if (!handler) {
|
|
122
|
+
const error = /* @__PURE__ */ new Error(`${symbol} not in ${href}`);
|
|
123
|
+
emitEvent("qerror", {
|
|
124
|
+
importError: "no-symbol",
|
|
125
|
+
error,
|
|
126
|
+
...eventData
|
|
127
|
+
});
|
|
128
|
+
console.error(error);
|
|
129
|
+
} else {
|
|
130
|
+
symbols.set(key, handler);
|
|
131
|
+
emitEvent("qsymbol", eventData);
|
|
132
|
+
}
|
|
133
|
+
return handler;
|
|
134
|
+
}, (error) => {
|
|
135
|
+
emitEvent("qerror", {
|
|
136
|
+
importError: "async",
|
|
137
|
+
error,
|
|
138
|
+
...eventData
|
|
139
|
+
});
|
|
140
|
+
console.error(error);
|
|
141
|
+
});
|
|
153
142
|
};
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
tasks.push(async () => {
|
|
254
|
-
await run(handler || await resolve());
|
|
255
|
-
});
|
|
256
|
-
} else {
|
|
257
|
-
const result = run(handler);
|
|
258
|
-
if (isPromise(result)) {
|
|
259
|
-
defer = true;
|
|
260
|
-
tasks.push(() => result);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
143
|
+
/**
|
|
144
|
+
* Dispatch an event by invoking QRL handlers. If there are multiple handlers, they are awaited in
|
|
145
|
+
* order.
|
|
146
|
+
*/
|
|
147
|
+
var dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDefault = true) => {
|
|
148
|
+
let defer = false;
|
|
149
|
+
if (kebabName) {
|
|
150
|
+
if (allowPreventDefault && element.hasAttribute("preventdefault:" + kebabName)) ev.preventDefault();
|
|
151
|
+
if (element.hasAttribute("stoppropagation:" + kebabName)) ev.stopPropagation();
|
|
152
|
+
}
|
|
153
|
+
const handlers = element._qDispatch?.[scopedKebabName];
|
|
154
|
+
if (handlers) {
|
|
155
|
+
if (typeof handlers === "function") {
|
|
156
|
+
const run = () => handlers(ev, element);
|
|
157
|
+
if (defer) tasks.push(async () => {
|
|
158
|
+
const result = run();
|
|
159
|
+
if (isPromise(result)) await result;
|
|
160
|
+
});
|
|
161
|
+
else {
|
|
162
|
+
const result = run();
|
|
163
|
+
if (isPromise(result)) {
|
|
164
|
+
defer = true;
|
|
165
|
+
tasks.push(() => result);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} else if (handlers.length) for (let i = 0; i < handlers.length; i++) {
|
|
169
|
+
const handler = handlers[i];
|
|
170
|
+
if (handler) {
|
|
171
|
+
const run = () => handler(ev, element);
|
|
172
|
+
if (defer) tasks.push(async () => {
|
|
173
|
+
const result = run();
|
|
174
|
+
if (isPromise(result)) await result;
|
|
175
|
+
});
|
|
176
|
+
else {
|
|
177
|
+
const result = run();
|
|
178
|
+
if (isPromise(result)) {
|
|
179
|
+
defer = true;
|
|
180
|
+
tasks.push(() => result);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const attrValue = element.getAttribute("q-" + scopedKebabName);
|
|
188
|
+
if (attrValue) {
|
|
189
|
+
const container = element.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])");
|
|
190
|
+
const qBase = container.getAttribute("q:base");
|
|
191
|
+
const base = new URL(qBase, doc.baseURI);
|
|
192
|
+
const qrls = attrValue.split("|");
|
|
193
|
+
const waitForReady = waitForContainerReady(container);
|
|
194
|
+
for (let i = 0; i < qrls.length; i++) {
|
|
195
|
+
const qrl = qrls[i];
|
|
196
|
+
const reqTime = performance.now();
|
|
197
|
+
const [chunk, symbol, capturedIds] = qrl.split("#");
|
|
198
|
+
const run = (handler) => {
|
|
199
|
+
if (handler && element.isConnected) {
|
|
200
|
+
const onError = (error) => {
|
|
201
|
+
emitEvent("qerror", {
|
|
202
|
+
error,
|
|
203
|
+
qBase,
|
|
204
|
+
symbol,
|
|
205
|
+
element,
|
|
206
|
+
reqTime
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
try {
|
|
210
|
+
const result = handler.call(capturedIds, ev, element);
|
|
211
|
+
if (isPromise(result)) return result.catch(onError);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
return onError(error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const resolve = (reportSyncError = true) => resolveHandler(container, element, qBase, base, chunk, symbol, reqTime, reportSyncError);
|
|
218
|
+
const handler = waitForReady ? void 0 : resolve();
|
|
219
|
+
if (waitForReady) {
|
|
220
|
+
defer = true;
|
|
221
|
+
tasks.push(async () => {
|
|
222
|
+
await waitForReady;
|
|
223
|
+
await run(await resolve(false) || await resolve());
|
|
224
|
+
});
|
|
225
|
+
} else if (isPromise(handler)) {
|
|
226
|
+
defer = true;
|
|
227
|
+
tasks.push(() => handler.then(run));
|
|
228
|
+
} else if (defer) {
|
|
229
|
+
defer = true;
|
|
230
|
+
tasks.push(async () => {
|
|
231
|
+
await run(handler || await resolve());
|
|
232
|
+
});
|
|
233
|
+
} else {
|
|
234
|
+
const result = run(handler);
|
|
235
|
+
if (isPromise(result)) {
|
|
236
|
+
defer = true;
|
|
237
|
+
tasks.push(() => result);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
265
242
|
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Event handler responsible for processing element events.
|
|
245
|
+
*
|
|
246
|
+
* If browser emits an event, the `eventProcessor` walks the DOM tree looking for corresponding
|
|
247
|
+
* `(${event.type})`. If found the event's URL is parsed and `import()`ed.
|
|
248
|
+
*
|
|
249
|
+
* @param ev - Browser event.
|
|
250
|
+
*/
|
|
251
|
+
var processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = true) => {
|
|
252
|
+
const kebabName = camelToKebab(ev.type);
|
|
253
|
+
const scopedKebabName = scope + ":" + kebabName;
|
|
254
|
+
const captureAttribute = capturePrefix + kebabName;
|
|
255
|
+
const elements = [];
|
|
256
|
+
const captureHandlers = [];
|
|
257
|
+
const tasks = [];
|
|
258
|
+
let current = ev.target;
|
|
259
|
+
while (current) if (isElementNode(current)) {
|
|
260
|
+
elements.push(current);
|
|
261
|
+
captureHandlers.push(isCaptureHandlerElement(current, scopedKebabName, captureAttribute));
|
|
262
|
+
current = current.parentElement;
|
|
263
|
+
} else current = current.parentElement;
|
|
264
|
+
for (let i = elements.length - 1; i >= 0; i--) if (captureHandlers[i]) {
|
|
265
|
+
dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);
|
|
266
|
+
if (ev.cancelBubble) {
|
|
267
|
+
queueTasks(tasks);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
for (let i = 0; i < elements.length; i++) if (!captureHandlers[i]) {
|
|
272
|
+
dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);
|
|
273
|
+
if (!ev.bubbles || ev.cancelBubble) {
|
|
274
|
+
queueTasks(tasks);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
queueTasks(tasks);
|
|
302
279
|
};
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
280
|
+
var processPassiveElementEvent = (ev) => processElementEvent(ev, passiveElementPrefix, false);
|
|
281
|
+
var broadcast = (scope, ev, allowPreventDefault = true) => {
|
|
282
|
+
const kebabName = camelToKebab(ev.type);
|
|
283
|
+
const scopedKebabName = scope + ":" + kebabName;
|
|
284
|
+
const elements = querySelectorAll("[q-" + CSS.escape(scopedKebabName) + "]");
|
|
285
|
+
const tasks = [];
|
|
286
|
+
for (let i = 0; i < elements.length; i++) {
|
|
287
|
+
const el = elements[i];
|
|
288
|
+
dispatch(el, ev, scopedKebabName, tasks, kebabName, allowPreventDefault);
|
|
289
|
+
}
|
|
290
|
+
queueTasks(tasks);
|
|
314
291
|
};
|
|
315
|
-
|
|
316
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Event handler responsible for processing browser events.
|
|
294
|
+
*
|
|
295
|
+
* If browser emits an event, the `eventProcessor` walks the DOM tree looking for corresponding
|
|
296
|
+
* `(${event.type})`. If found the event's URL is parsed and `import()`ed.
|
|
297
|
+
*
|
|
298
|
+
* @param ev - Browser event.
|
|
299
|
+
*/
|
|
300
|
+
var processDocumentEvent = (ev) => {
|
|
301
|
+
broadcast(documentPrefix, ev);
|
|
317
302
|
};
|
|
318
|
-
|
|
319
|
-
|
|
303
|
+
var processPassiveDocumentEvent = (ev) => {
|
|
304
|
+
broadcast(passiveDocumentPrefix, ev, false);
|
|
320
305
|
};
|
|
321
|
-
|
|
322
|
-
|
|
306
|
+
var processWindowEvent = (ev) => {
|
|
307
|
+
broadcast(windowPrefix, ev);
|
|
323
308
|
};
|
|
324
|
-
|
|
325
|
-
|
|
309
|
+
var processPassiveWindowEvent = (ev) => {
|
|
310
|
+
broadcast(passiveWindowPrefix, ev, false);
|
|
326
311
|
};
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
}
|
|
312
|
+
/**
|
|
313
|
+
* Called when the document is ready and whenever a container is added, so make this idempotent. For
|
|
314
|
+
* qidle and qinit we remove the attributes immediately, and for qvisible we add an attribute
|
|
315
|
+
*/
|
|
316
|
+
var processReadyStateChange = () => {
|
|
317
|
+
const readyState = doc.readyState;
|
|
318
|
+
if (readyState == "interactive" || readyState == "complete") {
|
|
319
|
+
hasInitialized = 1;
|
|
320
|
+
roots.forEach(findShadowRoots);
|
|
321
|
+
if (events.has("d:qinit")) {
|
|
322
|
+
events.delete("d:qinit");
|
|
323
|
+
const ev = createEvent("qinit");
|
|
324
|
+
const elements = querySelectorAll("[q-d\\:qinit]");
|
|
325
|
+
const tasks = [];
|
|
326
|
+
for (let i = 0; i < elements.length; i++) {
|
|
327
|
+
const el = elements[i];
|
|
328
|
+
dispatch(el, ev, "d:qinit", tasks);
|
|
329
|
+
el.removeAttribute("q-d:qinit");
|
|
330
|
+
}
|
|
331
|
+
queueTasks(tasks);
|
|
332
|
+
}
|
|
333
|
+
if (events.has("d:qidle")) {
|
|
334
|
+
events.delete("d:qidle");
|
|
335
|
+
(win.requestIdleCallback ?? win.setTimeout).bind(win)(() => {
|
|
336
|
+
const ev = createEvent("qidle");
|
|
337
|
+
const elements = querySelectorAll("[q-d\\:qidle]");
|
|
338
|
+
const tasks = [];
|
|
339
|
+
for (let i = 0; i < elements.length; i++) {
|
|
340
|
+
const el = elements[i];
|
|
341
|
+
dispatch(el, ev, "d:qidle", tasks);
|
|
342
|
+
el.removeAttribute("q-d:qidle");
|
|
343
|
+
}
|
|
344
|
+
queueTasks(tasks);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
if (events.has("e:qvisible")) {
|
|
348
|
+
observer || (observer = new IntersectionObserver((entries) => {
|
|
349
|
+
const tasks = [];
|
|
350
|
+
for (let i = 0; i < entries.length; i++) {
|
|
351
|
+
const entry = entries[i];
|
|
352
|
+
if (entry.isIntersecting) {
|
|
353
|
+
observer.unobserve(entry.target);
|
|
354
|
+
dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible", tasks);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
queueTasks(tasks);
|
|
358
|
+
}));
|
|
359
|
+
const elements = querySelectorAll("[q-e\\:qvisible]:not([q\\:observed])");
|
|
360
|
+
for (let i = 0; i < elements.length; i++) {
|
|
361
|
+
const el = elements[i];
|
|
362
|
+
observer.observe(el);
|
|
363
|
+
el.setAttribute("q:observed", "true");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
384
367
|
};
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,
|
|
410
|
-
true,
|
|
411
|
-
passive
|
|
412
|
-
)
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {
|
|
416
|
-
processReadyStateChange();
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
} else {
|
|
420
|
-
if (!roots.has(eventNameOrRoot)) {
|
|
421
|
-
events.forEach((kebabEventName) => {
|
|
422
|
-
const { scope, eventName } = parseKebabEvent(kebabEventName);
|
|
423
|
-
const passive = isPassiveScope(scope);
|
|
424
|
-
const rootScope = getRootScope(scope);
|
|
425
|
-
if (rootScope !== windowPrefix) {
|
|
426
|
-
addEventListener(
|
|
427
|
-
eventNameOrRoot,
|
|
428
|
-
eventName,
|
|
429
|
-
rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,
|
|
430
|
-
true,
|
|
431
|
-
passive
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
roots.add(eventNameOrRoot);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
368
|
+
var addEventOrRoot = (...eventNames) => {
|
|
369
|
+
for (let i = 0; i < eventNames.length; i++) {
|
|
370
|
+
const eventNameOrRoot = eventNames[i];
|
|
371
|
+
if (eventNameOrRoot === QwikEvContainerReady) markContainerReady(eventNames[++i]);
|
|
372
|
+
else if (typeof eventNameOrRoot === "string") {
|
|
373
|
+
if (!events.has(eventNameOrRoot)) {
|
|
374
|
+
events.add(eventNameOrRoot);
|
|
375
|
+
const { scope, eventName } = parseKebabEvent(eventNameOrRoot);
|
|
376
|
+
const passive = isPassiveScope(scope);
|
|
377
|
+
const rootScope = getRootScope(scope);
|
|
378
|
+
if (rootScope === windowPrefix) addEventListener(win, eventName, passive ? processPassiveWindowEvent : processWindowEvent, true, passive);
|
|
379
|
+
else roots.forEach((root) => addEventListener(root, eventName, rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent, true, passive));
|
|
380
|
+
if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) processReadyStateChange();
|
|
381
|
+
}
|
|
382
|
+
} else if (!roots.has(eventNameOrRoot)) {
|
|
383
|
+
events.forEach((kebabEventName) => {
|
|
384
|
+
const { scope, eventName } = parseKebabEvent(kebabEventName);
|
|
385
|
+
const passive = isPassiveScope(scope);
|
|
386
|
+
const rootScope = getRootScope(scope);
|
|
387
|
+
if (rootScope !== windowPrefix) addEventListener(eventNameOrRoot, eventName, rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent, true, passive);
|
|
388
|
+
});
|
|
389
|
+
roots.add(eventNameOrRoot);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
439
392
|
};
|
|
440
|
-
|
|
393
|
+
var _qwikEv = win._qwikEv;
|
|
441
394
|
if (!_qwikEv?.roots) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
};
|
|
452
|
-
addEventListener(doc, readyStateChange, processReadyStateChange);
|
|
453
|
-
processReadyStateChange();
|
|
395
|
+
if (Array.isArray(_qwikEv)) addEventOrRoot(..._qwikEv);
|
|
396
|
+
else addEventOrRoot("e:click", "e:input");
|
|
397
|
+
win._qwikEv = {
|
|
398
|
+
events,
|
|
399
|
+
roots,
|
|
400
|
+
push: addEventOrRoot
|
|
401
|
+
};
|
|
402
|
+
addEventListener(doc, readyStateChange, processReadyStateChange);
|
|
403
|
+
processReadyStateChange();
|
|
454
404
|
}
|
|
405
|
+
//#endregion
|