vitral 0.2.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.
- 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-TT5WBLJ6.js +42 -0
- package/dist/channel-2YPYGX3J.js +95 -0
- package/dist/chunk-463H6B56.js +50 -0
- package/dist/chunk-54CBIZES.js +105 -0
- package/dist/chunk-6EX5KYT5.js +64 -0
- package/dist/{chunk-6Y3VMWHH.js → chunk-BCC25ANK.js} +11 -5
- package/dist/{chunk-2XF5BKV3.js → chunk-EMSB2NVX.js} +26 -13
- package/dist/{chunk-HP6QWU6K.js → chunk-IH3ZT3QU.js} +2 -2
- package/dist/{chunk-PX7PBCCT.js → chunk-TW7KYJQ6.js} +7 -17
- package/dist/{chunk-S5MZT5IT.js → chunk-UYOPJ4XQ.js} +1 -1
- package/dist/{chunk-UTYAX6MU.js → chunk-W6322KGP.js} +2 -2
- package/dist/{chunk-NCONW6WS.js → chunk-WD4CDGDZ.js} +73 -44
- package/dist/cli.js +1196 -31
- package/dist/contract-46EZFQPQ.js +17 -0
- package/dist/{dedupe-IWFIXRWG.js → dedupe-S7BHQMOZ.js} +4 -3
- package/dist/devtools.d.ts +32 -2
- package/dist/devtools.js +27 -12
- package/dist/element.d.ts +13 -4
- package/dist/element.js +7 -6
- package/dist/embed.js +2 -0
- package/dist/{errors-KKB8FGCz.d.ts → errors-kjBv6IH_.d.ts} +7 -1
- package/dist/{events-DUdjhfps.d.ts → events-Dkpkw_Sv.d.ts} +1 -1
- package/dist/expose-OVWTPHH5.js +15 -0
- package/dist/federation.d.ts +89 -0
- package/dist/federation.js +101 -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/overrides-NP754HY7.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-PVSETNMZ.js +159 -0
- package/dist/single-spa.d.ts +40 -0
- package/dist/single-spa.js +52 -0
- package/dist/{slot-pB276oPt.d.ts → slot-UPg6ob9v.d.ts} +2 -2
- package/dist/solid.d.ts +4 -4
- package/dist/solid.js +6 -5
- package/dist/{sri-BVKZNX5Q.js → sri-M7ZRU57G.js} +43 -11
- 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-CA2p9KHC.d.ts} +174 -4
- package/dist/vite.d.ts +26 -0
- package/dist/vite.js +686 -51
- package/dist/vue.d.ts +11 -4
- package/dist/vue.js +10 -5
- package/package.json +115 -23
- package/dist/chunk-DXORSF4X.js +0 -42
- package/dist/chunk-SFL6LTP3.js +0 -56
- package/dist/expose-53BEJB34.js +0 -14
- package/dist/overrides-NZAIUGK5.js +0 -15
- package/dist/shadow-MYRJQLLY.js +0 -72
package/dist/iframe.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
splitName
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IH3ZT3QU.js";
|
|
4
4
|
import {
|
|
5
5
|
verifyIntegrity
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UYOPJ4XQ.js";
|
|
7
7
|
import {
|
|
8
8
|
events,
|
|
9
9
|
navigate,
|
|
10
10
|
setFrameMounter,
|
|
11
11
|
track
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WD4CDGDZ.js";
|
|
13
13
|
import {
|
|
14
14
|
resolveEntry
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-EMSB2NVX.js";
|
|
16
|
+
import "./chunk-6EX5KYT5.js";
|
|
17
17
|
import {
|
|
18
|
-
RemoteError,
|
|
19
18
|
fetchBytes,
|
|
20
19
|
withRetry,
|
|
21
20
|
withTimeout
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-TW7KYJQ6.js";
|
|
22
|
+
import {
|
|
23
|
+
RemoteError,
|
|
24
|
+
report
|
|
25
|
+
} from "./chunk-463H6B56.js";
|
|
23
26
|
import {
|
|
24
27
|
protocol
|
|
25
28
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -46,7 +49,7 @@ var FRAME_RUNTIME = `function (w, load) {
|
|
|
46
49
|
// Ponto de extens\xE3o: uma ponte nova registra handlers em channel[tipo] e
|
|
47
50
|
// acrescenta campos aqui (a Fase 2 acrescenta ctx.shared).
|
|
48
51
|
var ctx = {
|
|
49
|
-
name: d.name, baseUrl: d.baseUrl, events: events, shadowRoot: null, protocol: 1,
|
|
52
|
+
name: d.name, baseUrl: d.baseUrl, events: events, shadowRoot: null, portalContainer: doc.body, protocol: 1,
|
|
50
53
|
reportError: function (e) { post('report', { message: String((e && e.message) || e) }) },
|
|
51
54
|
navigate: function (url, o) { post('navigate', { url: String(url), replace: !!(o && o.replace) }) }
|
|
52
55
|
}
|
|
@@ -119,7 +122,6 @@ async function mountFrame(target, name, props, options, sandbox, bridges) {
|
|
|
119
122
|
await verifyIntegrity(name, bytes, integrity);
|
|
120
123
|
return bytes;
|
|
121
124
|
}) : void 0;
|
|
122
|
-
track(name, resolved.entry);
|
|
123
125
|
const baseUrl = /^https?:/.test(resolved.entry) ? new URL(".", resolved.entry).href : resolved.entry;
|
|
124
126
|
const frame = document.createElement("iframe");
|
|
125
127
|
frame.setAttribute("sandbox", sandbox);
|
|
@@ -188,7 +190,7 @@ async function mountFrame(target, name, props, options, sandbox, bridges) {
|
|
|
188
190
|
break;
|
|
189
191
|
}
|
|
190
192
|
case "report": {
|
|
191
|
-
const err = new RemoteError("RENDER_FAILED", name, String(d?.message));
|
|
193
|
+
const err = report(new RemoteError("RENDER_FAILED", name, String(d?.message)), resolved);
|
|
192
194
|
if (options.onError) options.onError(err);
|
|
193
195
|
else console.error(err);
|
|
194
196
|
break;
|
|
@@ -217,6 +219,7 @@ async function mountFrame(target, name, props, options, sandbox, bridges) {
|
|
|
217
219
|
cleanup();
|
|
218
220
|
throw e;
|
|
219
221
|
}
|
|
222
|
+
disposers.push(track(name, resolved));
|
|
220
223
|
let alive = true;
|
|
221
224
|
return {
|
|
222
225
|
update(next) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import { V as VitralConfig, c as RemoteEntry, P as Props, a as RemoteModule, I as Isolation,
|
|
2
|
-
export { C as CheckedProps, H as Handler,
|
|
3
|
-
import { R as RemoteError } from './errors-
|
|
4
|
-
export { a as RemoteErrorCode } from './errors-
|
|
5
|
-
export { R as RemoteSlot, a as SlotOptions, S as SlotStatus, c as createSlot } from './slot-
|
|
6
|
-
export { e as events } from './events-
|
|
1
|
+
import { V as VitralConfig, c as RemoteEntry, P as Props, a as RemoteModule, I as Isolation, d as StyleOptions, M as MountedRemote, E as EventBus, R as RemoteContext, e as SharedValue } from './types-CA2p9KHC.js';
|
|
2
|
+
export { f as Channel, g as ChannelContext, C as CheckedProps, D as DevOverrides, H as Handler, h as McpAppBridge, i as PropsOf, j as ProvideOptions, k as ProvidedValue, l as RemoteContract, m as RemoteManifest, n as RemoteMetric, o as Remotes, p as RollbackInfo, S as Shared, q as SharedApi, b as SharedModules, r as SharedType, s as batch, t as provide, u as shared } from './types-CA2p9KHC.js';
|
|
3
|
+
import { R as RemoteError } from './errors-kjBv6IH_.js';
|
|
4
|
+
export { a as RemoteErrorCode } from './errors-kjBv6IH_.js';
|
|
5
|
+
export { R as RemoteSlot, a as SlotOptions, S as SlotStatus, c as createSlot } from './slot-UPg6ob9v.js';
|
|
6
|
+
export { e as events } from './events-Dkpkw_Sv.js';
|
|
7
7
|
export { n as navigate } from './navigate-BRG1WJUM.js';
|
|
8
8
|
export { r as __reset } from './state-BDdCwc21.js';
|
|
9
9
|
|
|
10
|
-
/** Configura a lib. Pode ser chamada mais de uma vez; as opções são mescladas. */
|
|
11
|
-
declare function configure(config: VitralConfig): void;
|
|
12
|
-
/** Registra (ou substitui) um remote. */
|
|
13
|
-
declare function register(name: string, entry: string | RemoteEntry): void;
|
|
14
|
-
/**
|
|
15
|
-
* Registra a URL de um `src` e devolve o nome para montar. Sem `name`, o nome
|
|
16
|
-
* é a própria URL (e o nome do manifesto vira um apelido). Com `trusted`, a
|
|
17
|
-
* origem entra na allowlist mesmo com `allowedOrigins`: vale para URL escrita
|
|
18
|
-
* no código do host, nunca para URL vinda de dados.
|
|
19
|
-
*/
|
|
20
|
-
declare function registerSrc(src: string, name?: string, trusted?: boolean): string;
|
|
21
|
-
|
|
22
10
|
/** Uma chave do store vista de fora (devtools, SSR, ponte do iframe). */
|
|
23
11
|
interface SharedEntry {
|
|
24
12
|
key: string;
|
|
@@ -60,6 +48,18 @@ interface SharedStore {
|
|
|
60
48
|
list(): SharedEntry[];
|
|
61
49
|
}
|
|
62
50
|
|
|
51
|
+
/** Configura a lib. Pode ser chamada mais de uma vez; as opções são mescladas. */
|
|
52
|
+
declare function configure(config: VitralConfig): void;
|
|
53
|
+
/** Registra (ou substitui) um remote. */
|
|
54
|
+
declare function register(name: string, entry: string | RemoteEntry): void;
|
|
55
|
+
/**
|
|
56
|
+
* Registra a URL de um `src` e devolve o nome para montar. Sem `name`, o nome
|
|
57
|
+
* é a própria URL (e o nome do manifesto vira um apelido). Com `trusted`, a
|
|
58
|
+
* origem entra na allowlist mesmo com `allowedOrigins`: vale para URL escrita
|
|
59
|
+
* no código do host, nunca para URL vinda de dados.
|
|
60
|
+
*/
|
|
61
|
+
declare function registerSrc(src: string, name?: string, trusted?: boolean): string;
|
|
62
|
+
|
|
63
63
|
/** Baixa (uma vez só) e devolve o módulo de um remote. */
|
|
64
64
|
declare function loadRemote<P extends Props = Props>(name: string): Promise<RemoteModule<P>>;
|
|
65
65
|
/**
|
|
@@ -97,12 +97,14 @@ declare function createEventBus(): EventBus;
|
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
99
|
* Troca as montagens de `name` (e das partes, `name/…`) pela versão que o
|
|
100
|
-
* manifesto aponta agora, sem recarregar a página.
|
|
101
|
-
*
|
|
100
|
+
* manifesto aponta agora, sem recarregar a página. Resolve quando todas as
|
|
101
|
+
* montagens já mostram a versão nova. Rejeita se a versão nova não carregar
|
|
102
|
+
* ou se o `mount` dela falhar; nesse caso a montagem antiga fica na tela.
|
|
102
103
|
*/
|
|
103
104
|
declare function refresh(name: string): Promise<void>;
|
|
104
105
|
/**
|
|
105
|
-
* Revalida os manifestos dos remotes montados
|
|
106
|
+
* Revalida os manifestos dos remotes montados agora (os desmontados ficam de
|
|
107
|
+
* fora) e emite
|
|
106
108
|
* `vitral:update-available` com `{ name, entry }` para cada deploy novo.
|
|
107
109
|
* Devolve os nomes com versão nova. Falhas de rede são ignoradas.
|
|
108
110
|
*/
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
syncTabs,
|
|
18
18
|
unsafeHTML,
|
|
19
19
|
watchUpdates
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-WD4CDGDZ.js";
|
|
21
21
|
import {
|
|
22
22
|
configure,
|
|
23
23
|
loadModule,
|
|
@@ -25,11 +25,12 @@ import {
|
|
|
25
25
|
preload,
|
|
26
26
|
register,
|
|
27
27
|
registerSrc
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-EMSB2NVX.js";
|
|
29
|
+
import "./chunk-6EX5KYT5.js";
|
|
30
|
+
import "./chunk-TW7KYJQ6.js";
|
|
30
31
|
import {
|
|
31
32
|
RemoteError
|
|
32
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-463H6B56.js";
|
|
33
34
|
import {
|
|
34
35
|
createEventBus,
|
|
35
36
|
resetProtocol
|
package/dist/otel.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { R as RemoteError } from './errors-kjBv6IH_.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Erros dos remotes no OpenTelemetry, sem depender do `@opentelemetry/api`:
|
|
5
|
+
*
|
|
6
|
+
* import { trace } from '@opentelemetry/api'
|
|
7
|
+
* import { otelOnError } from 'vitral/otel'
|
|
8
|
+
*
|
|
9
|
+
* configure({ onError: otelOnError({ trace, tracer: trace.getTracer('host') }) })
|
|
10
|
+
*
|
|
11
|
+
* Com um span ativo, o erro vira um evento `exception` nele. Sem span ativo
|
|
12
|
+
* (ou sem `trace`), o `tracer` abre e fecha um span `vitral.error` com o erro.
|
|
13
|
+
* Os atributos são os de exceção do OpenTelemetry mais `vitral.remote`,
|
|
14
|
+
* `vitral.version`, `vitral.code`, `vitral.entry` e `vitral.route`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Atributos de span e de evento. */
|
|
18
|
+
type Attributes = Record<string, string>;
|
|
19
|
+
/** A parte de um `Span` que o adaptador usa. */
|
|
20
|
+
interface SpanLike {
|
|
21
|
+
addEvent(name: string, attributes?: Attributes): unknown;
|
|
22
|
+
recordException(exception: Error): void;
|
|
23
|
+
setStatus(status: {
|
|
24
|
+
code: number;
|
|
25
|
+
message?: string;
|
|
26
|
+
}): unknown;
|
|
27
|
+
end(): void;
|
|
28
|
+
}
|
|
29
|
+
interface OtelOptions {
|
|
30
|
+
/** O `trace` de `@opentelemetry/api`, para achar o span ativo. */
|
|
31
|
+
trace?: {
|
|
32
|
+
getActiveSpan(): SpanLike | undefined;
|
|
33
|
+
};
|
|
34
|
+
/** Tracer que abre um span quando não há span ativo. */
|
|
35
|
+
tracer?: {
|
|
36
|
+
startSpan(name: string, options?: {
|
|
37
|
+
attributes?: Attributes;
|
|
38
|
+
}): SpanLike;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** `onError` para o `configure` que registra cada `RemoteError` no OpenTelemetry. */
|
|
42
|
+
declare function otelOnError({ trace, tracer }: OtelOptions): (error: RemoteError) => void;
|
|
43
|
+
|
|
44
|
+
export { type Attributes, type OtelOptions, type SpanLike, otelOnError };
|
package/dist/otel.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/otel.ts
|
|
2
|
+
function otelOnError({ trace, tracer }) {
|
|
3
|
+
return (error) => {
|
|
4
|
+
const all = {
|
|
5
|
+
"exception.type": error.name,
|
|
6
|
+
"exception.message": error.message,
|
|
7
|
+
"exception.stacktrace": error.stack,
|
|
8
|
+
"vitral.remote": error.remote,
|
|
9
|
+
"vitral.version": error.version,
|
|
10
|
+
"vitral.code": error.code,
|
|
11
|
+
"vitral.entry": error.entry,
|
|
12
|
+
"vitral.route": error.route
|
|
13
|
+
};
|
|
14
|
+
const attributes = {};
|
|
15
|
+
for (const k in all) if (all[k] !== void 0) attributes[k] = all[k];
|
|
16
|
+
const active = trace?.getActiveSpan();
|
|
17
|
+
if (active) return void active.addEvent("exception", attributes);
|
|
18
|
+
const span = tracer?.startSpan("vitral.error", { attributes });
|
|
19
|
+
if (!span) return;
|
|
20
|
+
span.recordException(error);
|
|
21
|
+
span.setStatus({ code: 2, message: error.message });
|
|
22
|
+
span.end();
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
otelOnError
|
|
27
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OVERRIDES_KEY,
|
|
3
|
+
activeOverrides,
|
|
4
|
+
clearOverrides,
|
|
5
|
+
dropOverride,
|
|
6
|
+
isRef,
|
|
7
|
+
manifestUrl,
|
|
8
|
+
overrideFor,
|
|
9
|
+
overridesEnabled,
|
|
10
|
+
resolveOverride,
|
|
11
|
+
storeOverride,
|
|
12
|
+
storedOverrides
|
|
13
|
+
} from "./chunk-54CBIZES.js";
|
|
14
|
+
import "./chunk-GNPFWISJ.js";
|
|
15
|
+
export {
|
|
16
|
+
OVERRIDES_KEY,
|
|
17
|
+
activeOverrides,
|
|
18
|
+
clearOverrides,
|
|
19
|
+
dropOverride,
|
|
20
|
+
isRef,
|
|
21
|
+
manifestUrl,
|
|
22
|
+
overrideFor,
|
|
23
|
+
overridesEnabled,
|
|
24
|
+
resolveOverride,
|
|
25
|
+
storeOverride,
|
|
26
|
+
storedOverrides
|
|
27
|
+
};
|
package/dist/preact.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as preact from 'preact';
|
|
2
2
|
import { VNode, ComponentType } from 'preact';
|
|
3
|
-
import { P as Props, I as Isolation, C as CheckedProps, a as RemoteModule, S as Shared } from './types-
|
|
4
|
-
export { R as RemoteContext } from './types-
|
|
5
|
-
import { R as RemoteError } from './errors-
|
|
6
|
-
import { S as SlotStatus } from './slot-
|
|
7
|
-
export { e as events } from './events-
|
|
3
|
+
import { P as Props, I as Isolation, C as CheckedProps, a as RemoteModule, S as Shared } from './types-CA2p9KHC.js';
|
|
4
|
+
export { R as RemoteContext } from './types-CA2p9KHC.js';
|
|
5
|
+
import { R as RemoteError } from './errors-kjBv6IH_.js';
|
|
6
|
+
import { S as SlotStatus } from './slot-UPg6ob9v.js';
|
|
7
|
+
export { e as events } from './events-Dkpkw_Sv.js';
|
|
8
8
|
export { n as navigate } from './navigate-BRG1WJUM.js';
|
|
9
9
|
import { L as Loading, P as Prefetch } from './host-slot-Cz6EiGsB.js';
|
|
10
10
|
|
package/dist/preact.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-W6322KGP.js";
|
|
4
4
|
import {
|
|
5
5
|
defineRemote,
|
|
6
6
|
events,
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
navigate,
|
|
9
9
|
same,
|
|
10
10
|
shared
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-WD4CDGDZ.js";
|
|
12
|
+
import "./chunk-EMSB2NVX.js";
|
|
13
|
+
import "./chunk-6EX5KYT5.js";
|
|
14
|
+
import "./chunk-TW7KYJQ6.js";
|
|
15
|
+
import "./chunk-463H6B56.js";
|
|
15
16
|
import "./chunk-GNPFWISJ.js";
|
|
16
17
|
|
|
17
18
|
// src/preact.ts
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode, ComponentType } from 'react';
|
|
2
2
|
import { L as Loading, P as Prefetch } from './host-slot-Cz6EiGsB.js';
|
|
3
3
|
import * as JSXRuntime from 'react/jsx-runtime';
|
|
4
|
-
import { P as Props, I as Isolation, C as CheckedProps, a as RemoteModule, S as Shared, R as RemoteContext } from './types-
|
|
5
|
-
export { E as EventBus } from './types-
|
|
6
|
-
export { e as events } from './events-
|
|
4
|
+
import { P as Props, I as Isolation, C as CheckedProps, a as RemoteModule, S as Shared, R as RemoteContext } from './types-CA2p9KHC.js';
|
|
5
|
+
export { E as EventBus } from './types-CA2p9KHC.js';
|
|
6
|
+
export { e as events } from './events-Dkpkw_Sv.js';
|
|
7
|
+
import './errors-kjBv6IH_.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Adaptador React (funciona em Vite, CRA e Next.js App/Pages Router).
|
|
@@ -17,6 +18,13 @@ export { e as events } from './events-DUdjhfps.js';
|
|
|
17
18
|
declare function reactRemote<P extends Props>(Component: ComponentType<P>): RemoteModule<P>;
|
|
18
19
|
/** Dentro de um remote: dá acesso ao contexto (nome, eventos, baseUrl). */
|
|
19
20
|
declare function useVitral(): RemoteContext | null;
|
|
21
|
+
/**
|
|
22
|
+
* Dentro de um remote: onde renderizar portais. No Shadow DOM é um elemento
|
|
23
|
+
* dentro do shadow root (com os estilos do remote); fora de um remote,
|
|
24
|
+
* `undefined`, e a biblioteca usa o padrão dela (`document.body`). Use em
|
|
25
|
+
* `<Popover.Portal container={usePortalContainer()}>`.
|
|
26
|
+
*/
|
|
27
|
+
declare function usePortalContainer(): HTMLElement | undefined;
|
|
20
28
|
/** Assina um evento do barramento global enquanto o componente estiver montado. */
|
|
21
29
|
declare function useEvent<T = unknown>(type: string, handler: (payload: T) => void): void;
|
|
22
30
|
/** Estado derivado do último valor emitido em `type`. */
|
|
@@ -60,4 +68,4 @@ interface RemoteProps<P extends Props = Props> {
|
|
|
60
68
|
*/
|
|
61
69
|
declare function Remote<P extends Props = Props, N extends string = string>({ name, src, props, isolate, fallback, error, onError, className, loading, prefetch, priority, keepAlive, }: RemoteProps<P> & CheckedProps<N>): JSXRuntime.JSX.Element;
|
|
62
70
|
|
|
63
|
-
export { Remote, type RemoteProps, reactRemote, useEvent, useEventValue, useShared, useVitral };
|
|
71
|
+
export { Remote, type RemoteProps, reactRemote, useEvent, useEventValue, usePortalContainer, useShared, useVitral };
|
package/dist/react.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
hostSlot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-W6322KGP.js";
|
|
5
5
|
import {
|
|
6
6
|
defineRemote,
|
|
7
7
|
events,
|
|
8
8
|
memoSelect,
|
|
9
9
|
same,
|
|
10
10
|
shared
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-WD4CDGDZ.js";
|
|
12
|
+
import "./chunk-EMSB2NVX.js";
|
|
13
|
+
import "./chunk-6EX5KYT5.js";
|
|
14
|
+
import "./chunk-TW7KYJQ6.js";
|
|
15
|
+
import "./chunk-463H6B56.js";
|
|
15
16
|
import {
|
|
16
17
|
protocol
|
|
17
18
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -65,6 +66,9 @@ function reactRemote(Component) {
|
|
|
65
66
|
function useVitral() {
|
|
66
67
|
return useContext(VitralContext);
|
|
67
68
|
}
|
|
69
|
+
function usePortalContainer() {
|
|
70
|
+
return useVitral()?.portalContainer;
|
|
71
|
+
}
|
|
68
72
|
function useEvent(type, handler) {
|
|
69
73
|
const ref = useRef(handler);
|
|
70
74
|
ref.current = handler;
|
|
@@ -99,7 +103,7 @@ function offerReact() {
|
|
|
99
103
|
// O React 19 expõe o react/compiler-runtime pelo próprio react.
|
|
100
104
|
...compiler && { "react/compiler-runtime": compiler }
|
|
101
105
|
};
|
|
102
|
-
p.pending(import("./dedupe-
|
|
106
|
+
p.pending(import("./dedupe-S7BHQMOZ.js").then((m) => m.offer(p, { react: { version: ReactAll.version, modules } })).catch(() => {
|
|
103
107
|
}));
|
|
104
108
|
}
|
|
105
109
|
function Remote({
|
|
@@ -162,6 +166,7 @@ export {
|
|
|
162
166
|
reactRemote,
|
|
163
167
|
useEvent,
|
|
164
168
|
useEventValue,
|
|
169
|
+
usePortalContainer,
|
|
165
170
|
useShared,
|
|
166
171
|
useVitral
|
|
167
172
|
};
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as Props } from './types-
|
|
2
|
-
import { S as SlotStatus } from './slot-
|
|
3
|
-
import './errors-
|
|
1
|
+
import { P as Props } from './types-CA2p9KHC.js';
|
|
2
|
+
import { S as SlotStatus } from './slot-UPg6ob9v.js';
|
|
3
|
+
import './errors-kjBv6IH_.js';
|
|
4
4
|
|
|
5
5
|
/** Padrão de URL → nome do remote. A primeira rota que bate vence. */
|
|
6
6
|
type Routes = Record<string, string>;
|
package/dist/routes.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSlot,
|
|
3
3
|
navigate
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-WD4CDGDZ.js";
|
|
5
|
+
import "./chunk-EMSB2NVX.js";
|
|
6
|
+
import "./chunk-6EX5KYT5.js";
|
|
7
|
+
import "./chunk-TW7KYJQ6.js";
|
|
8
|
+
import "./chunk-463H6B56.js";
|
|
8
9
|
import "./chunk-GNPFWISJ.js";
|
|
9
10
|
|
|
10
11
|
// src/routes.ts
|
package/dist/sentry.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { R as RemoteError } from './errors-kjBv6IH_.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Erros dos remotes no Sentry, sem depender do SDK:
|
|
5
|
+
*
|
|
6
|
+
* import * as Sentry from '@sentry/browser'
|
|
7
|
+
* import { sentryOnError } from 'vitral/sentry'
|
|
8
|
+
*
|
|
9
|
+
* configure({ onError: sentryOnError(Sentry) })
|
|
10
|
+
*
|
|
11
|
+
* Cada `RemoteError` vira um `captureException` com as tags `vitral.remote`,
|
|
12
|
+
* `vitral.version` e `vitral.code`, e com `entry`, `route` e `docs` no `extra`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** A parte do SDK do Sentry que o adaptador usa (`@sentry/browser`, `@sentry/react`…). */
|
|
16
|
+
interface SentryLike {
|
|
17
|
+
captureException(exception: unknown, hint?: {
|
|
18
|
+
tags?: Record<string, string>;
|
|
19
|
+
extra?: Record<string, unknown>;
|
|
20
|
+
}): unknown;
|
|
21
|
+
}
|
|
22
|
+
/** `onError` para o `configure` que manda cada `RemoteError` ao Sentry. */
|
|
23
|
+
declare function sentryOnError(sentry: SentryLike): (error: RemoteError) => void;
|
|
24
|
+
|
|
25
|
+
export { type SentryLike, sentryOnError };
|
package/dist/sentry.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/sentry.ts
|
|
2
|
+
function sentryOnError(sentry) {
|
|
3
|
+
return (error) => {
|
|
4
|
+
const tags = { "vitral.remote": error.remote, "vitral.code": error.code };
|
|
5
|
+
if (error.version) tags["vitral.version"] = error.version;
|
|
6
|
+
sentry.captureException(error, { tags, extra: { entry: error.entry, route: error.route, docs: error.docs } });
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
sentryOnError
|
|
11
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchCssText,
|
|
3
|
+
injectCss
|
|
4
|
+
} from "./chunk-6EX5KYT5.js";
|
|
5
|
+
import "./chunk-TW7KYJQ6.js";
|
|
6
|
+
import "./chunk-463H6B56.js";
|
|
7
|
+
import "./chunk-GNPFWISJ.js";
|
|
8
|
+
|
|
9
|
+
// src/core/shadow.ts
|
|
10
|
+
var sheets = /* @__PURE__ */ new Map();
|
|
11
|
+
var noop = () => {
|
|
12
|
+
};
|
|
13
|
+
var hoisted = /* @__PURE__ */ new Set();
|
|
14
|
+
var RELATIVE_URL = /url\(\s*(['"]?)(?![a-z]+:|\/\/|#)([^'")]+)\1\s*\)/gi;
|
|
15
|
+
var GLOBAL_RULES = /@property\s+(--[\w-]+)\s*\{[^}]*\}|@font-face\s*\{[^}]*\}|@import\s+(?:url\(\s*)?(?:(['"])(.*?)\2|([^'"\s);]+))\s*\)?[^;]*;/gi;
|
|
16
|
+
function plan({ css, shadow: s }) {
|
|
17
|
+
const at = (u) => new URL(u, css[0]).href;
|
|
18
|
+
const ready = s ? s.css.map(at) : [];
|
|
19
|
+
return [s ? [...(s.imports ?? []).map(at), ...ready, ...css.slice(ready.length)] : css, ready, (s?.global ?? []).map(at)];
|
|
20
|
+
}
|
|
21
|
+
function prefetch(r, priority) {
|
|
22
|
+
const [urls, , global] = plan(r);
|
|
23
|
+
for (const u of urls) fetchCssText(u, r.sri?.[u], priority).catch(noop);
|
|
24
|
+
injectCss(global, null, r.sri);
|
|
25
|
+
}
|
|
26
|
+
async function attachShadowRoot(target, make, r, global = {}, local = {}) {
|
|
27
|
+
const name = make().getAttribute("data-vitral-root");
|
|
28
|
+
let registry = registryFor(name);
|
|
29
|
+
let root = target.shadowRoot;
|
|
30
|
+
if (!root && !fake(registry))
|
|
31
|
+
try {
|
|
32
|
+
root = target.attachShadow({ mode: "open", customElementRegistry: registry });
|
|
33
|
+
} catch {
|
|
34
|
+
broken = true;
|
|
35
|
+
registries.delete(name);
|
|
36
|
+
registry = registryFor(name);
|
|
37
|
+
}
|
|
38
|
+
root ??= target.attachShadow({ mode: "open" });
|
|
39
|
+
const own = root.customElementRegistry ?? registry;
|
|
40
|
+
let el = make();
|
|
41
|
+
if (!fake(own))
|
|
42
|
+
try {
|
|
43
|
+
el = make({ customElementRegistry: own });
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
root.appendChild(el);
|
|
47
|
+
return [...await attachStyles(root, el, r, global, local), root, own, el];
|
|
48
|
+
}
|
|
49
|
+
var registries = /* @__PURE__ */ new Map();
|
|
50
|
+
var broken = false;
|
|
51
|
+
var fake = (registry) => Object.getPrototypeOf(registry) === customElements;
|
|
52
|
+
var owners = /* @__PURE__ */ new Map();
|
|
53
|
+
function registryFor(name) {
|
|
54
|
+
let registry = registries.get(name);
|
|
55
|
+
if (registry) return registry;
|
|
56
|
+
let real = customElements;
|
|
57
|
+
if (!broken && "initialize" in CustomElementRegistry.prototype)
|
|
58
|
+
try {
|
|
59
|
+
real = new CustomElementRegistry();
|
|
60
|
+
} catch {
|
|
61
|
+
broken = true;
|
|
62
|
+
}
|
|
63
|
+
const shared = real === customElements;
|
|
64
|
+
const own = registry = shared ? Object.create(real) : real;
|
|
65
|
+
if (shared) {
|
|
66
|
+
for (const k of ["get", "getName", "upgrade", "whenDefined"]) if (k in real) own[k] = real[k].bind(real);
|
|
67
|
+
}
|
|
68
|
+
const define = real.define;
|
|
69
|
+
own.define = (tag, ctor, options) => {
|
|
70
|
+
const had = real.get(tag);
|
|
71
|
+
const owner = owners.get(tag);
|
|
72
|
+
if (!had) return shared && owners.set(tag, name), define.call(real, tag, ctor, options);
|
|
73
|
+
if (shared && had !== ctor && owner !== name && dev())
|
|
74
|
+
console.warn(`[vitral] ${name}: <${tag}> j\xE1 foi definido por ${owner ?? "outro c\xF3digo"}; fica essa defini\xE7\xE3o. Sem Scoped Custom Element Registries, os remotes dividem o registro global.`);
|
|
75
|
+
};
|
|
76
|
+
registries.set(name, registry);
|
|
77
|
+
return registry;
|
|
78
|
+
}
|
|
79
|
+
function dev() {
|
|
80
|
+
try {
|
|
81
|
+
return process.env.NODE_ENV !== "production";
|
|
82
|
+
} catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function attachStyles(root, el, r, global = {}, local = {}) {
|
|
87
|
+
const sri = r.sri ?? {};
|
|
88
|
+
const [css, ready, up] = plan(r);
|
|
89
|
+
const portal = el.cloneNode();
|
|
90
|
+
portal.setAttribute("data-vitral-portal", "");
|
|
91
|
+
el.after(portal);
|
|
92
|
+
const urls = [...global.inherit ?? [], ...local.inherit ?? []].map((u) => new URL(u, document.baseURI).href).concat(css);
|
|
93
|
+
const props = injectCss(up, null, sri);
|
|
94
|
+
if (typeof CSSStyleSheet !== "undefined" && "replaceSync" in CSSStyleSheet.prototype) {
|
|
95
|
+
const loaded = await Promise.all(urls.map((u) => loadSheet(u, [], sri[u], ready.includes(u) ? !!r.shadow.rebase : void 0)));
|
|
96
|
+
root.adoptedStyleSheets = [.../* @__PURE__ */ new Set([...root.adoptedStyleSheets, ...loaded.flat()])];
|
|
97
|
+
} else {
|
|
98
|
+
await injectCss(urls, root, sri);
|
|
99
|
+
}
|
|
100
|
+
await props;
|
|
101
|
+
const stop = (local.mirrorTheme ?? global.mirrorTheme) === false ? [] : [mirrorTheme(el), mirrorTheme(portal)];
|
|
102
|
+
return [() => (stop.forEach((fn) => fn()), portal.remove()), portal];
|
|
103
|
+
}
|
|
104
|
+
function loadSheet(href, chain, integrity, ready) {
|
|
105
|
+
let p = sheets.get(href);
|
|
106
|
+
if (!p) {
|
|
107
|
+
p = fetchCssText(href, integrity).then((text) => {
|
|
108
|
+
const sheet = new CSSStyleSheet();
|
|
109
|
+
if (ready !== false) text = text.replace(RELATIVE_URL, (_, q, u) => `url(${q}${new URL(u, href).href}${q})`);
|
|
110
|
+
if (ready != null) return sheet.replaceSync(text), [sheet];
|
|
111
|
+
const up = [];
|
|
112
|
+
const imports = [];
|
|
113
|
+
const rest = text.replace(GLOBAL_RULES, (rule, prop, _q, quoted, bare) => {
|
|
114
|
+
const url = quoted ?? bare;
|
|
115
|
+
if (url) imports.push(new URL(url, href).href);
|
|
116
|
+
else if (!hoisted.has(prop ?? rule)) {
|
|
117
|
+
hoisted.add(prop ?? rule);
|
|
118
|
+
up.push(rule);
|
|
119
|
+
}
|
|
120
|
+
return "";
|
|
121
|
+
});
|
|
122
|
+
if (up.length) {
|
|
123
|
+
const style = document.createElement("style");
|
|
124
|
+
style.setAttribute("data-vitral-properties", "");
|
|
125
|
+
style.textContent = up.join("\n");
|
|
126
|
+
document.head.appendChild(style);
|
|
127
|
+
}
|
|
128
|
+
sheet.replaceSync(rest);
|
|
129
|
+
const next = [...chain, href];
|
|
130
|
+
return Promise.all(imports.filter((u) => !next.includes(u)).map((u) => loadSheet(u, next))).then((found) => [...found.flat(), sheet]);
|
|
131
|
+
}).catch(() => {
|
|
132
|
+
sheets.delete(href);
|
|
133
|
+
return [];
|
|
134
|
+
});
|
|
135
|
+
sheets.set(href, p);
|
|
136
|
+
}
|
|
137
|
+
return p;
|
|
138
|
+
}
|
|
139
|
+
function mirrorTheme(el) {
|
|
140
|
+
const html = document.documentElement;
|
|
141
|
+
let added = [];
|
|
142
|
+
const sync = () => {
|
|
143
|
+
el.classList.remove(...added);
|
|
144
|
+
added = [...html.classList].filter((c) => !el.classList.contains(c));
|
|
145
|
+
el.classList.add(...added);
|
|
146
|
+
const theme = html.getAttribute("data-theme");
|
|
147
|
+
if (theme === null) el.removeAttribute("data-theme");
|
|
148
|
+
else el.setAttribute("data-theme", theme);
|
|
149
|
+
};
|
|
150
|
+
sync();
|
|
151
|
+
const observer = new MutationObserver(sync);
|
|
152
|
+
observer.observe(html, { attributeFilter: ["class", "data-theme"] });
|
|
153
|
+
return () => observer.disconnect();
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
attachShadowRoot,
|
|
157
|
+
prefetch,
|
|
158
|
+
registryFor
|
|
159
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { P as Props, a as RemoteModule } from './types-CA2p9KHC.js';
|
|
2
|
+
import './errors-kjBv6IH_.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* App do single-spa como remote do vitral, sem reescrever o app:
|
|
6
|
+
*
|
|
7
|
+
* // src/vitral-remote.js
|
|
8
|
+
* import { singleSpaRemote } from 'vitral/single-spa'
|
|
9
|
+
* import * as lifecycles from './main' // exporta bootstrap, mount e unmount
|
|
10
|
+
*
|
|
11
|
+
* export default singleSpaRemote(lifecycles)
|
|
12
|
+
*
|
|
13
|
+
* Funciona com os lifecycles de `single-spa-react`, `single-spa-vue`,
|
|
14
|
+
* `single-spa-angular` etc. e com lifecycles escritos à mão. Os lifecycles
|
|
15
|
+
* recebem as props do host mais `name` e `domElement` (o elemento do remote).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Um lifecycle do single-spa: uma função ou uma lista delas, em sequência. */
|
|
19
|
+
type SingleSpaLifecycle = ((props: any) => unknown) | ((props: any) => unknown)[];
|
|
20
|
+
/** O que um app ou parcel do single-spa exporta. */
|
|
21
|
+
interface SingleSpaLifecycles {
|
|
22
|
+
bootstrap?: SingleSpaLifecycle;
|
|
23
|
+
mount: SingleSpaLifecycle;
|
|
24
|
+
unmount: SingleSpaLifecycle;
|
|
25
|
+
update?: SingleSpaLifecycle;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Embrulha os lifecycles de um app do single-spa no contrato `mount`.
|
|
29
|
+
*
|
|
30
|
+
* - `bootstrap` roda uma vez, antes do primeiro `mount`.
|
|
31
|
+
* - Os lifecycles nunca se sobrepõem: um `mount` espera o `unmount` anterior.
|
|
32
|
+
* - `update(props)` chama o `update` do app (parcels); sem ele, o app é
|
|
33
|
+
* desmontado e montado de novo com as props novas.
|
|
34
|
+
* - Duas instâncias ao mesmo tempo recebem `name` diferentes (`conta`, `conta-2`).
|
|
35
|
+
*/
|
|
36
|
+
declare function singleSpaRemote<P extends Props = Props>(lifecycles: SingleSpaLifecycles | {
|
|
37
|
+
default: SingleSpaLifecycles;
|
|
38
|
+
}): RemoteModule<P>;
|
|
39
|
+
|
|
40
|
+
export { type SingleSpaLifecycle, type SingleSpaLifecycles, singleSpaRemote };
|