@qwik.dev/core 2.0.0-beta.35 → 2.0.0-beta.37

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.
@@ -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);
@@ -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";performance.now();const i=/\.[mc]?js$/;const f=1e3/60;const l=0;const a=1;const $=2;const u=3;const m=4;const d=/* @__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=m;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=d.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);d.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};
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};
@@ -7,9 +7,12 @@ const passiveDocumentPrefix = "dp";
7
7
  const elementPrefix = "e";
8
8
  const passiveElementPrefix = "ep";
9
9
  const capturePrefix = "capture:";
10
+ const readyStateChange = "readystatechange";
11
+ const QwikEvContainerReady = 0;
10
12
  const events = /* @__PURE__ */ new Set();
11
13
  const roots = /* @__PURE__ */ new Set([doc]);
12
14
  const symbols = /* @__PURE__ */ new Map();
15
+ const readyContainers = {};
13
16
  let observer;
14
17
  let hasInitialized;
15
18
  let queuedTasks;
@@ -56,6 +59,21 @@ const resolveContainer = (containerEl) => {
56
59
  }
57
60
  }
58
61
  };
62
+ const markContainerReady = (hash) => {
63
+ readyContainers[hash] = 1;
64
+ emitEvent(readyStateChange);
65
+ };
66
+ const waitForContainerReady = (container) => {
67
+ const hash = container.getAttribute("q:instance");
68
+ return container.getAttribute("q:container") === "paused" && doc.readyState === "loading" && !readyContainers[hash] && new Promise((resolve) => {
69
+ const ready = () => {
70
+ if (doc.readyState !== "loading" || readyContainers[hash]) {
71
+ resolve();
72
+ }
73
+ };
74
+ addEventListener(doc, readyStateChange, ready);
75
+ });
76
+ };
59
77
  const createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });
60
78
  const emitEvent = (eventName, detail) => {
61
79
  doc.dispatchEvent(createEvent(eventName, detail));
@@ -74,17 +92,16 @@ const isPassiveScope = (scope) => scope.length === 2;
74
92
  const getRootScope = (scope) => scope.charAt(0);
75
93
  const isElementNode = (node) => !!node && node.nodeType === 1;
76
94
  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) => {
95
+ const resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime, reportSyncError = true) => {
78
96
  const eventData = {
79
97
  qBase,
80
98
  symbol,
81
99
  element,
82
100
  reqTime
83
101
  };
84
- if (chunk === "") {
85
- const hash = container.getAttribute("q:instance");
86
- const handler2 = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];
87
- if (!handler2) {
102
+ if (!chunk) {
103
+ const handler2 = (doc["qFuncs_" + container.getAttribute("q:instance")] || [])[+symbol];
104
+ if (!handler2 && reportSyncError) {
88
105
  const error = new Error("sym:" + symbol);
89
106
  emitEvent("qerror", {
90
107
  importError: "sync",
@@ -194,26 +211,14 @@ const dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDe
194
211
  const qBase = container.getAttribute("q:base");
195
212
  const base = new URL(qBase, doc.baseURI);
196
213
  const qrls = attrValue.split("|");
214
+ const waitForReady = waitForContainerReady(container);
197
215
  for (let i = 0; i < qrls.length; i++) {
198
216
  const qrl = qrls[i];
199
217
  const reqTime = performance.now();
200
218
  const [chunk, symbol, capturedIds] = qrl.split("#");
201
219
  const run = (handler2) => {
202
220
  if (handler2 && element.isConnected) {
203
- try {
204
- const result = handler2.call(capturedIds, ev, element);
205
- if (isPromise(result)) {
206
- return result.catch((error) => {
207
- emitEvent("qerror", {
208
- error,
209
- qBase,
210
- symbol,
211
- element,
212
- reqTime
213
- });
214
- });
215
- }
216
- } catch (error) {
221
+ const onError = (error) => {
217
222
  emitEvent("qerror", {
218
223
  error,
219
224
  qBase,
@@ -221,14 +226,32 @@ const dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDe
221
226
  element,
222
227
  reqTime
223
228
  });
229
+ };
230
+ try {
231
+ const result = handler2.call(capturedIds, ev, element);
232
+ if (isPromise(result)) {
233
+ return result.catch(onError);
234
+ }
235
+ } catch (error) {
236
+ return onError(error);
224
237
  }
225
238
  }
226
239
  };
227
- const handler = resolveHandler(container, element, qBase, base, chunk, symbol, reqTime);
228
- if (defer || isPromise(handler)) {
240
+ const resolve = (reportSyncError = true) => resolveHandler(container, element, qBase, base, chunk, symbol, reqTime, reportSyncError);
241
+ const handler = waitForReady ? void 0 : resolve();
242
+ if (waitForReady) {
243
+ defer = true;
244
+ tasks.push(async () => {
245
+ await waitForReady;
246
+ await run(await resolve(false) || await resolve());
247
+ });
248
+ } else if (isPromise(handler)) {
249
+ defer = true;
250
+ tasks.push(() => handler.then(run));
251
+ } else if (defer) {
229
252
  defer = true;
230
253
  tasks.push(async () => {
231
- await run(isPromise(handler) ? await handler : handler);
254
+ await run(handler || 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
- const continuePropagation = !ev.cancelBubble;
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
- const doBubble = ev.bubbles && !ev.cancelBubble;
274
- if (!doBubble || ev.cancelBubble) {
295
+ if (!ev.bubbles || ev.cancelBubble) {
275
296
  queueTasks(tasks);
276
297
  return;
277
298
  }
@@ -364,7 +385,9 @@ const processReadyStateChange = () => {
364
385
  const addEventOrRoot = (...eventNames) => {
365
386
  for (let i = 0; i < eventNames.length; i++) {
366
387
  const eventNameOrRoot = eventNames[i];
367
- if (typeof eventNameOrRoot === "string") {
388
+ if (eventNameOrRoot === QwikEvContainerReady) {
389
+ markContainerReady(eventNames[++i]);
390
+ } else if (typeof eventNameOrRoot === "string") {
368
391
  if (!events.has(eventNameOrRoot)) {
369
392
  events.add(eventNameOrRoot);
370
393
  const { scope, eventName } = parseKebabEvent(eventNameOrRoot);
@@ -426,6 +449,6 @@ if (!_qwikEv?.roots) {
426
449
  roots,
427
450
  push: addEventOrRoot
428
451
  };
429
- addEventListener(doc, "readystatechange", processReadyStateChange);
452
+ addEventListener(doc, readyStateChange, processReadyStateChange);
430
453
  processReadyStateChange();
431
454
  }
@@ -1 +1 @@
1
- const e=document,t=window,r="w",n="wp",o="d",s="dp",i="e",c="ep",l="capture:",a=new Set,p=new Set([e]),q=new Map;let u,f,h;const d=(e,t)=>Array.from(e.querySelectorAll(t)),b=e=>{const t=[];return p.forEach(r=>t.push(...d(r,e))),t},m=(e,t,r,n=!1,o=!1)=>e.addEventListener(t,r,{capture:n,passive:o}),g=e=>{J(e);const t=d(e,"[q\\:shadowroot]");for(let e=0;e<t.length;e++){const r=t[e].shadowRoot;r&&g(r)}},v=e=>e&&"function"==typeof e.then,y=async e=>{for(let t=0;t<e.length;t++)await e[t]()},w=e=>{if(e.length){const t=()=>y(e);h=h?h.then(t,t):t()}},E=t=>{if(void 0===t._qwikjson_){let r=(t===e.documentElement?e.body:t).lastElementChild;for(;r;){if("SCRIPT"===r.tagName&&"qwik/json"===r.getAttribute("type")){t._qwikjson_=JSON.parse(r.textContent.replace(/\\x3C(\/?script)/gi,"<$1"));break}r=r.previousElementSibling}}},A=(e,t)=>new CustomEvent(e,{detail:t}),C=(t,r)=>{e.dispatchEvent(A(t,r))},_=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),k=e=>e.replace(/-./g,e=>e[1].toUpperCase()),B=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:k(e.slice(t+1))}},S=e=>2===e.length,I=e=>e.charAt(0),N=e=>!!e&&1===e.nodeType,T=(e,t,r)=>e.hasAttribute(r)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),$=(t,r,n,o,s,i,c)=>{const l={qBase:n,symbol:i,element:r,reqTime:c};if(""===s){const r=t.getAttribute("q:instance"),n=(e["qFuncs_"+r]||[])[Number.parseInt(i)];if(!n){const e=Error("sym:"+i);C("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const a=`${i}|${n}|${s}`,p=q.get(a);if(p)return p;const u=new URL(s,o).href,f=import(u);return E(t),f.then(e=>{const t=e[i];if(t)q.set(a,t),C("qsymbol",l);else{const e=Error(`${i} not in ${u}`);C("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{C("qerror",{importError:"async",error:e,...l}),console.error(e)})},R=(t,r,n,o,s,i=!0)=>{let c=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&r.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&r.stopPropagation());const l=t._qDispatch?.[n];if(l){if("function"==typeof l){const e=()=>l(r,t);if(c)o.push(async()=>{const t=e();v(t)&&await t});else{const t=e();v(t)&&(c=!0,o.push(()=>t))}}else if(l.length)for(let e=0;e<l.length;e++){const n=l[e];if(n){const e=()=>n(r,t);if(c)o.push(async()=>{const t=e();v(t)&&await t});else{const t=e();v(t)&&(c=!0,o.push(()=>t))}}}return}const a=t.getAttribute("q-"+n);if(a){const n=t.closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])"),s=n.getAttribute("q:base"),i=new URL(s,e.baseURI),l=a.split("|");for(let e=0;e<l.length;e++){const a=l[e],p=performance.now(),[q,u,f]=a.split("#"),h=e=>{if(e&&t.isConnected)try{const n=e.call(f,r,t);if(v(n))return n.catch(e=>{C("qerror",{error:e,qBase:s,symbol:u,element:t,reqTime:p})})}catch(e){C("qerror",{error:e,qBase:s,symbol:u,element:t,reqTime:p})}},d=$(n,t,s,i,q,u,p);if(c||v(d))c=!0,o.push(async()=>{await h(v(d)?await d:d)});else{const e=h(d);v(e)&&(c=!0,o.push(()=>e))}}}},x=(e,t=i,r=!0)=>{const n=_(e.type),o=t+":"+n,s=l+n,c=[],a=[],p=[];let q=e.target;for(;q;)N(q)?(c.push(q),a.push(T(q,o,s)),q=q.parentElement):q=q.parentElement;for(let t=c.length-1;t>=0;t--)if(a[t]&&(R(c[t],e,o,p,n,r),e.cancelBubble||e.cancelBubble))return void w(p);for(let t=0;t<c.length;t++)if(!a[t]&&(R(c[t],e,o,p,n,r),!e.bubbles||e.cancelBubble||e.cancelBubble))return void w(p);w(p)},L=e=>x(e,c,!1),U=(e,t,r=!0)=>{const n=_(t.type),o=e+":"+n,s=b("[q-"+e+"\\:"+n+"]"),i=[];for(let e=0;e<s.length;e++){const c=s[e];R(c,t,o,i,n,r)}w(i)},j=e=>{U(o,e)},D=e=>{U(s,e,!1)},O=e=>{U(r,e)},P=e=>{U(n,e,!1)},F=()=>{const r=e.readyState;if("interactive"==r||"complete"==r){if(f=1,p.forEach(g),a.has("d:qinit")){a.delete("d:qinit");const e=A("qinit"),t=b("[q-d\\:qinit]"),r=[];for(let n=0;n<t.length;n++){const o=t[n];R(o,e,"d:qinit",r),o.removeAttribute("q-d:qinit")}w(r)}if(a.has("d:qidle")&&(a.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=A("qidle"),t=b("[q-d\\:qidle]"),r=[];for(let n=0;n<t.length;n++){const o=t[n];R(o,e,"d:qidle",r),o.removeAttribute("q-d:qidle")}w(r)})),a.has("e:qvisible")){u||(u=new IntersectionObserver(e=>{const t=[];for(let r=0;r<e.length;r++){const n=e[r];n.isIntersecting&&(u.unobserve(n.target),R(n.target,A("qvisible",n),"e:qvisible",t))}w(t)}));const e=b("[q-e\\:qvisible]:not([q\\:observed])");for(let t=0;t<e.length;t++){const r=e[t];u.observe(r),r.setAttribute("q:observed","true")}}}},J=(...e)=>{for(let n=0;n<e.length;n++){const s=e[n];if("string"==typeof s){if(!a.has(s)){a.add(s);const{scope:e,eventName:n}=B(s),i=S(e),c=I(e);c===r?m(t,n,i?P:O,!0,i):p.forEach(e=>m(e,n,c===o?i?D:j:i?L:x,!0,i)),1!==f||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||F()}}else p.has(s)||(a.forEach(e=>{const{scope:t,eventName:n}=B(e),i=S(t),c=I(t);c!==r&&m(s,n,c===o?i?D:j:i?L:x,!0,i)}),p.add(s))}},M=t._qwikEv;M?.roots||(Array.isArray(M)?J(...M):J("e:click","e:input"),t._qwikEv={events:a,roots:p,push:J},m(e,"readystatechange",F),F());
1
+ const e=document,t=window,n="w",r="wp",o="d",s="dp",i="e",a="ep",c="capture:",l="readystatechange",p=0,u=new Set,d=new Set([e]),f=new Map,h={};let q,b,g;const m=(e,t)=>Array.from(e.querySelectorAll(t)),v=e=>{const t=[];return d.forEach(n=>t.push(...m(n,e))),t},w=(e,t,n,r=!1,o=!1)=>e.addEventListener(t,n,{capture:r,passive:o}),y=e=>{H(e);const t=m(e,"[q\\:shadowroot]");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&y(n)}},A=e=>e&&"function"==typeof e.then,E=async e=>{for(let t=0;t<e.length;t++)await e[t]()},C=e=>{if(e.length){const t=()=>E(e);g=g?g.then(t,t):t()}},S=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}}},_=e=>{h[e]=1,I(l)},k=t=>{const n=t.getAttribute("q:instance");return"paused"===t.getAttribute("q:container")&&"loading"===e.readyState&&!h[n]&&new Promise(t=>{w(e,l,()=>{("loading"!==e.readyState||h[n])&&t()})})},$=(e,t)=>new CustomEvent(e,{detail:t}),I=(t,n)=>{e.dispatchEvent($(t,n))},N=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),R=e=>e.replace(/-./g,e=>e[1].toUpperCase()),T=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:R(e.slice(t+1))}},x=e=>2===e.length,B=e=>e.charAt(0),L=e=>!!e&&1===e.nodeType,U=(e,t,n)=>e.hasAttribute(n)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),j=(t,n,r,o,s,i,a,c=!0)=>{const l={qBase:r,symbol:i,element:n,reqTime:a};if(!s){const n=(e["qFuncs_"+t.getAttribute("q:instance")]||[])[+i];if(!n&&c){const e=Error("sym:"+i);I("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const p=`${i}|${r}|${s}`,u=f.get(p);if(u)return u;const d=new URL(s,o).href,h=import(d);return S(t),h.then(e=>{const t=e[i];if(t)f.set(p,t),I("qsymbol",l);else{const e=Error(`${i} not in ${d}`);I("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{I("qerror",{importError:"async",error:e,...l}),console.error(e)})},D=(t,n,r,o,s,i=!0)=>{let a=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&n.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&n.stopPropagation());const c=t._qDispatch?.[r];if(c){if("function"==typeof c){const e=()=>c(n,t);if(a)o.push(async()=>{const t=e();A(t)&&await t});else{const t=e();A(t)&&(a=!0,o.push(()=>t))}}else if(c.length)for(let e=0;e<c.length;e++){const r=c[e];if(r){const e=()=>r(n,t);if(a)o.push(async()=>{const t=e();A(t)&&await t});else{const t=e();A(t)&&(a=!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),c=l.split("|"),p=k(r);for(let e=0;e<c.length;e++){const l=c[e],u=performance.now(),[d,f,h]=l.split("#"),q=e=>{if(e&&t.isConnected){const r=e=>{I("qerror",{error:e,qBase:s,symbol:f,element:t,reqTime:u})};try{const o=e.call(h,n,t);if(A(o))return o.catch(r)}catch(e){return r(e)}}},b=(e=!0)=>j(r,t,s,i,d,f,u,e),g=p?void 0:b();if(p)a=!0,o.push(async()=>{await p,await q(await b(!1)||await b())});else if(A(g))a=!0,o.push(()=>g.then(q));else if(a)a=!0,o.push(async()=>{await q(g||await b())});else{const e=q(g);A(e)&&(a=!0,o.push(()=>e))}}}},O=(e,t=i,n=!0)=>{const r=N(e.type),o=t+":"+r,s=c+r,a=[],l=[],p=[];let u=e.target;for(;u;)L(u)?(a.push(u),l.push(U(u,o,s)),u=u.parentElement):u=u.parentElement;for(let t=a.length-1;t>=0;t--)if(l[t]&&(D(a[t],e,o,p,r,n),e.cancelBubble))return void C(p);for(let t=0;t<a.length;t++)if(!l[t]&&(D(a[t],e,o,p,r,n),!e.bubbles||e.cancelBubble))return void C(p);C(p)},P=e=>O(e,a,!1),F=(e,t,n=!0)=>{const r=N(t.type),o=e+":"+r,s=v("[q-"+e+"\\:"+r+"]"),i=[];for(let e=0;e<s.length;e++){const a=s[e];D(a,t,o,i,r,n)}C(i)},J=e=>{F(o,e)},M=e=>{F(s,e,!1)},Z=e=>{F(n,e)},z=e=>{F(r,e,!1)},G=()=>{const n=e.readyState;if("interactive"==n||"complete"==n){if(b=1,d.forEach(y),u.has("d:qinit")){u.delete("d:qinit");const e=$("qinit"),t=v("[q-d\\:qinit]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];D(o,e,"d:qinit",n),o.removeAttribute("q-d:qinit")}C(n)}if(u.has("d:qidle")&&(u.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=$("qidle"),t=v("[q-d\\:qidle]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];D(o,e,"d:qidle",n),o.removeAttribute("q-d:qidle")}C(n)})),u.has("e:qvisible")){q||(q=new IntersectionObserver(e=>{const t=[];for(let n=0;n<e.length;n++){const r=e[n];r.isIntersecting&&(q.unobserve(r.target),D(r.target,$("qvisible",r),"e:qvisible",t))}C(t)}));const e=v("[q-e\\:qvisible]:not([q\\:observed])");for(let t=0;t<e.length;t++){const n=e[t];q.observe(n),n.setAttribute("q:observed","true")}}}},H=(...e)=>{for(let r=0;r<e.length;r++){const s=e[r];if(0===s)_(e[++r]);else if("string"==typeof s){if(!u.has(s)){u.add(s);const{scope:e,eventName:r}=T(s),i=x(e),a=B(e);a===n?w(t,r,i?z:Z,!0,i):d.forEach(e=>w(e,r,a===o?i?M:J:i?P:O,!0,i)),1!==b||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||G()}}else d.has(s)||(u.forEach(e=>{const{scope:t,eventName:r}=T(e),i=x(t),a=B(t);a!==n&&w(s,r,a===o?i?M:J:i?P:O,!0,i)}),d.add(s))}},K=t._qwikEv;K?.roots||(Array.isArray(K)?H(...K):H("e:click","e:input"),t._qwikEv={events:u,roots:d,push:H},w(e,l,G),G());
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 */