@qwik.dev/core 2.0.0-beta.19 → 2.0.0-beta.21

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