vitral 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +210 -195
- package/dist/angular.d.ts +2 -2
- package/dist/angular.js +11 -10
- package/dist/auto.js +16 -10
- package/dist/{capture-2I5IQ2C2.js → capture-5TUYE67Q.js} +3 -2
- package/dist/{channel-BHOVSU5X.js → channel-LW7J2VLA.js} +7 -4
- package/dist/{chunk-UCFOXMOR.js → chunk-24GEJNHQ.js} +6 -3
- package/dist/{chunk-LITYI5X7.js → chunk-3VYMK53Z.js} +4 -4
- package/dist/{chunk-YDO7SPF4.js → chunk-6EFYG6N7.js} +4 -4
- package/dist/{chunk-DSOK3BNO.js → chunk-7VQLAFIO.js} +45 -14
- package/dist/{chunk-6XXPGS5Q.js → chunk-GAVXPS5X.js} +33 -24
- package/dist/{chunk-GB3J6I2T.js → chunk-JRZ7FNAE.js} +10 -8
- package/dist/{chunk-B7LKO4HS.js → chunk-KA2SH4FH.js} +7 -4
- package/dist/chunk-M7AYWO4W.js +13 -0
- package/dist/{chunk-VDVVEGAO.js → chunk-NDB5GJMS.js} +9 -6
- package/dist/{chunk-54CBIZES.js → chunk-P2RSLXEB.js} +16 -4
- package/dist/{chunk-OKXLOMAG.js → chunk-PHVXXDWT.js} +1 -1
- package/dist/{chunk-5JNG3OG5.js → chunk-QIGE3XYA.js} +2 -2
- package/dist/{chunk-EQZOJU3B.js → chunk-RKYDVK2P.js} +1 -1
- package/dist/{chunk-BQGVAXFM.js → chunk-U4QBQQQJ.js} +7 -3
- package/dist/{chunk-F5USJIBT.js → chunk-UMSDTGTI.js} +16 -12
- package/dist/{chunk-GNPFWISJ.js → chunk-VKY4TKRT.js} +13 -2
- package/dist/{chunk-SQ46TAP4.js → chunk-YF7HTZMX.js} +8 -5
- package/dist/cli.js +5 -5
- package/dist/contract-YNLXHJL7.js +97 -0
- package/dist/devtools.js +2 -2
- package/dist/edge.d.ts +1 -1
- package/dist/element.d.ts +2 -2
- package/dist/element.js +11 -10
- package/dist/embed.js +2 -2
- package/dist/{events-XXC4si92.d.ts → events-C7OtGkNT.d.ts} +1 -1
- package/dist/expose-ZDAACD24.js +19 -0
- package/dist/federation.d.ts +1 -1
- package/dist/{hydrate-QPVDJHM7.js → hydrate-GRYEYDGZ.js} +13 -10
- package/dist/{i18n-TMQBOCPP.js → i18n-S5XJHITJ.js} +6 -5
- package/dist/i18n.d.ts +1 -10
- package/dist/i18n.js +6 -5
- package/dist/iframe.js +15 -12
- package/dist/index.d.ts +14 -6
- package/dist/index.js +11 -8
- package/dist/{loader-vj8m2GQU.d.ts → loader-BWTfd89w.d.ts} +1 -1
- package/dist/next-config.d.ts +1 -1
- package/dist/next-host.d.ts +3 -3
- package/dist/next-host.js +14 -13
- package/dist/next-server.d.ts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/{overrides-5BGODLCO.js → overrides-VDR33GS7.js} +2 -2
- package/dist/preact.d.ts +4 -4
- package/dist/preact.js +12 -10
- package/dist/prefetch.js +8 -7
- package/dist/react-server.d.ts +1 -1
- package/dist/react.d.ts +4 -4
- package/dist/react.js +11 -10
- package/dist/{reframe-IV36WJRO.js → reframe-SQLGQC6U.js} +19 -16
- package/dist/routes.d.ts +2 -2
- package/dist/routes.js +10 -9
- package/dist/{shadow-ABRO7JNY.js → shadow-H3CCEKCL.js} +5 -4
- package/dist/single-spa.d.ts +1 -1
- package/dist/{slot-CxhuVuka.d.ts → slot-BNPG3hc0.d.ts} +1 -1
- package/dist/snapshot.js +1 -1
- package/dist/solid.d.ts +3 -3
- package/dist/solid.js +14 -11
- package/dist/sri-XXWEYDFN.js +18 -0
- package/dist/svelte.d.ts +4 -4
- package/dist/svelte.js +10 -9
- package/dist/sw.d.ts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +9 -8
- package/dist/{types-cSsvpvgE.d.ts → types-L-qRmgLw.d.ts} +29 -2
- package/dist/vitals.js +3 -2
- package/dist/vite.js +1 -0
- package/dist/vue.d.ts +6 -6
- package/dist/vue.js +12 -10
- package/package.json +22 -22
- package/dist/contract-3JY7SOGQ.js +0 -18
- package/dist/expose-4CIS6AKL.js +0 -18
- package/dist/sri-Z5U32IR2.js +0 -17
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RemoteError,
|
|
3
3
|
isRemoteError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-U4QBQQQJ.js";
|
|
5
|
+
import {
|
|
6
|
+
tr
|
|
7
|
+
} from "./chunk-M7AYWO4W.js";
|
|
5
8
|
import {
|
|
6
9
|
protocol
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VKY4TKRT.js";
|
|
8
11
|
|
|
9
12
|
// src/core/util.ts
|
|
10
13
|
function pageOrigin() {
|
|
@@ -32,7 +35,7 @@ async function withRetry(retries, fn) {
|
|
|
32
35
|
}
|
|
33
36
|
function withTimeout(ms, name, p) {
|
|
34
37
|
return new Promise((resolve, reject) => {
|
|
35
|
-
const t = setTimeout(() => reject(new RemoteError("TIMEOUT", name, `n\xE3o respondeu em ${ms}ms`)), ms);
|
|
38
|
+
const t = setTimeout(() => reject(new RemoteError("TIMEOUT", name, tr(`n\xE3o respondeu em ${ms}ms`, `no response in ${ms}ms`))), ms);
|
|
36
39
|
p.then(resolve, reject).finally(() => clearTimeout(t));
|
|
37
40
|
});
|
|
38
41
|
}
|
|
@@ -40,11 +43,11 @@ function fetchBytes(url, timeout, name, init) {
|
|
|
40
43
|
const ctrl = new AbortController();
|
|
41
44
|
const got = fetch(url, { signal: ctrl.signal, credentials: "omit", ...init }).then(
|
|
42
45
|
(res) => {
|
|
43
|
-
if (!res.ok) throw new RemoteError("LOAD_FAILED", name, `HTTP ${res.status} em ${url}`);
|
|
46
|
+
if (!res.ok) throw new RemoteError("LOAD_FAILED", name, tr(`HTTP ${res.status} em ${url}`, `HTTP ${res.status} at ${url}`));
|
|
44
47
|
return res.arrayBuffer();
|
|
45
48
|
},
|
|
46
49
|
(e) => {
|
|
47
|
-
throw new RemoteError("LOAD_FAILED", name, `falha ao baixar ${url}`, e);
|
|
50
|
+
throw new RemoteError("LOAD_FAILED", name, tr(`falha ao baixar ${url}`, `failed to fetch ${url}`), e);
|
|
48
51
|
}
|
|
49
52
|
);
|
|
50
53
|
return withTimeout(timeout, name, got).catch((e) => {
|
|
@@ -57,7 +60,7 @@ async function fetchJson(url, timeout, name, init) {
|
|
|
57
60
|
try {
|
|
58
61
|
return JSON.parse(text);
|
|
59
62
|
} catch (e) {
|
|
60
|
-
throw new RemoteError("INVALID_MODULE", name, `JSON inv\xE1lido em ${url}`, e);
|
|
63
|
+
throw new RemoteError("INVALID_MODULE", name, tr(`JSON inv\xE1lido em ${url}`, `invalid JSON at ${url}`), e);
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
function addLink(rel, href, props = {}, parent = document.head) {
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
protocol
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VKY4TKRT.js";
|
|
4
4
|
|
|
5
5
|
// src/core/overrides.ts
|
|
6
6
|
var OVERRIDES_KEY = "vitral:overrides";
|
|
7
|
+
var LOCAL = /^(localhost|127\.0\.0\.1|\[::1\])$/;
|
|
7
8
|
function overridesEnabled() {
|
|
8
|
-
return !!protocol().settings().devOverrides || typeof location !== "undefined" &&
|
|
9
|
+
return !!protocol().settings().devOverrides || typeof location !== "undefined" && LOCAL.test(location.hostname);
|
|
10
|
+
}
|
|
11
|
+
function fromPreview(preview, url) {
|
|
12
|
+
const origin = new URL(preview.replace(/\{name\}/g, "vitralname").replace(/\{ref\}/g, "vitralref"), location.href).origin;
|
|
13
|
+
const pattern = origin.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/vitral(name|ref)/g, "[\\w-]+");
|
|
14
|
+
return new RegExp(`^${pattern}$`).test(new URL(url).origin);
|
|
9
15
|
}
|
|
10
16
|
var manifestUrl = (url) => /\.(json|m?js)(\?|$)/.test(url) ? url : url.replace(/\/?$/, "/vitral.json");
|
|
11
17
|
var isRef = (value) => /^[\w.-]+$/.test(value);
|
|
@@ -57,9 +63,12 @@ function dropOverride(name) {
|
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
function resolveOverride(name, value) {
|
|
60
|
-
if (!isRef(value)) return new URL(manifestUrl(value), location.href).href;
|
|
61
66
|
const d = protocol().settings().devOverrides;
|
|
62
67
|
const preview = typeof d === "object" ? d.preview : void 0;
|
|
68
|
+
if (!isRef(value)) {
|
|
69
|
+
const url2 = new URL(manifestUrl(value), location.href);
|
|
70
|
+
return typeof d !== "object" || LOCAL.test(url2.hostname) || preview && fromPreview(preview, url2.href) ? url2.href : void 0;
|
|
71
|
+
}
|
|
63
72
|
if (!preview) return;
|
|
64
73
|
const url = preview.replace(/\{name\}/g, encodeURIComponent(name)).replace(/\{ref\}/g, encodeURIComponent(value));
|
|
65
74
|
return new URL(manifestUrl(url), location.href).href;
|
|
@@ -79,7 +88,10 @@ function overrideFor(name) {
|
|
|
79
88
|
if (!o) return;
|
|
80
89
|
const first = !warned.has(name) && warned.add(name);
|
|
81
90
|
if (!o.url) {
|
|
82
|
-
if (first)
|
|
91
|
+
if (first)
|
|
92
|
+
console.warn(
|
|
93
|
+
isRef(o.value) ? `[vitral] override ${name}@${o.value} ignorado: falta configure({ devOverrides: { preview } })` : `[vitral] override ${name}@${o.value} ignorado: com devOverrides: { preview }, s\xF3 valem apelidos, localhost e URLs do modelo. Use devOverrides: true para aceitar qualquer URL.`
|
|
94
|
+
);
|
|
83
95
|
return;
|
|
84
96
|
}
|
|
85
97
|
const p = protocol();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/core/bundled.ts
|
|
2
2
|
var bundled = {};
|
|
3
3
|
var dedupeModule = () => bundled.dedupe ? Promise.resolve(bundled.dedupe) : import("./dedupe-M63VMCWA.js");
|
|
4
|
-
var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-
|
|
4
|
+
var sriModule = () => bundled.sri ? Promise.resolve(bundled.sri) : import("./sri-XXWEYDFN.js");
|
|
5
5
|
|
|
6
6
|
export {
|
|
7
7
|
bundled,
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPt
|
|
3
|
+
} from "./chunk-M7AYWO4W.js";
|
|
1
4
|
import {
|
|
2
5
|
ctxHooks
|
|
3
6
|
} from "./chunk-JWDDXX5O.js";
|
|
4
7
|
import {
|
|
5
8
|
protocol
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VKY4TKRT.js";
|
|
7
10
|
|
|
8
11
|
// src/core/errors.ts
|
|
9
12
|
var ERROR_DOCS = "https://joaogabriel15.github.io/vitral/erros/";
|
|
10
13
|
var RemoteError = class extends Error {
|
|
11
14
|
constructor(code, remote, message, cause) {
|
|
12
|
-
|
|
15
|
+
const docs = (isPt() ? ERROR_DOCS : ERROR_DOCS.replace("/erros/", "/en/erros/")) + code;
|
|
16
|
+
super(`[vitral] ${remote}: ${message} (${docs})`);
|
|
13
17
|
this.code = code;
|
|
14
18
|
this.remote = remote;
|
|
15
19
|
this.cause = cause;
|
|
16
20
|
this.name = "RemoteError";
|
|
17
|
-
this.docs =
|
|
21
|
+
this.docs = docs;
|
|
18
22
|
if (typeof location != "undefined") this.route = location.pathname;
|
|
19
23
|
}
|
|
20
24
|
};
|
|
@@ -6,26 +6,27 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
hostSlot,
|
|
8
8
|
when
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QIGE3XYA.js";
|
|
10
10
|
import {
|
|
11
11
|
defineRemote,
|
|
12
12
|
memoSelect,
|
|
13
|
+
messages,
|
|
13
14
|
same,
|
|
14
15
|
shared
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-7VQLAFIO.js";
|
|
16
17
|
import {
|
|
17
18
|
policy,
|
|
18
19
|
preload
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GAVXPS5X.js";
|
|
20
21
|
import {
|
|
21
22
|
dedupeModule
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PHVXXDWT.js";
|
|
23
24
|
import {
|
|
24
25
|
events
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RKYDVK2P.js";
|
|
26
27
|
import {
|
|
27
28
|
protocol
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-VKY4TKRT.js";
|
|
29
30
|
|
|
30
31
|
// src/react.tsx
|
|
31
32
|
import {
|
|
@@ -137,11 +138,14 @@ function preload2(name, options) {
|
|
|
137
138
|
offerReact();
|
|
138
139
|
preload(name, options);
|
|
139
140
|
}
|
|
140
|
-
var defaultError = (retry) =>
|
|
141
|
-
|
|
142
|
-
" ",
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
var defaultError = (retry) => {
|
|
142
|
+
const m = messages();
|
|
143
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", "data-vitral-default": "error", children: [
|
|
144
|
+
m.error,
|
|
145
|
+
" ",
|
|
146
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: retry, children: m.retry })
|
|
147
|
+
] });
|
|
148
|
+
};
|
|
145
149
|
function Remote({
|
|
146
150
|
name,
|
|
147
151
|
src,
|
|
@@ -192,7 +196,7 @@ function Remote({
|
|
|
192
196
|
let dead = false;
|
|
193
197
|
let s = null;
|
|
194
198
|
if (holder) {
|
|
195
|
-
const go = () => import("./hydrate-
|
|
199
|
+
const go = () => import("./hydrate-GRYEYDGZ.js").then((m) => {
|
|
196
200
|
if (!dead) slot.current = s = m.hydrateSlot(target.current, holder, { ...options, props: latest.current ?? {} });
|
|
197
201
|
});
|
|
198
202
|
const stop = policy() === "lazy" ? when(target.current, "visible", go) : (go(), () => {
|
|
@@ -34,6 +34,7 @@ function createProtocol() {
|
|
|
34
34
|
const entries = /* @__PURE__ */ new Map();
|
|
35
35
|
const modules = /* @__PURE__ */ new Map();
|
|
36
36
|
let ready = Promise.resolve();
|
|
37
|
+
const again = [];
|
|
37
38
|
return {
|
|
38
39
|
protocol: PROTOCOL,
|
|
39
40
|
events: createEventBus(),
|
|
@@ -46,12 +47,22 @@ function createProtocol() {
|
|
|
46
47
|
modules.delete(name);
|
|
47
48
|
},
|
|
48
49
|
entry: (name) => entries.get(name),
|
|
49
|
-
origins: () => [...entries.values()].filter((e) => e.url).map((e) => new URL(e.url).origin),
|
|
50
|
+
origins: () => [...entries.values()].filter((e) => e.url && !e.untrusted).map((e) => new URL(e.url).origin),
|
|
50
51
|
pending(p) {
|
|
51
52
|
if (p) ready = Promise.all([ready, p]);
|
|
52
|
-
return ready.then(() => {
|
|
53
|
+
return Promise.all([ready, ...again.map((f) => f())]).then(() => {
|
|
53
54
|
});
|
|
54
55
|
},
|
|
56
|
+
pendingRetry(run) {
|
|
57
|
+
let failed = false;
|
|
58
|
+
const go = () => {
|
|
59
|
+
const p = run();
|
|
60
|
+
p.catch(() => failed = true);
|
|
61
|
+
return p;
|
|
62
|
+
};
|
|
63
|
+
let last = go();
|
|
64
|
+
again.push(() => failed ? (failed = false, last = go()) : last);
|
|
65
|
+
},
|
|
55
66
|
load(name, fetcher) {
|
|
56
67
|
let p = modules.get(name);
|
|
57
68
|
if (!p) {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mountable
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GAVXPS5X.js";
|
|
4
4
|
import {
|
|
5
5
|
RemoteError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-U4QBQQQJ.js";
|
|
7
|
+
import {
|
|
8
|
+
tr
|
|
9
|
+
} from "./chunk-M7AYWO4W.js";
|
|
7
10
|
import {
|
|
8
11
|
protocol
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VKY4TKRT.js";
|
|
10
13
|
|
|
11
14
|
// src/core/expose.ts
|
|
12
15
|
function splitName(name) {
|
|
@@ -26,7 +29,7 @@ function resolveAny(name, loadFile) {
|
|
|
26
29
|
if (!key) return loadFile(name);
|
|
27
30
|
const r = await loadFile(remote);
|
|
28
31
|
const table = r.exports?.exposes;
|
|
29
|
-
if (!table?.[key]) throw new RemoteError("NOT_EXPOSED", name, `${remote} n\xE3o exp\xF5e ${key}. Expostos: ${Object.keys(table ?? {}).join(", ")}`);
|
|
32
|
+
if (!table?.[key]) throw new RemoteError("NOT_EXPOSED", name, tr(`${remote} n\xE3o exp\xF5e ${key}. Expostos: ${Object.keys(table ?? {}).join(", ")}`, `${remote} does not expose ${key}. Exposed: ${Object.keys(table ?? {}).join(", ")}`));
|
|
30
33
|
try {
|
|
31
34
|
const value = table[key];
|
|
32
35
|
const ns = await (typeof value == "function" ? value() : value);
|
|
@@ -39,7 +42,7 @@ function resolveAny(name, loadFile) {
|
|
|
39
42
|
async function resolveModule(name, loadFile) {
|
|
40
43
|
const r = await resolveAny(name, loadFile);
|
|
41
44
|
if (!r.exports) {
|
|
42
|
-
throw new RemoteError("INVALID_MODULE", name, "o remote foi carregado por uma c\xF3pia antiga da lib, que n\xE3o guarda os exports");
|
|
45
|
+
throw new RemoteError("INVALID_MODULE", name, tr("o remote foi carregado por uma c\xF3pia antiga da lib, que n\xE3o guarda os exports", "the remote was loaded by an old copy of the lib, which does not keep exports"));
|
|
43
46
|
}
|
|
44
47
|
return r.exports;
|
|
45
48
|
}
|
package/dist/cli.js
CHANGED
|
@@ -531,7 +531,7 @@ import { dirname as dirname2, join as join2, resolve as resolve3 } from "path";
|
|
|
531
531
|
import { gzipSync } from "zlib";
|
|
532
532
|
var WARN_KB = 250;
|
|
533
533
|
var ANY_ORIGIN = "https://host.invalid";
|
|
534
|
-
var
|
|
534
|
+
var satisfiesRange;
|
|
535
535
|
var ok = (title) => ({ status: "ok", title });
|
|
536
536
|
var warn = (title, cause, fix) => ({ status: "warn", title, cause, fix });
|
|
537
537
|
var error = (title, cause, fix) => ({ status: "error", title, cause, fix });
|
|
@@ -811,7 +811,7 @@ async function checkRemote(name, e, ctx, seen) {
|
|
|
811
811
|
else if (files2.length) out.push(ok(`${files2.length} arquivo(s) do manifesto conferem com o hash`));
|
|
812
812
|
const range = e.contract ?? ctx.contract;
|
|
813
813
|
if (m.contract?.version && range) {
|
|
814
|
-
if (
|
|
814
|
+
if (satisfiesRange(m.contract.version, range)) out.push(ok(`contrato ${m.contract.version} na faixa ${range} do host`));
|
|
815
815
|
else
|
|
816
816
|
out.push(
|
|
817
817
|
error(
|
|
@@ -825,7 +825,7 @@ async function checkRemote(name, e, ctx, seen) {
|
|
|
825
825
|
for (const [dep, want] of Object.entries(m.contract?.peers ?? {})) {
|
|
826
826
|
const have = ctx.deps[dep];
|
|
827
827
|
if (!have) continue;
|
|
828
|
-
if (
|
|
828
|
+
if (satisfiesRange(have, want)) out.push(ok(`${dep} ${have} do host serve para o remote (${want})`));
|
|
829
829
|
else
|
|
830
830
|
out.push(
|
|
831
831
|
(range ? error : warn)(
|
|
@@ -844,7 +844,7 @@ function divergent(seen, deps) {
|
|
|
844
844
|
const out = [];
|
|
845
845
|
for (const [dep, list] of groups) {
|
|
846
846
|
const candidates = [deps[dep], ...list.map((l) => l.version)].filter((v) => !!v);
|
|
847
|
-
if (list.length < 2 || candidates.some((v) => list.every((l) =>
|
|
847
|
+
if (list.length < 2 || candidates.some((v) => list.every((l) => satisfiesRange(v, l.range)))) continue;
|
|
848
848
|
out.push(
|
|
849
849
|
warn(
|
|
850
850
|
`${dep} em vers\xF5es divergentes: ${list.map((l) => `${l.who} ${l.range}`).join(", ")}`,
|
|
@@ -867,7 +867,7 @@ async function remotesOf(o, f, cwd, timeout) {
|
|
|
867
867
|
}
|
|
868
868
|
async function doctor(options = {}) {
|
|
869
869
|
;
|
|
870
|
-
({
|
|
870
|
+
({ satisfiesRange } = await import("./contract-YNLXHJL7.js"));
|
|
871
871
|
const cwd = options.cwd ?? process.cwd();
|
|
872
872
|
const f = options.fetch ?? fetch;
|
|
873
873
|
const timeout = options.timeout ?? 15e3;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tr
|
|
3
|
+
} from "./chunk-M7AYWO4W.js";
|
|
4
|
+
import {
|
|
5
|
+
protocol
|
|
6
|
+
} from "./chunk-VKY4TKRT.js";
|
|
7
|
+
import "./chunk-MLKGABMK.js";
|
|
8
|
+
|
|
9
|
+
// src/core/range.ts
|
|
10
|
+
function satisfiesRange(version, range) {
|
|
11
|
+
const v = parts(version);
|
|
12
|
+
if (!v) return false;
|
|
13
|
+
const alts = range.split("||");
|
|
14
|
+
if (version.includes("-")) return alts.some((a) => a.trim().replace(/^[=v]+/, "") === version.replace(/^v/, ""));
|
|
15
|
+
const at = pad(v);
|
|
16
|
+
return alts.some((a) => {
|
|
17
|
+
const tests = alternative(a);
|
|
18
|
+
return !!tests && tests.every((t) => t(at));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function validRange(range) {
|
|
22
|
+
return range.split("||").every((a) => !!alternative(a));
|
|
23
|
+
}
|
|
24
|
+
var cmp = (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
|
|
25
|
+
var pad = (n) => [n[0] ?? 0, n[1] ?? 0, n[2] ?? 0];
|
|
26
|
+
var up = (n, i) => pad([...n.slice(0, i), n[i] + 1]);
|
|
27
|
+
function parts(s) {
|
|
28
|
+
const m = /^[=v]*(?:(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-[\w.-]+)?(?:\+[\w.-]+)?)?$/.exec(s.trim());
|
|
29
|
+
if (!m) return null;
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const p of m.slice(1, 4)) {
|
|
32
|
+
if (p === void 0 || /[xX*]/.test(p)) break;
|
|
33
|
+
out.push(+p);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function alternative(a) {
|
|
38
|
+
const s = a.trim();
|
|
39
|
+
const hyphen = /^(\S+)\s+-\s+(\S+)$/.exec(s);
|
|
40
|
+
if (hyphen) {
|
|
41
|
+
const lo = parts(hyphen[1]);
|
|
42
|
+
const hi = parts(hyphen[2]);
|
|
43
|
+
if (!lo || !hi) return null;
|
|
44
|
+
return [(v) => cmp(v, pad(lo)) >= 0, hi.length === 3 ? (v) => cmp(v, pad(hi)) <= 0 : hi.length ? (v) => cmp(v, up(hi, hi.length - 1)) < 0 : () => true];
|
|
45
|
+
}
|
|
46
|
+
if (!s) return [() => true];
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const c of s.replace(/(\^|~>?|[<>]=?|=)\s+/g, "$1").split(/\s+/)) {
|
|
49
|
+
const t = comparator(c);
|
|
50
|
+
if (!t) return null;
|
|
51
|
+
out.push(t);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
function comparator(c) {
|
|
56
|
+
const [, op = "", rest] = /^(\^|~>?|>=|<=|>|<|=)?(.*)$/.exec(c);
|
|
57
|
+
const n = parts(rest);
|
|
58
|
+
if (!n) return null;
|
|
59
|
+
const k = n.length;
|
|
60
|
+
const lo = pad(n);
|
|
61
|
+
const between = (hi) => (v) => cmp(v, lo) >= 0 && cmp(v, hi) < 0;
|
|
62
|
+
if (!k) return op === "<" || op === ">" ? () => false : () => true;
|
|
63
|
+
switch (op) {
|
|
64
|
+
case "^":
|
|
65
|
+
return between(up(n, Math.max(0, n.findIndex((x, i) => x !== 0 || i === k - 1))));
|
|
66
|
+
case "~":
|
|
67
|
+
case "~>":
|
|
68
|
+
return between(up(n, k >= 2 ? 1 : 0));
|
|
69
|
+
case ">=":
|
|
70
|
+
return (v) => cmp(v, lo) >= 0;
|
|
71
|
+
case "<":
|
|
72
|
+
return (v) => cmp(v, lo) < 0;
|
|
73
|
+
case ">":
|
|
74
|
+
return k === 3 ? (v) => cmp(v, lo) > 0 : (v) => cmp(v, up(n, k - 1)) >= 0;
|
|
75
|
+
case "<=":
|
|
76
|
+
return k === 3 ? (v) => cmp(v, lo) <= 0 : (v) => cmp(v, up(n, k - 1)) < 0;
|
|
77
|
+
default:
|
|
78
|
+
return k === 3 ? (v) => cmp(v, lo) === 0 : between(up(n, k - 1));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/core/contract.ts
|
|
83
|
+
async function checkContract(c, range = protocol().settings().contract) {
|
|
84
|
+
const { satisfies } = await import("./dedupe-M63VMCWA.js");
|
|
85
|
+
if (!validRange(range))
|
|
86
|
+
return tr(`a faixa de contrato ${range} do host n\xE3o \xE9 uma faixa de vers\xE3o v\xE1lida (ex.: '^2', '^1 || ^2', '>=2 <4')`, `the host contract range ${range} is not a valid version range (e.g. '^2', '^1 || ^2', '>=2 <4')`);
|
|
87
|
+
if (c.version && !satisfiesRange(c.version, range)) return tr(`o host aceita contrato ${range}, o remote publica ${c.version}`, `the host accepts contract ${range}, the remote publishes ${c.version}`);
|
|
88
|
+
const offered = protocol().settings().offered ?? {};
|
|
89
|
+
for (const dep in c.peers) {
|
|
90
|
+
const have = offered[dep];
|
|
91
|
+
if (have && !satisfies(have, c.peers[dep])) return tr(`o remote espera ${dep} ${c.peers[dep]}, o host oferece ${have}`, `the remote expects ${dep} ${c.peers[dep]}, the host offers ${have}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
checkContract,
|
|
96
|
+
satisfiesRange
|
|
97
|
+
};
|
package/dist/devtools.js
CHANGED
package/dist/edge.d.ts
CHANGED
package/dist/element.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Props, S as Shared, a as RemoteModule } from './types-
|
|
2
|
-
import { S as SlotStatus } from './slot-
|
|
1
|
+
import { P as Props, S as Shared, a as RemoteModule } from './types-L-qRmgLw.js';
|
|
2
|
+
import { S as SlotStatus } from './slot-BNPG3hc0.js';
|
|
3
3
|
import './errors-kjBv6IH_.js';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/element.js
CHANGED
|
@@ -3,19 +3,20 @@ import {
|
|
|
3
3
|
VitralRemoteElement,
|
|
4
4
|
defineVitralElement,
|
|
5
5
|
elementRemote
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-JRZ7FNAE.js";
|
|
7
|
+
import "./chunk-QIGE3XYA.js";
|
|
8
|
+
import "./chunk-7VQLAFIO.js";
|
|
9
|
+
import "./chunk-GAVXPS5X.js";
|
|
10
|
+
import "./chunk-PHVXXDWT.js";
|
|
11
|
+
import "./chunk-6EFYG6N7.js";
|
|
12
|
+
import "./chunk-NDB5GJMS.js";
|
|
13
|
+
import "./chunk-U4QBQQQJ.js";
|
|
14
|
+
import "./chunk-M7AYWO4W.js";
|
|
14
15
|
import "./chunk-JWDDXX5O.js";
|
|
15
16
|
import "./chunk-2Z4OH3BP.js";
|
|
16
17
|
import "./chunk-4E33RZMM.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-RKYDVK2P.js";
|
|
19
|
+
import "./chunk-VKY4TKRT.js";
|
|
19
20
|
import "./chunk-MLKGABMK.js";
|
|
20
21
|
export {
|
|
21
22
|
SharedController,
|