@platforma-sdk/block-tools 2.11.2 → 2.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/bin/run.js +9 -5
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.js +13 -13
  4. package/dist/cli.js.map +1 -1
  5. package/dist/cli.mjs +845 -981
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/cmd/build-meta.d.ts +2 -9
  8. package/dist/cmd/build-model.d.ts +2 -10
  9. package/dist/cmd/list-overview-snapshots.d.ts +2 -9
  10. package/dist/cmd/mark-stable.d.ts +2 -13
  11. package/dist/cmd/pack.d.ts +2 -9
  12. package/dist/cmd/publish.d.ts +2 -12
  13. package/dist/cmd/refresh-registry.d.ts +2 -9
  14. package/dist/cmd/restore-overview-from-snapshot.d.ts +2 -10
  15. package/dist/cmd/structure/check.d.ts +2 -10
  16. package/dist/cmd/structure/init.d.ts +2 -18
  17. package/dist/cmd/structure/refresh.d.ts +10 -11
  18. package/dist/cmd/update-deps.d.ts +2 -6
  19. package/dist/cmd/upload-package-v1.d.ts +2 -14
  20. package/dist/config-BmJWc8sR.js +3 -0
  21. package/dist/config-BmJWc8sR.js.map +1 -0
  22. package/dist/{config-DpfTzcgG.mjs → config-CiC347sB.mjs} +453 -398
  23. package/dist/config-CiC347sB.mjs.map +1 -0
  24. package/dist/index.js +1 -1
  25. package/dist/index.mjs +15 -15
  26. package/dist/registry_v1/config_schema.d.ts +7 -7
  27. package/dist/registry_v1/flags.d.ts +2 -4
  28. package/dist/structure/cli/run-structure.d.ts +1 -1
  29. package/dist/structure/engine/discovery.d.ts +2 -3
  30. package/dist/structure/rules/block-package-json.d.ts +3 -3
  31. package/dist/structure/rules/shared/pascal-case.d.ts +1 -0
  32. package/dist/v2/index.d.ts +1 -0
  33. package/dist/v2/model/block_components.d.ts +11 -0
  34. package/dist/v2/model/block_meta.d.ts +7 -0
  35. package/dist/v2/resolve_to_registry.d.ts +37 -0
  36. package/dist/v2/source_package.d.ts +12 -0
  37. package/package.json +9 -24
  38. package/src/cli.test.ts +56 -0
  39. package/src/cli.ts +50 -0
  40. package/src/cmd/build-meta.ts +11 -22
  41. package/src/cmd/build-model.ts +16 -33
  42. package/src/cmd/list-overview-snapshots.ts +24 -28
  43. package/src/cmd/mark-stable.ts +35 -55
  44. package/src/cmd/pack.ts +11 -22
  45. package/src/cmd/publish.test.ts +35 -0
  46. package/src/cmd/publish.ts +55 -49
  47. package/src/cmd/refresh-registry.ts +22 -26
  48. package/src/cmd/restore-overview-from-snapshot.ts +24 -34
  49. package/src/cmd/structure/check.ts +19 -28
  50. package/src/cmd/structure/init.ts +40 -47
  51. package/src/cmd/structure/refresh.ts +45 -36
  52. package/src/cmd/update-deps.ts +22 -12
  53. package/src/cmd/upload-package-v1.ts +42 -60
  54. package/src/registry_v1/flags.ts +7 -7
  55. package/src/structure/__tests__/discovery-shortname.test.ts +3 -0
  56. package/src/structure/__tests__/facade-end-state.test.ts +195 -0
  57. package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -1
  58. package/src/structure/cli/run-structure.ts +2 -2
  59. package/src/structure/engine/__tests__/discovery.test.ts +22 -26
  60. package/src/structure/engine/discovery.ts +12 -30
  61. package/src/structure/rules/block-package-json.ts +146 -64
  62. package/src/structure/rules/block.ts +40 -5
  63. package/src/structure/rules/model-package-json.ts +6 -1
  64. package/src/structure/rules/shared/pascal-case.ts +16 -0
  65. package/src/structure/rules/software-package-json.ts +6 -1
  66. package/src/structure/rules/test-package-json.ts +5 -1
  67. package/src/structure/rules/ui-package-json.ts +5 -1
  68. package/src/structure/rules/workflow-package-json.ts +5 -1
  69. package/src/structure/templates/static/block/src/AGENTS.ts +5 -0
  70. package/src/structure/templates/static/block/src/agents-extra.ts +8 -0
  71. package/src/structure/templates/static/block/src/block-extra.ts +9 -0
  72. package/src/structure/templates/static/block/tsconfig.json +4 -0
  73. package/src/structure/templates/text/block/src/index.tpl.ts +55 -0
  74. package/src/v2/from_pack_v2.test.ts +142 -0
  75. package/src/v2/index.ts +1 -0
  76. package/src/v2/model/block_components.ts +33 -0
  77. package/src/v2/model/block_meta.ts +18 -0
  78. package/src/v2/model/content_conversion.ts +0 -1
  79. package/src/v2/resolve_to_registry.ts +84 -0
  80. package/src/v2/source_package.ts +34 -1
  81. package/bin/dev.cmd +0 -3
  82. package/bin/dev.js +0 -6
  83. package/dist/cmd/index.d.ts +0 -28
  84. package/dist/config-DpfTzcgG.mjs.map +0 -1
  85. package/dist/config-xxVy3IQR.js +0 -3
  86. package/dist/config-xxVy3IQR.js.map +0 -1
  87. package/src/cmd/index.ts +0 -31
  88. package/src/structure/templates/static/block/index.d.ts +0 -6
  89. package/src/structure/templates/static/block/index.js +0 -8
@@ -1,59 +1,61 @@
1
1
  import e from "node:path";
2
2
  import * as t from "node:fs";
3
- import n from "node:fs/promises";
4
- import * as r from "mime-types";
5
- import * as i from "tar";
6
- import { tryResolve as a } from "@milaboratories/resolve-helper";
7
- import { AnyChannel as o, BlockPackDescriptionFromPackageJsonRaw as s, BlockPackDescriptionManifest as c, BlockPackIdNoVersion as l, BlockPackManifest as u, BlockPackManifestFile as d, SemVer as f, Sha256Schema as p, VersionWithChannels as m, addPrefixToRelative as h, blockPackIdNoVersionEquals as g, blockPackIdToString as _, mapRemoteToAbsolute as v } from "@milaboratories/pl-model-middle-layer";
8
- import { extractConfigGeneric as y } from "@milaboratories/pl-model-common";
9
- import { gunzip as b, gunzipSync as ee, gzip as te } from "node:zlib";
10
- import { createHash as ne, randomUUID as re } from "node:crypto";
11
- import { ConsoleLoggerAdapter as ie, Retry2TimesWithDelay as x, notEmpty as ae, retry as S } from "@milaboratories/ts-helpers";
12
- import { promisify as oe } from "node:util";
13
- import { z as C } from "zod";
14
- import se from "canonicalize";
15
- import { LRUCache as ce } from "lru-cache";
16
- import w from "node:path/posix";
17
- import { S3 as le, paginateListObjectsV2 as ue } from "@aws-sdk/client-s3";
18
- import { request as de } from "undici";
19
- import { defaultHttpDispatcher as fe } from "@milaboratories/pl-http";
20
- import pe from "yaml";
21
- import * as me from "node:os";
3
+ import n from "node:fs";
4
+ import r from "node:fs/promises";
5
+ import * as i from "mime-types";
6
+ import * as a from "tar";
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";
15
+ 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";
22
24
  //#region \0rolldown/runtime.js
23
- var he = Object.create, T = Object.defineProperty, ge = Object.getOwnPropertyDescriptor, _e = Object.getOwnPropertyNames, ve = Object.getPrototypeOf, ye = Object.prototype.hasOwnProperty, E = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), be = (e, t) => {
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) => {
24
26
  let n = {};
25
- for (var r in e) T(n, r, {
27
+ for (var r in e) w(n, r, {
26
28
  get: e[r],
27
29
  enumerable: !0
28
30
  });
29
- return t || T(n, Symbol.toStringTag, { value: "Module" }), n;
30
- }, xe = (e, t, n, r) => {
31
- if (t && typeof t == "object" || typeof t == "function") for (var i = _e(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !ye.call(e, s) && s !== n && T(e, s, {
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, {
32
34
  get: ((e) => t[e]).bind(null, s),
33
- enumerable: !(r = ge(t, s)) || r.enumerable
35
+ enumerable: !(r = ye(t, s)) || r.enumerable
34
36
  });
35
37
  return e;
36
- }, Se = (e, t, n) => (n = e == null ? {} : he(ve(e)), xe(t || !e || !e.__esModule ? T(n, "default", {
38
+ }, Te = (e, t, n) => (n = e == null ? {} : ve(xe(e)), we(t || !e || !e.__esModule ? w(n, "default", {
37
39
  value: e,
38
40
  enumerable: !0
39
- }) : n, e)), Ce = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
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) {
40
42
  if (typeof require < "u") return require.apply(this, arguments);
41
43
  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.");
42
44
  });
43
45
  //#endregion
44
46
  //#region src/v2/model/content_conversion.ts
45
- function we(e, t) {
46
- let n = a(e, t);
47
+ function De(e, t) {
48
+ let n = o(e, t);
47
49
  if (n === void 0) throw Error(`Can't resolve ${t} against ${e}`);
48
50
  return {
49
51
  type: "absolute-file",
50
52
  file: n
51
53
  };
52
54
  }
53
- function Te(e, t, n) {
55
+ function Oe(e, t, n) {
54
56
  let r = t.endsWith("/") ? t : `${t}/`;
55
57
  for (let t of n) {
56
- let n = a(e, r + t);
58
+ let n = o(e, r + t);
57
59
  if (n !== void 0) {
58
60
  if (!n.endsWith(t)) throw Error(`Unexpected resolve result ${n} with index file ${t}`);
59
61
  return {
@@ -64,37 +66,37 @@ function Te(e, t, n) {
64
66
  }
65
67
  throw Error(`Can't resolve ${t} folder against ${e}, no index file found (${n.join(", ")})`);
66
68
  }
67
- function Ee(t) {
69
+ function ke(t) {
68
70
  return (n) => n.type === "relative" ? {
69
71
  type: "absolute-file",
70
72
  file: e.resolve(t, n.path)
71
73
  } : n;
72
74
  }
73
- function De() {
74
- return async (e) => e.type === "absolute-file" ? await n.readFile(e.file, { encoding: "utf-8" }) : e.content;
75
+ function Ae() {
76
+ return async (e) => e.type === "absolute-file" ? await r.readFile(e.file, { encoding: "utf-8" }) : e.content;
75
77
  }
76
- function Oe() {
78
+ function je() {
77
79
  return async (e) => {
78
80
  if (e.type === "absolute-file") {
79
- let t = r.lookup(e.file);
81
+ let t = i.lookup(e.file);
80
82
  if (!t) throw Error(`Can't recognize mime type of the file: ${e.file}.`);
81
83
  return {
82
84
  type: "explicit-base64",
83
85
  mimeType: t,
84
- content: await n.readFile(e.file, { encoding: "base64" })
86
+ content: await r.readFile(e.file, { encoding: "base64" })
85
87
  };
86
88
  } else return e;
87
89
  };
88
90
  }
89
- function ke() {
91
+ function Me() {
90
92
  return async (e) => {
91
93
  if (e.type === "absolute-file") {
92
- let t = r.lookup(e.file);
94
+ let t = i.lookup(e.file);
93
95
  if (!t) throw Error(`Can't recognize mime type of the file: ${e.file}.`);
94
96
  return {
95
97
  type: "explicit-bytes",
96
98
  mimeType: t,
97
- content: Buffer.from(await n.readFile(e.file))
99
+ content: Buffer.from(await r.readFile(e.file))
98
100
  };
99
101
  } else if (e.type === "explicit-base64") return {
100
102
  type: "explicit-bytes",
@@ -104,44 +106,44 @@ function ke() {
104
106
  else return e;
105
107
  };
106
108
  }
107
- function Ae(t, r) {
109
+ function Ne(t, n) {
108
110
  return async (i) => {
109
111
  if (i.type === "absolute-file") {
110
112
  let a = e.basename(i.file), o = e.resolve(t, a);
111
- return r?.push(a), await n.cp(i.file, o), {
113
+ return n?.push(a), await r.cp(i.file, o), {
112
114
  type: "relative",
113
115
  path: a
114
116
  };
115
117
  } else return i;
116
118
  };
117
119
  }
118
- function je(t, n, r) {
120
+ function Pe(t, n, r) {
119
121
  if (!n.endsWith(".tgz")) throw Error(`Unexpected tgz file name: ${n}`);
120
- return async (a) => {
122
+ return async (i) => {
121
123
  let o = e.resolve(t, n);
122
- return await i.create({
124
+ return await a.create({
123
125
  gzip: !0,
124
126
  file: o,
125
- cwd: a.folder
127
+ cwd: i.folder
126
128
  }, ["."]), r?.push(n), {
127
129
  type: "relative",
128
130
  path: n
129
131
  };
130
132
  };
131
133
  }
132
- function Me(e) {
134
+ function Fe(e) {
133
135
  return async (t) => t.type === "explicit-string" ? t : {
134
136
  type: "explicit-string",
135
137
  content: (await e(t.path)).toString("utf8")
136
138
  };
137
139
  }
138
- function Ne(e) {
140
+ function Ie(e) {
139
141
  return async (t) => t.type === "explicit-string" ? t.content : (await e(t.path)).toString("utf8");
140
142
  }
141
- function Pe(e) {
143
+ function Le(e) {
142
144
  return async (t) => {
143
145
  if (t.type === "explicit-base64") return t;
144
- let n = r.lookup(t.path);
146
+ let n = i.lookup(t.path);
145
147
  if (!n) throw Error(`Can't recognize mime type of the file: ${t.path}.`);
146
148
  return {
147
149
  type: "explicit-base64",
@@ -150,14 +152,14 @@ function Pe(e) {
150
152
  };
151
153
  };
152
154
  }
153
- function Fe(e) {
155
+ function Re(e) {
154
156
  return async (t) => {
155
157
  if (t.type === "explicit-base64") return {
156
158
  type: "explicit-bytes",
157
159
  mimeType: t.mimeType,
158
160
  content: new Uint8Array(Buffer.from(t.content, "base64"))
159
161
  };
160
- let n = r.lookup(t.path);
162
+ let n = i.lookup(t.path);
161
163
  if (!n) throw Error(`Can't recognize mime type of the file: ${t.path}.`);
162
164
  return {
163
165
  type: "explicit-bytes",
@@ -168,7 +170,7 @@ function Fe(e) {
168
170
  }
169
171
  //#endregion
170
172
  //#region src/v2/model/block_meta.ts
171
- async function D(e, t, n) {
173
+ async function E(e, t, n) {
172
174
  let { organization: r } = e, { logo: i, ...a } = r;
173
175
  return {
174
176
  ...e,
@@ -181,37 +183,58 @@ async function D(e, t, n) {
181
183
  ...e.logo === void 0 ? {} : { logo: await n(e.logo) }
182
184
  };
183
185
  }
184
- async function Ie(e, t) {
185
- let n = Ee(t);
186
- return D(e, async (e) => n(e), async (e) => n(e));
186
+ async function ze(e, t) {
187
+ let n = ke(t);
188
+ return E(e, async (e) => n(e), async (e) => n(e));
189
+ }
190
+ async function Be(e, t) {
191
+ let n = ke(t);
192
+ return E(e, async (e) => n(e), async (e) => n(e));
187
193
  }
188
- async function Le(e, t, n) {
189
- let r = Ae(t, n);
190
- return D(e, async (e) => r(e), async (e) => r(e));
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));
191
197
  }
192
- async function Re(e) {
193
- return D(e, De(), Oe());
198
+ async function He(e) {
199
+ return E(e, Ae(), je());
194
200
  }
195
- async function ze(e) {
196
- return D(e, De(), ke());
201
+ async function Ue(e) {
202
+ return E(e, Ae(), Me());
197
203
  }
198
- async function Be(e, t) {
199
- return D(e, Ne(t), Fe(t));
204
+ async function We(e, t) {
205
+ return E(e, Ie(t), Re(t));
200
206
  }
201
207
  //#endregion
202
208
  //#region src/v2/model/block_components.ts
203
- function Ve(e, t) {
209
+ function Ge(e, t) {
210
+ return {
211
+ workflow: {
212
+ type: "workflow-v1",
213
+ main: De(t, e.workflow.main)
214
+ },
215
+ model: De(t, e.model),
216
+ ui: Oe(t, e.ui, ["index.html"])
217
+ };
218
+ }
219
+ function Ke(t, n) {
220
+ let r = (t) => ({
221
+ type: "absolute-file",
222
+ file: e.resolve(n, t.path)
223
+ });
204
224
  return {
205
225
  workflow: {
206
226
  type: "workflow-v1",
207
- main: we(t, e.workflow.main)
227
+ main: r(t.workflow.main)
208
228
  },
209
- model: we(t, e.model),
210
- ui: Te(t, e.ui, ["index.html"])
229
+ model: r(t.model),
230
+ ui: {
231
+ type: "absolute-folder",
232
+ folder: e.resolve(n, t.ui.path)
233
+ }
211
234
  };
212
235
  }
213
- async function He(e, t, n) {
214
- let r = Ae(t, n), i = je(t, "ui.tgz", n);
236
+ async function qe(e, t, n) {
237
+ let r = Ne(t, n), i = Pe(t, "ui.tgz", n);
215
238
  return {
216
239
  workflow: {
217
240
  type: "workflow-v1",
@@ -221,8 +244,8 @@ async function He(e, t, n) {
221
244
  ui: await i(e.ui)
222
245
  };
223
246
  }
224
- function Ue(e, t) {
225
- let n = v(t);
247
+ function Je(e, t) {
248
+ let n = y(t);
226
249
  return {
227
250
  workflow: {
228
251
  type: "workflow-v1",
@@ -234,33 +257,33 @@ function Ue(e, t) {
234
257
  }
235
258
  //#endregion
236
259
  //#region src/v2/model/block_description.ts
237
- async function We(e, t) {
238
- let r = Ve(e.components, t), i = await Ie(e.meta, t), a = y(JSON.parse(await n.readFile(r.model.file, "utf-8")));
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")));
239
262
  return {
240
263
  ...e,
241
- components: r,
264
+ components: n,
242
265
  meta: i,
243
266
  featureFlags: a.featureFlags
244
267
  };
245
268
  }
246
- async function Ge(e, t, n) {
247
- let r = await He(e.components, t, n), i = await Le(e.meta, t, n);
269
+ async function Xe(e, t, n) {
270
+ let r = await qe(e.components, t, n), i = await Ve(e.meta, t, n);
248
271
  return {
249
272
  ...e,
250
273
  components: r,
251
274
  meta: i
252
275
  };
253
276
  }
254
- function Ke(e, t, n) {
277
+ function Ze(e, t, n) {
255
278
  return {
256
279
  ...e,
257
280
  components: t(e.components),
258
281
  meta: n(e.meta)
259
282
  };
260
283
  }
261
- function O(e, t) {
262
- let n = h(t);
263
- return Ke(e, (e) => ({
284
+ function D(e, t) {
285
+ let n = g(t);
286
+ return Ze(e, (e) => ({
264
287
  workflow: {
265
288
  type: "workflow-v1",
266
289
  main: n(e.workflow.main)
@@ -283,23 +306,23 @@ function O(e, t) {
283
306
  }
284
307
  //#endregion
285
308
  //#region src/util.ts
286
- async function qe(e, t) {
309
+ async function Qe(e, t) {
287
310
  try {
288
- return t(await n.readFile(e));
311
+ return t(await r.readFile(e));
289
312
  } catch (e) {
290
313
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return;
291
314
  throw e;
292
315
  }
293
316
  }
294
- function k(e) {
295
- return Promise.resolve(ne("sha256").update(ArrayBuffer.isView(e) ? e : Buffer.from(e)).digest("hex").toUpperCase());
317
+ function O(e) {
318
+ return Promise.resolve(ie("sha256").update(ArrayBuffer.isView(e) ? e : Buffer.from(e)).digest("hex").toUpperCase());
296
319
  }
297
320
  //#endregion
298
321
  //#region src/v2/build_dist.ts
299
- async function Je(t, r) {
300
- let i = t.components.workflow.main, a = await n.readFile(e.resolve(r, i.path)), o;
322
+ async function $e(t, n) {
323
+ let i = t.components.workflow.main, a = await r.readFile(e.resolve(n, i.path)), o;
301
324
  try {
302
- let e = ee(a).toString("utf-8");
325
+ let e = ne(a).toString("utf-8");
303
326
  o = JSON.parse(e);
304
327
  } catch {
305
328
  return;
@@ -307,33 +330,33 @@ async function Je(t, r) {
307
330
  let s = o;
308
331
  if (!(s.type !== "pl.tengo-template.v3" || !s.template)) return s.template.requiredCapabilities;
309
332
  }
310
- async function Ye(t, r) {
311
- await n.mkdir(r, { recursive: !0 });
312
- let i = [], a = await Ge(t, r, i), o = await Je(a, r);
333
+ async function et(t, n) {
334
+ await r.mkdir(n, { recursive: !0 });
335
+ let i = [], a = await Xe(t, n, i), o = await $e(a, n);
313
336
  o && o.length > 0 && (a.meta = {
314
337
  ...a.meta,
315
338
  requiredCapabilities: o
316
339
  });
317
340
  let s = await Promise.all(i.map(async (t) => {
318
- let i = await n.readFile(e.resolve(r, t)), a = await k(i);
341
+ let i = await r.readFile(e.resolve(n, t)), a = await O(i);
319
342
  return {
320
343
  name: t,
321
344
  size: i.length,
322
345
  sha256: a
323
346
  };
324
- })), c = u.parse({
347
+ })), c = d.parse({
325
348
  schema: "v2",
326
349
  description: { ...a },
327
350
  files: s,
328
351
  timestamp: Date.now()
329
352
  });
330
- return await n.writeFile(e.resolve(r, d), JSON.stringify(c)), c;
353
+ return await r.writeFile(e.resolve(n, f), JSON.stringify(c)), c;
331
354
  }
332
355
  //#endregion
333
356
  //#region src/v2/source_package.ts
334
- var A = "block", Xe = /(?:@[a-zA-Z0-9-.]+\/)?(?<organization>[a-zA-Z0-9-]+)\.(?<name>[a-zA-Z0-9-]+)/;
335
- function Ze(e) {
336
- let t = e.match(Xe);
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);
337
360
  if (!t) throw Error(`Malformed package name (${e}), can't infer organization and block pack name.`);
338
361
  let { name: n, organization: r } = t.groups;
339
362
  return {
@@ -341,17 +364,17 @@ function Ze(e) {
341
364
  organization: r
342
365
  };
343
366
  }
344
- async function Qe(t, n) {
367
+ async function rt(t, n) {
345
368
  let r = e.resolve(t, "package.json");
346
369
  try {
347
- let e = await qe(r, (e) => JSON.parse(e.toString("utf-8")));
370
+ let e = await Qe(r, (e) => JSON.parse(e.toString("utf-8")));
348
371
  if (e === void 0) return;
349
- let n = e[A];
350
- return n === void 0 ? void 0 : await We({
351
- ...s.parse(n),
372
+ let n = e[k];
373
+ return n === void 0 ? void 0 : await Ye({
374
+ ...c.parse(n),
352
375
  id: {
353
- ...Ze(ae(e.name, `"name" not found in ${r}`)),
354
- version: f.parse(e.version)
376
+ ...nt(se(e.name, `"name" not found in ${r}`)),
377
+ version: p.parse(e.version)
355
378
  }
356
379
  }, t);
357
380
  } catch (e) {
@@ -359,24 +382,56 @@ async function Qe(t, n) {
359
382
  return;
360
383
  }
361
384
  }
362
- async function $e(t) {
363
- let r = e.resolve(t, "package.json"), i = JSON.parse(await n.readFile(r, { encoding: "utf-8" })), a = i[A];
364
- if (a === void 0) throw Error(`Block description (field ${A}) not found in ${r}.`);
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}.`);
365
388
  return {
366
- ...s.parse(a),
389
+ ...c.parse(a),
367
390
  id: {
368
- ...Ze(ae(i.name, `"name" not found in ${r}`)),
369
- version: f.parse(i.version)
391
+ ...nt(se(i.name, `"name" not found in ${n}`)),
392
+ version: p.parse(i.version)
370
393
  },
371
394
  featureFlags: {}
372
395
  };
373
396
  }
374
- async function et(e) {
375
- return await We(await $e(e), e);
397
+ async function at(e) {
398
+ return await Ye(await it(e), e);
399
+ }
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);
403
+ return {
404
+ ...a.description,
405
+ components: o,
406
+ meta: s
407
+ };
408
+ }
409
+ //#endregion
410
+ //#region src/v2/resolve_to_registry.ts
411
+ var A = "published.json";
412
+ function ct(e) {
413
+ return {
414
+ registryUrl: e.registryUrl,
415
+ id: e.id
416
+ };
417
+ }
418
+ async function lt(t, n) {
419
+ let i = e.resolve(t, A);
420
+ await r.writeFile(i, JSON.stringify(n, null, 2), { encoding: "utf-8" });
421
+ }
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.`);
425
+ let a = JSON.parse(await r.readFile(i, { encoding: "utf-8" }));
426
+ return {
427
+ type: "from-registry-v2",
428
+ registryUrl: a.registryUrl,
429
+ id: a.id
430
+ };
376
431
  }
377
432
  //#endregion
378
433
  //#region ../../node_modules/.pnpm/semver@7.7.2/node_modules/semver/internal/constants.js
379
- var j = /* @__PURE__ */ E(((e, t) => {
434
+ var j = /* @__PURE__ */ T(((e, t) => {
380
435
  var n = "2.0.0", r = 256;
381
436
  t.exports = {
382
437
  MAX_LENGTH: r,
@@ -396,9 +451,9 @@ var j = /* @__PURE__ */ E(((e, t) => {
396
451
  FLAG_INCLUDE_PRERELEASE: 1,
397
452
  FLAG_LOOSE: 2
398
453
  };
399
- })), M = /* @__PURE__ */ E(((e, t) => {
454
+ })), M = /* @__PURE__ */ T(((e, t) => {
400
455
  t.exports = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => {};
401
- })), N = /* @__PURE__ */ E(((e, t) => {
456
+ })), N = /* @__PURE__ */ T(((e, t) => {
402
457
  var { MAX_SAFE_COMPONENT_LENGTH: n, MAX_SAFE_BUILD_LENGTH: r, MAX_LENGTH: i } = j(), a = M();
403
458
  e = t.exports = {};
404
459
  var o = e.re = [], s = e.safeRe = [], c = e.src = [], l = e.safeSrc = [], u = e.t = {}, d = 0, f = "[a-zA-Z0-9-]", p = [
@@ -413,10 +468,10 @@ var j = /* @__PURE__ */ E(((e, t) => {
413
468
  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);
414
469
  };
415
470
  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*$");
416
- })), tt = /* @__PURE__ */ E(((e, t) => {
471
+ })), dt = /* @__PURE__ */ T(((e, t) => {
417
472
  var n = Object.freeze({ loose: !0 }), r = Object.freeze({});
418
473
  t.exports = (e) => e ? typeof e == "object" ? e : n : r;
419
- })), nt = /* @__PURE__ */ E(((e, t) => {
474
+ })), ft = /* @__PURE__ */ T(((e, t) => {
420
475
  var n = /^[0-9]+$/, r = (e, t) => {
421
476
  let r = n.test(e), i = n.test(t);
422
477
  return r && i && (e = +e, t = +t), e === t ? 0 : r && !i ? -1 : i && !r ? 1 : e < t ? -1 : 1;
@@ -425,8 +480,8 @@ var j = /* @__PURE__ */ E(((e, t) => {
425
480
  compareIdentifiers: r,
426
481
  rcompareIdentifiers: (e, t) => r(t, e)
427
482
  };
428
- })), P = /* @__PURE__ */ E(((e, t) => {
429
- var n = M(), { MAX_LENGTH: r, MAX_SAFE_INTEGER: i } = j(), { safeRe: a, t: o } = N(), s = tt(), { compareIdentifiers: c } = nt();
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();
430
485
  t.exports = class e {
431
486
  constructor(t, c) {
432
487
  if (c = s(c), t instanceof e) {
@@ -546,7 +601,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
546
601
  return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this;
547
602
  }
548
603
  };
549
- })), F = /* @__PURE__ */ E(((e, t) => {
604
+ })), F = /* @__PURE__ */ T(((e, t) => {
550
605
  var n = P();
551
606
  t.exports = (e, t, r = !1) => {
552
607
  if (e instanceof n) return e;
@@ -557,19 +612,19 @@ var j = /* @__PURE__ */ E(((e, t) => {
557
612
  throw e;
558
613
  }
559
614
  };
560
- })), rt = /* @__PURE__ */ E(((e, t) => {
615
+ })), pt = /* @__PURE__ */ T(((e, t) => {
561
616
  var n = F();
562
617
  t.exports = (e, t) => {
563
618
  let r = n(e, t);
564
619
  return r ? r.version : null;
565
620
  };
566
- })), it = /* @__PURE__ */ E(((e, t) => {
621
+ })), mt = /* @__PURE__ */ T(((e, t) => {
567
622
  var n = F();
568
623
  t.exports = (e, t) => {
569
624
  let r = n(e.trim().replace(/^[=v]+/, ""), t);
570
625
  return r ? r.version : null;
571
626
  };
572
- })), at = /* @__PURE__ */ E(((e, t) => {
627
+ })), ht = /* @__PURE__ */ T(((e, t) => {
573
628
  var n = P();
574
629
  t.exports = (e, t, r, i, a) => {
575
630
  typeof r == "string" && (a = i, i = r, r = void 0);
@@ -579,7 +634,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
579
634
  return null;
580
635
  }
581
636
  };
582
- })), ot = /* @__PURE__ */ E(((e, t) => {
637
+ })), gt = /* @__PURE__ */ T(((e, t) => {
583
638
  var n = F();
584
639
  t.exports = (e, t) => {
585
640
  let r = n(e, null, !0), i = n(t, null, !0), a = r.compare(i);
@@ -592,62 +647,62 @@ var j = /* @__PURE__ */ E(((e, t) => {
592
647
  let u = l ? "pre" : "";
593
648
  return r.major === i.major ? r.minor === i.minor ? r.patch === i.patch ? "prerelease" : u + "patch" : u + "minor" : u + "major";
594
649
  };
595
- })), st = /* @__PURE__ */ E(((e, t) => {
650
+ })), _t = /* @__PURE__ */ T(((e, t) => {
596
651
  var n = P();
597
652
  t.exports = (e, t) => new n(e, t).major;
598
- })), ct = /* @__PURE__ */ E(((e, t) => {
653
+ })), vt = /* @__PURE__ */ T(((e, t) => {
599
654
  var n = P();
600
655
  t.exports = (e, t) => new n(e, t).minor;
601
- })), lt = /* @__PURE__ */ E(((e, t) => {
656
+ })), yt = /* @__PURE__ */ T(((e, t) => {
602
657
  var n = P();
603
658
  t.exports = (e, t) => new n(e, t).patch;
604
- })), ut = /* @__PURE__ */ E(((e, t) => {
659
+ })), bt = /* @__PURE__ */ T(((e, t) => {
605
660
  var n = F();
606
661
  t.exports = (e, t) => {
607
662
  let r = n(e, t);
608
663
  return r && r.prerelease.length ? r.prerelease : null;
609
664
  };
610
- })), I = /* @__PURE__ */ E(((e, t) => {
665
+ })), I = /* @__PURE__ */ T(((e, t) => {
611
666
  var n = P();
612
667
  t.exports = (e, t, r) => new n(e, r).compare(new n(t, r));
613
- })), dt = /* @__PURE__ */ E(((e, t) => {
668
+ })), xt = /* @__PURE__ */ T(((e, t) => {
614
669
  var n = I();
615
670
  t.exports = (e, t, r) => n(t, e, r);
616
- })), ft = /* @__PURE__ */ E(((e, t) => {
671
+ })), St = /* @__PURE__ */ T(((e, t) => {
617
672
  var n = I();
618
673
  t.exports = (e, t) => n(e, t, !0);
619
- })), pt = /* @__PURE__ */ E(((e, t) => {
674
+ })), Ct = /* @__PURE__ */ T(((e, t) => {
620
675
  var n = P();
621
676
  t.exports = (e, t, r) => {
622
677
  let i = new n(e, r), a = new n(t, r);
623
678
  return i.compare(a) || i.compareBuild(a);
624
679
  };
625
- })), mt = /* @__PURE__ */ E(((e, t) => {
626
- var n = pt();
680
+ })), wt = /* @__PURE__ */ T(((e, t) => {
681
+ var n = Ct();
627
682
  t.exports = (e, t) => e.sort((e, r) => n(e, r, t));
628
- })), ht = /* @__PURE__ */ E(((e, t) => {
629
- var n = pt();
683
+ })), Tt = /* @__PURE__ */ T(((e, t) => {
684
+ var n = Ct();
630
685
  t.exports = (e, t) => e.sort((e, r) => n(r, e, t));
631
- })), L = /* @__PURE__ */ E(((e, t) => {
686
+ })), L = /* @__PURE__ */ T(((e, t) => {
632
687
  var n = I();
633
688
  t.exports = (e, t, r) => n(e, t, r) > 0;
634
- })), gt = /* @__PURE__ */ E(((e, t) => {
689
+ })), Et = /* @__PURE__ */ T(((e, t) => {
635
690
  var n = I();
636
691
  t.exports = (e, t, r) => n(e, t, r) < 0;
637
- })), _t = /* @__PURE__ */ E(((e, t) => {
692
+ })), Dt = /* @__PURE__ */ T(((e, t) => {
638
693
  var n = I();
639
694
  t.exports = (e, t, r) => n(e, t, r) === 0;
640
- })), vt = /* @__PURE__ */ E(((e, t) => {
695
+ })), Ot = /* @__PURE__ */ T(((e, t) => {
641
696
  var n = I();
642
697
  t.exports = (e, t, r) => n(e, t, r) !== 0;
643
- })), yt = /* @__PURE__ */ E(((e, t) => {
698
+ })), kt = /* @__PURE__ */ T(((e, t) => {
644
699
  var n = I();
645
700
  t.exports = (e, t, r) => n(e, t, r) >= 0;
646
- })), bt = /* @__PURE__ */ E(((e, t) => {
701
+ })), At = /* @__PURE__ */ T(((e, t) => {
647
702
  var n = I();
648
703
  t.exports = (e, t, r) => n(e, t, r) <= 0;
649
- })), xt = /* @__PURE__ */ E(((e, t) => {
650
- var n = _t(), r = vt(), i = L(), a = yt(), o = gt(), s = bt();
704
+ })), jt = /* @__PURE__ */ T(((e, t) => {
705
+ var n = Dt(), r = Ot(), i = L(), a = kt(), o = Et(), s = At();
651
706
  t.exports = (e, t, c, l) => {
652
707
  switch (t) {
653
708
  case "===": return typeof e == "object" && (e = e.version), typeof c == "object" && (c = c.version), e === c;
@@ -663,7 +718,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
663
718
  default: throw TypeError(`Invalid operator: ${t}`);
664
719
  }
665
720
  };
666
- })), St = /* @__PURE__ */ E(((e, t) => {
721
+ })), Mt = /* @__PURE__ */ T(((e, t) => {
667
722
  var n = P(), r = F(), { safeRe: i, t: a } = N();
668
723
  t.exports = (e, t) => {
669
724
  if (e instanceof n) return e;
@@ -680,7 +735,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
680
735
  let s = o[2];
681
736
  return r(`${s}.${o[3] || "0"}.${o[4] || "0"}${t.includePrerelease && o[5] ? `-${o[5]}` : ""}${t.includePrerelease && o[6] ? `+${o[6]}` : ""}`, t);
682
737
  };
683
- })), Ct = /* @__PURE__ */ E(((e, t) => {
738
+ })), Nt = /* @__PURE__ */ T(((e, t) => {
684
739
  t.exports = class {
685
740
  constructor() {
686
741
  this.max = 1e3, this.map = /* @__PURE__ */ new Map();
@@ -703,7 +758,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
703
758
  return this;
704
759
  }
705
760
  };
706
- })), R = /* @__PURE__ */ E(((e, t) => {
761
+ })), R = /* @__PURE__ */ T(((e, t) => {
707
762
  var n = /\s+/g;
708
763
  t.exports = class e {
709
764
  constructor(t, r) {
@@ -743,8 +798,8 @@ var j = /* @__PURE__ */ E(((e, t) => {
743
798
  let t = ((this.options.includePrerelease && p) | (this.options.loose && m)) + ":" + e, n = r.get(t);
744
799
  if (n) return n;
745
800
  let i = this.options.loose, s = i ? c[l.HYPHENRANGELOOSE] : c[l.HYPHENRANGE];
746
- e = e.replace(s, S(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);
747
- let g = e.split(" ").map((e) => v(e, this.options)).join(" ").split(/\s+/).map((e) => ae(e, this.options));
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));
748
803
  i && (g = g.filter((e) => (o("loose invalid filter", e, this.options), !!e.match(c[l.COMPARATORLOOSE])))), o("range list", g);
749
804
  let _ = /* @__PURE__ */ new Map(), y = g.map((e) => new a(e, this.options));
750
805
  for (let e of y) {
@@ -752,8 +807,8 @@ var j = /* @__PURE__ */ E(((e, t) => {
752
807
  _.set(e.value, e);
753
808
  }
754
809
  _.size > 1 && _.has("") && _.delete("");
755
- let b = [..._.values()];
756
- return r.set(t, b), b;
810
+ let ee = [..._.values()];
811
+ return r.set(t, ee), ee;
757
812
  }
758
813
  intersects(t, n) {
759
814
  if (!(t instanceof e)) throw TypeError("a Range is required");
@@ -766,22 +821,22 @@ var j = /* @__PURE__ */ E(((e, t) => {
766
821
  } catch {
767
822
  return !1;
768
823
  }
769
- for (let t = 0; t < this.set.length; t++) if (oe(this.set[t], e, this.options)) return !0;
824
+ for (let t = 0; t < this.set.length; t++) if (x(this.set[t], e, this.options)) return !0;
770
825
  return !1;
771
826
  }
772
827
  };
773
- var r = new (Ct())(), i = tt(), 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) => {
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) => {
774
829
  let n = !0, r = e.slice(), i = r.pop();
775
830
  for (; n && r.length;) n = r.every((e) => i.intersects(e, t)), i = r.pop();
776
831
  return n;
777
- }, v = (e, t) => (o("comp", e, t), e = te(e, t), o("caret", e), e = b(e, t), o("tildes", e), e = re(e, t), o("xrange", e), e = x(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) => {
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) => {
778
833
  let n = t.loose ? c[l.TILDELOOSE] : c[l.TILDE];
779
834
  return e.replace(n, (t, n, r, i, a) => {
780
835
  o("tilde", e, t, n, r, i, a);
781
836
  let s;
782
837
  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;
783
838
  });
784
- }, te = (e, t) => e.trim().split(/\s+/).map((e) => ne(e, t)).join(" "), ne = (e, t) => {
839
+ }, ne = (e, t) => e.trim().split(/\s+/).map((e) => re(e, t)).join(" "), re = (e, t) => {
785
840
  o("caret", e, t);
786
841
  let n = t.loose ? c[l.CARETLOOSE] : c[l.CARET], r = t.includePrerelease ? "-0" : "";
787
842
  return e.replace(n, (t, n, i, a, s) => {
@@ -789,7 +844,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
789
844
  let c;
790
845
  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;
791
846
  });
792
- }, re = (e, t) => (o("replaceXRanges", e, t), e.split(/\s+/).map((e) => ie(e, t)).join(" ")), ie = (e, t) => {
847
+ }, ie = (e, t) => (o("replaceXRanges", e, t), e.split(/\s+/).map((e) => ae(e, t)).join(" ")), ae = (e, t) => {
793
848
  e = e.trim();
794
849
  let n = t.loose ? c[l.XRANGELOOSE] : c[l.XRANGE];
795
850
  return e.replace(n, (n, r, i, a, s, c) => {
@@ -797,7 +852,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
797
852
  let l = y(i), u = l || y(a), d = u || y(s), f = d;
798
853
  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;
799
854
  });
800
- }, x = (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], "")), S = (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()), oe = (e, t, n) => {
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) => {
801
856
  for (let n = 0; n < e.length; n++) if (!e[n].test(t)) return !1;
802
857
  if (t.prerelease.length && !n.includePrerelease) {
803
858
  for (let n = 0; n < e.length; n++) if (o(e[n].semver), e[n].semver !== a.ANY && e[n].semver.prerelease.length > 0) {
@@ -808,7 +863,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
808
863
  }
809
864
  return !0;
810
865
  };
811
- })), z = /* @__PURE__ */ E(((e, t) => {
866
+ })), z = /* @__PURE__ */ T(((e, t) => {
812
867
  var n = Symbol("SemVer ANY");
813
868
  t.exports = class e {
814
869
  static get ANY() {
@@ -843,8 +898,8 @@ var j = /* @__PURE__ */ E(((e, t) => {
843
898
  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(">")));
844
899
  }
845
900
  };
846
- var r = tt(), { safeRe: i, t: a } = N(), o = xt(), s = M(), c = P(), l = R();
847
- })), B = /* @__PURE__ */ E(((e, t) => {
901
+ var r = dt(), { safeRe: i, t: a } = N(), o = jt(), s = M(), c = P(), l = R();
902
+ })), B = /* @__PURE__ */ T(((e, t) => {
848
903
  var n = R();
849
904
  t.exports = (e, t, r) => {
850
905
  try {
@@ -854,10 +909,10 @@ var j = /* @__PURE__ */ E(((e, t) => {
854
909
  }
855
910
  return t.test(e);
856
911
  };
857
- })), wt = /* @__PURE__ */ E(((e, t) => {
912
+ })), Pt = /* @__PURE__ */ T(((e, t) => {
858
913
  var n = R();
859
914
  t.exports = (e, t) => new n(e, t).set.map((e) => e.map((e) => e.value).join(" ").trim().split(" "));
860
- })), Tt = /* @__PURE__ */ E(((e, t) => {
915
+ })), Ft = /* @__PURE__ */ T(((e, t) => {
861
916
  var n = P(), r = R();
862
917
  t.exports = (e, t, i) => {
863
918
  let a = null, o = null, s = null;
@@ -870,7 +925,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
870
925
  s.test(e) && (!a || o.compare(e) === -1) && (a = e, o = new n(a, i));
871
926
  }), a;
872
927
  };
873
- })), Et = /* @__PURE__ */ E(((e, t) => {
928
+ })), It = /* @__PURE__ */ T(((e, t) => {
874
929
  var n = P(), r = R();
875
930
  t.exports = (e, t, i) => {
876
931
  let a = null, o = null, s = null;
@@ -883,7 +938,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
883
938
  s.test(e) && (!a || o.compare(e) === 1) && (a = e, o = new n(a, i));
884
939
  }), a;
885
940
  };
886
- })), Dt = /* @__PURE__ */ E(((e, t) => {
941
+ })), Lt = /* @__PURE__ */ T(((e, t) => {
887
942
  var n = P(), r = R(), i = L();
888
943
  t.exports = (e, t) => {
889
944
  e = new r(e, t);
@@ -909,7 +964,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
909
964
  }
910
965
  return a && e.test(a) ? a : null;
911
966
  };
912
- })), Ot = /* @__PURE__ */ E(((e, t) => {
967
+ })), Rt = /* @__PURE__ */ T(((e, t) => {
913
968
  var n = R();
914
969
  t.exports = (e, t) => {
915
970
  try {
@@ -918,8 +973,8 @@ var j = /* @__PURE__ */ E(((e, t) => {
918
973
  return null;
919
974
  }
920
975
  };
921
- })), kt = /* @__PURE__ */ E(((e, t) => {
922
- var n = P(), r = z(), { ANY: i } = r, a = R(), o = B(), s = L(), c = gt(), l = bt(), u = yt();
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();
923
978
  t.exports = (e, t, d, f) => {
924
979
  e = new n(e, f), t = new a(t, f);
925
980
  let p, m, h, g, _;
@@ -941,16 +996,16 @@ var j = /* @__PURE__ */ E(((e, t) => {
941
996
  }
942
997
  return !0;
943
998
  };
944
- })), At = /* @__PURE__ */ E(((e, t) => {
945
- var n = kt();
999
+ })), Bt = /* @__PURE__ */ T(((e, t) => {
1000
+ var n = zt();
946
1001
  t.exports = (e, t, r) => n(e, t, ">", r);
947
- })), jt = /* @__PURE__ */ E(((e, t) => {
948
- var n = kt();
1002
+ })), Vt = /* @__PURE__ */ T(((e, t) => {
1003
+ var n = zt();
949
1004
  t.exports = (e, t, r) => n(e, t, "<", r);
950
- })), Mt = /* @__PURE__ */ E(((e, t) => {
1005
+ })), Ht = /* @__PURE__ */ T(((e, t) => {
951
1006
  var n = R();
952
1007
  t.exports = (e, t, r) => (e = new n(e, r), t = new n(t, r), e.intersects(t, r));
953
- })), Nt = /* @__PURE__ */ E(((e, t) => {
1008
+ })), Ut = /* @__PURE__ */ T(((e, t) => {
954
1009
  var n = B(), r = I();
955
1010
  t.exports = (e, t, i) => {
956
1011
  let a = [], o = null, s = null, c = e.sort((e, t) => r(e, t, i));
@@ -961,7 +1016,7 @@ var j = /* @__PURE__ */ E(((e, t) => {
961
1016
  let u = l.join(" || "), d = typeof t.raw == "string" ? t.raw : String(t);
962
1017
  return u.length < d.length ? u : t;
963
1018
  };
964
- })), Pt = /* @__PURE__ */ E(((e, t) => {
1019
+ })), Wt = /* @__PURE__ */ T(((e, t) => {
965
1020
  var n = R(), r = z(), { ANY: i } = r, a = B(), o = I(), s = (e, t, r = {}) => {
966
1021
  if (e === t) return !0;
967
1022
  e = new n(e, r), t = new n(t, r);
@@ -1020,46 +1075,46 @@ var j = /* @__PURE__ */ E(((e, t) => {
1020
1075
  return r < 0 ? e : r > 0 || t.operator === "<" && e.operator === "<=" ? t : e;
1021
1076
  };
1022
1077
  t.exports = s;
1023
- })), V = /* @__PURE__ */ Se((/* @__PURE__ */ E(((e, t) => {
1024
- var n = N(), r = j(), i = P(), a = nt();
1078
+ })), V = /* @__PURE__ */ Te((/* @__PURE__ */ T(((e, t) => {
1079
+ var n = N(), r = j(), i = P(), a = ft();
1025
1080
  t.exports = {
1026
1081
  parse: F(),
1027
- valid: rt(),
1028
- clean: it(),
1029
- inc: at(),
1030
- diff: ot(),
1031
- major: st(),
1032
- minor: ct(),
1033
- patch: lt(),
1034
- prerelease: ut(),
1082
+ valid: pt(),
1083
+ clean: mt(),
1084
+ inc: ht(),
1085
+ diff: gt(),
1086
+ major: _t(),
1087
+ minor: vt(),
1088
+ patch: yt(),
1089
+ prerelease: bt(),
1035
1090
  compare: I(),
1036
- rcompare: dt(),
1037
- compareLoose: ft(),
1038
- compareBuild: pt(),
1039
- sort: mt(),
1040
- rsort: ht(),
1091
+ rcompare: xt(),
1092
+ compareLoose: St(),
1093
+ compareBuild: Ct(),
1094
+ sort: wt(),
1095
+ rsort: Tt(),
1041
1096
  gt: L(),
1042
- lt: gt(),
1043
- eq: _t(),
1044
- neq: vt(),
1045
- gte: yt(),
1046
- lte: bt(),
1047
- cmp: xt(),
1048
- coerce: St(),
1097
+ lt: Et(),
1098
+ eq: Dt(),
1099
+ neq: Ot(),
1100
+ gte: kt(),
1101
+ lte: At(),
1102
+ cmp: jt(),
1103
+ coerce: Mt(),
1049
1104
  Comparator: z(),
1050
1105
  Range: R(),
1051
1106
  satisfies: B(),
1052
- toComparators: wt(),
1053
- maxSatisfying: Tt(),
1054
- minSatisfying: Et(),
1055
- minVersion: Dt(),
1056
- validRange: Ot(),
1057
- outside: kt(),
1058
- gtr: At(),
1059
- ltr: jt(),
1060
- intersects: Mt(),
1061
- simplifyRange: Nt(),
1062
- subset: Pt(),
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(),
1063
1118
  SemVer: i,
1064
1119
  re: n.re,
1065
1120
  src: n.src,
@@ -1069,58 +1124,58 @@ var j = /* @__PURE__ */ E(((e, t) => {
1069
1124
  compareIdentifiers: a.compareIdentifiers,
1070
1125
  rcompareIdentifiers: a.rcompareIdentifiers
1071
1126
  };
1072
- })))()), Ft = "_updates_v2/per_package_version/";
1073
- function It(e, t) {
1074
- return `${Ft}${e.organization}/${e.name}/${e.version}/${t}`;
1127
+ })))()), Gt = "_updates_v2/per_package_version/";
1128
+ function Kt(e, t) {
1129
+ return `${Gt}${e.organization}/${e.name}/${e.version}/${t}`;
1075
1130
  }
1076
- var Lt = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, Rt = "_updates_v2/_global_update_in", zt = "_updates_v2/_global_update_out", Bt = "_overview_snapshots_v2/global/", Vt = "_overview_snapshots_v2/per_package/", Ht = /^(?<timestamp>\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}Z-[a-z0-9]+)\.json\.gz$/;
1077
- function Ut(e) {
1078
- return `${Bt}${e}.json.gz`;
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`;
1079
1134
  }
1080
- function Wt(e, t) {
1081
- return `${Vt}${e.organization}/${e.name}/${t}.json.gz`;
1135
+ function en(e, t) {
1136
+ return `${Zt}${e.organization}/${e.name}/${t}.json.gz`;
1082
1137
  }
1083
1138
  //#endregion
1084
1139
  //#region src/v2/registry/schema_public.ts
1085
- var Gt = "v2/", Kt = "overview.json", qt = "overview.json.gz", Jt = "overview.json", H = "manifest.json", U = "channels", W = /^[-a-z0-9]+$/;
1140
+ var tn = "v2/", nn = "overview.json", rn = "overview.json.gz", an = "overview.json", H = "manifest.json", U = "channels", W = /^[-a-z0-9]+$/;
1086
1141
  function G(e) {
1087
1142
  return `${e.organization}/${e.name}/${e.version}`;
1088
1143
  }
1089
1144
  function K(e) {
1090
1145
  return `v2/${G(e)}`;
1091
1146
  }
1092
- var Yt = "/" + H, Xt = C.object({
1093
- description: c,
1094
- channels: C.array(C.string()).default(() => []),
1095
- manifestSha256: p
1096
- }).passthrough(), q = C.object({
1097
- schema: C.literal("v2"),
1098
- versions: C.array(Xt)
1147
+ var on = "/" + H, sn = S.object({
1148
+ description: l,
1149
+ channels: S.array(S.string()).default(() => []),
1150
+ manifestSha256: m
1151
+ }).passthrough(), q = S.object({
1152
+ schema: S.literal("v2"),
1153
+ versions: S.array(sn)
1099
1154
  }).passthrough();
1100
- function Zt(e) {
1101
- return `${e.organization}/${e.name}/${Jt}`;
1155
+ function cn(e) {
1156
+ return `${e.organization}/${e.name}/${an}`;
1102
1157
  }
1103
- function Qt(e) {
1104
- return `v2/${Zt(e)}`;
1158
+ function ln(e) {
1159
+ return `v2/${cn(e)}`;
1105
1160
  }
1106
- function $t(e) {
1161
+ function un(e) {
1107
1162
  return `${G(e)}/${U}/`;
1108
1163
  }
1109
- function en(e) {
1110
- return `v2/${$t(e)}`;
1111
- }
1112
- var tn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/manifest\.json$/, J = `v2/${Kt}`, nn = `v2/${qt}`, rn = C.object({
1113
- id: l,
1114
- allVersions: C.array(C.string()).optional(),
1115
- allVersionsWithChannels: C.array(m).optional(),
1116
- latest: c.optional(),
1117
- latestManifestSha256: p.optional(),
1118
- latestByChannel: C.record(C.string(), C.object({
1119
- description: c,
1120
- manifestSha256: p
1164
+ function dn(e) {
1165
+ return `v2/${un(e)}`;
1166
+ }
1167
+ var fn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/manifest\.json$/, J = `v2/${nn}`, pn = `v2/${rn}`, mn = S.object({
1168
+ id: u,
1169
+ allVersions: S.array(S.string()).optional(),
1170
+ allVersionsWithChannels: S.array(h).optional(),
1171
+ latest: l.optional(),
1172
+ latestManifestSha256: m.optional(),
1173
+ latestByChannel: S.record(S.string(), S.object({
1174
+ description: l,
1175
+ manifestSha256: m
1121
1176
  }).passthrough()).default({})
1122
1177
  }).passthrough();
1123
- function an(e) {
1178
+ function hn(e) {
1124
1179
  let t = `${e.id.organization}/${e.id.name}`, n = e.allVersionsWithChannels;
1125
1180
  if (n === void 0) {
1126
1181
  if (e.allVersions === void 0) throw Error(`GlobalOverviewEntry ${t} is missing both 'allVersionsWithChannels' and the deprecated 'allVersions' fallback`);
@@ -1130,11 +1185,11 @@ function an(e) {
1130
1185
  }));
1131
1186
  }
1132
1187
  let r = e.latestByChannel;
1133
- if (!r[o]) {
1188
+ if (!r[s]) {
1134
1189
  if (e.latest === void 0 || e.latestManifestSha256 === void 0) throw Error(`GlobalOverviewEntry ${t} is missing the 'latestByChannel[any]' slot and the deprecated 'latest'/'latestManifestSha256' fallback`);
1135
1190
  r = {
1136
1191
  ...r,
1137
- [o]: {
1192
+ [s]: {
1138
1193
  description: e.latest,
1139
1194
  manifestSha256: e.latestManifestSha256
1140
1195
  }
@@ -1146,23 +1201,23 @@ function an(e) {
1146
1201
  latestByChannel: r
1147
1202
  };
1148
1203
  }
1149
- var on = C.object({
1150
- schema: C.literal("v2"),
1151
- packages: C.array(rn)
1204
+ var gn = S.object({
1205
+ schema: S.literal("v2"),
1206
+ packages: S.array(mn)
1152
1207
  }).passthrough();
1153
1208
  function Y(e) {
1154
- let t = on.parse(e);
1209
+ let t = gn.parse(e);
1155
1210
  return {
1156
1211
  ...t,
1157
- packages: t.packages.map(an)
1212
+ packages: t.packages.map(hn)
1158
1213
  };
1159
1214
  }
1160
1215
  //#endregion
1161
1216
  //#region src/v2/registry/registry.ts
1162
- var sn = class {
1163
- gzipAsync = oe(te);
1164
- gunzipAsync = oe(b);
1165
- constructor(e, t = new ie(), n = {}) {
1217
+ var _n = class {
1218
+ gzipAsync = le(re);
1219
+ gunzipAsync = le(te);
1220
+ constructor(e, t = new oe(), n = {}) {
1166
1221
  this.storage = e, this.logger = t, this.settings = n;
1167
1222
  }
1168
1223
  generateTimestamp() {
@@ -1173,7 +1228,7 @@ var sn = class {
1173
1228
  }
1174
1229
  async createGlobalOverviewSnapshot(e, t) {
1175
1230
  if (!this.settings.skipSnapshotCreation) try {
1176
- let n = await this.gzipAsync(e), r = Ut(t);
1231
+ let n = await this.gzipAsync(e), r = $t(t);
1177
1232
  await this.storage.putFile(r, Buffer.from(n)), this.logger.info(`Global overview snapshot created at ${r}`);
1178
1233
  } catch (e) {
1179
1234
  this.logger.warn(`Failed to create global overview snapshot: ${String(e)}`);
@@ -1181,7 +1236,7 @@ var sn = class {
1181
1236
  }
1182
1237
  async createPackageOverviewSnapshot(e, t, n) {
1183
1238
  if (!this.settings.skipSnapshotCreation) try {
1184
- let r = JSON.stringify(t), i = await this.gzipAsync(r), a = Wt(e, n);
1239
+ let r = JSON.stringify(t), i = await this.gzipAsync(r), a = en(e, n);
1185
1240
  await this.storage.putFile(a, Buffer.from(i)), this.logger.info(`Package overview snapshot created at ${a} for ${e.organization}:${e.name}`);
1186
1241
  } catch (t) {
1187
1242
  this.logger.warn(`Failed to create package overview snapshot for ${e.organization}:${e.name}: ${String(t)}`);
@@ -1189,7 +1244,7 @@ var sn = class {
1189
1244
  }
1190
1245
  async updateRegistry(e = "normal") {
1191
1246
  this.logger.info("Initiating registry refresh...");
1192
- let t = this.generateTimestamp(), n = /* @__PURE__ */ new Map(), r = [], i = await this.storage.listFiles(Ft), a = ({ organization: e, name: t, version: r }) => {
1247
+ let t = this.generateTimestamp(), n = /* @__PURE__ */ new Map(), r = [], i = await this.storage.listFiles(Gt), a = ({ organization: e, name: t, version: r }) => {
1193
1248
  let i = `${e}:${t}`, a = n.get(i);
1194
1249
  return a ? a.versions.has(r) ? !1 : (a.versions.add(r), !0) : (n.set(i, {
1195
1250
  package: {
@@ -1201,7 +1256,7 @@ var sn = class {
1201
1256
  };
1202
1257
  this.logger.info("Packages to be updated:");
1203
1258
  for (let e of i) {
1204
- let t = e.match(Lt);
1259
+ let t = e.match(qt);
1205
1260
  if (!t) continue;
1206
1261
  r.push(e);
1207
1262
  let { organization: n, name: i, version: o, seed: s } = t.groups, c = a({
@@ -1214,7 +1269,7 @@ var sn = class {
1214
1269
  if (e === "force") {
1215
1270
  let e = await this.storage.listFiles("v2/");
1216
1271
  for (let t of e) {
1217
- let e = t.match(tn);
1272
+ let e = t.match(fn);
1218
1273
  if (!e) continue;
1219
1274
  let { organization: n, name: r, version: i } = e.groups, o = a({
1220
1275
  organization: n,
@@ -1224,18 +1279,18 @@ var sn = class {
1224
1279
  this.logger.info(` - ${n}:${r}:${i} force_added:${o}`);
1225
1280
  }
1226
1281
  }
1227
- let s = await this.storage.getFile(J);
1228
- if (e === "force" && s !== void 0) {
1282
+ let o = await this.storage.getFile(J);
1283
+ if (e === "force" && o !== void 0) {
1229
1284
  let e = this.generatePreWriteTimestamp();
1230
- await this.createGlobalOverviewSnapshot(s.toString(), e);
1285
+ await this.createGlobalOverviewSnapshot(o.toString(), e);
1231
1286
  }
1232
- let c = (e === "force" || s === void 0 ? {
1287
+ let c = (e === "force" || o === void 0 ? {
1233
1288
  schema: "v2",
1234
1289
  packages: []
1235
- } : Y(JSON.parse(s.toString()))).packages;
1290
+ } : Y(JSON.parse(o.toString()))).packages;
1236
1291
  this.logger.info(`Global overview ${e === "force" ? "starting empty (force mode)" : "loaded"}, ${c.length} records`);
1237
1292
  for (let [, r] of n.entries()) {
1238
- let n = Qt(r.package), i = await this.storage.getFile(n);
1293
+ let n = ln(r.package), i = await this.storage.getFile(n);
1239
1294
  if (e === "force" && i !== void 0) {
1240
1295
  let e = this.generatePreWriteTimestamp(), t = q.parse(JSON.parse(i.toString()));
1241
1296
  await this.createPackageOverviewSnapshot(r.package, t, e);
@@ -1245,28 +1300,28 @@ var sn = class {
1245
1300
  versions: []
1246
1301
  } : q.parse(JSON.parse(i.toString()));
1247
1302
  this.logger.info(`Updating ${r.package.organization}:${r.package.name} overview${e === "force" ? " (starting empty in force mode)" : ""}, ${a.versions.length} records`);
1248
- let s = a.versions.filter((e) => !r.versions.has(e.description.id.version));
1303
+ let o = a.versions.filter((e) => !r.versions.has(e.description.id.version));
1249
1304
  for (let [e] of r.versions.entries()) {
1250
1305
  let t = e.toString(), n = {
1251
1306
  ...r.package,
1252
1307
  version: t
1253
- }, i = await this.storage.getFile(K(n) + Yt);
1308
+ }, i = await this.storage.getFile(K(n) + on);
1254
1309
  if (!i) continue;
1255
- let a = await k(i), o = (await this.storage.listFiles(en(n))).filter((e) => e.match(W) ? !0 : (this.logger.warn(`Unexpected channel in ${_(n)}: ${e}`), !1));
1256
- s.push({
1257
- description: O(u.parse(JSON.parse(i.toString("utf8"))).description, t),
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),
1258
1313
  manifestSha256: a,
1259
- channels: o
1314
+ channels: s
1260
1315
  });
1261
1316
  }
1262
- s.sort((e, t) => (0, V.compare)(t.description.id.version, e.description.id.version));
1317
+ o.sort((e, t) => (0, V.compare)(t.description.id.version, e.description.id.version));
1263
1318
  let l = {
1264
1319
  schema: "v2",
1265
- versions: s
1320
+ versions: o
1266
1321
  };
1267
- e !== "dry-run" && (await this.storage.putFile(n, Buffer.from(JSON.stringify(l))), await this.createPackageOverviewSnapshot(r.package, l, t)), this.logger.info(`Done (${s.length} records)`);
1268
- let d = /* @__PURE__ */ new Set();
1269
- for (let e of s) for (let t of e.channels) d.add(t);
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);
1270
1325
  c = c.filter((e) => e.id.organization !== r.package.organization || e.id.name !== r.package.name);
1271
1326
  let f = `${r.package.organization}/${r.package.name}`;
1272
1327
  c.push({
@@ -1274,18 +1329,18 @@ var sn = class {
1274
1329
  organization: r.package.organization,
1275
1330
  name: r.package.name
1276
1331
  },
1277
- allVersions: s.map((e) => e.description.id.version).reverse(),
1278
- allVersionsWithChannels: s.map((e) => ({
1332
+ allVersions: o.map((e) => e.description.id.version).reverse(),
1333
+ allVersionsWithChannels: o.map((e) => ({
1279
1334
  version: e.description.id.version,
1280
1335
  channels: e.channels
1281
1336
  })).reverse(),
1282
- latest: O(s[0].description, f),
1283
- latestManifestSha256: s[0].manifestSha256,
1284
- latestByChannel: Object.fromEntries([...d, o].map((e) => {
1285
- let t = s.find((t) => e === o || t.channels.indexOf(e) !== -1);
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);
1286
1341
  if (!t) throw Error("Assertion error");
1287
1342
  return [e, {
1288
- description: O(t.description, f),
1343
+ description: D(t.description, f),
1289
1344
  manifestSha256: t?.manifestSha256
1290
1345
  }];
1291
1346
  }))
@@ -1298,13 +1353,13 @@ var sn = class {
1298
1353
  }), n = Buffer.from(e);
1299
1354
  await this.storage.putFile(J, n);
1300
1355
  let r = await this.gzipAsync(e);
1301
- await this.storage.putFile(nn, Buffer.from(r)), await this.createGlobalOverviewSnapshot(e, t);
1356
+ await this.storage.putFile(pn, Buffer.from(r)), await this.createGlobalOverviewSnapshot(e, t);
1302
1357
  }
1303
- this.logger.info(`Global overview updated (${c.length} records)`), e !== "dry-run" && await this.storage.deleteFiles(...r.map((e) => `${Ft}${e}`)), this.logger.info("Version update requests cleared");
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");
1304
1359
  }
1305
1360
  async updateIfNeeded(e = "normal") {
1306
1361
  this.logger.info("Checking if registry requires refresh...");
1307
- let t = await this.storage.getFile(Rt), n = await this.storage.getFile(zt);
1362
+ let t = await this.storage.getFile(Jt), n = await this.storage.getFile(Yt);
1308
1363
  if (e !== "force" && t === void 0 && n === void 0) {
1309
1364
  this.logger.info("No global seed files found, update not needed.");
1310
1365
  return;
@@ -1313,10 +1368,10 @@ var sn = class {
1313
1368
  this.logger.info("Registry is up to date.");
1314
1369
  return;
1315
1370
  }
1316
- await this.updateRegistry(e), t && (e !== "dry-run" && await this.storage.putFile(zt, t), this.logger.info("Refresh finished."));
1371
+ await this.updateRegistry(e), t && (e !== "dry-run" && await this.storage.putFile(Yt, t), this.logger.info("Refresh finished."));
1317
1372
  }
1318
1373
  async getPackageOverview(e) {
1319
- let t = await this.storage.getFile(Qt(e));
1374
+ let t = await this.storage.getFile(ln(e));
1320
1375
  if (t !== void 0) return q.parse(JSON.parse(t.toString()));
1321
1376
  }
1322
1377
  async getGlobalOverview() {
@@ -1324,34 +1379,34 @@ var sn = class {
1324
1379
  if (e !== void 0) return Y(JSON.parse(e.toString()));
1325
1380
  }
1326
1381
  async marchChanged(e) {
1327
- let t = re(), n = It(e, t);
1328
- this.logger.info(`Creating update seed at ${n} ...`), await this.storage.putFile(n, Buffer.from(t)), this.logger.info(`Touching global update seed ${Rt} ...`), await this.storage.putFile(Rt, Buffer.from(t));
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));
1329
1384
  }
1330
1385
  async addPackageToChannel(e, t) {
1331
1386
  if (!t.match(W)) throw Error(`Illegal characters in channel name: ${t}`);
1332
1387
  let n = K(e);
1333
- if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${_(e)} not found in the registry.`);
1388
+ if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${v(e)} not found in the registry.`);
1334
1389
  await this.storage.putFile(`${n}/${U}/${t}`, Buffer.from(t)), await this.marchChanged(e);
1335
1390
  }
1336
1391
  async removePackageFromChannel(e, t) {
1337
1392
  if (!t.match(W)) throw Error(`Illegal characters in channel name: ${t}`);
1338
1393
  let n = K(e);
1339
- if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${_(e)} not found in the registry.`);
1394
+ if (await this.storage.getFile(`${n}/manifest.json`) === void 0) throw Error(`Package ${v(e)} not found in the registry.`);
1340
1395
  await this.storage.deleteFiles(`${n}/${U}/${t}`), await this.marchChanged(e);
1341
1396
  }
1342
1397
  async listGlobalOverviewSnapshots() {
1343
- let e = await this.storage.listFiles(Bt), t = [];
1398
+ let e = await this.storage.listFiles(Xt), t = [];
1344
1399
  for (let n of e) {
1345
- let e = n.indexOf("/") === -1 ? n : n.substring(n.lastIndexOf("/") + 1), r = e.match(Ht);
1400
+ let e = n.indexOf("/") === -1 ? n : n.substring(n.lastIndexOf("/") + 1), r = e.match(Qt);
1346
1401
  r && t.push({
1347
1402
  timestamp: r.groups.timestamp,
1348
- path: Bt + e
1403
+ path: Xt + e
1349
1404
  });
1350
1405
  }
1351
1406
  return t.sort((e, t) => t.timestamp.localeCompare(e.timestamp)), t;
1352
1407
  }
1353
1408
  async restoreGlobalOverviewFromSnapshot(e) {
1354
- let t = Ut(e), n = await this.storage.getFile(t);
1409
+ let t = $t(e), n = await this.storage.getFile(t);
1355
1410
  if (!n) throw Error(`Snapshot ${e} not found at ${t}`);
1356
1411
  let r = (await this.gunzipAsync(n)).toString("utf8");
1357
1412
  try {
@@ -1362,14 +1417,14 @@ var sn = class {
1362
1417
  let i = Buffer.from(r);
1363
1418
  await this.storage.putFile(J, i);
1364
1419
  let a = await this.gzipAsync(r);
1365
- await this.storage.putFile(nn, Buffer.from(a)), this.logger.info(`Global overview restored from snapshot ${e}`);
1420
+ await this.storage.putFile(pn, Buffer.from(a)), this.logger.info(`Global overview restored from snapshot ${e}`);
1366
1421
  }
1367
1422
  async publishPackage(e, t) {
1368
1423
  let n = K(e.description.id);
1369
1424
  for (let r of e.files) {
1370
1425
  let e = await t(r.name);
1371
1426
  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})`);
1372
- let i = await k(e);
1427
+ let i = await O(e);
1373
1428
  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()})`);
1374
1429
  let a = n + "/" + r.name;
1375
1430
  this.logger.info(`Uploading ${r.name} -> ${a} ...`), await this.storage.putFile(a, e);
@@ -1377,11 +1432,11 @@ var sn = class {
1377
1432
  let r = n + "/" + H;
1378
1433
  this.logger.info(`Uploading manifest to ${r} ...`), await this.storage.putFile(r, Buffer.from(JSON.stringify(e))), await this.marchChanged(e.description.id);
1379
1434
  }
1380
- }, cn = {
1435
+ }, vn = {
1381
1436
  cacheBlockListFor: 45e3,
1382
1437
  keepStaleBlockListFor: 3e5
1383
1438
  };
1384
- function ln(e, t) {
1439
+ function yn(e, t) {
1385
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));
1386
1441
  return a && i.push({
1387
1442
  type: "patch",
@@ -1394,24 +1449,24 @@ function ln(e, t) {
1394
1449
  update: s
1395
1450
  }), i;
1396
1451
  }
1397
- var un = class {
1452
+ var bn = class {
1398
1453
  v2RootFolderReader;
1399
1454
  ops;
1400
1455
  constructor(e, t) {
1401
1456
  this.registryReader = e, this.v2RootFolderReader = e.relativeReader("v2/"), this.ops = {
1402
- ...cn,
1457
+ ...vn,
1403
1458
  ...t
1404
1459
  };
1405
1460
  }
1406
- embeddedGlobalMetaCache = new ce({
1461
+ embeddedGlobalMetaCache = new de({
1407
1462
  max: 500,
1408
- fetchMethod: async (e, t, n) => await S(async () => {
1463
+ fetchMethod: async (e, t, n) => await x(async () => {
1409
1464
  let e = n.context.relativeTo === void 0 ? this.v2RootFolderReader.getContentReader() : this.v2RootFolderReader.relativeReader(G(n.context.relativeTo)).getContentReader();
1410
- return await Be(n.context.meta, e);
1411
- }, x)
1465
+ return await We(n.context.meta, e);
1466
+ }, b)
1412
1467
  });
1413
1468
  async embedMetaContent(e, t, n, r) {
1414
- return await this.embeddedGlobalMetaCache.forceFetch(se({
1469
+ return await this.embeddedGlobalMetaCache.forceFetch(ue({
1415
1470
  id: e,
1416
1471
  sha256: t,
1417
1472
  absolutePath: n
@@ -1425,8 +1480,8 @@ var un = class {
1425
1480
  async listBlockPacks(e) {
1426
1481
  if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.cacheBlockListFor) return this.listCache;
1427
1482
  try {
1428
- return await S(async () => {
1429
- let t = Y(JSON.parse(Buffer.from(await this.v2RootFolderReader.readFile(Kt, { signal: e?.signal })).toString())), n = await Promise.all(t.packages.map(async (e) => {
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) => {
1430
1485
  let t = await Promise.all(Object.entries(e.latestByChannel).map(async ([e, t]) => [e, {
1431
1486
  id: t.description.id,
1432
1487
  meta: await this.embedMetaContent(t.description.id, t.manifestSha256, !0, t.description.meta),
@@ -1445,28 +1500,28 @@ var un = class {
1445
1500
  };
1446
1501
  }));
1447
1502
  return this.listCache = n, this.listCacheTimestamp = Date.now(), n;
1448
- }, x);
1503
+ }, b);
1449
1504
  } catch (e) {
1450
1505
  if (this.listCache !== void 0 && Date.now() - this.listCacheTimestamp <= this.ops.keepStaleBlockListFor) return this.listCache;
1451
1506
  throw e;
1452
1507
  }
1453
1508
  }
1454
1509
  async getLatestOverview(e, t) {
1455
- let n = (await this.listBlockPacks()).find((t) => g(e, t.id));
1510
+ let n = (await this.listBlockPacks()).find((t) => _(e, t.id));
1456
1511
  if (n !== void 0) return n.latestByChannel[t];
1457
1512
  }
1458
1513
  async getUpdateSuggestions(e, t) {
1459
- let n = (await this.listBlockPacks()).find((t) => g(e, t.id));
1514
+ let n = (await this.listBlockPacks()).find((t) => _(e, t.id));
1460
1515
  if (n === void 0) return;
1461
- let r = n.allVersions.filter((e) => t === o || e.channels.indexOf(t) >= 0).map((e) => e.version);
1462
- return r.reverse(), ln(e.version, r);
1516
+ 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);
1463
1518
  }
1464
1519
  async getSpecificOverview(e, t) {
1465
- return await S(async () => {
1466
- let n = await this.v2RootFolderReader.readFile(G(e) + Yt), r = u.parse(JSON.parse(Buffer.from(n).toString()));
1520
+ return await x(async () => {
1521
+ let n = await this.v2RootFolderReader.readFile(G(e) + on), r = d.parse(JSON.parse(Buffer.from(n).toString()));
1467
1522
  return {
1468
1523
  id: e,
1469
- meta: await this.embedMetaContent(e, await k(n), !1, r.description.meta),
1524
+ meta: await this.embedMetaContent(e, await O(n), !1, r.description.meta),
1470
1525
  spec: {
1471
1526
  type: "from-registry-v2",
1472
1527
  id: e,
@@ -1474,19 +1529,19 @@ var un = class {
1474
1529
  channel: t
1475
1530
  }
1476
1531
  };
1477
- }, x);
1532
+ }, b);
1478
1533
  }
1479
- componentsCache = new ce({
1534
+ componentsCache = new de({
1480
1535
  max: 500,
1481
- fetchMethod: async (e, t, { context: n }) => await S(async () => {
1536
+ fetchMethod: async (e, t, { context: n }) => await x(async () => {
1482
1537
  let e = this.v2RootFolderReader.relativeReader(G(n));
1483
- return Ue(u.parse(JSON.parse(Buffer.from(await e.readFile(H)).toString())).description.components, e.rootUrl.toString());
1484
- }, x)
1538
+ return Je(d.parse(JSON.parse(Buffer.from(await e.readFile(H)).toString())).description.components, e.rootUrl.toString());
1539
+ }, b)
1485
1540
  });
1486
1541
  async getComponents(e) {
1487
- return await this.componentsCache.forceFetch(se(e), { context: e });
1542
+ return await this.componentsCache.forceFetch(ue(e), { context: e });
1488
1543
  }
1489
- }, dn = class {
1544
+ }, xn = class {
1490
1545
  constructor(e, t, n) {
1491
1546
  this.client = e, this.bucket = t, this.root = n;
1492
1547
  }
@@ -1494,7 +1549,7 @@ var un = class {
1494
1549
  try {
1495
1550
  return Buffer.from(await (await this.client.getObject({
1496
1551
  Bucket: this.bucket,
1497
- Key: w.join(this.root, e)
1552
+ Key: C.join(this.root, e)
1498
1553
  })).Body.transformToByteArray());
1499
1554
  } catch (e) {
1500
1555
  if (e instanceof Error && e.name === "NoSuchKey") return;
@@ -1502,35 +1557,35 @@ var un = class {
1502
1557
  }
1503
1558
  }
1504
1559
  async listFiles(e) {
1505
- let t = w.join(this.root, e), n = ue({ client: this.client }, {
1560
+ let t = C.join(this.root, e), n = pe({ client: this.client }, {
1506
1561
  Bucket: this.bucket,
1507
1562
  Prefix: t
1508
1563
  }), r = [];
1509
- for await (let e of n) r.push(...(e.Contents ?? []).map((e) => w.relative(t, e.Key)));
1564
+ for await (let e of n) r.push(...(e.Contents ?? []).map((e) => C.relative(t, e.Key)));
1510
1565
  return r;
1511
1566
  }
1512
1567
  async putFile(e, t) {
1513
1568
  await this.client.putObject({
1514
1569
  Bucket: this.bucket,
1515
- Key: w.join(this.root, e),
1570
+ Key: C.join(this.root, e),
1516
1571
  Body: t
1517
1572
  });
1518
1573
  }
1519
1574
  async deleteFiles(...e) {
1520
1575
  let t = await this.client.deleteObjects({
1521
1576
  Bucket: this.bucket,
1522
- Delete: { Objects: e.map((e) => ({ Key: w.join(this.root, e) })) }
1577
+ Delete: { Objects: e.map((e) => ({ Key: C.join(this.root, e) })) }
1523
1578
  });
1524
1579
  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")}`);
1525
1580
  }
1526
- }, fn = class {
1581
+ }, Sn = class {
1527
1582
  root;
1528
1583
  constructor(t) {
1529
1584
  this.root = e.resolve(t);
1530
1585
  }
1531
1586
  toAbsolutePath(t) {
1532
- if (w.isAbsolute(t)) throw Error("absolute path");
1533
- return e.resolve(this.root, t.split(w.sep).join(e.sep));
1587
+ if (C.isAbsolute(t)) throw Error("absolute path");
1588
+ return e.resolve(this.root, t.split(C.sep).join(e.sep));
1534
1589
  }
1535
1590
  async getFile(e) {
1536
1591
  try {
@@ -1546,7 +1601,7 @@ var un = class {
1546
1601
  return (await t.promises.readdir(r, {
1547
1602
  recursive: !0,
1548
1603
  withFileTypes: !0
1549
- })).filter((e) => e.isFile()).map((t) => e.relative(r, e.resolve(t.parentPath, t.name)).split(e.sep).join(w.sep));
1604
+ })).filter((e) => e.isFile()).map((t) => e.relative(r, e.resolve(t.parentPath, t.name)).split(e.sep).join(C.sep));
1550
1605
  } catch (e) {
1551
1606
  if (e instanceof Error && "code" in e && e.code === "ENOENT") return [];
1552
1607
  throw e;
@@ -1560,27 +1615,27 @@ var un = class {
1560
1615
  for (let n of e) await t.promises.rm(this.toAbsolutePath(n));
1561
1616
  }
1562
1617
  };
1563
- function pn(t) {
1564
- let n = new URL(t, `file:${e.resolve(".").split(e.sep).join(w.sep)}/`);
1618
+ function Cn(t) {
1619
+ let n = new URL(t, `file:${e.resolve(".").split(e.sep).join(C.sep)}/`);
1565
1620
  switch (n.protocol) {
1566
- case "file:": return new fn(e.resolve(n.pathname));
1621
+ case "file:": return new Sn(e.resolve(n.pathname));
1567
1622
  case "s3:": {
1568
1623
  let e = {}, t = n.searchParams.get("region");
1569
1624
  t && (e.region = t);
1570
1625
  let r = n.hostname;
1571
- return new dn(new le(e), r, n.pathname.replace(/^\//, ""));
1626
+ return new xn(new fe(e), r, n.pathname.replace(/^\//, ""));
1572
1627
  }
1573
1628
  default: throw Error(`Unknown protocol: ${n.protocol}`);
1574
1629
  }
1575
1630
  }
1576
1631
  //#endregion
1577
1632
  //#region src/io/folder_reader.ts
1578
- var mn = class e {
1633
+ var wn = class e {
1579
1634
  constructor(e, t) {
1580
1635
  this.rootUrl = e, this.httpDispatcher = t;
1581
1636
  }
1582
1637
  async readFile(e, t) {
1583
- let n = await de(new URL(e, this.rootUrl), {
1638
+ let n = await me(new URL(e, this.rootUrl), {
1584
1639
  dispatcher: this.httpDispatcher,
1585
1640
  signal: t?.signal
1586
1641
  });
@@ -1593,82 +1648,82 @@ var mn = class e {
1593
1648
  let t = e === void 0 ? this : this.relativeReader(e);
1594
1649
  return (e) => t.readFile(e);
1595
1650
  }
1596
- }, hn = class t {
1651
+ }, Tn = class t {
1597
1652
  constructor(e, t) {
1598
1653
  this.rootUrl = e, this.root = t;
1599
1654
  }
1600
- async readFile(t, r) {
1601
- let i = e.join(this.root, ...t.split(w.sep));
1602
- return await n.readFile(i, { signal: r?.signal });
1655
+ async readFile(t, n) {
1656
+ let i = e.join(this.root, ...t.split(C.sep));
1657
+ return await r.readFile(i, { signal: n?.signal });
1603
1658
  }
1604
1659
  relativeReader(n) {
1605
- return n.endsWith("/") || (n += "/"), new t(new URL(n, this.rootUrl), e.join(this.root, ...n.split(w.sep)));
1660
+ return n.endsWith("/") || (n += "/"), new t(new URL(n, this.rootUrl), e.join(this.root, ...n.split(C.sep)));
1606
1661
  }
1607
1662
  getContentReader(e) {
1608
1663
  let t = e === void 0 ? this : this.relativeReader(e);
1609
1664
  return (e) => t.readFile(e);
1610
1665
  }
1611
1666
  };
1612
- function gn(t) {
1613
- return t.split(w.sep).join(e.sep);
1667
+ function En(t) {
1668
+ return t.split(C.sep).join(e.sep);
1614
1669
  }
1615
- function _n(t) {
1616
- return t.split(e.sep).join(w.sep);
1670
+ function Dn(t) {
1671
+ return t.split(e.sep).join(C.sep);
1617
1672
  }
1618
- function vn(t, n) {
1673
+ function On(t, n) {
1619
1674
  t.endsWith("/") || (t += "/");
1620
- let r = new URL(t, `file:${_n(e.resolve("."))}/`);
1675
+ let r = new URL(t, `file:${Dn(e.resolve("."))}/`);
1621
1676
  switch (r.protocol) {
1622
- case "file:": return new hn(r, gn(r.pathname));
1677
+ case "file:": return new Tn(r, En(r.pathname));
1623
1678
  case "https:":
1624
- case "http:": return new mn(r, n ?? fe());
1679
+ case "http:": return new wn(r, n ?? he());
1625
1680
  default: throw Error(`Unknown protocol: ${r.protocol}`);
1626
1681
  }
1627
1682
  }
1628
1683
  //#endregion
1629
1684
  //#region src/common_types.ts
1630
- var yn = C.string().regex(/^(?:s3:|file:)/), bn = C.object({
1631
- organization: C.string(),
1632
- package: C.string(),
1633
- version: f.optional(),
1634
- files: C.record(C.string().regex(/^[^/]+$/), C.string()).default({}),
1635
- meta: C.object({}).passthrough()
1636
- }), xn = C.object({
1637
- registries: C.record(C.string(), yn).default({}),
1638
- registry: C.string().optional()
1639
- }), Sn = xn.merge(bn).required({
1685
+ var kn = S.string().regex(/^(?:s3:|file:)/), An = S.object({
1686
+ organization: S.string(),
1687
+ package: S.string(),
1688
+ version: p.optional(),
1689
+ files: S.record(S.string().regex(/^[^/]+$/), S.string()).default({}),
1690
+ meta: S.object({}).passthrough()
1691
+ }), jn = S.object({
1692
+ registries: S.record(S.string(), kn).default({}),
1693
+ registry: S.string().optional()
1694
+ }), Mn = jn.merge(An).required({
1640
1695
  registry: !0,
1641
1696
  version: !0
1642
- }), X = Sn.partial().required({
1697
+ }), X = Mn.partial().required({
1643
1698
  registries: !0,
1644
1699
  files: !0
1645
- }), Cn = "pl.package.json", wn = "pl.package.yaml", Z = "v1/";
1646
- function Tn(e) {
1700
+ }), Nn = "pl.package.json", Pn = "pl.package.yaml", Z = "v1/";
1701
+ function Fn(e) {
1647
1702
  return `${Z}${e.organization}/${e.package}/${e.version}`;
1648
1703
  }
1649
- function En(e, t) {
1704
+ function In(e, t) {
1650
1705
  return `${Z}${e.organization}/${e.package}/${e.version}/${t}`;
1651
1706
  }
1652
- function Dn(e) {
1707
+ function Ln(e) {
1653
1708
  return `${Z}${e.organization}/${e.package}/overview.json`;
1654
1709
  }
1655
- var Q = `${Z}overview.json`, On = "meta.json", kn = "_updates_v1/per_package_version/";
1656
- function An(e, t) {
1657
- return `${kn}${e.organization}/${e.package}/${e.version}/${t}`;
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}`;
1658
1713
  }
1659
- var jn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, Mn = "_updates_v1/_global_update_in", Nn = "_updates_v1/_global_update_out", Pn = class {
1714
+ var Vn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?<version>[^/]+)\/(?<seed>[^/]+)$/, Hn = "_updates_v1/_global_update_in", Un = "_updates_v1/_global_update_out", Wn = class {
1660
1715
  constructor(e, t) {
1661
1716
  this.storage = e, this.logger = t;
1662
1717
  }
1663
1718
  constructNewPackage(e) {
1664
- return new Fn(this.storage, e);
1719
+ return new Gn(this.storage, e);
1665
1720
  }
1666
1721
  async updateRegistry() {
1667
1722
  this.logger?.info("Initiating registry refresh...");
1668
- let e = /* @__PURE__ */ new Map(), t = [], n = await this.storage.listFiles(kn);
1723
+ let e = /* @__PURE__ */ new Map(), t = [], n = await this.storage.listFiles(zn);
1669
1724
  this.logger?.info("Packages to be updated:");
1670
1725
  for (let r of n) {
1671
- let n = r.match(jn);
1726
+ let n = r.match(Vn);
1672
1727
  if (!n) continue;
1673
1728
  t.push(r);
1674
1729
  let { packageKeyWithoutVersion: i, organization: a, pkg: o, version: s, seed: c } = n.groups, l = e.get(i);
@@ -1683,13 +1738,13 @@ var jn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?
1683
1738
  let r = await this.storage.getFile(Q), i = r === void 0 ? [] : JSON.parse(r.toString());
1684
1739
  this.logger?.info(`Global overview loaded, ${i.length} records`);
1685
1740
  for (let [, t] of e.entries()) {
1686
- let e = Dn(t.package), n = await this.storage.getFile(e), r = n === void 0 ? [] : JSON.parse(n.toString());
1741
+ let e = Ln(t.package), n = await this.storage.getFile(e), r = n === void 0 ? [] : JSON.parse(n.toString());
1687
1742
  this.logger?.info(`Updating ${t.package.organization}:${t.package.package} overview, ${r.length} records`), r = r.filter((e) => !t.versions.has(e.version));
1688
1743
  for (let [e] of t.versions.entries()) {
1689
- let n = e.toString(), i = await this.storage.getFile(En({
1744
+ let n = e.toString(), i = await this.storage.getFile(In({
1690
1745
  ...t.package,
1691
1746
  version: n
1692
- }, On));
1747
+ }, Rn));
1693
1748
  i && r.push({
1694
1749
  version: n,
1695
1750
  meta: JSON.parse(i.toString())
@@ -1703,36 +1758,36 @@ var jn = /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<pkg>[^/]+))\/(?
1703
1758
  latestMeta: r[0].meta
1704
1759
  });
1705
1760
  }
1706
- 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) => `${kn}${e}`)), this.logger?.info("Version update requests cleared");
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");
1707
1762
  }
1708
1763
  async updateIfNeeded(e = !1) {
1709
1764
  this.logger?.info("Checking if registry requires refresh...");
1710
- let t = await this.storage.getFile(Mn), n = await this.storage.getFile(Nn);
1711
- !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(Nn, t), this.logger?.info("Refresh finished")));
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")));
1712
1767
  }
1713
1768
  async getPackageOverview(e) {
1714
- let t = await this.storage.getFile(Dn(e));
1769
+ let t = await this.storage.getFile(Ln(e));
1715
1770
  if (t !== void 0) return JSON.parse(t.toString());
1716
1771
  }
1717
1772
  async getGlobalOverview() {
1718
1773
  let e = await this.storage.getFile(Q);
1719
1774
  if (e !== void 0) return JSON.parse(e.toString());
1720
1775
  }
1721
- }, Fn = class {
1776
+ }, Gn = class {
1722
1777
  metaAdded = !1;
1723
- seed = re();
1778
+ seed = ae();
1724
1779
  constructor(e, t) {
1725
1780
  this.storage = e, this.name = t;
1726
1781
  }
1727
1782
  async addFile(e, t) {
1728
- await this.storage.putFile(En(this.name, e), t);
1783
+ await this.storage.putFile(In(this.name, e), t);
1729
1784
  }
1730
1785
  async writeMeta(e) {
1731
- await this.addFile(On, Buffer.from(JSON.stringify(e))), this.metaAdded = !0;
1786
+ await this.addFile(Rn, Buffer.from(JSON.stringify(e))), this.metaAdded = !0;
1732
1787
  }
1733
1788
  async finish() {
1734
1789
  if (!this.metaAdded) throw Error("meta not added");
1735
- await this.storage.putFile(An(this.name, this.seed), Buffer.of(0)), await this.storage.putFile(Mn, Buffer.from(this.seed));
1790
+ await this.storage.putFile(Bn(this.name, this.seed), Buffer.of(0)), await this.storage.putFile(Hn, Buffer.from(this.seed));
1736
1791
  }
1737
1792
  };
1738
1793
  //#endregion
@@ -1751,17 +1806,17 @@ function $(e, t) {
1751
1806
  }
1752
1807
  };
1753
1808
  }
1754
- async function In(e) {
1755
- return qe(e, (e) => X.parse(JSON.parse(e.toString())));
1809
+ async function Kn(e) {
1810
+ return Qe(e, (e) => X.parse(JSON.parse(e.toString())));
1756
1811
  }
1757
- async function Ln(e) {
1758
- return qe(e, (e) => X.parse(pe.parse(e.toString())));
1812
+ async function qn(e) {
1813
+ return Qe(e, (e) => X.parse(ge.parse(e.toString())));
1759
1814
  }
1760
- async function Rn() {
1815
+ async function Jn() {
1761
1816
  let e = X.parse({});
1762
- return e = $(e, await In("./.pl.reg.json")), e = $(e, await Ln("./.pl.reg.yaml")), e = $(e, await In(`${me.homedir()}/.pl.reg.json`)), e = $(e, await Ln(`${me.homedir()}/.pl.reg.yaml`)), e = $(e, await In(Cn)), e = $(e, await Ln(wn)), e;
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;
1763
1818
  }
1764
- var zn = class {
1819
+ var Yn = class {
1765
1820
  constructor(e) {
1766
1821
  this.conf = e;
1767
1822
  }
@@ -1772,7 +1827,7 @@ var zn = class {
1772
1827
  if (!e) throw Error(`Registry with alias "${t}" not found`);
1773
1828
  t = e;
1774
1829
  }
1775
- return new Pn(pn(t), e);
1830
+ return new Wn(Cn(t), e);
1776
1831
  }
1777
1832
  get fullPackageName() {
1778
1833
  return {
@@ -1782,11 +1837,11 @@ var zn = class {
1782
1837
  };
1783
1838
  }
1784
1839
  };
1785
- async function Bn(e) {
1786
- let t = await Rn();
1787
- return new zn(Sn.parse($(t, e)));
1840
+ async function Xn(e) {
1841
+ let t = await Jn();
1842
+ return new Yn(Mn.parse($(t, e)));
1788
1843
  }
1789
1844
  //#endregion
1790
- export { Le as $, tn as A, Y as B, Kt as C, Gt as D, J as E, $t as F, Qe as G, et as H, K as I, Ge as J, Ye as K, G as L, Jt as M, Xt as N, H as O, en as P, Ve as Q, Qt as R, U as S, nn as T, $e as U, A as V, Ze as W, Ue as X, We as Y, He as Z, pn as _, Ce as _t, Tn as a, ke as at, sn as b, bn as c, Ee as ct, xn as d, Pe as dt, Re as et, Sn as f, Fe as ft, dn as g, be as gt, fn as h, Te as ht, On as i, Oe as it, q as j, Yt as k, Cn as l, je as lt, vn as m, we as mt, Bn as n, Be as nt, Dn as o, De as ot, X as p, Me as pt, O as q, Q as r, Ie as rt, En as s, Ae as st, zn as t, ze as tt, wn as u, Ne as ut, un as v, qt as w, W as x, ln as y, Zt as z };
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 };
1791
1846
 
1792
- //# sourceMappingURL=config-DpfTzcgG.mjs.map
1847
+ //# sourceMappingURL=config-CiC347sB.mjs.map