@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.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +96 -10
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +624 -339
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +2538 -2369
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +26 -19
- package/dist/optimizer.mjs +1278 -1234
- package/dist/preloader.mjs +86 -86
- package/dist/server.mjs +2 -2
- package/dist/server.prod.mjs +261 -261
- package/dist/starters/features/csr/index.html +4 -0
- package/dist/testing/index.d.ts +42 -8
- package/dist/testing/index.mjs +407 -291
- package/dist/testing/package.json +1 -1
- package/package.json +4 -4
- package/public.d.ts +1 -0
package/dist/preloader.mjs
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import { isBrowser
|
|
2
|
-
const
|
|
3
|
-
const config = { t: 0,
|
|
4
|
-
const
|
|
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
|
|
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
|
|
12
|
+
const bundles = /* @__PURE__ */ new Map();
|
|
13
13
|
let queueDirty;
|
|
14
|
-
let
|
|
15
|
-
const
|
|
14
|
+
let preloadCount = 0;
|
|
15
|
+
const queue = [];
|
|
16
16
|
const log = (...e) => {
|
|
17
|
-
console.log(`Preloader ${Date.now() - loadStart}ms ${
|
|
17
|
+
console.log(`Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`, ...e);
|
|
18
18
|
};
|
|
19
19
|
const sortQueue = () => {
|
|
20
20
|
if (queueDirty) {
|
|
21
|
-
|
|
21
|
+
queue.sort((e, t) => e.u - t.u);
|
|
22
22
|
queueDirty = 0;
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
25
|
+
const trigger = () => {
|
|
26
|
+
if (!queue.length) return;
|
|
27
27
|
sortQueue();
|
|
28
|
-
while (
|
|
29
|
-
const e =
|
|
30
|
-
const t = e.
|
|
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.
|
|
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 ||
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (o >= 0.99 || preloadCount < n) {
|
|
37
|
+
queue.shift();
|
|
38
|
+
preloadOne(e);
|
|
39
39
|
} else break;
|
|
40
40
|
}
|
|
41
|
-
if (config.t && !
|
|
42
|
-
const e = [...
|
|
43
|
-
const t = e.reduce((e2, t2) => e2 + t2.
|
|
44
|
-
const o = e.reduce((e2, t2) => e2 + t2
|
|
45
|
-
log(`>>>> done ${e.length}/${
|
|
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
|
|
49
|
-
if (e.
|
|
50
|
-
|
|
48
|
+
const preloadOne = (e) => {
|
|
49
|
+
if (e.i >= BundleImportState_Preload) return;
|
|
50
|
+
preloadCount++;
|
|
51
51
|
const t = Date.now();
|
|
52
|
-
e.
|
|
53
|
-
e.
|
|
54
|
-
config.t && log(`<< load ${Math.round((1 - e.
|
|
55
|
-
const o =
|
|
56
|
-
o.href = new URL(`${base}${e.
|
|
57
|
-
o.rel =
|
|
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
|
-
|
|
60
|
+
preloadCount--;
|
|
61
61
|
const n = Date.now();
|
|
62
|
-
e
|
|
63
|
-
e.
|
|
64
|
-
config.t && log(`>> done after ${e
|
|
62
|
+
e.$ = n - t;
|
|
63
|
+
e.i = BundleImportState_Loaded;
|
|
64
|
+
config.t && log(`>> done after ${e.$}ms`, e.m);
|
|
65
65
|
o.remove();
|
|
66
|
-
|
|
66
|
+
trigger();
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
doc.head.appendChild(o);
|
|
69
69
|
};
|
|
70
|
-
const
|
|
70
|
+
const adjustProbabilities = (e, t, o) => {
|
|
71
71
|
if (o?.has(e)) return;
|
|
72
|
-
const n = e.
|
|
73
|
-
e.
|
|
74
|
-
if (n - e.
|
|
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.
|
|
77
|
+
base != null && e.i < BundleImportState_Preload
|
|
78
78
|
) {
|
|
79
|
-
if (e.
|
|
80
|
-
e.
|
|
81
|
-
|
|
82
|
-
config.t && log(`queued ${Math.round((1 - e.
|
|
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.
|
|
86
|
+
if (e.h) {
|
|
87
87
|
o ||= /* @__PURE__ */ new Set();
|
|
88
88
|
o.add(e);
|
|
89
|
-
const t2 = 1 - e.
|
|
90
|
-
for (const n2 of e.
|
|
91
|
-
const e2 =
|
|
92
|
-
if (e2.
|
|
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 &&
|
|
95
|
-
|
|
96
|
-
r = Math.min(0.01, 1 - n2.
|
|
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.
|
|
99
|
-
const s = n2.
|
|
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.
|
|
102
|
-
n2.
|
|
101
|
+
r = Math.max(0.02, e2.u * l);
|
|
102
|
+
n2.q = l;
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
adjustProbabilities(e2, r, o);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
|
-
const
|
|
109
|
-
const o =
|
|
110
|
-
if (o && o.
|
|
108
|
+
const handleBundle = (e, t) => {
|
|
109
|
+
const o = getBundle(e);
|
|
110
|
+
if (o && o.u > t) adjustProbabilities(o, t);
|
|
111
111
|
};
|
|
112
|
-
let
|
|
112
|
+
let depsCount;
|
|
113
113
|
const preload = (e, t) => {
|
|
114
114
|
if (!e?.length) return;
|
|
115
|
-
|
|
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
|
|
120
|
+
else handleBundle(n, o);
|
|
121
121
|
}
|
|
122
|
-
else
|
|
123
|
-
if (
|
|
122
|
+
else handleBundle(e, o);
|
|
123
|
+
if (isBrowser) trigger();
|
|
124
124
|
};
|
|
125
|
-
if (
|
|
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) => ({
|
|
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({
|
|
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
|
|
153
|
-
let t =
|
|
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
|
-
|
|
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.
|
|
170
|
-
if ("Q" in o) config.
|
|
169
|
+
if ("P" in o) config.o = o["P"];
|
|
170
|
+
if ("Q" in o) config.l = 1 - o["Q"];
|
|
171
171
|
}
|
|
172
|
-
if (!
|
|
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 =
|
|
179
|
-
n.
|
|
180
|
-
if (n.
|
|
181
|
-
t2.push([n, n.
|
|
182
|
-
n.
|
|
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)
|
|
187
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
1222
|
+
qwik: "2.0.0-beta.29-dev+bc61b71",
|
|
1223
1223
|
qwikDom: "2.1.19"
|
|
1224
1224
|
};
|
|
1225
1225
|
|