@platforma-sdk/block-tools 2.6.27 → 2.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +15 -13
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-XBQ2O39y.mjs → config-DKBY0B2u.mjs} +272 -273
- package/dist/config-DKBY0B2u.mjs.map +1 -0
- package/dist/config-Ycas5fbX.js +3 -0
- package/dist/config-Ycas5fbX.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -17
- package/dist/index.mjs.map +1 -1
- package/dist/registry_v1/v1_repo_schema.d.ts +2 -2
- package/package.json +16 -13
- package/src/cmd/build-meta.ts +9 -9
- package/src/cmd/build-model.ts +20 -16
- package/src/cmd/index.ts +0 -1
- package/src/cmd/list-overview-snapshots.ts +5 -5
- package/src/cmd/mark-stable.ts +14 -15
- package/src/cmd/pack.ts +7 -7
- package/src/cmd/publish.ts +16 -16
- package/src/cmd/refresh-registry.ts +4 -10
- package/src/cmd/restore-overview-from-snapshot.ts +16 -16
- package/src/cmd/update-deps.ts +3 -2
- package/src/cmd/upload-package-v1.ts +12 -12
- package/src/io/folder_reader.ts +15 -11
- package/src/io/storage.ts +25 -23
- package/src/registry_v1/config.ts +11 -10
- package/src/registry_v1/config_schema.ts +5 -5
- package/src/registry_v1/flags.ts +3 -2
- package/src/registry_v1/registry.ts +34 -35
- package/src/registry_v1/v1_repo_schema.ts +2 -2
- package/src/util.ts +15 -11
- package/src/v2/build_dist.ts +12 -9
- package/src/v2/model/block_components.ts +6 -6
- package/src/v2/model/block_description.ts +13 -13
- package/src/v2/model/block_meta.ts +10 -9
- package/src/v2/model/content_conversion.ts +28 -26
- package/src/v2/registry/index.ts +3 -3
- package/src/v2/registry/registry.test.ts +1 -1
- package/src/v2/registry/registry.ts +64 -63
- package/src/v2/registry/registry_reader.ts +47 -46
- package/src/v2/registry/schema_internal.ts +3 -3
- package/src/v2/registry/schema_public.ts +29 -26
- package/src/v2/source_package.ts +26 -23
- package/dist/config-DjpRXRy9.js +0 -3
- package/dist/config-DjpRXRy9.js.map +0 -1
- package/dist/config-XBQ2O39y.mjs.map +0 -1
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BlockPackId } from '@milaboratories/pl-model-middle-layer';
|
|
1
3
|
import {
|
|
2
4
|
AnyChannel,
|
|
3
5
|
BlockComponentsManifest,
|
|
4
6
|
BlockPackDescriptionManifest,
|
|
5
|
-
BlockPackId,
|
|
6
7
|
BlockPackIdNoVersion,
|
|
7
8
|
BlockPackMeta,
|
|
8
9
|
ContentRelativeBinary,
|
|
9
10
|
ContentRelativeText,
|
|
10
11
|
CreateBlockPackDescriptionSchema,
|
|
11
|
-
SemVer,
|
|
12
12
|
Sha256Schema,
|
|
13
|
-
VersionWithChannels
|
|
13
|
+
VersionWithChannels,
|
|
14
14
|
} from '@milaboratories/pl-model-middle-layer';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
-
import { RelativeContentReader
|
|
16
|
+
import type { RelativeContentReader } from '../model';
|
|
17
|
+
import { relativeToExplicitBytes, relativeToExplicitString } from '../model';
|
|
17
18
|
|
|
18
19
|
export const MainPrefix = 'v2/';
|
|
19
20
|
|
|
@@ -43,13 +44,13 @@ export const ManifestSuffix = '/' + ManifestFileName;
|
|
|
43
44
|
export const PackageOverviewVersionEntry = z.object({
|
|
44
45
|
description: BlockPackDescriptionManifest,
|
|
45
46
|
channels: z.array(z.string()).default(() => []),
|
|
46
|
-
manifestSha256: Sha256Schema
|
|
47
|
+
manifestSha256: Sha256Schema,
|
|
47
48
|
}).passthrough();
|
|
48
49
|
export type PackageOverviewVersionEntry = z.infer<typeof PackageOverviewVersionEntry>;
|
|
49
50
|
|
|
50
51
|
export const PackageOverview = z.object({
|
|
51
52
|
schema: z.literal('v2'),
|
|
52
|
-
versions: z.array(PackageOverviewVersionEntry)
|
|
53
|
+
versions: z.array(PackageOverviewVersionEntry),
|
|
53
54
|
}).passthrough();
|
|
54
55
|
export type PackageOverview = z.infer<typeof PackageOverview>;
|
|
55
56
|
|
|
@@ -69,14 +70,14 @@ export function packageChannelPrefix(bp: BlockPackId): string {
|
|
|
69
70
|
return `${MainPrefix}${packageChannelPrefixInsideV2(bp)}`;
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
export const PackageManifestPattern
|
|
73
|
-
/(?<packageKeyWithoutVersion>(?<organization>[
|
|
73
|
+
export const PackageManifestPattern
|
|
74
|
+
= /(?<packageKeyWithoutVersion>(?<organization>[^/]+)\/(?<name>[^/]+))\/(?<version>[^/]+)\/manifest\.json$/;
|
|
74
75
|
|
|
75
76
|
export const GlobalOverviewPath = `${MainPrefix}${GlobalOverviewFileName}`;
|
|
76
77
|
export const GlobalOverviewGzPath = `${MainPrefix}${GlobalOverviewGzFileName}`;
|
|
77
78
|
|
|
78
79
|
export function GlobalOverviewEntry<const Description extends z.ZodTypeAny>(
|
|
79
|
-
descriptionType: Description
|
|
80
|
+
descriptionType: Description,
|
|
80
81
|
) {
|
|
81
82
|
const universalSchema = z.object({
|
|
82
83
|
id: BlockPackIdNoVersion,
|
|
@@ -92,10 +93,10 @@ export function GlobalOverviewEntry<const Description extends z.ZodTypeAny>(
|
|
|
92
93
|
z.string(),
|
|
93
94
|
z.object({
|
|
94
95
|
description: descriptionType,
|
|
95
|
-
manifestSha256: Sha256Schema
|
|
96
|
-
}).passthrough()
|
|
96
|
+
manifestSha256: Sha256Schema,
|
|
97
|
+
}).passthrough(),
|
|
97
98
|
)
|
|
98
|
-
.default({})
|
|
99
|
+
.default({}),
|
|
99
100
|
}).passthrough();
|
|
100
101
|
return (
|
|
101
102
|
universalSchema
|
|
@@ -104,9 +105,10 @@ export function GlobalOverviewEntry<const Description extends z.ZodTypeAny>(
|
|
|
104
105
|
else
|
|
105
106
|
return {
|
|
106
107
|
...o,
|
|
107
|
-
allVersionsWithChannels: o.allVersions!.map((v) => ({ version: v, channels: [] }))
|
|
108
|
+
allVersionsWithChannels: o.allVersions!.map((v) => ({ version: v, channels: [] })),
|
|
108
109
|
};
|
|
109
110
|
})
|
|
111
|
+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
|
|
110
112
|
// make sure "any" channel set from main body
|
|
111
113
|
.transform((o: any) =>
|
|
112
114
|
o.latestByChannel[AnyChannel]
|
|
@@ -115,10 +117,11 @@ export function GlobalOverviewEntry<const Description extends z.ZodTypeAny>(
|
|
|
115
117
|
...o,
|
|
116
118
|
latestByChannel: {
|
|
117
119
|
...o.latestByChannel,
|
|
118
|
-
[AnyChannel]: { description: o.latest!, manifestSha256: o.latestManifestSha256! }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
120
|
+
[AnyChannel]: { description: o.latest!, manifestSha256: o.latestManifestSha256! },
|
|
121
|
+
},
|
|
122
|
+
},
|
|
121
123
|
)
|
|
124
|
+
/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
|
|
122
125
|
.pipe(universalSchema.required({ allVersionsWithChannels: true }))
|
|
123
126
|
);
|
|
124
127
|
}
|
|
@@ -126,11 +129,11 @@ export const GlobalOverviewEntryReg = GlobalOverviewEntry(BlockPackDescriptionMa
|
|
|
126
129
|
export type GlobalOverviewEntryReg = z.infer<typeof GlobalOverviewEntryReg>;
|
|
127
130
|
|
|
128
131
|
export function GlobalOverview<const Description extends z.ZodTypeAny>(
|
|
129
|
-
descriptionType: Description
|
|
132
|
+
descriptionType: Description,
|
|
130
133
|
) {
|
|
131
134
|
return z.object({
|
|
132
135
|
schema: z.literal('v2'),
|
|
133
|
-
packages: z.array(GlobalOverviewEntry(descriptionType))
|
|
136
|
+
packages: z.array(GlobalOverviewEntry(descriptionType)),
|
|
134
137
|
}).passthrough();
|
|
135
138
|
}
|
|
136
139
|
|
|
@@ -142,8 +145,8 @@ export function BlockDescriptionToExplicitBinaryBytes(reader: RelativeContentRea
|
|
|
142
145
|
BlockComponentsManifest,
|
|
143
146
|
BlockPackMeta(
|
|
144
147
|
ContentRelativeText.transform(relativeToExplicitString(reader)),
|
|
145
|
-
ContentRelativeBinary.transform(relativeToExplicitBytes(reader))
|
|
146
|
-
)
|
|
148
|
+
ContentRelativeBinary.transform(relativeToExplicitBytes(reader)),
|
|
149
|
+
),
|
|
147
150
|
);
|
|
148
151
|
}
|
|
149
152
|
export function GlobalOverviewToExplicitBinaryBytes(reader: RelativeContentReader) {
|
|
@@ -152,9 +155,9 @@ export function GlobalOverviewToExplicitBinaryBytes(reader: RelativeContentReade
|
|
|
152
155
|
BlockComponentsManifest,
|
|
153
156
|
BlockPackMeta(
|
|
154
157
|
ContentRelativeText.transform(relativeToExplicitString(reader)),
|
|
155
|
-
ContentRelativeBinary.transform(relativeToExplicitBytes(reader))
|
|
156
|
-
)
|
|
157
|
-
)
|
|
158
|
+
ContentRelativeBinary.transform(relativeToExplicitBytes(reader)),
|
|
159
|
+
),
|
|
160
|
+
),
|
|
158
161
|
);
|
|
159
162
|
}
|
|
160
163
|
export type GlobalOverviewExplicitBinaryBytes = z.infer<
|
|
@@ -167,9 +170,9 @@ export function GlobalOverviewToExplicitBinaryBase64(reader: RelativeContentRead
|
|
|
167
170
|
BlockComponentsManifest,
|
|
168
171
|
BlockPackMeta(
|
|
169
172
|
ContentRelativeText.transform(relativeToExplicitString(reader)),
|
|
170
|
-
ContentRelativeBinary.transform(relativeToExplicitBytes(reader))
|
|
171
|
-
)
|
|
172
|
-
)
|
|
173
|
+
ContentRelativeBinary.transform(relativeToExplicitBytes(reader)),
|
|
174
|
+
),
|
|
175
|
+
),
|
|
173
176
|
);
|
|
174
177
|
}
|
|
175
178
|
export type GlobalOverviewExplicitBinaryBase64 = z.infer<
|
package/src/v2/source_package.ts
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import path from 'path';
|
|
1
|
+
import path from 'node:path';
|
|
2
2
|
import { tryLoadFile } from '../util';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import type { BlockPackDescriptionAbsolute } from './model';
|
|
4
|
+
import { ResolvedBlockPackDescriptionFromPackageJson } from './model';
|
|
5
|
+
import type { MiLogger } from '@milaboratories/ts-helpers';
|
|
6
|
+
import { notEmpty } from '@milaboratories/ts-helpers';
|
|
5
7
|
import fsp from 'node:fs/promises';
|
|
8
|
+
import type {
|
|
9
|
+
BlockPackDescriptionRaw,
|
|
10
|
+
BlockPackId } from '@milaboratories/pl-model-middle-layer';
|
|
6
11
|
import {
|
|
7
12
|
BlockPackDescriptionFromPackageJsonRaw,
|
|
8
|
-
|
|
9
|
-
BlockPackId,
|
|
10
|
-
SemVer
|
|
13
|
+
SemVer,
|
|
11
14
|
} from '@milaboratories/pl-model-middle-layer';
|
|
12
15
|
|
|
13
16
|
export const BlockDescriptionPackageJsonField = 'block';
|
|
14
17
|
|
|
15
|
-
const ConventionPackageNamePattern
|
|
16
|
-
/(?:@[a-zA-Z0-9-.]+\/)?(?<organization>[a-zA-Z0-9-]+)\.(?<name>[a-zA-Z0-9-]+)/;
|
|
18
|
+
const ConventionPackageNamePattern
|
|
19
|
+
= /(?:@[a-zA-Z0-9-.]+\/)?(?<organization>[a-zA-Z0-9-]+)\.(?<name>[a-zA-Z0-9-]+)/;
|
|
17
20
|
|
|
18
21
|
export function parsePackageName(packageName: string): Pick<BlockPackId, 'organization' | 'name'> {
|
|
19
22
|
const match = packageName.match(ConventionPackageNamePattern);
|
|
20
23
|
if (!match)
|
|
21
24
|
throw new Error(
|
|
22
|
-
`Malformed package name (${packageName}), can't infer organization and block pack name
|
|
25
|
+
`Malformed package name (${packageName}), can't infer organization and block pack name.`,
|
|
23
26
|
);
|
|
24
27
|
const { name, organization } = match.groups!;
|
|
25
28
|
return { name, organization };
|
|
@@ -27,12 +30,12 @@ export function parsePackageName(packageName: string): Pick<BlockPackId, 'organi
|
|
|
27
30
|
|
|
28
31
|
export async function tryLoadPackDescription(
|
|
29
32
|
moduleRoot: string,
|
|
30
|
-
logger?: MiLogger
|
|
33
|
+
logger?: MiLogger,
|
|
31
34
|
): Promise<BlockPackDescriptionAbsolute | undefined> {
|
|
32
35
|
const fullPackageJsonPath = path.resolve(moduleRoot, 'package.json');
|
|
33
36
|
try {
|
|
34
37
|
const packageJson = await tryLoadFile(fullPackageJsonPath, (buf) =>
|
|
35
|
-
JSON.parse(buf.toString('utf-8'))
|
|
38
|
+
JSON.parse(buf.toString('utf-8')) as Record<string, unknown>,
|
|
36
39
|
);
|
|
37
40
|
if (packageJson === undefined) return undefined;
|
|
38
41
|
const descriptionNotParsed = packageJson[BlockDescriptionPackageJsonField];
|
|
@@ -41,17 +44,17 @@ export async function tryLoadPackDescription(
|
|
|
41
44
|
...BlockPackDescriptionFromPackageJsonRaw.parse(descriptionNotParsed),
|
|
42
45
|
id: {
|
|
43
46
|
...parsePackageName(
|
|
44
|
-
notEmpty(packageJson['name'], `"name" not found in ${fullPackageJsonPath}`)
|
|
47
|
+
notEmpty(packageJson['name'] as string | undefined, `"name" not found in ${fullPackageJsonPath}`),
|
|
45
48
|
),
|
|
46
|
-
version: SemVer.parse(packageJson['version'])
|
|
47
|
-
}
|
|
49
|
+
version: SemVer.parse(packageJson['version']),
|
|
50
|
+
},
|
|
48
51
|
};
|
|
49
|
-
const descriptionParsingResult
|
|
50
|
-
await ResolvedBlockPackDescriptionFromPackageJson(moduleRoot).safeParseAsync(descriptionRaw);
|
|
52
|
+
const descriptionParsingResult
|
|
53
|
+
= await ResolvedBlockPackDescriptionFromPackageJson(moduleRoot).safeParseAsync(descriptionRaw);
|
|
51
54
|
if (descriptionParsingResult.success) return descriptionParsingResult.data;
|
|
52
55
|
logger?.warn(descriptionParsingResult.error);
|
|
53
56
|
return undefined;
|
|
54
|
-
} catch (e:
|
|
57
|
+
} catch (e: unknown) {
|
|
55
58
|
logger?.warn(e);
|
|
56
59
|
return undefined;
|
|
57
60
|
}
|
|
@@ -59,26 +62,26 @@ export async function tryLoadPackDescription(
|
|
|
59
62
|
|
|
60
63
|
export async function loadPackDescriptionRaw(moduleRoot: string): Promise<BlockPackDescriptionRaw> {
|
|
61
64
|
const fullPackageJsonPath = path.resolve(moduleRoot, 'package.json');
|
|
62
|
-
const packageJson = JSON.parse(await fsp.readFile(fullPackageJsonPath, { encoding: 'utf-8' }))
|
|
65
|
+
const packageJson = JSON.parse(await fsp.readFile(fullPackageJsonPath, { encoding: 'utf-8' })) as Record<string, unknown>;
|
|
63
66
|
const descriptionNotParsed = packageJson[BlockDescriptionPackageJsonField];
|
|
64
67
|
if (descriptionNotParsed === undefined)
|
|
65
68
|
throw new Error(
|
|
66
|
-
`Block description (field ${BlockDescriptionPackageJsonField}) not found in ${fullPackageJsonPath}
|
|
69
|
+
`Block description (field ${BlockDescriptionPackageJsonField}) not found in ${fullPackageJsonPath}.`,
|
|
67
70
|
);
|
|
68
71
|
return {
|
|
69
72
|
...BlockPackDescriptionFromPackageJsonRaw.parse(descriptionNotParsed),
|
|
70
73
|
id: {
|
|
71
74
|
...parsePackageName(
|
|
72
|
-
notEmpty(packageJson['name'], `"name" not found in ${fullPackageJsonPath}`)
|
|
75
|
+
notEmpty(packageJson['name'] as string | undefined, `"name" not found in ${fullPackageJsonPath}`),
|
|
73
76
|
),
|
|
74
|
-
version: SemVer.parse(packageJson['version'])
|
|
77
|
+
version: SemVer.parse(packageJson['version']),
|
|
75
78
|
},
|
|
76
|
-
featureFlags: {}
|
|
79
|
+
featureFlags: {},
|
|
77
80
|
};
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
export async function loadPackDescription(
|
|
81
|
-
moduleRoot: string
|
|
84
|
+
moduleRoot: string,
|
|
82
85
|
): Promise<BlockPackDescriptionAbsolute> {
|
|
83
86
|
const descriptionRaw = await loadPackDescriptionRaw(moduleRoot);
|
|
84
87
|
return await ResolvedBlockPackDescriptionFromPackageJson(moduleRoot).parseAsync(descriptionRaw);
|
package/dist/config-DjpRXRy9.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";var Cn=Object.defineProperty;var In=(t,e,r)=>e in t?Cn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var J=(t,e,r)=>In(t,typeof e!="symbol"?e+"":e,r);const g=require("@milaboratories/pl-model-middle-layer"),T=require("zod"),z=require("node:path"),M=require("node:fs/promises"),Nn=require("mime-types"),Tn=require("tar"),_r=require("@milaboratories/resolve-helper"),It=require("@milaboratories/ts-helpers"),Ut=require("node:zlib"),Vt=require("node:util"),Ln=require("@milaboratories/pl-model-common"),jr=require("node:crypto"),An=require("yaml"),Fn=require("node:os"),U=require("node:path/posix"),Mr=require("@aws-sdk/client-s3"),bn=require("node:fs");function he(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const pe=he(Nn),Bn=he(Tn),Xt=he(Fn),Z=he(bn);function Ur(t){return T.z.string().transform((e,r)=>{const n=_r.tryResolve(t,e);return n===void 0?(r.addIssue({code:T.z.ZodIssueCode.custom,message:`Can't resolve ${e} against ${t}`}),T.z.NEVER):{type:"absolute-file",file:n}})}function Vr(t,...e){return T.z.string().transform((r,n)=>{const i=r.endsWith("/")?r:`${r}/`;for(const l of e){const a=_r.tryResolve(t,i+l);if(a!==void 0){if(!a.endsWith(l))throw new Error(`Unexpected resolve result ${a} with index file ${l}`);return{type:"absolute-folder",folder:a.slice(0,a.length-l.length)}}}return n.addIssue({code:T.z.ZodIssueCode.custom,message:`Can't resolve ${r} folder against ${t}, no index file found (${e.join(", ")})`}),T.z.NEVER})}function wt(t){return e=>e.type==="relative"?{type:"absolute-file",file:z.resolve(t,e.path)}:e}function Nt(){return async t=>t.type==="absolute-file"?await M.readFile(t.file,{encoding:"utf-8"}):t.content}function Xr(){return async t=>{if(t.type==="absolute-file"){const e=pe.lookup(t.file);if(!e)throw new Error(`Can't recognize mime type of the file: ${t.file}.`);return{type:"explicit-base64",mimeType:e,content:await M.readFile(t.file,{encoding:"base64"})}}else return t}}function Jr(){return async t=>{if(t.type==="absolute-file"){const e=pe.lookup(t.file);if(!e)throw new Error(`Can't recognize mime type of the file: ${t.file}.`);return{type:"explicit-bytes",mimeType:e,content:Buffer.from(await M.readFile(t.file))}}else return t.type==="explicit-base64"?{type:"explicit-bytes",mimeType:t.mimeType,content:Buffer.from(t.content,"base64")}:t}}function ce(t,e){return async r=>{if(r.type==="absolute-file"){const n=z.basename(r.file),i=z.resolve(t,n);return e==null||e.push(n),await M.cp(r.file,i),{type:"relative",path:n}}else return r}}function Wr(t,e,r){if(!e.endsWith(".tgz"))throw new Error(`Unexpected tgz file name: ${e}`);return async n=>{const i=z.resolve(t,e);return await Bn.create({gzip:!0,file:i,cwd:n.folder},["."]),r==null||r.push(e),{type:"relative",path:e}}}function ge(t){return async e=>e.type==="explicit-string"?e:{type:"explicit-string",content:(await t(e.path)).toString("utf8")}}function Hr(t){return async e=>e.type==="explicit-string"?e.content:(await t(e.path)).toString("utf8")}function Dn(t){return async e=>{if(e.type==="explicit-base64")return e;const r=pe.lookup(e.path);if(!r)throw new Error(`Can't recognize mime type of the file: ${e.path}.`);return{type:"explicit-base64",mimeType:r,content:(await t(e.path)).toString("base64")}}}function te(t){return async e=>{if(e.type==="explicit-base64")return{type:"explicit-bytes",mimeType:e.mimeType,content:Buffer.from(e.content,"base64")};const r=pe.lookup(e.path);if(!r)throw new Error(`Can't recognize mime type of the file: ${e.path}.`);return{type:"explicit-bytes",mimeType:r,content:await t(e.path)}}}function Yr(t){return g.BlockPackMeta(g.DescriptionContentText.transform(wt(t)),g.DescriptionContentBinary.transform(wt(t)))}function Zr(t,e){return g.BlockPackMeta(g.ContentAbsoluteTextLocal.transform(ce(t,e)),g.ContentAbsoluteBinaryLocal.transform(ce(t,e)))}const qn=g.BlockPackMeta(g.ContentAbsoluteTextLocal.transform(Nt()),g.ContentAbsoluteBinaryLocal.transform(Xr())).pipe(g.BlockPackMetaEmbeddedBase64),zn=g.BlockPackMeta(g.ContentAbsoluteTextLocal.transform(Nt()),g.ContentAbsoluteBinaryLocal.transform(Jr())).pipe(g.BlockPackMetaEmbeddedBytes);function xn(t){return g.BlockPackMeta(g.ContentRelativeText.transform(Hr(t)),g.ContentRelativeBinary.transform(te(t))).pipe(g.BlockPackMetaEmbeddedBytes)}function Kr(t){return g.BlockComponents(Ur(t),Vr(t,"index.html"))}function Qr(t,e){return g.BlockComponents(g.ContentAbsoluteBinaryLocal.transform(ce(t,e)),g.ContentAbsoluteFolder.transform(Wr(t,"ui.tgz",e))).pipe(g.BlockComponentsManifest)}function Gn(t){return g.BlockComponents(g.ContentRelative.transform(g.mapRemoteToAbsolute(t)),g.ContentRelative.transform(g.mapRemoteToAbsolute(t)))}function Tt(t){return g.CreateBlockPackDescriptionSchema(Kr(t),Yr(t)).transform(async(e,r)=>{const i=Ln.extractConfigGeneric(JSON.parse(await M.readFile(e.components.model.file,"utf-8"))).featureFlags;return{...e,featureFlags:i}})}function en(t,e){return g.CreateBlockPackDescriptionSchema(Qr(t,e),Zr(t,e)).pipe(g.BlockPackDescriptionManifest)}function Rt(t){const e=g.addPrefixToRelative(t);return g.BlockPackDescriptionManifest.pipe(g.CreateBlockPackDescriptionSchema(g.BlockComponents(g.ContentRelative.transform(e),g.ContentRelative.transform(e)),g.BlockPackMeta(g.ContentRelativeText.transform(e),g.ContentRelativeBinary.transform(e)))).pipe(g.BlockPackDescriptionManifest)}async function Lt(t,e){try{return e(await M.readFile(t))}catch(r){if(r.code=="ENOENT")return;throw new Error("",{cause:r})}}async function le(t){return Buffer.from(await crypto.subtle.digest("sha-256",t)).toString("hex").toUpperCase()}async function _n(t,e){await M.mkdir(e,{recursive:!0});const r=[],n=await en(e,r).parseAsync(t),i=await Promise.all(r.map(async a=>{const h=await M.readFile(z.resolve(e,a)),c=await le(h);return{name:a,size:h.length,sha256:c}})),l=g.BlockPackManifest.parse({schema:"v2",description:{...n},files:i,timestamp:Date.now()});return await M.writeFile(z.resolve(e,g.BlockPackManifestFile),JSON.stringify(l)),l}const ue="block",jn=/(?:@[a-zA-Z0-9-.]+\/)?(?<organization>[a-zA-Z0-9-]+)\.(?<name>[a-zA-Z0-9-]+)/;function At(t){const e=t.match(jn);if(!e)throw new Error(`Malformed package name (${t}), can't infer organization and block pack name.`);const{name:r,organization:n}=e.groups;return{name:r,organization:n}}async function Mn(t,e){const r=z.resolve(t,"package.json");try{const n=await Lt(r,h=>JSON.parse(h.toString("utf-8")));if(n===void 0)return;const i=n[ue];if(i===void 0)return;const l={...g.BlockPackDescriptionFromPackageJsonRaw.parse(i),id:{...At(It.notEmpty(n.name,`"name" not found in ${r}`)),version:g.SemVer.parse(n.version)}},a=await Tt(t).safeParseAsync(l);if(a.success)return a.data;e==null||e.warn(a.error);return}catch(n){e==null||e.warn(n);return}}async function tn(t){const e=z.resolve(t,"package.json"),r=JSON.parse(await M.readFile(e,{encoding:"utf-8"})),n=r[ue];if(n===void 0)throw new Error(`Block description (field ${ue}) not found in ${e}.`);return{...g.BlockPackDescriptionFromPackageJsonRaw.parse(n),id:{...At(It.notEmpty(r.name,`"name" not found in ${e}`)),version:g.SemVer.parse(r.version)},featureFlags:{}}}async function Un(t){const e=await tn(t);return await Tt(t).parseAsync(e)}function Vn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ne={exports:{}},Ce,Jt;function de(){if(Jt)return Ce;Jt=1;const t="2.0.0",e=256,r=Number.MAX_SAFE_INTEGER||9007199254740991,n=16,i=e-6;return Ce={MAX_LENGTH:e,MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_SAFE_INTEGER:r,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:t,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},Ce}var Ie,Wt;function me(){return Wt||(Wt=1,Ie=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{}),Ie}var Ht;function re(){return Ht||(Ht=1,function(t,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=de(),l=me();e=t.exports={};const a=e.re=[],h=e.safeRe=[],c=e.src=[],o=e.safeSrc=[],s=e.t={};let u=0;const f="[a-zA-Z0-9-]",d=[["\\s",1],["\\d",i],[f,n]],v=P=>{for(const[O,R]of d)P=P.split(`${O}*`).join(`${O}{0,${R}}`).split(`${O}+`).join(`${O}{1,${R}}`);return P},p=(P,O,R)=>{const k=v(O),A=u++;l(P,A,O),s[P]=A,c[A]=O,o[A]=k,a[A]=new RegExp(O,R?"g":void 0),h[A]=new RegExp(k,R?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${f}*`),p("MAINVERSION",`(${c[s.NUMERICIDENTIFIER]})\\.(${c[s.NUMERICIDENTIFIER]})\\.(${c[s.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${c[s.NUMERICIDENTIFIERLOOSE]})\\.(${c[s.NUMERICIDENTIFIERLOOSE]})\\.(${c[s.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${c[s.NONNUMERICIDENTIFIER]}|${c[s.NUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${c[s.NONNUMERICIDENTIFIER]}|${c[s.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASE",`(?:-(${c[s.PRERELEASEIDENTIFIER]}(?:\\.${c[s.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${c[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[s.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${f}+`),p("BUILD",`(?:\\+(${c[s.BUILDIDENTIFIER]}(?:\\.${c[s.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${c[s.MAINVERSION]}${c[s.PRERELEASE]}?${c[s.BUILD]}?`),p("FULL",`^${c[s.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${c[s.MAINVERSIONLOOSE]}${c[s.PRERELEASELOOSE]}?${c[s.BUILD]}?`),p("LOOSE",`^${c[s.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${c[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${c[s.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${c[s.XRANGEIDENTIFIER]})(?:\\.(${c[s.XRANGEIDENTIFIER]})(?:\\.(${c[s.XRANGEIDENTIFIER]})(?:${c[s.PRERELEASE]})?${c[s.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${c[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[s.XRANGEIDENTIFIERLOOSE]})(?:${c[s.PRERELEASELOOSE]})?${c[s.BUILD]}?)?)?`),p("XRANGE",`^${c[s.GTLT]}\\s*${c[s.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${c[s.GTLT]}\\s*${c[s.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),p("COERCE",`${c[s.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",c[s.COERCEPLAIN]+`(?:${c[s.PRERELEASE]})?(?:${c[s.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",c[s.COERCE],!0),p("COERCERTLFULL",c[s.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${c[s.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",p("TILDE",`^${c[s.LONETILDE]}${c[s.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${c[s.LONETILDE]}${c[s.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${c[s.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",p("CARET",`^${c[s.LONECARET]}${c[s.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${c[s.LONECARET]}${c[s.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${c[s.GTLT]}\\s*(${c[s.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${c[s.GTLT]}\\s*(${c[s.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${c[s.GTLT]}\\s*(${c[s.LOOSEPLAIN]}|${c[s.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${c[s.XRANGEPLAIN]})\\s+-\\s+(${c[s.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${c[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[s.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(ne,ne.exports)),ne.exports}var Ne,Yt;function Ft(){if(Yt)return Ne;Yt=1;const t=Object.freeze({loose:!0}),e=Object.freeze({});return Ne=n=>n?typeof n!="object"?t:n:e,Ne}var Te,Zt;function rn(){if(Zt)return Te;Zt=1;const t=/^[0-9]+$/,e=(n,i)=>{const l=t.test(n),a=t.test(i);return l&&a&&(n=+n,i=+i),n===i?0:l&&!a?-1:a&&!l?1:n<i?-1:1};return Te={compareIdentifiers:e,rcompareIdentifiers:(n,i)=>e(i,n)},Te}var Le,Kt;function G(){if(Kt)return Le;Kt=1;const t=me(),{MAX_LENGTH:e,MAX_SAFE_INTEGER:r}=de(),{safeRe:n,t:i}=re(),l=Ft(),{compareIdentifiers:a}=rn();class h{constructor(o,s){if(s=l(s),o instanceof h){if(o.loose===!!s.loose&&o.includePrerelease===!!s.includePrerelease)return o;o=o.version}else if(typeof o!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof o}".`);if(o.length>e)throw new TypeError(`version is longer than ${e} characters`);t("SemVer",o,s),this.options=s,this.loose=!!s.loose,this.includePrerelease=!!s.includePrerelease;const u=o.trim().match(s.loose?n[i.LOOSE]:n[i.FULL]);if(!u)throw new TypeError(`Invalid Version: ${o}`);if(this.raw=o,this.major=+u[1],this.minor=+u[2],this.patch=+u[3],this.major>r||this.major<0)throw new TypeError("Invalid major version");if(this.minor>r||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>r||this.patch<0)throw new TypeError("Invalid patch version");u[4]?this.prerelease=u[4].split(".").map(f=>{if(/^[0-9]+$/.test(f)){const d=+f;if(d>=0&&d<r)return d}return f}):this.prerelease=[],this.build=u[5]?u[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(o){if(t("SemVer.compare",this.version,this.options,o),!(o instanceof h)){if(typeof o=="string"&&o===this.version)return 0;o=new h(o,this.options)}return o.version===this.version?0:this.compareMain(o)||this.comparePre(o)}compareMain(o){return o instanceof h||(o=new h(o,this.options)),a(this.major,o.major)||a(this.minor,o.minor)||a(this.patch,o.patch)}comparePre(o){if(o instanceof h||(o=new h(o,this.options)),this.prerelease.length&&!o.prerelease.length)return-1;if(!this.prerelease.length&&o.prerelease.length)return 1;if(!this.prerelease.length&&!o.prerelease.length)return 0;let s=0;do{const u=this.prerelease[s],f=o.prerelease[s];if(t("prerelease compare",s,u,f),u===void 0&&f===void 0)return 0;if(f===void 0)return 1;if(u===void 0)return-1;if(u===f)continue;return a(u,f)}while(++s)}compareBuild(o){o instanceof h||(o=new h(o,this.options));let s=0;do{const u=this.build[s],f=o.build[s];if(t("build compare",s,u,f),u===void 0&&f===void 0)return 0;if(f===void 0)return 1;if(u===void 0)return-1;if(u===f)continue;return a(u,f)}while(++s)}inc(o,s,u){if(o.startsWith("pre")){if(!s&&u===!1)throw new Error("invalid increment argument: identifier is empty");if(s){const f=`-${s}`.match(this.options.loose?n[i.PRERELEASELOOSE]:n[i.PRERELEASE]);if(!f||f[1]!==s)throw new Error(`invalid identifier: ${s}`)}}switch(o){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",s,u);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",s,u);break;case"prepatch":this.prerelease.length=0,this.inc("patch",s,u),this.inc("pre",s,u);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",s,u),this.inc("pre",s,u);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const f=Number(u)?1:0;if(this.prerelease.length===0)this.prerelease=[f];else{let d=this.prerelease.length;for(;--d>=0;)typeof this.prerelease[d]=="number"&&(this.prerelease[d]++,d=-2);if(d===-1){if(s===this.prerelease.join(".")&&u===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(f)}}if(s){let d=[s,f];u===!1&&(d=[s]),a(this.prerelease[0],s)===0?isNaN(this.prerelease[1])&&(this.prerelease=d):this.prerelease=d}break}default:throw new Error(`invalid increment argument: ${o}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return Le=h,Le}var Ae,Qt;function W(){if(Qt)return Ae;Qt=1;const t=G();return Ae=(r,n,i=!1)=>{if(r instanceof t)return r;try{return new t(r,n)}catch(l){if(!i)return null;throw l}},Ae}var Fe,er;function Xn(){if(er)return Fe;er=1;const t=W();return Fe=(r,n)=>{const i=t(r,n);return i?i.version:null},Fe}var be,tr;function Jn(){if(tr)return be;tr=1;const t=W();return be=(r,n)=>{const i=t(r.trim().replace(/^[=v]+/,""),n);return i?i.version:null},be}var Be,rr;function Wn(){if(rr)return Be;rr=1;const t=G();return Be=(r,n,i,l,a)=>{typeof i=="string"&&(a=l,l=i,i=void 0);try{return new t(r instanceof t?r.version:r,i).inc(n,l,a).version}catch{return null}},Be}var De,nr;function Hn(){if(nr)return De;nr=1;const t=W();return De=(r,n)=>{const i=t(r,null,!0),l=t(n,null,!0),a=i.compare(l);if(a===0)return null;const h=a>0,c=h?i:l,o=h?l:i,s=!!c.prerelease.length;if(!!o.prerelease.length&&!s){if(!o.patch&&!o.minor)return"major";if(o.compareMain(c)===0)return o.minor&&!o.patch?"minor":"patch"}const f=s?"pre":"";return i.major!==l.major?f+"major":i.minor!==l.minor?f+"minor":i.patch!==l.patch?f+"patch":"prerelease"},De}var qe,sr;function Yn(){if(sr)return qe;sr=1;const t=G();return qe=(r,n)=>new t(r,n).major,qe}var ze,ir;function Zn(){if(ir)return ze;ir=1;const t=G();return ze=(r,n)=>new t(r,n).minor,ze}var xe,ar;function Kn(){if(ar)return xe;ar=1;const t=G();return xe=(r,n)=>new t(r,n).patch,xe}var Ge,or;function Qn(){if(or)return Ge;or=1;const t=W();return Ge=(r,n)=>{const i=t(r,n);return i&&i.prerelease.length?i.prerelease:null},Ge}var _e,cr;function _(){if(cr)return _e;cr=1;const t=G();return _e=(r,n,i)=>new t(r,i).compare(new t(n,i)),_e}var je,lr;function es(){if(lr)return je;lr=1;const t=_();return je=(r,n,i)=>t(n,r,i),je}var Me,ur;function ts(){if(ur)return Me;ur=1;const t=_();return Me=(r,n)=>t(r,n,!0),Me}var Ue,fr;function bt(){if(fr)return Ue;fr=1;const t=G();return Ue=(r,n,i)=>{const l=new t(r,i),a=new t(n,i);return l.compare(a)||l.compareBuild(a)},Ue}var Ve,hr;function rs(){if(hr)return Ve;hr=1;const t=bt();return Ve=(r,n)=>r.sort((i,l)=>t(i,l,n)),Ve}var Xe,pr;function ns(){if(pr)return Xe;pr=1;const t=bt();return Xe=(r,n)=>r.sort((i,l)=>t(l,i,n)),Xe}var Je,gr;function ve(){if(gr)return Je;gr=1;const t=_();return Je=(r,n,i)=>t(r,n,i)>0,Je}var We,dr;function Bt(){if(dr)return We;dr=1;const t=_();return We=(r,n,i)=>t(r,n,i)<0,We}var He,mr;function nn(){if(mr)return He;mr=1;const t=_();return He=(r,n,i)=>t(r,n,i)===0,He}var Ye,vr;function sn(){if(vr)return Ye;vr=1;const t=_();return Ye=(r,n,i)=>t(r,n,i)!==0,Ye}var Ze,Er;function Dt(){if(Er)return Ze;Er=1;const t=_();return Ze=(r,n,i)=>t(r,n,i)>=0,Ze}var Ke,$r;function qt(){if($r)return Ke;$r=1;const t=_();return Ke=(r,n,i)=>t(r,n,i)<=0,Ke}var Qe,wr;function an(){if(wr)return Qe;wr=1;const t=nn(),e=sn(),r=ve(),n=Dt(),i=Bt(),l=qt();return Qe=(h,c,o,s)=>{switch(c){case"===":return typeof h=="object"&&(h=h.version),typeof o=="object"&&(o=o.version),h===o;case"!==":return typeof h=="object"&&(h=h.version),typeof o=="object"&&(o=o.version),h!==o;case"":case"=":case"==":return t(h,o,s);case"!=":return e(h,o,s);case">":return r(h,o,s);case">=":return n(h,o,s);case"<":return i(h,o,s);case"<=":return l(h,o,s);default:throw new TypeError(`Invalid operator: ${c}`)}},Qe}var et,Rr;function ss(){if(Rr)return et;Rr=1;const t=G(),e=W(),{safeRe:r,t:n}=re();return et=(l,a)=>{if(l instanceof t)return l;if(typeof l=="number"&&(l=String(l)),typeof l!="string")return null;a=a||{};let h=null;if(!a.rtl)h=l.match(a.includePrerelease?r[n.COERCEFULL]:r[n.COERCE]);else{const d=a.includePrerelease?r[n.COERCERTLFULL]:r[n.COERCERTL];let v;for(;(v=d.exec(l))&&(!h||h.index+h[0].length!==l.length);)(!h||v.index+v[0].length!==h.index+h[0].length)&&(h=v),d.lastIndex=v.index+v[1].length+v[2].length;d.lastIndex=-1}if(h===null)return null;const c=h[2],o=h[3]||"0",s=h[4]||"0",u=a.includePrerelease&&h[5]?`-${h[5]}`:"",f=a.includePrerelease&&h[6]?`+${h[6]}`:"";return e(`${c}.${o}.${s}${u}${f}`,a)},et}var tt,kr;function is(){if(kr)return tt;kr=1;class t{constructor(){this.max=1e3,this.map=new Map}get(r){const n=this.map.get(r);if(n!==void 0)return this.map.delete(r),this.map.set(r,n),n}delete(r){return this.map.delete(r)}set(r,n){if(!this.delete(r)&&n!==void 0){if(this.map.size>=this.max){const l=this.map.keys().next().value;this.delete(l)}this.map.set(r,n)}return this}}return tt=t,tt}var rt,Pr;function j(){if(Pr)return rt;Pr=1;const t=/\s+/g;class e{constructor(m,S){if(S=i(S),m instanceof e)return m.loose===!!S.loose&&m.includePrerelease===!!S.includePrerelease?m:new e(m.raw,S);if(m instanceof l)return this.raw=m.value,this.set=[[m]],this.formatted=void 0,this;if(this.options=S,this.loose=!!S.loose,this.includePrerelease=!!S.includePrerelease,this.raw=m.trim().replace(t," "),this.set=this.raw.split("||").map($=>this.parseRange($.trim())).filter($=>$.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const $=this.set[0];if(this.set=this.set.filter(y=>!p(y[0])),this.set.length===0)this.set=[$];else if(this.set.length>1){for(const y of this.set)if(y.length===1&&P(y[0])){this.set=[y];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let m=0;m<this.set.length;m++){m>0&&(this.formatted+="||");const S=this.set[m];for(let $=0;$<S.length;$++)$>0&&(this.formatted+=" "),this.formatted+=S[$].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(m){const $=((this.options.includePrerelease&&d)|(this.options.loose&&v))+":"+m,y=n.get($);if(y)return y;const w=this.options.loose,I=w?c[o.HYPHENRANGELOOSE]:c[o.HYPHENRANGE];m=m.replace(I,ye(this.options.includePrerelease)),a("hyphen replace",m),m=m.replace(c[o.COMPARATORTRIM],s),a("comparator trim",m),m=m.replace(c[o.TILDETRIM],u),a("tilde trim",m),m=m.replace(c[o.CARETTRIM],f),a("caret trim",m);let L=m.split(" ").map(q=>R(q,this.options)).join(" ").split(/\s+/).map(q=>Se(q,this.options));w&&(L=L.filter(q=>(a("loose invalid filter",q,this.options),!!q.match(c[o.COMPARATORLOOSE])))),a("range list",L);const N=new Map,b=L.map(q=>new l(q,this.options));for(const q of b){if(p(q))return[q];N.set(q.value,q)}N.size>1&&N.has("")&&N.delete("");const x=[...N.values()];return n.set($,x),x}intersects(m,S){if(!(m instanceof e))throw new TypeError("a Range is required");return this.set.some($=>O($,S)&&m.set.some(y=>O(y,S)&&$.every(w=>y.every(I=>w.intersects(I,S)))))}test(m){if(!m)return!1;if(typeof m=="string")try{m=new h(m,this.options)}catch{return!1}for(let S=0;S<this.set.length;S++)if(Oe(this.set[S],m,this.options))return!0;return!1}}rt=e;const r=is(),n=new r,i=Ft(),l=Ee(),a=me(),h=G(),{safeRe:c,t:o,comparatorTrimReplace:s,tildeTrimReplace:u,caretTrimReplace:f}=re(),{FLAG_INCLUDE_PRERELEASE:d,FLAG_LOOSE:v}=de(),p=E=>E.value==="<0.0.0-0",P=E=>E.value==="",O=(E,m)=>{let S=!0;const $=E.slice();let y=$.pop();for(;S&&$.length;)S=$.every(w=>y.intersects(w,m)),y=$.pop();return S},R=(E,m)=>(a("comp",E,m),E=F(E,m),a("caret",E),E=A(E,m),a("tildes",E),E=C(E,m),a("xrange",E),E=Pe(E,m),a("stars",E),E),k=E=>!E||E.toLowerCase()==="x"||E==="*",A=(E,m)=>E.trim().split(/\s+/).map(S=>B(S,m)).join(" "),B=(E,m)=>{const S=m.loose?c[o.TILDELOOSE]:c[o.TILDE];return E.replace(S,($,y,w,I,L)=>{a("tilde",E,$,y,w,I,L);let N;return k(y)?N="":k(w)?N=`>=${y}.0.0 <${+y+1}.0.0-0`:k(I)?N=`>=${y}.${w}.0 <${y}.${+w+1}.0-0`:L?(a("replaceTilde pr",L),N=`>=${y}.${w}.${I}-${L} <${y}.${+w+1}.0-0`):N=`>=${y}.${w}.${I} <${y}.${+w+1}.0-0`,a("tilde return",N),N})},F=(E,m)=>E.trim().split(/\s+/).map(S=>D(S,m)).join(" "),D=(E,m)=>{a("caret",E,m);const S=m.loose?c[o.CARETLOOSE]:c[o.CARET],$=m.includePrerelease?"-0":"";return E.replace(S,(y,w,I,L,N)=>{a("caret",E,y,w,I,L,N);let b;return k(w)?b="":k(I)?b=`>=${w}.0.0${$} <${+w+1}.0.0-0`:k(L)?w==="0"?b=`>=${w}.${I}.0${$} <${w}.${+I+1}.0-0`:b=`>=${w}.${I}.0${$} <${+w+1}.0.0-0`:N?(a("replaceCaret pr",N),w==="0"?I==="0"?b=`>=${w}.${I}.${L}-${N} <${w}.${I}.${+L+1}-0`:b=`>=${w}.${I}.${L}-${N} <${w}.${+I+1}.0-0`:b=`>=${w}.${I}.${L}-${N} <${+w+1}.0.0-0`):(a("no pr"),w==="0"?I==="0"?b=`>=${w}.${I}.${L}${$} <${w}.${I}.${+L+1}-0`:b=`>=${w}.${I}.${L}${$} <${w}.${+I+1}.0-0`:b=`>=${w}.${I}.${L} <${+w+1}.0.0-0`),a("caret return",b),b})},C=(E,m)=>(a("replaceXRanges",E,m),E.split(/\s+/).map(S=>H(S,m)).join(" ")),H=(E,m)=>{E=E.trim();const S=m.loose?c[o.XRANGELOOSE]:c[o.XRANGE];return E.replace(S,($,y,w,I,L,N)=>{a("xRange",E,$,y,w,I,L,N);const b=k(w),x=b||k(I),q=x||k(L),Y=q;return y==="="&&Y&&(y=""),N=m.includePrerelease?"-0":"",b?y===">"||y==="<"?$="<0.0.0-0":$="*":y&&Y?(x&&(I=0),L=0,y===">"?(y=">=",x?(w=+w+1,I=0,L=0):(I=+I+1,L=0)):y==="<="&&(y="<",x?w=+w+1:I=+I+1),y==="<"&&(N="-0"),$=`${y+w}.${I}.${L}${N}`):x?$=`>=${w}.0.0${N} <${+w+1}.0.0-0`:q&&($=`>=${w}.${I}.0${N} <${w}.${+I+1}.0-0`),a("xRange return",$),$})},Pe=(E,m)=>(a("replaceStars",E,m),E.trim().replace(c[o.STAR],"")),Se=(E,m)=>(a("replaceGTE0",E,m),E.trim().replace(c[m.includePrerelease?o.GTE0PRE:o.GTE0],"")),ye=E=>(m,S,$,y,w,I,L,N,b,x,q,Y)=>(k($)?S="":k(y)?S=`>=${$}.0.0${E?"-0":""}`:k(w)?S=`>=${$}.${y}.0${E?"-0":""}`:I?S=`>=${S}`:S=`>=${S}${E?"-0":""}`,k(b)?N="":k(x)?N=`<${+b+1}.0.0-0`:k(q)?N=`<${b}.${+x+1}.0-0`:Y?N=`<=${b}.${x}.${q}-${Y}`:E?N=`<${b}.${x}.${+q+1}-0`:N=`<=${N}`,`${S} ${N}`.trim()),Oe=(E,m,S)=>{for(let $=0;$<E.length;$++)if(!E[$].test(m))return!1;if(m.prerelease.length&&!S.includePrerelease){for(let $=0;$<E.length;$++)if(a(E[$].semver),E[$].semver!==l.ANY&&E[$].semver.prerelease.length>0){const y=E[$].semver;if(y.major===m.major&&y.minor===m.minor&&y.patch===m.patch)return!0}return!1}return!0};return rt}var nt,Sr;function Ee(){if(Sr)return nt;Sr=1;const t=Symbol("SemVer ANY");class e{static get ANY(){return t}constructor(s,u){if(u=r(u),s instanceof e){if(s.loose===!!u.loose)return s;s=s.value}s=s.trim().split(/\s+/).join(" "),a("comparator",s,u),this.options=u,this.loose=!!u.loose,this.parse(s),this.semver===t?this.value="":this.value=this.operator+this.semver.version,a("comp",this)}parse(s){const u=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],f=s.match(u);if(!f)throw new TypeError(`Invalid comparator: ${s}`);this.operator=f[1]!==void 0?f[1]:"",this.operator==="="&&(this.operator=""),f[2]?this.semver=new h(f[2],this.options.loose):this.semver=t}toString(){return this.value}test(s){if(a("Comparator.test",s,this.options.loose),this.semver===t||s===t)return!0;if(typeof s=="string")try{s=new h(s,this.options)}catch{return!1}return l(s,this.operator,this.semver,this.options)}intersects(s,u){if(!(s instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(s.value,u).test(this.value):s.operator===""?s.value===""?!0:new c(this.value,u).test(s.semver):(u=r(u),u.includePrerelease&&(this.value==="<0.0.0-0"||s.value==="<0.0.0-0")||!u.includePrerelease&&(this.value.startsWith("<0.0.0")||s.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&s.operator.startsWith(">")||this.operator.startsWith("<")&&s.operator.startsWith("<")||this.semver.version===s.semver.version&&this.operator.includes("=")&&s.operator.includes("=")||l(this.semver,"<",s.semver,u)&&this.operator.startsWith(">")&&s.operator.startsWith("<")||l(this.semver,">",s.semver,u)&&this.operator.startsWith("<")&&s.operator.startsWith(">")))}}nt=e;const r=Ft(),{safeRe:n,t:i}=re(),l=an(),a=me(),h=G(),c=j();return nt}var st,yr;function $e(){if(yr)return st;yr=1;const t=j();return st=(r,n,i)=>{try{n=new t(n,i)}catch{return!1}return n.test(r)},st}var it,Or;function as(){if(Or)return it;Or=1;const t=j();return it=(r,n)=>new t(r,n).set.map(i=>i.map(l=>l.value).join(" ").trim().split(" ")),it}var at,Cr;function os(){if(Cr)return at;Cr=1;const t=G(),e=j();return at=(n,i,l)=>{let a=null,h=null,c=null;try{c=new e(i,l)}catch{return null}return n.forEach(o=>{c.test(o)&&(!a||h.compare(o)===-1)&&(a=o,h=new t(a,l))}),a},at}var ot,Ir;function cs(){if(Ir)return ot;Ir=1;const t=G(),e=j();return ot=(n,i,l)=>{let a=null,h=null,c=null;try{c=new e(i,l)}catch{return null}return n.forEach(o=>{c.test(o)&&(!a||h.compare(o)===1)&&(a=o,h=new t(a,l))}),a},ot}var ct,Nr;function ls(){if(Nr)return ct;Nr=1;const t=G(),e=j(),r=ve();return ct=(i,l)=>{i=new e(i,l);let a=new t("0.0.0");if(i.test(a)||(a=new t("0.0.0-0"),i.test(a)))return a;a=null;for(let h=0;h<i.set.length;++h){const c=i.set[h];let o=null;c.forEach(s=>{const u=new t(s.semver.version);switch(s.operator){case">":u.prerelease.length===0?u.patch++:u.prerelease.push(0),u.raw=u.format();case"":case">=":(!o||r(u,o))&&(o=u);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${s.operator}`)}}),o&&(!a||r(a,o))&&(a=o)}return a&&i.test(a)?a:null},ct}var lt,Tr;function us(){if(Tr)return lt;Tr=1;const t=j();return lt=(r,n)=>{try{return new t(r,n).range||"*"}catch{return null}},lt}var ut,Lr;function zt(){if(Lr)return ut;Lr=1;const t=G(),e=Ee(),{ANY:r}=e,n=j(),i=$e(),l=ve(),a=Bt(),h=qt(),c=Dt();return ut=(s,u,f,d)=>{s=new t(s,d),u=new n(u,d);let v,p,P,O,R;switch(f){case">":v=l,p=h,P=a,O=">",R=">=";break;case"<":v=a,p=c,P=l,O="<",R="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(i(s,u,d))return!1;for(let k=0;k<u.set.length;++k){const A=u.set[k];let B=null,F=null;if(A.forEach(D=>{D.semver===r&&(D=new e(">=0.0.0")),B=B||D,F=F||D,v(D.semver,B.semver,d)?B=D:P(D.semver,F.semver,d)&&(F=D)}),B.operator===O||B.operator===R||(!F.operator||F.operator===O)&&p(s,F.semver))return!1;if(F.operator===R&&P(s,F.semver))return!1}return!0},ut}var ft,Ar;function fs(){if(Ar)return ft;Ar=1;const t=zt();return ft=(r,n,i)=>t(r,n,">",i),ft}var ht,Fr;function hs(){if(Fr)return ht;Fr=1;const t=zt();return ht=(r,n,i)=>t(r,n,"<",i),ht}var pt,br;function ps(){if(br)return pt;br=1;const t=j();return pt=(r,n,i)=>(r=new t(r,i),n=new t(n,i),r.intersects(n,i)),pt}var gt,Br;function gs(){if(Br)return gt;Br=1;const t=$e(),e=_();return gt=(r,n,i)=>{const l=[];let a=null,h=null;const c=r.sort((f,d)=>e(f,d,i));for(const f of c)t(f,n,i)?(h=f,a||(a=f)):(h&&l.push([a,h]),h=null,a=null);a&&l.push([a,null]);const o=[];for(const[f,d]of l)f===d?o.push(f):!d&&f===c[0]?o.push("*"):d?f===c[0]?o.push(`<=${d}`):o.push(`${f} - ${d}`):o.push(`>=${f}`);const s=o.join(" || "),u=typeof n.raw=="string"?n.raw:String(n);return s.length<u.length?s:n},gt}var dt,Dr;function ds(){if(Dr)return dt;Dr=1;const t=j(),e=Ee(),{ANY:r}=e,n=$e(),i=_(),l=(u,f,d={})=>{if(u===f)return!0;u=new t(u,d),f=new t(f,d);let v=!1;e:for(const p of u.set){for(const P of f.set){const O=c(p,P,d);if(v=v||O!==null,O)continue e}if(v)return!1}return!0},a=[new e(">=0.0.0-0")],h=[new e(">=0.0.0")],c=(u,f,d)=>{if(u===f)return!0;if(u.length===1&&u[0].semver===r){if(f.length===1&&f[0].semver===r)return!0;d.includePrerelease?u=a:u=h}if(f.length===1&&f[0].semver===r){if(d.includePrerelease)return!0;f=h}const v=new Set;let p,P;for(const C of u)C.operator===">"||C.operator===">="?p=o(p,C,d):C.operator==="<"||C.operator==="<="?P=s(P,C,d):v.add(C.semver);if(v.size>1)return null;let O;if(p&&P){if(O=i(p.semver,P.semver,d),O>0)return null;if(O===0&&(p.operator!==">="||P.operator!=="<="))return null}for(const C of v){if(p&&!n(C,String(p),d)||P&&!n(C,String(P),d))return null;for(const H of f)if(!n(C,String(H),d))return!1;return!0}let R,k,A,B,F=P&&!d.includePrerelease&&P.semver.prerelease.length?P.semver:!1,D=p&&!d.includePrerelease&&p.semver.prerelease.length?p.semver:!1;F&&F.prerelease.length===1&&P.operator==="<"&&F.prerelease[0]===0&&(F=!1);for(const C of f){if(B=B||C.operator===">"||C.operator===">=",A=A||C.operator==="<"||C.operator==="<=",p){if(D&&C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===D.major&&C.semver.minor===D.minor&&C.semver.patch===D.patch&&(D=!1),C.operator===">"||C.operator===">="){if(R=o(p,C,d),R===C&&R!==p)return!1}else if(p.operator===">="&&!n(p.semver,String(C),d))return!1}if(P){if(F&&C.semver.prerelease&&C.semver.prerelease.length&&C.semver.major===F.major&&C.semver.minor===F.minor&&C.semver.patch===F.patch&&(F=!1),C.operator==="<"||C.operator==="<="){if(k=s(P,C,d),k===C&&k!==P)return!1}else if(P.operator==="<="&&!n(P.semver,String(C),d))return!1}if(!C.operator&&(P||p)&&O!==0)return!1}return!(p&&A&&!P&&O!==0||P&&B&&!p&&O!==0||D||F)},o=(u,f,d)=>{if(!u)return f;const v=i(u.semver,f.semver,d);return v>0?u:v<0||f.operator===">"&&u.operator===">="?f:u},s=(u,f,d)=>{if(!u)return f;const v=i(u.semver,f.semver,d);return v<0?u:v>0||f.operator==="<"&&u.operator==="<="?f:u};return dt=l,dt}var mt,qr;function ms(){if(qr)return mt;qr=1;const t=re(),e=de(),r=G(),n=rn(),i=W(),l=Xn(),a=Jn(),h=Wn(),c=Hn(),o=Yn(),s=Zn(),u=Kn(),f=Qn(),d=_(),v=es(),p=ts(),P=bt(),O=rs(),R=ns(),k=ve(),A=Bt(),B=nn(),F=sn(),D=Dt(),C=qt(),H=an(),Pe=ss(),Se=Ee(),ye=j(),Oe=$e(),E=as(),m=os(),S=cs(),$=ls(),y=us(),w=zt(),I=fs(),L=hs(),N=ps(),b=gs(),x=ds();return mt={parse:i,valid:l,clean:a,inc:h,diff:c,major:o,minor:s,patch:u,prerelease:f,compare:d,rcompare:v,compareLoose:p,compareBuild:P,sort:O,rsort:R,gt:k,lt:A,eq:B,neq:F,gte:D,lte:C,cmp:H,coerce:Pe,Comparator:Se,Range:ye,satisfies:Oe,toComparators:E,maxSatisfying:m,minSatisfying:S,minVersion:$,validRange:y,outside:w,gtr:I,ltr:L,intersects:N,simplifyRange:b,subset:x,SemVer:r,re:t.re,src:t.src,tokens:t.t,SEMVER_SPEC_VERSION:e.SEMVER_SPEC_VERSION,RELEASE_TYPES:e.RELEASE_TYPES,compareIdentifiers:n.compareIdentifiers,rcompareIdentifiers:n.rcompareIdentifiers},mt}var on=ms();const cn=Vn(on),kt="_updates_v2/per_package_version/";function vs(t,e){return`${kt}${t.organization}/${t.name}/${t.version}/${e}`}const Es=/(?<packageKeyWithoutVersion>(?<organization>[^\/]+)\/(?<name>[^\/]+))\/(?<version>[^\/]+)\/(?<seed>[^\/]+)$/,vt="_updates_v2/_global_update_in",zr="_updates_v2/_global_update_out",Pt="_overview_snapshots_v2/global/",$s="_overview_snapshots_v2/per_package/",ws=/^(?<timestamp>\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}\.\d{3}Z-[a-z0-9]+)\.json\.gz$/;function xr(t){return`${Pt}${t}.json.gz`}function Rs(t,e){return`${$s}${t.organization}/${t.name}/${e}.json.gz`}const X="v2/",ln="overview.json",un="overview.json.gz",fn="overview.json",ee="manifest.json",fe="channels",se=/^[-a-z0-9]+$/;function xt(t){return`${t.organization}/${t.name}/${t.version}`}function K(t){return`${X}${xt(t)}`}const hn="/"+ee,pn=T.z.object({description:g.BlockPackDescriptionManifest,channels:T.z.array(T.z.string()).default(()=>[]),manifestSha256:g.Sha256Schema}).passthrough(),ie=T.z.object({schema:T.z.literal("v2"),versions:T.z.array(pn)}).passthrough();function gn(t){return`${t.organization}/${t.name}/${fn}`}function St(t){return`${X}${gn(t)}`}function dn(t){return`${xt(t)}/${fe}/`}function mn(t){return`${X}${dn(t)}`}const vn=/(?<packageKeyWithoutVersion>(?<organization>[^\/]+)\/(?<name>[^\/]+))\/(?<version>[^\/]+)\/manifest\.json$/,Q=`${X}${ln}`,yt=`${X}${un}`;function Gt(t){const e=T.z.object({id:g.BlockPackIdNoVersion,allVersions:T.z.array(T.z.string()).optional(),allVersionsWithChannels:T.z.array(g.VersionWithChannels).optional(),latest:t,latestManifestSha256:g.Sha256Schema,latestByChannel:T.z.record(T.z.string(),T.z.object({description:t,manifestSha256:g.Sha256Schema}).passthrough()).default({})}).passthrough();return e.transform(r=>r.allVersionsWithChannels?r:{...r,allVersionsWithChannels:r.allVersions.map(n=>({version:n,channels:[]}))}).transform(r=>r.latestByChannel[g.AnyChannel]?r:{...r,latestByChannel:{...r.latestByChannel,[g.AnyChannel]:{description:r.latest,manifestSha256:r.latestManifestSha256}}}).pipe(e.required({allVersionsWithChannels:!0}))}const ks=Gt(g.BlockPackDescriptionManifest);function we(t){return T.z.object({schema:T.z.literal("v2"),packages:T.z.array(Gt(t))}).passthrough()}const ae=we(g.BlockPackDescriptionManifest);function Ps(t){return g.CreateBlockPackDescriptionSchema(g.BlockComponentsManifest,g.BlockPackMeta(g.ContentRelativeText.transform(ge(t)),g.ContentRelativeBinary.transform(te(t))))}function Ss(t){return we(g.CreateBlockPackDescriptionSchema(g.BlockComponentsManifest,g.BlockPackMeta(g.ContentRelativeText.transform(ge(t)),g.ContentRelativeBinary.transform(te(t)))))}function ys(t){return we(g.CreateBlockPackDescriptionSchema(g.BlockComponentsManifest,g.BlockPackMeta(g.ContentRelativeText.transform(ge(t)),g.ContentRelativeBinary.transform(te(t)))))}class Os{constructor(e,r=new It.ConsoleLoggerAdapter,n={}){J(this,"gzipAsync",Vt.promisify(Ut.gzip));J(this,"gunzipAsync",Vt.promisify(Ut.gunzip));this.storage=e,this.logger=r,this.settings=n}generateTimestamp(){const e=new Date().toISOString().replace(/:/g,"-").replace(/\.(\d{3})Z$/,".$1Z"),r=Math.random().toString(36).substring(2,6);return`${e}-${r}`}generatePreWriteTimestamp(){const e=new Date().toISOString().replace(/:/g,"-").replace(/\.(\d{3})Z$/,".$1Z"),r=Math.random().toString(36).substring(2,6);return`${e}-prewrite-${r}`}async createGlobalOverviewSnapshot(e,r){if(!this.settings.skipSnapshotCreation)try{const n=await this.gzipAsync(e),i=xr(r);await this.storage.putFile(i,Buffer.from(n)),this.logger.info(`Global overview snapshot created at ${i}`)}catch(n){this.logger.warn(`Failed to create global overview snapshot: ${n}`)}}async createPackageOverviewSnapshot(e,r,n){if(!this.settings.skipSnapshotCreation)try{const i=JSON.stringify(r),l=await this.gzipAsync(i),a=Rs(e,n);await this.storage.putFile(a,Buffer.from(l)),this.logger.info(`Package overview snapshot created at ${a} for ${e.organization}:${e.name}`)}catch(i){this.logger.warn(`Failed to create package overview snapshot for ${e.organization}:${e.name}: ${i}`)}}async updateRegistry(e="normal"){this.logger.info("Initiating registry refresh...");const r=this.generateTimestamp(),n=new Map,i=[],l=await this.storage.listFiles(kt),a=({organization:s,name:u,version:f})=>{const d=`${s}:${u}`;let v=n.get(d);if(v){if(!v.versions.has(f))return v.versions.add(f),!0}else return n.set(d,{package:{organization:s,name:u},versions:new Set([f])}),!0;return!1};this.logger.info("Packages to be updated:");for(const s of l){const u=s.match(Es);if(!u)continue;i.push(s);const{organization:f,name:d,version:v,seed:p}=u.groups,P=a({organization:f,name:d,version:v});this.logger.info(` - ${f}:${d}:${v} added:${P}`)}if(e==="force"){const s=await this.storage.listFiles(X);for(const u of s){const f=u.match(vn);if(!f)continue;const{organization:d,name:v,version:p}=f.groups,P=a({organization:d,name:v,version:p});this.logger.info(` - ${d}:${v}:${p} force_added:${P}`)}}const h=await this.storage.getFile(Q);if(e==="force"&&h!==void 0){const s=this.generatePreWriteTimestamp();await this.createGlobalOverviewSnapshot(h.toString(),s)}let o=(e==="force"?{packages:[]}:h===void 0?{packages:[]}:ae.parse(JSON.parse(h.toString()))).packages;this.logger.info(`Global overview ${e==="force"?"starting empty (force mode)":"loaded"}, ${o.length} records`);for(const[,s]of n.entries()){const u=St(s.package),f=await this.storage.getFile(u);if(e==="force"&&f!==void 0){const R=this.generatePreWriteTimestamp(),k=ie.parse(JSON.parse(f.toString()));await this.createPackageOverviewSnapshot(s.package,k,R)}const d=e==="force"?{versions:[]}:f===void 0?{versions:[]}:ie.parse(JSON.parse(f.toString()));this.logger.info(`Updating ${s.package.organization}:${s.package.name} overview${e==="force"?" (starting empty in force mode)":""}, ${d.versions.length} records`);const v=d.versions.filter(R=>!s.versions.has(R.description.id.version));for(const[R]of s.versions.entries()){const k=R.toString(),A={...s.package,version:k},B=await this.storage.getFile(K(A)+hn);if(!B)continue;const F=await le(B),D=(await this.storage.listFiles(mn(A))).filter(C=>C.match(se)?!0:(this.logger.warn(`Unexpected channel in ${g.blockPackIdToString(A)}: ${C}`),!1));v.push({description:Rt(k).parse(g.BlockPackManifest.parse(JSON.parse(B.toString("utf8"))).description),manifestSha256:F,channels:D})}v.sort((R,k)=>on.compare(k.description.id.version,R.description.id.version));const p={schema:"v2",versions:v};e!=="dry-run"&&(await this.storage.putFile(u,Buffer.from(JSON.stringify(p))),await this.createPackageOverviewSnapshot(s.package,p,r)),this.logger.info(`Done (${v.length} records)`);const P=new Set;for(const R of v)for(const k of R.channels)P.add(k);o=o.filter(R=>R.id.organization!==s.package.organization||R.id.name!==s.package.name);const O=Rt(`${s.package.organization}/${s.package.name}`);o.push({id:{organization:s.package.organization,name:s.package.name},allVersions:v.map(R=>R.description.id.version).reverse(),allVersionsWithChannels:v.map(R=>({version:R.description.id.version,channels:R.channels})).reverse(),latest:O.parse(v[0].description),latestManifestSha256:v[0].manifestSha256,latestByChannel:Object.fromEntries([...P,g.AnyChannel].map(R=>{const k=v.find(A=>R===g.AnyChannel||A.channels.indexOf(R)!==-1);if(!k)throw new Error("Assertion error");return[R,{description:O.parse(k.description),manifestSha256:k==null?void 0:k.manifestSha256}]}))})}if(e!=="dry-run"){const s=JSON.stringify({schema:"v2",packages:o}),u=Buffer.from(s);await this.storage.putFile(Q,u);const f=await this.gzipAsync(s);await this.storage.putFile(yt,Buffer.from(f)),await this.createGlobalOverviewSnapshot(s,r)}this.logger.info(`Global overview updated (${o.length} records)`),e!=="dry-run"&&await this.storage.deleteFiles(...i.map(s=>`${kt}${s}`)),this.logger.info("Version update requests cleared")}async updateIfNeeded(e="normal"){this.logger.info("Checking if registry requires refresh...");const r=await this.storage.getFile(vt),n=await this.storage.getFile(zr);if(e!=="force"&&r===void 0&&n===void 0){this.logger.info("No global seed files found, update not needed.");return}if(e!=="force"&&r!==void 0&&n!==void 0&&r.equals(n)){this.logger.info("Registry is up to date.");return}await this.updateRegistry(e),r&&(e!=="dry-run"&&await this.storage.putFile(zr,r),this.logger.info("Refresh finished."))}async getPackageOverview(e){const r=await this.storage.getFile(St(e));if(r!==void 0)return ie.parse(JSON.parse(r.toString()))}async getGlobalOverview(){const e=await this.storage.getFile(Q);if(e!==void 0)return ae.parse(JSON.parse(e.toString()))}async marchChanged(e){const r=jr.randomUUID(),n=vs(e,r);this.logger.info(`Creating update seed at ${n} ...`),await this.storage.putFile(n,Buffer.from(r)),this.logger.info(`Touching global update seed ${vt} ...`),await this.storage.putFile(vt,Buffer.from(r))}async addPackageToChannel(e,r){if(!r.match(se))throw new Error(`Illegal characters in channel name: ${r}`);const n=K(e);if(await this.storage.getFile(`${n}/${ee}`)===void 0)throw new Error(`Package ${g.blockPackIdToString(e)} not found in the registry.`);await this.storage.putFile(`${n}/${fe}/${r}`,Buffer.from(r)),await this.marchChanged(e)}async removePackageFromChannel(e,r){if(!r.match(se))throw new Error(`Illegal characters in channel name: ${r}`);const n=K(e);if(await this.storage.getFile(`${n}/${ee}`)===void 0)throw new Error(`Package ${g.blockPackIdToString(e)} not found in the registry.`);await this.storage.deleteFiles(`${n}/${fe}/${r}`),await this.marchChanged(e)}async listGlobalOverviewSnapshots(){const e=await this.storage.listFiles(Pt),r=[];for(const n of e){const i=n.indexOf("/")===-1?n:n.substring(n.lastIndexOf("/")+1),l=i.match(ws);l&&r.push({timestamp:l.groups.timestamp,path:Pt+i})}return r.sort((n,i)=>i.timestamp.localeCompare(n.timestamp)),r}async restoreGlobalOverviewFromSnapshot(e){const r=xr(e),n=await this.storage.getFile(r);if(!n)throw new Error(`Snapshot ${e} not found at ${r}`);const l=(await this.gunzipAsync(n)).toString("utf8");try{ae.parse(JSON.parse(l))}catch(c){throw new Error(`Invalid snapshot data in ${e}: ${c}`)}const a=Buffer.from(l);await this.storage.putFile(Q,a);const h=await this.gzipAsync(l);await this.storage.putFile(yt,Buffer.from(h)),this.logger.info(`Global overview restored from snapshot ${e}`)}async publishPackage(e,r){const n=K(e.description.id);for(const l of e.files){const a=await r(l.name);if(a.length!==l.size)throw new Error(`Actual file size don't match file size from the manifest file for ${l.name} (actual = ${a.length}; manifest = ${l.size})`);const h=await le(a);if(h!==l.sha256.toUpperCase())throw new Error(`Actual file SHA-256 don't match the checksum from the manifest file for ${l.name} (actual = ${h}; manifest = ${l.sha256.toUpperCase()})`);const c=n+"/"+l.name;this.logger.info(`Uploading ${l.name} -> ${c} ...`),await this.storage.putFile(c,a)}const i=n+"/"+ee;this.logger.info(`Uploading manifest to ${i} ...`),await this.storage.putFile(i,Buffer.from(JSON.stringify(e))),await this.marchChanged(e.description.id)}}class En{constructor(e,r,n){this.client=e,this.bucket=r,this.root=n}async getFile(e){try{return Buffer.from(await(await this.client.getObject({Bucket:this.bucket,Key:U.join(this.root,e)})).Body.transformToByteArray())}catch(r){if(r.name==="NoSuchKey")return;throw r}}async listFiles(e){const r=U.join(this.root,e),n=Mr.paginateListObjectsV2({client:this.client},{Bucket:this.bucket,Prefix:r}),i=[];for await(const l of n)i.push(...(l.Contents??[]).map(a=>U.relative(r,a.Key)));return i}async putFile(e,r){await this.client.putObject({Bucket:this.bucket,Key:U.join(this.root,e),Body:r})}async deleteFiles(...e){const r=await this.client.deleteObjects({Bucket:this.bucket,Delete:{Objects:e.map(n=>({Key:U.join(this.root,n)}))}});if(r.Errors!==void 0&&r.Errors.length>0)throw new Error(`Errors encountered while deleting files: ${r.Errors.join(`
|
|
2
|
-
`)}`)}}class $n{constructor(e){J(this,"root");this.root=z.resolve(e)}toAbsolutePath(e){if(U.isAbsolute(e))throw new Error("absolute path");return z.resolve(this.root,e.split(U.sep).join(z.sep))}async getFile(e){try{return await Z.promises.readFile(this.toAbsolutePath(e))}catch(r){if(r.code=="ENOENT")return;throw new Error("",{cause:r})}}async listFiles(e){try{const r=this.toAbsolutePath(e);return(await Z.promises.readdir(r,{recursive:!0,withFileTypes:!0})).filter(n=>n.isFile()).map(n=>z.relative(r,z.resolve(n.parentPath,n.name)).split(z.sep).join(U.sep))}catch(r){if(r.code=="ENOENT")return[];throw new Error("",{cause:r})}}async putFile(e,r){const n=this.toAbsolutePath(e);await Z.promises.mkdir(z.dirname(n),{recursive:!0}),await Z.promises.writeFile(n,r)}async deleteFiles(...e){for(const r of e)await Z.promises.rm(this.toAbsolutePath(r))}}function wn(t){const e=new URL(t,`file:${z.resolve(".").split(z.sep).join(U.sep)}/`);switch(e.protocol){case"file:":const r=z.resolve(e.pathname);return new $n(r);case"s3:":const n={},i=e.searchParams.get("region");i&&(n.region=i);const l=e.hostname;return new En(new Mr.S3(n),l,e.pathname.replace(/^\//,""));default:throw new Error(`Unknown protocol: ${e.protocol}`)}}const Cs=T.z.string().regex(/^(?:s3:|file:)/),Rn=T.z.object({organization:T.z.string(),package:T.z.string(),version:g.SemVer.optional(),files:T.z.record(T.z.string().regex(/^[^\/]+$/),T.z.string()).default({}),meta:T.z.object({}).passthrough()}),kn=T.z.object({registries:T.z.record(T.z.string(),Cs).default({}),registry:T.z.string().optional()}),_t=kn.merge(Rn).required({registry:!0,version:!0}),Re=_t.partial().required({registries:!0,files:!0}),Pn="pl.package.json",Sn="pl.package.yaml",ke="v1/";function Is(t){return`${ke}${t.organization}/${t.package}/${t.version}`}function jt(t,e){return`${ke}${t.organization}/${t.package}/${t.version}/${e}`}function Ot(t){return`${ke}${t.organization}/${t.package}/overview.json`}const oe=`${ke}overview.json`,Mt="meta.json",Ct="_updates_v1/per_package_version/";function Ns(t,e){return`${Ct}${t.organization}/${t.package}/${t.version}/${e}`}const Ts=/(?<packageKeyWithoutVersion>(?<organization>[^\/]+)\/(?<pkg>[^\/]+))\/(?<version>[^\/]+)\/(?<seed>[^\/]+)$/,yn="_updates_v1/_global_update_in",Gr="_updates_v1/_global_update_out";class Ls{constructor(e,r){this.storage=e,this.logger=r}constructNewPackage(e){return new As(this.storage,e)}async updateRegistry(){var a,h,c,o,s,u,f,d;(a=this.logger)==null||a.info("Initiating registry refresh...");const e=new Map,r=[],n=await this.storage.listFiles(Ct);(h=this.logger)==null||h.info("Packages to be updated:");for(const v of n){const p=v.match(Ts);if(!p)continue;r.push(v);const{packageKeyWithoutVersion:P,organization:O,pkg:R,version:k,seed:A}=p.groups;let B=e.get(P);B?B.versions.has(k)||B.versions.add(k):e.set(P,{package:{organization:O,package:R},versions:new Set([k])}),(c=this.logger)==null||c.info(` - ${O}:${R}:${k}`)}const i=await this.storage.getFile(oe);let l=i===void 0?[]:JSON.parse(i.toString());(o=this.logger)==null||o.info(`Global overview loaded, ${l.length} records`);for(const[,v]of e.entries()){const p=Ot(v.package),P=await this.storage.getFile(p);let O=P===void 0?[]:JSON.parse(P.toString());(s=this.logger)==null||s.info(`Updating ${v.package.organization}:${v.package.package} overview, ${O.length} records`),O=O.filter(R=>!v.versions.has(R.version));for(const[R]of v.versions.entries()){const k=R.toString(),A=await this.storage.getFile(jt({...v.package,version:k},Mt));A&&O.push({version:k,meta:JSON.parse(A.toString())})}O.sort((R,k)=>cn.compare(k.version,R.version)),await this.storage.putFile(p,Buffer.from(JSON.stringify(O))),(u=this.logger)==null||u.info(`Done (${O.length} records)`),l=l.filter(R=>R.organization!==v.package.organization||R.package!==v.package.package),l.push({organization:v.package.organization,package:v.package.package,allVersions:O.map(R=>R.version).reverse(),latestVersion:O[0].version,latestMeta:O[0].meta})}await this.storage.putFile(oe,Buffer.from(JSON.stringify(l))),(f=this.logger)==null||f.info(`Global overview updated (${l.length} records)`),await this.storage.deleteFiles(...r.map(v=>`${Ct}${v}`)),(d=this.logger)==null||d.info("Version update requests cleared")}async updateIfNeeded(e=!1){var i,l;(i=this.logger)==null||i.info("Checking if registry requires refresh...");const r=await this.storage.getFile(yn),n=await this.storage.getFile(Gr);!e&&r===void 0&&n===void 0||!e&&r!==void 0&&n!==void 0&&r.equals(n)||(await this.updateRegistry(),r&&(await this.storage.putFile(Gr,r),(l=this.logger)==null||l.info("Refresh finished")))}async getPackageOverview(e){const r=await this.storage.getFile(Ot(e));if(r!==void 0)return JSON.parse(r.toString())}async getGlobalOverview(){const e=await this.storage.getFile(oe);if(e!==void 0)return JSON.parse(e.toString())}}class As{constructor(e,r){J(this,"metaAdded",!1);J(this,"seed",jr.randomUUID());this.storage=e,this.name=r}async addFile(e,r){await this.storage.putFile(jt(this.name,e),r)}async writeMeta(e){await this.addFile(Mt,Buffer.from(JSON.stringify(e))),this.metaAdded=!0}async finish(){if(!this.metaAdded)throw new Error("meta not added");await this.storage.putFile(Ns(this.name,this.seed),Buffer.of(0)),await this.storage.putFile(yn,Buffer.from(this.seed))}}function V(t,e){return e===void 0?t:{...t,...e,registries:{...t.registries,...e.registries},files:{...t.files,...e.files}}}async function Et(t){return Lt(t,e=>Re.parse(JSON.parse(e.toString())))}async function $t(t){return Lt(t,e=>Re.parse(An.parse(e.toString())))}async function Fs(){let t=Re.parse({});return t=V(t,await Et("./.pl.reg.json")),t=V(t,await $t("./.pl.reg.yaml")),t=V(t,await Et(`${Xt.homedir()}/.pl.reg.json`)),t=V(t,await $t(`${Xt.homedir()}/.pl.reg.yaml`)),t=V(t,await Et(Pn)),t=V(t,await $t(Sn)),t}class On{constructor(e){this.conf=e}createRegistry(e){let r=this.conf.registry;if(!r.startsWith("file:")&&!r.startsWith("s3:")){const n=this.conf.registries[r];if(!n)throw new Error(`Registry with alias "${r}" not found`);r=n}return new Ls(wn(r),e)}get fullPackageName(){return{organization:this.conf.organization,package:this.conf.package,version:this.conf.version}}}async function bs(t){const e=await Fs();return new On(_t.parse(V(e,t)))}exports.BlockComponentsAbsoluteUrl=Gn;exports.BlockComponentsConsolidate=Qr;exports.BlockComponentsDescription=Kr;exports.BlockDescriptionPackageJsonField=ue;exports.BlockDescriptionToExplicitBinaryBytes=Ps;exports.BlockPackDescriptionConsolidateToFolder=en;exports.BlockPackDescriptionManifestAddRelativePathPrefix=Rt;exports.BlockPackMetaConsolidate=Zr;exports.BlockPackMetaDescription=Yr;exports.BlockPackMetaEmbedAbsoluteBase64=qn;exports.BlockPackMetaEmbedAbsoluteBytes=zn;exports.BlockPackMetaEmbedBytes=xn;exports.BlockRegistryV2=Os;exports.ChannelNameRegexp=se;exports.ChannelsFolder=fe;exports.FSStorage=$n;exports.GlobalOverview=we;exports.GlobalOverviewEntry=Gt;exports.GlobalOverviewEntryReg=ks;exports.GlobalOverviewFileName=ln;exports.GlobalOverviewGzFileName=un;exports.GlobalOverviewGzPath=yt;exports.GlobalOverviewPath=oe;exports.GlobalOverviewPath$1=Q;exports.GlobalOverviewReg=ae;exports.GlobalOverviewToExplicitBinaryBase64=ys;exports.GlobalOverviewToExplicitBinaryBytes=Ss;exports.MainPrefix=X;exports.ManifestFileName=ee;exports.ManifestSuffix=hn;exports.MetaFile=Mt;exports.PackageManifestPattern=vn;exports.PackageOverview=ie;exports.PackageOverviewFileName=fn;exports.PackageOverviewVersionEntry=pn;exports.PlPackageConfigData=Rn;exports.PlPackageJsonConfigFile=Pn;exports.PlPackageYamlConfigFile=Sn;exports.PlRegCommonConfigData=kn;exports.PlRegFullPackageConfigData=_t;exports.PlRegPackageConfig=On;exports.PlRegPackageConfigDataShard=Re;exports.ResolvedBlockPackDescriptionFromPackageJson=Tt;exports.ResolvedModuleFile=Ur;exports.ResolvedModuleFolder=Vr;exports.S3Storage=En;exports.absoluteToBase64=Xr;exports.absoluteToBytes=Jr;exports.absoluteToString=Nt;exports.buildBlockPackDist=_n;exports.calculateSha256=le;exports.cpAbsoluteToRelative=ce;exports.getConfig=bs;exports.loadPackDescription=Un;exports.loadPackDescriptionRaw=tn;exports.mapLocalToAbsolute=wt;exports.packFolderToRelativeTgz=Wr;exports.packageChannelPrefix=mn;exports.packageChannelPrefixInsideV2=dn;exports.packageContentPrefix=Is;exports.packageContentPrefix$1=K;exports.packageContentPrefixInsideV2=xt;exports.packageOverviewPath=Ot;exports.packageOverviewPath$1=St;exports.packageOverviewPathInsideV2=gn;exports.parsePackageName=At;exports.payloadFilePath=jt;exports.relativeToContentString=Hr;exports.relativeToExplicitBinary64=Dn;exports.relativeToExplicitBytes=te;exports.relativeToExplicitString=ge;exports.semver=cn;exports.storageByUrl=wn;exports.tryLoadPackDescription=Mn;
|
|
3
|
-
//# sourceMappingURL=config-DjpRXRy9.js.map
|