vitral 0.10.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -7
- package/dist/angular.d.ts +2 -2
- package/dist/angular.js +13 -10
- package/dist/auto.js +11 -8
- package/dist/{capture-A6JQNNQY.js → capture-2I5IQ2C2.js} +2 -1
- package/dist/{channel-2DUQQPPA.js → channel-ABGK26Q5.js} +5 -3
- package/dist/{chunk-WAU6OKK3.js → chunk-2SAI6S2H.js} +11 -3
- package/dist/chunk-2Z4OH3BP.js +85 -0
- package/dist/chunk-5O6XDJBR.js +15 -0
- package/dist/chunk-623K4UNS.js +70 -0
- package/dist/{chunk-VTGHPX4J.js → chunk-6JH2I65O.js} +15 -13
- package/dist/{chunk-EVVYV5ED.js → chunk-AL6MLNVY.js} +49 -21
- package/dist/chunk-B3PFMWZT.js +21 -0
- package/dist/{chunk-463H6B56.js → chunk-BQGVAXFM.js} +3 -4
- package/dist/{chunk-TW7KYJQ6.js → chunk-GGMM56TM.js} +1 -1
- package/dist/{chunk-FOEXP52G.js → chunk-I3CDUKHO.js} +69 -19
- package/dist/{chunk-SC2KF7GJ.js → chunk-IKCEA3YN.js} +3 -3
- package/dist/chunk-JWDDXX5O.js +6 -0
- package/dist/{chunk-B2MPYF4M.js → chunk-KCF46XOX.js} +4 -2
- package/dist/{chunk-R3HUMHNL.js → chunk-LDOSAAEF.js} +15 -0
- package/dist/{chunk-MGG5BW3U.js → chunk-MICF64AZ.js} +2 -2
- package/dist/{chunk-QINOFHG6.js → chunk-NQ6ZTGQZ.js} +2 -2
- package/dist/chunk-QQWE5J6U.js +37 -0
- package/dist/{chunk-VK6W7KHM.js → chunk-SPSAXBPR.js} +10 -6
- package/dist/{chunk-CFJC4GRB.js → chunk-SVYL6UCB.js} +21 -10
- package/dist/{chunk-UYOPJ4XQ.js → chunk-UCFOXMOR.js} +1 -1
- package/dist/cli.js +119 -8
- package/dist/{contract-IXM52LVW.js → contract-3JY7SOGQ.js} +1 -1
- package/dist/{dedupe-SRAPOK3V.js → dedupe-M63VMCWA.js} +3 -1
- package/dist/edge.d.ts +4 -2
- package/dist/edge.js +69 -46
- package/dist/element.d.ts +3 -3
- package/dist/element.js +11 -8
- package/dist/embed.js +2 -2
- package/dist/{events-CWdYSrkz.d.ts → events-II6hXM3Q.d.ts} +1 -1
- package/dist/expose-2S3TCXSP.js +18 -0
- package/dist/federation.d.ts +1 -1
- package/dist/{hydrate-IVQNHOP3.js → hydrate-FJHHLW5G.js} +22 -12
- package/dist/iframe.js +15 -12
- package/dist/index.d.ts +6 -6
- package/dist/index.js +25 -11
- package/dist/{loader-CLRMRRFv.d.ts → loader-Bmul2-5T.d.ts} +1 -1
- package/dist/next-config.d.ts +30 -10
- package/dist/next-config.js +29 -20
- package/dist/next-host.d.ts +11 -5
- package/dist/next-host.js +54 -29
- package/dist/next-server.d.ts +56 -0
- package/dist/next-server.js +90 -0
- package/dist/preact.d.ts +4 -4
- package/dist/preact.js +10 -7
- package/dist/prefetch.d.ts +40 -3
- package/dist/prefetch.js +100 -30
- package/dist/react-server.d.ts +16 -5
- package/dist/react-server.js +8 -3
- package/dist/react.d.ts +20 -6
- package/dist/react.js +14 -9
- package/dist/{reframe-ZOQPW552.js → reframe-HIYA2TIU.js} +10 -9
- package/dist/route-4KQITYD4.js +138 -0
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +12 -9
- package/dist/{shadow-PZGQKUA4.js → shadow-7ZV4JEO6.js} +4 -3
- package/dist/sign.d.ts +49 -0
- package/dist/sign.js +15 -0
- package/dist/single-spa.d.ts +1 -1
- package/dist/{slot-DRYmGvvV.d.ts → slot--WLgdcW_.d.ts} +1 -1
- package/dist/snapshot.d.ts +6 -0
- package/dist/snapshot.js +125 -0
- package/dist/solid.d.ts +3 -3
- package/dist/solid.js +10 -7
- package/dist/sri-AMQOKKWR.js +17 -0
- package/dist/ssr-markup-BCPpGmss.d.ts +13 -0
- package/dist/state-B1FJi8I9.d.ts +14 -0
- package/dist/svelte.d.ts +4 -4
- package/dist/svelte.js +10 -7
- package/dist/sw.d.ts +48 -1
- package/dist/sw.js +79 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +10 -7
- package/dist/{types-g8WEVD_b.d.ts → types-DJautV-K.d.ts} +86 -1
- package/dist/vitals.js +2 -1
- package/dist/vite.d.ts +4 -2
- package/dist/vite.js +62 -12
- package/dist/vue.d.ts +3 -3
- package/dist/vue.js +13 -10
- package/package.json +47 -39
- package/dist/expose-BA4HSXDP.js +0 -17
- package/dist/portals-RLXKPXBZ.js +0 -24
- package/dist/sri-LQBLQMG5.js +0 -14
- package/dist/state-BDdCwc21.d.ts +0 -4
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RemoteTree,
|
|
3
|
+
StateContext,
|
|
3
4
|
VitralContext
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KCF46XOX.js";
|
|
5
6
|
import {
|
|
6
|
-
hostSlot
|
|
7
|
-
|
|
7
|
+
hostSlot,
|
|
8
|
+
when
|
|
9
|
+
} from "./chunk-2SAI6S2H.js";
|
|
8
10
|
import {
|
|
9
11
|
defineRemote,
|
|
10
12
|
memoSelect,
|
|
11
13
|
same,
|
|
12
14
|
shared
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import {
|
|
15
|
-
events
|
|
16
|
-
} from "./chunk-EQZOJU3B.js";
|
|
15
|
+
} from "./chunk-6JH2I65O.js";
|
|
17
16
|
import {
|
|
17
|
+
policy,
|
|
18
18
|
preload
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-AL6MLNVY.js";
|
|
20
20
|
import {
|
|
21
21
|
dedupeModule
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-MICF64AZ.js";
|
|
23
|
+
import {
|
|
24
|
+
events
|
|
25
|
+
} from "./chunk-EQZOJU3B.js";
|
|
23
26
|
import {
|
|
24
27
|
protocol
|
|
25
28
|
} from "./chunk-GNPFWISJ.js";
|
|
@@ -39,15 +42,35 @@ import * as ReactDOM from "react-dom";
|
|
|
39
42
|
import * as ReactDOMClient from "react-dom/client";
|
|
40
43
|
import * as JSXRuntime from "react/jsx-runtime";
|
|
41
44
|
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
45
|
+
|
|
46
|
+
// src/core/portals.ts
|
|
47
|
+
function scopePortals(root, scope) {
|
|
48
|
+
const owner = (node) => {
|
|
49
|
+
const key = Object.keys(node).find((k) => k.startsWith("__reactFiber$"));
|
|
50
|
+
for (let f = key && node[key]; f; f = f.return) {
|
|
51
|
+
const s = f.stateNode;
|
|
52
|
+
if (s && s !== node && s.nodeType === 1 && root.contains(s)) return true;
|
|
53
|
+
if (f.tag === 3) return s?.containerInfo === root;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
const mark = (n) => {
|
|
58
|
+
if (n instanceof Element && !n.hasAttribute("data-vitral-scope") && owner(n)) n.setAttribute("data-vitral-scope", scope);
|
|
59
|
+
};
|
|
60
|
+
const watch = new MutationObserver((list) => list.forEach((r) => r.addedNodes.forEach(mark)));
|
|
61
|
+
watch.observe(document.body, { childList: true });
|
|
62
|
+
document.body.childNodes.forEach(mark);
|
|
63
|
+
return () => watch.disconnect();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/react.tsx
|
|
42
67
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
43
68
|
function reactRemote(Component) {
|
|
44
69
|
const start = (el, props, ctx, hydrate) => {
|
|
45
70
|
const tree = (p) => /* @__PURE__ */ jsx(RemoteTree, { Component, props: p, ctx });
|
|
46
71
|
const options = { onUncaughtError: (e) => ctx.reportError(e) };
|
|
47
72
|
const scope = ctx.portalContainer === document.body && el.closest("[data-vitral-scope]")?.getAttribute("data-vitral-scope");
|
|
48
|
-
|
|
49
|
-
let gone = false;
|
|
50
|
-
if (scope) void import("./portals-RLXKPXBZ.js").then((m) => gone || (stop = m.scopePortals(el, scope)));
|
|
73
|
+
const stop = scope ? scopePortals(el, scope) : void 0;
|
|
51
74
|
const root = hydrate ? hydrateRoot(el, tree(props), options) : createRoot(el, options);
|
|
52
75
|
const render = (p) => root.render(tree(p));
|
|
53
76
|
if (!hydrate) render(props);
|
|
@@ -55,7 +78,6 @@ function reactRemote(Component) {
|
|
|
55
78
|
update: render,
|
|
56
79
|
unmount: () => {
|
|
57
80
|
root.unmount();
|
|
58
|
-
gone = true;
|
|
59
81
|
stop?.();
|
|
60
82
|
}
|
|
61
83
|
};
|
|
@@ -68,6 +90,9 @@ function reactRemote(Component) {
|
|
|
68
90
|
function useVitral() {
|
|
69
91
|
return useContext(VitralContext);
|
|
70
92
|
}
|
|
93
|
+
function useInitialState() {
|
|
94
|
+
return useContext(StateContext);
|
|
95
|
+
}
|
|
71
96
|
function usePortalContainer() {
|
|
72
97
|
return useVitral()?.portalContainer;
|
|
73
98
|
}
|
|
@@ -124,16 +149,22 @@ function Remote({
|
|
|
124
149
|
loading,
|
|
125
150
|
prefetch,
|
|
126
151
|
priority,
|
|
127
|
-
keepAlive
|
|
152
|
+
keepAlive,
|
|
153
|
+
ssr,
|
|
154
|
+
snapshot
|
|
128
155
|
}) {
|
|
129
156
|
const target = useRef(null);
|
|
130
157
|
const slot = useRef(null);
|
|
131
158
|
const [state, setState] = useState({ status: "loading", error: null });
|
|
132
159
|
const onErrorRef = useRef(onError);
|
|
133
160
|
onErrorRef.current = onError;
|
|
161
|
+
const [html] = useState(() => ssr || null);
|
|
162
|
+
const [snapped, setSnapped] = useState(false);
|
|
163
|
+
const latest = useRef(props);
|
|
164
|
+
latest.current = props;
|
|
134
165
|
useEffect(() => {
|
|
135
166
|
offerReact();
|
|
136
|
-
const
|
|
167
|
+
const options = {
|
|
137
168
|
name,
|
|
138
169
|
src,
|
|
139
170
|
props: props ?? {},
|
|
@@ -142,6 +173,8 @@ function Remote({
|
|
|
142
173
|
prefetch,
|
|
143
174
|
priority,
|
|
144
175
|
keepAlive,
|
|
176
|
+
snapshot,
|
|
177
|
+
onSnapshot: setSnapped,
|
|
145
178
|
onStatus(status2, e) {
|
|
146
179
|
setState({ status: status2, error: e });
|
|
147
180
|
if (e) {
|
|
@@ -149,8 +182,24 @@ function Remote({
|
|
|
149
182
|
else console.error(e);
|
|
150
183
|
}
|
|
151
184
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
185
|
+
};
|
|
186
|
+
const holder = html && target.current.querySelector(":scope>[data-vitral-ssr]");
|
|
187
|
+
let dead = false;
|
|
188
|
+
let s = null;
|
|
189
|
+
if (holder) {
|
|
190
|
+
const go = () => import("./hydrate-FJHHLW5G.js").then((m) => {
|
|
191
|
+
if (!dead) slot.current = s = m.hydrateSlot(target.current, holder, { ...options, props: latest.current ?? {} });
|
|
192
|
+
});
|
|
193
|
+
const stop = policy() === "lazy" ? when(target.current, "visible", go) : (go(), () => {
|
|
194
|
+
});
|
|
195
|
+
const end = () => (stop(), dead = true);
|
|
196
|
+
return () => {
|
|
197
|
+
end();
|
|
198
|
+
slot.current = null;
|
|
199
|
+
queueMicrotask(() => s?.destroy());
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
slot.current = s = hostSlot(target.current, options);
|
|
154
203
|
return () => {
|
|
155
204
|
slot.current = null;
|
|
156
205
|
queueMicrotask(() => s.destroy());
|
|
@@ -161,15 +210,16 @@ function Remote({
|
|
|
161
210
|
const retry = () => slot.current?.retry();
|
|
162
211
|
const { status, error: err } = state;
|
|
163
212
|
return /* @__PURE__ */ jsxs("div", { className, "data-vitral": name ?? src, "data-vitral-status": status, children: [
|
|
164
|
-
status === "loading" && fallback,
|
|
213
|
+
status === "loading" && !html && !snapped && fallback,
|
|
165
214
|
status === "error" && err && (typeof error === "function" ? error(err, retry) : error ?? null),
|
|
166
|
-
/* @__PURE__ */ jsx("div", { ref: target })
|
|
215
|
+
html ? /* @__PURE__ */ jsx("div", { ref: target, dangerouslySetInnerHTML: { __html: html }, suppressHydrationWarning: true }) : /* @__PURE__ */ jsx("div", { ref: target })
|
|
167
216
|
] });
|
|
168
217
|
}
|
|
169
218
|
|
|
170
219
|
export {
|
|
171
220
|
reactRemote,
|
|
172
221
|
useVitral,
|
|
222
|
+
useInitialState,
|
|
173
223
|
usePortalContainer,
|
|
174
224
|
useEvent,
|
|
175
225
|
useEventValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addLink,
|
|
3
3
|
fetchBytes
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GGMM56TM.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-
|
|
26
|
+
if (shadow && adopts()) import("./shadow-7ZV4JEO6.js").then((m) => m.prefetch(r, priority), noop);
|
|
27
27
|
else for (const href of r.css) if (!document.querySelector(`link[href="${href}"]`)) addLink("preload", href, { as: "style", integrity: r.sri?.[href] ?? "", fetchPriority: priority });
|
|
28
28
|
}
|
|
29
29
|
function injectStyles(r, shadow, make, styles) {
|
|
30
|
-
return shadow ? import("./shadow-
|
|
30
|
+
return shadow ? import("./shadow-7ZV4JEO6.js").then((m) => m.attachShadowRoot(shadow, make, r, protocol().settings().styles, styles)) : injectCss(r.css, null, r.sri).then(() => [noop]);
|
|
31
31
|
}
|
|
32
32
|
function injectCss(urls, root, sri = {}) {
|
|
33
33
|
const owner = root ?? document;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Component as ReactComponent, createContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var VitralContext = createContext(null);
|
|
5
|
+
var StateContext = createContext(void 0);
|
|
5
6
|
var Boundary = class extends ReactComponent {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
@@ -17,11 +18,12 @@ var Boundary = class extends ReactComponent {
|
|
|
17
18
|
return this.state.failed ? null : this.props.children;
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
function RemoteTree({ Component, props, ctx }) {
|
|
21
|
-
return /* @__PURE__ */ jsx(VitralContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(Boundary, { ctx, children: /* @__PURE__ */ jsx(Component, { ...props }) }) });
|
|
21
|
+
function RemoteTree({ Component, props, ctx, state = ctx?.initialState }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(VitralContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(StateContext.Provider, { value: state, children: /* @__PURE__ */ jsx(Boundary, { ctx, children: /* @__PURE__ */ jsx(Component, { ...props }) }) }) });
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export {
|
|
25
26
|
VitralContext,
|
|
27
|
+
StateContext,
|
|
26
28
|
RemoteTree
|
|
27
29
|
};
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
var dedupe_exports = {};
|
|
10
10
|
__export(dedupe_exports, {
|
|
11
11
|
offer: () => offer,
|
|
12
|
+
planned: () => planned,
|
|
12
13
|
satisfies: () => satisfies,
|
|
13
14
|
shared: () => shared
|
|
14
15
|
});
|
|
@@ -73,9 +74,23 @@ function offer(p, groups) {
|
|
|
73
74
|
p.configure({ offered: { ...p.settings().offered, [name]: version } });
|
|
74
75
|
}
|
|
75
76
|
}
|
|
77
|
+
function planned(name, split) {
|
|
78
|
+
const plan = globalThis[/* @__PURE__ */ Symbol.for("vitral")].settings().dedupePlan?.[name];
|
|
79
|
+
const absolute = (u) => new URL(u, location.href).href;
|
|
80
|
+
if (!plan || !split.dedupe) return split;
|
|
81
|
+
const sri = { ...split.sri };
|
|
82
|
+
const dedupe = split.dedupe.map((d) => {
|
|
83
|
+
const c = plan[d.name];
|
|
84
|
+
if (c?.for !== `${d.range}@${d.version}`) return d;
|
|
85
|
+
for (const u in c.sri) sri[absolute(u)] = c.sri[u];
|
|
86
|
+
return { ...d, version: c.version, file: absolute(c.file), chunks: c.chunks?.map(absolute) };
|
|
87
|
+
});
|
|
88
|
+
return { ...split, dedupe, sri };
|
|
89
|
+
}
|
|
76
90
|
|
|
77
91
|
export {
|
|
78
92
|
shared,
|
|
79
93
|
offer,
|
|
94
|
+
planned,
|
|
80
95
|
dedupe_exports
|
|
81
96
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/core/bundled.ts
|
|
2
2
|
var bundled = {};
|
|
3
|
-
var dedupeModule = () => bundled.dedupe ? Promise.resolve(bundled.dedupe) : import("./dedupe-
|
|
4
|
-
var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-
|
|
3
|
+
var dedupeModule = () => bundled.dedupe ? Promise.resolve(bundled.dedupe) : import("./dedupe-M63VMCWA.js");
|
|
4
|
+
var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-AMQOKKWR.js");
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
7
|
bundled,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
critical,
|
|
3
|
+
ordered
|
|
4
|
+
} from "./chunk-5O6XDJBR.js";
|
|
5
|
+
import {
|
|
6
|
+
satisfies
|
|
7
|
+
} from "./chunk-4E33RZMM.js";
|
|
8
|
+
|
|
9
|
+
// src/core/next-hints.ts
|
|
10
|
+
function hintsOf(m, url, offered, integrity, keys) {
|
|
11
|
+
const k = (keys ?? []).map((x) => " ed25519-" + x.replace(/^ed25519-/, "")).join("");
|
|
12
|
+
const base = new URL(url, "http://host.invalid/");
|
|
13
|
+
const at = (f) => {
|
|
14
|
+
const u = new URL(f, base);
|
|
15
|
+
return u.origin === "http://host.invalid" ? u.pathname + u.search : u.href;
|
|
16
|
+
};
|
|
17
|
+
const crit = critical(m);
|
|
18
|
+
const hint = (f) => {
|
|
19
|
+
const h = integrity !== false && m.files?.[f] ? [at(f), m.files[f] + k] : [at(f)];
|
|
20
|
+
if (crit.has(f)) h[1] ??= void 0, h[2] = "high";
|
|
21
|
+
return h;
|
|
22
|
+
};
|
|
23
|
+
const served = (d) => !!offered[d.name] && satisfies(offered[d.name], d.range);
|
|
24
|
+
const own = (m.dedupe ?? []).filter((d) => !served(d)).flatMap((d) => [...d.chunks ?? [], d.file]);
|
|
25
|
+
const offers = m.split ? (m.dedupe ?? []).filter((d) => d.name !== "react" && served(d)).map((d) => d.name) : [];
|
|
26
|
+
return {
|
|
27
|
+
manifest: at(url),
|
|
28
|
+
css: (m.css ?? []).map(hint),
|
|
29
|
+
js: (m.split ? ordered([...own, ...m.split.chunks ?? [], m.split.entry], m.split.order) : [m.entry]).map(hint),
|
|
30
|
+
...offers.length && { offers },
|
|
31
|
+
...k && { signed: k.trim() }
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
hintsOf
|
|
37
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
verifyIntegrity
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UCFOXMOR.js";
|
|
4
4
|
import {
|
|
5
5
|
dedupeModule
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MICF64AZ.js";
|
|
7
7
|
import {
|
|
8
8
|
addLink,
|
|
9
9
|
fetchBytes,
|
|
10
10
|
withTimeout
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-GGMM56TM.js";
|
|
12
12
|
import {
|
|
13
13
|
RemoteError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BQGVAXFM.js";
|
|
15
15
|
import {
|
|
16
16
|
__export
|
|
17
17
|
} from "./chunk-MLKGABMK.js";
|
|
@@ -20,10 +20,12 @@ import {
|
|
|
20
20
|
var sri_exports = {};
|
|
21
21
|
__export(sri_exports, {
|
|
22
22
|
importVerified: () => importVerified,
|
|
23
|
+
signature: () => signature,
|
|
23
24
|
verified: () => verified
|
|
24
25
|
});
|
|
25
26
|
var failed = /* @__PURE__ */ new Set();
|
|
26
27
|
async function importVerified(name, r, run, timeout) {
|
|
28
|
+
if (r.split?.dedupe?.length && globalThis[/* @__PURE__ */ Symbol.for("vitral")]?.settings().dedupePlan?.[name]) r = { ...r, split: (await dedupeModule()).planned(name, r.split) };
|
|
27
29
|
const { entry, integrity, priority } = r;
|
|
28
30
|
if (!failed.has(entry)) {
|
|
29
31
|
try {
|
|
@@ -38,7 +40,7 @@ async function importVerified(name, r, run, timeout) {
|
|
|
38
40
|
if (e instanceof RemoteError && e.code === "TIMEOUT") throw e;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
const bytes = await fetchBytes(entry, timeout, name, failed.has(entry)
|
|
43
|
+
const bytes = await fetchBytes(entry, timeout, name, { priority, ...failed.has(entry) && { cache: "reload" }, ...signature(integrity) });
|
|
42
44
|
await verifyIntegrity(name, bytes, integrity);
|
|
43
45
|
const url = URL.createObjectURL(new Blob([bytes], { type: "text/javascript" }));
|
|
44
46
|
try {
|
|
@@ -47,7 +49,8 @@ async function importVerified(name, r, run, timeout) {
|
|
|
47
49
|
URL.revokeObjectURL(url);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
var
|
|
52
|
+
var signature = (integrity) => /ed25519-/.test(integrity) ? { integrity } : {};
|
|
53
|
+
var STRICT = /^(sha(256|384|512)-[A-Za-z0-9+/]+={0,2}( +|$))+(ed25519-[A-Za-z0-9+/]+={0,2}( +|$))*$/;
|
|
51
54
|
var PROBE = "data:text/javascript,export{}";
|
|
52
55
|
var PROBE_SRI = "sha256-d3bjIZdvLjBurwdLwkSVOnEBPFFly+T1SR9r3VVHBGg=";
|
|
53
56
|
var maps;
|
|
@@ -170,6 +173,7 @@ function check(load, good, bad) {
|
|
|
170
173
|
|
|
171
174
|
export {
|
|
172
175
|
importVerified,
|
|
176
|
+
signature,
|
|
173
177
|
verified,
|
|
174
178
|
sri_exports
|
|
175
179
|
};
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot,
|
|
3
|
-
timings
|
|
4
|
-
|
|
3
|
+
timings,
|
|
4
|
+
when
|
|
5
|
+
} from "./chunk-2SAI6S2H.js";
|
|
5
6
|
import {
|
|
6
7
|
defineRemote,
|
|
7
8
|
memoSelect,
|
|
8
9
|
same,
|
|
9
10
|
shared
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6JH2I65O.js";
|
|
11
12
|
import {
|
|
13
|
+
policy,
|
|
12
14
|
registerSrc,
|
|
13
15
|
warmSsr
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AL6MLNVY.js";
|
|
15
17
|
|
|
16
18
|
// src/element.ts
|
|
17
19
|
var Base = typeof HTMLElement === "undefined" ? class {
|
|
18
20
|
} : HTMLElement;
|
|
19
21
|
var VitralRemoteElement = class extends Base {
|
|
20
|
-
static {
|
|
21
|
-
|
|
22
|
+
// Getter, e não campo estático: o campo vira um bloco `static {}`, e o
|
|
23
|
+
// bundler do remote mantém a classe (e o loader do host) por causa dele.
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return ["name", "src", "props", "isolate"];
|
|
22
26
|
}
|
|
23
27
|
#slot = null;
|
|
24
28
|
#props = {};
|
|
@@ -49,6 +53,9 @@ var VitralRemoteElement = class extends Base {
|
|
|
49
53
|
prefetch: this.getAttribute("prefetch"),
|
|
50
54
|
priority: this.getAttribute("priority") || void 0,
|
|
51
55
|
keepAlive: keep === null ? false : Number(keep) || true,
|
|
56
|
+
snapshot: this.hasAttribute("snapshot"),
|
|
57
|
+
// A última tela no lugar do "carregando".
|
|
58
|
+
onSnapshot: (shown) => this.#snapped = shown,
|
|
52
59
|
styles: { inherit: this.getAttribute("inherit-styles")?.split(/\s+/).filter(Boolean) },
|
|
53
60
|
onStatus: (status, error) => {
|
|
54
61
|
this.setAttribute("data-vitral-status", status);
|
|
@@ -56,21 +63,24 @@ var VitralRemoteElement = class extends Base {
|
|
|
56
63
|
else this.removeAttribute("aria-busy");
|
|
57
64
|
const has = (slot) => {
|
|
58
65
|
const els = this.querySelectorAll(`:scope > [slot="${slot}"]`);
|
|
59
|
-
for (const el of els) el.hidden = status !== (slot === "fallback" ? "loading" : "error");
|
|
66
|
+
for (const el of els) el.hidden = status !== (slot === "fallback" ? "loading" : "error") || slot === "fallback" && this.#snapped;
|
|
60
67
|
return els.length > 0;
|
|
61
68
|
};
|
|
62
69
|
queueMicrotask(() => {
|
|
63
70
|
if (this.#slot?.status !== status) return;
|
|
64
71
|
const custom = { loading: has("fallback"), error: has("error"), ready: true };
|
|
65
|
-
this.#showDefault(custom[status] ? null : status);
|
|
72
|
+
this.#showDefault(custom[status] || status === "loading" && this.#snapped ? null : status);
|
|
66
73
|
});
|
|
67
74
|
if (status === "ready") this.dispatchEvent(new CustomEvent("vitral-ready", { bubbles: true, detail: { timings: timings(name) } }));
|
|
68
75
|
if (status === "error") this.dispatchEvent(new CustomEvent("vitral-error", { bubbles: true, detail: { error } }));
|
|
69
76
|
}
|
|
70
77
|
};
|
|
71
78
|
const ssr = true ? this.querySelector(":scope>[data-vitral-ssr]") : null;
|
|
72
|
-
if (ssr)
|
|
73
|
-
|
|
79
|
+
if (ssr) {
|
|
80
|
+
const go = () => (warmSsr(ssr), import("./hydrate-FJHHLW5G.js").then((m) => this.isConnected && !this.#slot && (this.#slot = m.hydrateSlot(this, ssr, { ...options, props: this.#props }))));
|
|
81
|
+
if (policy() === "lazy") when(this, "visible", go);
|
|
82
|
+
else go();
|
|
83
|
+
} else this.#slot = hostSlot(this, options);
|
|
74
84
|
}
|
|
75
85
|
/**
|
|
76
86
|
* Nome para montar. `src` em atributo é registrado sem entrar na allowlist:
|
|
@@ -82,6 +92,7 @@ var VitralRemoteElement = class extends Base {
|
|
|
82
92
|
return src ? registerSrc(src, name ?? void 0, false) : name;
|
|
83
93
|
}
|
|
84
94
|
#default = null;
|
|
95
|
+
#snapped = false;
|
|
85
96
|
/** Carregando e erro padrão, só quando não há slot próprio. */
|
|
86
97
|
#showDefault(status) {
|
|
87
98
|
this.#default?.remove();
|