vitral 0.10.1 → 0.11.0
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/dist/angular.d.ts +2 -2
- package/dist/angular.js +13 -10
- package/dist/auto.js +11 -8
- package/dist/{capture-A6JQNNQY.js → capture-2I5IQ2C2.js} +2 -1
- package/dist/{channel-2DUQQPPA.js → channel-ABGK26Q5.js} +5 -3
- package/dist/{chunk-WAU6OKK3.js → chunk-2SAI6S2H.js} +11 -3
- package/dist/chunk-2Z4OH3BP.js +85 -0
- package/dist/chunk-5O6XDJBR.js +15 -0
- package/dist/chunk-623K4UNS.js +70 -0
- package/dist/{chunk-VTGHPX4J.js → chunk-6JH2I65O.js} +15 -13
- package/dist/{chunk-FOEXP52G.js → chunk-7P5O3REI.js} +46 -15
- package/dist/{chunk-EVVYV5ED.js → chunk-AL6MLNVY.js} +49 -21
- package/dist/{chunk-CFJC4GRB.js → chunk-AQUQD3NA.js} +17 -8
- package/dist/chunk-B3PFMWZT.js +21 -0
- package/dist/{chunk-463H6B56.js → chunk-BQGVAXFM.js} +3 -4
- package/dist/{chunk-TW7KYJQ6.js → chunk-GGMM56TM.js} +1 -1
- package/dist/{chunk-SC2KF7GJ.js → chunk-IKCEA3YN.js} +3 -3
- package/dist/chunk-JWDDXX5O.js +6 -0
- package/dist/{chunk-B2MPYF4M.js → chunk-KCF46XOX.js} +4 -2
- package/dist/{chunk-R3HUMHNL.js → chunk-LDOSAAEF.js} +15 -0
- package/dist/{chunk-MGG5BW3U.js → chunk-MICF64AZ.js} +2 -2
- package/dist/{chunk-QINOFHG6.js → chunk-NQ6ZTGQZ.js} +2 -2
- package/dist/chunk-QQWE5J6U.js +37 -0
- package/dist/{chunk-VK6W7KHM.js → chunk-SPSAXBPR.js} +10 -6
- package/dist/{chunk-UYOPJ4XQ.js → chunk-UCFOXMOR.js} +1 -1
- package/dist/cli.js +119 -8
- package/dist/{contract-IXM52LVW.js → contract-3JY7SOGQ.js} +1 -1
- package/dist/{dedupe-SRAPOK3V.js → dedupe-M63VMCWA.js} +3 -1
- package/dist/edge.d.ts +4 -2
- package/dist/edge.js +69 -46
- package/dist/element.d.ts +2 -2
- package/dist/element.js +11 -8
- package/dist/embed.js +2 -2
- package/dist/{events-CWdYSrkz.d.ts → events-II6hXM3Q.d.ts} +1 -1
- package/dist/expose-2S3TCXSP.js +18 -0
- package/dist/federation.d.ts +1 -1
- package/dist/{hydrate-IVQNHOP3.js → hydrate-FJHHLW5G.js} +22 -12
- package/dist/iframe.js +15 -12
- package/dist/index.d.ts +6 -6
- package/dist/index.js +25 -11
- package/dist/{loader-CLRMRRFv.d.ts → loader-Bmul2-5T.d.ts} +1 -1
- package/dist/next-config.d.ts +30 -10
- package/dist/next-config.js +29 -20
- package/dist/next-host.d.ts +11 -5
- package/dist/next-host.js +54 -29
- package/dist/next-server.d.ts +56 -0
- package/dist/next-server.js +90 -0
- package/dist/preact.d.ts +4 -4
- package/dist/preact.js +10 -7
- package/dist/prefetch.d.ts +40 -3
- package/dist/prefetch.js +100 -30
- package/dist/react-server.d.ts +16 -5
- package/dist/react-server.js +8 -3
- package/dist/react.d.ts +20 -6
- package/dist/react.js +14 -9
- package/dist/{reframe-ZOQPW552.js → reframe-HIYA2TIU.js} +10 -9
- package/dist/route-4KQITYD4.js +138 -0
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +12 -9
- package/dist/{shadow-PZGQKUA4.js → shadow-7ZV4JEO6.js} +4 -3
- package/dist/sign.d.ts +49 -0
- package/dist/sign.js +15 -0
- package/dist/single-spa.d.ts +1 -1
- package/dist/{slot-DRYmGvvV.d.ts → slot--WLgdcW_.d.ts} +1 -1
- package/dist/snapshot.d.ts +6 -0
- package/dist/snapshot.js +125 -0
- package/dist/solid.d.ts +3 -3
- package/dist/solid.js +10 -7
- package/dist/sri-AMQOKKWR.js +17 -0
- package/dist/ssr-markup-BCPpGmss.d.ts +13 -0
- package/dist/state-B1FJi8I9.d.ts +14 -0
- package/dist/svelte.d.ts +4 -4
- package/dist/svelte.js +10 -7
- package/dist/sw.d.ts +48 -1
- package/dist/sw.js +79 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +10 -7
- package/dist/{types-g8WEVD_b.d.ts → types-DJautV-K.d.ts} +86 -1
- package/dist/vitals.js +2 -1
- package/dist/vite.d.ts +4 -2
- package/dist/vite.js +62 -12
- package/dist/vue.d.ts +3 -3
- package/dist/vue.js +12 -9
- package/package.json +37 -19
- package/dist/expose-BA4HSXDP.js +0 -17
- package/dist/sri-LQBLQMG5.js +0 -14
- package/dist/state-BDdCwc21.d.ts +0 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dedupeModule,
|
|
3
3
|
sriModule
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MICF64AZ.js";
|
|
5
5
|
import {
|
|
6
6
|
prefetchCss
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IKCEA3YN.js";
|
|
8
8
|
import {
|
|
9
9
|
absolute,
|
|
10
10
|
addLink,
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
pageOrigin,
|
|
14
14
|
withRetry,
|
|
15
15
|
withTimeout
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GGMM56TM.js";
|
|
17
17
|
import {
|
|
18
18
|
RemoteError,
|
|
19
19
|
fail,
|
|
20
20
|
isRemoteError,
|
|
21
21
|
report
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-BQGVAXFM.js";
|
|
23
23
|
import {
|
|
24
24
|
protocol
|
|
25
25
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -29,7 +29,7 @@ function configure(config) {
|
|
|
29
29
|
const p = protocol();
|
|
30
30
|
const { remotes, dedupe, ...rest } = config;
|
|
31
31
|
p.configure(rest);
|
|
32
|
-
if (rest.captureGlobalErrors) import("./capture-
|
|
32
|
+
if (rest.captureGlobalErrors) import("./capture-2I5IQ2C2.js").then((m) => m.capture());
|
|
33
33
|
if (dedupe) p.pending(dedupeModule().then((m) => m.offer(p, dedupe)).catch(() => {
|
|
34
34
|
}));
|
|
35
35
|
if (typeof remotes === "string") {
|
|
@@ -78,12 +78,35 @@ function checkOrigin(name, url) {
|
|
|
78
78
|
throw new RemoteError("ORIGIN_BLOCKED", name, `origem ${origin} n\xE3o est\xE1 em allowedOrigins`);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
// src/core/policy.ts
|
|
82
|
+
function choose(s) {
|
|
83
|
+
return s.saveData || /2g/.test(s.effectiveType) ? "lazy" : s.effectiveType == "3g" || s.deviceMemory <= 2 ? "critical" : "all";
|
|
84
|
+
}
|
|
85
|
+
function signals() {
|
|
86
|
+
const n = typeof navigator == "object" ? navigator : {};
|
|
87
|
+
return { saveData: n.connection?.saveData, effectiveType: n.connection?.effectiveType, deviceMemory: n.deviceMemory };
|
|
88
|
+
}
|
|
89
|
+
function signalsFrom(headers) {
|
|
90
|
+
const get = (k) => {
|
|
91
|
+
if (typeof headers.get === "function") return headers.get(k) ?? void 0;
|
|
92
|
+
const v = headers[k];
|
|
93
|
+
return Array.isArray(v) ? v[0] : v;
|
|
94
|
+
};
|
|
95
|
+
const memory = Number(get("device-memory"));
|
|
96
|
+
return { saveData: get("save-data") === "on" || void 0, effectiveType: get("ect"), deviceMemory: Number.isFinite(memory) && get("device-memory") ? memory : void 0 };
|
|
97
|
+
}
|
|
98
|
+
function policy() {
|
|
99
|
+
const n = typeof navigator == "object" ? navigator : {};
|
|
100
|
+
const c = n.connection || {};
|
|
101
|
+
return protocol().settings().policy || (c.saveData || /2g/.test(c.effectiveType) ? "lazy" : c.effectiveType == "3g" || n.deviceMemory <= 2 ? "critical" : "all");
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
// src/core/loader.ts
|
|
82
105
|
function loadRemote(name) {
|
|
83
106
|
return load(name).then((r) => r.module);
|
|
84
107
|
}
|
|
85
108
|
function loadModule(name) {
|
|
86
|
-
return import("./expose-
|
|
109
|
+
return import("./expose-2S3TCXSP.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
|
|
87
110
|
}
|
|
88
111
|
function preload(name, options = {}) {
|
|
89
112
|
const done = load(name);
|
|
@@ -101,8 +124,7 @@ function routeChunks(r) {
|
|
|
101
124
|
return Object.keys(r.sri ?? {}).filter((u) => u.startsWith(dir) && u.endsWith(".js") && !loaded.has(u));
|
|
102
125
|
}
|
|
103
126
|
function warmRoutes(r) {
|
|
104
|
-
|
|
105
|
-
if (c?.saveData || /2g/.test(c?.effectiveType)) return;
|
|
127
|
+
if (policy() !== "all") return;
|
|
106
128
|
const queue = routeChunks(r).slice();
|
|
107
129
|
const next = () => queue.length && fetch(queue.shift(), { priority: "low" }).then((res) => res.arrayBuffer()).catch(() => {
|
|
108
130
|
}).then(next);
|
|
@@ -124,7 +146,7 @@ function warmSsr(holder) {
|
|
|
124
146
|
}
|
|
125
147
|
function load(name, isolate, priority) {
|
|
126
148
|
const file = (n) => loadFile(n, isolate, priority);
|
|
127
|
-
return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-
|
|
149
|
+
return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-2S3TCXSP.js").then((m) => m.resolveTarget(name, file))).catch(fail);
|
|
128
150
|
}
|
|
129
151
|
function loadFile(name, isolate, priority) {
|
|
130
152
|
const p = protocol();
|
|
@@ -133,7 +155,7 @@ function loadFile(name, isolate, priority) {
|
|
|
133
155
|
let resolved;
|
|
134
156
|
try {
|
|
135
157
|
const known = p.entry(name);
|
|
136
|
-
const early = known?.url && !known.module && !known.manifest && !overrides() ? prefetchManifest(known.url, name, priority) : void 0;
|
|
158
|
+
const early = known?.url && !known.module && !known.manifest && !overrides() ? prefetchManifest(known.url, name, priority, signed(known)) : void 0;
|
|
137
159
|
await p.pending();
|
|
138
160
|
const override = await devOverride(name);
|
|
139
161
|
const entry = override ? { isolate: p.entry(name)?.isolate, ...override } : p.entry(name);
|
|
@@ -171,23 +193,24 @@ async function loadLocal(name, entry) {
|
|
|
171
193
|
}
|
|
172
194
|
async function resolveEntry(name, entry, priority, early) {
|
|
173
195
|
checkOrigin(name, entry.url);
|
|
174
|
-
const
|
|
175
|
-
|
|
196
|
+
const keys = signed(entry);
|
|
197
|
+
const m = entry.manifest ?? (new URL(entry.url).pathname.endsWith(".json") ? await (early ?? manifestOf(entry.url, name, priority, keys)) : { name, entry: entry.url });
|
|
198
|
+
if (m?.stable) return resolveEntry(name, await (await import("./channel-ABGK26Q5.js")).pick(name, entry, m), priority);
|
|
176
199
|
if (typeof m?.entry !== "string") throw new RemoteError("INVALID_MODULE", name, `manifesto inv\xE1lido em ${entry.url}`);
|
|
177
200
|
if (m.contract && (entry.contract || protocol().settings().contract)) {
|
|
178
|
-
const why = await (await import("./contract-
|
|
201
|
+
const why = await (await import("./contract-3JY7SOGQ.js")).checkContract(m.contract, entry.contract);
|
|
179
202
|
if (why) throw new RemoteError("CONTRACT_MISMATCH", name, why);
|
|
180
203
|
}
|
|
181
204
|
const abs = (u) => absolute(u, entry.url);
|
|
182
205
|
const sri = {};
|
|
183
|
-
for (const file in m.files ?? {}) sri[abs(file)] = m.files[file];
|
|
206
|
+
for (const file in m.files ?? {}) sri[abs(file)] = m.files[file] + keys;
|
|
184
207
|
const resolved = {
|
|
185
208
|
entry: abs(m.entry),
|
|
186
209
|
css: [...m.css ?? [], ...entry.css ?? []].map(abs),
|
|
187
210
|
shadow: m.shadow,
|
|
188
211
|
// A integridade declarada pelo host vence a do manifesto, e aí só o
|
|
189
212
|
// arquivo único (o que ela descreve) é usado.
|
|
190
|
-
integrity: entry.integrity === false ? void 0 : entry.integrity ?? m.integrity,
|
|
213
|
+
integrity: entry.integrity === false ? void 0 : entry.integrity ?? (m.integrity && m.integrity + keys),
|
|
191
214
|
isolate: entry.isolate,
|
|
192
215
|
scope: m.scope,
|
|
193
216
|
version: m.version,
|
|
@@ -213,21 +236,22 @@ async function resolveEntry(name, entry, priority, early) {
|
|
|
213
236
|
}
|
|
214
237
|
return resolved;
|
|
215
238
|
}
|
|
216
|
-
|
|
239
|
+
var signed = (e) => (e.keys ?? []).map((k) => " ed25519-" + k).join("");
|
|
240
|
+
function prefetchManifest(url, name, priority, keys) {
|
|
217
241
|
try {
|
|
218
242
|
if (!new URL(url).pathname.endsWith(".json")) return;
|
|
219
243
|
checkOrigin(name, url);
|
|
220
244
|
} catch {
|
|
221
245
|
return;
|
|
222
246
|
}
|
|
223
|
-
const f = manifestOf(url, name, priority);
|
|
247
|
+
const f = manifestOf(url, name, priority, keys);
|
|
224
248
|
f.catch(() => {
|
|
225
249
|
});
|
|
226
250
|
return f;
|
|
227
251
|
}
|
|
228
|
-
function manifestOf(url, name, priority) {
|
|
252
|
+
function manifestOf(url, name, priority, keys) {
|
|
229
253
|
const { timeout, maxStale } = protocol().settings();
|
|
230
|
-
const fresh = fetchJson(url, timeout, name, { cache: "no-cache", credentials: "same-origin", priority });
|
|
254
|
+
const fresh = fetchJson(url, timeout, name, { cache: "no-cache", credentials: "same-origin", priority, integrity: keys.slice(1) });
|
|
231
255
|
return maxStale ? import("./stale-XV4LNHDX.js").then((m) => m.stale(url, fresh, maxStale), () => fresh) : fresh;
|
|
232
256
|
}
|
|
233
257
|
async function importModule(name, r) {
|
|
@@ -242,8 +266,8 @@ async function importModule(name, r) {
|
|
|
242
266
|
if (!r.integrity) {
|
|
243
267
|
if (!r.split) return run(r.entry);
|
|
244
268
|
if (r.split.dedupe?.length) {
|
|
245
|
-
const { shared } = await dedupeModule();
|
|
246
|
-
for (const d of r.split.dedupe)
|
|
269
|
+
const { shared, planned } = await dedupeModule();
|
|
270
|
+
for (const d of planned(name, r.split).dedupe)
|
|
247
271
|
shared(protocol())(d.name, d.range, { version: d.version, url: d.file, load: async () => (await run(d.file)).default });
|
|
248
272
|
}
|
|
249
273
|
return run(r.split.entry);
|
|
@@ -263,6 +287,10 @@ export {
|
|
|
263
287
|
configure,
|
|
264
288
|
register,
|
|
265
289
|
registerSrc,
|
|
290
|
+
choose,
|
|
291
|
+
signals,
|
|
292
|
+
signalsFrom,
|
|
293
|
+
policy,
|
|
266
294
|
loadRemote,
|
|
267
295
|
loadModule,
|
|
268
296
|
preload,
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot,
|
|
3
|
-
timings
|
|
4
|
-
|
|
3
|
+
timings,
|
|
4
|
+
when
|
|
5
|
+
} from "./chunk-2SAI6S2H.js";
|
|
5
6
|
import {
|
|
6
7
|
defineRemote,
|
|
7
8
|
memoSelect,
|
|
8
9
|
same,
|
|
9
10
|
shared
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6JH2I65O.js";
|
|
11
12
|
import {
|
|
13
|
+
policy,
|
|
12
14
|
registerSrc,
|
|
13
15
|
warmSsr
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AL6MLNVY.js";
|
|
15
17
|
|
|
16
18
|
// src/element.ts
|
|
17
19
|
var Base = typeof HTMLElement === "undefined" ? class {
|
|
@@ -49,6 +51,9 @@ var VitralRemoteElement = class extends Base {
|
|
|
49
51
|
prefetch: this.getAttribute("prefetch"),
|
|
50
52
|
priority: this.getAttribute("priority") || void 0,
|
|
51
53
|
keepAlive: keep === null ? false : Number(keep) || true,
|
|
54
|
+
snapshot: this.hasAttribute("snapshot"),
|
|
55
|
+
// A última tela no lugar do "carregando".
|
|
56
|
+
onSnapshot: (shown) => this.#snapped = shown,
|
|
52
57
|
styles: { inherit: this.getAttribute("inherit-styles")?.split(/\s+/).filter(Boolean) },
|
|
53
58
|
onStatus: (status, error) => {
|
|
54
59
|
this.setAttribute("data-vitral-status", status);
|
|
@@ -56,21 +61,24 @@ var VitralRemoteElement = class extends Base {
|
|
|
56
61
|
else this.removeAttribute("aria-busy");
|
|
57
62
|
const has = (slot) => {
|
|
58
63
|
const els = this.querySelectorAll(`:scope > [slot="${slot}"]`);
|
|
59
|
-
for (const el of els) el.hidden = status !== (slot === "fallback" ? "loading" : "error");
|
|
64
|
+
for (const el of els) el.hidden = status !== (slot === "fallback" ? "loading" : "error") || slot === "fallback" && this.#snapped;
|
|
60
65
|
return els.length > 0;
|
|
61
66
|
};
|
|
62
67
|
queueMicrotask(() => {
|
|
63
68
|
if (this.#slot?.status !== status) return;
|
|
64
69
|
const custom = { loading: has("fallback"), error: has("error"), ready: true };
|
|
65
|
-
this.#showDefault(custom[status] ? null : status);
|
|
70
|
+
this.#showDefault(custom[status] || status === "loading" && this.#snapped ? null : status);
|
|
66
71
|
});
|
|
67
72
|
if (status === "ready") this.dispatchEvent(new CustomEvent("vitral-ready", { bubbles: true, detail: { timings: timings(name) } }));
|
|
68
73
|
if (status === "error") this.dispatchEvent(new CustomEvent("vitral-error", { bubbles: true, detail: { error } }));
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
76
|
const ssr = true ? this.querySelector(":scope>[data-vitral-ssr]") : null;
|
|
72
|
-
if (ssr)
|
|
73
|
-
|
|
77
|
+
if (ssr) {
|
|
78
|
+
const go = () => (warmSsr(ssr), import("./hydrate-FJHHLW5G.js").then((m) => this.isConnected && !this.#slot && (this.#slot = m.hydrateSlot(this, ssr, { ...options, props: this.#props }))));
|
|
79
|
+
if (policy() === "lazy") when(this, "visible", go);
|
|
80
|
+
else go();
|
|
81
|
+
} else this.#slot = hostSlot(this, options);
|
|
74
82
|
}
|
|
75
83
|
/**
|
|
76
84
|
* Nome para montar. `src` em atributo é registrado sem entrar na allowlist:
|
|
@@ -82,6 +90,7 @@ var VitralRemoteElement = class extends Base {
|
|
|
82
90
|
return src ? registerSrc(src, name ?? void 0, false) : name;
|
|
83
91
|
}
|
|
84
92
|
#default = null;
|
|
93
|
+
#snapped = false;
|
|
85
94
|
/** Carregando e erro padrão, só quando não há slot próprio. */
|
|
86
95
|
#showDefault(status) {
|
|
87
96
|
this.#default?.remove();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/core/ssr-markup.ts
|
|
2
|
+
var attr = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
3
|
+
var inlineJson = (v) => JSON.stringify(v).replace(/</g, "\\u003c");
|
|
4
|
+
function stateScript(r) {
|
|
5
|
+
return typeof r === "object" && r.state !== void 0 ? `<script type="application/json" data-vitral-state>${inlineJson(r.state)}</script>` : "";
|
|
6
|
+
}
|
|
7
|
+
var htmlOf = (r) => typeof r === "string" ? r : r.html;
|
|
8
|
+
function ssrHolder(name, m, rendered, css, seed) {
|
|
9
|
+
const n = attr(name);
|
|
10
|
+
const scope = m.scope ? ` data-vitral-scope="${attr(m.scope)}"` : "";
|
|
11
|
+
const links = css.map(([href, sri]) => `<link rel="stylesheet" href="${attr(href)}" crossorigin="anonymous"${sri ? ` integrity="${attr(sri)}"` : ""}>`).join("");
|
|
12
|
+
const manifest = seed ? `<script type="application/json" data-vitral-manifest="${attr(seed[0])}">${inlineJson(seed[1])}</script>` : "";
|
|
13
|
+
return `<div data-vitral-ssr data-vitral-slot="${n}">${manifest}${stateScript(rendered)}${links}<div data-vitral-root="${n}"${scope} style="display:contents">${htmlOf(rendered)}</div></div>`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
inlineJson,
|
|
18
|
+
stateScript,
|
|
19
|
+
htmlOf,
|
|
20
|
+
ssrHolder
|
|
21
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ctxHooks
|
|
3
|
+
} from "./chunk-JWDDXX5O.js";
|
|
1
4
|
import {
|
|
2
5
|
protocol
|
|
3
6
|
} from "./chunk-GNPFWISJ.js";
|
|
4
7
|
|
|
5
|
-
// src/core/hooks.ts
|
|
6
|
-
var ctxHooks = {};
|
|
7
|
-
|
|
8
8
|
// src/core/errors.ts
|
|
9
9
|
var ERROR_DOCS = "https://joaogabriel15.github.io/vitral/erros/";
|
|
10
10
|
var RemoteError = class extends Error {
|
|
@@ -40,7 +40,6 @@ var fail = (e) => {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export {
|
|
43
|
-
ctxHooks,
|
|
44
43
|
RemoteError,
|
|
45
44
|
isRemoteError,
|
|
46
45
|
mounted,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addLink,
|
|
3
3
|
fetchBytes
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GGMM56TM.js";
|
|
5
5
|
import {
|
|
6
6
|
protocol
|
|
7
7
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -23,11 +23,11 @@ function fetchCssText(href, integrity, priority) {
|
|
|
23
23
|
return p;
|
|
24
24
|
}
|
|
25
25
|
function prefetchCss(r, shadow, priority = "auto") {
|
|
26
|
-
if (shadow && adopts()) import("./shadow-
|
|
26
|
+
if (shadow && adopts()) import("./shadow-7ZV4JEO6.js").then((m) => m.prefetch(r, priority), noop);
|
|
27
27
|
else for (const href of r.css) if (!document.querySelector(`link[href="${href}"]`)) addLink("preload", href, { as: "style", integrity: r.sri?.[href] ?? "", fetchPriority: priority });
|
|
28
28
|
}
|
|
29
29
|
function injectStyles(r, shadow, make, styles) {
|
|
30
|
-
return shadow ? import("./shadow-
|
|
30
|
+
return shadow ? import("./shadow-7ZV4JEO6.js").then((m) => m.attachShadowRoot(shadow, make, r, protocol().settings().styles, styles)) : injectCss(r.css, null, r.sri).then(() => [noop]);
|
|
31
31
|
}
|
|
32
32
|
function injectCss(urls, root, sri = {}) {
|
|
33
33
|
const owner = root ?? document;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Component as ReactComponent, createContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var VitralContext = createContext(null);
|
|
5
|
+
var StateContext = createContext(void 0);
|
|
5
6
|
var Boundary = class extends ReactComponent {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
@@ -17,11 +18,12 @@ var Boundary = class extends ReactComponent {
|
|
|
17
18
|
return this.state.failed ? null : this.props.children;
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
function RemoteTree({ Component, props, ctx }) {
|
|
21
|
-
return /* @__PURE__ */ jsx(VitralContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(Boundary, { ctx, children: /* @__PURE__ */ jsx(Component, { ...props }) }) });
|
|
21
|
+
function RemoteTree({ Component, props, ctx, state = ctx?.initialState }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(VitralContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(StateContext.Provider, { value: state, children: /* @__PURE__ */ jsx(Boundary, { ctx, children: /* @__PURE__ */ jsx(Component, { ...props }) }) }) });
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export {
|
|
25
26
|
VitralContext,
|
|
27
|
+
StateContext,
|
|
26
28
|
RemoteTree
|
|
27
29
|
};
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
var dedupe_exports = {};
|
|
10
10
|
__export(dedupe_exports, {
|
|
11
11
|
offer: () => offer,
|
|
12
|
+
planned: () => planned,
|
|
12
13
|
satisfies: () => satisfies,
|
|
13
14
|
shared: () => shared
|
|
14
15
|
});
|
|
@@ -73,9 +74,23 @@ function offer(p, groups) {
|
|
|
73
74
|
p.configure({ offered: { ...p.settings().offered, [name]: version } });
|
|
74
75
|
}
|
|
75
76
|
}
|
|
77
|
+
function planned(name, split) {
|
|
78
|
+
const plan = globalThis[/* @__PURE__ */ Symbol.for("vitral")].settings().dedupePlan?.[name];
|
|
79
|
+
const absolute = (u) => new URL(u, location.href).href;
|
|
80
|
+
if (!plan || !split.dedupe) return split;
|
|
81
|
+
const sri = { ...split.sri };
|
|
82
|
+
const dedupe = split.dedupe.map((d) => {
|
|
83
|
+
const c = plan[d.name];
|
|
84
|
+
if (c?.for !== `${d.range}@${d.version}`) return d;
|
|
85
|
+
for (const u in c.sri) sri[absolute(u)] = c.sri[u];
|
|
86
|
+
return { ...d, version: c.version, file: absolute(c.file), chunks: c.chunks?.map(absolute) };
|
|
87
|
+
});
|
|
88
|
+
return { ...split, dedupe, sri };
|
|
89
|
+
}
|
|
76
90
|
|
|
77
91
|
export {
|
|
78
92
|
shared,
|
|
79
93
|
offer,
|
|
94
|
+
planned,
|
|
80
95
|
dedupe_exports
|
|
81
96
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/core/bundled.ts
|
|
2
2
|
var bundled = {};
|
|
3
|
-
var dedupeModule = () => bundled.dedupe ? Promise.resolve(bundled.dedupe) : import("./dedupe-
|
|
4
|
-
var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-
|
|
3
|
+
var dedupeModule = () => bundled.dedupe ? Promise.resolve(bundled.dedupe) : import("./dedupe-M63VMCWA.js");
|
|
4
|
+
var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-AMQOKKWR.js");
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
7
|
bundled,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
critical,
|
|
3
|
+
ordered
|
|
4
|
+
} from "./chunk-5O6XDJBR.js";
|
|
5
|
+
import {
|
|
6
|
+
satisfies
|
|
7
|
+
} from "./chunk-4E33RZMM.js";
|
|
8
|
+
|
|
9
|
+
// src/core/next-hints.ts
|
|
10
|
+
function hintsOf(m, url, offered, integrity, keys) {
|
|
11
|
+
const k = (keys ?? []).map((x) => " ed25519-" + x.replace(/^ed25519-/, "")).join("");
|
|
12
|
+
const base = new URL(url, "http://host.invalid/");
|
|
13
|
+
const at = (f) => {
|
|
14
|
+
const u = new URL(f, base);
|
|
15
|
+
return u.origin === "http://host.invalid" ? u.pathname + u.search : u.href;
|
|
16
|
+
};
|
|
17
|
+
const crit = critical(m);
|
|
18
|
+
const hint = (f) => {
|
|
19
|
+
const h = integrity !== false && m.files?.[f] ? [at(f), m.files[f] + k] : [at(f)];
|
|
20
|
+
if (crit.has(f)) h[1] ??= void 0, h[2] = "high";
|
|
21
|
+
return h;
|
|
22
|
+
};
|
|
23
|
+
const served = (d) => !!offered[d.name] && satisfies(offered[d.name], d.range);
|
|
24
|
+
const own = (m.dedupe ?? []).filter((d) => !served(d)).flatMap((d) => [...d.chunks ?? [], d.file]);
|
|
25
|
+
const offers = m.split ? (m.dedupe ?? []).filter((d) => d.name !== "react" && served(d)).map((d) => d.name) : [];
|
|
26
|
+
return {
|
|
27
|
+
manifest: at(url),
|
|
28
|
+
css: (m.css ?? []).map(hint),
|
|
29
|
+
js: (m.split ? ordered([...own, ...m.split.chunks ?? [], m.split.entry], m.split.order) : [m.entry]).map(hint),
|
|
30
|
+
...offers.length && { offers },
|
|
31
|
+
...k && { signed: k.trim() }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
hintsOf
|
|
37
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
verifyIntegrity
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UCFOXMOR.js";
|
|
4
4
|
import {
|
|
5
5
|
dedupeModule
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MICF64AZ.js";
|
|
7
7
|
import {
|
|
8
8
|
addLink,
|
|
9
9
|
fetchBytes,
|
|
10
10
|
withTimeout
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GGMM56TM.js";
|
|
12
12
|
import {
|
|
13
13
|
RemoteError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BQGVAXFM.js";
|
|
15
15
|
import {
|
|
16
16
|
__export
|
|
17
17
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -20,10 +20,12 @@ import {
|
|
|
20
20
|
var sri_exports = {};
|
|
21
21
|
__export(sri_exports, {
|
|
22
22
|
importVerified: () => importVerified,
|
|
23
|
+
signature: () => signature,
|
|
23
24
|
verified: () => verified
|
|
24
25
|
});
|
|
25
26
|
var failed = /* @__PURE__ */ new Set();
|
|
26
27
|
async function importVerified(name, r, run, timeout) {
|
|
28
|
+
if (r.split?.dedupe?.length && globalThis[/* @__PURE__ */ Symbol.for("vitral")]?.settings().dedupePlan?.[name]) r = { ...r, split: (await dedupeModule()).planned(name, r.split) };
|
|
27
29
|
const { entry, integrity, priority } = r;
|
|
28
30
|
if (!failed.has(entry)) {
|
|
29
31
|
try {
|
|
@@ -38,7 +40,7 @@ async function importVerified(name, r, run, timeout) {
|
|
|
38
40
|
if (e instanceof RemoteError && e.code === "TIMEOUT") throw e;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
const bytes = await fetchBytes(entry, timeout, name, failed.has(entry)
|
|
43
|
+
const bytes = await fetchBytes(entry, timeout, name, { priority, ...failed.has(entry) && { cache: "reload" }, ...signature(integrity) });
|
|
42
44
|
await verifyIntegrity(name, bytes, integrity);
|
|
43
45
|
const url = URL.createObjectURL(new Blob([bytes], { type: "text/javascript" }));
|
|
44
46
|
try {
|
|
@@ -47,7 +49,8 @@ async function importVerified(name, r, run, timeout) {
|
|
|
47
49
|
URL.revokeObjectURL(url);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
var
|
|
52
|
+
var signature = (integrity) => /ed25519-/.test(integrity) ? { integrity } : {};
|
|
53
|
+
var STRICT = /^(sha(256|384|512)-[A-Za-z0-9+/]+={0,2}( +|$))+(ed25519-[A-Za-z0-9+/]+={0,2}( +|$))*$/;
|
|
51
54
|
var PROBE = "data:text/javascript,export{}";
|
|
52
55
|
var PROBE_SRI = "sha256-d3bjIZdvLjBurwdLwkSVOnEBPFFly+T1SR9r3VVHBGg=";
|
|
53
56
|
var maps;
|
|
@@ -170,6 +173,7 @@ function check(load, good, bad) {
|
|
|
170
173
|
|
|
171
174
|
export {
|
|
172
175
|
importVerified,
|
|
176
|
+
signature,
|
|
173
177
|
verified,
|
|
174
178
|
sri_exports
|
|
175
179
|
};
|