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.
Files changed (89) hide show
  1. package/README.md +23 -7
  2. package/dist/angular.d.ts +2 -2
  3. package/dist/angular.js +13 -10
  4. package/dist/auto.js +11 -8
  5. package/dist/{capture-A6JQNNQY.js → capture-2I5IQ2C2.js} +2 -1
  6. package/dist/{channel-2DUQQPPA.js → channel-ABGK26Q5.js} +5 -3
  7. package/dist/{chunk-WAU6OKK3.js → chunk-2SAI6S2H.js} +11 -3
  8. package/dist/chunk-2Z4OH3BP.js +85 -0
  9. package/dist/chunk-5O6XDJBR.js +15 -0
  10. package/dist/chunk-623K4UNS.js +70 -0
  11. package/dist/{chunk-VTGHPX4J.js → chunk-6JH2I65O.js} +15 -13
  12. package/dist/{chunk-EVVYV5ED.js → chunk-AL6MLNVY.js} +49 -21
  13. package/dist/chunk-B3PFMWZT.js +21 -0
  14. package/dist/{chunk-463H6B56.js → chunk-BQGVAXFM.js} +3 -4
  15. package/dist/{chunk-TW7KYJQ6.js → chunk-GGMM56TM.js} +1 -1
  16. package/dist/{chunk-FOEXP52G.js → chunk-I3CDUKHO.js} +69 -19
  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-CFJC4GRB.js → chunk-SVYL6UCB.js} +21 -10
  26. package/dist/{chunk-UYOPJ4XQ.js → chunk-UCFOXMOR.js} +1 -1
  27. package/dist/cli.js +119 -8
  28. package/dist/{contract-IXM52LVW.js → contract-3JY7SOGQ.js} +1 -1
  29. package/dist/{dedupe-SRAPOK3V.js → dedupe-M63VMCWA.js} +3 -1
  30. package/dist/edge.d.ts +4 -2
  31. package/dist/edge.js +69 -46
  32. package/dist/element.d.ts +3 -3
  33. package/dist/element.js +11 -8
  34. package/dist/embed.js +2 -2
  35. package/dist/{events-CWdYSrkz.d.ts → events-II6hXM3Q.d.ts} +1 -1
  36. package/dist/expose-2S3TCXSP.js +18 -0
  37. package/dist/federation.d.ts +1 -1
  38. package/dist/{hydrate-IVQNHOP3.js → hydrate-FJHHLW5G.js} +22 -12
  39. package/dist/iframe.js +15 -12
  40. package/dist/index.d.ts +6 -6
  41. package/dist/index.js +25 -11
  42. package/dist/{loader-CLRMRRFv.d.ts → loader-Bmul2-5T.d.ts} +1 -1
  43. package/dist/next-config.d.ts +30 -10
  44. package/dist/next-config.js +29 -20
  45. package/dist/next-host.d.ts +11 -5
  46. package/dist/next-host.js +54 -29
  47. package/dist/next-server.d.ts +56 -0
  48. package/dist/next-server.js +90 -0
  49. package/dist/preact.d.ts +4 -4
  50. package/dist/preact.js +10 -7
  51. package/dist/prefetch.d.ts +40 -3
  52. package/dist/prefetch.js +100 -30
  53. package/dist/react-server.d.ts +16 -5
  54. package/dist/react-server.js +8 -3
  55. package/dist/react.d.ts +20 -6
  56. package/dist/react.js +14 -9
  57. package/dist/{reframe-ZOQPW552.js → reframe-HIYA2TIU.js} +10 -9
  58. package/dist/route-4KQITYD4.js +138 -0
  59. package/dist/routes.d.ts +2 -2
  60. package/dist/routes.js +12 -9
  61. package/dist/{shadow-PZGQKUA4.js → shadow-7ZV4JEO6.js} +4 -3
  62. package/dist/sign.d.ts +49 -0
  63. package/dist/sign.js +15 -0
  64. package/dist/single-spa.d.ts +1 -1
  65. package/dist/{slot-DRYmGvvV.d.ts → slot--WLgdcW_.d.ts} +1 -1
  66. package/dist/snapshot.d.ts +6 -0
  67. package/dist/snapshot.js +125 -0
  68. package/dist/solid.d.ts +3 -3
  69. package/dist/solid.js +10 -7
  70. package/dist/sri-AMQOKKWR.js +17 -0
  71. package/dist/ssr-markup-BCPpGmss.d.ts +13 -0
  72. package/dist/state-B1FJi8I9.d.ts +14 -0
  73. package/dist/svelte.d.ts +4 -4
  74. package/dist/svelte.js +10 -7
  75. package/dist/sw.d.ts +48 -1
  76. package/dist/sw.js +79 -2
  77. package/dist/testing.d.ts +2 -2
  78. package/dist/testing.js +10 -7
  79. package/dist/{types-g8WEVD_b.d.ts → types-DJautV-K.d.ts} +86 -1
  80. package/dist/vitals.js +2 -1
  81. package/dist/vite.d.ts +4 -2
  82. package/dist/vite.js +62 -12
  83. package/dist/vue.d.ts +3 -3
  84. package/dist/vue.js +13 -10
  85. package/package.json +47 -39
  86. package/dist/expose-BA4HSXDP.js +0 -17
  87. package/dist/portals-RLXKPXBZ.js +0 -24
  88. package/dist/sri-LQBLQMG5.js +0 -14
  89. package/dist/state-BDdCwc21.d.ts +0 -4
package/dist/cli.js CHANGED
@@ -5,6 +5,10 @@ import {
5
5
  import {
6
6
  loadTs
7
7
  } from "./chunk-PY7P5BF4.js";
8
+ import {
9
+ keygen,
10
+ signDir
11
+ } from "./chunk-623K4UNS.js";
8
12
  import {
9
13
  dictMatch
10
14
  } from "./chunk-NZEQGRBL.js";
@@ -844,7 +848,7 @@ async function remotesOf(o, f, cwd, timeout) {
844
848
  }
845
849
  async function doctor(options = {}) {
846
850
  ;
847
- ({ satisfies } = await import("./dedupe-SRAPOK3V.js"));
851
+ ({ satisfies } = await import("./dedupe-M63VMCWA.js"));
848
852
  const cwd = options.cwd ?? process.cwd();
849
853
  const f = options.fetch ?? fetch;
850
854
  const timeout = options.timeout ?? 15e3;
@@ -889,6 +893,17 @@ function format(r) {
889
893
  async function doctorCli(argv, options = {}, log = console.log) {
890
894
  const args2 = [...argv];
891
895
  const json = args2.includes("--json");
896
+ const stats = flag(args2, "--stats");
897
+ if (stats) {
898
+ const { routeReport, formatRoute } = await import("./route-4KQITYD4.js");
899
+ const route = flag(args2, "--route") ?? "/";
900
+ const remotes = [];
901
+ for (let r3 = flag(args2, "--remote"); r3 !== void 0; r3 = flag(args2, "--remote")) remotes.push(r3);
902
+ const top = flag(args2, "--top");
903
+ const r2 = routeReport({ stats, route, remotes, cwd: options.cwd, top: top === void 0 ? void 0 : Number(top) });
904
+ log(json ? JSON.stringify(r2, null, 2) : formatRoute(r2));
905
+ return r2.checks.some((c) => c.status === "error") ? 1 : 0;
906
+ }
892
907
  const maxKb = flag(args2, "--max-kb");
893
908
  const r = await doctor({
894
909
  ...options,
@@ -1250,8 +1265,65 @@ ${result.notes.map((n) => ` - ${n}`).join("\n")}`);
1250
1265
  return result;
1251
1266
  }
1252
1267
 
1268
+ // src/cli/prior.ts
1269
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
1270
+ function buildPrior(lines, o = {}) {
1271
+ const { minCount = 5, minRow = 20, top = 10 } = o;
1272
+ const t = /* @__PURE__ */ Object.create(null);
1273
+ for (const line of lines) {
1274
+ if (!line.trim()) continue;
1275
+ let s;
1276
+ try {
1277
+ s = JSON.parse(line);
1278
+ } catch {
1279
+ continue;
1280
+ }
1281
+ const path = Array.isArray(s) ? s : s?.path;
1282
+ if (!Array.isArray(path)) continue;
1283
+ for (let i = 1; i < path.length; i++) {
1284
+ const [a, b] = [path[i - 1], path[i]];
1285
+ if (typeof a !== "string" || typeof b !== "string" || a === b || a === "__proto__" || b === "__proto__") continue;
1286
+ const row = t[a] ??= /* @__PURE__ */ Object.create(null);
1287
+ row[b] = (row[b] ?? 0) + 1;
1288
+ }
1289
+ }
1290
+ const out = {};
1291
+ for (const from of Object.keys(t).sort()) {
1292
+ const kept = Object.entries(t[from]).filter(([, n]) => n >= minCount).sort((x, y) => y[1] - x[1] || (x[0] < y[0] ? -1 : 1)).slice(0, top);
1293
+ if (kept.reduce((a, [, n]) => a + n, 0) >= minRow) out[from] = Object.fromEntries(kept);
1294
+ }
1295
+ return { t: out };
1296
+ }
1297
+ function prior(file, out, o) {
1298
+ const p = buildPrior(readFileSync7(file, "utf8").split("\n"), o);
1299
+ const json = JSON.stringify(p);
1300
+ if (out) {
1301
+ writeFileSync6(out, json + "\n");
1302
+ console.log(`[vitral] ${Object.keys(p.t).length} rotas em ${out}`);
1303
+ } else console.log(json);
1304
+ }
1305
+
1306
+ // src/cli/sign.ts
1307
+ import { readFileSync as readFileSync8 } from "fs";
1308
+ function signCli(dir, o, log = console.log) {
1309
+ if (o.keygen) {
1310
+ const k = keygen();
1311
+ log(`Chave p\xFAblica (vai no host, em configure({ remotes: { nome: { url, keys: [...] } } })):
1312
+ ${k.publicKey}
1313
+ `);
1314
+ log(`Chave privada (segredo do CI do remote, em VITRAL_SIGNING_KEY ou num arquivo para --key-file):
1315
+ ${k.privateKey}`);
1316
+ return;
1317
+ }
1318
+ if (!dir) throw new Error("[vitral] sign precisa da pasta do build: vitral sign dist");
1319
+ const key = o.keyFile ? readFileSync8(o.keyFile, "utf8") : process.env.VITRAL_SIGNING_KEY;
1320
+ if (!key) throw new Error("[vitral] sign precisa da chave privada: --key-file arquivo.pem ou VITRAL_SIGNING_KEY");
1321
+ const out = signDir(dir, key.replace(/\\n/g, "\n"), { base: o.base, headersFile: !o.noHeaders });
1322
+ log(`${Object.keys(out).length} arquivos assinados. Headers em vitral-signatures.json${o.noHeaders ? "" : " e _headers"}.`);
1323
+ }
1324
+
1253
1325
  // src/cli/test.ts
1254
- import { existsSync as existsSync7, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "fs";
1326
+ import { existsSync as existsSync7, readdirSync as readdirSync3, readFileSync as readFileSync9, statSync as statSync2 } from "fs";
1255
1327
  import { createRequire } from "module";
1256
1328
  import { dirname as dirname4, join as join4, resolve as resolve5 } from "path";
1257
1329
  import { pathToFileURL } from "url";
@@ -1416,7 +1488,7 @@ function sourcesIn(dir) {
1416
1488
  if (f.name === "node_modules") continue;
1417
1489
  const p = join4(d, f.name);
1418
1490
  if (f.isDirectory()) walk(p);
1419
- else if (/\.[cm]?js$/.test(f.name)) out.push(readFileSync7(p, "utf8"));
1491
+ else if (/\.[cm]?js$/.test(f.name)) out.push(readFileSync9(p, "utf8"));
1420
1492
  }
1421
1493
  };
1422
1494
  walk(dir);
@@ -1431,7 +1503,7 @@ function publishedTypes(since, cwd) {
1431
1503
  return existsSync7(abs) && statSync2(abs).isDirectory() ? join4(abs, "vitral.d.ts") : abs;
1432
1504
  }
1433
1505
  async function readText(where, get2) {
1434
- if (!/^https?:\/\//.test(where)) return readFileSync7(where, "utf8");
1506
+ if (!/^https?:\/\//.test(where)) return readFileSync9(where, "utf8");
1435
1507
  const res = await get2(where);
1436
1508
  if (!res.ok) throw new Error(`HTTP ${res.status} em ${where}`);
1437
1509
  return res.text();
@@ -1443,7 +1515,7 @@ async function test(options = {}) {
1443
1515
  const dir = resolve5(cwd, options.dir ?? "dist");
1444
1516
  if (!options.contracts?.length && !options.since) throw new Error("[vitral] passe --contract arquivo e/ou --since url. Veja `vitral --help`.");
1445
1517
  const localFile = resolve5(cwd, options.types ?? join4(dir, "vitral.d.ts"));
1446
- const local = existsSync7(localFile) ? parseProps(readFileSync7(localFile, "utf8")) : null;
1518
+ const local = existsSync7(localFile) ? parseProps(readFileSync9(localFile, "utf8")) : null;
1447
1519
  let ts;
1448
1520
  const typescript = async () => ts === void 0 ? ts = await loadTs(cwd) : ts;
1449
1521
  let failures = 0;
@@ -1464,7 +1536,7 @@ async function test(options = {}) {
1464
1536
  if (!entry) {
1465
1537
  const manifest = join4(dir, "vitral.json");
1466
1538
  if (!existsSync7(manifest)) throw new Error(`[vitral] ${manifest} n\xE3o existe. Rode o build ou passe --entry.`);
1467
- entry = resolve5(dir, JSON.parse(readFileSync7(manifest, "utf8")).entry);
1539
+ entry = resolve5(dir, JSON.parse(readFileSync9(manifest, "utf8")).entry);
1468
1540
  }
1469
1541
  const close = typeof document === "undefined" ? await installDom(cwd) : void 0;
1470
1542
  try {
@@ -1474,7 +1546,7 @@ async function test(options = {}) {
1474
1546
  if (!local) log(`[vitral] sem Props local em ${localFile}: as props gravadas n\xE3o foram conferidas pelo tipo.`);
1475
1547
  else if (!tsApi) log("[vitral] sem TypeScript no projeto: as props gravadas n\xE3o foram conferidas pelo tipo.");
1476
1548
  for (const file of files2) {
1477
- const contract = JSON.parse(readFileSync7(file, "utf8"));
1549
+ const contract = JSON.parse(readFileSync9(file, "utf8"));
1478
1550
  const result = await verify(contract, mod, { sources: sources3 });
1479
1551
  if (local && tsApi) {
1480
1552
  const typed = checkCaseProps(contract, local, tsApi);
@@ -1502,11 +1574,15 @@ var AJUDA = `Uso:
1502
1574
  vitral mcp [--registry url|arquivo]
1503
1575
  vitral doctor [remotes.json | url | nome=url ...] [--host url] [--origin url] [--base url]
1504
1576
  [--contract faixa] [--max-kb n] [--json]
1577
+ vitral doctor --stats stats.json [--route /pagina] [--remote dist ...] [--top n] [--json]
1505
1578
  vitral migrate [pasta] [--from single-spa|module-federation] [--dry-run]
1506
1579
  vitral canal <canal.json> [--stable x.y.z] [--canary x.y.z | off] [--percent n]
1507
1580
  vitral test [--contract arquivo|pasta ...] [--since url|arquivo] [--dir dist] [--entry arquivo]
1508
1581
  [--types vitral.d.ts]
1509
1582
  vitral dict <dist> --from <dist-anterior> [--from ...] [--level n] [--no-dcb]
1583
+ vitral prior <sessoes.jsonl> [--out prior.json] [--min-count n] [--min-row n] [--top n]
1584
+ vitral sign --keygen
1585
+ vitral sign <dist> [--key-file chave.pem] [--base /caminho/] [--no-headers]
1510
1586
 
1511
1587
  types Baixa o vitral.d.ts de cada remote e gera vitral-env.d.ts.
1512
1588
  --check s\xF3 confere se o hash de cada manifesto ainda \xE9 o
@@ -1519,6 +1595,10 @@ var AJUDA = `Uso:
1519
1595
  doctor Confere cada remote como o host faria (manifesto, CORS, CSP, mount,
1520
1596
  integrity, contrato, dedupe, tamanho) e explica o que fazer.
1521
1597
  Sai com erro se alguma confer\xEAncia falhar (\xFAtil no CI).
1598
+ Com --stats (stats do webpack do host): soma o que a rota carrega
1599
+ por pacote e aponta tradu\xE7\xF5es inteiras no bundle, m\xF3dulos sem
1600
+ export usado, ofertas de share com o pacote inteiro e, com
1601
+ --remote, pacotes que o host e o remote levam em dobro.
1522
1602
  migrate Converte um app do single-spa ou um remote do Module Federation num
1523
1603
  remote vitral. Mostra o diff de cada arquivo.
1524
1604
  --dry-run s\xF3 mostra o que mudaria, sem escrever.
@@ -1533,7 +1613,16 @@ var AJUDA = `Uso:
1533
1613
  quebram o host.
1534
1614
  dict Pr\xE9-comprime cada arquivo do dist com a vers\xE3o anterior dele
1535
1615
  como dicion\xE1rio (.dcz e, com o bin\xE1rio brotli, .dcb) e grava
1536
- vitral-dict.json para o middleware vitral/dict.`;
1616
+ vitral-dict.json para o middleware vitral/dict.
1617
+ prior Gera as transi\xE7\xF5es da popula\xE7\xE3o para o prefetch (prior de
1618
+ vitral/prefetch), de sess\xF5es agregadas: uma por linha, array
1619
+ JSON de rotas. Tira transi\xE7\xF5es com menos de --min-count (5) e
1620
+ rotas com menos de --min-row (20) transi\xE7\xF5es.
1621
+ sign Assina o vitral.json, o JS e o CSS do dist com Ed25519 e grava os
1622
+ headers em vitral-signatures.json e _headers. O host que p\xF5e a
1623
+ chave p\xFAblica em keys s\xF3 roda arquivos assinados (Chrome 141+).
1624
+ Chave privada em --key-file ou VITRAL_SIGNING_KEY. --keygen cria
1625
+ o par de chaves. Rode por \xFAltimo, depois de vitral dict.`;
1537
1626
  var falhou = (err) => {
1538
1627
  console.error(err.message);
1539
1628
  process.exitCode = 1;
@@ -1618,6 +1707,28 @@ if (command === "types") {
1618
1707
  } catch (err) {
1619
1708
  falhou(err);
1620
1709
  }
1710
+ } else if (command === "prior" && args.length) {
1711
+ const num = (name) => {
1712
+ const v = flag(args, name);
1713
+ return v === void 0 ? void 0 : Number(v);
1714
+ };
1715
+ try {
1716
+ const out = flag(args, "--out");
1717
+ const o = { minCount: num("--min-count"), minRow: num("--min-row"), top: num("--top") };
1718
+ prior(args[0], out, o);
1719
+ } catch (err) {
1720
+ falhou(err);
1721
+ }
1722
+ } else if (command === "sign" && args.length) {
1723
+ try {
1724
+ const keygen2 = bool(args, "--keygen");
1725
+ const noHeaders = bool(args, "--no-headers");
1726
+ const keyFile = flag(args, "--key-file");
1727
+ const base = flag(args, "--base");
1728
+ signCli(args[0], { keygen: keygen2, keyFile, base, noHeaders });
1729
+ } catch (err) {
1730
+ falhou(err);
1731
+ }
1621
1732
  } else {
1622
1733
  console.log(AJUDA);
1623
1734
  process.exitCode = command && command !== "--help" ? 1 : 0;
@@ -5,7 +5,7 @@ import "./chunk-MLKGABMK.js";
5
5
 
6
6
  // src/core/contract.ts
7
7
  async function checkContract(c, range = protocol().settings().contract) {
8
- const { satisfies } = await import("./dedupe-SRAPOK3V.js");
8
+ const { satisfies } = await import("./dedupe-M63VMCWA.js");
9
9
  if (c.version && !satisfies(c.version, range)) return `o host aceita contrato ${range}, o remote publica ${c.version}`;
10
10
  const offered = protocol().settings().offered ?? {};
11
11
  for (const dep in c.peers) {
@@ -1,13 +1,15 @@
1
1
  import {
2
2
  offer,
3
+ planned,
3
4
  shared
4
- } from "./chunk-R3HUMHNL.js";
5
+ } from "./chunk-LDOSAAEF.js";
5
6
  import {
6
7
  satisfies
7
8
  } from "./chunk-4E33RZMM.js";
8
9
  import "./chunk-MLKGABMK.js";
9
10
  export {
10
11
  offer,
12
+ planned,
11
13
  satisfies,
12
14
  shared
13
15
  };
package/dist/edge.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { R as Routes } from './match-CMBM_jLW.js';
2
- import { P as Props } from './types-g8WEVD_b.js';
2
+ import { S as ServerRendered } from './ssr-markup-BCPpGmss.js';
3
+ import { P as Props } from './types-DJautV-K.js';
3
4
  import './errors-kjBv6IH_.js';
4
5
 
5
6
  /**
@@ -52,7 +53,8 @@ interface EdgeElement {
52
53
  */
53
54
 
54
55
  /** HTML do remote para estas props, no servidor. */
55
- type ServerRender = (props: Props) => string | Promise<string>;
56
+ /** HTML do remote, ou `{ html, state }`: o estado vai junto e chega em `ctx.initialState`. */
57
+ type ServerRender = (props: Props) => ServerRendered | Promise<ServerRendered>;
56
58
  /** Isolamento do remote na página (o mesmo de `isolate` no cliente). */
57
59
  type EdgeIsolation = 'shadow' | 'none';
58
60
  interface EdgeRemote {
package/dist/edge.js CHANGED
@@ -1,6 +1,16 @@
1
1
  import {
2
2
  matchRoute
3
3
  } from "./chunk-OVVGVPIV.js";
4
+ import {
5
+ critical,
6
+ ordered
7
+ } from "./chunk-5O6XDJBR.js";
8
+ import {
9
+ htmlOf,
10
+ inlineJson,
11
+ ssrHolder,
12
+ stateScript
13
+ } from "./chunk-B3PFMWZT.js";
4
14
  import "./chunk-MLKGABMK.js";
5
15
 
6
16
  // src/edge/rewriter.ts
@@ -58,80 +68,84 @@ function rewrite(body, tags, handlers) {
58
68
  async function process(out, end) {
59
69
  let text = "";
60
70
  let i = 0;
71
+ let from = 0;
72
+ const take = (to) => {
73
+ if (to > from) text += buf.slice(from, to);
74
+ from = to;
75
+ };
61
76
  const flush = () => text && (out.enqueue(encoder.encode(text)), text = "");
62
77
  for (; ; ) {
78
+ if (raw) {
79
+ const re = rawEnd(raw);
80
+ re.lastIndex = i;
81
+ const found = re.exec(buf);
82
+ if (found) raw = null, i = found.index;
83
+ else {
84
+ const last = buf.lastIndexOf("<");
85
+ i = !end && last >= i && buf.length - last < raw.length + 2 ? last : buf.length;
86
+ break;
87
+ }
88
+ }
63
89
  const lt = buf.indexOf("<", i);
64
90
  if (lt < 0) {
65
- text += buf.slice(i);
66
91
  i = buf.length;
67
92
  break;
68
93
  }
69
- text += buf.slice(i, lt);
70
94
  i = lt;
71
- if (raw) {
72
- const close2 = buf.slice(lt, lt + raw.length + 2).toLowerCase();
73
- if (close2.length < raw.length + 2 && !end) break;
74
- if (close2 === `</${raw}`) raw = null;
75
- else {
76
- text += "<";
77
- i = lt + 1;
78
- continue;
79
- }
80
- }
81
95
  if (!end && buf.length - lt < 4 && "<!--".startsWith(buf.slice(lt))) break;
82
96
  if (buf.startsWith("<!--", lt)) {
83
97
  const stop = buf.indexOf("-->", lt + 4);
84
98
  if (stop < 0) {
85
- if (!end) break;
86
- text += buf.slice(lt);
87
- i = buf.length;
99
+ if (end) i = buf.length;
88
100
  break;
89
101
  }
90
- text += buf.slice(lt, stop + 3);
91
102
  i = stop + 3;
92
103
  continue;
93
104
  }
94
- const m = /^<(\/?)([a-zA-Z][^\s/>]*)/.exec(buf.slice(lt, lt + 64));
95
- if (!m) {
105
+ const closing = buf.charCodeAt(lt + 1) === 47;
106
+ const at = lt + (closing ? 2 : 1);
107
+ if (!letter(buf.charCodeAt(at))) {
96
108
  if (buf.length - lt < 3 && !end) break;
97
- text += "<";
98
109
  i = lt + 1;
99
110
  continue;
100
111
  }
101
- const close = findTagEnd(buf, lt);
112
+ let k = at + 1;
113
+ while (k < buf.length && !nameEnd(buf.charCodeAt(k))) k++;
114
+ const close = tagEnd(buf, k);
102
115
  if (close < 0) {
103
- if (!end) break;
104
- text += buf.slice(lt);
105
- i = buf.length;
116
+ if (end) i = buf.length;
106
117
  break;
107
118
  }
108
- const source = buf.slice(lt, close + 1);
109
119
  i = close + 1;
110
- const name = m[2].toLowerCase();
111
- if (m[1]) {
120
+ const name = buf.slice(at, k).toLowerCase();
121
+ if (closing) {
112
122
  if (depth > 0 && !VOID.has(name)) depth--;
113
123
  else if (depth === 0 && name === tag) depth = -1;
114
- text += source;
115
124
  continue;
116
125
  }
117
126
  if (RAW.has(name)) raw = name;
118
- const selfClosing = source.endsWith("/>") || VOID.has(name);
127
+ const selfClosing = buf.charCodeAt(close - 1) === 47 || VOID.has(name);
119
128
  if (depth < 0 && wanted.has(name)) {
120
129
  tag = name;
121
- const el = new Tag(name, source);
130
+ const el = new Tag(name, buf.slice(lt, close + 1));
122
131
  const r = handlers.element(el);
132
+ take(lt);
123
133
  if (r) flush(), await r;
124
134
  text += el;
135
+ from = i;
125
136
  if (!selfClosing) depth = 0;
126
137
  continue;
127
138
  }
128
139
  if (depth === 0 && handlers.child) {
129
- const el = new Tag(name, source);
140
+ const el = new Tag(name, buf.slice(lt, close + 1));
130
141
  handlers.child(el);
142
+ take(lt);
131
143
  text += el;
132
- } else text += source;
144
+ from = i;
145
+ }
133
146
  if (depth >= 0 && !selfClosing) depth++;
134
147
  }
148
+ take(i);
135
149
  buf = buf.slice(i);
136
150
  flush();
137
151
  }
@@ -149,17 +163,25 @@ function rewrite(body, tags, handlers) {
149
163
  })
150
164
  );
151
165
  }
152
- function findTagEnd(s, start) {
153
- let quote = "";
154
- for (let i = start + 1; i < s.length; i++) {
155
- const c = s[i];
156
- if (quote) {
157
- if (c === quote) quote = "";
158
- } else if (c === '"' || c === "'") quote = c;
159
- else if (c === ">") return i;
166
+ var letter = (c) => (c | 32) >= 97 && (c | 32) <= 122;
167
+ var nameEnd = (c) => c === 62 || c === 47 || c === 32 || c >= 9 && c <= 13 || c === 160 || c === 5760 || c === 65279 || c > 8191 && /\s/.test(String.fromCharCode(c));
168
+ function tagEnd(s, from) {
169
+ for (let i = from; i < s.length; i++) {
170
+ const c = s.charCodeAt(i);
171
+ if (c === 62) return i;
172
+ if (c === 34 || c === 39) {
173
+ i = s.indexOf(c === 34 ? '"' : "'", i + 1);
174
+ if (i < 0) return -1;
175
+ }
160
176
  }
161
177
  return -1;
162
178
  }
179
+ var ends = /* @__PURE__ */ new Map();
180
+ var rawEnd = (name) => {
181
+ let re = ends.get(name);
182
+ if (!re) ends.set(name, re = new RegExp(`</${name}`, "gi"));
183
+ return re;
184
+ };
163
185
 
164
186
  // src/edge.ts
165
187
  var STALE = ["content-encoding", "content-length", "transfer-encoding", "connection", "keep-alive"];
@@ -222,9 +244,10 @@ function gateway(options) {
222
244
  if (!r || !m) return [];
223
245
  const { abs } = paths(r, m);
224
246
  const own = (m.dedupe ?? []).flatMap((d) => [...d.chunks ?? [], d.file]);
225
- const js = m.split ? [.../* @__PURE__ */ new Set([m.split.entry, ...m.split.chunks ?? [], ...own])] : [m.entry];
247
+ const js = m.split ? ordered([.../* @__PURE__ */ new Set([m.split.entry, ...m.split.chunks ?? [], ...own])], m.split.order) : [m.entry];
248
+ const crit = critical(m);
226
249
  const hashed = !!m.integrity || Object.keys(m.files ?? {}).length > 0;
227
- const out = js.map((u) => `<${local(r, abs(u))}>; ${hashed ? "rel=preload; as=fetch; crossorigin=anonymous" : "rel=modulepreload"}`);
250
+ const out = js.map((u) => `<${local(r, abs(u))}>; ${hashed ? "rel=preload; as=fetch; crossorigin=anonymous" : "rel=modulepreload"}${crit.has(u) ? "; fetchpriority=high" : ""}`);
228
251
  for (const u of m.css ?? []) out.push(`<${local(r, abs(u))}>; rel=preload; as=${isolate === "shadow" ? "fetch" : "style"}; crossorigin=anonymous`);
229
252
  return out;
230
253
  }
@@ -292,16 +315,16 @@ function gateway(options) {
292
315
  );
293
316
  return new Response(body, { status: res.status, statusText: res.statusText, headers });
294
317
  }
295
- async function markup(r, m, label, html, isolate) {
318
+ async function markup(r, m, label, rendered, isolate) {
296
319
  const { abs, sri } = paths(r, m);
297
320
  const name = escapeAttr(label);
298
321
  const scope = m.scope ? ` data-vitral-scope="${escapeAttr(m.scope)}"` : "";
299
- const root = `<div data-vitral-root="${name}"${scope} style="display:contents">${html}</div>`;
300
- const json = JSON.stringify(relocate(m, (u) => /^https?:\/\//.test(u) ? local(r, u) : u)).replace(/</g, "\\u003c");
301
- const seed = `<script type="application/json" data-vitral-manifest="${escapeAttr(local(r, r.url))}">${json}</script>`;
322
+ const root = `<div data-vitral-root="${name}"${scope} style="display:contents">${htmlOf(rendered)}</div>`;
323
+ const relocated = relocate(m, (u) => /^https?:\/\//.test(u) ? local(r, u) : u);
324
+ const seed = `<script type="application/json" data-vitral-manifest="${escapeAttr(local(r, r.url))}">${inlineJson(relocated)}</script>${stateScript(rendered)}`;
302
325
  const css = (m.css ?? []).map(abs);
303
326
  const link = (u) => `<link rel="stylesheet" href="${escapeAttr(local(r, u))}" crossorigin="anonymous"${sri[u] ? ` integrity="${escapeAttr(sri[u])}"` : ""}>`;
304
- if (isolate === "none") return `<div data-vitral-ssr data-vitral-slot="${name}">${seed}${css.map(link).join("")}${root}</div>`;
327
+ if (isolate === "none") return ssrHolder(label, m, rendered, css.map((u) => [local(r, u), sri[u]]), [local(r, r.url), relocated]);
305
328
  const s = m.shadow;
306
329
  const files = s && css[0] ? s.css.map((u) => new URL(u, css[0]).href) : css;
307
330
  const global = s && css[0] ? (s.global ?? []).map((u) => new URL(u, css[0]).href) : [];
package/dist/element.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as Props, S as Shared, a as RemoteModule } from './types-g8WEVD_b.js';
2
- import { S as SlotStatus } from './slot-DRYmGvvV.js';
1
+ import { P as Props, S as Shared, a as RemoteModule } from './types-DJautV-K.js';
2
+ import { S as SlotStatus } from './slot--WLgdcW_.js';
3
3
  import './errors-kjBv6IH_.js';
4
4
 
5
5
  /**
@@ -37,7 +37,7 @@ import './errors-kjBv6IH_.js';
37
37
  declare const Base: typeof HTMLElement;
38
38
  declare class VitralRemoteElement extends Base {
39
39
  #private;
40
- static observedAttributes: string[];
40
+ static get observedAttributes(): string[];
41
41
  get props(): Props;
42
42
  set props(value: Props);
43
43
  get status(): SlotStatus;
package/dist/element.js CHANGED
@@ -3,15 +3,18 @@ import {
3
3
  VitralRemoteElement,
4
4
  defineVitralElement,
5
5
  elementRemote
6
- } from "./chunk-CFJC4GRB.js";
7
- import "./chunk-WAU6OKK3.js";
8
- import "./chunk-VTGHPX4J.js";
6
+ } from "./chunk-SVYL6UCB.js";
7
+ import "./chunk-2SAI6S2H.js";
8
+ import "./chunk-6JH2I65O.js";
9
+ import "./chunk-AL6MLNVY.js";
10
+ import "./chunk-MICF64AZ.js";
11
+ import "./chunk-IKCEA3YN.js";
12
+ import "./chunk-GGMM56TM.js";
13
+ import "./chunk-BQGVAXFM.js";
14
+ import "./chunk-JWDDXX5O.js";
15
+ import "./chunk-2Z4OH3BP.js";
16
+ import "./chunk-4E33RZMM.js";
9
17
  import "./chunk-EQZOJU3B.js";
10
- import "./chunk-EVVYV5ED.js";
11
- import "./chunk-MGG5BW3U.js";
12
- import "./chunk-SC2KF7GJ.js";
13
- import "./chunk-TW7KYJQ6.js";
14
- import "./chunk-463H6B56.js";
15
18
  import "./chunk-GNPFWISJ.js";
16
19
  import "./chunk-MLKGABMK.js";
17
20
  export {