vitral 0.2.0 → 0.3.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/README.md +1 -1
- package/dist/angular.d.ts +3 -2
- package/dist/angular.js +7 -6
- package/dist/auto.js +7 -6
- package/dist/capture-JYFERAPL.js +42 -0
- package/dist/{chunk-6Y3VMWHH.js → chunk-3YXI3G34.js} +3 -3
- package/dist/{chunk-S5MZT5IT.js → chunk-AH7KNMBW.js} +1 -1
- package/dist/chunk-AKNNHQ2H.js +45 -0
- package/dist/{chunk-PX7PBCCT.js → chunk-GNHCZRQP.js} +7 -17
- package/dist/{chunk-NCONW6WS.js → chunk-I3VSKSAZ.js} +58 -30
- package/dist/{chunk-UTYAX6MU.js → chunk-IHTUM6LT.js} +2 -2
- package/dist/{chunk-HP6QWU6K.js → chunk-SDB5AZEI.js} +2 -2
- package/dist/{chunk-2XF5BKV3.js → chunk-TD4S3IHA.js} +23 -12
- package/dist/chunk-ZAC6QQI6.js +64 -0
- package/dist/cli.js +59 -9
- package/dist/contract-46EZFQPQ.js +17 -0
- package/dist/{dedupe-IWFIXRWG.js → dedupe-S7BHQMOZ.js} +4 -3
- package/dist/element.d.ts +3 -3
- package/dist/element.js +7 -6
- package/dist/{errors-KKB8FGCz.d.ts → errors-kjBv6IH_.d.ts} +7 -1
- package/dist/{events-DUdjhfps.d.ts → events-D5gs7rff.d.ts} +1 -1
- package/dist/expose-JUOUN5N5.js +15 -0
- package/dist/iframe.d.ts +1 -1
- package/dist/iframe.js +13 -10
- package/dist/index.d.ts +23 -21
- package/dist/index.js +5 -4
- package/dist/otel.d.ts +44 -0
- package/dist/otel.js +27 -0
- package/dist/preact.d.ts +5 -5
- package/dist/preact.js +6 -5
- package/dist/react.d.ts +12 -4
- package/dist/react.js +11 -6
- package/dist/routes.d.ts +3 -3
- package/dist/routes.js +5 -4
- package/dist/sentry.d.ts +25 -0
- package/dist/sentry.js +11 -0
- package/dist/{shadow-MYRJQLLY.js → shadow-6HELCHCJ.js} +37 -11
- package/dist/{slot-pB276oPt.d.ts → slot-DqXTwGbs.d.ts} +2 -2
- package/dist/solid.d.ts +4 -4
- package/dist/solid.js +6 -5
- package/dist/{sri-BVKZNX5Q.js → sri-JMX6JLQP.js} +6 -4
- package/dist/svelte.d.ts +5 -5
- package/dist/svelte.js +6 -5
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +5 -4
- package/dist/{types-BV-hUrms.d.ts → types-Czvm-siZ.d.ts} +63 -1
- package/dist/vite.d.ts +8 -0
- package/dist/vite.js +364 -35
- package/dist/vue.d.ts +10 -3
- package/dist/vue.js +10 -5
- package/package.json +54 -20
- package/dist/chunk-SFL6LTP3.js +0 -56
- package/dist/expose-53BEJB34.js +0 -14
package/README.md
CHANGED
|
@@ -187,7 +187,7 @@ Para isolar por completo, use Shadow DOM:
|
|
|
187
187
|
<Remote name="carrinho" isolate="shadow" />
|
|
188
188
|
```
|
|
189
189
|
|
|
190
|
-
Com Shadow DOM, as regras `@property` e `@font-face` sobem para o documento, então sombras, rings, gradientes e fontes do Tailwind v4 funcionam.
|
|
190
|
+
Com Shadow DOM, as regras `@property` e `@font-face` sobem para o documento, então sombras, rings, gradientes e fontes do Tailwind v4 funcionam. O plugin já faz essa separação no build (campo `shadow` do `vitral.json`): a página só adota o CSS pronto. Manifestos antigos continuam funcionando, com a separação feita no navegador.
|
|
191
191
|
|
|
192
192
|
O remote também pode usar o tema do host:
|
|
193
193
|
|
package/dist/angular.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
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-
|
|
3
|
-
export { e as events } from './events-
|
|
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';
|
|
4
4
|
export { n as navigate } from './navigate-BRG1WJUM.js';
|
|
5
|
+
import './errors-kjBv6IH_.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Adaptador Angular (standalone, zoneless ou com zone.js).
|
package/dist/angular.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineVitralElement
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-3YXI3G34.js";
|
|
4
|
+
import "./chunk-IHTUM6LT.js";
|
|
5
5
|
import {
|
|
6
6
|
defineRemote,
|
|
7
7
|
events,
|
|
@@ -9,12 +9,13 @@ import {
|
|
|
9
9
|
navigate,
|
|
10
10
|
same,
|
|
11
11
|
shared
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-I3VSKSAZ.js";
|
|
13
13
|
import {
|
|
14
14
|
configure
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-TD4S3IHA.js";
|
|
16
|
+
import "./chunk-ZAC6QQI6.js";
|
|
17
|
+
import "./chunk-GNHCZRQP.js";
|
|
18
|
+
import "./chunk-AKNNHQ2H.js";
|
|
18
19
|
import "./chunk-GNPFWISJ.js";
|
|
19
20
|
|
|
20
21
|
// src/angular.ts
|
package/dist/auto.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineVitralElement
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
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";
|
|
9
10
|
import "./chunk-GNPFWISJ.js";
|
|
10
11
|
|
|
11
12
|
// src/auto.ts
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RemoteError,
|
|
3
|
+
isRemoteError,
|
|
4
|
+
mounted,
|
|
5
|
+
report,
|
|
6
|
+
reported
|
|
7
|
+
} from "./chunk-AKNNHQ2H.js";
|
|
8
|
+
import {
|
|
9
|
+
protocol
|
|
10
|
+
} from "./chunk-GNPFWISJ.js";
|
|
11
|
+
|
|
12
|
+
// src/core/capture.ts
|
|
13
|
+
var on = false;
|
|
14
|
+
function capture() {
|
|
15
|
+
if (on || typeof addEventListener == "undefined") return;
|
|
16
|
+
on = true;
|
|
17
|
+
addEventListener("error", (e) => attribute(e.error, e.filename));
|
|
18
|
+
addEventListener("unhandledrejection", (e) => attribute(e.reason));
|
|
19
|
+
}
|
|
20
|
+
function owner(error, file) {
|
|
21
|
+
const url = file || String(error?.stack ?? "").match(/(?:https?|file):\/\/[^\s)'"]+/)?.[0];
|
|
22
|
+
if (!url) return;
|
|
23
|
+
const host = [...document.querySelectorAll("script[src],link[rel=modulepreload]")].map(
|
|
24
|
+
(el) => el.src || el.href
|
|
25
|
+
);
|
|
26
|
+
let best;
|
|
27
|
+
let size = 0;
|
|
28
|
+
for (const [name, { entry }] of mounted) {
|
|
29
|
+
const dir = new URL(".", entry).href;
|
|
30
|
+
if (dir.length > size && url.startsWith(dir) && !host.some((u) => u.startsWith(dir))) best = name, size = dir.length;
|
|
31
|
+
}
|
|
32
|
+
return best;
|
|
33
|
+
}
|
|
34
|
+
function attribute(error, file) {
|
|
35
|
+
if (!protocol().settings().captureGlobalErrors || isRemoteError(error) || error instanceof Object && reported.has(error)) return;
|
|
36
|
+
const name = owner(error, file);
|
|
37
|
+
if (name) report(new RemoteError("RENDER_FAILED", name, String(error?.message ?? error), error), mounted.get(name));
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
capture,
|
|
41
|
+
owner
|
|
42
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot,
|
|
3
3
|
timings
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IHTUM6LT.js";
|
|
5
5
|
import {
|
|
6
6
|
defineRemote,
|
|
7
7
|
memoSelect,
|
|
8
8
|
same,
|
|
9
9
|
shared
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-I3VSKSAZ.js";
|
|
11
11
|
import {
|
|
12
12
|
registerSrc
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TD4S3IHA.js";
|
|
14
14
|
|
|
15
15
|
// src/element.ts
|
|
16
16
|
var Base = typeof HTMLElement === "undefined" ? class {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
protocol
|
|
3
|
+
} from "./chunk-GNPFWISJ.js";
|
|
4
|
+
|
|
5
|
+
// src/core/errors.ts
|
|
6
|
+
var ERROR_DOCS = "https://joaogabriel15.github.io/vitral/erros/";
|
|
7
|
+
var RemoteError = class extends Error {
|
|
8
|
+
constructor(code, remote, message, cause) {
|
|
9
|
+
super(`[vitral] ${remote}: ${message} (${ERROR_DOCS}${code})`);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.remote = remote;
|
|
12
|
+
this.cause = cause;
|
|
13
|
+
this.name = "RemoteError";
|
|
14
|
+
this.docs = `${ERROR_DOCS}${code}`;
|
|
15
|
+
if (typeof location != "undefined") this.route = location.pathname;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var isRemoteError = (e) => e?.name === "RemoteError";
|
|
19
|
+
var mounted = /* @__PURE__ */ new Map();
|
|
20
|
+
var reported = /* @__PURE__ */ new WeakSet();
|
|
21
|
+
function report(e, from) {
|
|
22
|
+
if (isRemoteError(e) && !reported.has(e)) {
|
|
23
|
+
reported.add(e);
|
|
24
|
+
if (e.cause instanceof Object) reported.add(e.cause);
|
|
25
|
+
e.entry ??= from?.entry ?? protocol().entry(e.remote)?.url;
|
|
26
|
+
e.version ??= from?.version;
|
|
27
|
+
try {
|
|
28
|
+
protocol().settings().onError?.(e);
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return e;
|
|
33
|
+
}
|
|
34
|
+
var fail = (e) => {
|
|
35
|
+
throw report(e);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
RemoteError,
|
|
40
|
+
isRemoteError,
|
|
41
|
+
mounted,
|
|
42
|
+
reported,
|
|
43
|
+
report,
|
|
44
|
+
fail
|
|
45
|
+
};
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RemoteError,
|
|
3
|
+
isRemoteError
|
|
4
|
+
} from "./chunk-AKNNHQ2H.js";
|
|
1
5
|
import {
|
|
2
6
|
protocol
|
|
3
7
|
} from "./chunk-GNPFWISJ.js";
|
|
4
8
|
|
|
5
|
-
// src/core/errors.ts
|
|
6
|
-
var ERROR_DOCS = "https://joaogabriel15.github.io/vitral/erros/";
|
|
7
|
-
var RemoteError = class extends Error {
|
|
8
|
-
constructor(code, remote, message, cause) {
|
|
9
|
-
super(`[vitral] ${remote}: ${message} (${ERROR_DOCS}${code})`);
|
|
10
|
-
this.code = code;
|
|
11
|
-
this.remote = remote;
|
|
12
|
-
this.cause = cause;
|
|
13
|
-
this.name = "RemoteError";
|
|
14
|
-
this.docs = `${ERROR_DOCS}${code}`;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var isRemoteError = (e) => e?.name === "RemoteError";
|
|
18
|
-
|
|
19
9
|
// src/core/util.ts
|
|
20
10
|
function pageOrigin() {
|
|
21
11
|
return typeof location !== "undefined" ? location.origin : null;
|
|
@@ -69,15 +59,15 @@ function addLink(rel, href, props = {}, parent = document.head) {
|
|
|
69
59
|
}
|
|
70
60
|
function metric(name, stage, start) {
|
|
71
61
|
try {
|
|
72
|
-
|
|
62
|
+
const label = `vitral:${name}:${stage}`;
|
|
63
|
+
performance.clearMeasures(label);
|
|
64
|
+
performance.measure(label, { start });
|
|
73
65
|
protocol().settings().onMetric?.({ name, stage, start, duration: performance.now() - start });
|
|
74
66
|
} catch {
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
69
|
|
|
78
70
|
export {
|
|
79
|
-
RemoteError,
|
|
80
|
-
isRemoteError,
|
|
81
71
|
pageOrigin,
|
|
82
72
|
absolute,
|
|
83
73
|
withRetry,
|
|
@@ -3,15 +3,20 @@ import {
|
|
|
3
3
|
loadFile,
|
|
4
4
|
registerSrc,
|
|
5
5
|
resolveEntry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TD4S3IHA.js";
|
|
7
7
|
import {
|
|
8
8
|
injectStyles
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZAC6QQI6.js";
|
|
10
|
+
import {
|
|
11
|
+
metric
|
|
12
|
+
} from "./chunk-GNHCZRQP.js";
|
|
10
13
|
import {
|
|
11
14
|
RemoteError,
|
|
15
|
+
fail,
|
|
12
16
|
isRemoteError,
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
mounted,
|
|
18
|
+
report
|
|
19
|
+
} from "./chunk-AKNNHQ2H.js";
|
|
15
20
|
import {
|
|
16
21
|
protocol
|
|
17
22
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -60,27 +65,44 @@ function navigate(url, options = {}) {
|
|
|
60
65
|
|
|
61
66
|
// src/core/updates.ts
|
|
62
67
|
var versions = /* @__PURE__ */ new Map();
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
var live = /* @__PURE__ */ new Map();
|
|
69
|
+
function track(name, loaded) {
|
|
70
|
+
versions.set(name, loaded.entry);
|
|
71
|
+
mounted.set(name, loaded);
|
|
72
|
+
live.set(name, (live.get(name) ?? 0) + 1);
|
|
73
|
+
return () => {
|
|
74
|
+
const n = live.get(name) - 1;
|
|
75
|
+
if (n) live.set(name, n);
|
|
76
|
+
else live.delete(name), versions.delete(name), mounted.delete(name);
|
|
77
|
+
};
|
|
65
78
|
}
|
|
79
|
+
var swaps = null;
|
|
66
80
|
async function refresh(name) {
|
|
67
81
|
const p = protocol();
|
|
68
82
|
await p.pending();
|
|
69
83
|
const entry = p.entry(name);
|
|
70
84
|
if (entry) p.register(name, entry);
|
|
71
85
|
await loadFile(name);
|
|
86
|
+
const started = swaps = [];
|
|
72
87
|
events.emit("vitral:refresh", name);
|
|
88
|
+
swaps = null;
|
|
89
|
+
await Promise.all(started);
|
|
73
90
|
}
|
|
74
91
|
function refreshable(current, name, props, remount) {
|
|
92
|
+
let gen = 0;
|
|
75
93
|
const off = events.on("vitral:refresh", (n) => {
|
|
76
|
-
if (n
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
94
|
+
if (n !== name && !name.startsWith(n + "/")) return;
|
|
95
|
+
const mine = ++gen;
|
|
96
|
+
const used = props;
|
|
97
|
+
const swap = remount(used).then((next) => {
|
|
98
|
+
if (current.unmount === noop || mine !== gen) return next.unmount();
|
|
99
|
+
const old = current;
|
|
100
|
+
current = next;
|
|
101
|
+
old.unmount();
|
|
102
|
+
if (props !== used) next.update?.(props);
|
|
103
|
+
});
|
|
104
|
+
if (swaps) swaps.push(swap);
|
|
105
|
+
else swap.catch(console.error);
|
|
84
106
|
});
|
|
85
107
|
return {
|
|
86
108
|
update(next) {
|
|
@@ -99,10 +121,13 @@ var noop = () => {
|
|
|
99
121
|
async function checkUpdates() {
|
|
100
122
|
const p = protocol();
|
|
101
123
|
const found = [];
|
|
102
|
-
const { splitName } = await import("./expose-
|
|
124
|
+
const { splitName } = await import("./expose-JUOUN5N5.js");
|
|
103
125
|
const remotes = /* @__PURE__ */ new Map();
|
|
104
|
-
for (const
|
|
105
|
-
|
|
126
|
+
for (const name of live.keys()) {
|
|
127
|
+
const root = splitName(name)[0];
|
|
128
|
+
const entry = versions.get(root) ?? versions.get(name);
|
|
129
|
+
if (entry) remotes.set(root, entry);
|
|
130
|
+
}
|
|
106
131
|
for (const [name, entry] of remotes) versions.set(name, entry);
|
|
107
132
|
await Promise.all(
|
|
108
133
|
[...remotes].map(
|
|
@@ -141,11 +166,11 @@ async function mountOnce(target, name, props, options) {
|
|
|
141
166
|
const p = protocol();
|
|
142
167
|
await p.pending();
|
|
143
168
|
if ((options.isolate ?? registered(name)?.isolate ?? p.settings().isolate) === "iframe") {
|
|
144
|
-
if (!frames) throw new RemoteError("MOUNT_FAILED", name, 'isolate="iframe" precisa de enableIframe(), de vitral/iframe');
|
|
145
|
-
return frames(target, name, props, options);
|
|
169
|
+
if (!frames) throw report(new RemoteError("MOUNT_FAILED", name, 'isolate="iframe" precisa de enableIframe(), de vitral/iframe'));
|
|
170
|
+
return frames(target, name, props, options).catch(fail);
|
|
146
171
|
}
|
|
147
172
|
const { module: mod, ...resolved } = await load(name, options.isolate, options.priority);
|
|
148
|
-
track(name, resolved
|
|
173
|
+
const untrack = track(name, resolved);
|
|
149
174
|
const isolate = options.isolate ?? resolved.isolate ?? protocol().settings().isolate;
|
|
150
175
|
const label = resolved.name ?? name;
|
|
151
176
|
let shadowRoot = null;
|
|
@@ -160,7 +185,7 @@ async function mountOnce(target, name, props, options) {
|
|
|
160
185
|
target.appendChild(el);
|
|
161
186
|
}
|
|
162
187
|
let t = performance.now();
|
|
163
|
-
const release = await injectStyles(resolved
|
|
188
|
+
const [release, portal = document.body] = await injectStyles(resolved, shadowRoot, el, options.styles);
|
|
164
189
|
metric(name, "css", t);
|
|
165
190
|
t = performance.now();
|
|
166
191
|
const scoped = scopedEvents();
|
|
@@ -170,8 +195,9 @@ async function mountOnce(target, name, props, options) {
|
|
|
170
195
|
baseUrl: new URL(".", resolved.entry).href,
|
|
171
196
|
events: scoped.bus,
|
|
172
197
|
shadowRoot,
|
|
198
|
+
portalContainer: portal,
|
|
173
199
|
reportError(e) {
|
|
174
|
-
const err = isRemoteError(e) ? e : new RemoteError("RENDER_FAILED", label, String(e?.message ?? e), e);
|
|
200
|
+
const err = report(isRemoteError(e) ? e : new RemoteError("RENDER_FAILED", label, String(e?.message ?? e), e), resolved);
|
|
175
201
|
if (options.onError) options.onError(err);
|
|
176
202
|
else console.error(err);
|
|
177
203
|
},
|
|
@@ -181,27 +207,29 @@ async function mountOnce(target, name, props, options) {
|
|
|
181
207
|
onDeactivate: on("vitral:deactivate")
|
|
182
208
|
};
|
|
183
209
|
if (ctxHooks.shared) ctx.shared = ctxHooks.shared(name, scoped.track);
|
|
184
|
-
let
|
|
210
|
+
let mounted2;
|
|
185
211
|
try {
|
|
186
|
-
|
|
212
|
+
mounted2 = await mod.mount(el, props, ctx);
|
|
187
213
|
metric(name, "mount", t);
|
|
188
214
|
} catch (e) {
|
|
215
|
+
untrack();
|
|
189
216
|
scoped.dispose();
|
|
190
217
|
release();
|
|
191
218
|
el.remove();
|
|
192
|
-
throw new RemoteError("MOUNT_FAILED", label, "erro ao montar", e);
|
|
219
|
+
throw report(new RemoteError("MOUNT_FAILED", label, "erro ao montar", e), resolved);
|
|
193
220
|
}
|
|
194
221
|
let alive = true;
|
|
195
222
|
return {
|
|
196
223
|
update(next) {
|
|
197
|
-
if (alive)
|
|
224
|
+
if (alive) mounted2.update?.(next);
|
|
198
225
|
},
|
|
199
226
|
unmount() {
|
|
200
227
|
if (!alive) return;
|
|
201
228
|
alive = false;
|
|
202
229
|
try {
|
|
203
|
-
|
|
230
|
+
mounted2.unmount();
|
|
204
231
|
} finally {
|
|
232
|
+
untrack();
|
|
205
233
|
scoped.dispose();
|
|
206
234
|
release();
|
|
207
235
|
el.remove();
|
|
@@ -244,17 +272,17 @@ function createSlot(target, options) {
|
|
|
244
272
|
holder.setAttribute("data-vitral-slot", name);
|
|
245
273
|
target.appendChild(holder);
|
|
246
274
|
setStatus("loading");
|
|
247
|
-
const
|
|
275
|
+
const fail2 = (e) => {
|
|
248
276
|
if (my !== token) return;
|
|
249
277
|
setStatus("error", isRemoteError(e) ? e : new RemoteError("MOUNT_FAILED", name, String(e), e));
|
|
250
278
|
};
|
|
251
279
|
const initial = props;
|
|
252
|
-
mountRemote(holder, name, props, { isolate, priority: options.priority, styles: options.styles, onError:
|
|
280
|
+
mountRemote(holder, name, props, { isolate, priority: options.priority, styles: options.styles, onError: fail2 }).then((h) => {
|
|
253
281
|
if (my !== token) return h.unmount();
|
|
254
282
|
handle2 = h;
|
|
255
283
|
if (props !== initial) h.update?.(props);
|
|
256
284
|
setStatus("ready");
|
|
257
|
-
},
|
|
285
|
+
}, fail2);
|
|
258
286
|
};
|
|
259
287
|
mount();
|
|
260
288
|
return {
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prefetchCss
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZAC6QQI6.js";
|
|
4
4
|
import {
|
|
5
|
-
RemoteError,
|
|
6
5
|
absolute,
|
|
7
6
|
addLink,
|
|
8
7
|
fetchJson,
|
|
9
|
-
isRemoteError,
|
|
10
8
|
metric,
|
|
11
9
|
pageOrigin,
|
|
12
10
|
withRetry,
|
|
13
11
|
withTimeout
|
|
14
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GNHCZRQP.js";
|
|
13
|
+
import {
|
|
14
|
+
RemoteError,
|
|
15
|
+
fail,
|
|
16
|
+
isRemoteError,
|
|
17
|
+
report
|
|
18
|
+
} from "./chunk-AKNNHQ2H.js";
|
|
15
19
|
import {
|
|
16
20
|
protocol
|
|
17
21
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -21,7 +25,8 @@ function configure(config) {
|
|
|
21
25
|
const p = protocol();
|
|
22
26
|
const { remotes, dedupe, ...rest } = config;
|
|
23
27
|
p.configure(rest);
|
|
24
|
-
if (
|
|
28
|
+
if (rest.captureGlobalErrors) import("./capture-JYFERAPL.js").then((m) => m.capture());
|
|
29
|
+
if (dedupe) p.pending(import("./dedupe-S7BHQMOZ.js").then((m) => m.offer(p, dedupe)).catch(() => {
|
|
25
30
|
}));
|
|
26
31
|
if (typeof remotes === "string") {
|
|
27
32
|
const url = absolute(remotes);
|
|
@@ -74,7 +79,7 @@ function loadRemote(name) {
|
|
|
74
79
|
return load(name).then((r) => r.module);
|
|
75
80
|
}
|
|
76
81
|
function loadModule(name) {
|
|
77
|
-
return import("./expose-
|
|
82
|
+
return import("./expose-JUOUN5N5.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
|
|
78
83
|
}
|
|
79
84
|
function preload(name) {
|
|
80
85
|
load(name).catch(() => {
|
|
@@ -83,13 +88,13 @@ function preload(name) {
|
|
|
83
88
|
var paths;
|
|
84
89
|
function load(name, isolate, priority) {
|
|
85
90
|
const file = (n) => loadFile(n, isolate, priority);
|
|
86
|
-
|
|
87
|
-
return import("./expose-53BEJB34.js").then((m) => m.resolveTarget(name, file));
|
|
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);
|
|
88
92
|
}
|
|
89
93
|
function loadFile(name, isolate, priority) {
|
|
90
94
|
const p = protocol();
|
|
91
95
|
return p.load(name, async () => {
|
|
92
|
-
paths ??= import("./sri-
|
|
96
|
+
paths ??= import("./sri-JMX6JLQP.js").catch(() => null);
|
|
97
|
+
let resolved;
|
|
93
98
|
try {
|
|
94
99
|
await p.pending();
|
|
95
100
|
const override = await devOverride(name);
|
|
@@ -97,15 +102,15 @@ function loadFile(name, isolate, priority) {
|
|
|
97
102
|
if (!entry) throw new RemoteError("NOT_REGISTERED", name, "remote n\xE3o registrado. Use configure({ remotes }).");
|
|
98
103
|
if (entry.module) return await loadLocal(name, entry);
|
|
99
104
|
let t = performance.now();
|
|
100
|
-
|
|
105
|
+
resolved = await resolveEntry(name, entry, priority);
|
|
101
106
|
metric(name, "manifest", t);
|
|
102
|
-
prefetchCss(resolved
|
|
107
|
+
prefetchCss(resolved, (isolate ?? resolved.isolate ?? p.settings().isolate) === "shadow", priority);
|
|
103
108
|
t = performance.now();
|
|
104
109
|
const ns = await withRetry(p.settings().retries, () => importModule(name, resolved));
|
|
105
110
|
metric(name, "js", t);
|
|
106
111
|
return { ...resolved, module: ns?.default ?? ns, exports: ns };
|
|
107
112
|
} catch (e) {
|
|
108
|
-
throw isRemoteError(e) ? e : new RemoteError("LOAD_FAILED", name, String(e?.message ?? e), e);
|
|
113
|
+
throw report(isRemoteError(e) ? e : new RemoteError("LOAD_FAILED", name, String(e?.message ?? e), e), resolved);
|
|
109
114
|
}
|
|
110
115
|
});
|
|
111
116
|
}
|
|
@@ -124,17 +129,23 @@ async function resolveEntry(name, entry, priority) {
|
|
|
124
129
|
checkOrigin(name, entry.url);
|
|
125
130
|
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 });
|
|
126
131
|
if (typeof m?.entry !== "string") throw new RemoteError("INVALID_MODULE", name, `manifesto inv\xE1lido em ${entry.url}`);
|
|
132
|
+
if (m.contract && (entry.contract || protocol().settings().contract)) {
|
|
133
|
+
const why = await (await import("./contract-46EZFQPQ.js")).checkContract(m.contract, entry.contract);
|
|
134
|
+
if (why) throw new RemoteError("CONTRACT_MISMATCH", name, why);
|
|
135
|
+
}
|
|
127
136
|
const abs = (u) => absolute(u, entry.url);
|
|
128
137
|
const sri = {};
|
|
129
138
|
for (const file in m.files ?? {}) sri[abs(file)] = m.files[file];
|
|
130
139
|
const resolved = {
|
|
131
140
|
entry: abs(m.entry),
|
|
132
141
|
css: [...m.css ?? [], ...entry.css ?? []].map(abs),
|
|
142
|
+
shadow: m.shadow,
|
|
133
143
|
// A integridade declarada pelo host vence a do manifesto, e aí só o
|
|
134
144
|
// arquivo único (o que ela descreve) é usado.
|
|
135
145
|
integrity: entry.integrity ?? m.integrity,
|
|
136
146
|
isolate: entry.isolate,
|
|
137
147
|
scope: m.scope,
|
|
148
|
+
version: m.version,
|
|
138
149
|
sri,
|
|
139
150
|
priority,
|
|
140
151
|
split: m.split && !entry.integrity ? {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addLink,
|
|
3
|
+
fetchBytes
|
|
4
|
+
} from "./chunk-GNHCZRQP.js";
|
|
5
|
+
import {
|
|
6
|
+
protocol
|
|
7
|
+
} from "./chunk-GNPFWISJ.js";
|
|
8
|
+
|
|
9
|
+
// src/core/css.ts
|
|
10
|
+
var loadedCss = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
var cssText = /* @__PURE__ */ new Map();
|
|
12
|
+
var noop = () => {
|
|
13
|
+
};
|
|
14
|
+
var adopts = () => typeof CSSStyleSheet !== "undefined" && "replaceSync" in CSSStyleSheet.prototype;
|
|
15
|
+
function fetchCssText(href, integrity, priority) {
|
|
16
|
+
const key = `${href} ${integrity ?? ""}`;
|
|
17
|
+
let p = cssText.get(key);
|
|
18
|
+
if (!p) {
|
|
19
|
+
p = fetchBytes(href, protocol().settings().timeout, href, { integrity, priority }).then((b) => new TextDecoder().decode(b));
|
|
20
|
+
p.catch(() => cssText.delete(key));
|
|
21
|
+
cssText.set(key, p);
|
|
22
|
+
}
|
|
23
|
+
return p;
|
|
24
|
+
}
|
|
25
|
+
function prefetchCss(r, shadow, priority = "auto") {
|
|
26
|
+
if (shadow && adopts()) import("./shadow-6HELCHCJ.js").then((m) => m.prefetch(r, priority), noop);
|
|
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
|
+
}
|
|
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]);
|
|
31
|
+
}
|
|
32
|
+
function injectCss(urls, root, sri = {}) {
|
|
33
|
+
const owner = root ?? document;
|
|
34
|
+
let seen = loadedCss.get(owner);
|
|
35
|
+
if (!seen) loadedCss.set(owner, seen = /* @__PURE__ */ new Map());
|
|
36
|
+
const parent = root ?? document.head;
|
|
37
|
+
const timeout = protocol().settings().timeout;
|
|
38
|
+
return Promise.all(
|
|
39
|
+
urls.map((href) => {
|
|
40
|
+
let p = seen.get(href);
|
|
41
|
+
if (!p) {
|
|
42
|
+
p = new Promise((resolve) => {
|
|
43
|
+
const link = addLink("stylesheet", href, { integrity: sri[href] ?? "" }, parent);
|
|
44
|
+
setTimeout(resolve, timeout);
|
|
45
|
+
link.onload = () => resolve();
|
|
46
|
+
link.onerror = () => {
|
|
47
|
+
link.remove();
|
|
48
|
+
seen.delete(href);
|
|
49
|
+
resolve();
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
seen.set(href, p);
|
|
53
|
+
}
|
|
54
|
+
return p;
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
fetchCssText,
|
|
61
|
+
prefetchCss,
|
|
62
|
+
injectStyles,
|
|
63
|
+
injectCss
|
|
64
|
+
};
|