@qwik.dev/core 2.0.0-beta.25 → 2.0.0-beta.27

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,128 +1,128 @@
1
- import { isBrowser } from "@qwik.dev/core/build";
2
- const doc = isBrowser ? document : void 0;
3
- const config = { t: 0, o: 25, l: 0.65 };
4
- const rel = isBrowser && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
1
+ import { isBrowser as Nn } from "@qwik.dev/core/build";
2
+ const si = Nn ? document : void 0;
3
+ const config = { t: 0, i: 25, S: 0.65 };
4
+ const oi = Nn && si.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
5
5
  const loadStart = Date.now();
6
- const isJSRegex = /\.[mc]?js$/;
6
+ const li = /\.[mc]?js$/;
7
7
  const BundleImportState_None = 0;
8
8
  const BundleImportState_Queued = 1;
9
9
  const BundleImportState_Preload = 2;
10
10
  const BundleImportState_Alias = 3;
11
11
  const BundleImportState_Loaded = 4;
12
- const bundles = /* @__PURE__ */ new Map();
12
+ const ui = /* @__PURE__ */ new Map();
13
13
  let queueDirty;
14
- let preloadCount = 0;
15
- const queue = [];
14
+ let fi = 0;
15
+ const ai = [];
16
16
  const log = (...e) => {
17
- console.log(`Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`, ...e);
17
+ console.log(`Preloader ${Date.now() - loadStart}ms ${fi}/${ai.length} queued>`, ...e);
18
18
  };
19
19
  const sortQueue = () => {
20
20
  if (queueDirty) {
21
- queue.sort((e, t) => e.u - t.u);
21
+ ai.sort((e, t) => e.Tt - t.Tt);
22
22
  queueDirty = 0;
23
23
  }
24
24
  };
25
- const trigger = () => {
26
- if (!queue.length) return;
25
+ const hi = () => {
26
+ if (!ai.length) return;
27
27
  sortQueue();
28
- while (queue.length) {
29
- const e = queue[0];
30
- const t = e.u;
28
+ while (ai.length) {
29
+ const e = ai[0];
30
+ const t = e.Tt;
31
31
  const o = 1 - t;
32
- const n = graph ? config.o : (
32
+ const n = graph ? config.i : (
33
33
  // While the graph is not available, we limit to 5 preloads
34
34
  5
35
35
  );
36
- if (o >= 0.99 || preloadCount < n) {
37
- queue.shift();
38
- preloadOne(e);
36
+ if (o >= 0.99 || fi < n) {
37
+ ai.shift();
38
+ di(e);
39
39
  } else break;
40
40
  }
41
- if (config.t && !queue.length) {
42
- const e = [...bundles.values()].filter((e2) => e2.i > BundleImportState_None);
43
- const t = e.reduce((e2, t2) => e2 + t2.p, 0);
44
- const o = e.reduce((e2, t2) => e2 + t2.$, 0);
45
- log(`>>>> done ${e.length}/${bundles.size} total: ${t}ms waited, ${o}ms loaded`);
41
+ if (config.t && !ai.length) {
42
+ const e = [...ui.values()].filter((e2) => e2.Nt > BundleImportState_None);
43
+ const t = e.reduce((e2, t2) => e2 + t2.Lt, 0);
44
+ const o = e.reduce((e2, t2) => e2 + t2.zt, 0);
45
+ log(`>>>> done ${e.length}/${ui.size} total: ${t}ms waited, ${o}ms loaded`);
46
46
  }
47
47
  };
48
- const preloadOne = (e) => {
49
- if (e.i >= BundleImportState_Preload) return;
50
- preloadCount++;
48
+ const di = (e) => {
49
+ if (e.Nt >= BundleImportState_Preload) return;
50
+ fi++;
51
51
  const t = Date.now();
52
- e.p = t - e.B;
53
- e.i = BundleImportState_Preload;
54
- config.t && log(`<< load ${Math.round((1 - e.u) * 100)}% after ${`${e.p}ms`}`, e.m);
55
- const o = doc.createElement("link");
56
- o.href = new URL(`${base}${e.m}`, doc.baseURI).toString();
57
- o.rel = rel;
52
+ e.Lt = t - e.Ft;
53
+ e.Nt = BundleImportState_Preload;
54
+ config.t && log(`<< load ${Math.round((1 - e.Tt) * 100)}% after ${`${e.Lt}ms`}`, e.It);
55
+ const o = si.createElement("link");
56
+ o.href = new URL(`${base}${e.It}`, si.baseURI).toString();
57
+ o.rel = oi;
58
58
  o.as = "script";
59
59
  o.onload = o.onerror = () => {
60
- preloadCount--;
60
+ fi--;
61
61
  const n = Date.now();
62
- e.$ = n - t;
63
- e.i = BundleImportState_Loaded;
64
- config.t && log(`>> done after ${e.$}ms`, e.m);
62
+ e.zt = n - t;
63
+ e.Nt = BundleImportState_Loaded;
64
+ config.t && log(`>> done after ${e.zt}ms`, e.It);
65
65
  o.remove();
66
- trigger();
66
+ hi();
67
67
  };
68
- doc.head.appendChild(o);
68
+ si.head.appendChild(o);
69
69
  };
70
- const adjustProbabilities = (e, t, o) => {
70
+ const pi = (e, t, o) => {
71
71
  if (o?.has(e)) return;
72
- const n = e.u;
73
- e.u = t;
74
- if (n - e.u < 0.01) return;
72
+ const n = e.Tt;
73
+ e.Tt = t;
74
+ if (n - e.Tt < 0.01) return;
75
75
  if (
76
76
  // don't queue until we have initialized the preloader
77
- base != null && e.i < BundleImportState_Preload
77
+ base != null && e.Nt < BundleImportState_Preload
78
78
  ) {
79
- if (e.i === BundleImportState_None) {
80
- e.i = BundleImportState_Queued;
81
- queue.push(e);
82
- config.t && log(`queued ${Math.round((1 - e.u) * 100)}%`, e.m);
79
+ if (e.Nt === BundleImportState_None) {
80
+ e.Nt = BundleImportState_Queued;
81
+ ai.push(e);
82
+ config.t && log(`queued ${Math.round((1 - e.Tt) * 100)}%`, e.It);
83
83
  }
84
84
  queueDirty = 1;
85
85
  }
86
- if (e.h) {
86
+ if (e.Mt) {
87
87
  o ||= /* @__PURE__ */ new Set();
88
88
  o.add(e);
89
- const t2 = 1 - e.u;
90
- for (const n2 of e.h) {
91
- const e2 = getBundle(n2.m);
92
- if (e2.u === 0) continue;
89
+ const t2 = 1 - e.Tt;
90
+ for (const n2 of e.Mt) {
91
+ const e2 = ci(n2.It);
92
+ if (e2.Tt === 0) continue;
93
93
  let r;
94
- if (t2 === 1 || t2 >= 0.99 && depsCount < 100) {
95
- depsCount++;
96
- r = Math.min(0.01, 1 - n2.S);
94
+ if (t2 === 1 || t2 >= 0.99 && yi < 100) {
95
+ yi++;
96
+ r = Math.min(0.01, 1 - n2.Dt);
97
97
  } else {
98
- const o2 = 1 - n2.S * t2;
99
- const s = n2.q;
98
+ const o2 = 1 - n2.Dt * t2;
99
+ const s = n2.Wt;
100
100
  const l = o2 / s;
101
- r = Math.max(0.02, e2.u * l);
102
- n2.q = l;
101
+ r = Math.max(0.02, e2.Tt * l);
102
+ n2.Wt = l;
103
103
  }
104
- adjustProbabilities(e2, r, o);
104
+ pi(e2, r, o);
105
105
  }
106
106
  }
107
107
  };
108
- const handleBundle = (e, t) => {
109
- const o = getBundle(e);
110
- if (o && o.u > t) adjustProbabilities(o, t);
108
+ const $i = (e, t) => {
109
+ const o = ci(e);
110
+ if (o && o.Tt > t) pi(o, t);
111
111
  };
112
- let depsCount;
112
+ let yi;
113
113
  const preload = (e, t) => {
114
114
  if (!e?.length) return;
115
- depsCount = 0;
115
+ yi = 0;
116
116
  let o = t ? 1 - t : 0.4;
117
117
  if (Array.isArray(e)) for (let t2 = e.length - 1; t2 >= 0; t2--) {
118
118
  const n = e[t2];
119
119
  if (typeof n === "number") o = 1 - n / 10;
120
- else handleBundle(n, o);
120
+ else $i(n, o);
121
121
  }
122
- else handleBundle(e, o);
123
- if (isBrowser) trigger();
122
+ else $i(e, o);
123
+ if (Nn) hi();
124
124
  };
125
- if (isBrowser) document.addEventListener("qsymbol", (e) => {
125
+ if (Nn) document.addEventListener("qsymbol", (e) => {
126
126
  const { symbol: t, href: o } = e.detail;
127
127
  if (o) {
128
128
  const e2 = t.slice(t.lastIndexOf("_") + 1);
@@ -131,7 +131,7 @@ if (isBrowser) document.addEventListener("qsymbol", (e) => {
131
131
  });
132
132
  let base;
133
133
  let graph;
134
- const makeBundle = (e, t) => ({ m: e, i: isJSRegex.test(e) ? BundleImportState_None : BundleImportState_Alias, h: t, u: 1, B: Date.now(), p: 0, $: 0 });
134
+ const makeBundle = (e, t) => ({ It: e, Nt: li.test(e) ? BundleImportState_None : BundleImportState_Alias, Mt: t, Tt: 1, Ft: Date.now(), Lt: 0, zt: 0 });
135
135
  const parseBundleGraph = (e) => {
136
136
  const t = /* @__PURE__ */ new Map();
137
137
  let o = 0;
@@ -142,15 +142,15 @@ const parseBundleGraph = (e) => {
142
142
  let l = 1;
143
143
  while (s = e[o], typeof s === "number") {
144
144
  if (s < 0) l = -s / 10;
145
- else r.push({ m: e[s], S: l, q: 1 });
145
+ else r.push({ It: e[s], Dt: l, Wt: 1 });
146
146
  o++;
147
147
  }
148
148
  t.set(n, r);
149
149
  }
150
150
  return t;
151
151
  };
152
- const getBundle = (e) => {
153
- let t = bundles.get(e);
152
+ const ci = (e) => {
153
+ let t = ui.get(e);
154
154
  if (!t) {
155
155
  let o;
156
156
  if (graph) {
@@ -159,37 +159,37 @@ const getBundle = (e) => {
159
159
  if (!o.length) o = void 0;
160
160
  }
161
161
  t = makeBundle(e, o);
162
- bundles.set(e, t);
162
+ ui.set(e, t);
163
163
  }
164
164
  return t;
165
165
  };
166
166
  const loadBundleGraph = (e, t, o) => {
167
167
  if (o) {
168
168
  if ("d" in o) config.t = !!o.d;
169
- if ("P" in o) config.o = o["P"];
170
- if ("Q" in o) config.l = 1 - o["Q"];
169
+ if ("P" in o) config.i = o["P"];
170
+ if ("Q" in o) config.S = 1 - o["Q"];
171
171
  }
172
- if (!isBrowser || e == null) return;
172
+ if (!Nn || e == null) return;
173
173
  base = e;
174
174
  if (t) t.then((e2) => e2.text()).then((e2) => {
175
175
  graph = parseBundleGraph(JSON.parse(e2));
176
176
  const t2 = [];
177
177
  for (const [e3, o2] of graph.entries()) {
178
- const n = getBundle(e3);
179
- n.h = o2;
180
- if (n.u < 1) {
181
- t2.push([n, n.u]);
182
- n.u = 1;
178
+ const n = ci(e3);
179
+ n.Mt = o2;
180
+ if (n.Tt < 1) {
181
+ t2.push([n, n.Tt]);
182
+ n.Tt = 1;
183
183
  }
184
184
  }
185
185
  config.t && log(`parseBundleGraph got ${graph.size} bundles, adjusting ${t2.length}`);
186
- for (const [e3, o2] of t2) adjustProbabilities(e3, o2);
187
- trigger();
186
+ for (const [e3, o2] of t2) pi(e3, o2);
187
+ hi();
188
188
  }).catch(console.warn);
189
189
  };
190
190
  export {
191
191
  parseBundleGraph as g,
192
- handleBundle as h,
192
+ $i as h,
193
193
  loadBundleGraph as l,
194
194
  preload as p
195
195
  };
package/dist/server.mjs CHANGED
@@ -1,16 +1,10 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/server 2.0.0-beta.25-dev+2677279
3
+ * @qwik.dev/core/server 2.0.0-beta.27-dev+7fc6984
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
7
7
  */
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
8
 
15
9
  // packages/qwik/src/server/index.ts
16
10
  import { setPlatform as setPlatform2 } from "@qwik.dev/core";
@@ -26,12 +20,13 @@ import { isDev as isDev2 } from "@qwik.dev/core/build";
26
20
  import { isDev } from "@qwik.dev/core/build";
27
21
 
28
22
  // packages/qwik/src/core/shared/utils/qdev.ts
29
- var qDev = globalThis.qDev !== false;
30
- var qInspector = globalThis.qInspector === true;
31
- var qSerialize = globalThis.qSerialize !== false;
32
- var qDynamicPlatform = globalThis.qDynamicPlatform !== false;
33
- var qTest = globalThis.qTest === true;
34
- var qRuntimeQrl = globalThis.qRuntimeQrl === true;
23
+ var g = globalThis;
24
+ var qDev = g.qDev !== false;
25
+ var qInspector = g.qInspector === true;
26
+ var qSerialize = g.qSerialize !== false;
27
+ var qDynamicPlatform = g.qDynamicPlatform !== false;
28
+ var qTest = g.qTest === true;
29
+ var qRuntimeQrl = g.qRuntimeQrl === true;
35
30
 
36
31
  // packages/qwik/src/core/shared/utils/log.ts
37
32
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -145,7 +140,7 @@ var codeToText = (code, ...parts) => {
145
140
  // 4
146
141
  "QRL is not a function",
147
142
  // 5
148
- "Dynamic import not found",
143
+ "Dynamic import {{0}} not found",
149
144
  // 6
150
145
  "Unknown type argument",
151
146
  // 7
@@ -1174,15 +1169,7 @@ function createPlatform(opts, resolvedManifest) {
1174
1169
  if (regSym) {
1175
1170
  return regSym;
1176
1171
  }
1177
- let modulePath = String(url);
1178
- if (!modulePath.endsWith(".js")) {
1179
- modulePath += ".js";
1180
- }
1181
- const module = __require(modulePath);
1182
- if (!(symbolName in module)) {
1183
- throw new Error(`Q-ERROR: missing symbol '${symbolName}' in module '${modulePath}'.`);
1184
- }
1185
- return module[symbolName];
1172
+ throw qError(6 /* dynamicImportFailed */, [symbolName]);
1186
1173
  },
1187
1174
  raf: () => {
1188
1175
  console.error("server can not rerender");
@@ -1232,7 +1219,7 @@ function getBuildBase(opts) {
1232
1219
  return `${import.meta.env.BASE_URL || "/"}build/`;
1233
1220
  }
1234
1221
  var versions = {
1235
- qwik: "2.0.0-beta.25-dev+2677279",
1222
+ qwik: "2.0.0-beta.27-dev+7fc6984",
1236
1223
  qwikDom: "2.1.19"
1237
1224
  };
1238
1225
 
@@ -2344,7 +2331,7 @@ var SSRContainer = class extends _SharedContainer {
2344
2331
  }
2345
2332
  $noScriptHere$ = 0;
2346
2333
  /** Renders opening tag for DOM element */
2347
- openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null) {
2334
+ openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
2348
2335
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
2349
2336
  if (
2350
2337
  // don't append qwik loader before qwik style elements
@@ -2371,7 +2358,14 @@ var SSRContainer = class extends _SharedContainer {
2371
2358
  this.write(elementName);
2372
2359
  const lastNode = this.getOrCreateLastNode();
2373
2360
  if (varAttrs) {
2374
- innerHTML = this.writeAttrs(elementName, varAttrs, false, styleScopedId, currentFile);
2361
+ innerHTML = this.writeAttrs(
2362
+ elementName,
2363
+ varAttrs,
2364
+ false,
2365
+ styleScopedId,
2366
+ currentFile,
2367
+ hasMovedCaptures
2368
+ );
2375
2369
  }
2376
2370
  this.write(" " + Q_PROPS_SEPARATOR);
2377
2371
  if (key !== null) {
@@ -2380,7 +2374,14 @@ var SSRContainer = class extends _SharedContainer {
2380
2374
  this.write(EMPTY_ATTR);
2381
2375
  }
2382
2376
  if (constAttrs && !isObjectEmpty(constAttrs)) {
2383
- innerHTML = this.writeAttrs(elementName, constAttrs, true, styleScopedId, currentFile) || innerHTML;
2377
+ innerHTML = this.writeAttrs(
2378
+ elementName,
2379
+ constAttrs,
2380
+ true,
2381
+ styleScopedId,
2382
+ currentFile,
2383
+ hasMovedCaptures
2384
+ ) || innerHTML;
2384
2385
  }
2385
2386
  this.write(GT);
2386
2387
  if (lastNode) {
@@ -2992,9 +2993,8 @@ var SSRContainer = class extends _SharedContainer {
2992
2993
  this.write(element);
2993
2994
  }
2994
2995
  }
2995
- writeAttrs(tag, attrs, isConst, styleScopedId, currentFile) {
2996
+ writeAttrs(tag, attrs, isConst, styleScopedId, currentFile, hasMovedCaptures) {
2996
2997
  let innerHTML = void 0;
2997
- let isLoopElement = null;
2998
2998
  for (let key in attrs) {
2999
2999
  let value = attrs[key];
3000
3000
  if (isSSRUnsafeAttr(key)) {
@@ -3004,10 +3004,7 @@ var SSRContainer = class extends _SharedContainer {
3004
3004
  continue;
3005
3005
  }
3006
3006
  if (isHtmlAttributeAnEventName(key)) {
3007
- if (isLoopElement === null) {
3008
- isLoopElement = attributesContainsIterationProp(attrs);
3009
- }
3010
- value = _setEvent(this.serializationCtx, key, value, isLoopElement);
3007
+ value = _setEvent(this.serializationCtx, key, value, hasMovedCaptures);
3011
3008
  } else if (key === "ref") {
3012
3009
  const lastNode = this.getOrCreateLastNode();
3013
3010
  if (isSignal(value)) {
@@ -3096,9 +3093,6 @@ var isQwikStyleElement = (tag, attrs) => {
3096
3093
  }
3097
3094
  return false;
3098
3095
  };
3099
- var attributesContainsIterationProp = (attrs) => {
3100
- return Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_SINGLE) || Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_MULTI);
3101
- };
3102
3096
  function newTagError(text) {
3103
3097
  return qError(12 /* tagError */, [text]);
3104
3098
  }