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

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 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";
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";
5
5
  const loadStart = Date.now();
6
- const li = /\.[mc]?js$/;
6
+ const isJSRegex = /\.[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 ui = /* @__PURE__ */ new Map();
12
+ const bundles = /* @__PURE__ */ new Map();
13
13
  let queueDirty;
14
- let fi = 0;
15
- const ai = [];
14
+ let preloadCount = 0;
15
+ const queue = [];
16
16
  const log = (...e) => {
17
- console.log(`Preloader ${Date.now() - loadStart}ms ${fi}/${ai.length} queued>`, ...e);
17
+ console.log(`Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`, ...e);
18
18
  };
19
19
  const sortQueue = () => {
20
20
  if (queueDirty) {
21
- ai.sort((e, t) => e.Tt - t.Tt);
21
+ queue.sort((e, t) => e.u - t.u);
22
22
  queueDirty = 0;
23
23
  }
24
24
  };
25
- const hi = () => {
26
- if (!ai.length) return;
25
+ const trigger = () => {
26
+ if (!queue.length) return;
27
27
  sortQueue();
28
- while (ai.length) {
29
- const e = ai[0];
30
- const t = e.Tt;
28
+ while (queue.length) {
29
+ const e = queue[0];
30
+ const t = e.u;
31
31
  const o = 1 - t;
32
- const n = graph ? config.i : (
32
+ const n = graph ? config.o : (
33
33
  // While the graph is not available, we limit to 5 preloads
34
34
  5
35
35
  );
36
- if (o >= 0.99 || fi < n) {
37
- ai.shift();
38
- di(e);
36
+ if (o >= 0.99 || preloadCount < n) {
37
+ queue.shift();
38
+ preloadOne(e);
39
39
  } else break;
40
40
  }
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`);
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`);
46
46
  }
47
47
  };
48
- const di = (e) => {
49
- if (e.Nt >= BundleImportState_Preload) return;
50
- fi++;
48
+ const preloadOne = (e) => {
49
+ if (e.i >= BundleImportState_Preload) return;
50
+ preloadCount++;
51
51
  const t = Date.now();
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;
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;
58
58
  o.as = "script";
59
59
  o.onload = o.onerror = () => {
60
- fi--;
60
+ preloadCount--;
61
61
  const n = Date.now();
62
- e.zt = n - t;
63
- e.Nt = BundleImportState_Loaded;
64
- config.t && log(`>> done after ${e.zt}ms`, e.It);
62
+ e.$ = n - t;
63
+ e.i = BundleImportState_Loaded;
64
+ config.t && log(`>> done after ${e.$}ms`, e.m);
65
65
  o.remove();
66
- hi();
66
+ trigger();
67
67
  };
68
- si.head.appendChild(o);
68
+ doc.head.appendChild(o);
69
69
  };
70
- const pi = (e, t, o) => {
70
+ const adjustProbabilities = (e, t, o) => {
71
71
  if (o?.has(e)) return;
72
- const n = e.Tt;
73
- e.Tt = t;
74
- if (n - e.Tt < 0.01) return;
72
+ const n = e.u;
73
+ e.u = t;
74
+ if (n - e.u < 0.01) return;
75
75
  if (
76
76
  // don't queue until we have initialized the preloader
77
- base != null && e.Nt < BundleImportState_Preload
77
+ base != null && e.i < BundleImportState_Preload
78
78
  ) {
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);
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);
83
83
  }
84
84
  queueDirty = 1;
85
85
  }
86
- if (e.Mt) {
86
+ if (e.h) {
87
87
  o ||= /* @__PURE__ */ new Set();
88
88
  o.add(e);
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;
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;
93
93
  let r;
94
- if (t2 === 1 || t2 >= 0.99 && yi < 100) {
95
- yi++;
96
- r = Math.min(0.01, 1 - n2.Dt);
94
+ if (t2 === 1 || t2 >= 0.99 && depsCount < 100) {
95
+ depsCount++;
96
+ r = Math.min(0.01, 1 - n2.S);
97
97
  } else {
98
- const o2 = 1 - n2.Dt * t2;
99
- const s = n2.Wt;
98
+ const o2 = 1 - n2.S * t2;
99
+ const s = n2.q;
100
100
  const l = o2 / s;
101
- r = Math.max(0.02, e2.Tt * l);
102
- n2.Wt = l;
101
+ r = Math.max(0.02, e2.u * l);
102
+ n2.q = l;
103
103
  }
104
- pi(e2, r, o);
104
+ adjustProbabilities(e2, r, o);
105
105
  }
106
106
  }
107
107
  };
108
- const $i = (e, t) => {
109
- const o = ci(e);
110
- if (o && o.Tt > t) pi(o, t);
108
+ const handleBundle = (e, t) => {
109
+ const o = getBundle(e);
110
+ if (o && o.u > t) adjustProbabilities(o, t);
111
111
  };
112
- let yi;
112
+ let depsCount;
113
113
  const preload = (e, t) => {
114
114
  if (!e?.length) return;
115
- yi = 0;
115
+ depsCount = 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 $i(n, o);
120
+ else handleBundle(n, o);
121
121
  }
122
- else $i(e, o);
123
- if (Nn) hi();
122
+ else handleBundle(e, o);
123
+ if (isBrowser) trigger();
124
124
  };
125
- if (Nn) document.addEventListener("qsymbol", (e) => {
125
+ if (isBrowser) 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 (Nn) document.addEventListener("qsymbol", (e) => {
131
131
  });
132
132
  let base;
133
133
  let graph;
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 });
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 });
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({ It: e[s], Dt: l, Wt: 1 });
145
+ else r.push({ m: e[s], S: l, q: 1 });
146
146
  o++;
147
147
  }
148
148
  t.set(n, r);
149
149
  }
150
150
  return t;
151
151
  };
152
- const ci = (e) => {
153
- let t = ui.get(e);
152
+ const getBundle = (e) => {
153
+ let t = bundles.get(e);
154
154
  if (!t) {
155
155
  let o;
156
156
  if (graph) {
@@ -159,37 +159,37 @@ const ci = (e) => {
159
159
  if (!o.length) o = void 0;
160
160
  }
161
161
  t = makeBundle(e, o);
162
- ui.set(e, t);
162
+ bundles.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.i = o["P"];
170
- if ("Q" in o) config.S = 1 - o["Q"];
169
+ if ("P" in o) config.o = o["P"];
170
+ if ("Q" in o) config.l = 1 - o["Q"];
171
171
  }
172
- if (!Nn || e == null) return;
172
+ if (!isBrowser || 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 = ci(e3);
179
- n.Mt = o2;
180
- if (n.Tt < 1) {
181
- t2.push([n, n.Tt]);
182
- n.Tt = 1;
178
+ const n = getBundle(e3);
179
+ n.h = o2;
180
+ if (n.u < 1) {
181
+ t2.push([n, n.u]);
182
+ n.u = 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) pi(e3, o2);
187
- hi();
186
+ for (const [e3, o2] of t2) adjustProbabilities(e3, o2);
187
+ trigger();
188
188
  }).catch(console.warn);
189
189
  };
190
190
  export {
191
191
  parseBundleGraph as g,
192
- $i as h,
192
+ handleBundle as h,
193
193
  loadBundleGraph as l,
194
194
  preload as p
195
195
  };
package/dist/server.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/server 2.0.0-beta.27-dev+7fc6984
3
+ * @qwik.dev/core/server 2.0.0-beta.29-dev+bc61b71
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
@@ -1219,7 +1219,7 @@ function getBuildBase(opts) {
1219
1219
  return `${import.meta.env.BASE_URL || "/"}build/`;
1220
1220
  }
1221
1221
  var versions = {
1222
- qwik: "2.0.0-beta.27-dev+7fc6984",
1222
+ qwik: "2.0.0-beta.29-dev+bc61b71",
1223
1223
  qwikDom: "2.1.19"
1224
1224
  };
1225
1225