@platforma-sdk/block-tools 2.12.13 → 2.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.
Files changed (69) hide show
  1. package/dist/cli.js +12 -12
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +804 -720
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/cmd/build-kind-manifest.d.ts +7 -0
  6. package/dist/config-CtXMWNgm.js +3 -0
  7. package/dist/config-CtXMWNgm.js.map +1 -0
  8. package/dist/{config-CiC347sB.mjs → config-Dx45aFJ_.mjs} +792 -456
  9. package/dist/config-Dx45aFJ_.mjs.map +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/index.mjs +15 -15
  12. package/dist/structure/engine/api.d.ts +1 -1
  13. package/dist/structure/rules/kind-package-json.d.ts +3 -0
  14. package/dist/structure/rules/kind.d.ts +1 -0
  15. package/dist/v2/build_kind_dist.d.ts +25 -0
  16. package/dist/v2/index.d.ts +4 -0
  17. package/dist/v2/kind/resolve-refs.d.ts +63 -0
  18. package/dist/v2/kind/version-match.d.ts +23 -0
  19. package/dist/v2/model/block_description.d.ts +8 -1
  20. package/dist/v2/publish-block.d.ts +23 -0
  21. package/dist/v2/registry/index.d.ts +2 -0
  22. package/dist/v2/registry/kind_resolver.d.ts +121 -0
  23. package/dist/v2/registry/registry.d.ts +23 -0
  24. package/dist/v2/registry/registry_reader.d.ts +34 -1
  25. package/dist/v2/registry/schema_kinds.d.ts +632 -0
  26. package/dist/v2/registry/schema_public.d.ts +72 -0
  27. package/package.json +9 -9
  28. package/src/cli.test.ts +2 -1
  29. package/src/cli.ts +2 -0
  30. package/src/cmd/build-kind-manifest.ts +41 -0
  31. package/src/cmd/publish.ts +10 -1
  32. package/src/cmd/software/build.ts +17 -1
  33. package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -0
  34. package/src/structure/engine/api.ts +1 -1
  35. package/src/structure/engine/ctx.ts +1 -0
  36. package/src/structure/engine/discovery.ts +16 -2
  37. package/src/structure/rules/block-package-json.ts +18 -0
  38. package/src/structure/rules/kind-package-json.ts +117 -0
  39. package/src/structure/rules/kind.ts +29 -0
  40. package/src/structure/rules/model-package-json.ts +8 -0
  41. package/src/structure/rules/model.ts +15 -13
  42. package/src/structure/rules/shared/pascal-case.ts +1 -1
  43. package/src/structure/structure-definition.ts +2 -0
  44. package/src/structure/templates/static/kind/.oxfmtrc.json +4 -0
  45. package/src/structure/templates/static/kind/.oxlintrc.json +3 -0
  46. package/src/structure/templates/static/kind/src/index.ts +49 -0
  47. package/src/structure/templates/static/kind/tsconfig.json +10 -0
  48. package/src/structure/templates/text/model/src/index.tpl.ts +18 -0
  49. package/src/v2/build_dist.ts +35 -0
  50. package/src/v2/build_kind_dist.ts +104 -0
  51. package/src/v2/from_pack_v2.test.ts +2 -2
  52. package/src/v2/index.ts +4 -0
  53. package/src/v2/kind/resolve-refs.ts +150 -0
  54. package/src/v2/kind/version-match.test.ts +60 -0
  55. package/src/v2/kind/version-match.ts +55 -0
  56. package/src/v2/model/block_description.ts +15 -4
  57. package/src/v2/publish-block.ts +60 -0
  58. package/src/v2/registry/index.ts +2 -0
  59. package/src/v2/registry/kind_resolver.test.ts +123 -0
  60. package/src/v2/registry/kind_resolver.ts +190 -0
  61. package/src/v2/registry/registry.test.ts +247 -1
  62. package/src/v2/registry/registry.ts +227 -4
  63. package/src/v2/registry/registry_reader.ts +68 -0
  64. package/src/v2/registry/schema_kinds.test.ts +65 -0
  65. package/src/v2/registry/schema_kinds.ts +169 -0
  66. package/dist/config-BmJWc8sR.js +0 -3
  67. package/dist/config-BmJWc8sR.js.map +0 -1
  68. package/dist/config-CiC347sB.mjs.map +0 -1
  69. package/src/structure/templates/static/model/src/index.ts +0 -13
@@ -5,46 +5,48 @@ import r from "node:fs/promises";
5
5
  import * as i from "mime-types";
6
6
  import * as a from "tar";
7
7
  import { tryResolve as o } from "@milaboratories/resolve-helper";
8
- import { AnyChannel as s, BlockPackDescriptionFromPackageJsonRaw as c, BlockPackDescriptionManifest as l, BlockPackIdNoVersion as u, BlockPackManifest as d, BlockPackManifestFile as f, SemVer as p, Sha256Schema as m, VersionWithChannels as h, addPrefixToRelative as g, blockPackIdNoVersionEquals as _, blockPackIdToString as v, mapRemoteToAbsolute as y } from "@milaboratories/pl-model-middle-layer";
9
- import { extractConfigGeneric as ee } from "@milaboratories/pl-model-common";
10
- import { gunzip as te, gunzipSync as ne, gzip as re } from "node:zlib";
11
- import { createHash as ie, randomUUID as ae } from "node:crypto";
12
- import { ConsoleLoggerAdapter as oe, Retry2TimesWithDelay as b, notEmpty as se, retry as x } from "@milaboratories/ts-helpers";
13
- import { fileURLToPath as ce } from "node:url";
14
- import { promisify as le } from "node:util";
8
+ import { AnyChannel as s, BlockPackDescriptionFromPackageJsonRaw as c, BlockPackDescriptionManifest as l, BlockPackId as u, BlockPackIdNoVersion as d, BlockPackManifest as f, BlockPackManifestFile as p, SemVer as m, Sha256Schema as h, StableChannel as g, VersionWithChannels as _, addPrefixToRelative as v, blockPackIdNoVersionEquals as y, blockPackIdToString as b, mapRemoteToAbsolute as ee } from "@milaboratories/pl-model-middle-layer";
9
+ import { extractConfigGeneric as te, formatKindRef as ne, parseKindRef as x } from "@milaboratories/pl-model-common";
10
+ import { gunzip as re, gunzipSync as ie, gzip as ae } from "node:zlib";
11
+ import { createHash as oe, randomUUID as se } from "node:crypto";
12
+ import { util as ce } from "@platforma-sdk/package-builder-lib";
13
+ import { createRequire as le } from "node:module";
15
14
  import { z as S } from "zod";
16
- import ue from "canonicalize";
17
- import { LRUCache as de } from "lru-cache";
18
- import C from "node:path/posix";
19
- import { S3 as fe, paginateListObjectsV2 as pe } from "@aws-sdk/client-s3";
20
- import { request as me } from "undici";
21
- import { defaultHttpDispatcher as he } from "@milaboratories/pl-http";
22
- import ge from "yaml";
23
- import * as _e from "node:os";
15
+ import { ConsoleLoggerAdapter as ue, Retry2TimesWithDelay as C, notEmpty as de, retry as w } from "@milaboratories/ts-helpers";
16
+ import { fileURLToPath as fe } from "node:url";
17
+ import { promisify as pe } from "node:util";
18
+ import me from "canonicalize";
19
+ import { LRUCache as he } from "lru-cache";
20
+ import T from "node:path/posix";
21
+ import { S3 as ge, paginateListObjectsV2 as _e } from "@aws-sdk/client-s3";
22
+ import { request as ve } from "undici";
23
+ import { defaultHttpDispatcher as ye } from "@milaboratories/pl-http";
24
+ import be from "yaml";
25
+ import * as xe from "node:os";
24
26
  //#region \0rolldown/runtime.js
25
- var ve = Object.create, w = Object.defineProperty, ye = Object.getOwnPropertyDescriptor, be = Object.getOwnPropertyNames, xe = Object.getPrototypeOf, Se = Object.prototype.hasOwnProperty, T = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), Ce = (e, t) => {
27
+ var Se = Object.create, E = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, we = Object.getOwnPropertyNames, Te = Object.getPrototypeOf, Ee = Object.prototype.hasOwnProperty, D = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), De = (e, t) => {
26
28
  let n = {};
27
- for (var r in e) w(n, r, {
29
+ for (var r in e) E(n, r, {
28
30
  get: e[r],
29
31
  enumerable: !0
30
32
  });
31
- return t || w(n, Symbol.toStringTag, { value: "Module" }), n;
32
- }, we = (e, t, n, r) => {
33
- if (t && typeof t == "object" || typeof t == "function") for (var i = be(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Se.call(e, s) && s !== n && w(e, s, {
33
+ return t || E(n, Symbol.toStringTag, { value: "Module" }), n;
34
+ }, Oe = (e, t, n, r) => {
35
+ if (t && typeof t == "object" || typeof t == "function") for (var i = we(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !Ee.call(e, s) && s !== n && E(e, s, {
34
36
  get: ((e) => t[e]).bind(null, s),
35
- enumerable: !(r = ye(t, s)) || r.enumerable
37
+ enumerable: !(r = Ce(t, s)) || r.enumerable
36
38
  });
37
39
  return e;
38
- }, Te = (e, t, n) => (n = e == null ? {} : ve(xe(e)), we(t || !e || !e.__esModule ? w(n, "default", {
40
+ }, ke = (e, t, n) => (n = e == null ? {} : Se(Te(e)), Oe(t || !e || !e.__esModule ? E(n, "default", {
39
41
  value: e,
40
42
  enumerable: !0
41
- }) : n, e)), Ee = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
43
+ }) : n, e)), Ae = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
42
44
  if (typeof require < "u") return require.apply(this, arguments);
43
45
  throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
44
46
  });
45
47
  //#endregion
46
48
  //#region src/v2/model/content_conversion.ts
47
- function De(e, t) {
49
+ function je(e, t) {
48
50
  let n = o(e, t);
49
51
  if (n === void 0) throw Error(`Can't resolve ${t} against ${e}`);
50
52
  return {
@@ -52,7 +54,7 @@ function De(e, t) {
52
54
  file: n
53
55
  };
54
56
  }
55
- function Oe(e, t, n) {
57
+ function Me(e, t, n) {
56
58
  let r = t.endsWith("/") ? t : `${t}/`;
57
59
  for (let t of n) {
58
60
  let n = o(e, r + t);
@@ -66,16 +68,16 @@ function Oe(e, t, n) {
66
68
  }
67
69
  throw Error(`Can't resolve ${t} folder against ${e}, no index file found (${n.join(", ")})`);
68
70
  }
69
- function ke(t) {
71
+ function Ne(t) {
70
72
  return (n) => n.type === "relative" ? {
71
73
  type: "absolute-file",
72
74
  file: e.resolve(t, n.path)
73
75
  } : n;
74
76
  }
75
- function Ae() {
77
+ function Pe() {
76
78
  return async (e) => e.type === "absolute-file" ? await r.readFile(e.file, { encoding: "utf-8" }) : e.content;
77
79
  }
78
- function je() {
80
+ function Fe() {
79
81
  return async (e) => {
80
82
  if (e.type === "absolute-file") {
81
83
  let t = i.lookup(e.file);
@@ -88,7 +90,7 @@ function je() {
88
90
  } else return e;
89
91
  };
90
92
  }
91
- function Me() {
93
+ function Ie() {
92
94
  return async (e) => {
93
95
  if (e.type === "absolute-file") {
94
96
  let t = i.lookup(e.file);
@@ -106,7 +108,7 @@ function Me() {
106
108
  else return e;
107
109
  };
108
110
  }
109
- function Ne(t, n) {
111
+ function Le(t, n) {
110
112
  return async (i) => {
111
113
  if (i.type === "absolute-file") {
112
114
  let a = e.basename(i.file), o = e.resolve(t, a);
@@ -117,7 +119,7 @@ function Ne(t, n) {
117
119
  } else return i;
118
120
  };
119
121
  }
120
- function Pe(t, n, r) {
122
+ function Re(t, n, r) {
121
123
  if (!n.endsWith(".tgz")) throw Error(`Unexpected tgz file name: ${n}`);
122
124
  return async (i) => {
123
125
  let o = e.resolve(t, n);
@@ -131,16 +133,16 @@ function Pe(t, n, r) {
131
133
  };
132
134
  };
133
135
  }
134
- function Fe(e) {
136
+ function ze(e) {
135
137
  return async (t) => t.type === "explicit-string" ? t : {
136
138
  type: "explicit-string",
137
139
  content: (await e(t.path)).toString("utf8")
138
140
  };
139
141
  }
140
- function Ie(e) {
142
+ function Be(e) {
141
143
  return async (t) => t.type === "explicit-string" ? t.content : (await e(t.path)).toString("utf8");
142
144
  }
143
- function Le(e) {
145
+ function Ve(e) {
144
146
  return async (t) => {
145
147
  if (t.type === "explicit-base64") return t;
146
148
  let n = i.lookup(t.path);
@@ -152,7 +154,7 @@ function Le(e) {
152
154
  };
153
155
  };
154
156
  }
155
- function Re(e) {
157
+ function He(e) {
156
158
  return async (t) => {
157
159
  if (t.type === "explicit-base64") return {
158
160
  type: "explicit-bytes",
@@ -170,7 +172,7 @@ function Re(e) {
170
172
  }
171
173
  //#endregion
172
174
  //#region src/v2/model/block_meta.ts
173
- async function E(e, t, n) {
175
+ async function O(e, t, n) {
174
176
  let { organization: r } = e, { logo: i, ...a } = r;
175
177
  return {
176
178
  ...e,
@@ -183,40 +185,40 @@ async function E(e, t, n) {
183
185
  ...e.logo === void 0 ? {} : { logo: await n(e.logo) }
184
186
  };
185
187
  }
186
- async function ze(e, t) {
187
- let n = ke(t);
188
- return E(e, async (e) => n(e), async (e) => n(e));
188
+ async function Ue(e, t) {
189
+ let n = Ne(t);
190
+ return O(e, async (e) => n(e), async (e) => n(e));
189
191
  }
190
- async function Be(e, t) {
191
- let n = ke(t);
192
- return E(e, async (e) => n(e), async (e) => n(e));
192
+ async function We(e, t) {
193
+ let n = Ne(t);
194
+ return O(e, async (e) => n(e), async (e) => n(e));
193
195
  }
194
- async function Ve(e, t, n) {
195
- let r = Ne(t, n);
196
- return E(e, async (e) => r(e), async (e) => r(e));
196
+ async function Ge(e, t, n) {
197
+ let r = Le(t, n);
198
+ return O(e, async (e) => r(e), async (e) => r(e));
197
199
  }
198
- async function He(e) {
199
- return E(e, Ae(), je());
200
+ async function Ke(e) {
201
+ return O(e, Pe(), Fe());
200
202
  }
201
- async function Ue(e) {
202
- return E(e, Ae(), Me());
203
+ async function qe(e) {
204
+ return O(e, Pe(), Ie());
203
205
  }
204
- async function We(e, t) {
205
- return E(e, Ie(t), Re(t));
206
+ async function Je(e, t) {
207
+ return O(e, Be(t), He(t));
206
208
  }
207
209
  //#endregion
208
210
  //#region src/v2/model/block_components.ts
209
- function Ge(e, t) {
211
+ function Ye(e, t) {
210
212
  return {
211
213
  workflow: {
212
214
  type: "workflow-v1",
213
- main: De(t, e.workflow.main)
215
+ main: je(t, e.workflow.main)
214
216
  },
215
- model: De(t, e.model),
216
- ui: Oe(t, e.ui, ["index.html"])
217
+ model: je(t, e.model),
218
+ ui: Me(t, e.ui, ["index.html"])
217
219
  };
218
220
  }
219
- function Ke(t, n) {
221
+ function Xe(t, n) {
220
222
  let r = (t) => ({
221
223
  type: "absolute-file",
222
224
  file: e.resolve(n, t.path)
@@ -233,8 +235,8 @@ function Ke(t, n) {
233
235
  }
234
236
  };
235
237
  }
236
- async function qe(e, t, n) {
237
- let r = Ne(t, n), i = Pe(t, "ui.tgz", n);
238
+ async function Ze(e, t, n) {
239
+ let r = Le(t, n), i = Re(t, "ui.tgz", n);
238
240
  return {
239
241
  workflow: {
240
242
  type: "workflow-v1",
@@ -244,8 +246,8 @@ async function qe(e, t, n) {
244
246
  ui: await i(e.ui)
245
247
  };
246
248
  }
247
- function Je(e, t) {
248
- let n = y(t);
249
+ function Qe(e, t) {
250
+ let n = ee(t);
249
251
  return {
250
252
  workflow: {
251
253
  type: "workflow-v1",
@@ -257,33 +259,34 @@ function Je(e, t) {
257
259
  }
258
260
  //#endregion
259
261
  //#region src/v2/model/block_description.ts
260
- async function Ye(e, t) {
261
- let n = Ge(e.components, t), i = await ze(e.meta, t), a = ee(JSON.parse(await r.readFile(n.model.file, "utf-8")));
262
+ async function $e(e, t) {
263
+ let n = Ye(e.components, t), i = await Ue(e.meta, t), a = JSON.parse(await r.readFile(n.model.file, "utf-8")), o = te(a);
262
264
  return {
263
265
  ...e,
264
266
  components: n,
265
267
  meta: i,
266
- featureFlags: a.featureFlags
268
+ featureFlags: o.featureFlags,
269
+ ...a.kind === void 0 ? {} : { kind: a.kind }
267
270
  };
268
271
  }
269
- async function Xe(e, t, n) {
270
- let r = await qe(e.components, t, n), i = await Ve(e.meta, t, n);
272
+ async function et(e, t, n) {
273
+ let r = await Ze(e.components, t, n), i = await Ge(e.meta, t, n);
271
274
  return {
272
275
  ...e,
273
276
  components: r,
274
277
  meta: i
275
278
  };
276
279
  }
277
- function Ze(e, t, n) {
280
+ function tt(e, t, n) {
278
281
  return {
279
282
  ...e,
280
283
  components: t(e.components),
281
284
  meta: n(e.meta)
282
285
  };
283
286
  }
284
- function D(e, t) {
285
- let n = g(t);
286
- return Ze(e, (e) => ({
287
+ function k(e, t) {
288
+ let n = v(t);
289
+ return tt(e, (e) => ({
287
290
  workflow: {
288
291
  type: "workflow-v1",
289
292
  main: n(e.workflow.main)
@@ -306,7 +309,7 @@ function D(e, t) {
306
309
  }
307
310
  //#endregion
308
311
  //#region src/util.ts
309
- async function Qe(e, t) {
312
+ async function nt(e, t) {
310
313
  try {
311
314
  return t(await r.readFile(e));
312
315
  } catch (e) {
@@ -314,15 +317,15 @@ async function Qe(e, t) {
314
317
  throw e;
315
318
  }
316
319
  }
317
- function O(e) {
318
- return Promise.resolve(ie("sha256").update(ArrayBuffer.isView(e) ? e : Buffer.from(e)).digest("hex").toUpperCase());
320
+ function A(e) {
321
+ return Promise.resolve(oe("sha256").update(ArrayBuffer.isView(e) ? e : Buffer.from(e)).digest("hex").toUpperCase());
319
322
  }
320
323
  //#endregion
321
324
  //#region src/v2/build_dist.ts
322
- async function $e(t, n) {
325
+ async function rt(t, n) {
323
326
  let i = t.components.workflow.main, a = await r.readFile(e.resolve(n, i.path)), o;
324
327
  try {
325
- let e = ne(a).toString("utf-8");
328
+ let e = ie(a).toString("utf-8");
326
329
  o = JSON.parse(e);
327
330
  } catch {
328
331
  return;
@@ -330,33 +333,87 @@ async function $e(t, n) {
330
333
  let s = o;
331
334
  if (!(s.type !== "pl.tengo-template.v3" || !s.template)) return s.template.requiredCapabilities;
332
335
  }
333
- async function et(t, n) {
336
+ async function it(t, n) {
337
+ let i = t.components.model;
338
+ try {
339
+ return JSON.parse(await r.readFile(e.resolve(n, i.path), "utf-8")).kind ?? void 0;
340
+ } catch {
341
+ return;
342
+ }
343
+ }
344
+ async function at(t, n) {
334
345
  await r.mkdir(n, { recursive: !0 });
335
- let i = [], a = await Xe(t, n, i), o = await $e(a, n);
346
+ let i = [], a = await et(t, n, i), o = await rt(a, n);
336
347
  o && o.length > 0 && (a.meta = {
337
348
  ...a.meta,
338
349
  requiredCapabilities: o
339
350
  });
340
- let s = await Promise.all(i.map(async (t) => {
341
- let i = await r.readFile(e.resolve(n, t)), a = await O(i);
351
+ let s = await it(a, n);
352
+ s && (a.kind = s);
353
+ let c = await Promise.all(i.map(async (t) => {
354
+ let i = await r.readFile(e.resolve(n, t)), a = await A(i);
342
355
  return {
343
356
  name: t,
344
357
  size: i.length,
345
358
  sha256: a
346
359
  };
347
- })), c = d.parse({
360
+ })), l = f.parse({
348
361
  schema: "v2",
349
362
  description: { ...a },
350
- files: s,
363
+ files: c,
351
364
  timestamp: Date.now()
352
365
  });
353
- return await r.writeFile(e.resolve(n, f), JSON.stringify(c)), c;
366
+ return await r.writeFile(e.resolve(n, p), JSON.stringify(l)), l;
367
+ }
368
+ //#endregion
369
+ //#region src/v2/build_kind_dist.ts
370
+ var ot = "manifest.json";
371
+ async function st(t) {
372
+ let n = e.resolve(t, "package.json"), i;
373
+ try {
374
+ i = await r.readFile(n, "utf-8");
375
+ } catch {
376
+ throw Error(`Cannot read kind package.json at ${n}.`);
377
+ }
378
+ let a = JSON.parse(i);
379
+ if (typeof a.name != "string" || typeof a.version != "string") throw Error(`Kind package.json at ${n} must declare string "name" and "version".`);
380
+ return {
381
+ name: a.name,
382
+ version: a.version
383
+ };
384
+ }
385
+ async function ct(t = {}) {
386
+ let n = e.resolve(t.modulePath ?? "."), i = e.resolve(n, t.srcDir ?? "src"), a = e.resolve(n, t.dst ?? "dist"), o = t.entryFileName ?? "kind.js", { name: s, version: c } = await st(n), l = ce.hashDirSync(i).digest("hex").toUpperCase(), u = [o, "kind.d.ts"], d = [];
387
+ for (let t of u) {
388
+ let n = e.resolve(a, t), i;
389
+ try {
390
+ i = await r.readFile(n);
391
+ } catch (e) {
392
+ throw e instanceof Error && "code" in e && e.code === "ENOENT" ? Error(`Kind build is incomplete: ${t} is missing from ${a}. Run the kind's build before building its manifest.`) : e;
393
+ }
394
+ d.push({
395
+ name: t,
396
+ size: i.length,
397
+ sha256: await A(i)
398
+ });
399
+ }
400
+ let f = {
401
+ schema: "v1",
402
+ kind: {
403
+ name: s,
404
+ version: c
405
+ },
406
+ sourceHash: l,
407
+ files: d,
408
+ timestamp: Date.now()
409
+ };
410
+ return await r.writeFile(e.resolve(a, ot), JSON.stringify(f)), f;
354
411
  }
355
412
  //#endregion
356
413
  //#region src/v2/source_package.ts
357
- var k = "block", tt = /(?:@[a-zA-Z0-9-.]+\/)?(?<organization>[a-zA-Z0-9-]+)\.(?<name>[a-zA-Z0-9-]+)/;
358
- function nt(e) {
359
- let t = e.match(tt);
414
+ var j = "block", lt = /(?:@[a-zA-Z0-9-.]+\/)?(?<organization>[a-zA-Z0-9-]+)\.(?<name>[a-zA-Z0-9-]+)/;
415
+ function ut(e) {
416
+ let t = e.match(lt);
360
417
  if (!t) throw Error(`Malformed package name (${e}), can't infer organization and block pack name.`);
361
418
  let { name: n, organization: r } = t.groups;
362
419
  return {
@@ -364,17 +421,17 @@ function nt(e) {
364
421
  organization: r
365
422
  };
366
423
  }
367
- async function rt(t, n) {
424
+ async function dt(t, n) {
368
425
  let r = e.resolve(t, "package.json");
369
426
  try {
370
- let e = await Qe(r, (e) => JSON.parse(e.toString("utf-8")));
427
+ let e = await nt(r, (e) => JSON.parse(e.toString("utf-8")));
371
428
  if (e === void 0) return;
372
- let n = e[k];
373
- return n === void 0 ? void 0 : await Ye({
429
+ let n = e[j];
430
+ return n === void 0 ? void 0 : await $e({
374
431
  ...c.parse(n),
375
432
  id: {
376
- ...nt(se(e.name, `"name" not found in ${r}`)),
377
- version: p.parse(e.version)
433
+ ...ut(de(e.name, `"name" not found in ${r}`)),
434
+ version: m.parse(e.version)
378
435
  }
379
436
  }, t);
380
437
  } catch (e) {
@@ -382,24 +439,24 @@ async function rt(t, n) {
382
439
  return;
383
440
  }
384
441
  }
385
- async function it(t) {
386
- let n = e.resolve(t, "package.json"), i = JSON.parse(await r.readFile(n, { encoding: "utf-8" })), a = i[k];
387
- if (a === void 0) throw Error(`Block description (field ${k}) not found in ${n}.`);
442
+ async function ft(t) {
443
+ let n = e.resolve(t, "package.json"), i = JSON.parse(await r.readFile(n, { encoding: "utf-8" })), a = i[j];
444
+ if (a === void 0) throw Error(`Block description (field ${j}) not found in ${n}.`);
388
445
  return {
389
446
  ...c.parse(a),
390
447
  id: {
391
- ...nt(se(i.name, `"name" not found in ${n}`)),
392
- version: p.parse(i.version)
448
+ ...ut(de(i.name, `"name" not found in ${n}`)),
449
+ version: m.parse(i.version)
393
450
  },
394
451
  featureFlags: {}
395
452
  };
396
453
  }
397
- async function at(e) {
398
- return await Ye(await it(e), e);
454
+ async function pt(e) {
455
+ return await $e(await ft(e), e);
399
456
  }
400
- var ot = "block-pack";
401
- async function st(t) {
402
- let n = e.resolve(t, f), i = JSON.parse(await r.readFile(n, { encoding: "utf-8" })), a = d.parse(i), o = Ke(a.description.components, t), s = await Be(a.description.meta, t);
457
+ var mt = "block-pack";
458
+ async function ht(t) {
459
+ let n = e.resolve(t, p), i = JSON.parse(await r.readFile(n, { encoding: "utf-8" })), a = f.parse(i), o = Xe(a.description.components, t), s = await We(a.description.meta, t);
403
460
  return {
404
461
  ...a.description,
405
462
  components: o,
@@ -407,21 +464,137 @@ async function st(t) {
407
464
  };
408
465
  }
409
466
  //#endregion
467
+ //#region src/v2/registry/schema_kinds.ts
468
+ var M = "kinds/", gt = "overview.json", _t = "manifest.json";
469
+ function vt(e, t) {
470
+ let { org: n, name: r } = N(e);
471
+ return `${M}${n}/${r}/${t}`;
472
+ }
473
+ function yt(e) {
474
+ return `${M}${e.org}/${e.name}/${gt}`;
475
+ }
476
+ var bt = RegExp(`^(?<org>[^/]+)/(?<name>[^/]+)/${gt.replace(".", "\\.")}$`);
477
+ function N(e) {
478
+ let { organization: t, name: n } = ut(e);
479
+ return {
480
+ org: t,
481
+ name: n
482
+ };
483
+ }
484
+ var xt = S.object({
485
+ name: S.string(),
486
+ version: m
487
+ }).passthrough(), St = S.object({
488
+ name: S.string(),
489
+ size: S.number(),
490
+ sha256: h
491
+ }).passthrough(), P = S.object({
492
+ schema: S.literal("v1"),
493
+ kind: xt,
494
+ sourceHash: S.string(),
495
+ files: S.array(St),
496
+ timestamp: S.number().optional(),
497
+ firstUploadTimestamp: S.number().optional()
498
+ }).passthrough(), Ct = S.object({
499
+ id: u,
500
+ kindVersion: m,
501
+ channels: S.array(S.string()).default(() => [])
502
+ }).passthrough(), wt = S.object({
503
+ kindVersion: m,
504
+ latestByChannel: S.record(S.string(), u)
505
+ }).passthrough(), Tt = S.object({
506
+ schema: S.literal("v1"),
507
+ implementers: S.array(Ct),
508
+ kindVersions: S.array(wt)
509
+ }).passthrough(), Et = ".kind";
510
+ function Dt(e) {
511
+ return e.description.kind;
512
+ }
513
+ function Ot(t) {
514
+ let r = e.join(t, "package.json"), i = JSON.parse(n.readFileSync(r, "utf-8")), a = {
515
+ ...i.devDependencies,
516
+ ...i.dependencies
517
+ }, o = Object.entries(a).find(([e]) => e.endsWith(Et));
518
+ if (o) return {
519
+ npmName: o[0],
520
+ range: o[1]
521
+ };
522
+ }
523
+ async function kt(t, n) {
524
+ let i = At(t, n), a = e.join(i, "dist"), o;
525
+ try {
526
+ o = await r.readFile(e.join(a, "manifest.json"), "utf-8");
527
+ } catch {
528
+ throw Error(`Kind package "${n}" resolved to ${i} but has no dist/manifest.json. Build the kind (ts-builder build --target block-kind && block-tools build-kind-manifest) before publishing.`);
529
+ }
530
+ let s = P.parse(JSON.parse(o));
531
+ return {
532
+ ref: ne({
533
+ name: s.kind.name,
534
+ version: s.kind.version
535
+ }),
536
+ manifest: s,
537
+ fileReader: async (t) => Buffer.from(await r.readFile(e.resolve(a, t)))
538
+ };
539
+ }
540
+ function At(t, r) {
541
+ let i = le(e.join(t, "package.json"));
542
+ try {
543
+ return e.dirname(i.resolve(`${r}/package.json`));
544
+ } catch {
545
+ try {
546
+ let t = e.dirname(i.resolve(r));
547
+ for (let r = 0; r < 6; r++) {
548
+ if (n.existsSync(e.join(t, "package.json"))) return t;
549
+ let r = e.dirname(t);
550
+ if (r === t) break;
551
+ t = r;
552
+ }
553
+ } catch {}
554
+ throw Error(`Cannot resolve kind package "${r}" from ${t}. Ensure it is installed as a dependency of the facade.`);
555
+ }
556
+ }
557
+ //#endregion
558
+ //#region src/v2/kind/version-match.ts
559
+ var jt = class extends Error {
560
+ constructor(e) {
561
+ super(e), this.name = "KindVersionMismatchError";
562
+ }
563
+ };
564
+ function Mt(e, t) {
565
+ let n = x(e), r = x(t);
566
+ if (n.version !== r.version) throw new jt(`Kind version mismatch: model compiled against ${e}, facade declares ${t}. Rebuild the model against the declared kind.`);
567
+ let i = N(n.name), a = N(r.name);
568
+ if (i.org !== a.org || i.name !== a.name) throw new jt(`Kind name mismatch: model compiled against ${e}, facade declares ${t}.`);
569
+ }
570
+ //#endregion
571
+ //#region src/v2/publish-block.ts
572
+ async function Nt(e, t, n, r) {
573
+ let i = Dt(t);
574
+ if (i !== void 0) {
575
+ let t = Ot(n);
576
+ if (t === void 0) throw Error(`Model was compiled against kind ${i}, but the facade declares no kind dependency in its package.json.`);
577
+ let r = await kt(n, t.npmName);
578
+ Mt(i, r.ref), await e.publishKind(r.manifest, r.fileReader);
579
+ }
580
+ await e.publishPackage(t, r);
581
+ }
582
+ //#endregion
410
583
  //#region src/v2/resolve_to_registry.ts
411
- var A = "published.json";
412
- function ct(e) {
584
+ var F = "published.json";
585
+ function Pt(e) {
413
586
  return {
414
587
  registryUrl: e.registryUrl,
415
588
  id: e.id
416
589
  };
417
590
  }
418
- async function lt(t, n) {
419
- let i = e.resolve(t, A);
591
+ async function Ft(t, n) {
592
+ let i = e.resolve(t, F);
420
593
  await r.writeFile(i, JSON.stringify(n, null, 2), { encoding: "utf-8" });
421
594
  }
422
- async function ut(t) {
423
- let i = t.type === "from-pack-v2" ? e.resolve(ce(t.packUrl), A) : e.resolve(t.folder, "block-pack", A);
424
- if (!n.existsSync(i)) throw Error(`Block has no ${A} at ${i} — was the block published? Run block-tools publish before consuming via registry.`);
595
+ async function It(t) {
596
+ let i = t.type === "from-pack-v2" ? e.resolve(fe(t.packUrl), F) : e.resolve(t.folder, "block-pack", F);
597
+ if (!n.existsSync(i)) throw Error(`Block has no ${F} at ${i} — was the block published? Run block-tools publish before consuming via registry.`);
425
598
  let a = JSON.parse(await r.readFile(i, { encoding: "utf-8" }));
426
599
  return {
427
600
  type: "from-registry-v2",
@@ -431,7 +604,7 @@ async function ut(t) {
431
604
  }
432
605
  //#endregion
433
606
  //#region ../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js
434
- var j = /* @__PURE__ */ T(((e, t) => {
607
+ var I = /* @__PURE__ */ D(((e, t) => {
435
608
  var n = "2.0.0", r = 256;
436
609
  t.exports = {
437
610
  MAX_LENGTH: r,
@@ -451,10 +624,10 @@ var j = /* @__PURE__ */ T(((e, t) => {
451
624
  FLAG_INCLUDE_PRERELEASE: 1,
452
625
  FLAG_LOOSE: 2
453
626
  };
454
- })), M = /* @__PURE__ */ T(((e, t) => {
627
+ })), L = /* @__PURE__ */ D(((e, t) => {
455
628
  t.exports = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => {};
456
- })), N = /* @__PURE__ */ T(((e, t) => {
457
- var { MAX_SAFE_COMPONENT_LENGTH: n, MAX_SAFE_BUILD_LENGTH: r, MAX_LENGTH: i } = j(), a = M();
629
+ })), R = /* @__PURE__ */ D(((e, t) => {
630
+ var { MAX_SAFE_COMPONENT_LENGTH: n, MAX_SAFE_BUILD_LENGTH: r, MAX_LENGTH: i } = I(), a = L();
458
631
  e = t.exports = {};
459
632
  var o = e.re = [], s = e.safeRe = [], c = e.src = [], l = e.safeSrc = [], u = e.t = {}, d = 0, f = "[a-zA-Z0-9-]", p = [
460
633
  ["\\s", 1],
@@ -468,10 +641,10 @@ var j = /* @__PURE__ */ T(((e, t) => {
468
641
  a(e, i, t), u[e] = i, c[i] = t, l[i] = r, o[i] = new RegExp(t, n ? "g" : void 0), s[i] = new RegExp(r, n ? "g" : void 0);
469
642
  };
470
643
  h("NUMERICIDENTIFIER", "0|[1-9]\\d*"), h("NUMERICIDENTIFIERLOOSE", "\\d+"), h("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${f}*`), h("MAINVERSION", `(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`), h("MAINVERSIONLOOSE", `(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`), h("PRERELEASEIDENTIFIER", `(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`), h("PRERELEASEIDENTIFIERLOOSE", `(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`), h("PRERELEASE", `(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`), h("PRERELEASELOOSE", `(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`), h("BUILDIDENTIFIER", `${f}+`), h("BUILD", `(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`), h("FULLPLAIN", `v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`), h("FULL", `^${c[u.FULLPLAIN]}$`), h("LOOSEPLAIN", `[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`), h("LOOSE", `^${c[u.LOOSEPLAIN]}$`), h("GTLT", "((?:<|>)?=?)"), h("XRANGEIDENTIFIERLOOSE", `${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), h("XRANGEIDENTIFIER", `${c[u.NUMERICIDENTIFIER]}|x|X|\\*`), h("XRANGEPLAIN", `[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`), h("XRANGEPLAINLOOSE", `[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`), h("XRANGE", `^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`), h("XRANGELOOSE", `^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`), h("COERCEPLAIN", `(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`), h("COERCE", `${c[u.COERCEPLAIN]}(?:$|[^\\d])`), h("COERCEFULL", c[u.COERCEPLAIN] + `(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`), h("COERCERTL", c[u.COERCE], !0), h("COERCERTLFULL", c[u.COERCEFULL], !0), h("LONETILDE", "(?:~>?)"), h("TILDETRIM", `(\\s*)${c[u.LONETILDE]}\\s+`, !0), e.tildeTrimReplace = "$1~", h("TILDE", `^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`), h("TILDELOOSE", `^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`), h("LONECARET", "(?:\\^)"), h("CARETTRIM", `(\\s*)${c[u.LONECARET]}\\s+`, !0), e.caretTrimReplace = "$1^", h("CARET", `^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`), h("CARETLOOSE", `^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`), h("COMPARATORLOOSE", `^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`), h("COMPARATOR", `^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`), h("COMPARATORTRIM", `(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`, !0), e.comparatorTrimReplace = "$1$2$3", h("HYPHENRANGE", `^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`), h("HYPHENRANGELOOSE", `^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`), h("STAR", "(<|>)?=?\\s*\\*"), h("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), h("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
471
- })), dt = /* @__PURE__ */ T(((e, t) => {
644
+ })), Lt = /* @__PURE__ */ D(((e, t) => {
472
645
  var n = Object.freeze({ loose: !0 }), r = Object.freeze({});
473
646
  t.exports = (e) => e ? typeof e == "object" ? e : n : r;
474
- })), ft = /* @__PURE__ */ T(((e, t) => {
647
+ })), Rt = /* @__PURE__ */ D(((e, t) => {
475
648
  var n = /^[0-9]+$/, r = (e, t) => {
476
649
  let r = n.test(e), i = n.test(t);
477
650
  return r && i && (e = +e, t = +t), e === t ? 0 : r && !i ? -1 : i && !r ? 1 : e < t ? -1 : 1;
@@ -480,8 +653,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
480
653
  compareIdentifiers: r,
481
654
  rcompareIdentifiers: (e, t) => r(t, e)
482
655
  };
483
- })), P = /* @__PURE__ */ T(((e, t) => {
484
- var n = M(), { MAX_LENGTH: r, MAX_SAFE_INTEGER: i } = j(), { safeRe: a, t: o } = N(), s = dt(), { compareIdentifiers: c } = ft();
656
+ })), z = /* @__PURE__ */ D(((e, t) => {
657
+ var n = L(), { MAX_LENGTH: r, MAX_SAFE_INTEGER: i } = I(), { safeRe: a, t: o } = R(), s = Lt(), { compareIdentifiers: c } = Rt();
485
658
  t.exports = class e {
486
659
  constructor(t, c) {
487
660
  if (c = s(c), t instanceof e) {
@@ -601,8 +774,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
601
774
  return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this;
602
775
  }
603
776
  };
604
- })), F = /* @__PURE__ */ T(((e, t) => {
605
- var n = P();
777
+ })), B = /* @__PURE__ */ D(((e, t) => {
778
+ var n = z();
606
779
  t.exports = (e, t, r = !1) => {
607
780
  if (e instanceof n) return e;
608
781
  try {
@@ -612,20 +785,20 @@ var j = /* @__PURE__ */ T(((e, t) => {
612
785
  throw e;
613
786
  }
614
787
  };
615
- })), pt = /* @__PURE__ */ T(((e, t) => {
616
- var n = F();
788
+ })), zt = /* @__PURE__ */ D(((e, t) => {
789
+ var n = B();
617
790
  t.exports = (e, t) => {
618
791
  let r = n(e, t);
619
792
  return r ? r.version : null;
620
793
  };
621
- })), mt = /* @__PURE__ */ T(((e, t) => {
622
- var n = F();
794
+ })), Bt = /* @__PURE__ */ D(((e, t) => {
795
+ var n = B();
623
796
  t.exports = (e, t) => {
624
797
  let r = n(e.trim().replace(/^[=v]+/, ""), t);
625
798
  return r ? r.version : null;
626
799
  };
627
- })), ht = /* @__PURE__ */ T(((e, t) => {
628
- var n = P();
800
+ })), Vt = /* @__PURE__ */ D(((e, t) => {
801
+ var n = z();
629
802
  t.exports = (e, t, r, i, a) => {
630
803
  typeof r == "string" && (a = i, i = r, r = void 0);
631
804
  try {
@@ -634,8 +807,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
634
807
  return null;
635
808
  }
636
809
  };
637
- })), gt = /* @__PURE__ */ T(((e, t) => {
638
- var n = F();
810
+ })), Ht = /* @__PURE__ */ D(((e, t) => {
811
+ var n = B();
639
812
  t.exports = (e, t) => {
640
813
  let r = n(e, null, !0), i = n(t, null, !0), a = r.compare(i);
641
814
  if (a === 0) return null;
@@ -647,62 +820,62 @@ var j = /* @__PURE__ */ T(((e, t) => {
647
820
  let u = l ? "pre" : "";
648
821
  return r.major === i.major ? r.minor === i.minor ? r.patch === i.patch ? "prerelease" : u + "patch" : u + "minor" : u + "major";
649
822
  };
650
- })), _t = /* @__PURE__ */ T(((e, t) => {
651
- var n = P();
823
+ })), Ut = /* @__PURE__ */ D(((e, t) => {
824
+ var n = z();
652
825
  t.exports = (e, t) => new n(e, t).major;
653
- })), vt = /* @__PURE__ */ T(((e, t) => {
654
- var n = P();
826
+ })), Wt = /* @__PURE__ */ D(((e, t) => {
827
+ var n = z();
655
828
  t.exports = (e, t) => new n(e, t).minor;
656
- })), yt = /* @__PURE__ */ T(((e, t) => {
657
- var n = P();
829
+ })), Gt = /* @__PURE__ */ D(((e, t) => {
830
+ var n = z();
658
831
  t.exports = (e, t) => new n(e, t).patch;
659
- })), bt = /* @__PURE__ */ T(((e, t) => {
660
- var n = F();
832
+ })), Kt = /* @__PURE__ */ D(((e, t) => {
833
+ var n = B();
661
834
  t.exports = (e, t) => {
662
835
  let r = n(e, t);
663
836
  return r && r.prerelease.length ? r.prerelease : null;
664
837
  };
665
- })), I = /* @__PURE__ */ T(((e, t) => {
666
- var n = P();
838
+ })), V = /* @__PURE__ */ D(((e, t) => {
839
+ var n = z();
667
840
  t.exports = (e, t, r) => new n(e, r).compare(new n(t, r));
668
- })), xt = /* @__PURE__ */ T(((e, t) => {
669
- var n = I();
841
+ })), qt = /* @__PURE__ */ D(((e, t) => {
842
+ var n = V();
670
843
  t.exports = (e, t, r) => n(t, e, r);
671
- })), St = /* @__PURE__ */ T(((e, t) => {
672
- var n = I();
844
+ })), Jt = /* @__PURE__ */ D(((e, t) => {
845
+ var n = V();
673
846
  t.exports = (e, t) => n(e, t, !0);
674
- })), Ct = /* @__PURE__ */ T(((e, t) => {
675
- var n = P();
847
+ })), Yt = /* @__PURE__ */ D(((e, t) => {
848
+ var n = z();
676
849
  t.exports = (e, t, r) => {
677
850
  let i = new n(e, r), a = new n(t, r);
678
851
  return i.compare(a) || i.compareBuild(a);
679
852
  };
680
- })), wt = /* @__PURE__ */ T(((e, t) => {
681
- var n = Ct();
853
+ })), Xt = /* @__PURE__ */ D(((e, t) => {
854
+ var n = Yt();
682
855
  t.exports = (e, t) => e.sort((e, r) => n(e, r, t));
683
- })), Tt = /* @__PURE__ */ T(((e, t) => {
684
- var n = Ct();
856
+ })), Zt = /* @__PURE__ */ D(((e, t) => {
857
+ var n = Yt();
685
858
  t.exports = (e, t) => e.sort((e, r) => n(r, e, t));
686
- })), L = /* @__PURE__ */ T(((e, t) => {
687
- var n = I();
859
+ })), H = /* @__PURE__ */ D(((e, t) => {
860
+ var n = V();
688
861
  t.exports = (e, t, r) => n(e, t, r) > 0;
689
- })), Et = /* @__PURE__ */ T(((e, t) => {
690
- var n = I();
862
+ })), Qt = /* @__PURE__ */ D(((e, t) => {
863
+ var n = V();
691
864
  t.exports = (e, t, r) => n(e, t, r) < 0;
692
- })), Dt = /* @__PURE__ */ T(((e, t) => {
693
- var n = I();
865
+ })), $t = /* @__PURE__ */ D(((e, t) => {
866
+ var n = V();
694
867
  t.exports = (e, t, r) => n(e, t, r) === 0;
695
- })), Ot = /* @__PURE__ */ T(((e, t) => {
696
- var n = I();
868
+ })), en = /* @__PURE__ */ D(((e, t) => {
869
+ var n = V();
697
870
  t.exports = (e, t, r) => n(e, t, r) !== 0;
698
- })), kt = /* @__PURE__ */ T(((e, t) => {
699
- var n = I();
871
+ })), tn = /* @__PURE__ */ D(((e, t) => {
872
+ var n = V();
700
873
  t.exports = (e, t, r) => n(e, t, r) >= 0;
701
- })), At = /* @__PURE__ */ T(((e, t) => {
702
- var n = I();
874
+ })), nn = /* @__PURE__ */ D(((e, t) => {
875
+ var n = V();
703
876
  t.exports = (e, t, r) => n(e, t, r) <= 0;
704
- })), jt = /* @__PURE__ */ T(((e, t) => {
705
- var n = Dt(), r = Ot(), i = L(), a = kt(), o = Et(), s = At();
877
+ })), rn = /* @__PURE__ */ D(((e, t) => {
878
+ var n = $t(), r = en(), i = H(), a = tn(), o = Qt(), s = nn();
706
879
  t.exports = (e, t, c, l) => {
707
880
  switch (t) {
708
881
  case "===": return typeof e == "object" && (e = e.version), typeof c == "object" && (c = c.version), e === c;
@@ -718,8 +891,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
718
891
  default: throw TypeError(`Invalid operator: ${t}`);
719
892
  }
720
893
  };
721
- })), Mt = /* @__PURE__ */ T(((e, t) => {
722
- var n = P(), r = F(), { safeRe: i, t: a } = N();
894
+ })), an = /* @__PURE__ */ D(((e, t) => {
895
+ var n = z(), r = B(), { safeRe: i, t: a } = R();
723
896
  t.exports = (e, t) => {
724
897
  if (e instanceof n) return e;
725
898
  if (typeof e == "number" && (e = String(e)), typeof e != "string") return null;
@@ -735,7 +908,7 @@ var j = /* @__PURE__ */ T(((e, t) => {
735
908
  let s = o[2];
736
909
  return r(`${s}.${o[3] || "0"}.${o[4] || "0"}${t.includePrerelease && o[5] ? `-${o[5]}` : ""}${t.includePrerelease && o[6] ? `+${o[6]}` : ""}`, t);
737
910
  };
738
- })), Nt = /* @__PURE__ */ T(((e, t) => {
911
+ })), on = /* @__PURE__ */ D(((e, t) => {
739
912
  t.exports = class {
740
913
  constructor() {
741
914
  this.max = 1e3, this.map = /* @__PURE__ */ new Map();
@@ -758,7 +931,7 @@ var j = /* @__PURE__ */ T(((e, t) => {
758
931
  return this;
759
932
  }
760
933
  };
761
- })), R = /* @__PURE__ */ T(((e, t) => {
934
+ })), U = /* @__PURE__ */ D(((e, t) => {
762
935
  var n = /\s+/g;
763
936
  t.exports = class e {
764
937
  constructor(t, r) {
@@ -798,8 +971,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
798
971
  let t = ((this.options.includePrerelease && p) | (this.options.loose && m)) + ":" + e, n = r.get(t);
799
972
  if (n) return n;
800
973
  let i = this.options.loose, s = i ? c[l.HYPHENRANGELOOSE] : c[l.HYPHENRANGE];
801
- e = e.replace(s, se(this.options.includePrerelease)), o("hyphen replace", e), e = e.replace(c[l.COMPARATORTRIM], u), o("comparator trim", e), e = e.replace(c[l.TILDETRIM], d), o("tilde trim", e), e = e.replace(c[l.CARETTRIM], f), o("caret trim", e);
802
- let g = e.split(" ").map((e) => v(e, this.options)).join(" ").split(/\s+/).map((e) => b(e, this.options));
974
+ e = e.replace(s, oe(this.options.includePrerelease)), o("hyphen replace", e), e = e.replace(c[l.COMPARATORTRIM], u), o("comparator trim", e), e = e.replace(c[l.TILDETRIM], d), o("tilde trim", e), e = e.replace(c[l.CARETTRIM], f), o("caret trim", e);
975
+ let g = e.split(" ").map((e) => v(e, this.options)).join(" ").split(/\s+/).map((e) => ae(e, this.options));
803
976
  i && (g = g.filter((e) => (o("loose invalid filter", e, this.options), !!e.match(c[l.COMPARATORLOOSE])))), o("range list", g);
804
977
  let _ = /* @__PURE__ */ new Map(), y = g.map((e) => new a(e, this.options));
805
978
  for (let e of y) {
@@ -807,8 +980,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
807
980
  _.set(e.value, e);
808
981
  }
809
982
  _.size > 1 && _.has("") && _.delete("");
810
- let ee = [..._.values()];
811
- return r.set(t, ee), ee;
983
+ let b = [..._.values()];
984
+ return r.set(t, b), b;
812
985
  }
813
986
  intersects(t, n) {
814
987
  if (!(t instanceof e)) throw TypeError("a Range is required");
@@ -821,22 +994,22 @@ var j = /* @__PURE__ */ T(((e, t) => {
821
994
  } catch {
822
995
  return !1;
823
996
  }
824
- for (let t = 0; t < this.set.length; t++) if (x(this.set[t], e, this.options)) return !0;
997
+ for (let t = 0; t < this.set.length; t++) if (se(this.set[t], e, this.options)) return !0;
825
998
  return !1;
826
999
  }
827
1000
  };
828
- var r = new (Nt())(), i = dt(), a = z(), o = M(), s = P(), { safeRe: c, t: l, comparatorTrimReplace: u, tildeTrimReplace: d, caretTrimReplace: f } = N(), { FLAG_INCLUDE_PRERELEASE: p, FLAG_LOOSE: m } = j(), h = (e) => e.value === "<0.0.0-0", g = (e) => e.value === "", _ = (e, t) => {
1001
+ var r = new (on())(), i = Lt(), a = W(), o = L(), s = z(), { safeRe: c, t: l, comparatorTrimReplace: u, tildeTrimReplace: d, caretTrimReplace: f } = R(), { FLAG_INCLUDE_PRERELEASE: p, FLAG_LOOSE: m } = I(), h = (e) => e.value === "<0.0.0-0", g = (e) => e.value === "", _ = (e, t) => {
829
1002
  let n = !0, r = e.slice(), i = r.pop();
830
1003
  for (; n && r.length;) n = r.every((e) => i.intersects(e, t)), i = r.pop();
831
1004
  return n;
832
- }, v = (e, t) => (o("comp", e, t), e = ne(e, t), o("caret", e), e = ee(e, t), o("tildes", e), e = ie(e, t), o("xrange", e), e = oe(e, t), o("stars", e), e), y = (e) => !e || e.toLowerCase() === "x" || e === "*", ee = (e, t) => e.trim().split(/\s+/).map((e) => te(e, t)).join(" "), te = (e, t) => {
1005
+ }, v = (e, t) => (o("comp", e, t), e = te(e, t), o("caret", e), e = b(e, t), o("tildes", e), e = x(e, t), o("xrange", e), e = ie(e, t), o("stars", e), e), y = (e) => !e || e.toLowerCase() === "x" || e === "*", b = (e, t) => e.trim().split(/\s+/).map((e) => ee(e, t)).join(" "), ee = (e, t) => {
833
1006
  let n = t.loose ? c[l.TILDELOOSE] : c[l.TILDE];
834
1007
  return e.replace(n, (t, n, r, i, a) => {
835
1008
  o("tilde", e, t, n, r, i, a);
836
1009
  let s;
837
1010
  return y(n) ? s = "" : y(r) ? s = `>=${n}.0.0 <${+n + 1}.0.0-0` : y(i) ? s = `>=${n}.${r}.0 <${n}.${+r + 1}.0-0` : a ? (o("replaceTilde pr", a), s = `>=${n}.${r}.${i}-${a} <${n}.${+r + 1}.0-0`) : s = `>=${n}.${r}.${i} <${n}.${+r + 1}.0-0`, o("tilde return", s), s;
838
1011
  });
839
- }, ne = (e, t) => e.trim().split(/\s+/).map((e) => re(e, t)).join(" "), re = (e, t) => {
1012
+ }, te = (e, t) => e.trim().split(/\s+/).map((e) => ne(e, t)).join(" "), ne = (e, t) => {
840
1013
  o("caret", e, t);
841
1014
  let n = t.loose ? c[l.CARETLOOSE] : c[l.CARET], r = t.includePrerelease ? "-0" : "";
842
1015
  return e.replace(n, (t, n, i, a, s) => {
@@ -844,7 +1017,7 @@ var j = /* @__PURE__ */ T(((e, t) => {
844
1017
  let c;
845
1018
  return y(n) ? c = "" : y(i) ? c = `>=${n}.0.0${r} <${+n + 1}.0.0-0` : y(a) ? c = n === "0" ? `>=${n}.${i}.0${r} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.0${r} <${+n + 1}.0.0-0` : s ? (o("replaceCaret pr", s), c = n === "0" ? i === "0" ? `>=${n}.${i}.${a}-${s} <${n}.${i}.${+a + 1}-0` : `>=${n}.${i}.${a}-${s} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.${a}-${s} <${+n + 1}.0.0-0`) : (o("no pr"), c = n === "0" ? i === "0" ? `>=${n}.${i}.${a}${r} <${n}.${i}.${+a + 1}-0` : `>=${n}.${i}.${a}${r} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.${a} <${+n + 1}.0.0-0`), o("caret return", c), c;
846
1019
  });
847
- }, ie = (e, t) => (o("replaceXRanges", e, t), e.split(/\s+/).map((e) => ae(e, t)).join(" ")), ae = (e, t) => {
1020
+ }, x = (e, t) => (o("replaceXRanges", e, t), e.split(/\s+/).map((e) => re(e, t)).join(" ")), re = (e, t) => {
848
1021
  e = e.trim();
849
1022
  let n = t.loose ? c[l.XRANGELOOSE] : c[l.XRANGE];
850
1023
  return e.replace(n, (n, r, i, a, s, c) => {
@@ -852,7 +1025,7 @@ var j = /* @__PURE__ */ T(((e, t) => {
852
1025
  let l = y(i), u = l || y(a), d = u || y(s), f = d;
853
1026
  return r === "=" && f && (r = ""), c = t.includePrerelease ? "-0" : "", l ? n = r === ">" || r === "<" ? "<0.0.0-0" : "*" : r && f ? (u && (a = 0), s = 0, r === ">" ? (r = ">=", u ? (i = +i + 1, a = 0, s = 0) : (a = +a + 1, s = 0)) : r === "<=" && (r = "<", u ? i = +i + 1 : a = +a + 1), r === "<" && (c = "-0"), n = `${r + i}.${a}.${s}${c}`) : u ? n = `>=${i}.0.0${c} <${+i + 1}.0.0-0` : d && (n = `>=${i}.${a}.0${c} <${i}.${+a + 1}.0-0`), o("xRange return", n), n;
854
1027
  });
855
- }, oe = (e, t) => (o("replaceStars", e, t), e.trim().replace(c[l.STAR], "")), b = (e, t) => (o("replaceGTE0", e, t), e.trim().replace(c[t.includePrerelease ? l.GTE0PRE : l.GTE0], "")), se = (e) => (t, n, r, i, a, o, s, c, l, u, d, f) => (n = y(r) ? "" : y(i) ? `>=${r}.0.0${e ? "-0" : ""}` : y(a) ? `>=${r}.${i}.0${e ? "-0" : ""}` : o ? `>=${n}` : `>=${n}${e ? "-0" : ""}`, c = y(l) ? "" : y(u) ? `<${+l + 1}.0.0-0` : y(d) ? `<${l}.${+u + 1}.0-0` : f ? `<=${l}.${u}.${d}-${f}` : e ? `<${l}.${u}.${+d + 1}-0` : `<=${c}`, `${n} ${c}`.trim()), x = (e, t, n) => {
1028
+ }, ie = (e, t) => (o("replaceStars", e, t), e.trim().replace(c[l.STAR], "")), ae = (e, t) => (o("replaceGTE0", e, t), e.trim().replace(c[t.includePrerelease ? l.GTE0PRE : l.GTE0], "")), oe = (e) => (t, n, r, i, a, o, s, c, l, u, d, f) => (n = y(r) ? "" : y(i) ? `>=${r}.0.0${e ? "-0" : ""}` : y(a) ? `>=${r}.${i}.0${e ? "-0" : ""}` : o ? `>=${n}` : `>=${n}${e ? "-0" : ""}`, c = y(l) ? "" : y(u) ? `<${+l + 1}.0.0-0` : y(d) ? `<${l}.${+u + 1}.0-0` : f ? `<=${l}.${u}.${d}-${f}` : e ? `<${l}.${u}.${+d + 1}-0` : `<=${c}`, `${n} ${c}`.trim()), se = (e, t, n) => {
856
1029
  for (let n = 0; n < e.length; n++) if (!e[n].test(t)) return !1;
857
1030
  if (t.prerelease.length && !n.includePrerelease) {
858
1031
  for (let n = 0; n < e.length; n++) if (o(e[n].semver), e[n].semver !== a.ANY && e[n].semver.prerelease.length > 0) {
@@ -863,7 +1036,7 @@ var j = /* @__PURE__ */ T(((e, t) => {
863
1036
  }
864
1037
  return !0;
865
1038
  };
866
- })), z = /* @__PURE__ */ T(((e, t) => {
1039
+ })), W = /* @__PURE__ */ D(((e, t) => {
867
1040
  var n = Symbol("SemVer ANY");
868
1041
  t.exports = class e {
869
1042
  static get ANY() {
@@ -898,9 +1071,9 @@ var j = /* @__PURE__ */ T(((e, t) => {
898
1071
  return this.operator === "" ? this.value === "" ? !0 : new l(t.value, n).test(this.value) : t.operator === "" ? t.value === "" ? !0 : new l(this.value, n).test(t.semver) : (n = r(n), n.includePrerelease && (this.value === "<0.0.0-0" || t.value === "<0.0.0-0") || !n.includePrerelease && (this.value.startsWith("<0.0.0") || t.value.startsWith("<0.0.0")) ? !1 : !!(this.operator.startsWith(">") && t.operator.startsWith(">") || this.operator.startsWith("<") && t.operator.startsWith("<") || this.semver.version === t.semver.version && this.operator.includes("=") && t.operator.includes("=") || o(this.semver, "<", t.semver, n) && this.operator.startsWith(">") && t.operator.startsWith("<") || o(this.semver, ">", t.semver, n) && this.operator.startsWith("<") && t.operator.startsWith(">")));
899
1072
  }
900
1073
  };
901
- var r = dt(), { safeRe: i, t: a } = N(), o = jt(), s = M(), c = P(), l = R();
902
- })), B = /* @__PURE__ */ T(((e, t) => {
903
- var n = R();
1074
+ var r = Lt(), { safeRe: i, t: a } = R(), o = rn(), s = L(), c = z(), l = U();
1075
+ })), G = /* @__PURE__ */ D(((e, t) => {
1076
+ var n = U();
904
1077
  t.exports = (e, t, r) => {
905
1078
  try {
906
1079
  t = new n(t, r);
@@ -909,11 +1082,11 @@ var j = /* @__PURE__ */ T(((e, t) => {
909
1082
  }
910
1083
  return t.test(e);
911
1084
  };
912
- })), Pt = /* @__PURE__ */ T(((e, t) => {
913
- var n = R();
1085
+ })), sn = /* @__PURE__ */ D(((e, t) => {
1086
+ var n = U();
914
1087
  t.exports = (e, t) => new n(e, t).set.map((e) => e.map((e) => e.value).join(" ").trim().split(" "));
915
- })), Ft = /* @__PURE__ */ T(((e, t) => {
916
- var n = P(), r = R();
1088
+ })), cn = /* @__PURE__ */ D(((e, t) => {
1089
+ var n = z(), r = U();
917
1090
  t.exports = (e, t, i) => {
918
1091
  let a = null, o = null, s = null;
919
1092
  try {
@@ -925,8 +1098,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
925
1098
  s.test(e) && (!a || o.compare(e) === -1) && (a = e, o = new n(a, i));
926
1099
  }), a;
927
1100
  };
928
- })), It = /* @__PURE__ */ T(((e, t) => {
929
- var n = P(), r = R();
1101
+ })), ln = /* @__PURE__ */ D(((e, t) => {
1102
+ var n = z(), r = U();
930
1103
  t.exports = (e, t, i) => {
931
1104
  let a = null, o = null, s = null;
932
1105
  try {
@@ -938,8 +1111,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
938
1111
  s.test(e) && (!a || o.compare(e) === 1) && (a = e, o = new n(a, i));
939
1112
  }), a;
940
1113
  };
941
- })), Lt = /* @__PURE__ */ T(((e, t) => {
942
- var n = P(), r = R(), i = L();
1114
+ })), un = /* @__PURE__ */ D(((e, t) => {
1115
+ var n = z(), r = U(), i = H();
943
1116
  t.exports = (e, t) => {
944
1117
  e = new r(e, t);
945
1118
  let a = new n("0.0.0");
@@ -964,8 +1137,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
964
1137
  }
965
1138
  return a && e.test(a) ? a : null;
966
1139
  };
967
- })), Rt = /* @__PURE__ */ T(((e, t) => {
968
- var n = R();
1140
+ })), dn = /* @__PURE__ */ D(((e, t) => {
1141
+ var n = U();
969
1142
  t.exports = (e, t) => {
970
1143
  try {
971
1144
  return new n(e, t).range || "*";
@@ -973,8 +1146,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
973
1146
  return null;
974
1147
  }
975
1148
  };
976
- })), zt = /* @__PURE__ */ T(((e, t) => {
977
- var n = P(), r = z(), { ANY: i } = r, a = R(), o = B(), s = L(), c = Et(), l = At(), u = kt();
1149
+ })), fn = /* @__PURE__ */ D(((e, t) => {
1150
+ var n = z(), r = W(), { ANY: i } = r, a = U(), o = G(), s = H(), c = Qt(), l = nn(), u = tn();
978
1151
  t.exports = (e, t, d, f) => {
979
1152
  e = new n(e, f), t = new a(t, f);
980
1153
  let p, m, h, g, _;
@@ -996,17 +1169,17 @@ var j = /* @__PURE__ */ T(((e, t) => {
996
1169
  }
997
1170
  return !0;
998
1171
  };
999
- })), Bt = /* @__PURE__ */ T(((e, t) => {
1000
- var n = zt();
1172
+ })), pn = /* @__PURE__ */ D(((e, t) => {
1173
+ var n = fn();
1001
1174
  t.exports = (e, t, r) => n(e, t, ">", r);
1002
- })), Vt = /* @__PURE__ */ T(((e, t) => {
1003
- var n = zt();
1175
+ })), mn = /* @__PURE__ */ D(((e, t) => {
1176
+ var n = fn();
1004
1177
  t.exports = (e, t, r) => n(e, t, "<", r);
1005
- })), Ht = /* @__PURE__ */ T(((e, t) => {
1006
- var n = R();
1178
+ })), hn = /* @__PURE__ */ D(((e, t) => {
1179
+ var n = U();
1007
1180
  t.exports = (e, t, r) => (e = new n(e, r), t = new n(t, r), e.intersects(t, r));
1008
- })), Ut = /* @__PURE__ */ T(((e, t) => {
1009
- var n = B(), r = I();
1181
+ })), gn = /* @__PURE__ */ D(((e, t) => {
1182
+ var n = G(), r = V();
1010
1183
  t.exports = (e, t, i) => {
1011
1184
  let a = [], o = null, s = null, c = e.sort((e, t) => r(e, t, i));
1012
1185
  for (let e of c) n(e, t, i) ? (s = e, o ||= e) : (s && a.push([o, s]), s = null, o = null);
@@ -1016,8 +1189,8 @@ var j = /* @__PURE__ */ T(((e, t) => {
1016
1189
  let u = l.join(" || "), d = typeof t.raw == "string" ? t.raw : String(t);
1017
1190
  return u.length < d.length ? u : t;
1018
1191
  };
1019
- })), Wt = /* @__PURE__ */ T(((e, t) => {
1020
- var n = R(), r = z(), { ANY: i } = r, a = B(), o = I(), s = (e, t, r = {}) => {
1192
+ })), _n = /* @__PURE__ */ D(((e, t) => {
1193
+ var n = U(), r = W(), { ANY: i } = r, a = G(), o = V(), s = (e, t, r = {}) => {
1021
1194
  if (e === t) return !0;
1022
1195
  e = new n(e, r), t = new n(t, r);
1023
1196
  let i = !1;
@@ -1075,46 +1248,46 @@ var j = /* @__PURE__ */ T(((e, t) => {
1075
1248
  return r < 0 ? e : r > 0 || t.operator === "<" && e.operator === "<=" ? t : e;
1076
1249
  };
1077
1250
  t.exports = s;
1078
- })), V = /* @__PURE__ */ Te((/* @__PURE__ */ T(((e, t) => {
1079
- var n = N(), r = j(), i = P(), a = ft();
1251
+ })), K = /* @__PURE__ */ ke((/* @__PURE__ */ D(((e, t) => {
1252
+ var n = R(), r = I(), i = z(), a = Rt();
1080
1253
  t.exports = {
1081
- parse: F(),
1082
- valid: pt(),
1083
- clean: mt(),
1084
- inc: ht(),
1085
- diff: gt(),
1086
- major: _t(),
1087
- minor: vt(),
1088
- patch: yt(),
1089
- prerelease: bt(),
1090
- compare: I(),
1091
- rcompare: xt(),
1092
- compareLoose: St(),
1093
- compareBuild: Ct(),
1094
- sort: wt(),
1095
- rsort: Tt(),
1096
- gt: L(),
1097
- lt: Et(),
1098
- eq: Dt(),
1099
- neq: Ot(),
1100
- gte: kt(),
1101
- lte: At(),
1102
- cmp: jt(),
1103
- coerce: Mt(),
1104
- Comparator: z(),
1105
- Range: R(),
1106
- satisfies: B(),
1107
- toComparators: Pt(),
1108
- maxSatisfying: Ft(),
1109
- minSatisfying: It(),
1110
- minVersion: Lt(),
1111
- validRange: Rt(),
1112
- outside: zt(),
1113
- gtr: Bt(),
1114
- ltr: Vt(),
1115
- intersects: Ht(),
1116
- simplifyRange: Ut(),
1117
- subset: Wt(),
1254
+ parse: B(),
1255
+ valid: zt(),
1256
+ clean: Bt(),
1257
+ inc: Vt(),
1258
+ diff: Ht(),
1259
+ major: Ut(),
1260
+ minor: Wt(),
1261
+ patch: Gt(),
1262
+ prerelease: Kt(),
1263
+ compare: V(),
1264
+ rcompare: qt(),
1265
+ compareLoose: Jt(),
1266
+ compareBuild: Yt(),
1267
+ sort: Xt(),
1268
+ rsort: Zt(),
1269
+ gt: H(),
1270
+ lt: Qt(),
1271
+ eq: $t(),
1272
+ neq: en(),
1273
+ gte: tn(),
1274
+ lte: nn(),
1275
+ cmp: rn(),
1276
+ coerce: an(),
1277
+ Comparator: W(),
1278
+ Range: U(),
1279
+ satisfies: G(),
1280
+ toComparators: sn(),
1281
+ maxSatisfying: cn(),
1282
+ minSatisfying: ln(),
1283
+ minVersion: un(),
1284
+ validRange: dn(),
1285
+ outside: fn(),
1286
+ gtr: pn(),
1287
+ ltr: mn(),
1288
+ intersects: hn(),
1289
+ simplifyRange: gn(),
1290
+ subset: _n(),
1118
1291
  SemVer: i,
1119
1292
  re: n.re,
1120
1293
  src: n.src,
@@ -1124,58 +1297,58 @@ var j = /* @__PURE__ */ T(((e, t) => {
1124
1297
  compareIdentifiers: a.compareIdentifiers,
1125
1298
  rcompareIdentifiers: a.rcompareIdentifiers
1126
1299
  };
1127
- })))()), Gt = "_updates_v2/per_package_version/";
1128
- function Kt(e, t) {
1129
- return `${Gt}${e.organization}/${e.name}/${e.version}/${t}`;
1300
+ })))()), vn = "_updates_v2/per_package_version/";
1301
+ function yn(e, t) {
1302
+ return `${vn}${e.organization}/${e.name}/${e.version}/${t}`;
1130
1303
  }
1131
- var qt = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, Jt = "_updates_v2/_global_update_in", Yt = "_updates_v2/_global_update_out", Xt = "_overview_snapshots_v2/global/", Zt = "_overview_snapshots_v2/per_package/", Qt = /^(?<timestamp>\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}Z-[a-z0-9]+)\.json\.gz$/;
1132
- function $t(e) {
1133
- return `${Xt}${e}.json.gz`;
1304
+ var bn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, xn = "_updates_v2/_global_update_in", Sn = "_updates_v2/_global_update_out", Cn = "_overview_snapshots_v2/global/", wn = "_overview_snapshots_v2/per_package/", Tn = /^(?<timestamp>\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}Z-[a-z0-9]+)\.json\.gz$/;
1305
+ function En(e) {
1306
+ return `${Cn}${e}.json.gz`;
1134
1307
  }
1135
- function en(e, t) {
1136
- return `${Zt}${e.organization}/${e.name}/${t}.json.gz`;
1308
+ function Dn(e, t) {
1309
+ return `${wn}${e.organization}/${e.name}/${t}.json.gz`;
1137
1310
  }
1138
1311
  //#endregion
1139
1312
  //#region src/v2/registry/schema_public.ts
1140
- var tn = "v2/", nn = "overview.json", rn = "overview.json.gz", an = "overview.json", H = "manifest.json", U = "channels", W = /^[-a-z0-9]+$/;
1141
- function G(e) {
1313
+ var On = "v2/", kn = "overview.json", An = "overview.json.gz", jn = "overview.json", q = "manifest.json", Mn = "channels", Nn = /^[-a-z0-9]+$/;
1314
+ function J(e) {
1142
1315
  return `${e.organization}/${e.name}/${e.version}`;
1143
1316
  }
1144
- function K(e) {
1145
- return `v2/${G(e)}`;
1317
+ function Y(e) {
1318
+ return `v2/${J(e)}`;
1146
1319
  }
1147
- var on = "/" + H, sn = S.object({
1320
+ var Pn = "/" + q, Fn = S.object({
1148
1321
  description: l,
1149
1322
  channels: S.array(S.string()).default(() => []),
1150
- manifestSha256: m
1151
- }).passthrough(), q = S.object({
1323
+ manifestSha256: h
1324
+ }).passthrough(), In = S.object({
1152
1325
  schema: S.literal("v2"),
1153
- versions: S.array(sn)
1326
+ versions: S.array(Fn)
1154
1327
  }).passthrough();
1155
- function cn(e) {
1156
- return `${e.organization}/${e.name}/${an}`;
1328
+ function Ln(e) {
1329
+ return `${e.organization}/${e.name}/${jn}`;
1157
1330
  }
1158
- function ln(e) {
1159
- return `v2/${cn(e)}`;
1331
+ function Rn(e) {
1332
+ return `v2/${Ln(e)}`;
1160
1333
  }
1161
- function un(e) {
1162
- return `${G(e)}/${U}/`;
1334
+ function zn(e) {
1335
+ return `${J(e)}/${Mn}/`;
1163
1336
  }
1164
- function dn(e) {
1165
- return `v2/${un(e)}`;
1337
+ function Bn(e) {
1338
+ return `v2/${zn(e)}`;
1166
1339
  }
1167
- var fn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/manifest\.json$/, J = `v2/${nn}`, pn = `v2/${rn}`, mn = S.object({
1168
- id: u,
1340
+ var Vn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/manifest\.json$/, X = `v2/${kn}`, Hn = `v2/${An}`, Un = S.object({
1341
+ id: d,
1169
1342
  allVersions: S.array(S.string()).optional(),
1170
- allVersionsWithChannels: S.array(h).optional(),
1343
+ allVersionsWithChannels: S.array(_).optional(),
1171
1344
  latest: l.optional(),
1172
- latestManifestSha256: m.optional(),
1345
+ latestManifestSha256: h.optional(),
1173
1346
  latestByChannel: S.record(S.string(), S.object({
1174
1347
  description: l,
1175
- manifestSha256: m
1348
+ manifestSha256: h
1176
1349
  }).passthrough()).default({})
1177
1350
  }).passthrough();
1178
- function hn(e) {
1351
+ function Wn(e) {
1179
1352
  let t = `${e.id.organization}/${e.id.name}`, n = e.allVersionsWithChannels;
1180
1353
  if (n === void 0) {
1181
1354
  if (e.allVersions === void 0) throw Error(`GlobalOverviewEntry ${t} is missing both 'allVersionsWithChannels' and the deprecated 'allVersions' fallback`);
@@ -1201,23 +1374,23 @@ function hn(e) {
1201
1374
  latestByChannel: r
1202
1375
  };
1203
1376
  }
1204
- var gn = S.object({
1377
+ var Gn = S.object({
1205
1378
  schema: S.literal("v2"),
1206
- packages: S.array(mn)
1379
+ packages: S.array(Un)
1207
1380
  }).passthrough();
1208
- function Y(e) {
1209
- let t = gn.parse(e);
1381
+ function Z(e) {
1382
+ let t = Gn.parse(e);
1210
1383
  return {
1211
1384
  ...t,
1212
- packages: t.packages.map(hn)
1385
+ packages: t.packages.map(Wn)
1213
1386
  };
1214
1387
  }
1215
1388
  //#endregion
1216
1389
  //#region src/v2/registry/registry.ts
1217
- var _n = class {
1218
- gzipAsync = le(re);
1219
- gunzipAsync = le(te);
1220
- constructor(e, t = new oe(), n = {}) {
1390
+ var Kn = class {
1391
+ gzipAsync = pe(ae);
1392
+ gunzipAsync = pe(re);
1393
+ constructor(e, t = new ue(), n = {}) {
1221
1394
  this.storage = e, this.logger = t, this.settings = n;
1222
1395
  }
1223
1396
  generateTimestamp() {
@@ -1228,7 +1401,7 @@ var _n = class {
1228
1401
  }
1229
1402
  async createGlobalOverviewSnapshot(e, t) {
1230
1403
  if (!this.settings.skipSnapshotCreation) try {
1231
- let n = await this.gzipAsync(e), r = $t(t);
1404
+ let n = await this.gzipAsync(e), r = En(t);
1232
1405
  await this.storage.putFile(r, Buffer.from(n)), this.logger.info(`Global overview snapshot created at ${r}`);
1233
1406
  } catch (e) {
1234
1407
  this.logger.warn(`Failed to create global overview snapshot: ${String(e)}`);
@@ -1236,7 +1409,7 @@ var _n = class {
1236
1409
  }
1237
1410
  async createPackageOverviewSnapshot(e, t, n) {
1238
1411
  if (!this.settings.skipSnapshotCreation) try {
1239
- let r = JSON.stringify(t), i = await this.gzipAsync(r), a = en(e, n);
1412
+ let r = JSON.stringify(t), i = await this.gzipAsync(r), a = Dn(e, n);
1240
1413
  await this.storage.putFile(a, Buffer.from(i)), this.logger.info(`Package overview snapshot created at ${a} for ${e.organization}:${e.name}`);
1241
1414
  } catch (t) {
1242
1415
  this.logger.warn(`Failed to create package overview snapshot for ${e.organization}:${e.name}: ${String(t)}`);
@@ -1244,7 +1417,17 @@ var _n = class {
1244
1417
  }
1245
1418
  async updateRegistry(e = "normal") {
1246
1419
  this.logger.info("Initiating registry refresh...");
1247
- let t = this.generateTimestamp(), n = /* @__PURE__ */ new Map(), r = [], i = await this.storage.listFiles(Gt), a = ({ organization: e, name: t, version: r }) => {
1420
+ let t = this.generateTimestamp(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = [], a = (t, n) => {
1421
+ let i = r.get(t) ?? (e === "force" ? {
1422
+ rebuild: !0,
1423
+ add: []
1424
+ } : {
1425
+ rebuild: !1,
1426
+ replacedBlockIds: /* @__PURE__ */ new Set(),
1427
+ add: []
1428
+ });
1429
+ return i.rebuild || i.replacedBlockIds.add(n), r.set(t, i), i;
1430
+ }, o = await this.storage.listFiles(vn), c = ({ organization: e, name: t, version: r }) => {
1248
1431
  let i = `${e}:${t}`, a = n.get(i);
1249
1432
  return a ? a.versions.has(r) ? !1 : (a.versions.add(r), !0) : (n.set(i, {
1250
1433
  package: {
@@ -1255,111 +1438,153 @@ var _n = class {
1255
1438
  }), !0);
1256
1439
  };
1257
1440
  this.logger.info("Packages to be updated:");
1258
- for (let e of i) {
1259
- let t = e.match(qt);
1441
+ for (let e of o) {
1442
+ let t = e.match(bn);
1260
1443
  if (!t) continue;
1261
- r.push(e);
1262
- let { organization: n, name: i, version: o, seed: s } = t.groups, c = a({
1444
+ i.push(e);
1445
+ let { organization: n, name: r, version: a, seed: o } = t.groups, s = c({
1263
1446
  organization: n,
1264
- name: i,
1265
- version: o
1447
+ name: r,
1448
+ version: a
1266
1449
  });
1267
- this.logger.info(` - ${n}:${i}:${o} added:${c}`);
1450
+ this.logger.info(` - ${n}:${r}:${a} added:${s}`);
1268
1451
  }
1269
1452
  if (e === "force") {
1270
1453
  let e = await this.storage.listFiles("v2/");
1271
1454
  for (let t of e) {
1272
- let e = t.match(fn);
1455
+ let e = t.match(Vn);
1273
1456
  if (!e) continue;
1274
- let { organization: n, name: r, version: i } = e.groups, o = a({
1457
+ let { organization: n, name: r, version: i } = e.groups, a = c({
1275
1458
  organization: n,
1276
1459
  name: r,
1277
1460
  version: i
1278
1461
  });
1279
- this.logger.info(` - ${n}:${r}:${i} force_added:${o}`);
1462
+ this.logger.info(` - ${n}:${r}:${i} force_added:${a}`);
1280
1463
  }
1464
+ let t = await this.storage.listFiles(M);
1465
+ for (let e of t) bt.test(e) && r.set(M + e, {
1466
+ rebuild: !0,
1467
+ add: []
1468
+ });
1281
1469
  }
1282
- let o = await this.storage.getFile(J);
1283
- if (e === "force" && o !== void 0) {
1470
+ let l = await this.storage.getFile(X);
1471
+ if (e === "force" && l !== void 0) {
1284
1472
  let e = this.generatePreWriteTimestamp();
1285
- await this.createGlobalOverviewSnapshot(o.toString(), e);
1473
+ await this.createGlobalOverviewSnapshot(l.toString(), e);
1286
1474
  }
1287
- let c = (e === "force" || o === void 0 ? {
1475
+ let u = (e === "force" || l === void 0 ? {
1288
1476
  schema: "v2",
1289
1477
  packages: []
1290
- } : Y(JSON.parse(o.toString()))).packages;
1291
- this.logger.info(`Global overview ${e === "force" ? "starting empty (force mode)" : "loaded"}, ${c.length} records`);
1478
+ } : Z(JSON.parse(l.toString()))).packages;
1479
+ this.logger.info(`Global overview ${e === "force" ? "starting empty (force mode)" : "loaded"}, ${u.length} records`);
1292
1480
  for (let [, r] of n.entries()) {
1293
- let n = ln(r.package), i = await this.storage.getFile(n);
1481
+ let n = Rn(r.package), i = await this.storage.getFile(n);
1294
1482
  if (e === "force" && i !== void 0) {
1295
- let e = this.generatePreWriteTimestamp(), t = q.parse(JSON.parse(i.toString()));
1483
+ let e = this.generatePreWriteTimestamp(), t = In.parse(JSON.parse(i.toString()));
1296
1484
  await this.createPackageOverviewSnapshot(r.package, t, e);
1297
1485
  }
1298
- let a = e === "force" || i === void 0 ? {
1486
+ let o = e === "force" || i === void 0 ? {
1299
1487
  schema: "v2",
1300
1488
  versions: []
1301
- } : q.parse(JSON.parse(i.toString()));
1302
- this.logger.info(`Updating ${r.package.organization}:${r.package.name} overview${e === "force" ? " (starting empty in force mode)" : ""}, ${a.versions.length} records`);
1303
- let o = a.versions.filter((e) => !r.versions.has(e.description.id.version));
1489
+ } : In.parse(JSON.parse(i.toString()));
1490
+ this.logger.info(`Updating ${r.package.organization}:${r.package.name} overview${e === "force" ? " (starting empty in force mode)" : ""}, ${o.versions.length} records`);
1491
+ let c = o.versions.filter((e) => r.versions.has(e.description.id.version)), l = o.versions.filter((e) => !r.versions.has(e.description.id.version));
1492
+ for (let e of c) e.description.kind && a(yt(N(x(e.description.kind).name)), b(e.description.id));
1304
1493
  for (let [e] of r.versions.entries()) {
1305
1494
  let t = e.toString(), n = {
1306
1495
  ...r.package,
1307
1496
  version: t
1308
- }, i = await this.storage.getFile(K(n) + on);
1497
+ }, i = await this.storage.getFile(Y(n) + Pn);
1309
1498
  if (!i) continue;
1310
- let a = await O(i), s = (await this.storage.listFiles(dn(n))).filter((e) => e.match(W) ? !0 : (this.logger.warn(`Unexpected channel in ${v(n)}: ${e}`), !1));
1311
- o.push({
1312
- description: D(d.parse(JSON.parse(i.toString("utf8"))).description, t),
1313
- manifestSha256: a,
1499
+ let o = await A(i), s = (await this.storage.listFiles(Bn(n))).filter((e) => e.match(Nn) ? !0 : (this.logger.warn(`Unexpected channel in ${b(n)}: ${e}`), !1)), c = f.parse(JSON.parse(i.toString("utf8"))).description;
1500
+ if (l.push({
1501
+ description: k(c, t),
1502
+ manifestSha256: o,
1314
1503
  channels: s
1315
- });
1504
+ }), c.kind) {
1505
+ let { name: e, version: t } = x(c.kind);
1506
+ a(yt(N(e)), b(n)).add.push({
1507
+ id: n,
1508
+ kindVersion: t,
1509
+ channels: s
1510
+ });
1511
+ }
1316
1512
  }
1317
- o.sort((e, t) => (0, V.compare)(t.description.id.version, e.description.id.version));
1318
- let l = {
1513
+ l.sort((e, t) => (0, K.compare)(t.description.id.version, e.description.id.version));
1514
+ let d = {
1319
1515
  schema: "v2",
1320
- versions: o
1516
+ versions: l
1321
1517
  };
1322
- e !== "dry-run" && (await this.storage.putFile(n, Buffer.from(JSON.stringify(l))), await this.createPackageOverviewSnapshot(r.package, l, t)), this.logger.info(`Done (${o.length} records)`);
1323
- let u = /* @__PURE__ */ new Set();
1324
- for (let e of o) for (let t of e.channels) u.add(t);
1325
- c = c.filter((e) => e.id.organization !== r.package.organization || e.id.name !== r.package.name);
1326
- let f = `${r.package.organization}/${r.package.name}`;
1327
- c.push({
1518
+ e !== "dry-run" && (await this.storage.putFile(n, Buffer.from(JSON.stringify(d))), await this.createPackageOverviewSnapshot(r.package, d, t)), this.logger.info(`Done (${l.length} records)`);
1519
+ let p = /* @__PURE__ */ new Set();
1520
+ for (let e of l) for (let t of e.channels) p.add(t);
1521
+ u = u.filter((e) => e.id.organization !== r.package.organization || e.id.name !== r.package.name);
1522
+ let m = `${r.package.organization}/${r.package.name}`;
1523
+ u.push({
1328
1524
  id: {
1329
1525
  organization: r.package.organization,
1330
1526
  name: r.package.name
1331
1527
  },
1332
- allVersions: o.map((e) => e.description.id.version).reverse(),
1333
- allVersionsWithChannels: o.map((e) => ({
1528
+ allVersions: l.map((e) => e.description.id.version).reverse(),
1529
+ allVersionsWithChannels: l.map((e) => ({
1334
1530
  version: e.description.id.version,
1335
1531
  channels: e.channels
1336
1532
  })).reverse(),
1337
- latest: D(o[0].description, f),
1338
- latestManifestSha256: o[0].manifestSha256,
1339
- latestByChannel: Object.fromEntries([...u, s].map((e) => {
1340
- let t = o.find((t) => e === s || t.channels.indexOf(e) !== -1);
1533
+ latest: k(l[0].description, m),
1534
+ latestManifestSha256: l[0].manifestSha256,
1535
+ latestByChannel: Object.fromEntries([...p, s].map((e) => {
1536
+ let t = l.find((t) => e === s || t.channels.indexOf(e) !== -1);
1341
1537
  if (!t) throw Error("Assertion error");
1342
1538
  return [e, {
1343
- description: D(t.description, f),
1539
+ description: k(t.description, m),
1344
1540
  manifestSha256: t?.manifestSha256
1345
1541
  }];
1346
1542
  }))
1347
1543
  });
1348
1544
  }
1545
+ for (let [t, n] of r) {
1546
+ let r = [...n.rebuild ? [] : ((await this.getKindOverviewAt(t))?.implementers ?? []).filter((e) => !n.replacedBlockIds.has(b(e.id))), ...n.add];
1547
+ if (r.length === 0) {
1548
+ e !== "dry-run" && await this.storage.deleteFiles(t), this.logger.info(`Kind overview ${t} orphaned — removed`);
1549
+ continue;
1550
+ }
1551
+ let i = /* @__PURE__ */ new Map();
1552
+ for (let e of r) {
1553
+ let t = i.get(e.kindVersion);
1554
+ t ? t.push(e) : i.set(e.kindVersion, [e]);
1555
+ }
1556
+ let a = [...i.entries()].map(([e, t]) => {
1557
+ let n = /* @__PURE__ */ new Set();
1558
+ for (let e of t) for (let t of e.channels) n.add(t);
1559
+ return {
1560
+ kindVersion: e,
1561
+ latestByChannel: Object.fromEntries([...n, s].map((e) => {
1562
+ let n = t.filter((t) => e === s || t.channels.indexOf(e) !== -1).sort((e, t) => (0, K.compare)(t.id.version, e.id.version))[0];
1563
+ if (!n) throw Error("Assertion error");
1564
+ return [e, n.id];
1565
+ }))
1566
+ };
1567
+ }).sort((e, t) => (0, K.compare)(t.kindVersion, e.kindVersion)), o = {
1568
+ schema: "v1",
1569
+ implementers: r,
1570
+ kindVersions: a
1571
+ };
1572
+ e !== "dry-run" && await this.storage.putFile(t, Buffer.from(JSON.stringify(o))), this.logger.info(`Kind overview ${t} updated (${r.length} implementers, ${a.length} kind versions)`);
1573
+ }
1349
1574
  if (e !== "dry-run") {
1350
1575
  let e = JSON.stringify({
1351
1576
  schema: "v2",
1352
- packages: c
1577
+ packages: u
1353
1578
  }), n = Buffer.from(e);
1354
- await this.storage.putFile(J, n);
1579
+ await this.storage.putFile(X, n);
1355
1580
  let r = await this.gzipAsync(e);
1356
- await this.storage.putFile(pn, Buffer.from(r)), await this.createGlobalOverviewSnapshot(e, t);
1581
+ await this.storage.putFile(Hn, Buffer.from(r)), await this.createGlobalOverviewSnapshot(e, t);
1357
1582
  }
1358
- this.logger.info(`Global overview updated (${c.length} records)`), e !== "dry-run" && await this.storage.deleteFiles(...r.map((e) => `${Gt}${e}`)), this.logger.info("Version update requests cleared");
1583
+ this.logger.info(`Global overview updated (${u.length} records)`), e !== "dry-run" && await this.storage.deleteFiles(...i.map((e) => `${vn}${e}`)), this.logger.info("Version update requests cleared");
1359
1584
  }
1360
1585
  async updateIfNeeded(e = "normal") {
1361
1586
  this.logger.info("Checking if registry requires refresh...");
1362
- let t = await this.storage.getFile(Jt), n = await this.storage.getFile(Yt);
1587
+ let t = await this.storage.getFile(xn), n = await this.storage.getFile(Sn);
1363
1588
  if (e !== "force" && t === void 0 && n === void 0) {
1364
1589
  this.logger.info("No global seed files found, update not needed.");
1365
1590
  return;
@@ -1368,76 +1593,163 @@ var _n = class {
1368
1593
  this.logger.info("Registry is up to date.");
1369
1594
  return;
1370
1595
  }
1371
- await this.updateRegistry(e), t && (e !== "dry-run" && await this.storage.putFile(Yt, t), this.logger.info("Refresh finished."));
1596
+ await this.updateRegistry(e), t && (e !== "dry-run" && await this.storage.putFile(Sn, t), this.logger.info("Refresh finished."));
1372
1597
  }
1373
1598
  async getPackageOverview(e) {
1374
- let t = await this.storage.getFile(ln(e));
1375
- if (t !== void 0) return q.parse(JSON.parse(t.toString()));
1599
+ let t = await this.storage.getFile(Rn(e));
1600
+ if (t !== void 0) return In.parse(JSON.parse(t.toString()));
1376
1601
  }
1377
1602
  async getGlobalOverview() {
1378
- let e = await this.storage.getFile(J);
1379
- if (e !== void 0) return Y(JSON.parse(e.toString()));
1603
+ let e = await this.storage.getFile(X);
1604
+ if (e !== void 0) return Z(JSON.parse(e.toString()));
1605
+ }
1606
+ async getKindOverviewAt(e) {
1607
+ let t = await this.storage.getFile(e);
1608
+ if (t !== void 0) return Tt.parse(JSON.parse(t.toString()));
1380
1609
  }
1381
1610
  async marchChanged(e) {
1382
- let t = ae(), n = Kt(e, t);
1383
- this.logger.info(`Creating update seed at ${n} ...`), await this.storage.putFile(n, Buffer.from(t)), this.logger.info(`Touching global update seed ${Jt} ...`), await this.storage.putFile(Jt, Buffer.from(t));
1611
+ let t = se(), n = yn(e, t);
1612
+ this.logger.info(`Creating update seed at ${n} ...`), await this.storage.putFile(n, Buffer.from(t)), this.logger.info(`Touching global update seed ${xn} ...`), await this.storage.putFile(xn, Buffer.from(t));
1384
1613
  }
1385
1614
  async addPackageToChannel(e, t) {
1386
- if (!t.match(W)) throw Error(`Illegal characters in channel name: ${t}`);
1387
- let n = K(e);
1388
- if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${v(e)} not found in the registry.`);
1389
- await this.storage.putFile(`${n}/${U}/${t}`, Buffer.from(t)), await this.marchChanged(e);
1615
+ if (!t.match(Nn)) throw Error(`Illegal characters in channel name: ${t}`);
1616
+ let n = Y(e);
1617
+ if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${b(e)} not found in the registry.`);
1618
+ await this.storage.putFile(`${n}/${Mn}/${t}`, Buffer.from(t)), await this.marchChanged(e);
1390
1619
  }
1391
1620
  async removePackageFromChannel(e, t) {
1392
- if (!t.match(W)) throw Error(`Illegal characters in channel name: ${t}`);
1393
- let n = K(e);
1394
- if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${v(e)} not found in the registry.`);
1395
- await this.storage.deleteFiles(`${n}/${U}/${t}`), await this.marchChanged(e);
1621
+ if (!t.match(Nn)) throw Error(`Illegal characters in channel name: ${t}`);
1622
+ let n = Y(e);
1623
+ if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${b(e)} not found in the registry.`);
1624
+ await this.storage.deleteFiles(`${n}/${Mn}/${t}`), await this.marchChanged(e);
1396
1625
  }
1397
1626
  async listGlobalOverviewSnapshots() {
1398
- let e = await this.storage.listFiles(Xt), t = [];
1627
+ let e = await this.storage.listFiles(Cn), t = [];
1399
1628
  for (let n of e) {
1400
- let e = n.indexOf("/") === -1 ? n : n.substring(n.lastIndexOf("/") + 1), r = e.match(Qt);
1629
+ let e = n.indexOf("/") === -1 ? n : n.substring(n.lastIndexOf("/") + 1), r = e.match(Tn);
1401
1630
  r && t.push({
1402
1631
  timestamp: r.groups.timestamp,
1403
- path: Xt + e
1632
+ path: Cn + e
1404
1633
  });
1405
1634
  }
1406
1635
  return t.sort((e, t) => t.timestamp.localeCompare(e.timestamp)), t;
1407
1636
  }
1408
1637
  async restoreGlobalOverviewFromSnapshot(e) {
1409
- let t = $t(e), n = await this.storage.getFile(t);
1638
+ let t = En(e), n = await this.storage.getFile(t);
1410
1639
  if (!n) throw Error(`Snapshot ${e} not found at ${t}`);
1411
1640
  let r = (await this.gunzipAsync(n)).toString("utf8");
1412
1641
  try {
1413
- Y(JSON.parse(r));
1642
+ Z(JSON.parse(r));
1414
1643
  } catch (t) {
1415
1644
  throw Error(`Invalid snapshot data in ${e}: ${String(t)}`);
1416
1645
  }
1417
1646
  let i = Buffer.from(r);
1418
- await this.storage.putFile(J, i);
1647
+ await this.storage.putFile(X, i);
1419
1648
  let a = await this.gzipAsync(r);
1420
- await this.storage.putFile(pn, Buffer.from(a)), this.logger.info(`Global overview restored from snapshot ${e}`);
1649
+ await this.storage.putFile(Hn, Buffer.from(a)), this.logger.info(`Global overview restored from snapshot ${e}`);
1421
1650
  }
1422
1651
  async publishPackage(e, t) {
1423
- let n = K(e.description.id);
1652
+ let n = Y(e.description.id);
1424
1653
  for (let r of e.files) {
1425
1654
  let e = await t(r.name);
1426
1655
  if (e.length !== r.size) throw Error(`Actual file size don't match file size from the manifest file for ${r.name} (actual = ${e.length}; manifest = ${r.size})`);
1427
- let i = await O(e);
1656
+ let i = await A(e);
1428
1657
  if (i !== r.sha256.toUpperCase()) throw Error(`Actual file SHA-256 don't match the checksum from the manifest file for ${r.name} (actual = ${i}; manifest = ${r.sha256.toUpperCase()})`);
1429
1658
  let a = n + "/" + r.name;
1430
1659
  this.logger.info(`Uploading ${r.name} -> ${a} ...`), await this.storage.putFile(a, e);
1431
1660
  }
1432
- let r = n + "/" + H;
1661
+ let r = n + "/" + q;
1433
1662
  this.logger.info(`Uploading manifest to ${r} ...`), await this.storage.putFile(r, Buffer.from(JSON.stringify(e))), await this.marchChanged(e.description.id);
1434
1663
  }
1435
- }, vn = {
1664
+ async publishKind(e, t) {
1665
+ let { name: n, version: r } = e.kind, i = vt(n, r), a = await this.storage.getFile(`${i}/${_t}`);
1666
+ if (a !== void 0) {
1667
+ let t = P.parse(JSON.parse(a.toString()));
1668
+ if (t.sourceHash === e.sourceHash) {
1669
+ this.logger.info(`Kind ${n}@${r} already published with identical source — no-op`);
1670
+ return;
1671
+ }
1672
+ throw Error(`Immutable kind version republished with different content: ${i} (stored sourceHash ${t.sourceHash} != ${e.sourceHash})`);
1673
+ }
1674
+ for (let n of e.files) {
1675
+ let e = await t(n.name);
1676
+ if (e.length !== n.size) throw Error(`Actual file size don't match the manifest for ${n.name} (actual = ${e.length}; manifest = ${n.size})`);
1677
+ let r = await A(e);
1678
+ if (r !== n.sha256.toUpperCase()) throw Error(`Actual file SHA-256 don't match the manifest for ${n.name} (actual = ${r}; manifest = ${n.sha256.toUpperCase()})`);
1679
+ let a = `${i}/${n.name}`;
1680
+ this.logger.info(`Uploading ${n.name} -> ${a} ...`), await this.storage.putFile(a, e);
1681
+ }
1682
+ let o = P.parse({
1683
+ ...e,
1684
+ firstUploadTimestamp: e.firstUploadTimestamp ?? Date.now()
1685
+ }), s = `${i}/${_t}`;
1686
+ this.logger.info(`Uploading kind manifest to ${s} ...`), await this.storage.putFile(s, Buffer.from(JSON.stringify(o)));
1687
+ }
1688
+ };
1689
+ //#endregion
1690
+ //#region src/v2/registry/kind_resolver.ts
1691
+ function qn(e) {
1692
+ let t = e.trim();
1693
+ switch (t[0]) {
1694
+ case "~": return {
1695
+ op: "patch",
1696
+ version: t.slice(1)
1697
+ };
1698
+ case "^": return {
1699
+ op: "minor",
1700
+ version: t.slice(1)
1701
+ };
1702
+ case "@": return {
1703
+ op: "exact",
1704
+ version: t.slice(1)
1705
+ };
1706
+ default: return {
1707
+ op: "exact",
1708
+ version: t
1709
+ };
1710
+ }
1711
+ }
1712
+ function Jn(e) {
1713
+ if (e.op === "exact") return `=${e.version}`;
1714
+ let t = K.major(e.version), n = K.minor(e.version), r = e.op === "patch" ? `${t}.${n + 1}.0` : `${t + 1}.0.0`;
1715
+ return `>=${e.version} <${r}-0`;
1716
+ }
1717
+ var Yn = class extends Error {
1718
+ constructor(e, t) {
1719
+ super(`Cannot resolve block kind "${t}": ${e}`), this.reason = e, this.ref = t, this.name = "KindResolutionError";
1720
+ }
1721
+ };
1722
+ function Xn(e, t, n, r) {
1723
+ let i = e.filter((e) => K.eq(e.kindVersion, t) && (r || e.channels.includes(n)));
1724
+ if (i.length !== 0) return i.reduce((e, t) => K.gt(t.id.version, e.id.version) ? t : e).id;
1725
+ }
1726
+ function Zn(e, t, n) {
1727
+ let r = Jn(typeof t == "string" ? qn(t) : t), i = e.kindVersions.map((e) => e.kindVersion), a = K.maxSatisfying(i, r);
1728
+ if (a === null) return {
1729
+ ok: !1,
1730
+ reason: "no-matching-kind-version"
1731
+ };
1732
+ let o = e.kindVersions.find((e) => K.eq(e.kindVersion, a)), c = n.allowUnstable ? s : g, l = Xn(e.implementers, a, c, n.allowUnstable) ?? o?.latestByChannel[c];
1733
+ return l ? {
1734
+ ok: !0,
1735
+ blockId: l,
1736
+ channel: c
1737
+ } : e.implementers.some((e) => K.eq(e.kindVersion, a)) || o !== void 0 && Object.keys(o.latestByChannel).length > 0 ? {
1738
+ ok: !1,
1739
+ reason: "no-stable-implementation"
1740
+ } : {
1741
+ ok: !1,
1742
+ reason: "no-implementation"
1743
+ };
1744
+ }
1745
+ //#endregion
1746
+ //#region src/v2/registry/registry_reader.ts
1747
+ var Qn = {
1436
1748
  cacheBlockListFor: 45e3,
1437
1749
  keepStaleBlockListFor: 3e5
1438
1750
  };
1439
- function yn(e, t) {
1440
- let n = V.inc(e, "minor"), r = V.inc(e, "major"), i = [], a = t.find((t) => V.gt(t, e) && V.lt(t, n)), o = t.find((e) => V.gte(e, n) && V.lt(e, r)), s = t.find((e) => V.gte(e, r));
1751
+ function $n(e, t) {
1752
+ let n = K.inc(e, "minor"), r = K.inc(e, "major"), i = [], a = t.find((t) => K.gt(t, e) && K.lt(t, n)), o = t.find((e) => K.gte(e, n) && K.lt(e, r)), s = t.find((e) => K.gte(e, r));
1441
1753
  return a && i.push({
1442
1754
  type: "patch",
1443
1755
  update: a
@@ -1449,24 +1761,25 @@ function yn(e, t) {
1449
1761
  update: s
1450
1762
  }), i;
1451
1763
  }
1452
- var bn = class {
1764
+ var er = class {
1453
1765
  v2RootFolderReader;
1766
+ kindsRootFolderReader;
1454
1767
  ops;
1455
1768
  constructor(e, t) {
1456
- this.registryReader = e, this.v2RootFolderReader = e.relativeReader("v2/"), this.ops = {
1457
- ...vn,
1769
+ this.registryReader = e, this.v2RootFolderReader = e.relativeReader("v2/"), this.kindsRootFolderReader = e.relativeReader(M), this.ops = {
1770
+ ...Qn,
1458
1771
  ...t
1459
1772
  };
1460
1773
  }
1461
- embeddedGlobalMetaCache = new de({
1774
+ embeddedGlobalMetaCache = new he({
1462
1775
  max: 500,
1463
- fetchMethod: async (e, t, n) => await x(async () => {
1464
- let e = n.context.relativeTo === void 0 ? this.v2RootFolderReader.getContentReader() : this.v2RootFolderReader.relativeReader(G(n.context.relativeTo)).getContentReader();
1465
- return await We(n.context.meta, e);
1466
- }, b)
1776
+ fetchMethod: async (e, t, n) => await w(async () => {
1777
+ let e = n.context.relativeTo === void 0 ? this.v2RootFolderReader.getContentReader() : this.v2RootFolderReader.relativeReader(J(n.context.relativeTo)).getContentReader();
1778
+ return await Je(n.context.meta, e);
1779
+ }, C)
1467
1780
  });
1468
1781
  async embedMetaContent(e, t, n, r) {
1469
- return await this.embeddedGlobalMetaCache.forceFetch(ue({
1782
+ return await this.embeddedGlobalMetaCache.forceFetch(me({
1470
1783
  id: e,
1471
1784
  sha256: t,
1472
1785
  absolutePath: n
@@ -1480,8 +1793,8 @@ var bn = class {
1480
1793
  async listBlockPacks(e) {
1481
1794
  if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor) return this.listCache;
1482
1795
  try {
1483
- return await x(async () => {
1484
- let t = Y(JSON.parse(Buffer.from(await this.v2RootFolderReader.readFile(nn, { signal: e?.signal })).toString())), n = await Promise.all(t.packages.map(async (e) => {
1796
+ return await w(async () => {
1797
+ let t = Z(JSON.parse(Buffer.from(await this.v2RootFolderReader.readFile(kn, { signal: e?.signal })).toString())), n = await Promise.all(t.packages.map(async (e) => {
1485
1798
  let t = await Promise.all(Object.entries(e.latestByChannel).map(async ([e, t]) => [e, {
1486
1799
  id: t.description.id,
1487
1800
  meta: await this.embedMetaContent(t.description.id, t.manifestSha256, !0, t.description.meta),
@@ -1500,28 +1813,28 @@ var bn = class {
1500
1813
  };
1501
1814
  }));
1502
1815
  return this.listCache = n, this.listCacheTimestamp = Date.now(), n;
1503
- }, b);
1816
+ }, C);
1504
1817
  } catch (e) {
1505
1818
  if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor) return this.listCache;
1506
1819
  throw e;
1507
1820
  }
1508
1821
  }
1509
1822
  async getLatestOverview(e, t) {
1510
- let n = (await this.listBlockPacks()).find((t) => _(e, t.id));
1823
+ let n = (await this.listBlockPacks()).find((t) => y(e, t.id));
1511
1824
  if (n !== void 0) return n.latestByChannel[t];
1512
1825
  }
1513
1826
  async getUpdateSuggestions(e, t) {
1514
- let n = (await this.listBlockPacks()).find((t) => _(e, t.id));
1827
+ let n = (await this.listBlockPacks()).find((t) => y(e, t.id));
1515
1828
  if (n === void 0) return;
1516
1829
  let r = n.allVersions.filter((e) => t === s || e.channels.indexOf(t) >= 0).map((e) => e.version);
1517
- return r.reverse(), yn(e.version, r);
1830
+ return r.reverse(), $n(e.version, r);
1518
1831
  }
1519
1832
  async getSpecificOverview(e, t) {
1520
- return await x(async () => {
1521
- let n = await this.v2RootFolderReader.readFile(G(e) + on), r = d.parse(JSON.parse(Buffer.from(n).toString()));
1833
+ return await w(async () => {
1834
+ let n = await this.v2RootFolderReader.readFile(J(e) + Pn), r = f.parse(JSON.parse(Buffer.from(n).toString()));
1522
1835
  return {
1523
1836
  id: e,
1524
- meta: await this.embedMetaContent(e, await O(n), !1, r.description.meta),
1837
+ meta: await this.embedMetaContent(e, await A(n), !1, r.description.meta),
1525
1838
  spec: {
1526
1839
  type: "from-registry-v2",
1527
1840
  id: e,
@@ -1529,19 +1842,42 @@ var bn = class {
1529
1842
  channel: t
1530
1843
  }
1531
1844
  };
1532
- }, b);
1845
+ }, C);
1533
1846
  }
1534
- componentsCache = new de({
1847
+ componentsCache = new he({
1535
1848
  max: 500,
1536
- fetchMethod: async (e, t, { context: n }) => await x(async () => {
1537
- let e = this.v2RootFolderReader.relativeReader(G(n));
1538
- return Je(d.parse(JSON.parse(Buffer.from(await e.readFile(H)).toString())).description.components, e.rootUrl.toString());
1539
- }, b)
1849
+ fetchMethod: async (e, t, { context: n }) => await w(async () => {
1850
+ let e = this.v2RootFolderReader.relativeReader(J(n));
1851
+ return Qe(f.parse(JSON.parse(Buffer.from(await e.readFile(q)).toString())).description.components, e.rootUrl.toString());
1852
+ }, C)
1540
1853
  });
1541
1854
  async getComponents(e) {
1542
- return await this.componentsCache.forceFetch(ue(e), { context: e });
1855
+ return await this.componentsCache.forceFetch(me(e), { context: e });
1856
+ }
1857
+ async getKindOverview(e, t) {
1858
+ let { org: n, name: r } = N(e), i = `${n}/${r}/${gt}`;
1859
+ try {
1860
+ return await w(async () => {
1861
+ let e = await this.kindsRootFolderReader.readFile(i, { signal: t?.signal });
1862
+ return Tt.parse(JSON.parse(Buffer.from(e).toString()));
1863
+ }, C);
1864
+ } catch {
1865
+ return;
1866
+ }
1867
+ }
1868
+ async resolveKind(e, { allowUnstable: t }, n) {
1869
+ let { name: r, version: i } = x(e), a = await this.getKindOverview(r, n);
1870
+ if (a === void 0) throw new Yn("no-matching-kind-version", e);
1871
+ let o = Zn(a, i, { allowUnstable: t });
1872
+ if (!o.ok) throw new Yn(o.reason, e);
1873
+ return {
1874
+ type: "from-registry-v2",
1875
+ id: o.blockId,
1876
+ registryUrl: this.registryReader.rootUrl.toString(),
1877
+ channel: o.channel
1878
+ };
1543
1879
  }
1544
- }, xn = class {
1880
+ }, tr = class {
1545
1881
  constructor(e, t, n) {
1546
1882
  this.client = e, this.bucket = t, this.root = n;
1547
1883
  }
@@ -1549,7 +1885,7 @@ var bn = class {
1549
1885
  try {
1550
1886
  return Buffer.from(await (await this.client.getObject({
1551
1887
  Bucket: this.bucket,
1552
- Key: C.join(this.root, e)
1888
+ Key: T.join(this.root, e)
1553
1889
  })).Body.transformToByteArray());
1554
1890
  } catch (e) {
1555
1891
  if (e instanceof Error && e.name === "NoSuchKey") return;
@@ -1557,35 +1893,35 @@ var bn = class {
1557
1893
  }
1558
1894
  }
1559
1895
  async listFiles(e) {
1560
- let t = C.join(this.root, e), n = pe({ client: this.client }, {
1896
+ let t = T.join(this.root, e), n = _e({ client: this.client }, {
1561
1897
  Bucket: this.bucket,
1562
1898
  Prefix: t
1563
1899
  }), r = [];
1564
- for await (let e of n) r.push(...(e.Contents ?? []).map((e) => C.relative(t, e.Key)));
1900
+ for await (let e of n) r.push(...(e.Contents ?? []).map((e) => T.relative(t, e.Key)));
1565
1901
  return r;
1566
1902
  }
1567
1903
  async putFile(e, t) {
1568
1904
  await this.client.putObject({
1569
1905
  Bucket: this.bucket,
1570
- Key: C.join(this.root, e),
1906
+ Key: T.join(this.root, e),
1571
1907
  Body: t
1572
1908
  });
1573
1909
  }
1574
1910
  async deleteFiles(...e) {
1575
1911
  let t = await this.client.deleteObjects({
1576
1912
  Bucket: this.bucket,
1577
- Delete: { Objects: e.map((e) => ({ Key: C.join(this.root, e) })) }
1913
+ Delete: { Objects: e.map((e) => ({ Key: T.join(this.root, e) })) }
1578
1914
  });
1579
1915
  if (t.Errors !== void 0 && t.Errors.length > 0) throw Error(`Errors encountered while deleting files: ${t.Errors.map((e) => e.Message ?? e.Code ?? "Unknown error").join("\n")}`);
1580
1916
  }
1581
- }, Sn = class {
1917
+ }, nr = class {
1582
1918
  root;
1583
1919
  constructor(t) {
1584
1920
  this.root = e.resolve(t);
1585
1921
  }
1586
1922
  toAbsolutePath(t) {
1587
- if (C.isAbsolute(t)) throw Error("absolute path");
1588
- return e.resolve(this.root, t.split(C.sep).join(e.sep));
1923
+ if (T.isAbsolute(t)) throw Error("absolute path");
1924
+ return e.resolve(this.root, t.split(T.sep).join(e.sep));
1589
1925
  }
1590
1926
  async getFile(e) {
1591
1927
  try {
@@ -1601,7 +1937,7 @@ var bn = class {
1601
1937
  return (await t.promises.readdir(r, {
1602
1938
  recursive: !0,
1603
1939
  withFileTypes: !0
1604
- })).filter((e) => e.isFile()).map((t) => e.relative(r, e.resolve(t.parentPath, t.name)).split(e.sep).join(C.sep));
1940
+ })).filter((e) => e.isFile()).map((t) => e.relative(r, e.resolve(t.parentPath, t.name)).split(e.sep).join(T.sep));
1605
1941
  } catch (e) {
1606
1942
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return [];
1607
1943
  throw e;
@@ -1615,27 +1951,27 @@ var bn = class {
1615
1951
  for (let n of e) await t.promises.rm(this.toAbsolutePath(n));
1616
1952
  }
1617
1953
  };
1618
- function Cn(t) {
1619
- let n = new URL(t, `file:${e.resolve(".").split(e.sep).join(C.sep)}/`);
1954
+ function rr(t) {
1955
+ let n = new URL(t, `file:${e.resolve(".").split(e.sep).join(T.sep)}/`);
1620
1956
  switch (n.protocol) {
1621
- case "file:": return new Sn(e.resolve(n.pathname));
1957
+ case "file:": return new nr(e.resolve(n.pathname));
1622
1958
  case "s3:": {
1623
1959
  let e = {}, t = n.searchParams.get("region");
1624
1960
  t && (e.region = t);
1625
1961
  let r = n.hostname;
1626
- return new xn(new fe(e), r, n.pathname.replace(/^\//, ""));
1962
+ return new tr(new ge(e), r, n.pathname.replace(/^\//, ""));
1627
1963
  }
1628
1964
  default: throw Error(`Unknown protocol: ${n.protocol}`);
1629
1965
  }
1630
1966
  }
1631
1967
  //#endregion
1632
1968
  //#region src/io/folder_reader.ts
1633
- var wn = class e {
1969
+ var ir = class e {
1634
1970
  constructor(e, t) {
1635
1971
  this.rootUrl = e, this.httpDispatcher = t;
1636
1972
  }
1637
1973
  async readFile(e, t) {
1638
- let n = await me(new URL(e, this.rootUrl), {
1974
+ let n = await ve(new URL(e, this.rootUrl), {
1639
1975
  dispatcher: this.httpDispatcher,
1640
1976
  signal: t?.signal
1641
1977
  });
@@ -1648,82 +1984,82 @@ var wn = class e {
1648
1984
  let t = e === void 0 ? this : this.relativeReader(e);
1649
1985
  return (e) => t.readFile(e);
1650
1986
  }
1651
- }, Tn = class t {
1987
+ }, ar = class t {
1652
1988
  constructor(e, t) {
1653
1989
  this.rootUrl = e, this.root = t;
1654
1990
  }
1655
1991
  async readFile(t, n) {
1656
- let i = e.join(this.root, ...t.split(C.sep));
1992
+ let i = e.join(this.root, ...t.split(T.sep));
1657
1993
  return await r.readFile(i, { signal: n?.signal });
1658
1994
  }
1659
1995
  relativeReader(n) {
1660
- return n.endsWith("/") || (n += "/"), new t(new URL(n, this.rootUrl), e.join(this.root, ...n.split(C.sep)));
1996
+ return n.endsWith("/") || (n += "/"), new t(new URL(n, this.rootUrl), e.join(this.root, ...n.split(T.sep)));
1661
1997
  }
1662
1998
  getContentReader(e) {
1663
1999
  let t = e === void 0 ? this : this.relativeReader(e);
1664
2000
  return (e) => t.readFile(e);
1665
2001
  }
1666
2002
  };
1667
- function En(t) {
1668
- return t.split(C.sep).join(e.sep);
2003
+ function or(t) {
2004
+ return t.split(T.sep).join(e.sep);
1669
2005
  }
1670
- function Dn(t) {
1671
- return t.split(e.sep).join(C.sep);
2006
+ function sr(t) {
2007
+ return t.split(e.sep).join(T.sep);
1672
2008
  }
1673
- function On(t, n) {
2009
+ function cr(t, n) {
1674
2010
  t.endsWith("/") || (t += "/");
1675
- let r = new URL(t, `file:${Dn(e.resolve("."))}/`);
2011
+ let r = new URL(t, `file:${sr(e.resolve("."))}/`);
1676
2012
  switch (r.protocol) {
1677
- case "file:": return new Tn(r, En(r.pathname));
2013
+ case "file:": return new ar(r, or(r.pathname));
1678
2014
  case "https:":
1679
- case "http:": return new wn(r, n ?? he());
2015
+ case "http:": return new ir(r, n ?? ye());
1680
2016
  default: throw Error(`Unknown protocol: ${r.protocol}`);
1681
2017
  }
1682
2018
  }
1683
2019
  //#endregion
1684
2020
  //#region src/common_types.ts
1685
- var kn = S.string().regex(/^(?:s3:|file:)/), An = S.object({
2021
+ var lr = S.string().regex(/^(?:s3:|file:)/), ur = S.object({
1686
2022
  organization: S.string(),
1687
2023
  package: S.string(),
1688
- version: p.optional(),
2024
+ version: m.optional(),
1689
2025
  files: S.record(S.string().regex(/^[^/]+$/), S.string()).default({}),
1690
2026
  meta: S.object({}).passthrough()
1691
- }), jn = S.object({
1692
- registries: S.record(S.string(), kn).default({}),
2027
+ }), dr = S.object({
2028
+ registries: S.record(S.string(), lr).default({}),
1693
2029
  registry: S.string().optional()
1694
- }), Mn = jn.merge(An).required({
2030
+ }), fr = dr.merge(ur).required({
1695
2031
  registry: !0,
1696
2032
  version: !0
1697
- }), X = Mn.partial().required({
2033
+ }), pr = fr.partial().required({
1698
2034
  registries: !0,
1699
2035
  files: !0
1700
- }), Nn = "pl.package.json", Pn = "pl.package.yaml", Z = "v1/";
1701
- function Fn(e) {
1702
- return `${Z}${e.organization}/${e.package}/${e.version}`;
2036
+ }), mr = "pl.package.json", hr = "pl.package.yaml", gr = "v1/";
2037
+ function _r(e) {
2038
+ return `${gr}${e.organization}/${e.package}/${e.version}`;
1703
2039
  }
1704
- function In(e, t) {
1705
- return `${Z}${e.organization}/${e.package}/${e.version}/${t}`;
2040
+ function vr(e, t) {
2041
+ return `${gr}${e.organization}/${e.package}/${e.version}/${t}`;
1706
2042
  }
1707
- function Ln(e) {
1708
- return `${Z}${e.organization}/${e.package}/overview.json`;
2043
+ function yr(e) {
2044
+ return `${gr}${e.organization}/${e.package}/overview.json`;
1709
2045
  }
1710
- var Q = `${Z}overview.json`, Rn = "meta.json", zn = "_updates_v1/per_package_version/";
1711
- function Bn(e, t) {
1712
- return `${zn}${e.organization}/${e.package}/${e.version}/${t}`;
2046
+ var Q = `${gr}overview.json`, br = "meta.json", xr = "_updates_v1/per_package_version/";
2047
+ function Sr(e, t) {
2048
+ return `${xr}${e.organization}/${e.package}/${e.version}/${t}`;
1713
2049
  }
1714
- var Vn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, Hn = "_updates_v1/_global_update_in", Un = "_updates_v1/_global_update_out", Wn = class {
2050
+ var Cr = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, wr = "_updates_v1/_global_update_in", Tr = "_updates_v1/_global_update_out", Er = class {
1715
2051
  constructor(e, t) {
1716
2052
  this.storage = e, this.logger = t;
1717
2053
  }
1718
2054
  constructNewPackage(e) {
1719
- return new Gn(this.storage, e);
2055
+ return new Dr(this.storage, e);
1720
2056
  }
1721
2057
  async updateRegistry() {
1722
2058
  this.logger?.info("Initiating registry refresh...");
1723
- let e = /* @__PURE__ */ new Map(), t = [], n = await this.storage.listFiles(zn);
2059
+ let e = /* @__PURE__ */ new Map(), t = [], n = await this.storage.listFiles(xr);
1724
2060
  this.logger?.info("Packages to be updated:");
1725
2061
  for (let r of n) {
1726
- let n = r.match(Vn);
2062
+ let n = r.match(Cr);
1727
2063
  if (!n) continue;
1728
2064
  t.push(r);
1729
2065
  let { packageKeyWithoutVersion: i, organization: a, pkg: o, version: s, seed: c } = n.groups, l = e.get(i);
@@ -1738,19 +2074,19 @@ var Vn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?
1738
2074
  let r = await this.storage.getFile(Q), i = r === void 0 ? [] : JSON.parse(r.toString());
1739
2075
  this.logger?.info(`Global overview loaded, ${i.length} records`);
1740
2076
  for (let [, t] of e.entries()) {
1741
- let e = Ln(t.package), n = await this.storage.getFile(e), r = n === void 0 ? [] : JSON.parse(n.toString());
2077
+ let e = yr(t.package), n = await this.storage.getFile(e), r = n === void 0 ? [] : JSON.parse(n.toString());
1742
2078
  this.logger?.info(`Updating ${t.package.organization}:${t.package.package} overview, ${r.length} records`), r = r.filter((e) => !t.versions.has(e.version));
1743
2079
  for (let [e] of t.versions.entries()) {
1744
- let n = e.toString(), i = await this.storage.getFile(In({
2080
+ let n = e.toString(), i = await this.storage.getFile(vr({
1745
2081
  ...t.package,
1746
2082
  version: n
1747
- }, Rn));
2083
+ }, br));
1748
2084
  i && r.push({
1749
2085
  version: n,
1750
2086
  meta: JSON.parse(i.toString())
1751
2087
  });
1752
2088
  }
1753
- r.sort((e, t) => V.compare(t.version, e.version)), await this.storage.putFile(e, Buffer.from(JSON.stringify(r))), this.logger?.info(`Done (${r.length} records)`), i = i.filter((e) => e.organization !== t.package.organization || e.package !== t.package.package), i.push({
2089
+ r.sort((e, t) => K.compare(t.version, e.version)), await this.storage.putFile(e, Buffer.from(JSON.stringify(r))), this.logger?.info(`Done (${r.length} records)`), i = i.filter((e) => e.organization !== t.package.organization || e.package !== t.package.package), i.push({
1754
2090
  organization: t.package.organization,
1755
2091
  package: t.package.package,
1756
2092
  allVersions: r.map((e) => e.version).reverse(),
@@ -1758,36 +2094,36 @@ var Vn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?
1758
2094
  latestMeta: r[0].meta
1759
2095
  });
1760
2096
  }
1761
- await this.storage.putFile(Q, Buffer.from(JSON.stringify(i))), this.logger?.info(`Global overview updated (${i.length} records)`), await this.storage.deleteFiles(...t.map((e) => `${zn}${e}`)), this.logger?.info("Version update requests cleared");
2097
+ await this.storage.putFile(Q, Buffer.from(JSON.stringify(i))), this.logger?.info(`Global overview updated (${i.length} records)`), await this.storage.deleteFiles(...t.map((e) => `${xr}${e}`)), this.logger?.info("Version update requests cleared");
1762
2098
  }
1763
2099
  async updateIfNeeded(e = !1) {
1764
2100
  this.logger?.info("Checking if registry requires refresh...");
1765
- let t = await this.storage.getFile(Hn), n = await this.storage.getFile(Un);
1766
- !e && t === void 0 && n === void 0 || !e && t !== void 0 && n !== void 0 && t.equals(n) || (await this.updateRegistry(), t && (await this.storage.putFile(Un, t), this.logger?.info("Refresh finished")));
2101
+ let t = await this.storage.getFile(wr), n = await this.storage.getFile(Tr);
2102
+ !e && t === void 0 && n === void 0 || !e && t !== void 0 && n !== void 0 && t.equals(n) || (await this.updateRegistry(), t && (await this.storage.putFile(Tr, t), this.logger?.info("Refresh finished")));
1767
2103
  }
1768
2104
  async getPackageOverview(e) {
1769
- let t = await this.storage.getFile(Ln(e));
2105
+ let t = await this.storage.getFile(yr(e));
1770
2106
  if (t !== void 0) return JSON.parse(t.toString());
1771
2107
  }
1772
2108
  async getGlobalOverview() {
1773
2109
  let e = await this.storage.getFile(Q);
1774
2110
  if (e !== void 0) return JSON.parse(e.toString());
1775
2111
  }
1776
- }, Gn = class {
2112
+ }, Dr = class {
1777
2113
  metaAdded = !1;
1778
- seed = ae();
2114
+ seed = se();
1779
2115
  constructor(e, t) {
1780
2116
  this.storage = e, this.name = t;
1781
2117
  }
1782
2118
  async addFile(e, t) {
1783
- await this.storage.putFile(In(this.name, e), t);
2119
+ await this.storage.putFile(vr(this.name, e), t);
1784
2120
  }
1785
2121
  async writeMeta(e) {
1786
- await this.addFile(Rn, Buffer.from(JSON.stringify(e))), this.metaAdded = !0;
2122
+ await this.addFile(br, Buffer.from(JSON.stringify(e))), this.metaAdded = !0;
1787
2123
  }
1788
2124
  async finish() {
1789
2125
  if (!this.metaAdded) throw Error("meta not added");
1790
- await this.storage.putFile(Bn(this.name, this.seed), Buffer.of(0)), await this.storage.putFile(Hn, Buffer.from(this.seed));
2126
+ await this.storage.putFile(Sr(this.name, this.seed), Buffer.of(0)), await this.storage.putFile(wr, Buffer.from(this.seed));
1791
2127
  }
1792
2128
  };
1793
2129
  //#endregion
@@ -1806,17 +2142,17 @@ function $(e, t) {
1806
2142
  }
1807
2143
  };
1808
2144
  }
1809
- async function Kn(e) {
1810
- return Qe(e, (e) => X.parse(JSON.parse(e.toString())));
2145
+ async function Or(e) {
2146
+ return nt(e, (e) => pr.parse(JSON.parse(e.toString())));
1811
2147
  }
1812
- async function qn(e) {
1813
- return Qe(e, (e) => X.parse(ge.parse(e.toString())));
2148
+ async function kr(e) {
2149
+ return nt(e, (e) => pr.parse(be.parse(e.toString())));
1814
2150
  }
1815
- async function Jn() {
1816
- let e = X.parse({});
1817
- return e = $(e, await Kn("./.pl.reg.json")), e = $(e, await qn("./.pl.reg.yaml")), e = $(e, await Kn(`${_e.homedir()}/.pl.reg.json`)), e = $(e, await qn(`${_e.homedir()}/.pl.reg.yaml`)), e = $(e, await Kn(Nn)), e = $(e, await qn(Pn)), e;
2151
+ async function Ar() {
2152
+ let e = pr.parse({});
2153
+ return e = $(e, await Or("./.pl.reg.json")), e = $(e, await kr("./.pl.reg.yaml")), e = $(e, await Or(`${xe.homedir()}/.pl.reg.json`)), e = $(e, await kr(`${xe.homedir()}/.pl.reg.yaml`)), e = $(e, await Or(mr)), e = $(e, await kr(hr)), e;
1818
2154
  }
1819
- var Yn = class {
2155
+ var jr = class {
1820
2156
  constructor(e) {
1821
2157
  this.conf = e;
1822
2158
  }
@@ -1827,7 +2163,7 @@ var Yn = class {
1827
2163
  if (!e) throw Error(`Registry with alias "${t}" not found`);
1828
2164
  t = e;
1829
2165
  }
1830
- return new Wn(Cn(t), e);
2166
+ return new Er(rr(t), e);
1831
2167
  }
1832
2168
  get fullPackageName() {
1833
2169
  return {
@@ -1837,11 +2173,11 @@ var Yn = class {
1837
2173
  };
1838
2174
  }
1839
2175
  };
1840
- async function Xn(e) {
1841
- let t = await Jn();
1842
- return new Yn(Mn.parse($(t, e)));
2176
+ async function Mr(e) {
2177
+ let t = await Ar();
2178
+ return new jr(fr.parse($(t, e)));
1843
2179
  }
1844
2180
  //#endregion
1845
- export { D as $, fn as A, Y as B, nn as C, Oe as Ct, tn as D, J as E, un as F, k as G, ct as H, K as I, st as J, ot as K, G as L, an as M, sn as N, H as O, dn as P, et as Q, ln as R, U as S, De as St, pn as T, Ee as Tt, ut as U, A as V, lt as W, nt as X, it as Y, rt as Z, Cn as _, Pe as _t, Fn as a, Ke as at, _n as b, Re as bt, An as c, Ue as ct, jn as d, Be as dt, Xe as et, Mn as f, je as ft, xn as g, ke as gt, Sn as h, Ne as ht, Rn as i, Ge as it, q as j, on as k, Nn as l, We as lt, On as m, Ae as mt, Xn as n, Je as nt, Ln as o, Ve as ot, X as p, Me as pt, at as q, Q as r, qe as rt, In as s, He as st, Yn as t, Ye as tt, Pn as u, ze as ut, bn as v, Ie as vt, rn as w, Ce as wt, W as x, Fe as xt, yn as y, Le as yt, cn as z };
2181
+ export { Dt as $, X as A, Xe as At, Y as B, Le as Bt, Jn as C, at as Ct, kn as D, Qe as Dt, Mn as E, $e as Et, In as F, Ue as Ft, F as G, He as Gt, Rn as H, Re as Ht, jn as I, We as It, Ft as J, Me as Jt, Pt as K, ze as Kt, Fn as L, Fe as Lt, q as M, Ke as Mt, Pn as N, qe as Nt, An as O, Ze as Ot, Vn as P, Je as Pt, Ot as Q, Bn as R, Ie as Rt, Zn as S, ct as St, Nn as T, et as Tt, Ln as U, Be as Ut, J as V, Ne as Vt, Z as W, Ve as Wt, jt as X, Ae as Xt, Nt as Y, De as Yt, Mt as Z, rr as _, ht as _t, _r as a, xt as at, Yn as b, dt as bt, ur as c, bt as ct, dr as d, vt as dt, kt as et, fr as f, yt as ft, tr as g, pt as gt, nr as h, mt as ht, br as i, _t as it, On as j, Ge as jt, Hn as k, Ye as kt, mr as l, wt as lt, cr as m, j as mt, Mr as n, P as nt, yr as o, Tt as ot, pr as p, N as pt, It as q, je as qt, Q as r, St as rt, vr as s, gt as st, jr as t, Ct as tt, hr as u, M as ut, er as v, ft as vt, Kn as w, k as wt, qn as x, ot as xt, $n as y, ut as yt, zn as z, Pe as zt };
1846
2182
 
1847
- //# sourceMappingURL=config-CiC347sB.mjs.map
2183
+ //# sourceMappingURL=config-Dx45aFJ_.mjs.map