@qwik.dev/core 2.0.0-beta.35 → 2.0.0-beta.36
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 +2 -1
- 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 +183 -39
- package/dist/core.min.mjs +8 -9
- package/dist/core.mjs +2223 -1290
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +4492 -3645
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +0 -4
- package/dist/optimizer.mjs +429 -424
- package/dist/out-of-order-executor.debug.js +163 -0
- package/dist/out-of-order-executor.js +1 -0
- package/dist/preloader.mjs +1 -1
- package/dist/qwikloader.debug.js +47 -26
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.mjs +1160 -143
- package/dist/server.prod.mjs +1231 -428
- package/dist/testing/index.d.ts +75 -20
- package/dist/testing/index.mjs +2966 -1218
- package/dist/testing/package.json +1 -1
- package/dist/worker/package.json +1 -1
- package/package.json +4 -4
- package/public.d.ts +1 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
const Q_RESOLVED_SELECTOR = 'template[q\\:r="';
|
|
2
|
+
const Q_RESOLVED_ATTR = "q:r";
|
|
3
|
+
const Q_RESULT_PARENT_SELECTOR = '[q\\:rp="';
|
|
4
|
+
const Q_GROUP_ATTR = "q:g";
|
|
5
|
+
const Q_INDEX_ATTR = "q:i";
|
|
6
|
+
const Q_ORDER_ATTR = "q:o";
|
|
7
|
+
const Q_CONTAINER_SELECTOR = "[q\\:container]:not([q\\:container=html]):not([q\\:container=text])";
|
|
8
|
+
const installOutOfOrderExecutor = (doc) => {
|
|
9
|
+
const groups = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
const process = (boundaryId, content) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const executorDoc = doc;
|
|
13
|
+
(_a = executorDoc.qProcessOOOS) == null ? void 0 : _a.call(executorDoc, boundaryId, content);
|
|
14
|
+
};
|
|
15
|
+
const getScope = () => {
|
|
16
|
+
const script = doc.currentScript;
|
|
17
|
+
return script ? script.closest(Q_CONTAINER_SELECTOR) || doc : doc;
|
|
18
|
+
};
|
|
19
|
+
const group = (scope, groupId, total, order) => {
|
|
20
|
+
let scopedGroups = groups.get(scope);
|
|
21
|
+
if (!scopedGroups) {
|
|
22
|
+
groups.set(scope, scopedGroups = {});
|
|
23
|
+
}
|
|
24
|
+
return scopedGroups[groupId] || (scopedGroups[groupId] = {
|
|
25
|
+
r: {},
|
|
26
|
+
n: 0,
|
|
27
|
+
t: total,
|
|
28
|
+
o: order
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const getResolvedTemplate = (scope, boundaryId) => {
|
|
32
|
+
const currentScript = doc.currentScript;
|
|
33
|
+
const previousElement = currentScript ? currentScript.previousElementSibling : null;
|
|
34
|
+
if (previousElement && previousElement.localName === "template" && previousElement.getAttribute(Q_RESOLVED_ATTR) === String(boundaryId)) {
|
|
35
|
+
return previousElement;
|
|
36
|
+
}
|
|
37
|
+
const templates = scope.querySelectorAll(Q_RESOLVED_SELECTOR + boundaryId + '"]');
|
|
38
|
+
return templates.length ? templates[templates.length - 1] : null;
|
|
39
|
+
};
|
|
40
|
+
const getPlaceholderTemplate = (content, boundaryId) => {
|
|
41
|
+
return content.querySelector(Q_RESOLVED_SELECTOR + boundaryId + '"]');
|
|
42
|
+
};
|
|
43
|
+
const getResultParent = (scope, boundaryId) => {
|
|
44
|
+
return scope.querySelector(Q_RESULT_PARENT_SELECTOR + boundaryId + '"]');
|
|
45
|
+
};
|
|
46
|
+
const reveal = (content, fallback) => {
|
|
47
|
+
if (!content) {
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
if (fallback && fallback.style) {
|
|
51
|
+
fallback.style.display = "none";
|
|
52
|
+
}
|
|
53
|
+
if (content.style) {
|
|
54
|
+
content.style.display = "contents";
|
|
55
|
+
}
|
|
56
|
+
return 1;
|
|
57
|
+
};
|
|
58
|
+
const move = (scope, boundaryId, resolved) => {
|
|
59
|
+
if (!resolved) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const content = getResultParent(scope, boundaryId);
|
|
63
|
+
const placeholder = content ? getPlaceholderTemplate(content, boundaryId) : null;
|
|
64
|
+
const parent = placeholder ? placeholder.parentNode : null;
|
|
65
|
+
if (!placeholder || !content || !parent) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
parent.insertBefore(resolved.content, placeholder);
|
|
69
|
+
placeholder.remove();
|
|
70
|
+
resolved.remove();
|
|
71
|
+
return [content, content.previousElementSibling];
|
|
72
|
+
};
|
|
73
|
+
const flush = (group2) => {
|
|
74
|
+
const order = group2.o;
|
|
75
|
+
let entry;
|
|
76
|
+
let index;
|
|
77
|
+
let swapped = 0;
|
|
78
|
+
if (order === "p") {
|
|
79
|
+
for (const key in group2.r) {
|
|
80
|
+
entry = group2.r[key];
|
|
81
|
+
if (entry[0] && reveal(entry[0], entry[1])) {
|
|
82
|
+
entry[0] = 0;
|
|
83
|
+
swapped++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
} else if (order === "s") {
|
|
87
|
+
for (index = group2.n; (entry = group2.r[index]) && entry[0]; index++) {
|
|
88
|
+
if (!reveal(entry[0], entry[1])) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
entry[0] = 0;
|
|
92
|
+
swapped++;
|
|
93
|
+
group2.n = index + 1;
|
|
94
|
+
}
|
|
95
|
+
} else if (order === "r") {
|
|
96
|
+
if (group2.t < 0) {
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
if (group2.n < 0) {
|
|
100
|
+
group2.n = group2.t - 1;
|
|
101
|
+
}
|
|
102
|
+
for (index = group2.n; (entry = group2.r[index]) && entry[0]; index--) {
|
|
103
|
+
if (!reveal(entry[0], entry[1])) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
entry[0] = 0;
|
|
107
|
+
swapped++;
|
|
108
|
+
group2.n = index - 1;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
if (group2.t < 0) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
for (index = 0; index < group2.t; index++) {
|
|
115
|
+
entry = group2.r[index];
|
|
116
|
+
if (!entry) {
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (index = 0; index < group2.t; index++) {
|
|
121
|
+
entry = group2.r[index];
|
|
122
|
+
if (entry[0] && reveal(entry[0], entry[1])) {
|
|
123
|
+
entry[0] = 0;
|
|
124
|
+
swapped++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return swapped;
|
|
129
|
+
};
|
|
130
|
+
const qO = ((boundaryId) => {
|
|
131
|
+
const scope = getScope();
|
|
132
|
+
const resolved = getResolvedTemplate(scope, boundaryId);
|
|
133
|
+
if (!resolved) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const entry = move(scope, boundaryId, resolved);
|
|
137
|
+
if (!entry) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
process(boundaryId, entry[0] || null);
|
|
141
|
+
const groupId = resolved.getAttribute(Q_GROUP_ATTR);
|
|
142
|
+
if (groupId) {
|
|
143
|
+
const index = +(resolved.getAttribute(Q_INDEX_ATTR) || 0);
|
|
144
|
+
const currentGroup = group(scope, groupId, -1, resolved.getAttribute(Q_ORDER_ATTR) || "p");
|
|
145
|
+
currentGroup.r[index] = entry;
|
|
146
|
+
flush(currentGroup);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
reveal(entry[0] || null, entry[1]);
|
|
150
|
+
});
|
|
151
|
+
qO.g = (groupId, total, order) => {
|
|
152
|
+
const currentGroup = group(getScope(), groupId, total, order);
|
|
153
|
+
currentGroup.t = total;
|
|
154
|
+
currentGroup.o = order;
|
|
155
|
+
if (currentGroup.o === "r" && currentGroup.n === 0) {
|
|
156
|
+
currentGroup.n = total - 1;
|
|
157
|
+
}
|
|
158
|
+
flush(currentGroup);
|
|
159
|
+
};
|
|
160
|
+
qO.d = doc;
|
|
161
|
+
globalThis.qO = qO;
|
|
162
|
+
};
|
|
163
|
+
installOutOfOrderExecutor(document);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t='template[q\\:r="',e="q:r",n='[q\\:rp="',r="q:g",l="q:i",o="q:o",s="[q\\:container]:not([q\\:container=html]):not([q\\:container=text])",u=u=>{const i=new WeakMap,c=()=>{const t=u.currentScript;return t&&t.closest(s)||u},f=(t,e,n,r)=>{let l=i.get(t);return l||i.set(t,l={}),l[e]||(l[e]={r:{},n:0,t:n,o:r})},a=(t,e)=>t?(e&&e.style&&(e.style.display="none"),t.style&&(t.style.display="contents"),1):0,q=t=>{const e=t.o;let n,r,l=0;if("p"===e)for(const e in t.r)n=t.r[e],n[0]&&a(n[0],n[1])&&(n[0]=0,l++);else if("s"===e)for(r=t.n;(n=t.r[r])&&n[0]&&a(n[0],n[1]);r++)n[0]=0,l++,t.n=r+1;else if("r"===e){if(t.t<0)return 0;for(t.n<0&&(t.n=t.t-1),r=t.n;(n=t.r[r])&&n[0]&&a(n[0],n[1]);r--)n[0]=0,l++,t.n=r-1}else{if(t.t<0)return 0;for(r=0;r<t.t;r++)if(n=t.r[r],!n)return 0;for(r=0;r<t.t;r++)n=t.r[r],n[0]&&a(n[0],n[1])&&(n[0]=0,l++)}return l},p=s=>{const i=c(),p=((n,r)=>{const l=u.currentScript,o=l?l.previousElementSibling:null;if(o&&"template"===o.localName&&o.getAttribute(e)===r+"")return o;const s=n.querySelectorAll(t+r+'"]');return s.length?s[s.length-1]:null})(i,s);if(!p)return;const g=((e,r,l)=>{if(!l)return null;const o=((t,e)=>t.querySelector(n+e+'"]'))(e,r),s=o?((e,n)=>e.querySelector(t+n+'"]'))(o,r):null,u=s?s.parentNode:null;return s&&o&&u?(u.insertBefore(l.content,s),s.remove(),l.remove(),[o,o.previousElementSibling]):null})(i,s,p);if(!g)return;((t,e)=>{var n;const r=u;null==(n=r.qProcessOOOS)||n.call(r,t,e)})(s,g[0]||null);const m=p.getAttribute(r);if(m){const t=+(p.getAttribute(l)||0),e=f(i,m,-1,p.getAttribute(o)||"p");return e.r[t]=g,void q(e)}a(g[0]||null,g[1])};p.g=(t,e,n)=>{const r=f(c(),t,e,n);r.t=e,r.o=n,"r"===r.o&&0===r.n&&(r.n=e-1),q(r)},p.d=u,globalThis.qO=p};u(document);
|
package/dist/preloader.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isServer as e}from"@qwik.dev/core/build";const n=e=>{let n;if(typeof MessageChannel!=="undefined"){const t=new MessageChannel;t.port1.onmessage=()=>e();n=()=>t.port2.postMessage(null)}else n=()=>setTimeout(e);return n};const t=typeof document!=="undefined";const o=!e&&t;const s=o?document:void 0;const c={t:25};const r=o&&s.createElement("link").relList?.supports?.("modulepreload")?"modulePreload":"preload";
|
|
1
|
+
import{isServer as e}from"@qwik.dev/core/build";const n=e=>{let n;if(typeof MessageChannel!=="undefined"){const t=new MessageChannel;t.port1.onmessage=()=>e();n=()=>t.port2.postMessage(null)}else n=()=>setTimeout(e);return n};const t=typeof document!=="undefined";const o=!e&&t;const s=o?document:void 0;const c={t:25};const r=o&&s.createElement("link").relList?.supports?.("modulepreload")?"modulePreload":"preload";const i=/\.[mc]?js$/;const f=1e3/60;const l=0;const a=1;const $=2;const u=3;const d=4;const m=/* @__PURE__ */new Map;let p;let b=0;const w=[];const h=n(q);const y=n(S);let M=0;let P=0;let k=0;const v=[];const g=()=>{if(p){w.sort((e,n)=>e.o-n.o);p=0}};function q(){M=0;if(!w.length)return;g();const e=performance.now()+f;let n=0;while(w.length){const t=w[0];const o=t.o;const s=1-o;if(s>=.99||b<c.t){w.shift();T(t);if(performance.now()>=e){n=1;break}}else break}if(n&&w.length&&!M){M=1;h()}}const x=(e,n,t)=>{v.unshift({i:e,o:n,l:t})};const C=()=>{const e=v[v.length-1];const n=e.i;if(e.$){const t=e.u;if(t>=e.$.length){v.pop();return 0}const o=e.$[t];e.u=t+1;const s=R(o.m);if(s.o===0)return 1;const c=1-n.o;let r;if(c===1||c>=.99)r=Math.min(.01,1-o.p);else{const e=1-o.p*c;const n=o.h;const t=e/n;r=Math.max(.02,s.o*t);o.h=t}v.push({i:s,o:r,l:e.l});return 1}if(e.l?.has(n)){v.pop();return 0}const t=n.o;n.o=e.o;if(t-n.o<.01){v.pop();return 0}if(J!=null&&n.M<$){if(n.M===l){n.M=a;w.push(n)}p=1}if(n.$?.length){const t=e.l||/* @__PURE__ */new Set;t.add(n);e.l=t;e.$=n.$;e.u=0;return 0}v.pop();return 0};function S(){if(k||!v.length)return;P=0;k=1;const e=o?performance.now()+f:0;let n=0;while(v.length){n=1;const t=C();if(o&&t&&performance.now()>=e){if(!P){P=1;y()}break}}k=0;if(n&&o)h()}const T=e=>{if(e.M>=$)return;b++;const n=performance.now();e.k=n-e.v;e.M=$;const t=s.createElement("link");t.href=new URL(`${J}${e.m}`,s.baseURI).toString();t.rel=r;t.as="script";t.onload=t.onerror=()=>{b--;const o=performance.now();e.q=o-n;e.M=d;t.remove();h()};s.head.appendChild(t)};const j=(e,n,t)=>{x(e,n,t);if(o)y();else S()};const A=(e,n)=>{const t=R(e);if(t)x(t,n)};const I=(e,n)=>{if(!e?.length)return;const t=n?1-n:.4;if(Array.isArray(e))for(let o=e.length-1;o>=0;o--){const n=e[o];A(n,t)}else A(e,t);if(o)y();else S()};if(o)document.addEventListener("qsymbol",e=>{const{symbol:n,href:t}=e.detail;if(t){const e=n.slice(n.lastIndexOf("_")+1);I(e,1)}});let J;let L;const N=(e,n)=>({m:e,M:i.test(e)?l:u,$:n,o:1,v:performance.now(),k:0,q:0});const O=e=>{const n=/* @__PURE__ */new Map;let t=0;while(t<e.length){const o=e[t++];const s=[];let c;let r=1;while(c=e[t],typeof c==="number"){if(c<0)r=-c/10;else s.push({m:e[c],p:r,h:1});t++}n.set(o,s)}return n};const R=e=>{let n=m.get(e);if(!n){let t;if(L){t=L.get(e);if(!t)return;if(!t.length)t=void 0}n=N(e,t);m.set(e,n)}return n};const U=(e,t,s)=>{if(s)if("P"in s)c.t=s["P"];if(!o||e==null)return;J=e;if(t)t.then(e=>e.text()).then(e=>{L=O(JSON.parse(e));const t=[];for(const[n,c]of L.entries()){const e=R(n);e.$=c;if(e.o<1){t.push([e,e.o]);e.o=1}}if(!t.length){h();return}let o=0;const s=n(()=>{const e=performance.now()+f;while(o<t.length){const[n,c]=t[o];o++;j(n,c);if(o<t.length&&performance.now()>=e){s();return}}h()});s()}).catch(console.warn)};export{O as g,U as l,I as p};
|
package/dist/qwikloader.debug.js
CHANGED
|
@@ -7,6 +7,8 @@ const passiveDocumentPrefix = "dp";
|
|
|
7
7
|
const elementPrefix = "e";
|
|
8
8
|
const passiveElementPrefix = "ep";
|
|
9
9
|
const capturePrefix = "capture:";
|
|
10
|
+
const readyStateChange = "readystatechange";
|
|
11
|
+
const containerReady = "qready";
|
|
10
12
|
const events = /* @__PURE__ */ new Set();
|
|
11
13
|
const roots = /* @__PURE__ */ new Set([doc]);
|
|
12
14
|
const symbols = /* @__PURE__ */ new Map();
|
|
@@ -56,6 +58,19 @@ const resolveContainer = (containerEl) => {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
};
|
|
61
|
+
const waitForContainerReady = (container) => {
|
|
62
|
+
const hash = container.getAttribute("q:instance");
|
|
63
|
+
return container.getAttribute("q:container") === "paused" && doc.readyState === "loading" && !doc[containerReady]?.[hash] && new Promise((resolve) => {
|
|
64
|
+
const ready = (ev) => {
|
|
65
|
+
if (ev.detail === hash) {
|
|
66
|
+
doc.removeEventListener(containerReady, ready);
|
|
67
|
+
resolve();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
addEventListener(doc, readyStateChange, resolve);
|
|
71
|
+
addEventListener(doc, containerReady, ready);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
59
74
|
const createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });
|
|
60
75
|
const emitEvent = (eventName, detail) => {
|
|
61
76
|
doc.dispatchEvent(createEvent(eventName, detail));
|
|
@@ -74,17 +89,16 @@ const isPassiveScope = (scope) => scope.length === 2;
|
|
|
74
89
|
const getRootScope = (scope) => scope.charAt(0);
|
|
75
90
|
const isElementNode = (node) => !!node && node.nodeType === 1;
|
|
76
91
|
const isCaptureHandlerElement = (element, scopedKebabName, captureAttribute) => element.hasAttribute(captureAttribute) && (!!element._qDispatch?.[scopedKebabName] || element.hasAttribute("q-" + scopedKebabName));
|
|
77
|
-
const resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime) => {
|
|
92
|
+
const resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime, reportSyncError = true) => {
|
|
78
93
|
const eventData = {
|
|
79
94
|
qBase,
|
|
80
95
|
symbol,
|
|
81
96
|
element,
|
|
82
97
|
reqTime
|
|
83
98
|
};
|
|
84
|
-
if (chunk
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
if (!handler2) {
|
|
99
|
+
if (!chunk) {
|
|
100
|
+
const handler2 = (doc["qFuncs_" + container.getAttribute("q:instance")] || [])[+symbol];
|
|
101
|
+
if (!handler2 && reportSyncError) {
|
|
88
102
|
const error = new Error("sym:" + symbol);
|
|
89
103
|
emitEvent("qerror", {
|
|
90
104
|
importError: "sync",
|
|
@@ -194,26 +208,18 @@ const dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDe
|
|
|
194
208
|
const qBase = container.getAttribute("q:base");
|
|
195
209
|
const base = new URL(qBase, doc.baseURI);
|
|
196
210
|
const qrls = attrValue.split("|");
|
|
211
|
+
const waitForReady = waitForContainerReady(container);
|
|
197
212
|
for (let i = 0; i < qrls.length; i++) {
|
|
198
213
|
const qrl = qrls[i];
|
|
199
214
|
const reqTime = performance.now();
|
|
200
215
|
const [chunk, symbol, capturedIds] = qrl.split("#");
|
|
201
216
|
const run = (handler2) => {
|
|
202
217
|
if (handler2 && element.isConnected) {
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
207
|
-
emitEvent("qerror", {
|
|
208
|
-
error,
|
|
209
|
-
qBase,
|
|
210
|
-
symbol,
|
|
211
|
-
element,
|
|
212
|
-
reqTime
|
|
213
|
-
});
|
|
214
|
-
});
|
|
218
|
+
const onError = (error) => {
|
|
219
|
+
const retry = waitForContainerReady(container);
|
|
220
|
+
if (retry) {
|
|
221
|
+
return retry.then(() => run(handler2));
|
|
215
222
|
}
|
|
216
|
-
} catch (error) {
|
|
217
223
|
emitEvent("qerror", {
|
|
218
224
|
error,
|
|
219
225
|
qBase,
|
|
@@ -221,14 +227,31 @@ const dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDe
|
|
|
221
227
|
element,
|
|
222
228
|
reqTime
|
|
223
229
|
});
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
const result = handler2.call(capturedIds, ev, element);
|
|
233
|
+
if (isPromise(result)) {
|
|
234
|
+
return result.catch(onError);
|
|
235
|
+
}
|
|
236
|
+
} catch (error) {
|
|
237
|
+
return onError(error);
|
|
224
238
|
}
|
|
225
239
|
}
|
|
226
240
|
};
|
|
227
|
-
const
|
|
228
|
-
|
|
241
|
+
const resolve = (reportSyncError = true) => resolveHandler(container, element, qBase, base, chunk, symbol, reqTime, reportSyncError);
|
|
242
|
+
const handler = waitForReady && !chunk ? resolve(false) : resolve();
|
|
243
|
+
if (isPromise(handler)) {
|
|
244
|
+
defer = true;
|
|
245
|
+
tasks.push(() => handler.then(run));
|
|
246
|
+
} else if (defer || waitForReady && !chunk && !handler) {
|
|
229
247
|
defer = true;
|
|
230
248
|
tasks.push(async () => {
|
|
231
|
-
|
|
249
|
+
let retryHandler = handler;
|
|
250
|
+
if (!retryHandler && waitForReady) {
|
|
251
|
+
await waitForReady;
|
|
252
|
+
retryHandler = resolve(false);
|
|
253
|
+
}
|
|
254
|
+
await run(retryHandler || await resolve());
|
|
232
255
|
});
|
|
233
256
|
} else {
|
|
234
257
|
const result = run(handler);
|
|
@@ -260,8 +283,7 @@ const processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = tr
|
|
|
260
283
|
for (let i = elements.length - 1; i >= 0; i--) {
|
|
261
284
|
if (captureHandlers[i]) {
|
|
262
285
|
dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);
|
|
263
|
-
|
|
264
|
-
if (!continuePropagation || ev.cancelBubble) {
|
|
286
|
+
if (ev.cancelBubble) {
|
|
265
287
|
queueTasks(tasks);
|
|
266
288
|
return;
|
|
267
289
|
}
|
|
@@ -270,8 +292,7 @@ const processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = tr
|
|
|
270
292
|
for (let i = 0; i < elements.length; i++) {
|
|
271
293
|
if (!captureHandlers[i]) {
|
|
272
294
|
dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);
|
|
273
|
-
|
|
274
|
-
if (!doBubble || ev.cancelBubble) {
|
|
295
|
+
if (!ev.bubbles || ev.cancelBubble) {
|
|
275
296
|
queueTasks(tasks);
|
|
276
297
|
return;
|
|
277
298
|
}
|
|
@@ -426,6 +447,6 @@ if (!_qwikEv?.roots) {
|
|
|
426
447
|
roots,
|
|
427
448
|
push: addEventOrRoot
|
|
428
449
|
};
|
|
429
|
-
addEventListener(doc,
|
|
450
|
+
addEventListener(doc, readyStateChange, processReadyStateChange);
|
|
430
451
|
processReadyStateChange();
|
|
431
452
|
}
|
package/dist/qwikloader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=document,t=window,
|
|
1
|
+
const e=document,t=window,n="w",r="wp",o="d",s="dp",i="e",c="ep",a="capture:",l="readystatechange",p="qready",u=new Set,q=new Set([e]),d=new Map;let h,f,b;const g=(e,t)=>Array.from(e.querySelectorAll(t)),m=e=>{const t=[];return q.forEach(n=>t.push(...g(n,e))),t},v=(e,t,n,r=!1,o=!1)=>e.addEventListener(t,n,{capture:r,passive:o}),y=e=>{z(e);const t=g(e,"[q\\:shadowroot]");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&y(n)}},w=e=>e&&"function"==typeof e.then,E=async e=>{for(let t=0;t<e.length;t++)await e[t]()},A=e=>{if(e.length){const t=()=>E(e);b=b?b.then(t,t):t()}},C=t=>{if(void 0===t._qwikjson_){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){t._qwikjson_=JSON.parse(n.textContent.replace(/\\x3C(\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},_=t=>{const n=t.getAttribute("q:instance");return"paused"===t.getAttribute("q:container")&&"loading"===e.readyState&&!e[p]?.[n]&&new Promise(t=>{const r=o=>{o.detail===n&&(e.removeEventListener(p,r),t())};v(e,l,t),v(e,p,r)})},k=(e,t)=>new CustomEvent(e,{detail:t}),S=(t,n)=>{e.dispatchEvent(k(t,n))},$=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),I=e=>e.replace(/-./g,e=>e[1].toUpperCase()),L=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:I(e.slice(t+1))}},N=e=>2===e.length,R=e=>e.charAt(0),T=e=>!!e&&1===e.nodeType,x=(e,t,n)=>e.hasAttribute(n)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),B=(t,n,r,o,s,i,c,a=!0)=>{const l={qBase:r,symbol:i,element:n,reqTime:c};if(!s){const n=(e["qFuncs_"+t.getAttribute("q:instance")]||[])[+i];if(!n&&a){const e=Error("sym:"+i);S("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const p=`${i}|${r}|${s}`,u=d.get(p);if(u)return u;const q=new URL(s,o).href,h=import(q);return C(t),h.then(e=>{const t=e[i];if(t)d.set(p,t),S("qsymbol",l);else{const e=Error(`${i} not in ${q}`);S("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{S("qerror",{importError:"async",error:e,...l}),console.error(e)})},U=(t,n,r,o,s,i=!0)=>{let c=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&n.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&n.stopPropagation());const a=t._qDispatch?.[r];if(a){if("function"==typeof a){const e=()=>a(n,t);if(c)o.push(async()=>{const t=e();w(t)&&await t});else{const t=e();w(t)&&(c=!0,o.push(()=>t))}}else if(a.length)for(let e=0;e<a.length;e++){const r=a[e];if(r){const e=()=>r(n,t);if(c)o.push(async()=>{const t=e();w(t)&&await t});else{const t=e();w(t)&&(c=!0,o.push(()=>t))}}}return}const l=t.getAttribute("q-"+r);if(l){const r=t.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])"),s=r.getAttribute("q:base"),i=new URL(s,e.baseURI),a=l.split("|"),p=_(r);for(let e=0;e<a.length;e++){const l=a[e],u=performance.now(),[q,d,h]=l.split("#"),f=e=>{if(e&&t.isConnected){const o=n=>{const o=_(r);if(o)return o.then(()=>f(e));S("qerror",{error:n,qBase:s,symbol:d,element:t,reqTime:u})};try{const r=e.call(h,n,t);if(w(r))return r.catch(o)}catch(e){return o(e)}}},b=(e=!0)=>B(r,t,s,i,q,d,u,e),g=p&&!q?b(!1):b();if(w(g))c=!0,o.push(()=>g.then(f));else if(c||p&&!q&&!g)c=!0,o.push(async()=>{let e=g;!e&&p&&(await p,e=b(!1)),await f(e||await b())});else{const e=f(g);w(e)&&(c=!0,o.push(()=>e))}}}},j=(e,t=i,n=!0)=>{const r=$(e.type),o=t+":"+r,s=a+r,c=[],l=[],p=[];let u=e.target;for(;u;)T(u)?(c.push(u),l.push(x(u,o,s)),u=u.parentElement):u=u.parentElement;for(let t=c.length-1;t>=0;t--)if(l[t]&&(U(c[t],e,o,p,r,n),e.cancelBubble))return void A(p);for(let t=0;t<c.length;t++)if(!l[t]&&(U(c[t],e,o,p,r,n),!e.bubbles||e.cancelBubble))return void A(p);A(p)},D=e=>j(e,c,!1),O=(e,t,n=!0)=>{const r=$(t.type),o=e+":"+r,s=m("[q-"+e+"\\:"+r+"]"),i=[];for(let e=0;e<s.length;e++){const c=s[e];U(c,t,o,i,r,n)}A(i)},P=e=>{O(o,e)},F=e=>{O(s,e,!1)},J=e=>{O(n,e)},M=e=>{O(r,e,!1)},Z=()=>{const n=e.readyState;if("interactive"==n||"complete"==n){if(f=1,q.forEach(y),u.has("d:qinit")){u.delete("d:qinit");const e=k("qinit"),t=m("[q-d\\:qinit]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];U(o,e,"d:qinit",n),o.removeAttribute("q-d:qinit")}A(n)}if(u.has("d:qidle")&&(u.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=k("qidle"),t=m("[q-d\\:qidle]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];U(o,e,"d:qidle",n),o.removeAttribute("q-d:qidle")}A(n)})),u.has("e:qvisible")){h||(h=new IntersectionObserver(e=>{const t=[];for(let n=0;n<e.length;n++){const r=e[n];r.isIntersecting&&(h.unobserve(r.target),U(r.target,k("qvisible",r),"e:qvisible",t))}A(t)}));const e=m("[q-e\\:qvisible]:not([q\\:observed])");for(let t=0;t<e.length;t++){const n=e[t];h.observe(n),n.setAttribute("q:observed","true")}}}},z=(...e)=>{for(let r=0;r<e.length;r++){const s=e[r];if("string"==typeof s){if(!u.has(s)){u.add(s);const{scope:e,eventName:r}=L(s),i=N(e),c=R(e);c===n?v(t,r,i?M:J,!0,i):q.forEach(e=>v(e,r,c===o?i?F:P:i?D:j,!0,i)),1!==f||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||Z()}}else q.has(s)||(u.forEach(e=>{const{scope:t,eventName:r}=L(e),i=N(t),c=R(t);c!==n&&v(s,r,c===o?i?F:P:i?D:j,!0,i)}),q.add(s))}},G=t._qwikEv;G?.roots||(Array.isArray(G)?z(...G):z("e:click","e:input"),t._qwikEv={events:u,roots:q,push:z},v(e,l,Z),Z());
|
package/dist/server.d.ts
CHANGED
|
@@ -98,6 +98,9 @@ declare interface JSXNode<T extends string | FunctionComponent | unknown = unkno
|
|
|
98
98
|
*/
|
|
99
99
|
declare type JSXOutput = JSXNode | string | number | boolean | null | undefined | JSXOutput[];
|
|
100
100
|
|
|
101
|
+
/** @public */
|
|
102
|
+
export declare type OutOfOrderStreaming = boolean;
|
|
103
|
+
|
|
101
104
|
/** @public */
|
|
102
105
|
export declare interface PrefetchResource {
|
|
103
106
|
url: string;
|
|
@@ -289,6 +292,7 @@ declare interface Signal<T = any> {
|
|
|
289
292
|
/** @public */
|
|
290
293
|
export declare interface StreamingOptions {
|
|
291
294
|
inOrder?: InOrderStreaming;
|
|
295
|
+
outOfOrder?: OutOfOrderStreaming;
|
|
292
296
|
}
|
|
293
297
|
|
|
294
298
|
/** @public */
|