@qwik.dev/core 2.0.0-beta.14 → 2.0.0-beta.15
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/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +48 -16
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +379 -174
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +237 -140
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +140 -147
- package/dist/qwikloader.debug.js +38 -10
- package/dist/qwikloader.js +1 -1
- package/dist/server.mjs +5 -5
- package/dist/starters/features/csr/package.json +1 -1
- package/dist/testing/index.d.ts +6 -6
- package/dist/testing/index.mjs +306 -151
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
package/dist/qwikloader.debug.js
CHANGED
|
@@ -3,6 +3,8 @@ const win = window;
|
|
|
3
3
|
const events = /* @__PURE__ */ new Set();
|
|
4
4
|
const roots = /* @__PURE__ */ new Set([doc]);
|
|
5
5
|
const symbols = {};
|
|
6
|
+
const windowPrefix = "-window";
|
|
7
|
+
const documentPrefix = "-document";
|
|
6
8
|
let hasInitialized;
|
|
7
9
|
const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));
|
|
8
10
|
const querySelectorAll = (query) => {
|
|
@@ -64,11 +66,11 @@ const dispatch = async (element, scope, ev, eventName = ev.type) => {
|
|
|
64
66
|
}
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
|
-
const attrValue = element.getAttribute(attrName);
|
|
68
69
|
const qDispatchEvent = element.qDispatchEvent;
|
|
69
70
|
if (qDispatchEvent) {
|
|
70
71
|
return qDispatchEvent(ev, scope);
|
|
71
72
|
}
|
|
73
|
+
const attrValue = element.getAttribute(attrName);
|
|
72
74
|
if (attrValue) {
|
|
73
75
|
const container = element.closest(
|
|
74
76
|
"[q\\:container]:not([q\\:container=html]):not([q\\:container=text])"
|
|
@@ -155,10 +157,13 @@ const emitEvent = (eventName, detail) => {
|
|
|
155
157
|
doc.dispatchEvent(createEvent(eventName, detail));
|
|
156
158
|
};
|
|
157
159
|
const camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());
|
|
158
|
-
const processDocumentEvent = async (ev) => {
|
|
160
|
+
const processDocumentEvent = async (ev, scope) => {
|
|
159
161
|
let type = camelToKebab(ev.type);
|
|
160
162
|
let element = ev.target;
|
|
161
|
-
|
|
163
|
+
if (scope === documentPrefix) {
|
|
164
|
+
broadcast(documentPrefix, ev, type);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
162
167
|
while (element && element.getAttribute) {
|
|
163
168
|
const results = dispatch(element, "", ev, type);
|
|
164
169
|
let cancelBubble = ev.cancelBubble;
|
|
@@ -170,7 +175,7 @@ const processDocumentEvent = async (ev) => {
|
|
|
170
175
|
}
|
|
171
176
|
};
|
|
172
177
|
const processWindowEvent = (ev) => {
|
|
173
|
-
broadcast(
|
|
178
|
+
broadcast(windowPrefix, ev, camelToKebab(ev.type));
|
|
174
179
|
};
|
|
175
180
|
const processReadyStateChange = () => {
|
|
176
181
|
const readyState = doc.readyState;
|
|
@@ -180,7 +185,7 @@ const processReadyStateChange = () => {
|
|
|
180
185
|
emitEvent("qinit");
|
|
181
186
|
const riC = win.requestIdleCallback ?? win.setTimeout;
|
|
182
187
|
riC.bind(win)(() => emitEvent("qidle"));
|
|
183
|
-
if (events.has("qvisible")) {
|
|
188
|
+
if (events.has(":qvisible")) {
|
|
184
189
|
const results = querySelectorAll("[on\\:qvisible]");
|
|
185
190
|
const observer = new IntersectionObserver((entries) => {
|
|
186
191
|
for (const entry of entries) {
|
|
@@ -198,20 +203,43 @@ const addEventListener = (el, eventName, handler, capture = false) => {
|
|
|
198
203
|
el.addEventListener(eventName, handler, { capture, passive: false });
|
|
199
204
|
};
|
|
200
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
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return { scope, eventName: kebabToCamel(eventName) };
|
|
218
|
+
};
|
|
201
219
|
const processEventOrNode = (...eventNames) => {
|
|
202
220
|
for (const eventNameOrNode of eventNames) {
|
|
203
221
|
if (typeof eventNameOrNode === "string") {
|
|
204
222
|
if (!events.has(eventNameOrNode)) {
|
|
205
223
|
events.add(eventNameOrNode);
|
|
206
|
-
const eventName =
|
|
207
|
-
|
|
208
|
-
|
|
224
|
+
const { scope, eventName } = processEventName(eventNameOrNode);
|
|
225
|
+
if (scope === windowPrefix) {
|
|
226
|
+
addEventListener(win, eventName, processWindowEvent, true);
|
|
227
|
+
} else {
|
|
228
|
+
roots.forEach(
|
|
229
|
+
(root) => addEventListener(root, eventName, (ev) => processDocumentEvent(ev, scope), true)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
209
232
|
}
|
|
210
233
|
} else {
|
|
211
234
|
if (!roots.has(eventNameOrNode)) {
|
|
212
235
|
events.forEach((kebabEventName) => {
|
|
213
|
-
const eventName =
|
|
214
|
-
addEventListener(
|
|
236
|
+
const { scope, eventName } = processEventName(kebabEventName);
|
|
237
|
+
addEventListener(
|
|
238
|
+
eventNameOrNode,
|
|
239
|
+
eventName,
|
|
240
|
+
(ev) => processDocumentEvent(ev, scope),
|
|
241
|
+
true
|
|
242
|
+
);
|
|
215
243
|
});
|
|
216
244
|
roots.add(eventNameOrNode);
|
|
217
245
|
}
|
package/dist/qwikloader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=document,e=window,n=new Set,o=new Set([t]),r={};let
|
|
1
|
+
const t=document,e=window,n=new Set,o=new Set([t]),r={},s="-window",i="-document";let a;const c=(t,e)=>Array.from(t.querySelectorAll(e)),l=t=>{const e=[];return o.forEach(n=>e.push(...c(n,t))),e},f=t=>{A(t),c(t,"[q\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&f(e)})},p=t=>t&&"function"==typeof t.then,u=(t,e,n=e.type)=>{l("[on"+t+"\\:"+n+"]").forEach(o=>{h(o,t,e,n)})},b=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}}},q=(t,e)=>new CustomEvent(t,{detail:e}),h=async(e,n,o,s=o.type)=>{const i="on"+n+":"+s;e.hasAttribute("preventdefault:"+s)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+s)&&o.stopPropagation();const a=e._qc_,c=a&&a.li.filter(t=>t[0]===i);if(c&&c.length>0){for(const t of c){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;p(n)&&await n,r&&o.stopPropagation()}return}const l=e.qDispatchEvent;if(l)return l(o,n);const f=e.getAttribute(i);if(f){const n=e.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])"),s=n.getAttribute("q:base"),i=n.getAttribute("q:version")||"unknown",a=n.getAttribute("q:manifest-hash")||"dev",c=new URL(s,t.baseURI);for(const l of f.split("\n")){const f=new URL(l,c),u=f.href,q=f.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let d,m,g;const y=l.startsWith("#"),v={qBase:s,qManifest:a,qVersion:i,href:u,symbol:q,element:e,reqTime:h};if(y){const e=n.getAttribute("q:instance");d=(t["qFuncs_"+e]||[])[Number.parseInt(q)],d||(m="sync",g=Error("sym:"+q))}else if(q in r)d=r[q];else{_("qsymbol",v);const t=f.href.split("#")[0];try{const e=import(t);b(n),d=(await e)[q],d?r[q]=d:(m="no-symbol",g=Error(`${q} not in ${t}`))}catch(t){m||(m="async"),g=t}}if(!d){_("qerror",{importError:m,error:g,...v}),console.error(g);break}const w=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,f];const n=d(o,e);p(n)&&await n}catch(t){_("qerror",{error:t,...v})}finally{t.__q_context__=w}}}},_=(e,n)=>{t.dispatchEvent(q(e,n))},d=t=>t.replace(/([A-Z-])/g,t=>"-"+t.toLowerCase()),m=async(t,e)=>{let n=d(t.type),o=t.target;if(e!==i)for(;o&&o.getAttribute;){const e=h(o,"",t,n);let r=t.cancelBubble;p(e)&&await e,r||(r=r||t.cancelBubble||o.hasAttribute("stoppropagation:"+t.type)),o=t.bubbles&&!0!==r?o.parentElement:null}else u(i,t,n)},g=t=>{u(s,t,d(t.type))},y=()=>{const r=t.readyState;if(!a&&("interactive"==r||"complete"==r)&&(o.forEach(f),a=1,_("qinit"),(e.requestIdleCallback??e.setTimeout).bind(e)(()=>_("qidle")),n.has(":qvisible"))){const t=l("[on\\:qvisible]"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),h(n.target,"",q("qvisible",n)))});t.forEach(t=>e.observe(t))}},v=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},w=t=>t.replace(/-./g,t=>t[1].toUpperCase()),E=t=>{const e=t.indexOf(":");let n="",o=t;if(e>=0){const r=t.substring(0,e);""!==r&&r!==s&&r!==i||(n=r,o=t.substring(e+1))}return{scope:n,eventName:w(o)}},A=(...t)=>{for(const r of t)if("string"==typeof r){if(!n.has(r)){n.add(r);const{scope:t,eventName:i}=E(r);t===s?v(e,i,g,!0):o.forEach(e=>v(e,i,e=>m(e,t),!0))}}else o.has(r)||(n.forEach(t=>{const{scope:e,eventName:n}=E(t);v(r,n,t=>m(t,e),!0)}),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?A(...r):A("click","input")),e.qwikevents={events:n,roots:o,push:A},v(t,"readystatechange",y),y()}
|
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.15-dev+920f1a4
|
|
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
|
|
@@ -1154,7 +1154,7 @@ function getBuildBase(opts) {
|
|
|
1154
1154
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1155
1155
|
}
|
|
1156
1156
|
var versions = {
|
|
1157
|
-
qwik: "2.0.0-beta.
|
|
1157
|
+
qwik: "2.0.0-beta.15-dev+920f1a4",
|
|
1158
1158
|
qwikDom: "2.1.19"
|
|
1159
1159
|
};
|
|
1160
1160
|
|
|
@@ -1313,7 +1313,7 @@ var preloaderPre = (container, options, nonce) => {
|
|
|
1313
1313
|
]);
|
|
1314
1314
|
container.closeElement();
|
|
1315
1315
|
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1316
|
-
const scriptAttrs = ["type", "module", "async", true];
|
|
1316
|
+
const scriptAttrs = ["type", "module", "async", true, "crossorigin", "anonymous"];
|
|
1317
1317
|
if (nonce) {
|
|
1318
1318
|
scriptAttrs.push("nonce", nonce);
|
|
1319
1319
|
}
|
|
@@ -1411,8 +1411,8 @@ var preLoaderOptionsDefault = {
|
|
|
1411
1411
|
};
|
|
1412
1412
|
|
|
1413
1413
|
// packages/qwik/src/server/scripts.ts
|
|
1414
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]),r={};let
|
|
1415
|
-
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = {};\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
|
|
1414
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]),r={},s="-window",i="-document";let a;const c=(t,e)=>Array.from(t.querySelectorAll(e)),l=t=>{const e=[];return o.forEach(n=>e.push(...c(n,t))),e},f=t=>{A(t),c(t,"[q\\\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&f(e)})},p=t=>t&&"function"==typeof t.then,u=(t,e,n=e.type)=>{l("[on"+t+"\\\\:"+n+"]").forEach(o=>{h(o,t,e,n)})},b=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}}},q=(t,e)=>new CustomEvent(t,{detail:e}),h=async(e,n,o,s=o.type)=>{const i="on"+n+":"+s;e.hasAttribute("preventdefault:"+s)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+s)&&o.stopPropagation();const a=e._qc_,c=a&&a.li.filter(t=>t[0]===i);if(c&&c.length>0){for(const t of c){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;p(n)&&await n,r&&o.stopPropagation()}return}const l=e.qDispatchEvent;if(l)return l(o,n);const f=e.getAttribute(i);if(f){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),s=n.getAttribute("q:base"),i=n.getAttribute("q:version")||"unknown",a=n.getAttribute("q:manifest-hash")||"dev",c=new URL(s,t.baseURI);for(const l of f.split("\\n")){const f=new URL(l,c),u=f.href,q=f.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let d,m,g;const y=l.startsWith("#"),v={qBase:s,qManifest:a,qVersion:i,href:u,symbol:q,element:e,reqTime:h};if(y){const e=n.getAttribute("q:instance");d=(t["qFuncs_"+e]||[])[Number.parseInt(q)],d||(m="sync",g=Error("sym:"+q))}else if(q in r)d=r[q];else{_("qsymbol",v);const t=f.href.split("#")[0];try{const e=import(t);b(n),d=(await e)[q],d?r[q]=d:(m="no-symbol",g=Error(`${q} not in ${t}`))}catch(t){m||(m="async"),g=t}}if(!d){_("qerror",{importError:m,error:g,...v}),console.error(g);break}const w=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,f];const n=d(o,e);p(n)&&await n}catch(t){_("qerror",{error:t,...v})}finally{t.__q_context__=w}}}},_=(e,n)=>{t.dispatchEvent(q(e,n))},d=t=>t.replace(/([A-Z-])/g,t=>"-"+t.toLowerCase()),m=async(t,e)=>{let n=d(t.type),o=t.target;if(e!==i)for(;o&&o.getAttribute;){const e=h(o,"",t,n);let r=t.cancelBubble;p(e)&&await e,r||(r=r||t.cancelBubble||o.hasAttribute("stoppropagation:"+t.type)),o=t.bubbles&&!0!==r?o.parentElement:null}else u(i,t,n)},g=t=>{u(s,t,d(t.type))},y=()=>{const r=t.readyState;if(!a&&("interactive"==r||"complete"==r)&&(o.forEach(f),a=1,_("qinit"),(e.requestIdleCallback??e.setTimeout).bind(e)(()=>_("qidle")),n.has(":qvisible"))){const t=l("[on\\\\:qvisible]"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),h(n.target,"",q("qvisible",n)))});t.forEach(t=>e.observe(t))}},v=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},w=t=>t.replace(/-./g,t=>t[1].toUpperCase()),E=t=>{const e=t.indexOf(":");let n="",o=t;if(e>=0){const r=t.substring(0,e);""!==r&&r!==s&&r!==i||(n=r,o=t.substring(e+1))}return{scope:n,eventName:w(o)}},A=(...t)=>{for(const r of t)if("string"==typeof r){if(!n.has(r)){n.add(r);const{scope:t,eventName:i}=E(r);t===s?v(e,i,g,!0):o.forEach(e=>v(e,i,e=>m(e,t),!0))}}else o.has(r)||(n.forEach(t=>{const{scope:e,eventName:n}=E(t);v(r,n,t=>m(t,e),!0)}),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?A(...r):A("click","input")),e.qwikevents={events:n,roots:o,push:A},v(t,"readystatechange",y),y()}';
|
|
1415
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = {};\nconst windowPrefix = "-window";\nconst documentPrefix = "-document";\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 qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\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 if (symbol in symbols) {\n handler = symbols[symbol];\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 } else {\n symbols[symbol] = handler;\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, scope) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n if (scope === documentPrefix) {\n broadcast(documentPrefix, ev, type);\n return;\n }\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(windowPrefix, ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\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 = win.requestIdleCallback ?? 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 kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst processEventName = (event) => {\n const i = event.indexOf(":");\n let scope = "";\n let eventName = event;\n if (i >= 0) {\n const s = event.substring(0, i);\n if (s === "" || s === windowPrefix || s === documentPrefix) {\n scope = s;\n eventName = event.substring(i + 1);\n }\n }\n return { scope, eventName: kebabToCamel(eventName) };\n};\nconst processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n events.add(eventNameOrNode);\n const { scope, eventName } = processEventName(eventNameOrNode);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(root, eventName, (ev) => processDocumentEvent(ev, scope), true)\n );\n }\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = processEventName(kebabEventName);\n addEventListener(\n eventNameOrNode,\n eventName,\n (ev) => processDocumentEvent(ev, scope),\n true\n );\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}';
|
|
1416
1416
|
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))}}}}`;
|
|
1417
1417
|
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1418
1418
|
const executorScript = document.currentScript;
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ declare type AsyncComputeQRL<T> = QRLInternal<AsyncComputedFn<T>>;
|
|
|
30
30
|
|
|
31
31
|
/** Class for back reference to the EffectSubscription */
|
|
32
32
|
declare abstract class BackRef {
|
|
33
|
-
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> |
|
|
33
|
+
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
declare type BivariantQrlFn<ARGS extends any[], RETURN> = {
|
|
@@ -219,10 +219,10 @@ export declare const createDOM: ({ html }?: {
|
|
|
219
219
|
userEvent: (queryOrElement: string | Element | keyof HTMLElementTagNameMap | null, eventNameCamel: string | keyof WindowEventMap, eventPayload?: any) => Promise<void>;
|
|
220
220
|
}>;
|
|
221
221
|
|
|
222
|
-
declare const createScheduler: (container: Container, journalFlush: () => void, choreQueue: ChoreArray, blockedChores:
|
|
222
|
+
declare const createScheduler: (container: Container, journalFlush: () => void, choreQueue: ChoreArray, blockedChores: ChoreArray, runningChores: Set<Chore>) => {
|
|
223
223
|
(type: ChoreType.QRL_RESOLVE, ignore: null, target: ComputeQRL<any> | AsyncComputeQRL<any>): Chore<ChoreType.QRL_RESOLVE>;
|
|
224
224
|
(type: ChoreType.WAIT_FOR_QUEUE): Chore<ChoreType.WAIT_FOR_QUEUE>;
|
|
225
|
-
(type: ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, host: HostElement |
|
|
225
|
+
(type: ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, host: HostElement | undefined, target: Signal<unknown> | StoreTarget, effects: Set<EffectSubscription> | undefined): Chore<ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS>;
|
|
226
226
|
(type: ChoreType.TASK | ChoreType.VISIBLE, task: Task): Chore<ChoreType.TASK | ChoreType.VISIBLE>;
|
|
227
227
|
(type: ChoreType.RUN_QRL, host: HostElement, target: QRLInternal<(...args: unknown[]) => unknown>, args: unknown[]): Chore<ChoreType.RUN_QRL>;
|
|
228
228
|
(type: ChoreType.COMPONENT, host: HostElement, qrl: QRLInternal<OnRenderFn<unknown>>, props: Props | null): Chore<ChoreType.COMPONENT>;
|
|
@@ -743,7 +743,7 @@ declare const enum SignalFlags {
|
|
|
743
743
|
declare class SignalImpl<T = any> implements Signal<T> {
|
|
744
744
|
$untrackedValue$: T;
|
|
745
745
|
/** Store a list of effects which are dependent on this signal. */
|
|
746
|
-
$effects$:
|
|
746
|
+
$effects$: undefined | Set<EffectSubscription>;
|
|
747
747
|
$container$: Container | null;
|
|
748
748
|
$wrappedSignal$: WrappedSignalImpl<T> | null;
|
|
749
749
|
constructor(container: Container | null, value: T);
|
|
@@ -1118,8 +1118,8 @@ declare class WrappedSignalImpl<T> extends SignalImpl<T> implements BackRef {
|
|
|
1118
1118
|
$func$: (...args: any[]) => T;
|
|
1119
1119
|
$funcStr$: string | null;
|
|
1120
1120
|
$flags$: AllSignalFlags;
|
|
1121
|
-
$hostElement$: HostElement |
|
|
1122
|
-
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> |
|
|
1121
|
+
$hostElement$: HostElement | undefined;
|
|
1122
|
+
[_EFFECT_BACK_REF]: Map<EffectProperty | string, EffectSubscription> | undefined;
|
|
1123
1123
|
constructor(container: Container | null, fn: (...args: any[]) => T, args: any[], fnStr: string | null, flags?: SignalFlags);
|
|
1124
1124
|
invalidate(): void;
|
|
1125
1125
|
/**
|