vitral 0.11.5 → 0.12.1

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.
Files changed (44) hide show
  1. package/dist/angular.js +7 -7
  2. package/dist/auto.js +7 -7
  3. package/dist/{channel-ABGK26Q5.js → channel-BHOVSU5X.js} +1 -1
  4. package/dist/{chunk-AL6MLNVY.js → chunk-52D6ZT4A.js} +16 -9
  5. package/dist/{chunk-SOENZNXO.js → chunk-B23S6737.js} +52 -3
  6. package/dist/{chunk-6JH2I65O.js → chunk-I7IFR65H.js} +6 -6
  7. package/dist/{chunk-2SAI6S2H.js → chunk-JKTZODC5.js} +2 -2
  8. package/dist/{chunk-MICF64AZ.js → chunk-QGAEXUP5.js} +1 -1
  9. package/dist/{chunk-I3CDUKHO.js → chunk-RGYVSS3X.js} +11 -6
  10. package/dist/{chunk-SVYL6UCB.js → chunk-UFETTKDP.js} +4 -4
  11. package/dist/{chunk-SPSAXBPR.js → chunk-VDNFRNOG.js} +25 -8
  12. package/dist/{chunk-GGMM56TM.js → chunk-VDVVEGAO.js} +7 -0
  13. package/dist/{chunk-IKCEA3YN.js → chunk-YDO7SPF4.js} +3 -3
  14. package/dist/{chunk-NQ6ZTGQZ.js → chunk-YKLWMIEH.js} +1 -1
  15. package/dist/cli.js +22 -3
  16. package/dist/element.js +7 -7
  17. package/dist/embed.js +2 -2
  18. package/dist/{expose-2S3TCXSP.js → expose-KL6TA472.js} +5 -5
  19. package/dist/{hydrate-FJHHLW5G.js → hydrate-LS3MLFGN.js} +6 -6
  20. package/dist/iframe.js +6 -6
  21. package/dist/index.js +5 -5
  22. package/dist/next-config.js +1 -1
  23. package/dist/next-host.d.ts +16 -3
  24. package/dist/next-host.js +30 -23
  25. package/dist/preact.d.ts +1 -0
  26. package/dist/preact.js +7 -7
  27. package/dist/prefetch.js +5 -5
  28. package/dist/react.d.ts +5 -1
  29. package/dist/react.js +7 -7
  30. package/dist/{reframe-HIYA2TIU.js → reframe-AD2UEPIO.js} +6 -6
  31. package/dist/{route-4KQITYD4.js → route-CEMWXHJI.js} +19 -1
  32. package/dist/routes.js +6 -6
  33. package/dist/{shadow-7ZV4JEO6.js → shadow-ABRO7JNY.js} +2 -2
  34. package/dist/solid.d.ts +2 -1
  35. package/dist/solid.js +18 -7
  36. package/dist/{sri-AMQOKKWR.js → sri-Z5U32IR2.js} +3 -3
  37. package/dist/svelte.js +6 -6
  38. package/dist/sw.d.ts +21 -19
  39. package/dist/sw.js +20 -9
  40. package/dist/testing.js +5 -5
  41. package/dist/vite.js +39 -1
  42. package/dist/vue.d.ts +1 -1
  43. package/dist/vue.js +7 -7
  44. package/package.json +14 -14
package/dist/angular.js CHANGED
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  defineVitralElement
3
- } from "./chunk-SVYL6UCB.js";
4
- import "./chunk-2SAI6S2H.js";
3
+ } from "./chunk-UFETTKDP.js";
4
+ import "./chunk-JKTZODC5.js";
5
5
  import {
6
6
  defineRemote,
7
7
  memoSelect,
8
8
  same,
9
9
  shared
10
- } from "./chunk-6JH2I65O.js";
10
+ } from "./chunk-I7IFR65H.js";
11
11
  import {
12
12
  configure
13
- } from "./chunk-AL6MLNVY.js";
14
- import "./chunk-MICF64AZ.js";
15
- import "./chunk-IKCEA3YN.js";
16
- import "./chunk-GGMM56TM.js";
13
+ } from "./chunk-52D6ZT4A.js";
14
+ import "./chunk-QGAEXUP5.js";
15
+ import "./chunk-YDO7SPF4.js";
16
+ import "./chunk-VDVVEGAO.js";
17
17
  import "./chunk-BQGVAXFM.js";
18
18
  import "./chunk-JWDDXX5O.js";
19
19
  import "./chunk-2Z4OH3BP.js";
package/dist/auto.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  defineVitralElement
3
- } from "./chunk-SVYL6UCB.js";
4
- import "./chunk-2SAI6S2H.js";
5
- import "./chunk-6JH2I65O.js";
6
- import "./chunk-AL6MLNVY.js";
7
- import "./chunk-MICF64AZ.js";
8
- import "./chunk-IKCEA3YN.js";
9
- import "./chunk-GGMM56TM.js";
3
+ } from "./chunk-UFETTKDP.js";
4
+ import "./chunk-JKTZODC5.js";
5
+ import "./chunk-I7IFR65H.js";
6
+ import "./chunk-52D6ZT4A.js";
7
+ import "./chunk-QGAEXUP5.js";
8
+ import "./chunk-YDO7SPF4.js";
9
+ import "./chunk-VDVVEGAO.js";
10
10
  import "./chunk-BQGVAXFM.js";
11
11
  import "./chunk-JWDDXX5O.js";
12
12
  import "./chunk-2Z4OH3BP.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  absolute
3
- } from "./chunk-GGMM56TM.js";
3
+ } from "./chunk-VDVVEGAO.js";
4
4
  import {
5
5
  RemoteError
6
6
  } from "./chunk-BQGVAXFM.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  dedupeModule,
3
3
  sriModule
4
- } from "./chunk-MICF64AZ.js";
4
+ } from "./chunk-QGAEXUP5.js";
5
5
  import {
6
6
  prefetchCss
7
- } from "./chunk-IKCEA3YN.js";
7
+ } from "./chunk-YDO7SPF4.js";
8
8
  import {
9
9
  absolute,
10
10
  addLink,
@@ -13,7 +13,7 @@ import {
13
13
  pageOrigin,
14
14
  withRetry,
15
15
  withTimeout
16
- } from "./chunk-GGMM56TM.js";
16
+ } from "./chunk-VDVVEGAO.js";
17
17
  import {
18
18
  RemoteError,
19
19
  fail,
@@ -106,7 +106,7 @@ function loadRemote(name) {
106
106
  return load(name).then((r) => r.module);
107
107
  }
108
108
  function loadModule(name) {
109
- return import("./expose-2S3TCXSP.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
109
+ return import("./expose-KL6TA472.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
110
110
  }
111
111
  function preload(name, options = {}) {
112
112
  const done = load(name);
@@ -146,7 +146,7 @@ function warmSsr(holder) {
146
146
  }
147
147
  function load(name, isolate, priority) {
148
148
  const file = (n) => loadFile(n, isolate, priority);
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);
149
+ return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-KL6TA472.js").then((m) => m.resolveTarget(name, file))).catch(fail);
150
150
  }
151
151
  function loadFile(name, isolate, priority) {
152
152
  const p = protocol();
@@ -195,7 +195,7 @@ async function resolveEntry(name, entry, priority, early) {
195
195
  checkOrigin(name, entry.url);
196
196
  const keys = signed(entry);
197
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);
198
+ if (m?.stable) return resolveEntry(name, await (await import("./channel-BHOVSU5X.js")).pick(name, entry, m), priority);
199
199
  if (typeof m?.entry !== "string") throw new RemoteError("INVALID_MODULE", name, `manifesto inv\xE1lido em ${entry.url}`);
200
200
  if (m.contract && (entry.contract || protocol().settings().contract)) {
201
201
  const why = await (await import("./contract-3JY7SOGQ.js")).checkContract(m.contract, entry.contract);
@@ -251,9 +251,11 @@ function prefetchManifest(url, name, priority, keys) {
251
251
  }
252
252
  function manifestOf(url, name, priority, keys) {
253
253
  const { timeout, maxStale } = protocol().settings();
254
- const fresh = fetchJson(url, timeout, name, { cache: "no-cache", credentials: "same-origin", priority, integrity: keys.slice(1) });
254
+ const hinted = typeof document != "undefined" && [...document.querySelectorAll("link[as=fetch]")].some((l) => l.href == url);
255
+ const fresh = fetchJson(url, timeout, name, { ...!hinted && { cache: "no-cache" }, credentials: "same-origin", priority, integrity: keys.slice(1) });
255
256
  return maxStale ? import("./stale-XV4LNHDX.js").then((m) => m.stale(url, fresh, maxStale), () => fresh) : fresh;
256
257
  }
258
+ var plainFailed = /* @__PURE__ */ new Map();
257
259
  async function importModule(name, r) {
258
260
  const { timeout } = protocol().settings();
259
261
  const run = (url) => withTimeout(timeout, name, import(
@@ -264,13 +266,18 @@ async function importModule(name, r) {
264
266
  throw isRemoteError(e) ? e : new RemoteError("LOAD_FAILED", name, `falha ao importar ${r.entry}`, e);
265
267
  });
266
268
  if (!r.integrity) {
267
- if (!r.split) return run(r.entry);
269
+ const n = plainFailed.get(r.entry);
270
+ const again = (e, next) => {
271
+ plainFailed.set(r.entry, next);
272
+ throw e;
273
+ };
274
+ if (n != null || !r.split) return run(n ? r.entry + (r.entry.includes("?") ? "&" : "?") + "vitral-retry=" + n : r.entry).catch((e) => again(e, (n ?? 0) + 1));
268
275
  if (r.split.dedupe?.length) {
269
276
  const { shared, planned } = await dedupeModule();
270
277
  for (const d of planned(name, r.split).dedupe)
271
278
  shared(protocol())(d.name, d.range, { version: d.version, url: d.file, load: async () => (await run(d.file)).default });
272
279
  }
273
- return run(r.split.entry);
280
+ return run(r.split.entry).catch((e) => again(e, 0));
274
281
  }
275
282
  const sri = await paths;
276
283
  if (!sri) throw new RemoteError("LOAD_FAILED", name, "n\xE3o foi poss\xEDvel carregar o verificador de integrity");
@@ -29,6 +29,25 @@ async function exportOrigins(ctx, file, cache) {
29
29
  }
30
30
  return origins(file, parsed, /* @__PURE__ */ new Map(), []);
31
31
  }
32
+ async function exportSources(ctx, file, cache) {
33
+ await exportOrigins(ctx, file, cache);
34
+ const parsed = /* @__PURE__ */ new Map();
35
+ for (const [f, p] of cache) parsed.set(f, await p);
36
+ return sources(file, parsed, /* @__PURE__ */ new Map(), []);
37
+ }
38
+ function sources(file, parsed, memo, stack) {
39
+ const p = parsed.get(file);
40
+ if (!p || stack.includes(file)) return /* @__PURE__ */ new Map();
41
+ const known = memo.get(file);
42
+ if (known) return known;
43
+ const next = [...stack, file];
44
+ const out = /* @__PURE__ */ new Map();
45
+ for (const name of p.local.keys()) out.set(name, [file, name]);
46
+ for (const n of p.named) out.set(n.exported, n.source && sources(n.source, parsed, memo, next).get(n.name) || [file, n.exported]);
47
+ for (const s of p.star) for (const [name, v] of sources(s, parsed, memo, next)) if (name !== "default" && !out.has(name)) out.set(name, v);
48
+ memo.set(file, out);
49
+ return out;
50
+ }
32
51
  function origins(file, parsed, memo, stack) {
33
52
  if (stack.includes(file)) return /* @__PURE__ */ new Map();
34
53
  const known = memo.get(file);
@@ -257,6 +276,32 @@ function dedupeHooks(entry, getGroups) {
257
276
  origins2 = /* @__PURE__ */ new Map();
258
277
  exports.clear();
259
278
  },
279
+ /**
280
+ * Depois do build dividido: arquivos de um grupo que o código principal
281
+ * alcança sem passar pela cópia própria. Eles baixam e rodam mesmo com o
282
+ * pacote oferecido pelo host; o aviso mostra um caminho até cada grupo.
283
+ */
284
+ leaks(ctx, root) {
285
+ const from = /* @__PURE__ */ new Map();
286
+ const stack = ["\0" + BOOT];
287
+ while (stack.length) {
288
+ const id = stack.pop();
289
+ const m = ctx.getModuleInfo(id);
290
+ for (const d of [...m?.importedIds ?? [], ...m?.dynamicallyImportedIds ?? []]) if (!d.startsWith(OWN) && !from.has(d)) from.set(d, id), stack.push(d);
291
+ }
292
+ const r = norm(root) + "/";
293
+ const show = (id) => {
294
+ const v = /^\0([\w:-]*?:)(\/.*)$/.exec(id);
295
+ return v ? v[1] + show(v[2]) : norm(id).startsWith(r) ? norm(id).slice(r.length) : id.replace(/^\0/, "");
296
+ };
297
+ for (const g of getGroups()) {
298
+ const found = [...from.keys()].filter((id) => !id.startsWith("\0") && inside(g, id));
299
+ if (!found.length) continue;
300
+ const chain = [found[0]];
301
+ while (from.has(chain[0]) && !chain[0].startsWith("\0" + BOOT)) chain.unshift(from.get(chain[0]));
302
+ ctx.warn?.(`dedupe: ${found.length} arquivo(s) de ${g.name} entram no c\xF3digo principal do remote, fora da c\xF3pia pr\xF3pria: baixam e rodam mesmo com o pacote oferecido pelo host. Um caminho: ${chain.slice(1).map(show).join(" \u2192 ")}`);
303
+ }
304
+ },
260
305
  /** Algum grupo troca também os imports que chegam a arquivos do pacote? */
261
306
  files: () => getGroups().some((g) => g.files),
262
307
  resolveId: {
@@ -324,14 +369,18 @@ export { v${i} as ${JSON.stringify(n)} }
324
369
  ` + (own.has("default") ? `export { default } from ${f}
325
370
  ` : "");
326
371
  }
372
+ const from = rest.length ? await exportSources(ctx, file, exports) : /* @__PURE__ */ new Map();
373
+ const src = (n) => from.get(n) ?? [file, n];
374
+ const rel = (x) => x.slice(g.dir.length + 1);
327
375
  if (rest.length)
328
- ctx.warn?.(`dedupe: ${file.slice(g.dir.length + 1)}: ${rest.join(", ")} n\xE3o sai(em) por nenhum export de ${g.name}: esses nomes v\xEAm de uma c\xF3pia pr\xF3pria deste arquivo`);
376
+ ctx.warn?.(`dedupe: ${rel(file)}: ${rest.join(", ")} n\xE3o sai(em) por nenhum export de ${g.name}: esses nomes v\xEAm de uma c\xF3pia pr\xF3pria de ${[...new Set(rest.map((n) => rel(src(n)[0])))].join(", ")}, que entra no c\xF3digo principal do remote`);
377
+ const q = (n) => n === "default" ? "default" : JSON.stringify(n);
329
378
  return `import { deps } from ${JSON.stringify(DEPS)}
330
379
  ` + shared.map(([name, v], i) => `const v${i} = deps[${JSON.stringify(v.spec)}][${JSON.stringify(v.name)}]
331
380
  ` + (name === "default" ? `export default v${i}
332
381
  ` : `export { v${i} as ${JSON.stringify(name)} }
333
- `)).join("") + (rest.length ? `export { ${rest.map((n) => n === "default" ? "default" : JSON.stringify(n)).join(", ")} } from ${f}
334
- ` : "");
382
+ `)).join("") + rest.map((n) => `export { ${q(src(n)[1])} as ${q(n)} } from ${JSON.stringify(src(n)[0])}
383
+ `).join("");
335
384
  }
336
385
  return null;
337
386
  }
@@ -3,13 +3,13 @@ import {
3
3
  loadFile,
4
4
  registerSrc,
5
5
  resolveEntry
6
- } from "./chunk-AL6MLNVY.js";
6
+ } from "./chunk-52D6ZT4A.js";
7
7
  import {
8
8
  injectStyles
9
- } from "./chunk-IKCEA3YN.js";
9
+ } from "./chunk-YDO7SPF4.js";
10
10
  import {
11
11
  metric
12
- } from "./chunk-GGMM56TM.js";
12
+ } from "./chunk-VDVVEGAO.js";
13
13
  import {
14
14
  RemoteError,
15
15
  fail,
@@ -87,7 +87,7 @@ var noop = () => {
87
87
  async function checkUpdates() {
88
88
  const p = protocol();
89
89
  const found = [];
90
- const { splitName } = await import("./expose-2S3TCXSP.js");
90
+ const { splitName } = await import("./expose-KL6TA472.js");
91
91
  const remotes = /* @__PURE__ */ new Map();
92
92
  for (const name of live.keys()) {
93
93
  const root = splitName(name)[0];
@@ -132,8 +132,8 @@ async function mountOnce(target, name, props, options) {
132
132
  const p = protocol();
133
133
  await p.pending();
134
134
  const isolate = options.isolate ?? registered(name)?.isolate ?? p.settings().isolate;
135
- if (isolate === "iframe") return (frames ?? (await import("./reframe-HIYA2TIU.js")).noFrames)(target, name, props, options).catch(fail);
136
- const { module: mod, ...resolved } = await (isolate == "reframe" ? (await import("./reframe-HIYA2TIU.js")).load : load)(name, isolate, options.priority);
135
+ if (isolate === "iframe") return (frames ?? (await import("./reframe-AD2UEPIO.js")).noFrames)(target, name, props, options).catch(fail);
136
+ const { module: mod, ...resolved } = await (isolate == "reframe" ? (await import("./reframe-AD2UEPIO.js")).load : load)(name, isolate, options.priority);
137
137
  const untrack = track(name, resolved);
138
138
  ctxHooks.watch?.(name);
139
139
  const label = resolved.name ?? name;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  createSlot
3
- } from "./chunk-6JH2I65O.js";
3
+ } from "./chunk-I7IFR65H.js";
4
4
  import {
5
5
  policy,
6
6
  preload,
7
7
  registerSrc
8
- } from "./chunk-AL6MLNVY.js";
8
+ } from "./chunk-52D6ZT4A.js";
9
9
  import {
10
10
  ctxHooks
11
11
  } from "./chunk-JWDDXX5O.js";
@@ -1,7 +1,7 @@
1
1
  // src/core/bundled.ts
2
2
  var bundled = {};
3
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");
4
+ var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-Z5U32IR2.js");
5
5
 
6
6
  export {
7
7
  bundled,
@@ -6,20 +6,20 @@ import {
6
6
  import {
7
7
  hostSlot,
8
8
  when
9
- } from "./chunk-2SAI6S2H.js";
9
+ } from "./chunk-JKTZODC5.js";
10
10
  import {
11
11
  defineRemote,
12
12
  memoSelect,
13
13
  same,
14
14
  shared
15
- } from "./chunk-6JH2I65O.js";
15
+ } from "./chunk-I7IFR65H.js";
16
16
  import {
17
17
  policy,
18
18
  preload
19
- } from "./chunk-AL6MLNVY.js";
19
+ } from "./chunk-52D6ZT4A.js";
20
20
  import {
21
21
  dedupeModule
22
- } from "./chunk-MICF64AZ.js";
22
+ } from "./chunk-QGAEXUP5.js";
23
23
  import {
24
24
  events
25
25
  } from "./chunk-EQZOJU3B.js";
@@ -137,6 +137,11 @@ function preload2(name, options) {
137
137
  offerReact();
138
138
  preload(name, options);
139
139
  }
140
+ var defaultError = (retry) => /* @__PURE__ */ jsxs("div", { role: "alert", "data-vitral-default": "error", children: [
141
+ "N\xE3o foi poss\xEDvel carregar.",
142
+ " ",
143
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: retry, children: "Tentar de novo" })
144
+ ] });
140
145
  function Remote({
141
146
  name,
142
147
  src,
@@ -187,7 +192,7 @@ function Remote({
187
192
  let dead = false;
188
193
  let s = null;
189
194
  if (holder) {
190
- const go = () => import("./hydrate-FJHHLW5G.js").then((m) => {
195
+ const go = () => import("./hydrate-LS3MLFGN.js").then((m) => {
191
196
  if (!dead) slot.current = s = m.hydrateSlot(target.current, holder, { ...options, props: latest.current ?? {} });
192
197
  });
193
198
  const stop = policy() === "lazy" ? when(target.current, "visible", go) : (go(), () => {
@@ -211,7 +216,7 @@ function Remote({
211
216
  const { status, error: err } = state;
212
217
  return /* @__PURE__ */ jsxs("div", { className, "data-vitral": name ?? src, "data-vitral-status": status, children: [
213
218
  status === "loading" && !html && !snapped && fallback,
214
- status === "error" && err && (typeof error === "function" ? error(err, retry) : error ?? null),
219
+ status === "error" && err && (error === void 0 ? defaultError(retry) : typeof error === "function" ? error(err, retry) : error),
215
220
  html ? /* @__PURE__ */ jsx("div", { ref: target, dangerouslySetInnerHTML: { __html: html }, suppressHydrationWarning: true }) : /* @__PURE__ */ jsx("div", { ref: target })
216
221
  ] });
217
222
  }
@@ -2,18 +2,18 @@ import {
2
2
  hostSlot,
3
3
  timings,
4
4
  when
5
- } from "./chunk-2SAI6S2H.js";
5
+ } from "./chunk-JKTZODC5.js";
6
6
  import {
7
7
  defineRemote,
8
8
  memoSelect,
9
9
  same,
10
10
  shared
11
- } from "./chunk-6JH2I65O.js";
11
+ } from "./chunk-I7IFR65H.js";
12
12
  import {
13
13
  policy,
14
14
  registerSrc,
15
15
  warmSsr
16
- } from "./chunk-AL6MLNVY.js";
16
+ } from "./chunk-52D6ZT4A.js";
17
17
 
18
18
  // src/element.ts
19
19
  var Base = typeof HTMLElement === "undefined" ? class {
@@ -77,7 +77,7 @@ var VitralRemoteElement = class extends Base {
77
77
  };
78
78
  const ssr = true ? this.querySelector(":scope>[data-vitral-ssr]") : null;
79
79
  if (ssr) {
80
- const go = () => (warmSsr(ssr), import("./hydrate-FJHHLW5G.js").then((m) => this.isConnected && !this.#slot && (this.#slot = m.hydrateSlot(this, ssr, { ...options, props: this.#props }))));
80
+ const go = () => (warmSsr(ssr), import("./hydrate-LS3MLFGN.js").then((m) => this.isConnected && !this.#slot && (this.#slot = m.hydrateSlot(this, ssr, { ...options, props: this.#props }))));
81
81
  if (policy() === "lazy") when(this, "visible", go);
82
82
  else go();
83
83
  } else this.#slot = hostSlot(this, options);
@@ -3,12 +3,13 @@ import {
3
3
  } from "./chunk-UCFOXMOR.js";
4
4
  import {
5
5
  dedupeModule
6
- } from "./chunk-MICF64AZ.js";
6
+ } from "./chunk-QGAEXUP5.js";
7
7
  import {
8
8
  addLink,
9
9
  fetchBytes,
10
+ retryUrl,
10
11
  withTimeout
11
- } from "./chunk-GGMM56TM.js";
12
+ } from "./chunk-VDVVEGAO.js";
12
13
  import {
13
14
  RemoteError
14
15
  } from "./chunk-BQGVAXFM.js";
@@ -23,25 +24,40 @@ __export(sri_exports, {
23
24
  signature: () => signature,
24
25
  verified: () => verified
25
26
  });
26
- var failed = /* @__PURE__ */ new Set();
27
+ var failed = /* @__PURE__ */ new Map();
28
+ var noBlob = false;
29
+ var onViolation = (e) => e.blockedURI.startsWith("blob") && (noBlob = true);
30
+ var listening = false;
31
+ var owner;
27
32
  async function importVerified(name, r, run, timeout) {
28
33
  if (r.split?.dedupe?.length && globalThis[/* @__PURE__ */ Symbol.for("vitral")]?.settings().dedupePlan?.[name]) r = { ...r, split: (await dedupeModule()).planned(name, r.split) };
29
34
  const { entry, integrity, priority } = r;
30
- if (!failed.has(entry)) {
35
+ const p = globalThis[/* @__PURE__ */ Symbol.for("vitral")];
36
+ if (owner !== p) {
37
+ owner = p;
38
+ failed.clear();
39
+ mapped.clear();
40
+ noBlob = false;
41
+ maps = probing = preloads = void 0;
42
+ }
43
+ const tries = failed.get(entry);
44
+ if (tries === void 0 || noBlob) {
45
+ const one = retryUrl(entry, tries ?? 0);
31
46
  try {
32
47
  const go = async () => {
33
- const url2 = await verified(r.split ?? { entry, chunks: [], sri: { [entry]: integrity }, priority }, run);
48
+ const url2 = await verified(tries === void 0 && r.split ? r.split : { entry: one, chunks: [], sri: { [one]: integrity }, priority }, run);
34
49
  return url2 && { ns: await run(url2) };
35
50
  };
36
51
  const done = await withTimeout(timeout, name, go());
37
52
  if (done) return done.ns;
38
53
  } catch (e) {
39
- failed.add(entry);
40
- if (e instanceof RemoteError && e.code === "TIMEOUT") throw e;
54
+ failed.set(entry, (tries ?? 0) + 1);
55
+ if (e instanceof RemoteError && e.code === "TIMEOUT" || noBlob) throw e;
41
56
  }
42
57
  }
43
58
  const bytes = await fetchBytes(entry, timeout, name, { priority, ...failed.has(entry) && { cache: "reload" }, ...signature(integrity) });
44
59
  await verifyIntegrity(name, bytes, integrity);
60
+ if (!listening && typeof document !== "undefined") listening = true, document.addEventListener("securitypolicyviolation", onViolation);
45
61
  const url = URL.createObjectURL(new Blob([bytes], { type: "text/javascript" }));
46
62
  try {
47
63
  return await run(url);
@@ -128,6 +144,7 @@ async function addMap(sri, probe, own) {
128
144
  await map(integrity, fail);
129
145
  if (ok && probe) {
130
146
  let r = await check(load, urls[0], urls[1]);
147
+ if (r === void 0) noBlob = true;
131
148
  if (r === void 0 && own) {
132
149
  await map({ [own[0]]: PROBE_SRI, [own[1]]: PROBE_SRI }, fail);
133
150
  r = ok && await check(load, own[0], own[1]);
@@ -155,7 +172,7 @@ function preload(href, integrity, fetchPriority = "auto") {
155
172
  return new Promise((resolve, reject) => {
156
173
  const link = addLink("modulepreload", href, { integrity, fetchPriority });
157
174
  link.onload = resolve;
158
- link.onerror = reject;
175
+ link.onerror = () => reject(new Error(`falha ao baixar ${href}`));
159
176
  });
160
177
  }
161
178
  async function checkPreloads(own) {
@@ -13,6 +13,12 @@ function pageOrigin() {
13
13
  function absolute(url, base) {
14
14
  return new URL(url, base ?? (typeof location !== "undefined" ? location.href : void 0)).href;
15
15
  }
16
+ function retryUrl(url, n) {
17
+ const u = new URL(url);
18
+ if (!n || !u.protocol.startsWith("http")) return url;
19
+ u.searchParams.set("vitral-retry", String(n));
20
+ return u.href;
21
+ }
16
22
  async function withRetry(retries, fn) {
17
23
  for (let i = 0; ; i++) {
18
24
  try {
@@ -70,6 +76,7 @@ function metric(name, stage, start) {
70
76
  export {
71
77
  pageOrigin,
72
78
  absolute,
79
+ retryUrl,
73
80
  withRetry,
74
81
  withTimeout,
75
82
  fetchBytes,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  addLink,
3
3
  fetchBytes
4
- } from "./chunk-GGMM56TM.js";
4
+ } from "./chunk-VDVVEGAO.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-7ZV4JEO6.js").then((m) => m.prefetch(r, priority), noop);
26
+ if (shadow && adopts()) import("./shadow-ABRO7JNY.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-7ZV4JEO6.js").then((m) => m.attachShadowRoot(shadow, make, r, protocol().settings().styles, styles)) : injectCss(r.css, null, r.sri).then(() => [noop]);
30
+ return shadow ? import("./shadow-ABRO7JNY.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;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mountable
3
- } from "./chunk-AL6MLNVY.js";
3
+ } from "./chunk-52D6ZT4A.js";
4
4
  import {
5
5
  RemoteError
6
6
  } from "./chunk-BQGVAXFM.js";
package/dist/cli.js CHANGED
@@ -758,8 +758,27 @@ async function checkRemote(name, e, ctx, seen) {
758
758
  else out.push(ok(`integrity do ${who} confere`));
759
759
  }
760
760
  if (!e.integrity && !m.integrity) out.push(warn("sem integrity: o JS roda sem confer\xEAncia", void 0, "gere o manifesto com o plugin vitral/vite ou fixe integrity no host."));
761
- const gz = gzipSync(bytes).length;
762
- const size = `tamanho do JS: ${kb2(bytes.length)} (${kb2(gz)} com gzip)`;
761
+ let gz = gzipSync(bytes).length;
762
+ let size = `tamanho do JS: ${kb2(bytes.length)} (${kb2(gz)} com gzip)`;
763
+ if (m.split) {
764
+ const sum = async (files3) => {
765
+ let raw2 = 0;
766
+ let zip2 = 0;
767
+ for (const f of new Set(files3)) {
768
+ const got = await get(ctx.f, abs(f), ctx.origin, ctx.timeout);
769
+ if (!got.res?.ok || !got.bytes) continue;
770
+ raw2 += got.bytes.length;
771
+ zip2 += gzipSync(got.bytes).length;
772
+ }
773
+ return [raw2, zip2];
774
+ };
775
+ const soon = [m.split.entry, ...m.split.chunks ?? []];
776
+ const [raw, zip] = await sum(soon);
777
+ const own = (m.dedupe ?? []).flatMap((d) => [d.file, ...d.chunks ?? []]).filter((f) => !soon.includes(f));
778
+ const [, ownZip] = own.length ? await sum(own) : [0, 0];
779
+ size = `JS da montagem: ${kb2(raw)} (${kb2(zip)} com gzip), com as ofertas do host` + (own.length ? `; c\xF3pias pr\xF3prias do dedupe, s\xF3 sem oferta: ${kb2(ownZip)} com gzip` : "") + `; arquivo \xFAnico, s\xF3 em navegador antigo ou depois de falha: ${kb2(gz)} com gzip`;
780
+ gz = zip;
781
+ }
763
782
  if (ctx.maxKb !== void 0 && gz > ctx.maxKb * 1024)
764
783
  out.push(error(size, `passa do limite de ${ctx.maxKb} kB.`, "veja o que entrou no bundle (vite build --mode production com rollup-plugin-visualizer) e use dedupe para o framework."));
765
784
  else if (ctx.maxKb === void 0 && gz > WARN_KB * 1024) out.push(warn(size, `acima de ${WARN_KB} kB com gzip, o remote atrasa a p\xE1gina.`, "confira o que entrou no bundle; use dedupe para o framework; passe --max-kb para tornar isto um erro."));
@@ -895,7 +914,7 @@ async function doctorCli(argv, options = {}, log = console.log) {
895
914
  const json = args2.includes("--json");
896
915
  const stats = flag(args2, "--stats");
897
916
  if (stats) {
898
- const { routeReport, formatRoute } = await import("./route-4KQITYD4.js");
917
+ const { routeReport, formatRoute } = await import("./route-CEMWXHJI.js");
899
918
  const route = flag(args2, "--route") ?? "/";
900
919
  const remotes = [];
901
920
  for (let r3 = flag(args2, "--remote"); r3 !== void 0; r3 = flag(args2, "--remote")) remotes.push(r3);
package/dist/element.js CHANGED
@@ -3,13 +3,13 @@ import {
3
3
  VitralRemoteElement,
4
4
  defineVitralElement,
5
5
  elementRemote
6
- } from "./chunk-SVYL6UCB.js";
7
- import "./chunk-2SAI6S2H.js";
8
- import "./chunk-6JH2I65O.js";
9
- import "./chunk-AL6MLNVY.js";
10
- import "./chunk-MICF64AZ.js";
11
- import "./chunk-IKCEA3YN.js";
12
- import "./chunk-GGMM56TM.js";
6
+ } from "./chunk-UFETTKDP.js";
7
+ import "./chunk-JKTZODC5.js";
8
+ import "./chunk-I7IFR65H.js";
9
+ import "./chunk-52D6ZT4A.js";
10
+ import "./chunk-QGAEXUP5.js";
11
+ import "./chunk-YDO7SPF4.js";
12
+ import "./chunk-VDVVEGAO.js";
13
13
  import "./chunk-BQGVAXFM.js";
14
14
  import "./chunk-JWDDXX5O.js";
15
15
  import "./chunk-2Z4OH3BP.js";