vitral 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/angular.d.ts +2 -2
  2. package/dist/angular.js +13 -10
  3. package/dist/auto.js +11 -8
  4. package/dist/{capture-A6JQNNQY.js → capture-2I5IQ2C2.js} +2 -1
  5. package/dist/{channel-2DUQQPPA.js → channel-ABGK26Q5.js} +5 -3
  6. package/dist/{chunk-WAU6OKK3.js → chunk-2SAI6S2H.js} +11 -3
  7. package/dist/chunk-2Z4OH3BP.js +85 -0
  8. package/dist/chunk-5O6XDJBR.js +15 -0
  9. package/dist/chunk-623K4UNS.js +70 -0
  10. package/dist/{chunk-VTGHPX4J.js → chunk-6JH2I65O.js} +15 -13
  11. package/dist/{chunk-FOEXP52G.js → chunk-7P5O3REI.js} +46 -15
  12. package/dist/{chunk-EVVYV5ED.js → chunk-AL6MLNVY.js} +49 -21
  13. package/dist/{chunk-CFJC4GRB.js → chunk-AQUQD3NA.js} +17 -8
  14. package/dist/chunk-B3PFMWZT.js +21 -0
  15. package/dist/{chunk-463H6B56.js → chunk-BQGVAXFM.js} +3 -4
  16. package/dist/{chunk-TW7KYJQ6.js → chunk-GGMM56TM.js} +1 -1
  17. package/dist/{chunk-SC2KF7GJ.js → chunk-IKCEA3YN.js} +3 -3
  18. package/dist/chunk-JWDDXX5O.js +6 -0
  19. package/dist/{chunk-B2MPYF4M.js → chunk-KCF46XOX.js} +4 -2
  20. package/dist/{chunk-R3HUMHNL.js → chunk-LDOSAAEF.js} +15 -0
  21. package/dist/{chunk-MGG5BW3U.js → chunk-MICF64AZ.js} +2 -2
  22. package/dist/{chunk-QINOFHG6.js → chunk-NQ6ZTGQZ.js} +2 -2
  23. package/dist/chunk-QQWE5J6U.js +37 -0
  24. package/dist/{chunk-VK6W7KHM.js → chunk-SPSAXBPR.js} +10 -6
  25. package/dist/{chunk-UYOPJ4XQ.js → chunk-UCFOXMOR.js} +1 -1
  26. package/dist/cli.js +119 -8
  27. package/dist/{contract-IXM52LVW.js → contract-3JY7SOGQ.js} +1 -1
  28. package/dist/{dedupe-SRAPOK3V.js → dedupe-M63VMCWA.js} +3 -1
  29. package/dist/edge.d.ts +4 -2
  30. package/dist/edge.js +69 -46
  31. package/dist/element.d.ts +2 -2
  32. package/dist/element.js +11 -8
  33. package/dist/embed.js +2 -2
  34. package/dist/{events-CWdYSrkz.d.ts → events-II6hXM3Q.d.ts} +1 -1
  35. package/dist/expose-2S3TCXSP.js +18 -0
  36. package/dist/federation.d.ts +1 -1
  37. package/dist/{hydrate-IVQNHOP3.js → hydrate-FJHHLW5G.js} +22 -12
  38. package/dist/iframe.js +15 -12
  39. package/dist/index.d.ts +6 -6
  40. package/dist/index.js +25 -11
  41. package/dist/{loader-CLRMRRFv.d.ts → loader-Bmul2-5T.d.ts} +1 -1
  42. package/dist/next-config.d.ts +30 -10
  43. package/dist/next-config.js +29 -20
  44. package/dist/next-host.d.ts +11 -5
  45. package/dist/next-host.js +54 -29
  46. package/dist/next-server.d.ts +56 -0
  47. package/dist/next-server.js +90 -0
  48. package/dist/preact.d.ts +4 -4
  49. package/dist/preact.js +10 -7
  50. package/dist/prefetch.d.ts +40 -3
  51. package/dist/prefetch.js +100 -30
  52. package/dist/react-server.d.ts +16 -5
  53. package/dist/react-server.js +8 -3
  54. package/dist/react.d.ts +20 -6
  55. package/dist/react.js +14 -9
  56. package/dist/{reframe-ZOQPW552.js → reframe-HIYA2TIU.js} +10 -9
  57. package/dist/route-4KQITYD4.js +138 -0
  58. package/dist/routes.d.ts +2 -2
  59. package/dist/routes.js +12 -9
  60. package/dist/{shadow-PZGQKUA4.js → shadow-7ZV4JEO6.js} +4 -3
  61. package/dist/sign.d.ts +49 -0
  62. package/dist/sign.js +15 -0
  63. package/dist/single-spa.d.ts +1 -1
  64. package/dist/{slot-DRYmGvvV.d.ts → slot--WLgdcW_.d.ts} +1 -1
  65. package/dist/snapshot.d.ts +6 -0
  66. package/dist/snapshot.js +125 -0
  67. package/dist/solid.d.ts +3 -3
  68. package/dist/solid.js +10 -7
  69. package/dist/sri-AMQOKKWR.js +17 -0
  70. package/dist/ssr-markup-BCPpGmss.d.ts +13 -0
  71. package/dist/state-B1FJi8I9.d.ts +14 -0
  72. package/dist/svelte.d.ts +4 -4
  73. package/dist/svelte.js +10 -7
  74. package/dist/sw.d.ts +48 -1
  75. package/dist/sw.js +79 -2
  76. package/dist/testing.d.ts +2 -2
  77. package/dist/testing.js +10 -7
  78. package/dist/{types-g8WEVD_b.d.ts → types-DJautV-K.d.ts} +86 -1
  79. package/dist/vitals.js +2 -1
  80. package/dist/vite.d.ts +4 -2
  81. package/dist/vite.js +62 -12
  82. package/dist/vue.d.ts +3 -3
  83. package/dist/vue.js +12 -9
  84. package/package.json +37 -19
  85. package/dist/expose-BA4HSXDP.js +0 -17
  86. package/dist/sri-LQBLQMG5.js +0 -14
  87. package/dist/state-BDdCwc21.d.ts +0 -4
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-g8WEVD_b.js';
3
- export { e as events } from './events-CWdYSrkz.js';
2
+ import { R as RemoteContext, P as Props, a as RemoteModule, S as Shared, V as VitralConfig } from './types-DJautV-K.js';
3
+ export { e as events } from './events-II6hXM3Q.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,24 +1,27 @@
1
1
  import {
2
2
  defineVitralElement
3
- } from "./chunk-CFJC4GRB.js";
4
- import "./chunk-WAU6OKK3.js";
3
+ } from "./chunk-AQUQD3NA.js";
4
+ import "./chunk-2SAI6S2H.js";
5
5
  import {
6
6
  defineRemote,
7
7
  memoSelect,
8
8
  same,
9
9
  shared
10
- } from "./chunk-VTGHPX4J.js";
10
+ } from "./chunk-6JH2I65O.js";
11
+ import {
12
+ configure
13
+ } from "./chunk-AL6MLNVY.js";
14
+ import "./chunk-MICF64AZ.js";
15
+ import "./chunk-IKCEA3YN.js";
16
+ import "./chunk-GGMM56TM.js";
17
+ import "./chunk-BQGVAXFM.js";
18
+ import "./chunk-JWDDXX5O.js";
19
+ import "./chunk-2Z4OH3BP.js";
20
+ import "./chunk-4E33RZMM.js";
11
21
  import {
12
22
  events,
13
23
  navigate
14
24
  } from "./chunk-EQZOJU3B.js";
15
- import {
16
- configure
17
- } from "./chunk-EVVYV5ED.js";
18
- import "./chunk-MGG5BW3U.js";
19
- import "./chunk-SC2KF7GJ.js";
20
- import "./chunk-TW7KYJQ6.js";
21
- import "./chunk-463H6B56.js";
22
25
  import "./chunk-GNPFWISJ.js";
23
26
  import "./chunk-MLKGABMK.js";
24
27
 
package/dist/auto.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import {
2
2
  defineVitralElement
3
- } from "./chunk-CFJC4GRB.js";
4
- import "./chunk-WAU6OKK3.js";
5
- import "./chunk-VTGHPX4J.js";
3
+ } from "./chunk-AQUQD3NA.js";
4
+ import "./chunk-2SAI6S2H.js";
5
+ import "./chunk-6JH2I65O.js";
6
+ import "./chunk-AL6MLNVY.js";
7
+ import "./chunk-MICF64AZ.js";
8
+ import "./chunk-IKCEA3YN.js";
9
+ import "./chunk-GGMM56TM.js";
10
+ import "./chunk-BQGVAXFM.js";
11
+ import "./chunk-JWDDXX5O.js";
12
+ import "./chunk-2Z4OH3BP.js";
13
+ import "./chunk-4E33RZMM.js";
6
14
  import "./chunk-EQZOJU3B.js";
7
- import "./chunk-EVVYV5ED.js";
8
- import "./chunk-MGG5BW3U.js";
9
- import "./chunk-SC2KF7GJ.js";
10
- import "./chunk-TW7KYJQ6.js";
11
- import "./chunk-463H6B56.js";
12
15
  import "./chunk-GNPFWISJ.js";
13
16
  import "./chunk-MLKGABMK.js";
14
17
 
@@ -4,7 +4,8 @@ import {
4
4
  mounted,
5
5
  report,
6
6
  reported
7
- } from "./chunk-463H6B56.js";
7
+ } from "./chunk-BQGVAXFM.js";
8
+ import "./chunk-JWDDXX5O.js";
8
9
  import {
9
10
  protocol
10
11
  } from "./chunk-GNPFWISJ.js";
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  absolute
3
- } from "./chunk-TW7KYJQ6.js";
3
+ } from "./chunk-GGMM56TM.js";
4
+ import {
5
+ RemoteError
6
+ } from "./chunk-BQGVAXFM.js";
4
7
  import {
5
- RemoteError,
6
8
  ctxHooks
7
- } from "./chunk-463H6B56.js";
9
+ } from "./chunk-JWDDXX5O.js";
8
10
  import {
9
11
  protocol
10
12
  } from "./chunk-GNPFWISJ.js";
@@ -1,10 +1,14 @@
1
1
  import {
2
2
  createSlot
3
- } from "./chunk-VTGHPX4J.js";
3
+ } from "./chunk-6JH2I65O.js";
4
4
  import {
5
+ policy,
5
6
  preload,
6
7
  registerSrc
7
- } from "./chunk-EVVYV5ED.js";
8
+ } from "./chunk-AL6MLNVY.js";
9
+ import {
10
+ ctxHooks
11
+ } from "./chunk-JWDDXX5O.js";
8
12
 
9
13
  // src/core/host-slot.ts
10
14
  var noop = () => {
@@ -92,11 +96,13 @@ function hostSlot(target, options) {
92
96
  let name = key(options);
93
97
  let status = "loading";
94
98
  let item = null;
99
+ const snap = options.snapshot ? ctxHooks.snapshot?.(target, name, () => props, () => item?.box, options.onSnapshot) : void 0;
95
100
  const onStatus = (s, e) => {
96
101
  status = s;
102
+ snap?.(s);
97
103
  options.onStatus?.(s, e);
98
104
  };
99
- const cancelPrefetch = options.prefetch ? when(target, options.prefetch, () => preload(name)) : noop;
105
+ const cancelPrefetch = options.prefetch && (options.prefetch !== "idle" || policy() !== "lazy") ? when(target, options.prefetch, () => preload(name)) : noop;
100
106
  const cancel = when(target, options.loading, () => {
101
107
  cancelPrefetch();
102
108
  const found = keepAlive ? kept.get(name) : void 0;
@@ -132,6 +138,7 @@ function hostSlot(target, options) {
132
138
  destroy() {
133
139
  cancel();
134
140
  cancelPrefetch();
141
+ snap?.();
135
142
  if (!item) return;
136
143
  if (keepAlive && status === "ready") park(name, item, keepAlive === true ? 5 : keepAlive);
137
144
  else {
@@ -148,5 +155,6 @@ function hostSlot(target, options) {
148
155
 
149
156
  export {
150
157
  timings,
158
+ when,
151
159
  hostSlot
152
160
  };
@@ -0,0 +1,85 @@
1
+ import {
2
+ satisfies
3
+ } from "./chunk-4E33RZMM.js";
4
+
5
+ // src/core/dedupe-plan.ts
6
+ var parts = (v) => v.split(/[.-]/).map((n) => Number(n) || 0);
7
+ var newer = (a, b) => {
8
+ const [x, y] = [parts(a), parts(b)];
9
+ for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return y[i] - x[i];
10
+ return 0;
11
+ };
12
+ function planDedupe(remotes, host = {}) {
13
+ const groups = /* @__PURE__ */ new Map();
14
+ for (const [remote, { url, manifest }] of Object.entries(remotes)) {
15
+ if (!manifest.split) continue;
16
+ const base = new URL(url, "http://host.invalid/");
17
+ const at = (f) => {
18
+ const u = new URL(f, base);
19
+ return u.origin === "http://host.invalid" ? u.pathname + u.search : u.href;
20
+ };
21
+ for (const d of manifest.dedupe ?? []) {
22
+ const files = [d.file, ...d.chunks ?? []];
23
+ const sri = Object.fromEntries(files.filter((f) => manifest.files?.[f]).map((f) => [at(f), manifest.files[f]]));
24
+ const copy = { version: d.version, file: at(d.file), ...d.chunks?.length && { chunks: d.chunks.map(at) }, sri };
25
+ (groups.get(d.name) ?? groups.set(d.name, []).get(d.name)).push({ remote, range: d.range, copy });
26
+ }
27
+ }
28
+ const plan = {};
29
+ const notes = [];
30
+ for (const [group, needs] of groups) {
31
+ const copies = /* @__PURE__ */ new Map();
32
+ if (host[group]) copies.set(host[group], null);
33
+ for (const n of [...needs].sort((a, b) => newer(a.copy.version, b.copy.version))) if (!copies.has(n.copy.version)) copies.set(n.copy.version, n.copy);
34
+ const versions = [...copies.keys()];
35
+ const chosen = cover(versions, needs.map((n) => n.range), host[group]);
36
+ if (chosen.length > 1) {
37
+ const by = (v) => needs.filter((n) => pick(chosen, n.range, host[group]) === v).map((n) => `${n.remote} (${n.range})`);
38
+ notes.push(`${group}: as faixas n\xE3o t\xEAm uma vers\xE3o em comum; a p\xE1gina com todos os remotes baixa ${chosen.length} c\xF3pias: ${chosen.map((v) => `${v}${copies.get(v) === null ? " do host" : ""} para ${by(v).join(", ")}`).join("; ")}.`);
39
+ }
40
+ for (const n of needs) {
41
+ const v = pick(chosen, n.range, host[group]);
42
+ const copy = v ? copies.get(v) : void 0;
43
+ if (!copy || v === n.copy.version) continue;
44
+ (plan[n.remote] ??= {})[group] = { ...copy, for: `${n.range}@${n.copy.version}` };
45
+ }
46
+ }
47
+ return { plan, notes };
48
+ }
49
+ function pick(chosen, range, host) {
50
+ if (host && chosen.includes(host) && satisfies(host, range)) return host;
51
+ return chosen.filter((v) => satisfies(v, range)).sort(newer)[0];
52
+ }
53
+ function cover(versions, ranges, host) {
54
+ const serves = versions.map((v) => ranges.map((r) => satisfies(v, r)));
55
+ const ok = (set) => ranges.every((_, j) => set.some((i) => serves[i][j]));
56
+ const score = (set) => (set.some((i) => versions[i] === host) ? 1e6 : 0) - set.reduce((a, i) => a + i, 0);
57
+ if (versions.length <= 12) {
58
+ for (let size = 1; size <= versions.length; size++) {
59
+ let best;
60
+ for (let mask = 0; mask < 1 << versions.length; mask++) {
61
+ const set = versions.map((_, i) => i).filter((i) => mask & 1 << i);
62
+ if (set.length === size && ok(set) && (!best || score(set) > score(best))) best = set;
63
+ }
64
+ if (best) return best.map((i) => versions[i]);
65
+ }
66
+ }
67
+ const left = new Set(ranges.map((_, j) => j));
68
+ const out = [];
69
+ while (left.size) {
70
+ let best = -1;
71
+ let count = 0;
72
+ for (let i = 0; i < versions.length; i++) {
73
+ const c = [...left].filter((j) => serves[i][j]).length;
74
+ if (c > count) best = i, count = c;
75
+ }
76
+ if (best < 0) break;
77
+ out.push(versions[best]);
78
+ for (const j of [...left]) if (serves[best][j]) left.delete(j);
79
+ }
80
+ return out;
81
+ }
82
+
83
+ export {
84
+ planDedupe
85
+ };
@@ -0,0 +1,15 @@
1
+ // src/core/order.ts
2
+ function ordered(files, order) {
3
+ if (!order) return files;
4
+ const at = new Map(order.map((f, i) => [f, i]));
5
+ return files.map((f, i) => [f, at.get(f) ?? order.length + i]).sort((a, b) => a[1] - b[1]).map(([f]) => f);
6
+ }
7
+ function critical(m) {
8
+ const { order = [], critical: critical2 = [] } = m.split ?? {};
9
+ return new Set(critical2.map((i) => order[i]).filter(Boolean));
10
+ }
11
+
12
+ export {
13
+ ordered,
14
+ critical
15
+ };
@@ -0,0 +1,70 @@
1
+ // src/sign.ts
2
+ import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify } from "crypto";
3
+ import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "fs";
4
+ import { join, posix, relative, sep } from "path";
5
+ function publicKeyOf(key) {
6
+ const k = typeof key === "string" ? createPublicKey(key) : key.type === "private" ? createPublicKey(key) : key;
7
+ return Buffer.from(k.export({ format: "jwk" }).x, "base64url").toString("base64");
8
+ }
9
+ function keygen() {
10
+ const { privateKey, publicKey } = generateKeyPairSync("ed25519");
11
+ return { privateKey: privateKey.export({ format: "pem", type: "pkcs8" }), publicKey: publicKeyOf(publicKey) };
12
+ }
13
+ var digestOf = (body) => `sha-256=:${createHash("sha256").update(body).digest("base64")}:`;
14
+ var paramsOf = (keyid) => `("unencoded-digest";sf);keyid="${keyid}";tag="sri"`;
15
+ var baseOf = (digest, params) => Buffer.from(`"unencoded-digest";sf: ${digest}
16
+ "@signature-params": ${params}`);
17
+ function signBody(body, privateKey) {
18
+ const key = typeof privateKey === "string" ? createPrivateKey(privateKey) : privateKey;
19
+ const digest = digestOf(body);
20
+ const params = paramsOf(publicKeyOf(key));
21
+ return { "Unencoded-Digest": digest, "Signature-Input": `signature=${params}`, Signature: `signature=:${sign(null, baseOf(digest, params), key).toString("base64")}:` };
22
+ }
23
+ function verifyBody(body, headers, keys) {
24
+ const get = (h) => (headers instanceof Headers ? headers.get(h) : headers[h] ?? headers[h.toLowerCase()]) ?? "";
25
+ const digest = get("Unencoded-Digest");
26
+ if (digest !== digestOf(body)) return false;
27
+ const input = /(?:^|,)\s*([\w-]+)=(\("unencoded-digest";sf\);keyid="([^"]+)";tag="sri")/.exec(get("Signature-Input"));
28
+ if (!input) return false;
29
+ const [, label, params, keyid] = input;
30
+ const sig = new RegExp(`(?:^|,)\\s*${label}=:([^:]+):`).exec(get("Signature"))?.[1];
31
+ const want = keys.map((k) => k.replace(/^ed25519-/, ""));
32
+ if (!sig || !want.includes(keyid)) return false;
33
+ const pub = createPublicKey({ key: { kty: "OKP", crv: "Ed25519", x: Buffer.from(keyid, "base64").toString("base64url") }, format: "jwk" });
34
+ return verify(null, baseOf(digest, params), pub, Buffer.from(sig, "base64"));
35
+ }
36
+ var BEGIN = "# vitral sign";
37
+ var END = "# /vitral sign";
38
+ var SIGNED = /(^|\/)vitral\.json$|\.(m?js|css)$/;
39
+ function signDir(dir, privateKey, o = {}) {
40
+ const key = createPrivateKey(privateKey);
41
+ const base = ("/" + (o.base ?? "/").replace(/^\/+|\/+$/g, "") + "/").replace(/^\/\/$/, "/");
42
+ const out = {};
43
+ const walk = (d) => {
44
+ for (const f of readdirSync(d).sort()) {
45
+ const p = join(d, f);
46
+ if (statSync(p).isDirectory()) walk(p);
47
+ else {
48
+ const rel = relative(dir, p).split(sep).join(posix.sep);
49
+ if (SIGNED.test(rel)) out[base + rel] = signBody(readFileSync(p), key);
50
+ }
51
+ }
52
+ };
53
+ walk(dir);
54
+ writeFileSync(join(dir, "vitral-signatures.json"), JSON.stringify(out, null, 2) + "\n");
55
+ if (o.headersFile !== false) {
56
+ const file = join(dir, "_headers");
57
+ const block = [BEGIN, ...Object.entries(out).flatMap(([path, h]) => [path, ...Object.entries(h).map(([k, v]) => ` ${k}: ${v}`)]), END].join("\n");
58
+ const old = existsSync(file) ? readFileSync(file, "utf8").replace(new RegExp(`\\n?${BEGIN}[\\s\\S]*?${END}\\n?`), "\n").trim() : "";
59
+ writeFileSync(file, (old ? old + "\n\n" : "") + block + "\n");
60
+ }
61
+ return out;
62
+ }
63
+
64
+ export {
65
+ publicKeyOf,
66
+ keygen,
67
+ signBody,
68
+ verifyBody,
69
+ signDir
70
+ };
@@ -1,28 +1,30 @@
1
- import {
2
- events,
3
- navigate,
4
- scopedEvents
5
- } from "./chunk-EQZOJU3B.js";
6
1
  import {
7
2
  load,
8
3
  loadFile,
9
4
  registerSrc,
10
5
  resolveEntry
11
- } from "./chunk-EVVYV5ED.js";
6
+ } from "./chunk-AL6MLNVY.js";
12
7
  import {
13
8
  injectStyles
14
- } from "./chunk-SC2KF7GJ.js";
9
+ } from "./chunk-IKCEA3YN.js";
15
10
  import {
16
11
  metric
17
- } from "./chunk-TW7KYJQ6.js";
12
+ } from "./chunk-GGMM56TM.js";
18
13
  import {
19
14
  RemoteError,
20
- ctxHooks,
21
15
  fail,
22
16
  isRemoteError,
23
17
  mounted,
24
18
  report
25
- } from "./chunk-463H6B56.js";
19
+ } from "./chunk-BQGVAXFM.js";
20
+ import {
21
+ ctxHooks
22
+ } from "./chunk-JWDDXX5O.js";
23
+ import {
24
+ events,
25
+ navigate,
26
+ scopedEvents
27
+ } from "./chunk-EQZOJU3B.js";
26
28
  import {
27
29
  protocol
28
30
  } from "./chunk-GNPFWISJ.js";
@@ -85,7 +87,7 @@ var noop = () => {
85
87
  async function checkUpdates() {
86
88
  const p = protocol();
87
89
  const found = [];
88
- const { splitName } = await import("./expose-BA4HSXDP.js");
90
+ const { splitName } = await import("./expose-2S3TCXSP.js");
89
91
  const remotes = /* @__PURE__ */ new Map();
90
92
  for (const name of live.keys()) {
91
93
  const root = splitName(name)[0];
@@ -130,8 +132,8 @@ async function mountOnce(target, name, props, options) {
130
132
  const p = protocol();
131
133
  await p.pending();
132
134
  const isolate = options.isolate ?? registered(name)?.isolate ?? p.settings().isolate;
133
- if (isolate === "iframe") return (frames ?? (await import("./reframe-ZOQPW552.js")).noFrames)(target, name, props, options).catch(fail);
134
- const { module: mod, ...resolved } = await (isolate == "reframe" ? (await import("./reframe-ZOQPW552.js")).load : load)(name, isolate, options.priority);
135
+ if (isolate === "iframe") return (frames ?? (await import("./reframe-HIYA2TIU.js")).noFrames)(target, name, props, options).catch(fail);
136
+ const { module: mod, ...resolved } = await (isolate == "reframe" ? (await import("./reframe-HIYA2TIU.js")).load : load)(name, isolate, options.priority);
135
137
  const untrack = track(name, resolved);
136
138
  ctxHooks.watch?.(name);
137
139
  const label = resolved.name ?? name;
@@ -1,25 +1,28 @@
1
1
  import {
2
2
  RemoteTree,
3
+ StateContext,
3
4
  VitralContext
4
- } from "./chunk-B2MPYF4M.js";
5
+ } from "./chunk-KCF46XOX.js";
5
6
  import {
6
- hostSlot
7
- } from "./chunk-WAU6OKK3.js";
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-VTGHPX4J.js";
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-EVVYV5ED.js";
19
+ } from "./chunk-AL6MLNVY.js";
20
20
  import {
21
21
  dedupeModule
22
- } from "./chunk-MGG5BW3U.js";
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";
@@ -68,6 +71,9 @@ function reactRemote(Component) {
68
71
  function useVitral() {
69
72
  return useContext(VitralContext);
70
73
  }
74
+ function useInitialState() {
75
+ return useContext(StateContext);
76
+ }
71
77
  function usePortalContainer() {
72
78
  return useVitral()?.portalContainer;
73
79
  }
@@ -124,16 +130,22 @@ function Remote({
124
130
  loading,
125
131
  prefetch,
126
132
  priority,
127
- keepAlive
133
+ keepAlive,
134
+ ssr,
135
+ snapshot
128
136
  }) {
129
137
  const target = useRef(null);
130
138
  const slot = useRef(null);
131
139
  const [state, setState] = useState({ status: "loading", error: null });
132
140
  const onErrorRef = useRef(onError);
133
141
  onErrorRef.current = onError;
142
+ const [html] = useState(() => ssr || null);
143
+ const [snapped, setSnapped] = useState(false);
144
+ const latest = useRef(props);
145
+ latest.current = props;
134
146
  useEffect(() => {
135
147
  offerReact();
136
- const s = hostSlot(target.current, {
148
+ const options = {
137
149
  name,
138
150
  src,
139
151
  props: props ?? {},
@@ -142,6 +154,8 @@ function Remote({
142
154
  prefetch,
143
155
  priority,
144
156
  keepAlive,
157
+ snapshot,
158
+ onSnapshot: setSnapped,
145
159
  onStatus(status2, e) {
146
160
  setState({ status: status2, error: e });
147
161
  if (e) {
@@ -149,8 +163,24 @@ function Remote({
149
163
  else console.error(e);
150
164
  }
151
165
  }
152
- });
153
- slot.current = s;
166
+ };
167
+ const holder = html && target.current.querySelector(":scope>[data-vitral-ssr]");
168
+ let dead = false;
169
+ let s = null;
170
+ if (holder) {
171
+ const go = () => import("./hydrate-FJHHLW5G.js").then((m) => {
172
+ if (!dead) slot.current = s = m.hydrateSlot(target.current, holder, { ...options, props: latest.current ?? {} });
173
+ });
174
+ const stop = policy() === "lazy" ? when(target.current, "visible", go) : (go(), () => {
175
+ });
176
+ const end = () => (stop(), dead = true);
177
+ return () => {
178
+ end();
179
+ slot.current = null;
180
+ queueMicrotask(() => s?.destroy());
181
+ };
182
+ }
183
+ slot.current = s = hostSlot(target.current, options);
154
184
  return () => {
155
185
  slot.current = null;
156
186
  queueMicrotask(() => s.destroy());
@@ -161,15 +191,16 @@ function Remote({
161
191
  const retry = () => slot.current?.retry();
162
192
  const { status, error: err } = state;
163
193
  return /* @__PURE__ */ jsxs("div", { className, "data-vitral": name ?? src, "data-vitral-status": status, children: [
164
- status === "loading" && fallback,
194
+ status === "loading" && !html && !snapped && fallback,
165
195
  status === "error" && err && (typeof error === "function" ? error(err, retry) : error ?? null),
166
- /* @__PURE__ */ jsx("div", { ref: target })
196
+ html ? /* @__PURE__ */ jsx("div", { ref: target, dangerouslySetInnerHTML: { __html: html }, suppressHydrationWarning: true }) : /* @__PURE__ */ jsx("div", { ref: target })
167
197
  ] });
168
198
  }
169
199
 
170
200
  export {
171
201
  reactRemote,
172
202
  useVitral,
203
+ useInitialState,
173
204
  usePortalContainer,
174
205
  useEvent,
175
206
  useEventValue,