@kubohiroya/sb3-toolchain 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.ja.md +1 -1
- package/README.md +1 -1
- package/dist/bin.js +0 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/extension-api-manifest.d.ts +63 -0
- package/dist/extension-api-manifest.js +214 -16
- package/dist/extension-api-manifest.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/docs/extension-api-compatibility.md +15 -1
- package/docs/ja/extension-api-compatibility.md +14 -1
- package/docs/ja/source-format-v1.md +1 -1
- package/docs/source-format-v1.md +1 -1
- package/package.json +18 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.0 - 2026-09-24
|
|
4
|
+
|
|
5
|
+
- Accept extension API manifest format version 2, which carries the metadata a server-side compiler
|
|
6
|
+
needs to lower a block: `resultType`, `effect`, `immutable`, `errors` and `server` per block, and
|
|
7
|
+
`normalizesTo`, `staticLiteral`, `minimum` and `maximum` per argument. Four published extensions
|
|
8
|
+
already emit such manifests and every one of them was rejected outright, so no project could
|
|
9
|
+
manage them with API compatibility checking.
|
|
10
|
+
- Require all five block metadata fields together at version 2, and reject version 2 metadata in a
|
|
11
|
+
version 1 manifest. The `effect` and `resultType` vocabularies match
|
|
12
|
+
`@kubohiroya/turbowarp-extension-manifest` and the compiler manifest reader in
|
|
13
|
+
`turbowarp-http-server`, so a manifest this toolchain accepts is one that reader can parse.
|
|
14
|
+
- Report version 2 metadata in `compareExtensionApiManifests`: `block-resultType-changed`,
|
|
15
|
+
`block-effect-changed`, `block-immutable-changed`, `block-error-added`, `block-error-removed`,
|
|
16
|
+
`block-server-supported-changed`, `block-server-ir-operation-changed` and
|
|
17
|
+
`format-version-changed`. Changes are breaking in both directions except a block gaining server
|
|
18
|
+
support, a block declaring a new error code, and a rise from version 1 to version 2.
|
|
19
|
+
- Add `state` to the `effect` vocabulary, for a block that mutates extension-held data scoped to a
|
|
20
|
+
target, and accept the optional extension-level `pathSegmentType` and `dataReferenceType` at
|
|
21
|
+
version 2. `turbowarp-structured-data` had put all three in a format version 3 of its own; with
|
|
22
|
+
these in place its manifest fits in version 2, so no reader needs a higher ceiling.
|
|
23
|
+
- Export `extensionApiManifestFormatVersions`, `extensionApiManifestResultTypes` and
|
|
24
|
+
`extensionApiManifestEffects`, plus the `ExtensionApiManifestServer`,
|
|
25
|
+
`ExtensionApiManifestFormatVersion`, `ExtensionApiManifestResultType` and
|
|
26
|
+
`ExtensionApiManifestEffect` types. `extensionApiManifestFormatVersion` still reads `1` and is now
|
|
27
|
+
the default rather than the only accepted version.
|
|
28
|
+
|
|
29
|
+
Rollback: pin `@kubohiroya/sb3-toolchain@0.13.0`. A version 1 manifest parses and compares exactly as
|
|
30
|
+
before, so a project with no version 2 extension is unaffected either way.
|
|
31
|
+
|
|
32
|
+
## 0.13.0 - 2026-09-14
|
|
33
|
+
|
|
34
|
+
- Add `tryParseExtensionApiManifest`, which returns `{manifest, error}` instead of throwing.
|
|
35
|
+
`parseExtensionApiManifest` aborts on the first problem, so a caller auditing several published
|
|
36
|
+
manifests could only report one failure per run; the new entry point lets it collect every
|
|
37
|
+
failure and report them together.
|
|
38
|
+
- Export `ExtensionApiManifestParseResult` and its `ExtensionApiManifestParseSuccess` /
|
|
39
|
+
`ExtensionApiManifestParseFailure` members from the package entry point.
|
|
40
|
+
|
|
41
|
+
Rollback: pin `@kubohiroya/sb3-toolchain@0.12.0`.
|
|
42
|
+
|
|
3
43
|
## 0.12.0 - 2026-09-10
|
|
4
44
|
|
|
5
45
|
- Ignore `.claude/**` in the ESLint config: flat config does not read `.gitignore`, so `eslint .`
|
package/README.ja.md
CHANGED
|
@@ -31,7 +31,7 @@ Scratch 3およびTurboWarpの`.sb3`プロジェクトを、Gitで差分を確
|
|
|
31
31
|
再現可能なインストールのため、検証済みのnpmバージョンを固定します。
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.
|
|
34
|
+
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.14.0
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## クイックスタート
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ expanded sources and rebuilding bit-for-bit identical SB3 files from the same in
|
|
|
32
32
|
Pin the verified npm version for reproducible installation.
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.
|
|
35
|
+
pnpm add --save-dev --save-exact @kubohiroya/sb3-toolchain@0.14.0
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
## Quick start
|
package/dist/bin.js
CHANGED
|
File without changes
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const packageName = "@kubohiroya/sb3-toolchain";
|
|
2
|
-
export declare const packageVersion = "0.
|
|
2
|
+
export declare const packageVersion = "0.14.0";
|
package/dist/constants.js
CHANGED
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nexport const packageName = '@kubohiroya/sb3-toolchain';\nexport const packageVersion = '0.
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nexport const packageName = '@kubohiroya/sb3-toolchain';\nexport const packageVersion = '0.14.0';\n"],"mappings":";AAEA,IAAa,cAAc;AAC3B,IAAa,iBAAiB"}
|
|
@@ -1,25 +1,69 @@
|
|
|
1
1
|
import { EmbeddedExtension, ExtensionApiManifestSource } from './types';
|
|
2
|
+
/** The version assumed when none is recorded; version 2 is also supported. */
|
|
2
3
|
export declare const extensionApiManifestFormatVersion = 1;
|
|
4
|
+
export declare const extensionApiManifestFormatVersions: readonly [1, 2];
|
|
3
5
|
export declare const defaultExtensionApiManifestSizeLimit: number;
|
|
6
|
+
/**
|
|
7
|
+
* Version 2 carries the metadata a server-side compiler needs to lower a block into its own IR.
|
|
8
|
+
*
|
|
9
|
+
* These vocabularies match `@kubohiroya/turbowarp-extension-manifest`, which produces the manifests,
|
|
10
|
+
* and the compiler manifest reader in `turbowarp-http-server`, which consumes them. A value accepted
|
|
11
|
+
* here but rejected there would let an unusable extension through an update.
|
|
12
|
+
*/
|
|
13
|
+
export declare const extensionApiManifestResultTypes: readonly ["json", "boolean", "number", "string", "void", "jsonText", "yamlText"];
|
|
14
|
+
export declare const extensionApiManifestEffects: readonly ["pure", "immutable", "control", "request-read", "response-write", "storage-read", "storage-write", "binary-read", "binary-write", "state"];
|
|
15
|
+
export type ExtensionApiManifestFormatVersion = (typeof extensionApiManifestFormatVersions)[number];
|
|
16
|
+
export type ExtensionApiManifestResultType = (typeof extensionApiManifestResultTypes)[number];
|
|
17
|
+
export type ExtensionApiManifestEffect = (typeof extensionApiManifestEffects)[number];
|
|
18
|
+
export interface ExtensionApiManifestServer {
|
|
19
|
+
irOperation?: string;
|
|
20
|
+
supported: boolean;
|
|
21
|
+
}
|
|
4
22
|
export interface ExtensionApiManifestArgument {
|
|
5
23
|
id: string;
|
|
24
|
+
maximum?: number;
|
|
6
25
|
menu?: string;
|
|
26
|
+
minimum?: number;
|
|
27
|
+
normalizesTo?: 'pathSegments';
|
|
28
|
+
staticLiteral?: boolean;
|
|
7
29
|
type: string;
|
|
8
30
|
}
|
|
9
31
|
export interface ExtensionApiManifestBlock {
|
|
10
32
|
arguments: ExtensionApiManifestArgument[];
|
|
11
33
|
blockType: string;
|
|
34
|
+
effect?: ExtensionApiManifestEffect;
|
|
35
|
+
errors?: string[];
|
|
36
|
+
immutable?: boolean;
|
|
12
37
|
opcode: string;
|
|
38
|
+
resultType?: ExtensionApiManifestResultType;
|
|
39
|
+
server?: ExtensionApiManifestServer;
|
|
13
40
|
}
|
|
14
41
|
export interface ExtensionApiManifestMenu {
|
|
15
42
|
acceptReporters: boolean;
|
|
16
43
|
id: string;
|
|
17
44
|
}
|
|
45
|
+
export interface ExtensionApiManifestPathSegmentType {
|
|
46
|
+
kind: 'discriminatedUnion';
|
|
47
|
+
variants: {
|
|
48
|
+
kind: string;
|
|
49
|
+
valueType: string;
|
|
50
|
+
}[];
|
|
51
|
+
}
|
|
52
|
+
export interface ExtensionApiManifestDataReferenceType {
|
|
53
|
+
kind: string;
|
|
54
|
+
lifetime: string;
|
|
55
|
+
scope: string;
|
|
56
|
+
valueType: string;
|
|
57
|
+
}
|
|
18
58
|
export interface ExtensionApiManifest {
|
|
19
59
|
blocks: ExtensionApiManifestBlock[];
|
|
60
|
+
/** Version 2 only: what the values this extension hands out refer to, and for how long. */
|
|
61
|
+
dataReferenceType?: ExtensionApiManifestDataReferenceType;
|
|
20
62
|
formatVersion: number;
|
|
21
63
|
id: string;
|
|
22
64
|
menus: ExtensionApiManifestMenu[];
|
|
65
|
+
/** Version 2 only: how a compiler should read the path arguments this extension takes. */
|
|
66
|
+
pathSegmentType?: ExtensionApiManifestPathSegmentType;
|
|
23
67
|
}
|
|
24
68
|
export interface ExtensionApiCompatibilityChange {
|
|
25
69
|
after: unknown;
|
|
@@ -33,12 +77,31 @@ export interface ValidatedExtensionApiManifest {
|
|
|
33
77
|
manifest: ExtensionApiManifest;
|
|
34
78
|
metadata: ExtensionApiManifestSource;
|
|
35
79
|
}
|
|
80
|
+
export interface ExtensionApiManifestParseSuccess {
|
|
81
|
+
error: null;
|
|
82
|
+
manifest: ExtensionApiManifest;
|
|
83
|
+
}
|
|
84
|
+
export interface ExtensionApiManifestParseFailure {
|
|
85
|
+
error: string;
|
|
86
|
+
manifest: null;
|
|
87
|
+
}
|
|
88
|
+
export type ExtensionApiManifestParseResult = ExtensionApiManifestParseSuccess | ExtensionApiManifestParseFailure;
|
|
36
89
|
export declare function extensionApiManifestIntegrity(contents: Uint8Array | string): string;
|
|
37
90
|
export declare function extensionApiManifestLocalPath(extensionId: string): string;
|
|
38
91
|
export declare function validateExtensionApiManifestSourceMetadata(extension: EmbeddedExtension): ExtensionApiManifestSource | null;
|
|
39
92
|
export declare function parseExtensionApiManifest(contents: Uint8Array | string, { expectedId }?: {
|
|
40
93
|
expectedId?: string;
|
|
41
94
|
}): ExtensionApiManifest;
|
|
95
|
+
/**
|
|
96
|
+
* Parse an extension API manifest without throwing.
|
|
97
|
+
*
|
|
98
|
+
* `parseExtensionApiManifest` aborts on the first problem, which suits callers
|
|
99
|
+
* that treat an invalid manifest as fatal. Callers that audit several manifests
|
|
100
|
+
* and report every failure together need the error as a value instead.
|
|
101
|
+
*/
|
|
102
|
+
export declare function tryParseExtensionApiManifest(contents: Uint8Array | string, options?: {
|
|
103
|
+
expectedId?: string;
|
|
104
|
+
}): ExtensionApiManifestParseResult;
|
|
42
105
|
export declare function validateManagedExtensionApiManifest(extension: EmbeddedExtension, contents: Uint8Array | string, { expectedId }?: {
|
|
43
106
|
expectedId?: string;
|
|
44
107
|
}): ValidatedExtensionApiManifest | null;
|
|
@@ -2,8 +2,38 @@ import { assert, errorMessage } from "./assert.js";
|
|
|
2
2
|
import { validateArchiveEntryName } from "./archive.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
//#region src/extension-api-manifest.ts
|
|
5
|
+
/** The version assumed when none is recorded; version 2 is also supported. */
|
|
5
6
|
var extensionApiManifestFormatVersion = 1;
|
|
7
|
+
var extensionApiManifestFormatVersions = [1, 2];
|
|
6
8
|
var defaultExtensionApiManifestSizeLimit = 1048576;
|
|
9
|
+
/**
|
|
10
|
+
* Version 2 carries the metadata a server-side compiler needs to lower a block into its own IR.
|
|
11
|
+
*
|
|
12
|
+
* These vocabularies match `@kubohiroya/turbowarp-extension-manifest`, which produces the manifests,
|
|
13
|
+
* and the compiler manifest reader in `turbowarp-http-server`, which consumes them. A value accepted
|
|
14
|
+
* here but rejected there would let an unusable extension through an update.
|
|
15
|
+
*/
|
|
16
|
+
var extensionApiManifestResultTypes = [
|
|
17
|
+
"json",
|
|
18
|
+
"boolean",
|
|
19
|
+
"number",
|
|
20
|
+
"string",
|
|
21
|
+
"void",
|
|
22
|
+
"jsonText",
|
|
23
|
+
"yamlText"
|
|
24
|
+
];
|
|
25
|
+
var extensionApiManifestEffects = [
|
|
26
|
+
"pure",
|
|
27
|
+
"immutable",
|
|
28
|
+
"control",
|
|
29
|
+
"request-read",
|
|
30
|
+
"response-write",
|
|
31
|
+
"storage-read",
|
|
32
|
+
"storage-write",
|
|
33
|
+
"binary-read",
|
|
34
|
+
"binary-write",
|
|
35
|
+
"state"
|
|
36
|
+
];
|
|
7
37
|
function isObject(value) {
|
|
8
38
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
39
|
}
|
|
@@ -38,7 +68,7 @@ function validateExtensionApiManifestSourceMetadata(extension) {
|
|
|
38
68
|
"integrity",
|
|
39
69
|
"path"
|
|
40
70
|
], `Managed extension API manifest metadata for ${extension.id}`);
|
|
41
|
-
assert(metadata.formatVersion
|
|
71
|
+
assert(extensionApiManifestFormatVersions.includes(metadata.formatVersion), `Managed extension ${extension.id} requires API manifest formatVersion ${extensionApiManifestFormatVersions.join(" or ")}.`);
|
|
42
72
|
const artifact = assertNonEmptyString(metadata.artifact, `Managed extension ${extension.id} API manifest artifact`);
|
|
43
73
|
validateArchiveEntryName(artifact);
|
|
44
74
|
assert(!artifact.endsWith("/"), `Managed extension API manifest artifact must be a file: ${artifact}`);
|
|
@@ -47,49 +77,157 @@ function validateExtensionApiManifestSourceMetadata(extension) {
|
|
|
47
77
|
assert(typeof metadata.integrity === "string" && /^sha256-[A-Za-z0-9+/]{43}=$/u.test(metadata.integrity), `Managed extension ${extension.id} API manifest requires SHA-256 integrity.`);
|
|
48
78
|
return metadata;
|
|
49
79
|
}
|
|
50
|
-
function normalizeArgument(value, blockOpcode, index, menuIds) {
|
|
80
|
+
function normalizeArgument(value, blockOpcode, index, menuIds, formatVersion) {
|
|
51
81
|
assert(isObject(value), `API manifest block ${blockOpcode} argument ${index} must be an object.`);
|
|
52
|
-
assertExactProperties(value, [
|
|
82
|
+
assertExactProperties(value, formatVersion === 1 ? [
|
|
53
83
|
"id",
|
|
54
84
|
"menu",
|
|
55
85
|
"type"
|
|
86
|
+
] : [
|
|
87
|
+
"id",
|
|
88
|
+
"maximum",
|
|
89
|
+
"menu",
|
|
90
|
+
"minimum",
|
|
91
|
+
"normalizesTo",
|
|
92
|
+
"staticLiteral",
|
|
93
|
+
"type"
|
|
56
94
|
], `API manifest block ${blockOpcode} argument ${index}`);
|
|
57
95
|
const id = assertNonEmptyString(value.id, `API manifest block ${blockOpcode} argument ${index} ID`);
|
|
58
96
|
const type = assertNonEmptyString(value.type, `API manifest block ${blockOpcode} argument ${id} type`);
|
|
97
|
+
const constraints = formatVersion === 1 ? {} : argumentConstraints(value, `${blockOpcode} argument ${id}`);
|
|
59
98
|
if (value.menu === void 0) return {
|
|
60
99
|
id,
|
|
61
|
-
type
|
|
100
|
+
type,
|
|
101
|
+
...constraints
|
|
62
102
|
};
|
|
63
103
|
const menu = assertNonEmptyString(value.menu, `API manifest block ${blockOpcode} argument ${id} menu`);
|
|
64
104
|
assert(menuIds.has(menu), `API manifest block ${blockOpcode} argument ${id} references unknown menu: ${menu}`);
|
|
65
105
|
return {
|
|
66
106
|
id,
|
|
67
107
|
menu,
|
|
68
|
-
type
|
|
108
|
+
type,
|
|
109
|
+
...constraints
|
|
69
110
|
};
|
|
70
111
|
}
|
|
71
|
-
function
|
|
112
|
+
function argumentConstraints(value, label) {
|
|
113
|
+
const constraints = {};
|
|
114
|
+
if (value.normalizesTo !== void 0) {
|
|
115
|
+
assert(value.normalizesTo === "pathSegments", `API manifest block ${label} normalizesTo must be pathSegments.`);
|
|
116
|
+
constraints.normalizesTo = "pathSegments";
|
|
117
|
+
}
|
|
118
|
+
if (value.staticLiteral !== void 0) constraints.staticLiteral = assertBoolean(value.staticLiteral, `API manifest block ${label} staticLiteral`);
|
|
119
|
+
for (const key of ["minimum", "maximum"]) {
|
|
120
|
+
const bound = value[key];
|
|
121
|
+
if (bound === void 0) continue;
|
|
122
|
+
assert(typeof bound === "number" && Number.isFinite(bound), `API manifest block ${label} ${key} must be a finite number.`);
|
|
123
|
+
constraints[key] = bound;
|
|
124
|
+
}
|
|
125
|
+
return constraints;
|
|
126
|
+
}
|
|
127
|
+
function normalizeBlock(value, index, menuIds, formatVersion) {
|
|
72
128
|
assert(isObject(value), `API manifest block ${index} must be an object.`);
|
|
73
|
-
assertExactProperties(value, [
|
|
129
|
+
assertExactProperties(value, formatVersion === 1 ? [
|
|
74
130
|
"arguments",
|
|
75
131
|
"blockType",
|
|
76
132
|
"opcode"
|
|
133
|
+
] : [
|
|
134
|
+
"arguments",
|
|
135
|
+
"blockType",
|
|
136
|
+
"effect",
|
|
137
|
+
"errors",
|
|
138
|
+
"immutable",
|
|
139
|
+
"opcode",
|
|
140
|
+
"resultType",
|
|
141
|
+
"server"
|
|
77
142
|
], `API manifest block ${index}`);
|
|
78
143
|
const opcode = assertNonEmptyString(value.opcode, `API manifest block ${index} opcode`);
|
|
79
144
|
const blockType = assertNonEmptyString(value.blockType, `API manifest block ${opcode} blockType`);
|
|
80
145
|
assert(Array.isArray(value.arguments), `API manifest block ${opcode} arguments must be an array.`);
|
|
81
|
-
const arguments_ = value.arguments.map((argument, argumentIndex) => normalizeArgument(argument, opcode, argumentIndex, menuIds));
|
|
146
|
+
const arguments_ = value.arguments.map((argument, argumentIndex) => normalizeArgument(argument, opcode, argumentIndex, menuIds, formatVersion));
|
|
82
147
|
const argumentIds = /* @__PURE__ */ new Set();
|
|
83
148
|
for (const argument of arguments_) {
|
|
84
149
|
assert(!argumentIds.has(argument.id), `API manifest block ${opcode} has duplicate argument ID: ${argument.id}`);
|
|
85
150
|
argumentIds.add(argument.id);
|
|
86
151
|
}
|
|
87
152
|
arguments_.sort((left, right) => compareIds(left.id, right.id));
|
|
88
|
-
|
|
153
|
+
const block = {
|
|
89
154
|
arguments: arguments_,
|
|
90
155
|
blockType,
|
|
91
156
|
opcode
|
|
92
157
|
};
|
|
158
|
+
if (formatVersion === 1) return block;
|
|
159
|
+
return {
|
|
160
|
+
...block,
|
|
161
|
+
effect: assertEnum(value.effect, extensionApiManifestEffects, `API manifest block ${opcode} effect`),
|
|
162
|
+
errors: normalizeErrors(value.errors, opcode),
|
|
163
|
+
immutable: assertBoolean(value.immutable, `API manifest block ${opcode} immutable`),
|
|
164
|
+
resultType: assertEnum(value.resultType, extensionApiManifestResultTypes, `API manifest block ${opcode} resultType`),
|
|
165
|
+
server: normalizeServer(value.server, opcode)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function normalizeExtensionTypes(manifest) {
|
|
169
|
+
const types = {};
|
|
170
|
+
if (manifest.pathSegmentType !== void 0) {
|
|
171
|
+
const pathType = manifest.pathSegmentType;
|
|
172
|
+
assert(isObject(pathType), "API manifest pathSegmentType must be an object.");
|
|
173
|
+
assertExactProperties(pathType, ["kind", "variants"], "API manifest pathSegmentType");
|
|
174
|
+
assert(pathType.kind === "discriminatedUnion", "API manifest pathSegmentType kind must be discriminatedUnion.");
|
|
175
|
+
assert(Array.isArray(pathType.variants) && pathType.variants.length > 0, "API manifest pathSegmentType variants must be a non-empty array.");
|
|
176
|
+
types.pathSegmentType = {
|
|
177
|
+
kind: "discriminatedUnion",
|
|
178
|
+
variants: pathType.variants.map((variant, index) => {
|
|
179
|
+
const label = `API manifest pathSegmentType variants[${index}]`;
|
|
180
|
+
assert(isObject(variant), `${label} must be an object.`);
|
|
181
|
+
assertExactProperties(variant, ["kind", "valueType"], label);
|
|
182
|
+
return {
|
|
183
|
+
kind: assertNonEmptyString(variant.kind, `${label} kind`),
|
|
184
|
+
valueType: assertNonEmptyString(variant.valueType, `${label} valueType`)
|
|
185
|
+
};
|
|
186
|
+
})
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
if (manifest.dataReferenceType !== void 0) {
|
|
190
|
+
const reference = manifest.dataReferenceType;
|
|
191
|
+
assert(isObject(reference), "API manifest dataReferenceType must be an object.");
|
|
192
|
+
assertExactProperties(reference, [
|
|
193
|
+
"kind",
|
|
194
|
+
"lifetime",
|
|
195
|
+
"scope",
|
|
196
|
+
"valueType"
|
|
197
|
+
], "API manifest dataReferenceType");
|
|
198
|
+
types.dataReferenceType = {
|
|
199
|
+
kind: assertNonEmptyString(reference.kind, "API manifest dataReferenceType kind"),
|
|
200
|
+
lifetime: assertNonEmptyString(reference.lifetime, "API manifest dataReferenceType lifetime"),
|
|
201
|
+
scope: assertNonEmptyString(reference.scope, "API manifest dataReferenceType scope"),
|
|
202
|
+
valueType: assertNonEmptyString(reference.valueType, "API manifest dataReferenceType valueType")
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return types;
|
|
206
|
+
}
|
|
207
|
+
function normalizeErrors(value, opcode) {
|
|
208
|
+
assert(Array.isArray(value), `API manifest block ${opcode} errors must be an array.`);
|
|
209
|
+
return value.map((error, index) => assertNonEmptyString(error, `API manifest block ${opcode} errors[${index}]`));
|
|
210
|
+
}
|
|
211
|
+
function normalizeServer(value, opcode) {
|
|
212
|
+
assert(isObject(value), `API manifest block ${opcode} server must be an object.`);
|
|
213
|
+
assertExactProperties(value, ["irOperation", "supported"], `API manifest block ${opcode} server`);
|
|
214
|
+
const supported = assertBoolean(value.supported, `API manifest block ${opcode} server.supported`);
|
|
215
|
+
if (value.irOperation === void 0) {
|
|
216
|
+
assert(!supported, `API manifest block ${opcode} server.irOperation is required when supported is true.`);
|
|
217
|
+
return { supported };
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
irOperation: assertNonEmptyString(value.irOperation, `API manifest block ${opcode} server.irOperation`),
|
|
221
|
+
supported
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function assertBoolean(value, label) {
|
|
225
|
+
assert(typeof value === "boolean", `${label} must be a boolean.`);
|
|
226
|
+
return value;
|
|
227
|
+
}
|
|
228
|
+
function assertEnum(value, allowed, label) {
|
|
229
|
+
assert(typeof value === "string" && allowed.includes(value), `${label} must be one of: ${allowed.join(", ")}.`);
|
|
230
|
+
return value;
|
|
93
231
|
}
|
|
94
232
|
function normalizeMenu(value, index) {
|
|
95
233
|
assert(isObject(value), `API manifest menu ${index} must be an object.`);
|
|
@@ -109,13 +247,21 @@ function parseExtensionApiManifest(contents, { expectedId } = {}) {
|
|
|
109
247
|
throw new Error(`Extension API manifest is not valid JSON: ${errorMessage(error)}`, { cause: error });
|
|
110
248
|
}
|
|
111
249
|
assert(isObject(manifest), "Extension API manifest must contain an object.");
|
|
112
|
-
assertExactProperties(manifest, [
|
|
250
|
+
assertExactProperties(manifest, isObject(manifest) && manifest.formatVersion === 2 ? [
|
|
251
|
+
"blocks",
|
|
252
|
+
"dataReferenceType",
|
|
253
|
+
"formatVersion",
|
|
254
|
+
"id",
|
|
255
|
+
"menus",
|
|
256
|
+
"pathSegmentType"
|
|
257
|
+
] : [
|
|
113
258
|
"blocks",
|
|
114
259
|
"formatVersion",
|
|
115
260
|
"id",
|
|
116
261
|
"menus"
|
|
117
262
|
], "Extension API manifest");
|
|
118
|
-
|
|
263
|
+
const formatVersion = manifest.formatVersion;
|
|
264
|
+
assert(extensionApiManifestFormatVersions.includes(formatVersion), `Unsupported extension API manifest formatVersion: ${manifest.formatVersion}`);
|
|
119
265
|
assert(typeof manifest.id === "string" && /^[a-z0-9]+$/u.test(manifest.id), `Invalid extension API manifest ID: ${JSON.stringify(manifest.id)}`);
|
|
120
266
|
if (expectedId !== void 0) assert(manifest.id === expectedId, `Extension API manifest ID mismatch: expected ${expectedId}, got ${manifest.id}`);
|
|
121
267
|
assert(Array.isArray(manifest.menus), "Extension API manifest menus must be an array.");
|
|
@@ -126,7 +272,7 @@ function parseExtensionApiManifest(contents, { expectedId } = {}) {
|
|
|
126
272
|
menuIds.add(menu.id);
|
|
127
273
|
}
|
|
128
274
|
assert(Array.isArray(manifest.blocks), "Extension API manifest blocks must be an array.");
|
|
129
|
-
const blocks = manifest.blocks.map((block, index) => normalizeBlock(block, index, menuIds));
|
|
275
|
+
const blocks = manifest.blocks.map((block, index) => normalizeBlock(block, index, menuIds, formatVersion));
|
|
130
276
|
const blockOpcodes = /* @__PURE__ */ new Set();
|
|
131
277
|
for (const block of blocks) {
|
|
132
278
|
assert(!blockOpcodes.has(block.opcode), `Extension API manifest has duplicate block opcode: ${block.opcode}`);
|
|
@@ -136,11 +282,32 @@ function parseExtensionApiManifest(contents, { expectedId } = {}) {
|
|
|
136
282
|
menus.sort((left, right) => compareIds(left.id, right.id));
|
|
137
283
|
return {
|
|
138
284
|
blocks,
|
|
139
|
-
formatVersion
|
|
285
|
+
formatVersion,
|
|
140
286
|
id: manifest.id,
|
|
141
|
-
menus
|
|
287
|
+
menus,
|
|
288
|
+
...formatVersion === 1 ? {} : normalizeExtensionTypes(manifest)
|
|
142
289
|
};
|
|
143
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Parse an extension API manifest without throwing.
|
|
293
|
+
*
|
|
294
|
+
* `parseExtensionApiManifest` aborts on the first problem, which suits callers
|
|
295
|
+
* that treat an invalid manifest as fatal. Callers that audit several manifests
|
|
296
|
+
* and report every failure together need the error as a value instead.
|
|
297
|
+
*/
|
|
298
|
+
function tryParseExtensionApiManifest(contents, options = {}) {
|
|
299
|
+
try {
|
|
300
|
+
return {
|
|
301
|
+
error: null,
|
|
302
|
+
manifest: parseExtensionApiManifest(contents, options)
|
|
303
|
+
};
|
|
304
|
+
} catch (error) {
|
|
305
|
+
return {
|
|
306
|
+
error: errorMessage(error),
|
|
307
|
+
manifest: null
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
144
311
|
function validateManagedExtensionApiManifest(extension, contents, { expectedId = extension.id } = {}) {
|
|
145
312
|
const metadata = validateExtensionApiManifestSourceMetadata(extension);
|
|
146
313
|
if (!metadata) return null;
|
|
@@ -154,6 +321,28 @@ function validateManagedExtensionApiManifest(extension, contents, { expectedId =
|
|
|
154
321
|
metadata
|
|
155
322
|
};
|
|
156
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Compares the format version 2 metadata of one block.
|
|
326
|
+
*
|
|
327
|
+
* Every change to a declared contract counts as breaking, in both directions: a consumer can rely on
|
|
328
|
+
* a block being immutable just as readily as on it not being. The two exceptions are a block gaining
|
|
329
|
+
* server support and a block declaring a new error code, which only widen what the block offers.
|
|
330
|
+
*/
|
|
331
|
+
function compareBlockMetadata(changes, installed, candidate, path) {
|
|
332
|
+
for (const property of [
|
|
333
|
+
"resultType",
|
|
334
|
+
"effect",
|
|
335
|
+
"immutable"
|
|
336
|
+
]) if (installed[property] !== candidate[property]) addChange(changes, `block-${property}-changed`, `${path}/${property}`, installed[property] ?? null, candidate[property] ?? null, true);
|
|
337
|
+
const installedErrors = new Set(installed.errors ?? []);
|
|
338
|
+
const candidateErrors = new Set(candidate.errors ?? []);
|
|
339
|
+
for (const code of installedErrors) if (!candidateErrors.has(code)) addChange(changes, "block-error-removed", `${path}/errors`, code, null, true);
|
|
340
|
+
for (const code of candidateErrors) if (!installedErrors.has(code)) addChange(changes, "block-error-added", `${path}/errors`, null, code, false);
|
|
341
|
+
const installedServer = installed.server;
|
|
342
|
+
const candidateServer = candidate.server;
|
|
343
|
+
if (installedServer?.supported !== candidateServer?.supported) addChange(changes, "block-server-supported-changed", `${path}/server/supported`, installedServer?.supported ?? null, candidateServer?.supported ?? null, installedServer?.supported === true);
|
|
344
|
+
if (installedServer?.irOperation !== candidateServer?.irOperation) addChange(changes, "block-server-ir-operation-changed", `${path}/server/irOperation`, installedServer?.irOperation ?? null, candidateServer?.irOperation ?? null, true);
|
|
345
|
+
}
|
|
157
346
|
function addChange(changes, kind, path, before, after, breaking) {
|
|
158
347
|
changes.push({
|
|
159
348
|
after,
|
|
@@ -165,6 +354,7 @@ function addChange(changes, kind, path, before, after, breaking) {
|
|
|
165
354
|
}
|
|
166
355
|
function compareExtensionApiManifests(installed, candidate) {
|
|
167
356
|
const changes = [];
|
|
357
|
+
if (installed.formatVersion !== candidate.formatVersion) addChange(changes, "format-version-changed", "/formatVersion", installed.formatVersion, candidate.formatVersion, candidate.formatVersion < installed.formatVersion);
|
|
168
358
|
const installedBlocks = new Map(installed.blocks.map((block) => [block.opcode, block]));
|
|
169
359
|
const candidateBlocks = new Map(candidate.blocks.map((block) => [block.opcode, block]));
|
|
170
360
|
for (const [opcode, block] of installedBlocks) {
|
|
@@ -175,6 +365,7 @@ function compareExtensionApiManifests(installed, candidate) {
|
|
|
175
365
|
continue;
|
|
176
366
|
}
|
|
177
367
|
if (block.blockType !== replacement.blockType) addChange(changes, "block-type-changed", `${path}/blockType`, block.blockType, replacement.blockType, true);
|
|
368
|
+
compareBlockMetadata(changes, block, replacement, path);
|
|
178
369
|
const installedArguments = new Map(block.arguments.map((argument) => [argument.id, argument]));
|
|
179
370
|
const candidateArguments = new Map(replacement.arguments.map((argument) => [argument.id, argument]));
|
|
180
371
|
for (const [argumentId, argument] of installedArguments) {
|
|
@@ -184,7 +375,14 @@ function compareExtensionApiManifests(installed, candidate) {
|
|
|
184
375
|
addChange(changes, "argument-removed", argumentPath, argument, null, true);
|
|
185
376
|
continue;
|
|
186
377
|
}
|
|
187
|
-
for (const property of [
|
|
378
|
+
for (const property of [
|
|
379
|
+
"type",
|
|
380
|
+
"menu",
|
|
381
|
+
"normalizesTo",
|
|
382
|
+
"staticLiteral",
|
|
383
|
+
"minimum",
|
|
384
|
+
"maximum"
|
|
385
|
+
]) if (argument[property] !== replacementArgument[property]) addChange(changes, `argument-${property}-changed`, `${argumentPath}/${property}`, argument[property] ?? null, replacementArgument[property] ?? null, true);
|
|
188
386
|
}
|
|
189
387
|
for (const [argumentId, argument] of candidateArguments) if (!installedArguments.has(argumentId)) addChange(changes, "argument-added", `${path}/arguments/${escapeJsonPointer(argumentId)}`, null, argument, true);
|
|
190
388
|
}
|
|
@@ -206,6 +404,6 @@ function formatExtensionApiCompatibilityChanges(extensionId, changes) {
|
|
|
206
404
|
return changes.map((change) => `${extensionId} ${change.breaking ? "breaking" : "compatible"} ${change.kind} ${change.path}`).join("\n");
|
|
207
405
|
}
|
|
208
406
|
//#endregion
|
|
209
|
-
export { compareExtensionApiManifests, defaultExtensionApiManifestSizeLimit, extensionApiManifestFormatVersion, extensionApiManifestIntegrity, extensionApiManifestLocalPath, formatExtensionApiCompatibilityChanges, parseExtensionApiManifest, validateExtensionApiManifestSourceMetadata, validateManagedExtensionApiManifest };
|
|
407
|
+
export { compareExtensionApiManifests, defaultExtensionApiManifestSizeLimit, extensionApiManifestEffects, extensionApiManifestFormatVersion, extensionApiManifestFormatVersions, extensionApiManifestIntegrity, extensionApiManifestLocalPath, extensionApiManifestResultTypes, formatExtensionApiCompatibilityChanges, parseExtensionApiManifest, tryParseExtensionApiManifest, validateExtensionApiManifestSourceMetadata, validateManagedExtensionApiManifest };
|
|
210
408
|
|
|
211
409
|
//# sourceMappingURL=extension-api-manifest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-api-manifest.js","names":[],"sources":["../src/extension-api-manifest.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nimport {createHash} from 'node:crypto';\n\nimport {validateArchiveEntryName} from './archive';\nimport {assert, errorMessage} from './assert';\nimport type {EmbeddedExtension, ExtensionApiManifestSource, UnknownRecord} from './types';\n\nexport const extensionApiManifestFormatVersion = 1;\nexport const defaultExtensionApiManifestSizeLimit = 1024 * 1024;\n\nexport interface ExtensionApiManifestArgument {\n id: string;\n menu?: string;\n type: string;\n}\n\nexport interface ExtensionApiManifestBlock {\n arguments: ExtensionApiManifestArgument[];\n blockType: string;\n opcode: string;\n}\n\nexport interface ExtensionApiManifestMenu {\n acceptReporters: boolean;\n id: string;\n}\n\nexport interface ExtensionApiManifest {\n blocks: ExtensionApiManifestBlock[];\n formatVersion: number;\n id: string;\n menus: ExtensionApiManifestMenu[];\n}\n\nexport interface ExtensionApiCompatibilityChange {\n after: unknown;\n before: unknown;\n breaking: boolean;\n kind: string;\n path: string;\n}\n\nexport interface ValidatedExtensionApiManifest {\n integrity: string;\n manifest: ExtensionApiManifest;\n metadata: ExtensionApiManifestSource;\n}\n\nfunction isObject(value: unknown): value is UnknownRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction assertExactProperties(\n value: UnknownRecord,\n expected: string[],\n description: string,\n): void {\n const expectedProperties = new Set(expected);\n const unexpected = Object.keys(value).filter((property) => !expectedProperties.has(property));\n assert(\n unexpected.length === 0,\n `${description} has unsupported properties: ${unexpected.join(', ')}`,\n );\n}\n\nfunction assertNonEmptyString(value: unknown, description: string): string {\n assert(\n typeof value === 'string' && value.length > 0,\n `${description} must be a non-empty string.`,\n );\n return value;\n}\n\nfunction compareIds(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction escapeJsonPointer(value: string): string {\n return value.replaceAll('~', '~0').replaceAll('/', '~1');\n}\n\nexport function extensionApiManifestIntegrity(contents: Uint8Array | string): string {\n return `sha256-${createHash('sha256').update(contents).digest('base64')}`;\n}\n\nexport function extensionApiManifestLocalPath(extensionId: string): string {\n return `extensions/${extensionId}.manifest.json`;\n}\n\nexport function validateExtensionApiManifestSourceMetadata(\n extension: EmbeddedExtension,\n): ExtensionApiManifestSource | null {\n const metadata: unknown = extension.source?.apiManifest;\n if (metadata === undefined) return null;\n assert(\n isObject(metadata),\n `Managed extension API manifest metadata must be an object: ${extension.id}`,\n );\n assertExactProperties(\n metadata,\n ['artifact', 'formatVersion', 'integrity', 'path'],\n `Managed extension API manifest metadata for ${extension.id}`,\n );\n assert(\n metadata.formatVersion === extensionApiManifestFormatVersion,\n `Managed extension ${extension.id} requires API manifest formatVersion ${extensionApiManifestFormatVersion}.`,\n );\n const artifact = assertNonEmptyString(\n metadata.artifact,\n `Managed extension ${extension.id} API manifest artifact`,\n );\n validateArchiveEntryName(artifact);\n assert(\n !artifact.endsWith('/'),\n `Managed extension API manifest artifact must be a file: ${artifact}`,\n );\n const expectedPath = extensionApiManifestLocalPath(extension.id);\n assert(\n metadata.path === expectedPath,\n `Managed extension API manifest path must match its ID: expected ${expectedPath}, got ${metadata.path}`,\n );\n assert(\n typeof metadata.integrity === 'string' &&\n /^sha256-[A-Za-z0-9+/]{43}=$/u.test(metadata.integrity),\n `Managed extension ${extension.id} API manifest requires SHA-256 integrity.`,\n );\n return metadata as unknown as ExtensionApiManifestSource;\n}\n\nfunction normalizeArgument(\n value: unknown,\n blockOpcode: string,\n index: number,\n menuIds: Set<string>,\n): ExtensionApiManifestArgument {\n assert(isObject(value), `API manifest block ${blockOpcode} argument ${index} must be an object.`);\n assertExactProperties(\n value,\n ['id', 'menu', 'type'],\n `API manifest block ${blockOpcode} argument ${index}`,\n );\n const id = assertNonEmptyString(\n value.id,\n `API manifest block ${blockOpcode} argument ${index} ID`,\n );\n const type = assertNonEmptyString(\n value.type,\n `API manifest block ${blockOpcode} argument ${id} type`,\n );\n if (value.menu === undefined) {\n return {id, type};\n }\n const menu = assertNonEmptyString(\n value.menu,\n `API manifest block ${blockOpcode} argument ${id} menu`,\n );\n assert(\n menuIds.has(menu),\n `API manifest block ${blockOpcode} argument ${id} references unknown menu: ${menu}`,\n );\n return {id, menu, type};\n}\n\nfunction normalizeBlock(\n value: unknown,\n index: number,\n menuIds: Set<string>,\n): ExtensionApiManifestBlock {\n assert(isObject(value), `API manifest block ${index} must be an object.`);\n assertExactProperties(value, ['arguments', 'blockType', 'opcode'], `API manifest block ${index}`);\n const opcode = assertNonEmptyString(value.opcode, `API manifest block ${index} opcode`);\n const blockType = assertNonEmptyString(value.blockType, `API manifest block ${opcode} blockType`);\n assert(\n Array.isArray(value.arguments),\n `API manifest block ${opcode} arguments must be an array.`,\n );\n const arguments_ = (value.arguments as unknown[]).map((argument, argumentIndex) =>\n normalizeArgument(argument, opcode, argumentIndex, menuIds),\n );\n const argumentIds = new Set<string>();\n for (const argument of arguments_) {\n assert(\n !argumentIds.has(argument.id),\n `API manifest block ${opcode} has duplicate argument ID: ${argument.id}`,\n );\n argumentIds.add(argument.id);\n }\n arguments_.sort((left, right) => compareIds(left.id, right.id));\n return {arguments: arguments_, blockType, opcode};\n}\n\nfunction normalizeMenu(value: unknown, index: number): ExtensionApiManifestMenu {\n assert(isObject(value), `API manifest menu ${index} must be an object.`);\n assertExactProperties(value, ['acceptReporters', 'id'], `API manifest menu ${index}`);\n const id = assertNonEmptyString(value.id, `API manifest menu ${index} ID`);\n assert(\n typeof value.acceptReporters === 'boolean',\n `API manifest menu ${id} acceptReporters must be a boolean.`,\n );\n return {acceptReporters: value.acceptReporters, id};\n}\n\nexport function parseExtensionApiManifest(\n contents: Uint8Array | string,\n {expectedId}: {expectedId?: string} = {},\n): ExtensionApiManifest {\n let manifest: unknown;\n try {\n manifest = JSON.parse(Buffer.from(contents).toString('utf8'));\n } catch (error) {\n throw new Error(`Extension API manifest is not valid JSON: ${errorMessage(error)}`, {\n cause: error,\n });\n }\n assert(isObject(manifest), 'Extension API manifest must contain an object.');\n assertExactProperties(\n manifest,\n ['blocks', 'formatVersion', 'id', 'menus'],\n 'Extension API manifest',\n );\n assert(\n manifest.formatVersion === extensionApiManifestFormatVersion,\n `Unsupported extension API manifest formatVersion: ${manifest.formatVersion}`,\n );\n assert(\n typeof manifest.id === 'string' && /^[a-z0-9]+$/u.test(manifest.id),\n `Invalid extension API manifest ID: ${JSON.stringify(manifest.id)}`,\n );\n if (expectedId !== undefined) {\n assert(\n manifest.id === expectedId,\n `Extension API manifest ID mismatch: expected ${expectedId}, got ${manifest.id}`,\n );\n }\n assert(Array.isArray(manifest.menus), 'Extension API manifest menus must be an array.');\n const menus = (manifest.menus as unknown[]).map(normalizeMenu);\n const menuIds = new Set<string>();\n for (const menu of menus) {\n assert(!menuIds.has(menu.id), `Extension API manifest has duplicate menu ID: ${menu.id}`);\n menuIds.add(menu.id);\n }\n assert(Array.isArray(manifest.blocks), 'Extension API manifest blocks must be an array.');\n const blocks = (manifest.blocks as unknown[]).map((block, index) =>\n normalizeBlock(block, index, menuIds),\n );\n const blockOpcodes = new Set<string>();\n for (const block of blocks) {\n assert(\n !blockOpcodes.has(block.opcode),\n `Extension API manifest has duplicate block opcode: ${block.opcode}`,\n );\n blockOpcodes.add(block.opcode);\n }\n blocks.sort((left, right) => compareIds(left.opcode, right.opcode));\n menus.sort((left, right) => compareIds(left.id, right.id));\n return {blocks, formatVersion: extensionApiManifestFormatVersion, id: manifest.id, menus};\n}\n\nexport function validateManagedExtensionApiManifest(\n extension: EmbeddedExtension,\n contents: Uint8Array | string,\n {expectedId = extension.id}: {expectedId?: string} = {},\n): ValidatedExtensionApiManifest | null {\n const metadata = validateExtensionApiManifestSourceMetadata(extension);\n if (!metadata) return null;\n const actualIntegrity = extensionApiManifestIntegrity(contents);\n assert(\n actualIntegrity === metadata.integrity,\n `Managed extension API manifest integrity mismatch for ${extension.id}: ` +\n `expected ${metadata.integrity}, got ${actualIntegrity}`,\n );\n const manifest = parseExtensionApiManifest(contents, {expectedId});\n assert(\n manifest.formatVersion === metadata.formatVersion,\n `Managed extension API manifest version mismatch for ${extension.id}.`,\n );\n return {integrity: actualIntegrity, manifest, metadata};\n}\n\nfunction addChange(\n changes: ExtensionApiCompatibilityChange[],\n kind: string,\n path: string,\n before: unknown,\n after: unknown,\n breaking: boolean,\n): void {\n changes.push({after, before, breaking, kind, path});\n}\n\nexport function compareExtensionApiManifests(\n installed: ExtensionApiManifest,\n candidate: ExtensionApiManifest,\n): ExtensionApiCompatibilityChange[] {\n const changes: ExtensionApiCompatibilityChange[] = [];\n const installedBlocks = new Map(installed.blocks.map((block) => [block.opcode, block]));\n const candidateBlocks = new Map(candidate.blocks.map((block) => [block.opcode, block]));\n for (const [opcode, block] of installedBlocks) {\n const path = `/blocks/${escapeJsonPointer(opcode)}`;\n const replacement = candidateBlocks.get(opcode);\n if (!replacement) {\n addChange(changes, 'block-removed', path, block, null, true);\n continue;\n }\n if (block.blockType !== replacement.blockType) {\n addChange(\n changes,\n 'block-type-changed',\n `${path}/blockType`,\n block.blockType,\n replacement.blockType,\n true,\n );\n }\n const installedArguments = new Map(block.arguments.map((argument) => [argument.id, argument]));\n const candidateArguments = new Map(\n replacement.arguments.map((argument) => [argument.id, argument]),\n );\n for (const [argumentId, argument] of installedArguments) {\n const argumentPath = `${path}/arguments/${escapeJsonPointer(argumentId)}`;\n const replacementArgument = candidateArguments.get(argumentId);\n if (!replacementArgument) {\n addChange(changes, 'argument-removed', argumentPath, argument, null, true);\n continue;\n }\n for (const property of ['type', 'menu'] as const) {\n if (argument[property] !== replacementArgument[property]) {\n addChange(\n changes,\n `argument-${property}-changed`,\n `${argumentPath}/${property}`,\n argument[property] ?? null,\n replacementArgument[property] ?? null,\n true,\n );\n }\n }\n }\n for (const [argumentId, argument] of candidateArguments) {\n if (!installedArguments.has(argumentId)) {\n addChange(\n changes,\n 'argument-added',\n `${path}/arguments/${escapeJsonPointer(argumentId)}`,\n null,\n argument,\n true,\n );\n }\n }\n }\n for (const [opcode, block] of candidateBlocks) {\n if (!installedBlocks.has(opcode)) {\n addChange(changes, 'block-added', `/blocks/${escapeJsonPointer(opcode)}`, null, block, false);\n }\n }\n\n const installedMenus = new Map(installed.menus.map((menu) => [menu.id, menu]));\n const candidateMenus = new Map(candidate.menus.map((menu) => [menu.id, menu]));\n const referencedInstalledMenus = new Set<string>();\n for (const block of installed.blocks) {\n for (const argument of block.arguments) {\n if (argument.menu !== undefined) referencedInstalledMenus.add(argument.menu);\n }\n }\n for (const [menuId, menu] of installedMenus) {\n const path = `/menus/${escapeJsonPointer(menuId)}`;\n const replacement = candidateMenus.get(menuId);\n if (!replacement) {\n addChange(changes, 'menu-removed', path, menu, null, referencedInstalledMenus.has(menuId));\n } else if (menu.acceptReporters !== replacement.acceptReporters) {\n addChange(\n changes,\n 'menu-accept-reporters-changed',\n `${path}/acceptReporters`,\n menu.acceptReporters,\n replacement.acceptReporters,\n true,\n );\n }\n }\n for (const [menuId, menu] of candidateMenus) {\n if (!installedMenus.has(menuId)) {\n addChange(changes, 'menu-added', `/menus/${escapeJsonPointer(menuId)}`, null, menu, false);\n }\n }\n return changes.sort((left, right) =>\n left.path === right.path\n ? compareIds(left.kind, right.kind)\n : compareIds(left.path, right.path),\n );\n}\n\nexport function formatExtensionApiCompatibilityChanges(\n extensionId: string,\n changes: ExtensionApiCompatibilityChange[],\n): string {\n return changes\n .map(\n (change) =>\n `${extensionId} ${change.breaking ? 'breaking' : 'compatible'} ${change.kind} ${change.path}`,\n )\n .join('\\n');\n}\n"],"mappings":";;;;AAQA,IAAa,oCAAoC;AACjD,IAAa,uCAAuC;AAwCpD,SAAS,SAAS,OAAwC;CACxD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,sBACP,OACA,UACA,aACM;CACN,MAAM,qBAAqB,IAAI,IAAI,QAAQ;CAC3C,MAAM,aAAa,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,aAAa,CAAC,mBAAmB,IAAI,QAAQ,CAAC;CAC5F,OACE,WAAW,WAAW,GACtB,GAAG,YAAY,+BAA+B,WAAW,KAAK,IAAI,GACpE;AACF;AAEA,SAAS,qBAAqB,OAAgB,aAA6B;CACzE,OACE,OAAO,UAAU,YAAY,MAAM,SAAS,GAC5C,GAAG,YAAY,6BACjB;CACA,OAAO;AACT;AAEA,SAAS,WAAW,MAAc,OAAuB;CACvD,OAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,SAAS,kBAAkB,OAAuB;CAChD,OAAO,MAAM,WAAW,KAAK,IAAI,CAAC,CAAC,WAAW,KAAK,IAAI;AACzD;AAEA,SAAgB,8BAA8B,UAAuC;CACnF,OAAO,UAAU,WAAW,QAAQ,CAAC,CAAC,OAAO,Q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MAAM,MAAM,MAAM,yBAAyB,IAAI,MAAM,CAAC;OACpF,IAAI,KAAK,oBAAoB,YAAY,iBAC9C,UACE,SACA,iCACA,GAAG,KAAK,mBACR,KAAK,iBACL,YAAY,iBACZ,IACF;CAEJ;CACA,KAAK,MAAM,CAAC,QAAQ,SAAS,gBAC3B,IAAI,CAAC,eAAe,IAAI,MAAM,GAC5B,UAAU,SAAS,cAAc,UAAU,kBAAkB,MAAM,KAAK,MAAM,MAAM,KAAK;CAG7F,OAAO,QAAQ,MAAM,MAAM,UACzB,KAAK,SAAS,MAAM,OAChB,WAAW,KAAK,MAAM,MAAM,IAAI,IAChC,WAAW,KAAK,MAAM,MAAM,IAAI,CACtC;AACF;AAEA,SAAgB,uCACd,aACA,SACQ;CACR,OAAO,QACJ,KACE,WACC,GAAG,YAAY,GAAG,OAAO,WAAW,aAAa,aAAa,GAAG,OAAO,KAAK,GAAG,OAAO,MAC3F,CAAC,CACA,KAAK,IAAI;AACd"}
|
|
1
|
+
{"version":3,"file":"extension-api-manifest.js","names":[],"sources":["../src/extension-api-manifest.ts"],"sourcesContent":["// SPDX-License-Identifier: MPL-2.0\n\nimport {createHash} from 'node:crypto';\n\nimport {validateArchiveEntryName} from './archive';\nimport {assert, errorMessage} from './assert';\nimport type {EmbeddedExtension, ExtensionApiManifestSource, UnknownRecord} from './types';\n\n/** The version assumed when none is recorded; version 2 is also supported. */\nexport const extensionApiManifestFormatVersion = 1;\nexport const extensionApiManifestFormatVersions = [1, 2] as const;\nexport const defaultExtensionApiManifestSizeLimit = 1024 * 1024;\n\n/**\n * Version 2 carries the metadata a server-side compiler needs to lower a block into its own IR.\n *\n * These vocabularies match `@kubohiroya/turbowarp-extension-manifest`, which produces the manifests,\n * and the compiler manifest reader in `turbowarp-http-server`, which consumes them. A value accepted\n * here but rejected there would let an unusable extension through an update.\n */\nexport const extensionApiManifestResultTypes = [\n 'json',\n 'boolean',\n 'number',\n 'string',\n 'void',\n // A string whose content is serialized JSON or YAML, which `string` alone would not record.\n 'jsonText',\n 'yamlText',\n] as const;\nexport const extensionApiManifestEffects = [\n 'pure',\n 'immutable',\n 'control',\n 'request-read',\n 'response-write',\n 'storage-read',\n 'storage-write',\n 'binary-read',\n 'binary-write',\n 'state',\n] as const;\n\nexport type ExtensionApiManifestFormatVersion = (typeof extensionApiManifestFormatVersions)[number];\nexport type ExtensionApiManifestResultType = (typeof extensionApiManifestResultTypes)[number];\nexport type ExtensionApiManifestEffect = (typeof extensionApiManifestEffects)[number];\n\nexport interface ExtensionApiManifestServer {\n irOperation?: string;\n supported: boolean;\n}\n\nexport interface ExtensionApiManifestArgument {\n id: string;\n maximum?: number;\n menu?: string;\n minimum?: number;\n normalizesTo?: 'pathSegments';\n staticLiteral?: boolean;\n type: string;\n}\n\nexport interface ExtensionApiManifestBlock {\n arguments: ExtensionApiManifestArgument[];\n blockType: string;\n effect?: ExtensionApiManifestEffect;\n errors?: string[];\n immutable?: boolean;\n opcode: string;\n resultType?: ExtensionApiManifestResultType;\n server?: ExtensionApiManifestServer;\n}\n\nexport interface ExtensionApiManifestMenu {\n acceptReporters: boolean;\n id: string;\n}\n\nexport interface ExtensionApiManifestPathSegmentType {\n kind: 'discriminatedUnion';\n variants: {kind: string; valueType: string}[];\n}\n\nexport interface ExtensionApiManifestDataReferenceType {\n kind: string;\n lifetime: string;\n scope: string;\n valueType: string;\n}\n\nexport interface ExtensionApiManifest {\n blocks: ExtensionApiManifestBlock[];\n /** Version 2 only: what the values this extension hands out refer to, and for how long. */\n dataReferenceType?: ExtensionApiManifestDataReferenceType;\n formatVersion: number;\n id: string;\n menus: ExtensionApiManifestMenu[];\n /** Version 2 only: how a compiler should read the path arguments this extension takes. */\n pathSegmentType?: ExtensionApiManifestPathSegmentType;\n}\n\nexport interface ExtensionApiCompatibilityChange {\n after: unknown;\n before: unknown;\n breaking: boolean;\n kind: string;\n path: string;\n}\n\nexport interface ValidatedExtensionApiManifest {\n integrity: string;\n manifest: ExtensionApiManifest;\n metadata: ExtensionApiManifestSource;\n}\n\nexport interface ExtensionApiManifestParseSuccess {\n error: null;\n manifest: ExtensionApiManifest;\n}\n\nexport interface ExtensionApiManifestParseFailure {\n error: string;\n manifest: null;\n}\n\nexport type ExtensionApiManifestParseResult =\n ExtensionApiManifestParseSuccess | ExtensionApiManifestParseFailure;\n\nfunction isObject(value: unknown): value is UnknownRecord {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction assertExactProperties(\n value: UnknownRecord,\n expected: string[],\n description: string,\n): void {\n const expectedProperties = new Set(expected);\n const unexpected = Object.keys(value).filter((property) => !expectedProperties.has(property));\n assert(\n unexpected.length === 0,\n `${description} has unsupported properties: ${unexpected.join(', ')}`,\n );\n}\n\nfunction assertNonEmptyString(value: unknown, description: string): string {\n assert(\n typeof value === 'string' && value.length > 0,\n `${description} must be a non-empty string.`,\n );\n return value;\n}\n\nfunction compareIds(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction escapeJsonPointer(value: string): string {\n return value.replaceAll('~', '~0').replaceAll('/', '~1');\n}\n\nexport function extensionApiManifestIntegrity(contents: Uint8Array | string): string {\n return `sha256-${createHash('sha256').update(contents).digest('base64')}`;\n}\n\nexport function extensionApiManifestLocalPath(extensionId: string): string {\n return `extensions/${extensionId}.manifest.json`;\n}\n\nexport function validateExtensionApiManifestSourceMetadata(\n extension: EmbeddedExtension,\n): ExtensionApiManifestSource | null {\n const metadata: unknown = extension.source?.apiManifest;\n if (metadata === undefined) return null;\n assert(\n isObject(metadata),\n `Managed extension API manifest metadata must be an object: ${extension.id}`,\n );\n assertExactProperties(\n metadata,\n ['artifact', 'formatVersion', 'integrity', 'path'],\n `Managed extension API manifest metadata for ${extension.id}`,\n );\n assert(\n extensionApiManifestFormatVersions.includes(\n metadata.formatVersion as ExtensionApiManifestFormatVersion,\n ),\n `Managed extension ${extension.id} requires API manifest formatVersion ${extensionApiManifestFormatVersions.join(' or ')}.`,\n );\n const artifact = assertNonEmptyString(\n metadata.artifact,\n `Managed extension ${extension.id} API manifest artifact`,\n );\n validateArchiveEntryName(artifact);\n assert(\n !artifact.endsWith('/'),\n `Managed extension API manifest artifact must be a file: ${artifact}`,\n );\n const expectedPath = extensionApiManifestLocalPath(extension.id);\n assert(\n metadata.path === expectedPath,\n `Managed extension API manifest path must match its ID: expected ${expectedPath}, got ${metadata.path}`,\n );\n assert(\n typeof metadata.integrity === 'string' &&\n /^sha256-[A-Za-z0-9+/]{43}=$/u.test(metadata.integrity),\n `Managed extension ${extension.id} API manifest requires SHA-256 integrity.`,\n );\n return metadata as unknown as ExtensionApiManifestSource;\n}\n\nfunction normalizeArgument(\n value: unknown,\n blockOpcode: string,\n index: number,\n menuIds: Set<string>,\n formatVersion: ExtensionApiManifestFormatVersion,\n): ExtensionApiManifestArgument {\n assert(isObject(value), `API manifest block ${blockOpcode} argument ${index} must be an object.`);\n assertExactProperties(\n value,\n formatVersion === 1\n ? ['id', 'menu', 'type']\n : ['id', 'maximum', 'menu', 'minimum', 'normalizesTo', 'staticLiteral', 'type'],\n `API manifest block ${blockOpcode} argument ${index}`,\n );\n const id = assertNonEmptyString(\n value.id,\n `API manifest block ${blockOpcode} argument ${index} ID`,\n );\n const type = assertNonEmptyString(\n value.type,\n `API manifest block ${blockOpcode} argument ${id} type`,\n );\n const constraints =\n formatVersion === 1 ? {} : argumentConstraints(value, `${blockOpcode} argument ${id}`);\n if (value.menu === undefined) {\n return {id, type, ...constraints};\n }\n const menu = assertNonEmptyString(\n value.menu,\n `API manifest block ${blockOpcode} argument ${id} menu`,\n );\n assert(\n menuIds.has(menu),\n `API manifest block ${blockOpcode} argument ${id} references unknown menu: ${menu}`,\n );\n return {id, menu, type, ...constraints};\n}\n\nfunction argumentConstraints(\n value: UnknownRecord,\n label: string,\n): Partial<ExtensionApiManifestArgument> {\n const constraints: Partial<ExtensionApiManifestArgument> = {};\n if (value.normalizesTo !== undefined) {\n assert(\n value.normalizesTo === 'pathSegments',\n `API manifest block ${label} normalizesTo must be pathSegments.`,\n );\n constraints.normalizesTo = 'pathSegments';\n }\n if (value.staticLiteral !== undefined) {\n constraints.staticLiteral = assertBoolean(\n value.staticLiteral,\n `API manifest block ${label} staticLiteral`,\n );\n }\n for (const key of ['minimum', 'maximum'] as const) {\n const bound = value[key];\n if (bound === undefined) continue;\n assert(\n typeof bound === 'number' && Number.isFinite(bound),\n `API manifest block ${label} ${key} must be a finite number.`,\n );\n constraints[key] = bound;\n }\n return constraints;\n}\n\nfunction normalizeBlock(\n value: unknown,\n index: number,\n menuIds: Set<string>,\n formatVersion: ExtensionApiManifestFormatVersion,\n): ExtensionApiManifestBlock {\n assert(isObject(value), `API manifest block ${index} must be an object.`);\n assertExactProperties(\n value,\n formatVersion === 1\n ? ['arguments', 'blockType', 'opcode']\n : [\n 'arguments',\n 'blockType',\n 'effect',\n 'errors',\n 'immutable',\n 'opcode',\n 'resultType',\n 'server',\n ],\n `API manifest block ${index}`,\n );\n const opcode = assertNonEmptyString(value.opcode, `API manifest block ${index} opcode`);\n const blockType = assertNonEmptyString(value.blockType, `API manifest block ${opcode} blockType`);\n assert(\n Array.isArray(value.arguments),\n `API manifest block ${opcode} arguments must be an array.`,\n );\n const arguments_ = (value.arguments as unknown[]).map((argument, argumentIndex) =>\n normalizeArgument(argument, opcode, argumentIndex, menuIds, formatVersion),\n );\n const argumentIds = new Set<string>();\n for (const argument of arguments_) {\n assert(\n !argumentIds.has(argument.id),\n `API manifest block ${opcode} has duplicate argument ID: ${argument.id}`,\n );\n argumentIds.add(argument.id);\n }\n arguments_.sort((left, right) => compareIds(left.id, right.id));\n const block: ExtensionApiManifestBlock = {arguments: arguments_, blockType, opcode};\n if (formatVersion === 1) return block;\n return {\n ...block,\n effect: assertEnum(\n value.effect,\n extensionApiManifestEffects,\n `API manifest block ${opcode} effect`,\n ),\n errors: normalizeErrors(value.errors, opcode),\n immutable: assertBoolean(value.immutable, `API manifest block ${opcode} immutable`),\n resultType: assertEnum(\n value.resultType,\n extensionApiManifestResultTypes,\n `API manifest block ${opcode} resultType`,\n ),\n server: normalizeServer(value.server, opcode),\n };\n}\n\nfunction normalizeExtensionTypes(manifest: UnknownRecord): Partial<ExtensionApiManifest> {\n const types: Partial<ExtensionApiManifest> = {};\n if (manifest.pathSegmentType !== undefined) {\n const pathType = manifest.pathSegmentType;\n assert(isObject(pathType), 'API manifest pathSegmentType must be an object.');\n assertExactProperties(pathType, ['kind', 'variants'], 'API manifest pathSegmentType');\n assert(\n pathType.kind === 'discriminatedUnion',\n 'API manifest pathSegmentType kind must be discriminatedUnion.',\n );\n assert(\n Array.isArray(pathType.variants) && pathType.variants.length > 0,\n 'API manifest pathSegmentType variants must be a non-empty array.',\n );\n types.pathSegmentType = {\n kind: 'discriminatedUnion',\n variants: (pathType.variants as unknown[]).map((variant, index) => {\n const label = `API manifest pathSegmentType variants[${index}]`;\n assert(isObject(variant), `${label} must be an object.`);\n assertExactProperties(variant, ['kind', 'valueType'], label);\n return {\n kind: assertNonEmptyString(variant.kind, `${label} kind`),\n valueType: assertNonEmptyString(variant.valueType, `${label} valueType`),\n };\n }),\n };\n }\n if (manifest.dataReferenceType !== undefined) {\n const reference = manifest.dataReferenceType;\n assert(isObject(reference), 'API manifest dataReferenceType must be an object.');\n assertExactProperties(\n reference,\n ['kind', 'lifetime', 'scope', 'valueType'],\n 'API manifest dataReferenceType',\n );\n types.dataReferenceType = {\n kind: assertNonEmptyString(reference.kind, 'API manifest dataReferenceType kind'),\n lifetime: assertNonEmptyString(reference.lifetime, 'API manifest dataReferenceType lifetime'),\n scope: assertNonEmptyString(reference.scope, 'API manifest dataReferenceType scope'),\n valueType: assertNonEmptyString(\n reference.valueType,\n 'API manifest dataReferenceType valueType',\n ),\n };\n }\n return types;\n}\n\nfunction normalizeErrors(value: unknown, opcode: string): string[] {\n assert(Array.isArray(value), `API manifest block ${opcode} errors must be an array.`);\n // Error codes keep their declared order: the manifest documents them as a list, not a set.\n return (value as unknown[]).map((error, index) =>\n assertNonEmptyString(error, `API manifest block ${opcode} errors[${index}]`),\n );\n}\n\nfunction normalizeServer(value: unknown, opcode: string): ExtensionApiManifestServer {\n assert(isObject(value), `API manifest block ${opcode} server must be an object.`);\n assertExactProperties(value, ['irOperation', 'supported'], `API manifest block ${opcode} server`);\n const supported = assertBoolean(value.supported, `API manifest block ${opcode} server.supported`);\n if (value.irOperation === undefined) {\n assert(\n !supported,\n `API manifest block ${opcode} server.irOperation is required when supported is true.`,\n );\n return {supported};\n }\n return {\n irOperation: assertNonEmptyString(\n value.irOperation,\n `API manifest block ${opcode} server.irOperation`,\n ),\n supported,\n };\n}\n\nfunction assertBoolean(value: unknown, label: string): boolean {\n assert(typeof value === 'boolean', `${label} must be a boolean.`);\n return value;\n}\n\nfunction assertEnum<T extends string>(value: unknown, allowed: readonly T[], label: string): T {\n assert(\n typeof value === 'string' && allowed.includes(value as T),\n `${label} must be one of: ${allowed.join(', ')}.`,\n );\n return value as T;\n}\n\nfunction normalizeMenu(value: unknown, index: number): ExtensionApiManifestMenu {\n assert(isObject(value), `API manifest menu ${index} must be an object.`);\n assertExactProperties(value, ['acceptReporters', 'id'], `API manifest menu ${index}`);\n const id = assertNonEmptyString(value.id, `API manifest menu ${index} ID`);\n assert(\n typeof value.acceptReporters === 'boolean',\n `API manifest menu ${id} acceptReporters must be a boolean.`,\n );\n return {acceptReporters: value.acceptReporters, id};\n}\n\nexport function parseExtensionApiManifest(\n contents: Uint8Array | string,\n {expectedId}: {expectedId?: string} = {},\n): ExtensionApiManifest {\n let manifest: unknown;\n try {\n manifest = JSON.parse(Buffer.from(contents).toString('utf8'));\n } catch (error) {\n throw new Error(`Extension API manifest is not valid JSON: ${errorMessage(error)}`, {\n cause: error,\n });\n }\n assert(isObject(manifest), 'Extension API manifest must contain an object.');\n assertExactProperties(\n manifest,\n isObject(manifest) && manifest.formatVersion === 2\n ? ['blocks', 'dataReferenceType', 'formatVersion', 'id', 'menus', 'pathSegmentType']\n : ['blocks', 'formatVersion', 'id', 'menus'],\n 'Extension API manifest',\n );\n const formatVersion = manifest.formatVersion as ExtensionApiManifestFormatVersion;\n assert(\n extensionApiManifestFormatVersions.includes(formatVersion),\n `Unsupported extension API manifest formatVersion: ${manifest.formatVersion}`,\n );\n assert(\n typeof manifest.id === 'string' && /^[a-z0-9]+$/u.test(manifest.id),\n `Invalid extension API manifest ID: ${JSON.stringify(manifest.id)}`,\n );\n if (expectedId !== undefined) {\n assert(\n manifest.id === expectedId,\n `Extension API manifest ID mismatch: expected ${expectedId}, got ${manifest.id}`,\n );\n }\n assert(Array.isArray(manifest.menus), 'Extension API manifest menus must be an array.');\n const menus = (manifest.menus as unknown[]).map(normalizeMenu);\n const menuIds = new Set<string>();\n for (const menu of menus) {\n assert(!menuIds.has(menu.id), `Extension API manifest has duplicate menu ID: ${menu.id}`);\n menuIds.add(menu.id);\n }\n assert(Array.isArray(manifest.blocks), 'Extension API manifest blocks must be an array.');\n const blocks = (manifest.blocks as unknown[]).map((block, index) =>\n normalizeBlock(block, index, menuIds, formatVersion),\n );\n const blockOpcodes = new Set<string>();\n for (const block of blocks) {\n assert(\n !blockOpcodes.has(block.opcode),\n `Extension API manifest has duplicate block opcode: ${block.opcode}`,\n );\n blockOpcodes.add(block.opcode);\n }\n blocks.sort((left, right) => compareIds(left.opcode, right.opcode));\n menus.sort((left, right) => compareIds(left.id, right.id));\n return {\n blocks,\n formatVersion,\n id: manifest.id,\n menus,\n ...(formatVersion === 1 ? {} : normalizeExtensionTypes(manifest)),\n };\n}\n\n/**\n * Parse an extension API manifest without throwing.\n *\n * `parseExtensionApiManifest` aborts on the first problem, which suits callers\n * that treat an invalid manifest as fatal. Callers that audit several manifests\n * and report every failure together need the error as a value instead.\n */\nexport function tryParseExtensionApiManifest(\n contents: Uint8Array | string,\n options: {expectedId?: string} = {},\n): ExtensionApiManifestParseResult {\n try {\n return {error: null, manifest: parseExtensionApiManifest(contents, options)};\n } catch (error) {\n return {error: errorMessage(error), manifest: null};\n }\n}\n\nexport function validateManagedExtensionApiManifest(\n extension: EmbeddedExtension,\n contents: Uint8Array | string,\n {expectedId = extension.id}: {expectedId?: string} = {},\n): ValidatedExtensionApiManifest | null {\n const metadata = validateExtensionApiManifestSourceMetadata(extension);\n if (!metadata) return null;\n const actualIntegrity = extensionApiManifestIntegrity(contents);\n assert(\n actualIntegrity === metadata.integrity,\n `Managed extension API manifest integrity mismatch for ${extension.id}: ` +\n `expected ${metadata.integrity}, got ${actualIntegrity}`,\n );\n const manifest = parseExtensionApiManifest(contents, {expectedId});\n assert(\n manifest.formatVersion === metadata.formatVersion,\n `Managed extension API manifest version mismatch for ${extension.id}.`,\n );\n return {integrity: actualIntegrity, manifest, metadata};\n}\n\n/**\n * Compares the format version 2 metadata of one block.\n *\n * Every change to a declared contract counts as breaking, in both directions: a consumer can rely on\n * a block being immutable just as readily as on it not being. The two exceptions are a block gaining\n * server support and a block declaring a new error code, which only widen what the block offers.\n */\nfunction compareBlockMetadata(\n changes: ExtensionApiCompatibilityChange[],\n installed: ExtensionApiManifestBlock,\n candidate: ExtensionApiManifestBlock,\n path: string,\n): void {\n for (const property of ['resultType', 'effect', 'immutable'] as const) {\n if (installed[property] !== candidate[property]) {\n addChange(\n changes,\n `block-${property}-changed`,\n `${path}/${property}`,\n installed[property] ?? null,\n candidate[property] ?? null,\n true,\n );\n }\n }\n\n const installedErrors = new Set(installed.errors ?? []);\n const candidateErrors = new Set(candidate.errors ?? []);\n for (const code of installedErrors) {\n if (!candidateErrors.has(code)) {\n addChange(changes, 'block-error-removed', `${path}/errors`, code, null, true);\n }\n }\n for (const code of candidateErrors) {\n if (!installedErrors.has(code)) {\n addChange(changes, 'block-error-added', `${path}/errors`, null, code, false);\n }\n }\n\n const installedServer = installed.server;\n const candidateServer = candidate.server;\n if (installedServer?.supported !== candidateServer?.supported) {\n addChange(\n changes,\n 'block-server-supported-changed',\n `${path}/server/supported`,\n installedServer?.supported ?? null,\n candidateServer?.supported ?? null,\n installedServer?.supported === true,\n );\n }\n if (installedServer?.irOperation !== candidateServer?.irOperation) {\n addChange(\n changes,\n 'block-server-ir-operation-changed',\n `${path}/server/irOperation`,\n installedServer?.irOperation ?? null,\n candidateServer?.irOperation ?? null,\n true,\n );\n }\n}\n\nfunction addChange(\n changes: ExtensionApiCompatibilityChange[],\n kind: string,\n path: string,\n before: unknown,\n after: unknown,\n breaking: boolean,\n): void {\n changes.push({after, before, breaking, kind, path});\n}\n\nexport function compareExtensionApiManifests(\n installed: ExtensionApiManifest,\n candidate: ExtensionApiManifest,\n): ExtensionApiCompatibilityChange[] {\n const changes: ExtensionApiCompatibilityChange[] = [];\n if (installed.formatVersion !== candidate.formatVersion) {\n // Going up adds metadata, which no existing consumer was reading. Going down removes metadata a\n // server-side compiler may already lower against, so that direction breaks.\n addChange(\n changes,\n 'format-version-changed',\n '/formatVersion',\n installed.formatVersion,\n candidate.formatVersion,\n candidate.formatVersion < installed.formatVersion,\n );\n }\n const installedBlocks = new Map(installed.blocks.map((block) => [block.opcode, block]));\n const candidateBlocks = new Map(candidate.blocks.map((block) => [block.opcode, block]));\n for (const [opcode, block] of installedBlocks) {\n const path = `/blocks/${escapeJsonPointer(opcode)}`;\n const replacement = candidateBlocks.get(opcode);\n if (!replacement) {\n addChange(changes, 'block-removed', path, block, null, true);\n continue;\n }\n if (block.blockType !== replacement.blockType) {\n addChange(\n changes,\n 'block-type-changed',\n `${path}/blockType`,\n block.blockType,\n replacement.blockType,\n true,\n );\n }\n compareBlockMetadata(changes, block, replacement, path);\n const installedArguments = new Map(block.arguments.map((argument) => [argument.id, argument]));\n const candidateArguments = new Map(\n replacement.arguments.map((argument) => [argument.id, argument]),\n );\n for (const [argumentId, argument] of installedArguments) {\n const argumentPath = `${path}/arguments/${escapeJsonPointer(argumentId)}`;\n const replacementArgument = candidateArguments.get(argumentId);\n if (!replacementArgument) {\n addChange(changes, 'argument-removed', argumentPath, argument, null, true);\n continue;\n }\n for (const property of [\n 'type',\n 'menu',\n 'normalizesTo',\n 'staticLiteral',\n 'minimum',\n 'maximum',\n ] as const) {\n if (argument[property] !== replacementArgument[property]) {\n addChange(\n changes,\n `argument-${property}-changed`,\n `${argumentPath}/${property}`,\n argument[property] ?? null,\n replacementArgument[property] ?? null,\n true,\n );\n }\n }\n }\n for (const [argumentId, argument] of candidateArguments) {\n if (!installedArguments.has(argumentId)) {\n addChange(\n changes,\n 'argument-added',\n `${path}/arguments/${escapeJsonPointer(argumentId)}`,\n null,\n argument,\n true,\n );\n }\n }\n }\n for (const [opcode, block] of candidateBlocks) {\n if (!installedBlocks.has(opcode)) {\n addChange(changes, 'block-added', `/blocks/${escapeJsonPointer(opcode)}`, null, block, false);\n }\n }\n\n const installedMenus = new Map(installed.menus.map((menu) => [menu.id, menu]));\n const candidateMenus = new Map(candidate.menus.map((menu) => [menu.id, menu]));\n const referencedInstalledMenus = new Set<string>();\n for (const block of installed.blocks) {\n for (const argument of block.arguments) {\n if (argument.menu !== undefined) referencedInstalledMenus.add(argument.menu);\n }\n }\n for (const [menuId, menu] of installedMenus) {\n const path = `/menus/${escapeJsonPointer(menuId)}`;\n const replacement = candidateMenus.get(menuId);\n if (!replacement) {\n addChange(changes, 'menu-removed', path, menu, null, referencedInstalledMenus.has(menuId));\n } else if (menu.acceptReporters !== replacement.acceptReporters) {\n addChange(\n changes,\n 'menu-accept-reporters-changed',\n `${path}/acceptReporters`,\n menu.acceptReporters,\n replacement.acceptReporters,\n true,\n );\n }\n }\n for (const [menuId, menu] of candidateMenus) {\n if (!installedMenus.has(menuId)) {\n addChange(changes, 'menu-added', `/menus/${escapeJsonPointer(menuId)}`, null, menu, false);\n }\n }\n return changes.sort((left, right) =>\n left.path === right.path\n ? compareIds(left.kind, right.kind)\n : compareIds(left.path, right.path),\n );\n}\n\nexport function formatExtensionApiCompatibilityChanges(\n extensionId: string,\n changes: ExtensionApiCompatibilityChange[],\n): string {\n return changes\n .map(\n (change) =>\n `${extensionId} ${change.breaking ? 'breaking' : 'compatible'} ${change.kind} ${change.path}`,\n )\n .join('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
export { packageName, packageVersion } from './constants';
|
|
6
6
|
export { extensionHeaderId, extensionHeaderMetadata, extensionIntegrity, validateExtensionSourceMetadata, validateManagedExtensionContents, } from './extension-dependencies';
|
|
7
|
-
export { compareExtensionApiManifests, defaultExtensionApiManifestSizeLimit, extensionApiManifestFormatVersion, extensionApiManifestIntegrity, extensionApiManifestLocalPath, formatExtensionApiCompatibilityChanges, parseExtensionApiManifest, validateExtensionApiManifestSourceMetadata, validateManagedExtensionApiManifest, } from './extension-api-manifest';
|
|
7
|
+
export { compareExtensionApiManifests, defaultExtensionApiManifestSizeLimit, extensionApiManifestEffects, extensionApiManifestFormatVersion, extensionApiManifestFormatVersions, extensionApiManifestIntegrity, extensionApiManifestLocalPath, extensionApiManifestResultTypes, formatExtensionApiCompatibilityChanges, parseExtensionApiManifest, tryParseExtensionApiManifest, validateExtensionApiManifestSourceMetadata, validateManagedExtensionApiManifest, } from './extension-api-manifest';
|
|
8
8
|
export { bundleExtensions, planExtensionBundle, planExtensionUnbundle, unbundleExtensions, } from './extension-bundle-configuration';
|
|
9
9
|
export { planBundledSb3Unbundle, unbundleSb3 } from './extension-bundle-archive';
|
|
10
10
|
export { buildExtensionBundles, createStaticExtensionBundle, extensionBundleRecoveryMarker, validateExtensionBundleConfigurations, } from './extension-bundle';
|
|
@@ -18,7 +18,7 @@ export { assertSb3ReleaseSnapshotMetadata, computeReleaseSourceIdentity, createS
|
|
|
18
18
|
export { cleanUpTurboWarpBlocks, turboWarpCleanUpLayout } from './turbowarp-clean-up';
|
|
19
19
|
export type { BuildSb3Options, WriteSb3ArchiveOptions, WriteSb3ArchiveResult } from './build';
|
|
20
20
|
export type { CliOptions } from './cli';
|
|
21
|
-
export type { ExtensionApiCompatibilityChange, ExtensionApiManifest, ExtensionApiManifestArgument, ExtensionApiManifestBlock, ExtensionApiManifestMenu, } from './extension-api-manifest';
|
|
21
|
+
export type { ExtensionApiCompatibilityChange, ExtensionApiManifest, ExtensionApiManifestArgument, ExtensionApiManifestBlock, ExtensionApiManifestDataReferenceType, ExtensionApiManifestEffect, ExtensionApiManifestFormatVersion, ExtensionApiManifestMenu, ExtensionApiManifestParseFailure, ExtensionApiManifestParseResult, ExtensionApiManifestParseSuccess, ExtensionApiManifestPathSegmentType, ExtensionApiManifestResultType, ExtensionApiManifestServer, } from './extension-api-manifest';
|
|
22
22
|
export type { BuildExtensionBundlesResult, ExtensionBundleComponent, ExtensionBundleCounts, ExtensionBundlePlan, } from './extension-bundle';
|
|
23
23
|
export type { BundledSb3UnbundlePlan } from './extension-bundle-archive';
|
|
24
24
|
export type { ExtensionIdMigrationCounts, ExtensionIdReference, RewriteExtensionIdDocumentsResult, } from './extension-id-migration';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { assert } from "./assert.js";
|
|
2
2
|
import { compareDirectories, inspectGitOutputState, validateOutputDirectoryPath } from "./output-safety.js";
|
|
3
3
|
import { validateArchiveEntryName } from "./archive.js";
|
|
4
|
-
import { compareExtensionApiManifests, defaultExtensionApiManifestSizeLimit, extensionApiManifestFormatVersion, extensionApiManifestIntegrity, extensionApiManifestLocalPath, formatExtensionApiCompatibilityChanges, parseExtensionApiManifest, validateExtensionApiManifestSourceMetadata, validateManagedExtensionApiManifest } from "./extension-api-manifest.js";
|
|
4
|
+
import { compareExtensionApiManifests, defaultExtensionApiManifestSizeLimit, extensionApiManifestEffects, extensionApiManifestFormatVersion, extensionApiManifestFormatVersions, extensionApiManifestIntegrity, extensionApiManifestLocalPath, extensionApiManifestResultTypes, formatExtensionApiCompatibilityChanges, parseExtensionApiManifest, tryParseExtensionApiManifest, validateExtensionApiManifestSourceMetadata, validateManagedExtensionApiManifest } from "./extension-api-manifest.js";
|
|
5
5
|
import { extensionHeaderId, extensionHeaderMetadata, extensionIntegrity, validateExtensionSourceMetadata, validateManagedExtensionContents } from "./extension-dependencies.js";
|
|
6
6
|
import { buildExtensionBundles, createStaticExtensionBundle, extensionBundleRecoveryMarker, validateExtensionBundleConfigurations } from "./extension-bundle.js";
|
|
7
7
|
import { applyProjectAssetAdditions, projectAssetAdditionsFormatVersion } from "./project-asset-additions.js";
|
|
@@ -15,4 +15,4 @@ import { bundleExtensions, planExtensionBundle, planExtensionUnbundle, unbundleE
|
|
|
15
15
|
import { migrateExtensionId, planExtensionIdMigration, validateNewExtensionId } from "./extension-id-migration.js";
|
|
16
16
|
import { defaultExtensionArtifactSizeLimit, extensionStatus, syncExtensions, updateExtensions } from "./extension-sync.js";
|
|
17
17
|
import { assertSb3ReleaseSnapshotMetadata, computeReleaseSourceIdentity, createSb3ReleaseSnapshot, createSb3ReleaseSnapshotMetadata, freezeSb3ReleaseSnapshot, readSb3ReleaseSnapshotMetadata, recordPublishedSb3ReleaseSnapshot, verifySb3ReleaseSnapshot, writeSb3ReleaseCandidate } from "./release-snapshot.js";
|
|
18
|
-
export { applyProjectAssetAdditions, assert, assertSb3ReleaseSnapshotMetadata, buildExtensionBundles, buildSb3, bundleExtensions, cleanUpTurboWarpBlocks, compareDirectories, compareExtensionApiManifests, computeReleaseSourceIdentity, createDeterministicSb3, createSb3ReleaseSnapshot, createSb3ReleaseSnapshotMetadata, createStaticExtensionBundle, decodeExtensionDataUrl, defaultExtensionApiManifestSizeLimit, defaultExtensionArtifactSizeLimit, extensionApiManifestFormatVersion, extensionApiManifestIntegrity, extensionApiManifestLocalPath, extensionBundleRecoveryMarker, extensionHeaderId, extensionHeaderMetadata, extensionIntegrity, extensionStatus, fixedZipTimestamp, formatExtensionApiCompatibilityChanges, freezeSb3ReleaseSnapshot, importSb3, inspectGitOutputState, migrateExtensionId, packageName, packageVersion, parseExtensionApiManifest, planBundledSb3Unbundle, planExtensionBundle, planExtensionIdMigration, planExtensionUnbundle, projectAssetAdditionsFormatVersion, readSb3ReleaseSnapshotMetadata, recordPublishedSb3ReleaseSnapshot, sourceFormatVersion, syncExtensions, turboWarpCleanUpLayout, unbundleExtensions, unbundleSb3, updateExtensions, validateArchiveEntryName, validateExtensionApiManifestSourceMetadata, validateExtensionBundleConfigurations, validateExtensionSourceMetadata, validateManagedExtensionApiManifest, validateManagedExtensionContents, validateNewExtensionId, validateOutputDirectoryPath, validateSb3Source, verifySb3ReleaseSnapshot, writeSb3ReleaseCandidate };
|
|
18
|
+
export { applyProjectAssetAdditions, assert, assertSb3ReleaseSnapshotMetadata, buildExtensionBundles, buildSb3, bundleExtensions, cleanUpTurboWarpBlocks, compareDirectories, compareExtensionApiManifests, computeReleaseSourceIdentity, createDeterministicSb3, createSb3ReleaseSnapshot, createSb3ReleaseSnapshotMetadata, createStaticExtensionBundle, decodeExtensionDataUrl, defaultExtensionApiManifestSizeLimit, defaultExtensionArtifactSizeLimit, extensionApiManifestEffects, extensionApiManifestFormatVersion, extensionApiManifestFormatVersions, extensionApiManifestIntegrity, extensionApiManifestLocalPath, extensionApiManifestResultTypes, extensionBundleRecoveryMarker, extensionHeaderId, extensionHeaderMetadata, extensionIntegrity, extensionStatus, fixedZipTimestamp, formatExtensionApiCompatibilityChanges, freezeSb3ReleaseSnapshot, importSb3, inspectGitOutputState, migrateExtensionId, packageName, packageVersion, parseExtensionApiManifest, planBundledSb3Unbundle, planExtensionBundle, planExtensionIdMigration, planExtensionUnbundle, projectAssetAdditionsFormatVersion, readSb3ReleaseSnapshotMetadata, recordPublishedSb3ReleaseSnapshot, sourceFormatVersion, syncExtensions, tryParseExtensionApiManifest, turboWarpCleanUpLayout, unbundleExtensions, unbundleSb3, updateExtensions, validateArchiveEntryName, validateExtensionApiManifestSourceMetadata, validateExtensionBundleConfigurations, validateExtensionSourceMetadata, validateManagedExtensionApiManifest, validateManagedExtensionContents, validateNewExtensionId, validateOutputDirectoryPath, validateSb3Source, verifySb3ReleaseSnapshot, writeSb3ReleaseCandidate };
|
|
@@ -61,7 +61,21 @@ Add `apiManifest` below an existing GitHub `source` object:
|
|
|
61
61
|
|
|
62
62
|
- `artifact` is the manifest path in the GitHub repository.
|
|
63
63
|
- `path` must be `extensions/<extensionId>.manifest.json` in expanded source.
|
|
64
|
-
- `formatVersion` must be `1`.
|
|
64
|
+
- `formatVersion` must be `1` or `2`.
|
|
65
|
+
|
|
66
|
+
Version 2 adds, on every block, the metadata a server-side compiler needs to lower it: `resultType`,
|
|
67
|
+
`effect`, `immutable`, `errors` and `server`. Arguments may additionally carry `normalizesTo`,
|
|
68
|
+
`staticLiteral`, `minimum` and `maximum`. All five block fields are required together, and `effect`
|
|
69
|
+
must be one of `pure`, `immutable`, `control`, `request-read`, `response-write`, `storage-read`,
|
|
70
|
+
`storage-write`, `binary-read` or `binary-write`.
|
|
71
|
+
|
|
72
|
+
A comparison reports every change to that metadata as breaking, in both directions: a project can
|
|
73
|
+
rely on a block being immutable just as readily as on it not being. The two exceptions are a block
|
|
74
|
+
gaining server support and a block declaring a new error code, which only widen what the block
|
|
75
|
+
offers. A rise from version 1 to version 2 is compatible, because it only adds metadata no existing
|
|
76
|
+
project was reading; a fall from 2 to 1 is breaking, because it removes metadata a server may
|
|
77
|
+
already lower against.
|
|
78
|
+
|
|
65
79
|
- `integrity` is the SHA-256 SRI value of the installed manifest file.
|
|
66
80
|
|
|
67
81
|
The JavaScript and manifest artifacts use the same repository and `resolvedCommit`. Separate
|
|
@@ -60,7 +60,20 @@ flowchart LR
|
|
|
60
60
|
|
|
61
61
|
- `artifact`はGitHubリポジトリ内のマニフェストのパスです。
|
|
62
62
|
- `path`は展開ソース内の`extensions/<extensionId>.manifest.json`でなければなりません。
|
|
63
|
-
- `formatVersion`は`1`でなければなりません。
|
|
63
|
+
- `formatVersion`は`1`または`2`でなければなりません。
|
|
64
|
+
|
|
65
|
+
バージョン2は、サーバー側コンパイラがブロックをloweringするために必要なメタデータを各ブロックに追加します。
|
|
66
|
+
`resultType`、`effect`、`immutable`、`errors`、`server`です。引数はさらに`normalizesTo`、`staticLiteral`、
|
|
67
|
+
`minimum`、`maximum`を持てます。ブロックの5つのフィールドは揃って必須で、`effect`は`pure`、`immutable`、
|
|
68
|
+
`control`、`request-read`、`response-write`、`storage-read`、`storage-write`、`binary-read`、
|
|
69
|
+
`binary-write`のいずれかでなければなりません。
|
|
70
|
+
|
|
71
|
+
比較では、このメタデータの変更はどちら向きでも破壊的として報告します。ブロックがimmutableであることに
|
|
72
|
+
プロジェクトが依存しうるのと同様に、immutableでないことにも依存しうるためです。例外は2つで、ブロックが
|
|
73
|
+
サーバー対応を獲得した場合と、新しいエラーコードを宣言した場合です。どちらもブロックの提供範囲を広げる
|
|
74
|
+
だけです。バージョン1から2への上昇は互換です。既存のプロジェクトが読んでいなかったメタデータを追加する
|
|
75
|
+
だけだからです。2から1への下降は破壊的です。サーバーが既にloweringに使っているメタデータを失うためです。
|
|
76
|
+
|
|
64
77
|
- `integrity`はインストール済みマニフェストファイルのSHA-256 SRI値です。
|
|
65
78
|
|
|
66
79
|
JavaScript成果物とマニフェスト成果物は、同じリポジトリと`resolvedCommit`を使用します。別のリポジトリや
|
|
@@ -97,7 +97,7 @@ npmパッケージから管理する機能拡張には、任意の`source`メタ
|
|
|
97
97
|
- `apiManifest`: 任意で使用するAPI互換性メタデータ
|
|
98
98
|
- `artifact`: 同じGitHubリポジトリを基準にしたAPIマニフェストのパス
|
|
99
99
|
- `path`: 必須のローカルパス`extensions/<extensionId>.manifest.json`
|
|
100
|
-
- `formatVersion`:
|
|
100
|
+
- `formatVersion`: 対応するマニフェスト形式。`1`または`2`
|
|
101
101
|
- `integrity`: インストール済みマニフェストのSRI形式SHA-256
|
|
102
102
|
|
|
103
103
|
検証とビルドでは、ネットワークへ接続せずに管理対象機能拡張を検証します。
|
package/docs/source-format-v1.md
CHANGED
|
@@ -98,7 +98,7 @@ For an exact npm dependency, replace the GitHub-specific fields with the package
|
|
|
98
98
|
- `apiManifest`: optional, opt-in API compatibility metadata
|
|
99
99
|
- `artifact`: API manifest path relative to the same GitHub repository
|
|
100
100
|
- `path`: required local path `extensions/<extensionId>.manifest.json`
|
|
101
|
-
- `formatVersion`: supported manifest format,
|
|
101
|
+
- `formatVersion`: supported manifest format, `1` or `2`
|
|
102
102
|
- `integrity`: SRI-form SHA-256 of the installed manifest
|
|
103
103
|
|
|
104
104
|
Validation and builds verify managed extensions without accessing the network:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/sb3-toolchain",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Git-friendly source management and deterministic builds for Scratch 3 and TurboWarp SB3 projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -36,6 +36,21 @@
|
|
|
36
36
|
"access": "public",
|
|
37
37
|
"registry": "https://registry.npmjs.org/"
|
|
38
38
|
},
|
|
39
|
+
"packageManager": "pnpm@11.11.0",
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "vite build",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"format": "prettier --check .github docs scripts src test CHANGELOG.md eslint.config.ts package.json README.md README.ja.md repo-policy.json tsconfig.json vite.config.ts",
|
|
44
|
+
"format:write": "prettier --write .github docs scripts src test CHANGELOG.md eslint.config.ts package.json README.md README.ja.md repo-policy.json tsconfig.json vite.config.ts",
|
|
45
|
+
"typecheck": "tsc --project tsconfig.json",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest",
|
|
48
|
+
"pack:check": "npm pack --dry-run --ignore-scripts",
|
|
49
|
+
"release:check": "npm publish --dry-run --access public",
|
|
50
|
+
"repo:check": "node --experimental-strip-types scripts/check-repo.ts",
|
|
51
|
+
"check": "pnpm run lint && pnpm run format && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run repo:check && pnpm run pack:check",
|
|
52
|
+
"prepack": "pnpm run check"
|
|
53
|
+
},
|
|
39
54
|
"dependencies": {
|
|
40
55
|
"fflate": "0.8.3",
|
|
41
56
|
"music-metadata": "11.14.0",
|
|
@@ -62,18 +77,5 @@
|
|
|
62
77
|
"turbowarp",
|
|
63
78
|
"source-control",
|
|
64
79
|
"reproducible-builds"
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
"build": "vite build",
|
|
68
|
-
"lint": "eslint .",
|
|
69
|
-
"format": "prettier --check .github docs scripts src test CHANGELOG.md eslint.config.ts package.json README.md README.ja.md repo-policy.json tsconfig.json vite.config.ts",
|
|
70
|
-
"format:write": "prettier --write .github docs scripts src test CHANGELOG.md eslint.config.ts package.json README.md README.ja.md repo-policy.json tsconfig.json vite.config.ts",
|
|
71
|
-
"typecheck": "tsc --project tsconfig.json",
|
|
72
|
-
"test": "vitest run",
|
|
73
|
-
"test:watch": "vitest",
|
|
74
|
-
"pack:check": "npm pack --dry-run --ignore-scripts",
|
|
75
|
-
"release:check": "npm publish --dry-run --access public",
|
|
76
|
-
"repo:check": "node --experimental-strip-types scripts/check-repo.ts",
|
|
77
|
-
"check": "pnpm run lint && pnpm run format && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run repo:check && pnpm run pack:check"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
+
]
|
|
81
|
+
}
|