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.
- 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-FOEXP52G.js → chunk-7P5O3REI.js} +46 -15
- package/dist/{chunk-EVVYV5ED.js → chunk-AL6MLNVY.js} +49 -21
- package/dist/{chunk-CFJC4GRB.js → chunk-AQUQD3NA.js} +17 -8
- 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-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-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 +2 -2
- 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 +12 -9
- package/package.json +37 -19
- package/dist/expose-BA4HSXDP.js +0 -17
- package/dist/sri-LQBLQMG5.js +0 -14
- package/dist/state-BDdCwc21.d.ts +0 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocolo global entre cópias da lib.
|
|
3
|
+
*
|
|
4
|
+
* Host e remotes podem trazer cópias (e versões) diferentes do vitral. Todas
|
|
5
|
+
* se encontram em `globalThis[Symbol.for('vitral')]`, um objeto pequeno e
|
|
6
|
+
* estável: só métodos e o número do protocolo, nunca estruturas internas.
|
|
7
|
+
* A primeira cópia a carregar instala o objeto; as outras usam os métodos
|
|
8
|
+
* que conhecem. Mudanças futuras só acrescentam métodos e sobem `protocol`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Só para testes: apaga o protocolo global. */
|
|
12
|
+
declare function resetProtocol(): void;
|
|
13
|
+
|
|
14
|
+
export { resetProtocol as r };
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Component } from 'svelte';
|
|
2
|
-
import { P as Props, I as Isolation, a as RemoteModule } from './types-
|
|
3
|
-
export { R as RemoteContext } from './types-
|
|
2
|
+
import { P as Props, I as Isolation, a as RemoteModule } from './types-DJautV-K.js';
|
|
3
|
+
export { R as RemoteContext } from './types-DJautV-K.js';
|
|
4
4
|
import { R as RemoteError } from './errors-kjBv6IH_.js';
|
|
5
|
-
import { S as SlotStatus } from './slot
|
|
6
|
-
export { e as events } from './events-
|
|
5
|
+
import { S as SlotStatus } from './slot--WLgdcW_.js';
|
|
6
|
+
export { e as events } from './events-II6hXM3Q.js';
|
|
7
7
|
export { n as navigate } from './navigate-BRG1WJUM.js';
|
|
8
8
|
import { L as Loading, P as Prefetch } from './host-slot-Cz6EiGsB.js';
|
|
9
9
|
|
package/dist/svelte.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2SAI6S2H.js";
|
|
4
4
|
import {
|
|
5
5
|
defineRemote
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6JH2I65O.js";
|
|
7
|
+
import "./chunk-AL6MLNVY.js";
|
|
8
|
+
import "./chunk-MICF64AZ.js";
|
|
9
|
+
import "./chunk-IKCEA3YN.js";
|
|
10
|
+
import "./chunk-GGMM56TM.js";
|
|
11
|
+
import "./chunk-BQGVAXFM.js";
|
|
12
|
+
import "./chunk-JWDDXX5O.js";
|
|
13
|
+
import "./chunk-2Z4OH3BP.js";
|
|
14
|
+
import "./chunk-4E33RZMM.js";
|
|
7
15
|
import {
|
|
8
16
|
events,
|
|
9
17
|
navigate
|
|
10
18
|
} from "./chunk-EQZOJU3B.js";
|
|
11
|
-
import "./chunk-EVVYV5ED.js";
|
|
12
|
-
import "./chunk-MGG5BW3U.js";
|
|
13
|
-
import "./chunk-SC2KF7GJ.js";
|
|
14
|
-
import "./chunk-TW7KYJQ6.js";
|
|
15
|
-
import "./chunk-463H6B56.js";
|
|
16
19
|
import "./chunk-GNPFWISJ.js";
|
|
17
20
|
import "./chunk-MLKGABMK.js";
|
|
18
21
|
|
package/dist/sw.d.ts
CHANGED
|
@@ -1,8 +1,55 @@
|
|
|
1
|
+
import { d as RemoteManifest } from './types-DJautV-K.js';
|
|
2
|
+
import './errors-kjBv6IH_.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Para o service worker do host: os arquivos que um remote publica, para
|
|
6
|
+
* guardar no cache e o remote abrir offline.
|
|
7
|
+
*
|
|
8
|
+
* // sw.js do host
|
|
9
|
+
* import { remoteFiles } from 'vitral/sw'
|
|
10
|
+
* self.addEventListener('install', (e) => e.waitUntil(
|
|
11
|
+
* remoteFiles('/delivery-remote/vitral.json').then((urls) => caches.open('remotes').then((c) => c.addAll(urls))),
|
|
12
|
+
* ))
|
|
13
|
+
*/
|
|
14
|
+
|
|
1
15
|
/**
|
|
2
16
|
* URLs absolutas do manifesto e de tudo que ele lista: arquivo único, CSS,
|
|
3
17
|
* build dividido (inclusive os `import()` das rotas), cópias de `dedupe` e os
|
|
4
18
|
* módulos de teste do SRI.
|
|
5
19
|
*/
|
|
6
20
|
declare function remoteFiles(manifestUrl: string, init?: RequestInit): Promise<string[]>;
|
|
21
|
+
/** O mesmo que `remoteFiles`, para um manifesto já lido. */
|
|
22
|
+
declare function filesOf(m: RemoteManifest, manifestUrl: string): string[];
|
|
23
|
+
interface RemoteWorkerOptions {
|
|
24
|
+
/** URLs dos `vitral.json` dos remotes. */
|
|
25
|
+
manifests: string[];
|
|
26
|
+
/** Nome do cache. Padrão `vitral-remotes`. */
|
|
27
|
+
cache?: string;
|
|
28
|
+
}
|
|
29
|
+
/** O que o service worker precisa do `self`. */
|
|
30
|
+
interface Scope {
|
|
31
|
+
addEventListener(type: string, fn: (e: any) => void): void;
|
|
32
|
+
location?: {
|
|
33
|
+
href: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Service worker do host para os remotes. No `install`, baixa o manifesto e
|
|
38
|
+
* todos os arquivos de cada remote para o CacheStorage: o Chrome gera o cache
|
|
39
|
+
* de código completo para scripts gravados durante o `install`, e a volta à
|
|
40
|
+
* página compila menos. Onde há Static Routing API (Chrome 123+), os arquivos
|
|
41
|
+
* com hash vão direto ao cache, sem acordar o service worker; nos outros
|
|
42
|
+
* navegadores, o `fetch` responde do cache.
|
|
43
|
+
*
|
|
44
|
+
* O manifesto vai sempre à rede primeiro (o cache só vale offline). Quando
|
|
45
|
+
* ele muda (deploy do remote), os arquivos novos entram no cache por trás, e
|
|
46
|
+
* a próxima visita já os encontra. Arquivos de versões que nenhum manifesto
|
|
47
|
+
* lista saem do cache no `activate` e a cada manifesto novo.
|
|
48
|
+
*
|
|
49
|
+
* // sw.js do host
|
|
50
|
+
* import { remoteWorker } from 'vitral/sw'
|
|
51
|
+
* remoteWorker(self, { manifests: ['/delivery-remote/vitral.json'] })
|
|
52
|
+
*/
|
|
53
|
+
declare function remoteWorker(self: Scope, o: RemoteWorkerOptions): void;
|
|
7
54
|
|
|
8
|
-
export { remoteFiles };
|
|
55
|
+
export { type RemoteWorkerOptions, filesOf, remoteFiles, remoteWorker };
|
package/dist/sw.js
CHANGED
|
@@ -5,7 +5,10 @@ async function remoteFiles(manifestUrl, init) {
|
|
|
5
5
|
const base = new URL(manifestUrl, globalThis.location?.href);
|
|
6
6
|
const res = await fetch(base, { cache: "no-cache", ...init });
|
|
7
7
|
if (!res.ok) throw new Error(`vitral: ${base.href} respondeu ${res.status}`);
|
|
8
|
-
|
|
8
|
+
return filesOf(await res.json(), base.href);
|
|
9
|
+
}
|
|
10
|
+
function filesOf(m, manifestUrl) {
|
|
11
|
+
const base = new URL(manifestUrl, globalThis.location?.href);
|
|
9
12
|
const files = [
|
|
10
13
|
m.entry,
|
|
11
14
|
...m.css ?? [],
|
|
@@ -18,6 +21,80 @@ async function remoteFiles(manifestUrl, init) {
|
|
|
18
21
|
];
|
|
19
22
|
return [base.href, ...new Set(files.filter(Boolean).map((f) => new URL(f, base).href))];
|
|
20
23
|
}
|
|
24
|
+
var hashed = (u, manifests) => !manifests.has(u) && /\.(js|mjs|css|wasm)$/.test(new URL(u).pathname);
|
|
25
|
+
function remoteWorker(self, o) {
|
|
26
|
+
const name = o.cache ?? "vitral-remotes";
|
|
27
|
+
const base = self.location?.href ?? globalThis.location?.href;
|
|
28
|
+
const manifests = new Set(o.manifests.map((m) => new URL(m, base).href));
|
|
29
|
+
const scopes = [...manifests].map((m) => new URL("./", m).href);
|
|
30
|
+
const mine = (u) => scopes.some((s) => u.startsWith(s));
|
|
31
|
+
const fill = async (known) => {
|
|
32
|
+
const c = await caches.open(name);
|
|
33
|
+
const keep = /* @__PURE__ */ new Set();
|
|
34
|
+
const read = async (m) => {
|
|
35
|
+
const res = await fetch(m, { cache: "no-cache" });
|
|
36
|
+
if (!res.ok) return [];
|
|
37
|
+
await c.put(m, res.clone());
|
|
38
|
+
return filesOf(await res.json(), m);
|
|
39
|
+
};
|
|
40
|
+
for (const m of manifests) {
|
|
41
|
+
const urls = known?.[0] === m ? filesOf(known[1], m) : await read(m).catch(() => []);
|
|
42
|
+
for (const u of urls) keep.add(u);
|
|
43
|
+
const missing = [];
|
|
44
|
+
for (const u of urls) if (hashed(u, manifests) && !await c.match(u)) missing.push(u);
|
|
45
|
+
await Promise.all(missing.map((u) => c.add(u).catch(() => {
|
|
46
|
+
})));
|
|
47
|
+
}
|
|
48
|
+
return keep;
|
|
49
|
+
};
|
|
50
|
+
const complete = (keep) => [...manifests].every((m) => keep.has(m));
|
|
51
|
+
const prune = async (keep) => {
|
|
52
|
+
if (!complete(keep)) return;
|
|
53
|
+
const c = await caches.open(name);
|
|
54
|
+
for (const req of await c.keys()) if (hashed(req.url, manifests) && mine(req.url) && !keep.has(req.url)) await c.delete(req);
|
|
55
|
+
};
|
|
56
|
+
self.addEventListener("install", (e) => {
|
|
57
|
+
const routes = scopes.map((s) => ({ condition: { urlPattern: new URL("split/*", s).href }, source: { cacheName: name } }));
|
|
58
|
+
e.waitUntil(
|
|
59
|
+
Promise.all([
|
|
60
|
+
fill(),
|
|
61
|
+
// Static Routing API: o arquivo com hash não passa pelo fetch do worker.
|
|
62
|
+
Promise.resolve().then(() => e.addRoutes?.(routes)).catch(() => {
|
|
63
|
+
})
|
|
64
|
+
])
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
self.addEventListener("activate", (e) => e.waitUntil(fill().then(prune)));
|
|
68
|
+
self.addEventListener("fetch", (e) => {
|
|
69
|
+
const req = e.request;
|
|
70
|
+
if (req.method !== "GET") return;
|
|
71
|
+
const url = req.url.split("#")[0];
|
|
72
|
+
if (manifests.has(url)) {
|
|
73
|
+
e.respondWith(
|
|
74
|
+
fetch(req).then(
|
|
75
|
+
(res) => {
|
|
76
|
+
if (res.ok) {
|
|
77
|
+
const copy = res.clone();
|
|
78
|
+
e.waitUntil?.(
|
|
79
|
+
copy.clone().json().then(async (m) => {
|
|
80
|
+
await (await caches.open(name)).put(url, copy);
|
|
81
|
+
await prune(await fill([url, m]));
|
|
82
|
+
}).catch(() => {
|
|
83
|
+
})
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return res;
|
|
87
|
+
},
|
|
88
|
+
() => caches.open(name).then((c) => c.match(url)).then((hit) => hit ?? Response.error())
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (mine(url) && hashed(url, manifests)) e.respondWith(caches.open(name).then((c) => c.match(req)).then((hit) => hit ?? fetch(req)));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
21
96
|
export {
|
|
22
|
-
|
|
97
|
+
filesOf,
|
|
98
|
+
remoteFiles,
|
|
99
|
+
remoteWorker
|
|
23
100
|
};
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Props, R as RemoteContext, a as RemoteModule } from './types-
|
|
2
|
-
export { r as resetVitral } from './state-
|
|
1
|
+
import { P as Props, R as RemoteContext, a as RemoteModule } from './types-DJautV-K.js';
|
|
2
|
+
export { r as resetVitral } from './state-B1FJi8I9.js';
|
|
3
3
|
import './errors-kjBv6IH_.js';
|
|
4
4
|
|
|
5
5
|
/** Endereço do JSON Schema do contrato. Vai no `$schema` do arquivo gravado. */
|
package/dist/testing.js
CHANGED
|
@@ -4,15 +4,18 @@ import {
|
|
|
4
4
|
harness,
|
|
5
5
|
verify
|
|
6
6
|
} from "./chunk-DAESKNQ6.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-EQZOJU3B.js";
|
|
7
|
+
import "./chunk-6JH2I65O.js";
|
|
9
8
|
import {
|
|
10
9
|
register
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-AL6MLNVY.js";
|
|
11
|
+
import "./chunk-MICF64AZ.js";
|
|
12
|
+
import "./chunk-IKCEA3YN.js";
|
|
13
|
+
import "./chunk-GGMM56TM.js";
|
|
14
|
+
import "./chunk-BQGVAXFM.js";
|
|
15
|
+
import "./chunk-JWDDXX5O.js";
|
|
16
|
+
import "./chunk-2Z4OH3BP.js";
|
|
17
|
+
import "./chunk-4E33RZMM.js";
|
|
18
|
+
import "./chunk-EQZOJU3B.js";
|
|
16
19
|
import {
|
|
17
20
|
protocol,
|
|
18
21
|
resetProtocol
|
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
import { R as RemoteError } from './errors-kjBv6IH_.js';
|
|
2
2
|
|
|
3
|
+
/** A cópia de outro remote que um remote usa no lugar da própria. */
|
|
4
|
+
interface PlannedCopy {
|
|
5
|
+
/** Faixa e versão da cópia própria que esta substitui (`^1.0.0@1.2.0`): outro deploy do remote não usa o plano. */
|
|
6
|
+
for?: string;
|
|
7
|
+
version: string;
|
|
8
|
+
/** URL da cópia (absoluta, ou a partir da raiz do site). */
|
|
9
|
+
file: string;
|
|
10
|
+
chunks?: string[];
|
|
11
|
+
/** Hash SRI da cópia e dos chunks dela, pela mesma URL. */
|
|
12
|
+
sri?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/** Por remote, por grupo: a cópia a usar. Remote ou grupo fora do plano segue como antes. */
|
|
15
|
+
type DedupePlan = Record<string, Record<string, PlannedCopy>>;
|
|
16
|
+
/**
|
|
17
|
+
* `remotes`: nome → `{ url, manifest }`. `host`: versão de cada grupo que o
|
|
18
|
+
* host oferece (o React do host entra como `react`).
|
|
19
|
+
*/
|
|
20
|
+
declare function planDedupe(remotes: Record<string, {
|
|
21
|
+
url: string;
|
|
22
|
+
manifest: RemoteManifest;
|
|
23
|
+
}>, host?: Record<string, string>): {
|
|
24
|
+
plan: DedupePlan;
|
|
25
|
+
notes: string[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type Policy = 'all' | 'critical' | 'lazy';
|
|
29
|
+
/** Sinais do navegador (Network Information, Device Memory) ou dos Client Hints. */
|
|
30
|
+
interface Signals {
|
|
31
|
+
saveData?: boolean;
|
|
32
|
+
/** `slow-2g`, `2g`, `3g` ou `4g`. */
|
|
33
|
+
effectiveType?: string;
|
|
34
|
+
/** Memória do aparelho, em GB (arredondada pelo navegador). */
|
|
35
|
+
deviceMemory?: number;
|
|
36
|
+
}
|
|
37
|
+
/** A tabela de heurística. Sinal ausente não conta. */
|
|
38
|
+
declare function choose(s: Signals): Policy;
|
|
39
|
+
/** Os sinais deste navegador. */
|
|
40
|
+
declare function signals(): Signals;
|
|
41
|
+
/**
|
|
42
|
+
* Os sinais dos Client Hints de uma requisição (`Save-Data`, `ECT`,
|
|
43
|
+
* `Device-Memory`), para o servidor decidir. O Chrome só manda os dois
|
|
44
|
+
* últimos depois de um `Accept-CH: ECT, Device-Memory`.
|
|
45
|
+
*/
|
|
46
|
+
declare function signalsFrom(headers: Headers | Record<string, string | string[] | undefined>): Signals;
|
|
47
|
+
/**
|
|
48
|
+
* A política deste visitante agora: a de `configure({ policy })`, ou a
|
|
49
|
+
* tabela. A mesma conta de `choose(signals())`, escrita de novo para o
|
|
50
|
+
* núcleo não carregar as duas funções.
|
|
51
|
+
*/
|
|
52
|
+
declare function policy(): Policy;
|
|
53
|
+
|
|
3
54
|
/**
|
|
4
55
|
* Tipos das chaves compartilhadas. Declare uma vez no projeto:
|
|
5
56
|
*
|
|
@@ -83,6 +134,11 @@ type CheckedProps<N extends string> = N extends keyof Remotes ? {
|
|
|
83
134
|
interface RemoteContext {
|
|
84
135
|
/** Nome com que o host registrou este remote. */
|
|
85
136
|
name: string;
|
|
137
|
+
/**
|
|
138
|
+
* Estado que o `render` do servidor devolveu com o HTML (`{ html, state }`),
|
|
139
|
+
* só na hidratação. O remote começa dele em vez de buscar os dados de novo.
|
|
140
|
+
*/
|
|
141
|
+
initialState?: unknown;
|
|
86
142
|
/** URL base de onde o remote foi carregado (útil para assets). */
|
|
87
143
|
baseUrl: string;
|
|
88
144
|
/**
|
|
@@ -184,6 +240,13 @@ interface RemoteEntry {
|
|
|
184
240
|
* nem `blob:` em `script-src`, onde a conferência não tem como rodar.
|
|
185
241
|
*/
|
|
186
242
|
integrity?: string | false;
|
|
243
|
+
/**
|
|
244
|
+
* Chaves públicas Ed25519 do remote (base64, sem `ed25519-`), de
|
|
245
|
+
* `vitral sign --keygen`. O Chrome 141+ só aceita o `vitral.json`, o JS e o
|
|
246
|
+
* CSS do remote assinados por uma delas (`vitral sign`), além do hash. Os
|
|
247
|
+
* outros navegadores ignoram e conferem só o hash.
|
|
248
|
+
*/
|
|
249
|
+
keys?: string[];
|
|
187
250
|
/** CSS extra para carregar junto. */
|
|
188
251
|
css?: string[];
|
|
189
252
|
/** Isolamento padrão para este remote. */
|
|
@@ -305,6 +368,21 @@ interface VitralConfig {
|
|
|
305
368
|
maxStale?: number;
|
|
306
369
|
/** Isolamento padrão para todos os remotes. Padrão `'none'`. */
|
|
307
370
|
isolate?: Isolation;
|
|
371
|
+
/**
|
|
372
|
+
* Quanto baixar além do que a página usa agora. Padrão: escolhida pelos
|
|
373
|
+
* sinais do visitante (`saveData`, `effectiveType`, `deviceMemory`).
|
|
374
|
+
* `'all'`: tudo. `'critical'` (3G, até 2 GB de memória): sem o preload
|
|
375
|
+
* ocioso dos outros remotes e sem `warmRoutes`. `'lazy'` (2G, economia de
|
|
376
|
+
* dados): só o que a página usa, e o remote com HTML do servidor só
|
|
377
|
+
* hidrata ao aparecer na tela.
|
|
378
|
+
*/
|
|
379
|
+
policy?: Policy;
|
|
380
|
+
/**
|
|
381
|
+
* Cópia de `dedupe` que cada remote usa, calculada com os manifestos de
|
|
382
|
+
* todos (`planDedupe`). O `withVitral` do host Next preenche sozinho.
|
|
383
|
+
* Assim dois remotes com faixas que se cruzam baixam uma cópia só.
|
|
384
|
+
*/
|
|
385
|
+
dedupePlan?: DedupePlan;
|
|
308
386
|
/**
|
|
309
387
|
* Liga os overrides de desenvolvimento (`?vitral=nome@url` e
|
|
310
388
|
* `localStorage['vitral:overrides']`) fora de localhost. Em localhost já
|
|
@@ -403,6 +481,13 @@ interface RemoteManifest {
|
|
|
403
481
|
entry: string;
|
|
404
482
|
chunks?: string[];
|
|
405
483
|
lazy?: string[];
|
|
484
|
+
/**
|
|
485
|
+
* O JS que roda ao montar (entrada, chunks e cópias de `dedupe`), na
|
|
486
|
+
* ordem de download: o caminho mais longo em bytes primeiro.
|
|
487
|
+
*/
|
|
488
|
+
order?: string[];
|
|
489
|
+
/** Posições em `order` do caminho crítico: esses vão com `fetchpriority="high"`. */
|
|
490
|
+
critical?: number[];
|
|
406
491
|
};
|
|
407
492
|
/**
|
|
408
493
|
* Dois módulos de teste do build dividido (`export{}` e um com hash errado),
|
|
@@ -469,4 +554,4 @@ interface EventBus {
|
|
|
469
554
|
last<T = unknown>(type: string): T | undefined;
|
|
470
555
|
}
|
|
471
556
|
|
|
472
|
-
export { type CheckedProps as C, type
|
|
557
|
+
export { provide as A, shared as B, type CheckedProps as C, type DedupePlan as D, type EventBus as E, signals as F, signalsFrom as G, type Handler as H, type Isolation as I, type MountedRemote as M, type Props as P, type RemoteContext as R, type Shared as S, type VitralConfig as V, type RemoteModule as a, type SharedModules as b, type RemoteEntry as c, type RemoteManifest as d, type StyleOptions as e, type SharedValue as f, type Channel as g, type ChannelContext as h, type DevOverrides as i, type McpAppBridge as j, type PlannedCopy as k, type Policy as l, type PropsOf as m, type ProvideOptions as n, type ProvidedValue as o, type RemoteContract as p, type RemoteMetric as q, type Remotes as r, type RollbackInfo as s, type SharedApi as t, type SharedType as u, type Signals as v, batch as w, choose as x, planDedupe as y, policy as z };
|
package/dist/vitals.js
CHANGED
package/dist/vite.d.ts
CHANGED
|
@@ -62,9 +62,11 @@ interface VitralViteOptions extends CssBuildOptions {
|
|
|
62
62
|
shared?: string[];
|
|
63
63
|
/**
|
|
64
64
|
* Prefixa todo o CSS do remote para valer só dentro dele (inclusive o
|
|
65
|
-
* preflight/tema do Tailwind). Padrão: true.
|
|
65
|
+
* preflight/tema do Tailwind). Padrão: true. `'native'` usa `@scope` no
|
|
66
|
+
* lugar do prefixo: CSS menor, mas sem a especificidade a mais (0,1,0)
|
|
67
|
+
* do prefixo, então uma regra igual do host pode valer dentro do remote.
|
|
66
68
|
*/
|
|
67
|
-
scopeCss?: boolean;
|
|
69
|
+
scopeCss?: boolean | 'native';
|
|
68
70
|
/**
|
|
69
71
|
* Outros componentes e módulos do remote, por nome. O host usa
|
|
70
72
|
* `carrinho/MiniCarrinho` ou `loadModule('carrinho/api')`.
|
package/dist/vite.js
CHANGED
|
@@ -43,13 +43,42 @@ function loadExposes(id, root, entry, exposes, main) {
|
|
|
43
43
|
|
|
44
44
|
// src/vite/manifest.ts
|
|
45
45
|
import { createHash } from "crypto";
|
|
46
|
-
import { readFileSync, rmSync, writeFileSync } from "fs";
|
|
46
|
+
import { readFileSync, rmSync, statSync, writeFileSync } from "fs";
|
|
47
47
|
import { join, posix } from "path";
|
|
48
48
|
var SPLIT = "split/";
|
|
49
49
|
var PROBES = [
|
|
50
50
|
[`${SPLIT}vitral-probe.js`, "export{}"],
|
|
51
51
|
[`${SPLIT}vitral-probe-x.js`, "export{}//"]
|
|
52
52
|
];
|
|
53
|
+
function criticalOrder(entry, mount, imports, size) {
|
|
54
|
+
const all = new Set(mount);
|
|
55
|
+
all.add(entry);
|
|
56
|
+
const edges = (f) => imports(f).filter((d) => all.has(d));
|
|
57
|
+
const memo = /* @__PURE__ */ new Map();
|
|
58
|
+
const rank = (f) => {
|
|
59
|
+
const known = memo.get(f);
|
|
60
|
+
if (known !== void 0) return known;
|
|
61
|
+
memo.set(f, size(f));
|
|
62
|
+
const r = size(f) + Math.max(0, ...edges(f).map(rank));
|
|
63
|
+
memo.set(f, r);
|
|
64
|
+
return r;
|
|
65
|
+
};
|
|
66
|
+
const first = /* @__PURE__ */ new Set([entry]);
|
|
67
|
+
for (const f of first) for (const d of edges(f)) first.add(d);
|
|
68
|
+
const byRank = (l) => l.map((f, i) => [f, rank(f), i]).sort((a, b) => b[1] - a[1] || a[2] - b[2]).map(([f]) => f);
|
|
69
|
+
const later = byRank([...all].filter((f) => !first.has(f)));
|
|
70
|
+
const order = [...byRank([...first]), ...later];
|
|
71
|
+
const path = /* @__PURE__ */ new Set();
|
|
72
|
+
const walk = (f) => {
|
|
73
|
+
while (f && !path.has(f)) {
|
|
74
|
+
path.add(f);
|
|
75
|
+
f = byRank(edges(f).filter((d) => !path.has(d)))[0];
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
walk(entry);
|
|
79
|
+
walk(later[0]);
|
|
80
|
+
return { order, critical: order.flatMap((f, i) => path.has(f) ? [i] : []) };
|
|
81
|
+
}
|
|
53
82
|
var sri = (file) => "sha384-" + createHash("sha384").update(readFileSync(file)).digest("base64");
|
|
54
83
|
function outputs(rolldown, hints = false) {
|
|
55
84
|
const banner = hints ? { [rolldown ? "postBanner" : "banner"]: compileHint } : {};
|
|
@@ -97,7 +126,11 @@ function collect(outDir, bundle) {
|
|
|
97
126
|
}
|
|
98
127
|
const lazy = [...app].filter((n) => n !== entry && !soon.has(n));
|
|
99
128
|
const uses = usedNames([...app, entry].flatMap((n) => Object.entries(byName.get(n)?.modules ?? {})));
|
|
100
|
-
|
|
129
|
+
const mount = [...soon, ...Object.values(own).flatMap((o) => [o.file, ...o.chunks])];
|
|
130
|
+
const { order, critical } = criticalOrder(entry, mount, (f) => byName.get(f)?.imports ?? [], (f) => statSync(join(outDir, f)).size);
|
|
131
|
+
const at = new Map(order.map((f, i) => [f, i]));
|
|
132
|
+
const first = [...soon].sort((a, b) => at.get(a) - at.get(b));
|
|
133
|
+
return { entry, chunks: first, files: [...used], own, lazy, uses, order, critical };
|
|
101
134
|
}
|
|
102
135
|
function rewrite(file, c, byName, deps) {
|
|
103
136
|
const targets = c.dynamicImports.filter((d) => byName.has(d));
|
|
@@ -135,7 +168,7 @@ function withSplit(m, outDir, s, groups2 = []) {
|
|
|
135
168
|
return { name, range, version, ...s.own[name], uses };
|
|
136
169
|
});
|
|
137
170
|
if (s) for (const [file, code] of PROBES) writeFileSync(join(outDir, file), code);
|
|
138
|
-
return { ...m, files, ...s && { split: { entry: s.entry, chunks: s.chunks, ...s.lazy.length && { lazy: s.lazy } }, probe: PROBES.map(([f]) => f) }, ...dedupe.length && { dedupe } };
|
|
171
|
+
return { ...m, files, ...s && { split: { entry: s.entry, chunks: s.chunks, ...s.lazy.length && { lazy: s.lazy }, order: s.order, critical: s.critical }, probe: PROBES.map(([f]) => f) }, ...dedupe.length && { dedupe } };
|
|
139
172
|
}
|
|
140
173
|
|
|
141
174
|
// src/vite/sbom.ts
|
|
@@ -346,13 +379,15 @@ function scopeSelector(selector, scope) {
|
|
|
346
379
|
if (s === "*") return `${scope}, ${scope} *`;
|
|
347
380
|
return `${scope} ${s}`;
|
|
348
381
|
}
|
|
349
|
-
function scopeCss(css, scopeName) {
|
|
382
|
+
function scopeCss(css, scopeName, native = false) {
|
|
350
383
|
const root = postcss.parse(css);
|
|
351
|
-
scopeRoot(root, scopeName);
|
|
384
|
+
scopeRoot(root, scopeName, native);
|
|
352
385
|
return root.toString();
|
|
353
386
|
}
|
|
354
|
-
|
|
387
|
+
var TOP = /^(charset|import|namespace|keyframes|-webkit-keyframes|font-face|property|counter-style|font-feature-values|font-palette-values|page|view-transition)$/i;
|
|
388
|
+
function scopeRoot(root, scopeName, native = false) {
|
|
355
389
|
const scope = `[data-vitral-scope="${scopeName}"]`;
|
|
390
|
+
if (native) return nativeScope(root, scope);
|
|
356
391
|
root.walkRules((rule) => {
|
|
357
392
|
let p = rule.parent;
|
|
358
393
|
while (p && p.type !== "root") {
|
|
@@ -363,6 +398,21 @@ function scopeRoot(root, scopeName) {
|
|
|
363
398
|
rule.selectors = rule.selectors.map((sel) => scopeSelector(sel, scope));
|
|
364
399
|
});
|
|
365
400
|
}
|
|
401
|
+
function nativeScope(root, scope) {
|
|
402
|
+
root.walkRules((rule) => {
|
|
403
|
+
for (let p = rule.parent; p && p.type !== "root"; p = p.parent) if (p.type === "atrule" && /keyframes$/i.test(p.name)) return;
|
|
404
|
+
rule.selectors = rule.selectors.map((sel) => {
|
|
405
|
+
const s = sel.trim();
|
|
406
|
+
const m = s.match(GLOBAL);
|
|
407
|
+
return m ? ":scope" + s.slice(m[0].length) : s === "*" ? ":scope, *" : s;
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
const block = postcss.atRule({ name: "scope", params: `(${scope})` });
|
|
411
|
+
for (const node of [...root.nodes]) {
|
|
412
|
+
if (!(node.type === "atrule" && TOP.test(node.name)) && node.type !== "comment") block.append(node);
|
|
413
|
+
}
|
|
414
|
+
if (block.nodes?.length) root.append(block);
|
|
415
|
+
}
|
|
366
416
|
|
|
367
417
|
// src/css-theme.ts
|
|
368
418
|
var GLOBAL2 = /^(?::root|:host|html|body)([.:[#][^\s>+~]*)?$/i;
|
|
@@ -457,7 +507,7 @@ function transformCss(css, options, scope) {
|
|
|
457
507
|
if (options.theme === "host") hostTheme(root);
|
|
458
508
|
if (options.layers === "flatten") flattenLayers(root);
|
|
459
509
|
if (options.renameRegisteredProperties) renameRegisteredProperties(root, scope);
|
|
460
|
-
if (options.scopeCss !== false) scopeRoot(root, scope);
|
|
510
|
+
if (options.scopeCss !== false) scopeRoot(root, scope, options.scopeCss === "native");
|
|
461
511
|
return root.toString();
|
|
462
512
|
}
|
|
463
513
|
var RELATIVE_URL = /url\(\s*(['"]?)(?![a-z]+:|\/\/|#)([^'")]+)\1\s*\)/i;
|
|
@@ -704,7 +754,7 @@ function nextDefine(env, mode) {
|
|
|
704
754
|
}
|
|
705
755
|
|
|
706
756
|
// src/vite/tsconfig.ts
|
|
707
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3, statSync } from "fs";
|
|
757
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
|
|
708
758
|
import { createRequire } from "module";
|
|
709
759
|
import { dirname as dirname2, join as join3, resolve as resolve3 } from "path";
|
|
710
760
|
function parseJsonc(text) {
|
|
@@ -791,7 +841,7 @@ var EXTENSIONS2 = ["", ".ts", ".tsx", ".mts", ".js", ".jsx", ".mjs", "/index.ts"
|
|
|
791
841
|
function fileOf(path) {
|
|
792
842
|
for (const ext of EXTENSIONS2) {
|
|
793
843
|
try {
|
|
794
|
-
if (
|
|
844
|
+
if (statSync2(path + ext).isFile()) return path + ext;
|
|
795
845
|
} catch {
|
|
796
846
|
}
|
|
797
847
|
}
|
|
@@ -920,9 +970,9 @@ function devManifest(name, scope) {
|
|
|
920
970
|
return { name, entry: DEV_ENTRY, css: [], ...scope ? { scope } : {} };
|
|
921
971
|
}
|
|
922
972
|
var DEV_CSS = { include: /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(\?|$)/, exclude: /[?&](raw|url|inline)\b/ };
|
|
923
|
-
function scopeDevCss(code, id, scope) {
|
|
973
|
+
function scopeDevCss(code, id, scope, native = false) {
|
|
924
974
|
if (!DEV_CSS.include.test(id) || DEV_CSS.exclude.test(id)) return;
|
|
925
|
-
return scopeCss(code, scope);
|
|
975
|
+
return scopeCss(code, scope, native);
|
|
926
976
|
}
|
|
927
977
|
function serveDevManifest(server, manifest) {
|
|
928
978
|
const path = `${server.config.base.replace(/\/?$/, "/")}vitral.json`;
|
|
@@ -1126,7 +1176,7 @@ function vitral(options = {}) {
|
|
|
1126
1176
|
transform: {
|
|
1127
1177
|
filter: { id: DEV_CSS },
|
|
1128
1178
|
handler(code, id) {
|
|
1129
|
-
if (serve && options.scopeCss !== false) return scopeDevCss(code, id, scopeName());
|
|
1179
|
+
if (serve && options.scopeCss !== false) return scopeDevCss(code, id, scopeName(), options.scopeCss === "native");
|
|
1130
1180
|
}
|
|
1131
1181
|
},
|
|
1132
1182
|
writeBundle(_, bundle) {
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { PropType, App, ShallowRef, WritableComputedRef, ComputedRef, Component } from 'vue';
|
|
3
|
-
import { P as Props, I as Isolation, R as RemoteContext, S as Shared, a as RemoteModule } from './types-
|
|
4
|
-
export { e as events } from './events-
|
|
3
|
+
import { P as Props, I as Isolation, R as RemoteContext, S as Shared, a as RemoteModule } from './types-DJautV-K.js';
|
|
4
|
+
export { e as events } from './events-II6hXM3Q.js';
|
|
5
5
|
import { L as Loading, P as Prefetch } from './host-slot-Cz6EiGsB.js';
|
|
6
6
|
import './errors-kjBv6IH_.js';
|
|
7
7
|
|
|
@@ -128,8 +128,8 @@ declare const VitralRemote: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
128
128
|
onReady?: ((...args: any[]) => any) | undefined;
|
|
129
129
|
}>, {
|
|
130
130
|
isolate: Isolation;
|
|
131
|
-
name: string;
|
|
132
131
|
priority: RequestPriority;
|
|
132
|
+
name: string;
|
|
133
133
|
loading: Loading;
|
|
134
134
|
src: string;
|
|
135
135
|
props: Props;
|
package/dist/vue.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hostSlot,
|
|
3
3
|
timings
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2SAI6S2H.js";
|
|
5
5
|
import {
|
|
6
6
|
defineRemote,
|
|
7
7
|
memoSelect,
|
|
8
8
|
same,
|
|
9
9
|
shared
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6JH2I65O.js";
|
|
11
|
+
import "./chunk-AL6MLNVY.js";
|
|
12
|
+
import "./chunk-MICF64AZ.js";
|
|
13
|
+
import "./chunk-IKCEA3YN.js";
|
|
14
|
+
import {
|
|
15
|
+
absolute
|
|
16
|
+
} from "./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
|
} from "./chunk-EQZOJU3B.js";
|
|
14
|
-
import "./chunk-EVVYV5ED.js";
|
|
15
|
-
import "./chunk-MGG5BW3U.js";
|
|
16
|
-
import "./chunk-SC2KF7GJ.js";
|
|
17
|
-
import {
|
|
18
|
-
absolute
|
|
19
|
-
} from "./chunk-TW7KYJQ6.js";
|
|
20
|
-
import "./chunk-463H6B56.js";
|
|
21
24
|
import "./chunk-GNPFWISJ.js";
|
|
22
25
|
import "./chunk-MLKGABMK.js";
|
|
23
26
|
|