vitral 0.3.0 → 0.4.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.
Files changed (55) hide show
  1. package/dist/angular.d.ts +2 -2
  2. package/dist/angular.js +7 -7
  3. package/dist/auto.js +7 -7
  4. package/dist/{capture-JYFERAPL.js → capture-TT5WBLJ6.js} +1 -1
  5. package/dist/channel-2YPYGX3J.js +95 -0
  6. package/dist/{chunk-AKNNHQ2H.js → chunk-463H6B56.js} +5 -0
  7. package/dist/chunk-54CBIZES.js +105 -0
  8. package/dist/{chunk-ZAC6QQI6.js → chunk-6EX5KYT5.js} +4 -4
  9. package/dist/{chunk-3YXI3G34.js → chunk-BCC25ANK.js} +11 -5
  10. package/dist/{chunk-TD4S3IHA.js → chunk-EMSB2NVX.js} +10 -8
  11. package/dist/{chunk-SDB5AZEI.js → chunk-IH3ZT3QU.js} +2 -2
  12. package/dist/{chunk-GNHCZRQP.js → chunk-TW7KYJQ6.js} +1 -1
  13. package/dist/{chunk-AH7KNMBW.js → chunk-UYOPJ4XQ.js} +1 -1
  14. package/dist/{chunk-IHTUM6LT.js → chunk-W6322KGP.js} +2 -2
  15. package/dist/{chunk-I3VSKSAZ.js → chunk-WD4CDGDZ.js} +21 -20
  16. package/dist/cli.js +1152 -37
  17. package/dist/devtools.d.ts +32 -2
  18. package/dist/devtools.js +27 -12
  19. package/dist/element.d.ts +12 -3
  20. package/dist/element.js +7 -7
  21. package/dist/embed.js +2 -0
  22. package/dist/{events-D5gs7rff.d.ts → events-Dkpkw_Sv.d.ts} +1 -1
  23. package/dist/expose-OVWTPHH5.js +15 -0
  24. package/dist/federation.d.ts +89 -0
  25. package/dist/federation.js +101 -0
  26. package/dist/iframe.js +7 -7
  27. package/dist/index.d.ts +4 -4
  28. package/dist/index.js +5 -5
  29. package/dist/overrides-NP754HY7.js +27 -0
  30. package/dist/preact.d.ts +4 -4
  31. package/dist/preact.js +6 -6
  32. package/dist/react.d.ts +3 -3
  33. package/dist/react.js +6 -6
  34. package/dist/routes.d.ts +2 -2
  35. package/dist/routes.js +5 -5
  36. package/dist/{shadow-6HELCHCJ.js → shadow-PVSETNMZ.js} +66 -5
  37. package/dist/single-spa.d.ts +40 -0
  38. package/dist/single-spa.js +52 -0
  39. package/dist/{slot-DqXTwGbs.d.ts → slot-UPg6ob9v.d.ts} +1 -1
  40. package/dist/solid.d.ts +3 -3
  41. package/dist/solid.js +6 -6
  42. package/dist/{sri-JMX6JLQP.js → sri-M7ZRU57G.js} +40 -10
  43. package/dist/svelte.d.ts +4 -4
  44. package/dist/svelte.js +6 -6
  45. package/dist/testing.d.ts +1 -1
  46. package/dist/testing.js +5 -5
  47. package/dist/{types-Czvm-siZ.d.ts → types-CA2p9KHC.d.ts} +112 -4
  48. package/dist/vite.d.ts +18 -0
  49. package/dist/vite.js +341 -35
  50. package/dist/vue.d.ts +3 -3
  51. package/dist/vue.js +6 -6
  52. package/package.json +79 -21
  53. package/dist/chunk-DXORSF4X.js +0 -42
  54. package/dist/expose-JUOUN5N5.js +0 -15
  55. package/dist/overrides-NZAIUGK5.js +0 -15
package/dist/angular.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { InjectionToken, Type, ApplicationConfig, Signal, Provider, EnvironmentProviders } from '@angular/core';
2
- import { R as RemoteContext, P as Props, a as RemoteModule, S as Shared, V as VitralConfig } from './types-Czvm-siZ.js';
3
- export { e as events } from './events-D5gs7rff.js';
2
+ import { R as RemoteContext, P as Props, a as RemoteModule, S as Shared, V as VitralConfig } from './types-CA2p9KHC.js';
3
+ export { e as events } from './events-Dkpkw_Sv.js';
4
4
  export { n as navigate } from './navigate-BRG1WJUM.js';
5
5
  import './errors-kjBv6IH_.js';
6
6
 
package/dist/angular.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineVitralElement
3
- } from "./chunk-3YXI3G34.js";
4
- import "./chunk-IHTUM6LT.js";
3
+ } from "./chunk-BCC25ANK.js";
4
+ import "./chunk-W6322KGP.js";
5
5
  import {
6
6
  defineRemote,
7
7
  events,
@@ -9,13 +9,13 @@ import {
9
9
  navigate,
10
10
  same,
11
11
  shared
12
- } from "./chunk-I3VSKSAZ.js";
12
+ } from "./chunk-WD4CDGDZ.js";
13
13
  import {
14
14
  configure
15
- } from "./chunk-TD4S3IHA.js";
16
- import "./chunk-ZAC6QQI6.js";
17
- import "./chunk-GNHCZRQP.js";
18
- import "./chunk-AKNNHQ2H.js";
15
+ } from "./chunk-EMSB2NVX.js";
16
+ import "./chunk-6EX5KYT5.js";
17
+ import "./chunk-TW7KYJQ6.js";
18
+ import "./chunk-463H6B56.js";
19
19
  import "./chunk-GNPFWISJ.js";
20
20
 
21
21
  // src/angular.ts
package/dist/auto.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  defineVitralElement
3
- } from "./chunk-3YXI3G34.js";
4
- import "./chunk-IHTUM6LT.js";
5
- import "./chunk-I3VSKSAZ.js";
6
- import "./chunk-TD4S3IHA.js";
7
- import "./chunk-ZAC6QQI6.js";
8
- import "./chunk-GNHCZRQP.js";
9
- import "./chunk-AKNNHQ2H.js";
3
+ } from "./chunk-BCC25ANK.js";
4
+ import "./chunk-W6322KGP.js";
5
+ import "./chunk-WD4CDGDZ.js";
6
+ import "./chunk-EMSB2NVX.js";
7
+ import "./chunk-6EX5KYT5.js";
8
+ import "./chunk-TW7KYJQ6.js";
9
+ import "./chunk-463H6B56.js";
10
10
  import "./chunk-GNPFWISJ.js";
11
11
 
12
12
  // src/auto.ts
@@ -4,7 +4,7 @@ import {
4
4
  mounted,
5
5
  report,
6
6
  reported
7
- } from "./chunk-AKNNHQ2H.js";
7
+ } from "./chunk-463H6B56.js";
8
8
  import {
9
9
  protocol
10
10
  } from "./chunk-GNPFWISJ.js";
@@ -0,0 +1,95 @@
1
+ import {
2
+ absolute
3
+ } from "./chunk-TW7KYJQ6.js";
4
+ import {
5
+ RemoteError,
6
+ ctxHooks
7
+ } from "./chunk-463H6B56.js";
8
+ import {
9
+ protocol
10
+ } from "./chunk-GNPFWISJ.js";
11
+
12
+ // src/core/channel.ts
13
+ var ROLLBACK_KEY = "vitral:rollback";
14
+ var ID_KEY = "vitral:id";
15
+ var watching = /* @__PURE__ */ new Map();
16
+ var abandoned = {};
17
+ var id;
18
+ async function pick(name, entry, channel) {
19
+ if (typeof channel.stable != "string") throw new RemoteError("INVALID_MODULE", name, `canal inv\xE1lido em ${entry.url}: falta "stable"`);
20
+ ctxHooks.watch = watch;
21
+ const ctx = { name, bucket: bucket(name) };
22
+ const { canary, stable } = channel;
23
+ let version = await entry.resolve?.(channel, ctx) ?? (canary && ctx.bucket < canary.percent ? canary.version : stable);
24
+ if (version !== stable && rolledBack()[name] === version) version = stable;
25
+ if (version === stable || entry.rollback === false) watching.delete(name);
26
+ else if (watching.get(name)?.from !== version) {
27
+ watching.set(name, { from: version, to: stable, errors: 0, mounts: 0, max: { errors: 3, mounts: 20, ...entry.rollback } });
28
+ }
29
+ return { ...entry, url: versionUrl(version, entry.url), integrity: void 0, manifest: void 0 };
30
+ }
31
+ var versionUrl = (version, channel) => absolute(/[/:]|\.(m?js|json)$/.test(version) ? version : `${version}/vitral.json`, channel);
32
+ function bucket(name) {
33
+ const key = protocol().settings().canaryKey ?? browserId();
34
+ let h = 2166136261;
35
+ for (const c of `${key}:${name}`) h = Math.imul(h ^ c.charCodeAt(0), 16777619);
36
+ return (h >>> 0) % 100;
37
+ }
38
+ function browserId() {
39
+ try {
40
+ id ??= localStorage.getItem(ID_KEY) ?? void 0;
41
+ } catch {
42
+ }
43
+ if (!id) {
44
+ id = Math.random().toString(36).slice(2);
45
+ try {
46
+ localStorage.setItem(ID_KEY, id);
47
+ } catch {
48
+ }
49
+ }
50
+ return id;
51
+ }
52
+ function rolledBack() {
53
+ try {
54
+ return { ...JSON.parse(sessionStorage.getItem(ROLLBACK_KEY) || "{}"), ...abandoned };
55
+ } catch {
56
+ return abandoned;
57
+ }
58
+ }
59
+ function watch(name, error) {
60
+ for (const [key, w] of watching) {
61
+ if (name !== key && !name.startsWith(key + "/")) continue;
62
+ if (!error) {
63
+ if (++w.mounts > w.max.mounts) w.mounts = 1, w.errors = 0;
64
+ } else if (++w.errors >= w.max.errors) {
65
+ rollback(key, w);
66
+ }
67
+ }
68
+ }
69
+ function rollback(name, w) {
70
+ watching.delete(name);
71
+ abandoned = { ...rolledBack(), [name]: w.from };
72
+ try {
73
+ sessionStorage.setItem(ROLLBACK_KEY, JSON.stringify(abandoned));
74
+ } catch {
75
+ }
76
+ console.warn(`[vitral] ${name}: ${w.errors} erros em ${w.mounts} montagens da vers\xE3o ${w.from}; voltando para ${w.to}`);
77
+ try {
78
+ protocol().settings().onRollback?.({ name, from: w.from, to: w.to, errors: w.errors, mounts: w.mounts });
79
+ } catch {
80
+ }
81
+ const p = protocol();
82
+ p.register(name, p.entry(name));
83
+ p.events.emit("vitral:refresh", name);
84
+ }
85
+ function resetChannels() {
86
+ watching.clear();
87
+ abandoned = {};
88
+ id = void 0;
89
+ }
90
+ export {
91
+ bucket,
92
+ pick,
93
+ resetChannels,
94
+ versionUrl
95
+ };
@@ -2,6 +2,9 @@ import {
2
2
  protocol
3
3
  } from "./chunk-GNPFWISJ.js";
4
4
 
5
+ // src/core/hooks.ts
6
+ var ctxHooks = {};
7
+
5
8
  // src/core/errors.ts
6
9
  var ERROR_DOCS = "https://joaogabriel15.github.io/vitral/erros/";
7
10
  var RemoteError = class extends Error {
@@ -28,6 +31,7 @@ function report(e, from) {
28
31
  protocol().settings().onError?.(e);
29
32
  } catch {
30
33
  }
34
+ ctxHooks.watch?.(e.remote, e);
31
35
  }
32
36
  return e;
33
37
  }
@@ -36,6 +40,7 @@ var fail = (e) => {
36
40
  };
37
41
 
38
42
  export {
43
+ ctxHooks,
39
44
  RemoteError,
40
45
  isRemoteError,
41
46
  mounted,
@@ -0,0 +1,105 @@
1
+ import {
2
+ protocol
3
+ } from "./chunk-GNPFWISJ.js";
4
+
5
+ // src/core/overrides.ts
6
+ var OVERRIDES_KEY = "vitral:overrides";
7
+ function overridesEnabled() {
8
+ return !!protocol().settings().devOverrides || typeof location !== "undefined" && /^(localhost|127\.0\.0\.1|\[::1\])$/.test(location.hostname);
9
+ }
10
+ var manifestUrl = (url) => /\.(json|m?js)(\?|$)/.test(url) ? url : url.replace(/\/?$/, "/vitral.json");
11
+ var isRef = (value) => /^[\w.-]+$/.test(value);
12
+ var read = (store) => {
13
+ try {
14
+ return JSON.parse(store().getItem(OVERRIDES_KEY) ?? "{}") ?? {};
15
+ } catch {
16
+ return {};
17
+ }
18
+ };
19
+ var write = (store, all) => {
20
+ try {
21
+ if (Object.keys(all).length) store().setItem(OVERRIDES_KEY, JSON.stringify(all));
22
+ else store().removeItem(OVERRIDES_KEY);
23
+ } catch {
24
+ }
25
+ };
26
+ var local = () => localStorage;
27
+ var session = () => sessionStorage;
28
+ var storedOverrides = () => read(local);
29
+ function storeOverride(name, value) {
30
+ const all = storedOverrides();
31
+ if (value) all[name] = isRef(value) ? value : manifestUrl(value);
32
+ else delete all[name];
33
+ write(local, all);
34
+ }
35
+ function tabOverrides() {
36
+ const all = read(session);
37
+ const pairs = new URLSearchParams(location.search).getAll("vitral").join(",").split(",");
38
+ if (!pairs.some(Boolean)) return all;
39
+ for (const pair of pairs) {
40
+ const at = pair.indexOf("@");
41
+ if (pair === "off") clearOverrides(), Object.keys(all).forEach((k) => delete all[k]);
42
+ else if (at > 0 && pair.slice(at + 1) === "off") delete all[pair.slice(0, at)];
43
+ else if (at > 0) all[pair.slice(0, at)] = pair.slice(at + 1);
44
+ }
45
+ write(session, all);
46
+ return all;
47
+ }
48
+ function clearOverrides() {
49
+ write(session, {});
50
+ write(local, {});
51
+ }
52
+ function dropOverride(name) {
53
+ for (const store of [session, local]) {
54
+ const all = read(store);
55
+ delete all[name];
56
+ write(store, all);
57
+ }
58
+ }
59
+ function resolveOverride(name, value) {
60
+ if (!isRef(value)) return new URL(manifestUrl(value), location.href).href;
61
+ const d = protocol().settings().devOverrides;
62
+ const preview = typeof d === "object" ? d.preview : void 0;
63
+ if (!preview) return;
64
+ const url = preview.replace(/\{name\}/g, encodeURIComponent(name)).replace(/\{ref\}/g, encodeURIComponent(value));
65
+ return new URL(manifestUrl(url), location.href).href;
66
+ }
67
+ function activeOverrides() {
68
+ const tab = tabOverrides();
69
+ const all = {};
70
+ for (const [source, map] of [["navegador", storedOverrides()], ["aba", tab]]) {
71
+ for (const [name, value] of Object.entries(map)) all[name] = { name, value, url: resolveOverride(name, value), source };
72
+ }
73
+ return Object.values(all);
74
+ }
75
+ var warned = /* @__PURE__ */ new Set();
76
+ function overrideFor(name) {
77
+ if (!overridesEnabled()) return;
78
+ const o = activeOverrides().find((o2) => o2.name === name);
79
+ if (!o) return;
80
+ const first = !warned.has(name) && warned.add(name);
81
+ if (!o.url) {
82
+ if (first) console.warn(`[vitral] override ${name}@${o.value} ignorado: falta configure({ devOverrides: { preview } })`);
83
+ return;
84
+ }
85
+ const p = protocol();
86
+ const trusted = p.settings().trusted ?? [];
87
+ const origin = new URL(o.url).origin;
88
+ if (!trusted.includes(origin)) p.configure({ trusted: [...trusted, origin] });
89
+ if (first) console.warn(`[vitral] override ativo: ${name} \u2192 ${o.url} (${o.source}). Para limpar: ?vitral=off`);
90
+ return { url: o.url };
91
+ }
92
+
93
+ export {
94
+ OVERRIDES_KEY,
95
+ overridesEnabled,
96
+ manifestUrl,
97
+ isRef,
98
+ storedOverrides,
99
+ storeOverride,
100
+ clearOverrides,
101
+ dropOverride,
102
+ resolveOverride,
103
+ activeOverrides,
104
+ overrideFor
105
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  addLink,
3
3
  fetchBytes
4
- } from "./chunk-GNHCZRQP.js";
4
+ } from "./chunk-TW7KYJQ6.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-6HELCHCJ.js").then((m) => m.prefetch(r, priority), noop);
26
+ if (shadow && adopts()) import("./shadow-PVSETNMZ.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
- function injectStyles(r, root, el, styles) {
30
- return root ? import("./shadow-6HELCHCJ.js").then((m) => m.attachStyles(root, el, r, protocol().settings().styles, styles)) : injectCss(r.css, null, r.sri).then(() => [noop]);
29
+ function injectStyles(r, shadow, make, styles) {
30
+ return shadow ? import("./shadow-PVSETNMZ.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,16 +1,16 @@
1
1
  import {
2
2
  hostSlot,
3
3
  timings
4
- } from "./chunk-IHTUM6LT.js";
4
+ } from "./chunk-W6322KGP.js";
5
5
  import {
6
6
  defineRemote,
7
7
  memoSelect,
8
8
  same,
9
9
  shared
10
- } from "./chunk-I3VSKSAZ.js";
10
+ } from "./chunk-WD4CDGDZ.js";
11
11
  import {
12
12
  registerSrc
13
- } from "./chunk-TD4S3IHA.js";
13
+ } from "./chunk-EMSB2NVX.js";
14
14
 
15
15
  // src/element.ts
16
16
  var Base = typeof HTMLElement === "undefined" ? class {
@@ -135,8 +135,14 @@ function defineVitralElement(tag = "vitral-remote") {
135
135
  function elementRemote(tag, setup) {
136
136
  return defineRemote({
137
137
  mount(el, props, ctx) {
138
- setup?.();
139
- const node = document.createElement(tag);
138
+ const registry = ctx.customElements ?? customElements;
139
+ const name = setup?.(registry) || tag;
140
+ let node;
141
+ try {
142
+ node = document.createElement(name, { customElementRegistry: registry });
143
+ } catch {
144
+ node = document.createElement(name);
145
+ }
140
146
  node.vitral = ctx;
141
147
  Object.assign(node, props);
142
148
  el.appendChild(node);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  prefetchCss
3
- } from "./chunk-ZAC6QQI6.js";
3
+ } from "./chunk-6EX5KYT5.js";
4
4
  import {
5
5
  absolute,
6
6
  addLink,
@@ -9,13 +9,13 @@ import {
9
9
  pageOrigin,
10
10
  withRetry,
11
11
  withTimeout
12
- } from "./chunk-GNHCZRQP.js";
12
+ } from "./chunk-TW7KYJQ6.js";
13
13
  import {
14
14
  RemoteError,
15
15
  fail,
16
16
  isRemoteError,
17
17
  report
18
- } from "./chunk-AKNNHQ2H.js";
18
+ } from "./chunk-463H6B56.js";
19
19
  import {
20
20
  protocol
21
21
  } from "./chunk-GNPFWISJ.js";
@@ -25,7 +25,7 @@ function configure(config) {
25
25
  const p = protocol();
26
26
  const { remotes, dedupe, ...rest } = config;
27
27
  p.configure(rest);
28
- if (rest.captureGlobalErrors) import("./capture-JYFERAPL.js").then((m) => m.capture());
28
+ if (rest.captureGlobalErrors) import("./capture-TT5WBLJ6.js").then((m) => m.capture());
29
29
  if (dedupe) p.pending(import("./dedupe-S7BHQMOZ.js").then((m) => m.offer(p, dedupe)).catch(() => {
30
30
  }));
31
31
  if (typeof remotes === "string") {
@@ -79,7 +79,7 @@ function loadRemote(name) {
79
79
  return load(name).then((r) => r.module);
80
80
  }
81
81
  function loadModule(name) {
82
- return import("./expose-JUOUN5N5.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
82
+ return import("./expose-OVWTPHH5.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
83
83
  }
84
84
  function preload(name) {
85
85
  load(name).catch(() => {
@@ -88,12 +88,12 @@ function preload(name) {
88
88
  var paths;
89
89
  function load(name, isolate, priority) {
90
90
  const file = (n) => loadFile(n, isolate, priority);
91
- return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-JUOUN5N5.js").then((m) => m.resolveTarget(name, file))).catch(fail);
91
+ return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-OVWTPHH5.js").then((m) => m.resolveTarget(name, file))).catch(fail);
92
92
  }
93
93
  function loadFile(name, isolate, priority) {
94
94
  const p = protocol();
95
95
  return p.load(name, async () => {
96
- paths ??= import("./sri-JMX6JLQP.js").catch(() => null);
96
+ paths ??= import("./sri-M7ZRU57G.js").catch(() => null);
97
97
  let resolved;
98
98
  try {
99
99
  await p.pending();
@@ -116,7 +116,8 @@ function loadFile(name, isolate, priority) {
116
116
  }
117
117
  function devOverride(name) {
118
118
  try {
119
- if (/vitral/.test(location.search + localStorage.getItem("vitral:overrides"))) return import("./overrides-NZAIUGK5.js").then((m) => m.overrideFor(name));
119
+ const k = "vitral:overrides";
120
+ if (location.search.includes("vitral") || localStorage[k] || sessionStorage[k]) return import("./overrides-NP754HY7.js").then((m) => m.overrideFor(name));
120
121
  } catch {
121
122
  }
122
123
  }
@@ -128,6 +129,7 @@ async function loadLocal(name, entry) {
128
129
  async function resolveEntry(name, entry, priority) {
129
130
  checkOrigin(name, entry.url);
130
131
  const m = entry.manifest ?? (new URL(entry.url).pathname.endsWith(".json") ? await fetchJson(entry.url, protocol().settings().timeout, name, { cache: "no-cache", priority }) : { name, entry: entry.url });
132
+ if (m?.stable) return resolveEntry(name, await (await import("./channel-2YPYGX3J.js")).pick(name, entry, m), priority);
131
133
  if (typeof m?.entry !== "string") throw new RemoteError("INVALID_MODULE", name, `manifesto inv\xE1lido em ${entry.url}`);
132
134
  if (m.contract && (entry.contract || protocol().settings().contract)) {
133
135
  const why = await (await import("./contract-46EZFQPQ.js")).checkContract(m.contract, entry.contract);
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  mountable
3
- } from "./chunk-TD4S3IHA.js";
3
+ } from "./chunk-EMSB2NVX.js";
4
4
  import {
5
5
  RemoteError
6
- } from "./chunk-AKNNHQ2H.js";
6
+ } from "./chunk-463H6B56.js";
7
7
  import {
8
8
  protocol
9
9
  } from "./chunk-GNPFWISJ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RemoteError,
3
3
  isRemoteError
4
- } from "./chunk-AKNNHQ2H.js";
4
+ } from "./chunk-463H6B56.js";
5
5
  import {
6
6
  protocol
7
7
  } from "./chunk-GNPFWISJ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RemoteError
3
- } from "./chunk-AKNNHQ2H.js";
3
+ } from "./chunk-463H6B56.js";
4
4
 
5
5
  // src/core/integrity.ts
6
6
  var clean = (b64) => b64.replace(/-/g, "+").replace(/_/g, "/").replace(/=/g, "");
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createSlot
3
- } from "./chunk-I3VSKSAZ.js";
3
+ } from "./chunk-WD4CDGDZ.js";
4
4
  import {
5
5
  preload,
6
6
  registerSrc
7
- } from "./chunk-TD4S3IHA.js";
7
+ } from "./chunk-EMSB2NVX.js";
8
8
 
9
9
  // src/core/host-slot.ts
10
10
  var noop = () => {
@@ -3,20 +3,21 @@ import {
3
3
  loadFile,
4
4
  registerSrc,
5
5
  resolveEntry
6
- } from "./chunk-TD4S3IHA.js";
6
+ } from "./chunk-EMSB2NVX.js";
7
7
  import {
8
8
  injectStyles
9
- } from "./chunk-ZAC6QQI6.js";
9
+ } from "./chunk-6EX5KYT5.js";
10
10
  import {
11
11
  metric
12
- } from "./chunk-GNHCZRQP.js";
12
+ } from "./chunk-TW7KYJQ6.js";
13
13
  import {
14
14
  RemoteError,
15
+ ctxHooks,
15
16
  fail,
16
17
  isRemoteError,
17
18
  mounted,
18
19
  report
19
- } from "./chunk-AKNNHQ2H.js";
20
+ } from "./chunk-463H6B56.js";
20
21
  import {
21
22
  protocol
22
23
  } from "./chunk-GNPFWISJ.js";
@@ -47,9 +48,6 @@ function scopedEvents() {
47
48
  };
48
49
  }
49
50
 
50
- // src/core/hooks.ts
51
- var ctxHooks = {};
52
-
53
51
  // src/core/navigate.ts
54
52
  function navigate(url, options = {}) {
55
53
  const target = new URL(url, location.href);
@@ -121,7 +119,7 @@ var noop = () => {
121
119
  async function checkUpdates() {
122
120
  const p = protocol();
123
121
  const found = [];
124
- const { splitName } = await import("./expose-JUOUN5N5.js");
122
+ const { splitName } = await import("./expose-OVWTPHH5.js");
125
123
  const remotes = /* @__PURE__ */ new Map();
126
124
  for (const name of live.keys()) {
127
125
  const root = splitName(name)[0];
@@ -171,21 +169,23 @@ async function mountOnce(target, name, props, options) {
171
169
  }
172
170
  const { module: mod, ...resolved } = await load(name, options.isolate, options.priority);
173
171
  const untrack = track(name, resolved);
172
+ ctxHooks.watch?.(name);
174
173
  const isolate = options.isolate ?? resolved.isolate ?? protocol().settings().isolate;
175
174
  const label = resolved.name ?? name;
176
- let shadowRoot = null;
177
- const el = document.createElement("div");
178
- el.setAttribute("data-vitral-root", label);
179
- if (resolved.scope) el.setAttribute("data-vitral-scope", resolved.scope);
180
- el.style.display = "contents";
181
- if (isolate === "shadow") {
182
- shadowRoot = target.shadowRoot ?? target.attachShadow({ mode: "open" });
183
- shadowRoot.appendChild(el);
184
- } else {
185
- target.appendChild(el);
186
- }
175
+ const make = (options2) => {
176
+ const el2 = document.createElement("div", options2);
177
+ el2.setAttribute("data-vitral-root", label);
178
+ if (resolved.scope) el2.setAttribute("data-vitral-scope", resolved.scope);
179
+ el2.style.display = "contents";
180
+ return el2;
181
+ };
187
182
  let t = performance.now();
188
- const [release, portal = document.body] = await injectStyles(resolved, shadowRoot, el, options.styles);
183
+ const [release, portal = document.body, shadowRoot = null, registry = customElements, el = target.appendChild(make())] = await injectStyles(
184
+ resolved,
185
+ isolate === "shadow" && target,
186
+ make,
187
+ options.styles
188
+ );
189
189
  metric(name, "css", t);
190
190
  t = performance.now();
191
191
  const scoped = scopedEvents();
@@ -196,6 +196,7 @@ async function mountOnce(target, name, props, options) {
196
196
  events: scoped.bus,
197
197
  shadowRoot,
198
198
  portalContainer: portal,
199
+ customElements: registry,
199
200
  reportError(e) {
200
201
  const err = report(isRemoteError(e) ? e : new RemoteError("RENDER_FAILED", label, String(e?.message ?? e), e), resolved);
201
202
  if (options.onError) options.onError(err);