vitral 0.7.2 → 0.9.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 +2 -0
- package/dist/angular.d.ts +2 -2
- package/dist/angular.js +8 -6
- package/dist/auto.js +5 -4
- package/dist/{chunk-72H4FXMD.js → chunk-6T25WKNK.js} +44 -13
- package/dist/chunk-EQZOJU3B.js +48 -0
- package/dist/chunk-JKNTXBZH.js +176 -0
- package/dist/{chunk-O7DV3EVB.js → chunk-NTXMEZIZ.js} +9 -46
- package/dist/chunk-P5JSFGPI.js +314 -0
- package/dist/{chunk-4NSPG6NK.js → chunk-PQXS2UDM.js} +1 -1
- package/dist/{chunk-TXSHK3SK.js → chunk-ZJ4IM2PZ.js} +2 -2
- package/dist/{chunk-V24ZNHUF.js → chunk-ZRAGLT3I.js} +4 -4
- package/dist/cli.js +1 -1
- package/dist/{contract-46EZFQPQ.js → contract-OMHCH6LI.js} +1 -1
- package/dist/{dedupe-S7BHQMOZ.js → dedupe-PZCSKL3L.js} +1 -1
- package/dist/edge.d.ts +1 -1
- package/dist/element.d.ts +2 -2
- package/dist/element.js +5 -4
- package/dist/embed.js +2 -2
- package/dist/{events-DLdbFqBM.d.ts → events-Cieg_far.d.ts} +1 -1
- package/dist/{expose-ZLYQZUP2.js → expose-V5ASGX4E.js} +2 -2
- package/dist/federation.d.ts +1 -1
- package/dist/{hydrate-NFZZMYWT.js → hydrate-6NE4MYOD.js} +7 -5
- package/dist/iframe.js +9 -7
- package/dist/index.d.ts +6 -19
- package/dist/index.js +6 -4
- package/dist/loader-BIXjuvvp.d.ts +25 -0
- package/dist/next-config.d.ts +95 -0
- package/dist/next-config.js +149 -0
- package/dist/next-host.d.ts +26 -0
- package/dist/next-host.js +105 -0
- package/dist/next.d.ts +190 -0
- package/dist/next.js +287 -0
- package/dist/portals-AK5XA2M5.js +22 -0
- package/dist/preact.d.ts +4 -4
- package/dist/preact.js +7 -5
- package/dist/prefetch.js +2 -2
- package/dist/react-server.d.ts +1 -1
- package/dist/react.d.ts +11 -4
- package/dist/react.js +17 -144
- package/dist/{reframe-7K5S6JC6.js → reframe-3ZN5CHEG.js} +4 -4
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +6 -4
- package/dist/single-spa.d.ts +1 -1
- package/dist/{slot-Ddzp7AgL.d.ts → slot-Dhczjs1E.d.ts} +1 -1
- package/dist/solid.d.ts +3 -3
- package/dist/solid.js +7 -5
- package/dist/{sri-576GTDIA.js → sri-TBZ6PYYY.js} +39 -24
- package/dist/svelte.d.ts +4 -4
- package/dist/svelte.js +6 -4
- package/dist/sw.d.ts +8 -0
- package/dist/sw.js +21 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -2
- package/dist/{types-EOz1rOHs.d.ts → types-wsKR1gfx.d.ts} +19 -3
- package/dist/vite.d.ts +33 -1
- package/dist/vite.js +353 -158
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +6 -4
- package/package.json +48 -22
package/README.md
CHANGED
|
@@ -186,6 +186,8 @@ Exemplo completo, com Dockerfiles e configuração do nginx: [`examples/docker`]
|
|
|
186
186
|
|
|
187
187
|
No Next e no Nuxt o componente renderiza o `fallback` no servidor e monta o remote no cliente.
|
|
188
188
|
|
|
189
|
+
Uma zona do Multi-Zones vira remote sem reescrever o código Next (`vitral({ next: true })`), e o app Next principal vira host com `withVitral` e `<NextRemote>`, trocando de área sem recarregar. Veja [Next.js](https://joaogabriel15.github.io/vitral/frameworks/next).
|
|
190
|
+
|
|
189
191
|
### Host em Vue
|
|
190
192
|
|
|
191
193
|
```vue
|
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-
|
|
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-wsKR1gfx.js';
|
|
3
|
+
export { e as events } from './events-Cieg_far.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,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineVitralElement
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ZRAGLT3I.js";
|
|
4
|
+
import "./chunk-ZJ4IM2PZ.js";
|
|
5
5
|
import {
|
|
6
6
|
defineRemote,
|
|
7
|
-
events,
|
|
8
7
|
memoSelect,
|
|
9
|
-
navigate,
|
|
10
8
|
same,
|
|
11
9
|
shared
|
|
12
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NTXMEZIZ.js";
|
|
11
|
+
import {
|
|
12
|
+
events,
|
|
13
|
+
navigate
|
|
14
|
+
} from "./chunk-EQZOJU3B.js";
|
|
13
15
|
import {
|
|
14
16
|
configure
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6T25WKNK.js";
|
|
16
18
|
import "./chunk-KU6HF2EW.js";
|
|
17
19
|
import "./chunk-TW7KYJQ6.js";
|
|
18
20
|
import "./chunk-463H6B56.js";
|
package/dist/auto.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineVitralElement
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ZRAGLT3I.js";
|
|
4
|
+
import "./chunk-ZJ4IM2PZ.js";
|
|
5
|
+
import "./chunk-NTXMEZIZ.js";
|
|
6
|
+
import "./chunk-EQZOJU3B.js";
|
|
7
|
+
import "./chunk-6T25WKNK.js";
|
|
7
8
|
import "./chunk-KU6HF2EW.js";
|
|
8
9
|
import "./chunk-TW7KYJQ6.js";
|
|
9
10
|
import "./chunk-463H6B56.js";
|
|
@@ -26,7 +26,7 @@ function configure(config) {
|
|
|
26
26
|
const { remotes, dedupe, ...rest } = config;
|
|
27
27
|
p.configure(rest);
|
|
28
28
|
if (rest.captureGlobalErrors) import("./capture-TT5WBLJ6.js").then((m) => m.capture());
|
|
29
|
-
if (dedupe) p.pending(import("./dedupe-
|
|
29
|
+
if (dedupe) p.pending(import("./dedupe-PZCSKL3L.js").then((m) => m.offer(p, dedupe)).catch(() => {
|
|
30
30
|
}));
|
|
31
31
|
if (typeof remotes === "string") {
|
|
32
32
|
const url = absolute(remotes);
|
|
@@ -79,27 +79,48 @@ function loadRemote(name) {
|
|
|
79
79
|
return load(name).then((r) => r.module);
|
|
80
80
|
}
|
|
81
81
|
function loadModule(name) {
|
|
82
|
-
return import("./expose-
|
|
82
|
+
return import("./expose-V5ASGX4E.js").then((m) => m.resolveModule(name, (n) => loadFile(n))).catch(fail);
|
|
83
83
|
}
|
|
84
|
-
function preload(name) {
|
|
85
|
-
load(name)
|
|
84
|
+
function preload(name, options = {}) {
|
|
85
|
+
const done = load(name);
|
|
86
|
+
done.catch(() => {
|
|
86
87
|
});
|
|
88
|
+
if (options.routes) done.then(warmRoutes, () => {
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function routeChunks(r) {
|
|
92
|
+
const s = r.split;
|
|
93
|
+
if (!s) return [];
|
|
94
|
+
if (s.lazy) return s.lazy;
|
|
95
|
+
const dir = s.entry.slice(0, s.entry.lastIndexOf("/") + 1);
|
|
96
|
+
const loaded = /* @__PURE__ */ new Set([s.entry, ...s.chunks, ...s.probe ?? [], ...(s.dedupe ?? []).flatMap((d) => [d.file, ...d.chunks ?? []])]);
|
|
97
|
+
return Object.keys(r.sri ?? {}).filter((u) => u.startsWith(dir) && u.endsWith(".js") && !loaded.has(u));
|
|
98
|
+
}
|
|
99
|
+
function warmRoutes(r) {
|
|
100
|
+
const c = navigator.connection;
|
|
101
|
+
if (c?.saveData || /2g/.test(c?.effectiveType)) return;
|
|
102
|
+
const queue = routeChunks(r).slice();
|
|
103
|
+
const next = () => queue.length && fetch(queue.shift(), { priority: "low" }).then((res) => res.arrayBuffer()).catch(() => {
|
|
104
|
+
}).then(next);
|
|
105
|
+
const run = () => [0, 0, 0].map(next);
|
|
106
|
+
if (typeof requestIdleCallback === "function") requestIdleCallback(run, { timeout: 1e4 });
|
|
107
|
+
else setTimeout(run, 1);
|
|
87
108
|
}
|
|
88
109
|
var paths;
|
|
89
110
|
function warm() {
|
|
90
111
|
if (paths) return;
|
|
91
|
-
paths = import("./sri-
|
|
92
|
-
import("./dedupe-
|
|
112
|
+
paths = import("./sri-TBZ6PYYY.js").catch(() => null);
|
|
113
|
+
import("./dedupe-PZCSKL3L.js").catch(() => {
|
|
93
114
|
});
|
|
94
115
|
}
|
|
95
116
|
function warmSsr(holder) {
|
|
96
|
-
paths ??= import("./sri-
|
|
97
|
-
if (holder.querySelector("script[data-vitral-manifest]")?.textContent?.includes('"dedupe"')) import("./dedupe-
|
|
117
|
+
paths ??= import("./sri-TBZ6PYYY.js").catch(() => null);
|
|
118
|
+
if (holder.querySelector("script[data-vitral-manifest]")?.textContent?.includes('"dedupe"')) import("./dedupe-PZCSKL3L.js").catch(() => {
|
|
98
119
|
});
|
|
99
120
|
}
|
|
100
121
|
function load(name, isolate, priority) {
|
|
101
122
|
const file = (n) => loadFile(n, isolate, priority);
|
|
102
|
-
return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-
|
|
123
|
+
return (protocol().entry(name) || !name.includes("/") ? file(name).then((r) => mountable(name, r)) : import("./expose-V5ASGX4E.js").then((m) => m.resolveTarget(name, file))).catch(fail);
|
|
103
124
|
}
|
|
104
125
|
function loadFile(name, isolate, priority) {
|
|
105
126
|
const p = protocol();
|
|
@@ -143,7 +164,7 @@ async function resolveEntry(name, entry, priority) {
|
|
|
143
164
|
if (m?.stable) return resolveEntry(name, await (await import("./channel-2YPYGX3J.js")).pick(name, entry, m), priority);
|
|
144
165
|
if (typeof m?.entry !== "string") throw new RemoteError("INVALID_MODULE", name, `manifesto inv\xE1lido em ${entry.url}`);
|
|
145
166
|
if (m.contract && (entry.contract || protocol().settings().contract)) {
|
|
146
|
-
const why = await (await import("./contract-
|
|
167
|
+
const why = await (await import("./contract-OMHCH6LI.js")).checkContract(m.contract, entry.contract);
|
|
147
168
|
if (why) throw new RemoteError("CONTRACT_MISMATCH", name, why);
|
|
148
169
|
}
|
|
149
170
|
const abs = (u) => absolute(u, entry.url);
|
|
@@ -155,17 +176,19 @@ async function resolveEntry(name, entry, priority) {
|
|
|
155
176
|
shadow: m.shadow,
|
|
156
177
|
// A integridade declarada pelo host vence a do manifesto, e aí só o
|
|
157
178
|
// arquivo único (o que ela descreve) é usado.
|
|
158
|
-
integrity: entry.integrity ?? m.integrity,
|
|
179
|
+
integrity: entry.integrity === false ? void 0 : entry.integrity ?? m.integrity,
|
|
159
180
|
isolate: entry.isolate,
|
|
160
181
|
scope: m.scope,
|
|
161
182
|
version: m.version,
|
|
162
183
|
sri,
|
|
163
184
|
priority,
|
|
164
|
-
split: m.split &&
|
|
185
|
+
split: m.split && typeof entry.integrity !== "string" ? {
|
|
165
186
|
entry: abs(m.split.entry),
|
|
166
187
|
chunks: (m.split.chunks ?? []).map(abs),
|
|
188
|
+
...m.split.lazy && { lazy: m.split.lazy.map(abs) },
|
|
167
189
|
sri,
|
|
168
190
|
priority,
|
|
191
|
+
...m.probe && { probe: m.probe.map(abs) },
|
|
169
192
|
dedupe: m.dedupe?.map((d) => ({ ...d, file: abs(d.file), chunks: d.chunks?.map(abs) }))
|
|
170
193
|
} : void 0
|
|
171
194
|
};
|
|
@@ -193,7 +216,15 @@ async function importModule(name, r) {
|
|
|
193
216
|
)).catch((e) => {
|
|
194
217
|
throw isRemoteError(e) ? e : new RemoteError("LOAD_FAILED", name, `falha ao importar ${r.entry}`, e);
|
|
195
218
|
});
|
|
196
|
-
if (!r.integrity)
|
|
219
|
+
if (!r.integrity) {
|
|
220
|
+
if (!r.split) return run(r.entry);
|
|
221
|
+
if (r.split.dedupe?.length) {
|
|
222
|
+
const { shared } = await import("./dedupe-PZCSKL3L.js");
|
|
223
|
+
for (const d of r.split.dedupe)
|
|
224
|
+
shared(protocol())(d.name, d.range, { version: d.version, url: d.file, load: async () => (await run(d.file)).default });
|
|
225
|
+
}
|
|
226
|
+
return run(r.split.entry);
|
|
227
|
+
}
|
|
197
228
|
const sri = await paths;
|
|
198
229
|
if (!sri) throw new RemoteError("LOAD_FAILED", name, "n\xE3o foi poss\xEDvel carregar o verificador de integrity");
|
|
199
230
|
return sri.importVerified(name, r, run, timeout);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
protocol
|
|
3
|
+
} from "./chunk-GNPFWISJ.js";
|
|
4
|
+
|
|
5
|
+
// src/core/events.ts
|
|
6
|
+
var events = {
|
|
7
|
+
emit: (t, p) => protocol().events.emit(t, p),
|
|
8
|
+
on: (t, h) => protocol().events.on(t, h),
|
|
9
|
+
last: (t) => protocol().events.last(t)
|
|
10
|
+
};
|
|
11
|
+
function scopedEvents() {
|
|
12
|
+
const offs = /* @__PURE__ */ new Set();
|
|
13
|
+
const track = (off) => {
|
|
14
|
+
const wrapped = () => (offs.delete(wrapped), off());
|
|
15
|
+
offs.add(wrapped);
|
|
16
|
+
return wrapped;
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
bus: {
|
|
20
|
+
emit: (t, p) => events.emit(t, p),
|
|
21
|
+
last: (t) => events.last(t),
|
|
22
|
+
on: (t, h) => track(events.on(t, h))
|
|
23
|
+
},
|
|
24
|
+
track,
|
|
25
|
+
dispose() {
|
|
26
|
+
for (const off of [...offs]) off();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// src/core/navigate.ts
|
|
32
|
+
function navigate(url, options = {}) {
|
|
33
|
+
const target = new URL(url, location.href);
|
|
34
|
+
if (target.origin !== location.origin) {
|
|
35
|
+
location.assign(target.href);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (options.replace) history.replaceState(history.state, "", target.href);
|
|
39
|
+
else history.pushState(history.state, "", target.href);
|
|
40
|
+
dispatchEvent(new PopStateEvent("popstate", { state: history.state }));
|
|
41
|
+
events.emit("vitral:navigate", target.pathname + target.search + target.hash);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
events,
|
|
46
|
+
scopedEvents,
|
|
47
|
+
navigate
|
|
48
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RemoteTree,
|
|
3
|
+
VitralContext
|
|
4
|
+
} from "./chunk-B2MPYF4M.js";
|
|
5
|
+
import {
|
|
6
|
+
hostSlot
|
|
7
|
+
} from "./chunk-ZJ4IM2PZ.js";
|
|
8
|
+
import {
|
|
9
|
+
defineRemote,
|
|
10
|
+
memoSelect,
|
|
11
|
+
same,
|
|
12
|
+
shared
|
|
13
|
+
} from "./chunk-NTXMEZIZ.js";
|
|
14
|
+
import {
|
|
15
|
+
events
|
|
16
|
+
} from "./chunk-EQZOJU3B.js";
|
|
17
|
+
import {
|
|
18
|
+
preload
|
|
19
|
+
} from "./chunk-6T25WKNK.js";
|
|
20
|
+
import {
|
|
21
|
+
protocol
|
|
22
|
+
} from "./chunk-GNPFWISJ.js";
|
|
23
|
+
|
|
24
|
+
// src/react.tsx
|
|
25
|
+
import {
|
|
26
|
+
useContext,
|
|
27
|
+
useEffect,
|
|
28
|
+
useMemo,
|
|
29
|
+
useRef,
|
|
30
|
+
useState,
|
|
31
|
+
useSyncExternalStore
|
|
32
|
+
} from "react";
|
|
33
|
+
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
34
|
+
import * as ReactAll from "react";
|
|
35
|
+
import * as ReactDOM from "react-dom";
|
|
36
|
+
import * as ReactDOMClient from "react-dom/client";
|
|
37
|
+
import * as JSXRuntime from "react/jsx-runtime";
|
|
38
|
+
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
39
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
40
|
+
function reactRemote(Component) {
|
|
41
|
+
const start = (el, props, ctx, hydrate) => {
|
|
42
|
+
const tree = (p) => /* @__PURE__ */ jsx(RemoteTree, { Component, props: p, ctx });
|
|
43
|
+
const options = { onUncaughtError: (e) => ctx.reportError(e) };
|
|
44
|
+
const scope = ctx.portalContainer === document.body && el.closest("[data-vitral-scope]")?.getAttribute("data-vitral-scope");
|
|
45
|
+
let stop;
|
|
46
|
+
let gone = false;
|
|
47
|
+
if (scope) void import("./portals-AK5XA2M5.js").then((m) => gone || (stop = m.scopePortals(el, scope)));
|
|
48
|
+
const root = hydrate ? hydrateRoot(el, tree(props), options) : createRoot(el, options);
|
|
49
|
+
const render = (p) => root.render(tree(p));
|
|
50
|
+
if (!hydrate) render(props);
|
|
51
|
+
return {
|
|
52
|
+
update: render,
|
|
53
|
+
unmount: () => {
|
|
54
|
+
root.unmount();
|
|
55
|
+
gone = true;
|
|
56
|
+
stop?.();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
return defineRemote({
|
|
61
|
+
mount: (el, props, ctx) => start(el, props, ctx, false),
|
|
62
|
+
hydrate: (el, props, ctx) => start(el, props, ctx, true)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function useVitral() {
|
|
66
|
+
return useContext(VitralContext);
|
|
67
|
+
}
|
|
68
|
+
function usePortalContainer() {
|
|
69
|
+
return useVitral()?.portalContainer;
|
|
70
|
+
}
|
|
71
|
+
function useEvent(type, handler) {
|
|
72
|
+
const ref = useRef(handler);
|
|
73
|
+
ref.current = handler;
|
|
74
|
+
useEffect(() => events.on(type, (p) => ref.current(p)), [type]);
|
|
75
|
+
}
|
|
76
|
+
function useEventValue(type) {
|
|
77
|
+
const [value, setValue] = useState(() => events.last(type));
|
|
78
|
+
useEvent(type, setValue);
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
function useShared(key, select = same) {
|
|
82
|
+
const handle = useMemo(() => shared(key), [key]);
|
|
83
|
+
const [pick] = useState(memoSelect);
|
|
84
|
+
return useSyncExternalStore(
|
|
85
|
+
handle.subscribe,
|
|
86
|
+
() => pick(handle.get(), select),
|
|
87
|
+
() => pick(void 0, select)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
var offeredTo;
|
|
91
|
+
function offerReact() {
|
|
92
|
+
const p = protocol();
|
|
93
|
+
if (offeredTo === p) return;
|
|
94
|
+
offeredTo = p;
|
|
95
|
+
const compiler = ReactAll.__COMPILER_RUNTIME;
|
|
96
|
+
const modules = {
|
|
97
|
+
react: ReactAll,
|
|
98
|
+
"react-dom": ReactDOM,
|
|
99
|
+
"react-dom/client": ReactDOMClient,
|
|
100
|
+
"react/jsx-runtime": JSXRuntime,
|
|
101
|
+
"react/jsx-dev-runtime": JSXDevRuntime,
|
|
102
|
+
// O React 19 expõe o react/compiler-runtime pelo próprio react.
|
|
103
|
+
...compiler && { "react/compiler-runtime": compiler }
|
|
104
|
+
};
|
|
105
|
+
p.pending(import("./dedupe-PZCSKL3L.js").then((m) => m.offer(p, { react: { version: ReactAll.version, modules } })).catch(() => {
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
function preload2(name, options) {
|
|
109
|
+
offerReact();
|
|
110
|
+
preload(name, options);
|
|
111
|
+
}
|
|
112
|
+
function Remote({
|
|
113
|
+
name,
|
|
114
|
+
src,
|
|
115
|
+
props,
|
|
116
|
+
isolate,
|
|
117
|
+
fallback = null,
|
|
118
|
+
error,
|
|
119
|
+
onError,
|
|
120
|
+
className,
|
|
121
|
+
loading,
|
|
122
|
+
prefetch,
|
|
123
|
+
priority,
|
|
124
|
+
keepAlive
|
|
125
|
+
}) {
|
|
126
|
+
const target = useRef(null);
|
|
127
|
+
const slot = useRef(null);
|
|
128
|
+
const [state, setState] = useState({ status: "loading", error: null });
|
|
129
|
+
const onErrorRef = useRef(onError);
|
|
130
|
+
onErrorRef.current = onError;
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
offerReact();
|
|
133
|
+
const s = hostSlot(target.current, {
|
|
134
|
+
name,
|
|
135
|
+
src,
|
|
136
|
+
props: props ?? {},
|
|
137
|
+
isolate,
|
|
138
|
+
loading,
|
|
139
|
+
prefetch,
|
|
140
|
+
priority,
|
|
141
|
+
keepAlive,
|
|
142
|
+
onStatus(status2, e) {
|
|
143
|
+
setState({ status: status2, error: e });
|
|
144
|
+
if (e) {
|
|
145
|
+
if (onErrorRef.current) onErrorRef.current(e);
|
|
146
|
+
else console.error(e);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
slot.current = s;
|
|
151
|
+
return () => {
|
|
152
|
+
slot.current = null;
|
|
153
|
+
queueMicrotask(() => s.destroy());
|
|
154
|
+
};
|
|
155
|
+
}, []);
|
|
156
|
+
useEffect(() => slot.current?.set({ name, src, isolate }), [name, src, isolate]);
|
|
157
|
+
useEffect(() => slot.current?.update(props ?? {}), [props]);
|
|
158
|
+
const retry = () => slot.current?.retry();
|
|
159
|
+
const { status, error: err } = state;
|
|
160
|
+
return /* @__PURE__ */ jsxs("div", { className, "data-vitral": name ?? src, "data-vitral-status": status, children: [
|
|
161
|
+
status === "loading" && fallback,
|
|
162
|
+
status === "error" && err && (typeof error === "function" ? error(err, retry) : error ?? null),
|
|
163
|
+
/* @__PURE__ */ jsx("div", { ref: target })
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
reactRemote,
|
|
169
|
+
useVitral,
|
|
170
|
+
usePortalContainer,
|
|
171
|
+
useEvent,
|
|
172
|
+
useEventValue,
|
|
173
|
+
useShared,
|
|
174
|
+
preload2 as preload,
|
|
175
|
+
Remote
|
|
176
|
+
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
events,
|
|
3
|
+
navigate,
|
|
4
|
+
scopedEvents
|
|
5
|
+
} from "./chunk-EQZOJU3B.js";
|
|
1
6
|
import {
|
|
2
7
|
load,
|
|
3
8
|
loadFile,
|
|
4
9
|
registerSrc,
|
|
5
10
|
resolveEntry
|
|
6
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6T25WKNK.js";
|
|
7
12
|
import {
|
|
8
13
|
injectStyles
|
|
9
14
|
} from "./chunk-KU6HF2EW.js";
|
|
@@ -22,45 +27,6 @@ import {
|
|
|
22
27
|
protocol
|
|
23
28
|
} from "./chunk-GNPFWISJ.js";
|
|
24
29
|
|
|
25
|
-
// src/core/events.ts
|
|
26
|
-
var events = {
|
|
27
|
-
emit: (t, p) => protocol().events.emit(t, p),
|
|
28
|
-
on: (t, h) => protocol().events.on(t, h),
|
|
29
|
-
last: (t) => protocol().events.last(t)
|
|
30
|
-
};
|
|
31
|
-
function scopedEvents() {
|
|
32
|
-
const offs = /* @__PURE__ */ new Set();
|
|
33
|
-
const track2 = (off) => {
|
|
34
|
-
const wrapped = () => (offs.delete(wrapped), off());
|
|
35
|
-
offs.add(wrapped);
|
|
36
|
-
return wrapped;
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
bus: {
|
|
40
|
-
emit: (t, p) => events.emit(t, p),
|
|
41
|
-
last: (t) => events.last(t),
|
|
42
|
-
on: (t, h) => track2(events.on(t, h))
|
|
43
|
-
},
|
|
44
|
-
track: track2,
|
|
45
|
-
dispose() {
|
|
46
|
-
for (const off of [...offs]) off();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/core/navigate.ts
|
|
52
|
-
function navigate(url, options = {}) {
|
|
53
|
-
const target = new URL(url, location.href);
|
|
54
|
-
if (target.origin !== location.origin) {
|
|
55
|
-
location.assign(target.href);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (options.replace) history.replaceState(history.state, "", target.href);
|
|
59
|
-
else history.pushState(history.state, "", target.href);
|
|
60
|
-
dispatchEvent(new PopStateEvent("popstate", { state: history.state }));
|
|
61
|
-
events.emit("vitral:navigate", target.pathname + target.search + target.hash);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
30
|
// src/core/updates.ts
|
|
65
31
|
var versions = /* @__PURE__ */ new Map();
|
|
66
32
|
var live = /* @__PURE__ */ new Map();
|
|
@@ -119,7 +85,7 @@ var noop = () => {
|
|
|
119
85
|
async function checkUpdates() {
|
|
120
86
|
const p = protocol();
|
|
121
87
|
const found = [];
|
|
122
|
-
const { splitName } = await import("./expose-
|
|
88
|
+
const { splitName } = await import("./expose-V5ASGX4E.js");
|
|
123
89
|
const remotes = /* @__PURE__ */ new Map();
|
|
124
90
|
for (const name of live.keys()) {
|
|
125
91
|
const root = splitName(name)[0];
|
|
@@ -164,8 +130,8 @@ async function mountOnce(target, name, props, options) {
|
|
|
164
130
|
const p = protocol();
|
|
165
131
|
await p.pending();
|
|
166
132
|
const isolate = options.isolate ?? registered(name)?.isolate ?? p.settings().isolate;
|
|
167
|
-
if (isolate === "iframe") return (frames ?? (await import("./reframe-
|
|
168
|
-
const { module: mod, ...resolved } = await (isolate == "reframe" ? (await import("./reframe-
|
|
133
|
+
if (isolate === "iframe") return (frames ?? (await import("./reframe-3ZN5CHEG.js")).noFrames)(target, name, props, options).catch(fail);
|
|
134
|
+
const { module: mod, ...resolved } = await (isolate == "reframe" ? (await import("./reframe-3ZN5CHEG.js")).load : load)(name, isolate, options.priority);
|
|
169
135
|
const untrack = track(name, resolved);
|
|
170
136
|
ctxHooks.watch?.(name);
|
|
171
137
|
const label = resolved.name ?? name;
|
|
@@ -607,9 +573,6 @@ function serializeShared(values) {
|
|
|
607
573
|
}
|
|
608
574
|
|
|
609
575
|
export {
|
|
610
|
-
events,
|
|
611
|
-
scopedEvents,
|
|
612
|
-
navigate,
|
|
613
576
|
track,
|
|
614
577
|
refresh,
|
|
615
578
|
refreshable,
|