@bufbuild/protoplugin 2.10.2 → 2.12.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/dist/cjs/create-es-plugin.d.ts +7 -7
- package/dist/cjs/create-es-plugin.js +2 -2
- package/dist/cjs/error.js +1 -1
- package/dist/cjs/file-preamble.d.ts +1 -1
- package/dist/cjs/file-preamble.js +11 -3
- package/dist/cjs/generated-file.js +1 -1
- package/dist/cjs/import-path.js +1 -1
- package/dist/cjs/import-symbol.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/jsdoc.js +1 -1
- package/dist/cjs/names.js +1 -1
- package/dist/cjs/parameter.d.ts +6 -0
- package/dist/cjs/parameter.js +17 -1
- package/dist/cjs/plugin.js +1 -1
- package/dist/cjs/printable.d.ts +1 -1
- package/dist/cjs/printable.js +1 -1
- package/dist/cjs/run-node.js +7 -2
- package/dist/cjs/runtime-imports.js +1 -1
- package/dist/cjs/safe-identifier.js +1 -1
- package/dist/cjs/schema.d.ts +1 -1
- package/dist/cjs/schema.js +6 -1
- package/dist/cjs/source-code-info.js +1 -1
- package/dist/cjs/transpile.js +6 -4
- package/dist/esm/create-es-plugin.d.ts +7 -7
- package/dist/esm/create-es-plugin.js +2 -2
- package/dist/esm/error.js +1 -1
- package/dist/esm/file-preamble.d.ts +1 -1
- package/dist/esm/file-preamble.js +11 -3
- package/dist/esm/generated-file.js +1 -1
- package/dist/esm/import-path.js +1 -1
- package/dist/esm/import-symbol.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/jsdoc.js +1 -1
- package/dist/esm/names.js +1 -1
- package/dist/esm/parameter.d.ts +6 -0
- package/dist/esm/parameter.js +17 -1
- package/dist/esm/plugin.js +1 -1
- package/dist/esm/printable.d.ts +1 -1
- package/dist/esm/printable.js +1 -1
- package/dist/esm/run-node.js +7 -2
- package/dist/esm/runtime-imports.js +1 -1
- package/dist/esm/safe-identifier.js +1 -1
- package/dist/esm/schema.d.ts +1 -1
- package/dist/esm/schema.js +6 -1
- package/dist/esm/source-code-info.js +1 -1
- package/dist/esm/transpile.js +6 -4
- package/package.json +2 -2
|
@@ -30,20 +30,20 @@ interface PluginInit<Options extends object> {
|
|
|
30
30
|
* If your plugin does not recognize an option, it must throw an Error in
|
|
31
31
|
* parseOptions.
|
|
32
32
|
*/
|
|
33
|
-
parseOptions?: (rawOptions: {
|
|
33
|
+
parseOptions?: ((rawOptions: {
|
|
34
34
|
key: string;
|
|
35
35
|
value: string;
|
|
36
|
-
}[]) => Options;
|
|
36
|
+
}[]) => Options) | undefined;
|
|
37
37
|
/**
|
|
38
38
|
* The earliest edition supported by this plugin. Defaults to the minimum
|
|
39
39
|
* edition supported by @bufbuild/protobuf.
|
|
40
40
|
*/
|
|
41
|
-
minimumEdition?: SupportedEdition;
|
|
41
|
+
minimumEdition?: SupportedEdition | undefined;
|
|
42
42
|
/**
|
|
43
43
|
* The latest edition supported by this plugin. Defaults to the maximum
|
|
44
44
|
* edition supported by @bufbuild/protobuf.
|
|
45
45
|
*/
|
|
46
|
-
maximumEdition?: SupportedEdition;
|
|
46
|
+
maximumEdition?: SupportedEdition | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* A function which will generate TypeScript files based on proto input.
|
|
49
49
|
* This function will be invoked by the plugin framework when the plugin runs.
|
|
@@ -61,7 +61,7 @@ interface PluginInit<Options extends object> {
|
|
|
61
61
|
* JavaScript files. If not, the plugin framework will transpile the files
|
|
62
62
|
* itself.
|
|
63
63
|
*/
|
|
64
|
-
generateJs?: (schema: Schema<Options>, target: "js") => void;
|
|
64
|
+
generateJs?: ((schema: Schema<Options>, target: "js") => void) | undefined;
|
|
65
65
|
/**
|
|
66
66
|
* A optional function which will generate TypeScript declaration files
|
|
67
67
|
* based on proto input. This function will be invoked by the plugin
|
|
@@ -72,7 +72,7 @@ interface PluginInit<Options extends object> {
|
|
|
72
72
|
* declaration files. If not, the plugin framework will transpile the files
|
|
73
73
|
* itself.
|
|
74
74
|
*/
|
|
75
|
-
generateDts?: (schema: Schema<Options>, target: "dts") => void;
|
|
75
|
+
generateDts?: ((schema: Schema<Options>, target: "dts") => void) | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* An optional function which will transpile a given set of files.
|
|
78
78
|
*
|
|
@@ -86,7 +86,7 @@ interface PluginInit<Options extends object> {
|
|
|
86
86
|
* transpiling to JS. If jsImportStyle is "legacy_commonjs", the function is
|
|
87
87
|
* expected to use CommonJs require() and exports when transpiling to JS.
|
|
88
88
|
*/
|
|
89
|
-
transpile?: (files: FileInfo[], transpileJs: boolean, transpileDts: boolean, jsImportStyle: "module" | "legacy_commonjs") => FileInfo[];
|
|
89
|
+
transpile?: ((files: FileInfo[], transpileJs: boolean, transpileDts: boolean, jsImportStyle: "module" | "legacy_commonjs") => FileInfo[]) | undefined;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Create a new code generator plugin for ECMAScript.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -36,7 +36,7 @@ function createEcmaScriptPlugin(init) {
|
|
|
36
36
|
const minimumEdition = (_a = init.minimumEdition) !== null && _a !== void 0 ? _a : protobuf_2.minimumEdition;
|
|
37
37
|
const maximumEdition = (_b = init.maximumEdition) !== null && _b !== void 0 ? _b : protobuf_2.maximumEdition;
|
|
38
38
|
const parameter = (0, parameter_js_1.parseParameter)(req.parameter, init.parseOptions);
|
|
39
|
-
const schema = (0, schema_js_1.createSchema)(req, parameter, init.name, init.version, minimumEdition, maximumEdition);
|
|
39
|
+
const schema = (0, schema_js_1.createSchema)(req, parameter, init.name, parameter.parsed.elidePluginVersion ? undefined : init.version, minimumEdition, maximumEdition);
|
|
40
40
|
const targetTs = schema.targets.includes("ts");
|
|
41
41
|
const targetJs = schema.targets.includes("js");
|
|
42
42
|
const targetDts = schema.targets.includes("dts");
|
package/dist/cjs/error.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DescFile } from "@bufbuild/protobuf";
|
|
2
|
-
export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string, parameter: string, tsNoCheck: boolean): string;
|
|
2
|
+
export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string | undefined, parameter: string, tsNoCheck: boolean): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -36,7 +36,12 @@ function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck)
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
writeLeadingComments((0, source_code_info_js_1.getSyntaxComments)(file));
|
|
39
|
-
|
|
39
|
+
if (pluginVersion === undefined) {
|
|
40
|
+
builder.push(`// @generated by ${pluginName}`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
builder.push(`// @generated by ${pluginName} ${pluginVersion}`);
|
|
44
|
+
}
|
|
40
45
|
if (parameter !== "") {
|
|
41
46
|
builder.push(` with parameter "${parameter}"`);
|
|
42
47
|
}
|
|
@@ -53,7 +58,10 @@ function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck)
|
|
|
53
58
|
builder.push("syntax proto3)\n");
|
|
54
59
|
break;
|
|
55
60
|
default: {
|
|
56
|
-
|
|
61
|
+
// Report the raw edition from the descriptor so files using
|
|
62
|
+
// EDITION_UNSTABLE (which we collapse to maximumEdition internally)
|
|
63
|
+
// still render as "edition unstable".
|
|
64
|
+
const editionString = wkt_1.Edition[file.proto.edition];
|
|
57
65
|
if (typeof editionString == "string") {
|
|
58
66
|
const e = editionString.replace("EDITION_", "").toLowerCase();
|
|
59
67
|
builder.push(`edition ${e})\n`);
|
package/dist/cjs/import-path.js
CHANGED
package/dist/cjs/index.js
CHANGED
package/dist/cjs/jsdoc.js
CHANGED
package/dist/cjs/names.js
CHANGED
package/dist/cjs/parameter.d.ts
CHANGED
|
@@ -37,6 +37,12 @@ export interface EcmaScriptPluginOptions {
|
|
|
37
37
|
* The default is false.
|
|
38
38
|
*/
|
|
39
39
|
tsNocheck: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Elide the plugin's version at the top of each file.
|
|
42
|
+
*
|
|
43
|
+
* The default is false.
|
|
44
|
+
*/
|
|
45
|
+
elidePluginVersion: boolean;
|
|
40
46
|
/**
|
|
41
47
|
* Prune empty files from the output.
|
|
42
48
|
*
|
package/dist/cjs/parameter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -18,6 +18,7 @@ const error_js_1 = require("./error.js");
|
|
|
18
18
|
function parseParameter(parameter, parseExtraOptions) {
|
|
19
19
|
let targets = ["js", "dts"];
|
|
20
20
|
let tsNocheck = false;
|
|
21
|
+
let elidePluginVersion = false;
|
|
21
22
|
let bootstrapWkt = false;
|
|
22
23
|
let keepEmptyFiles = false;
|
|
23
24
|
const rewriteImports = [];
|
|
@@ -62,6 +63,20 @@ function parseParameter(parameter, parseExtraOptions) {
|
|
|
62
63
|
throw new error_js_1.PluginOptionError(raw);
|
|
63
64
|
}
|
|
64
65
|
break;
|
|
66
|
+
case "elide_plugin_version":
|
|
67
|
+
switch (value) {
|
|
68
|
+
case "true":
|
|
69
|
+
case "1":
|
|
70
|
+
elidePluginVersion = true;
|
|
71
|
+
break;
|
|
72
|
+
case "false":
|
|
73
|
+
case "0":
|
|
74
|
+
elidePluginVersion = false;
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
throw new error_js_1.PluginOptionError(raw);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
65
80
|
case "bootstrap_wkt":
|
|
66
81
|
switch (value) {
|
|
67
82
|
case "true":
|
|
@@ -152,6 +167,7 @@ function parseParameter(parameter, parseExtraOptions) {
|
|
|
152
167
|
const ecmaScriptPluginOptions = {
|
|
153
168
|
targets,
|
|
154
169
|
tsNocheck,
|
|
170
|
+
elidePluginVersion,
|
|
155
171
|
bootstrapWkt,
|
|
156
172
|
rewriteImports,
|
|
157
173
|
importExtension,
|
package/dist/cjs/plugin.js
CHANGED
package/dist/cjs/printable.d.ts
CHANGED
package/dist/cjs/printable.js
CHANGED
package/dist/cjs/run-node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -61,7 +61,12 @@ function runNodeJs(plugin) {
|
|
|
61
61
|
function readBytes(stream) {
|
|
62
62
|
return new Promise((resolve, reject) => {
|
|
63
63
|
const chunks = [];
|
|
64
|
-
stream.on("data", (chunk) =>
|
|
64
|
+
stream.on("data", (chunk) => {
|
|
65
|
+
if (typeof chunk === "string") {
|
|
66
|
+
throw new Error("unexpected chunk type string");
|
|
67
|
+
}
|
|
68
|
+
chunks.push(chunk);
|
|
69
|
+
});
|
|
65
70
|
stream.on("end", () => {
|
|
66
71
|
resolve(Buffer.concat(chunks));
|
|
67
72
|
});
|
package/dist/cjs/schema.d.ts
CHANGED
|
@@ -43,5 +43,5 @@ interface SchemaController<Options extends object> extends Schema<Options> {
|
|
|
43
43
|
getFileInfo: () => FileInfo[];
|
|
44
44
|
prepareGenerate(target: Target): void;
|
|
45
45
|
}
|
|
46
|
-
export declare function createSchema<T extends object>(request: CodeGeneratorRequest, parameter: ParsedParameter<T>, pluginName: string, pluginVersion: string, minimumEdition: Edition, maximumEdition: Edition): SchemaController<T>;
|
|
46
|
+
export declare function createSchema<T extends object>(request: CodeGeneratorRequest, parameter: ParsedParameter<T>, pluginName: string, pluginVersion: string | undefined, minimumEdition: Edition, maximumEdition: Edition): SchemaController<T>;
|
|
47
47
|
export {};
|
package/dist/cjs/schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -86,6 +86,11 @@ function getFilesToGenerate(request, minimumEdition, maximumEdition) {
|
|
|
86
86
|
edition = wkt_1.Edition.EDITION_UNKNOWN;
|
|
87
87
|
break;
|
|
88
88
|
}
|
|
89
|
+
// EDITION_UNSTABLE is a sandbox for in-development features; accept
|
|
90
|
+
// it regardless of the plugin's min/max bounds.
|
|
91
|
+
if (edition === wkt_1.Edition.EDITION_UNSTABLE) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
89
94
|
if (edition < minimumEdition) {
|
|
90
95
|
throw new Error(`${file.name}: unsupported edition ${editionToString(edition)} - the earliest supported edition is ${editionToString(minimumEdition)}`);
|
|
91
96
|
}
|
package/dist/cjs/transpile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2021-
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
3
|
//
|
|
4
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -42,9 +42,11 @@ const vfs_1 = require("@typescript/vfs");
|
|
|
42
42
|
* npm does not support that yet.
|
|
43
43
|
*/
|
|
44
44
|
function createTranspiler(options, files) {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const fsMapOptions = {};
|
|
46
|
+
if (options.target) {
|
|
47
|
+
fsMapOptions.target = options.target;
|
|
48
|
+
}
|
|
49
|
+
const fsMap = (0, vfs_1.createDefaultMapFromNodeModules)(fsMapOptions);
|
|
48
50
|
for (const file of files) {
|
|
49
51
|
fsMap.set(file.name, file.content);
|
|
50
52
|
}
|
|
@@ -30,20 +30,20 @@ interface PluginInit<Options extends object> {
|
|
|
30
30
|
* If your plugin does not recognize an option, it must throw an Error in
|
|
31
31
|
* parseOptions.
|
|
32
32
|
*/
|
|
33
|
-
parseOptions?: (rawOptions: {
|
|
33
|
+
parseOptions?: ((rawOptions: {
|
|
34
34
|
key: string;
|
|
35
35
|
value: string;
|
|
36
|
-
}[]) => Options;
|
|
36
|
+
}[]) => Options) | undefined;
|
|
37
37
|
/**
|
|
38
38
|
* The earliest edition supported by this plugin. Defaults to the minimum
|
|
39
39
|
* edition supported by @bufbuild/protobuf.
|
|
40
40
|
*/
|
|
41
|
-
minimumEdition?: SupportedEdition;
|
|
41
|
+
minimumEdition?: SupportedEdition | undefined;
|
|
42
42
|
/**
|
|
43
43
|
* The latest edition supported by this plugin. Defaults to the maximum
|
|
44
44
|
* edition supported by @bufbuild/protobuf.
|
|
45
45
|
*/
|
|
46
|
-
maximumEdition?: SupportedEdition;
|
|
46
|
+
maximumEdition?: SupportedEdition | undefined;
|
|
47
47
|
/**
|
|
48
48
|
* A function which will generate TypeScript files based on proto input.
|
|
49
49
|
* This function will be invoked by the plugin framework when the plugin runs.
|
|
@@ -61,7 +61,7 @@ interface PluginInit<Options extends object> {
|
|
|
61
61
|
* JavaScript files. If not, the plugin framework will transpile the files
|
|
62
62
|
* itself.
|
|
63
63
|
*/
|
|
64
|
-
generateJs?: (schema: Schema<Options>, target: "js") => void;
|
|
64
|
+
generateJs?: ((schema: Schema<Options>, target: "js") => void) | undefined;
|
|
65
65
|
/**
|
|
66
66
|
* A optional function which will generate TypeScript declaration files
|
|
67
67
|
* based on proto input. This function will be invoked by the plugin
|
|
@@ -72,7 +72,7 @@ interface PluginInit<Options extends object> {
|
|
|
72
72
|
* declaration files. If not, the plugin framework will transpile the files
|
|
73
73
|
* itself.
|
|
74
74
|
*/
|
|
75
|
-
generateDts?: (schema: Schema<Options>, target: "dts") => void;
|
|
75
|
+
generateDts?: ((schema: Schema<Options>, target: "dts") => void) | undefined;
|
|
76
76
|
/**
|
|
77
77
|
* An optional function which will transpile a given set of files.
|
|
78
78
|
*
|
|
@@ -86,7 +86,7 @@ interface PluginInit<Options extends object> {
|
|
|
86
86
|
* transpiling to JS. If jsImportStyle is "legacy_commonjs", the function is
|
|
87
87
|
* expected to use CommonJs require() and exports when transpiling to JS.
|
|
88
88
|
*/
|
|
89
|
-
transpile?: (files: FileInfo[], transpileJs: boolean, transpileDts: boolean, jsImportStyle: "module" | "legacy_commonjs") => FileInfo[];
|
|
89
|
+
transpile?: ((files: FileInfo[], transpileJs: boolean, transpileDts: boolean, jsImportStyle: "module" | "legacy_commonjs") => FileInfo[]) | undefined;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Create a new code generator plugin for ECMAScript.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2021-
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -33,7 +33,7 @@ export function createEcmaScriptPlugin(init) {
|
|
|
33
33
|
const minimumEdition = (_a = init.minimumEdition) !== null && _a !== void 0 ? _a : minimumEditionUpstream;
|
|
34
34
|
const maximumEdition = (_b = init.maximumEdition) !== null && _b !== void 0 ? _b : maximumEditionUpstream;
|
|
35
35
|
const parameter = parseParameter(req.parameter, init.parseOptions);
|
|
36
|
-
const schema = createSchema(req, parameter, init.name, init.version, minimumEdition, maximumEdition);
|
|
36
|
+
const schema = createSchema(req, parameter, init.name, parameter.parsed.elidePluginVersion ? undefined : init.version, minimumEdition, maximumEdition);
|
|
37
37
|
const targetTs = schema.targets.includes("ts");
|
|
38
38
|
const targetJs = schema.targets.includes("js");
|
|
39
39
|
const targetDts = schema.targets.includes("dts");
|
package/dist/esm/error.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DescFile } from "@bufbuild/protobuf";
|
|
2
|
-
export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string, parameter: string, tsNoCheck: boolean): string;
|
|
2
|
+
export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string | undefined, parameter: string, tsNoCheck: boolean): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2021-
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -33,7 +33,12 @@ export function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsN
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
writeLeadingComments(getSyntaxComments(file));
|
|
36
|
-
|
|
36
|
+
if (pluginVersion === undefined) {
|
|
37
|
+
builder.push(`// @generated by ${pluginName}`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
builder.push(`// @generated by ${pluginName} ${pluginVersion}`);
|
|
41
|
+
}
|
|
37
42
|
if (parameter !== "") {
|
|
38
43
|
builder.push(` with parameter "${parameter}"`);
|
|
39
44
|
}
|
|
@@ -50,7 +55,10 @@ export function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsN
|
|
|
50
55
|
builder.push("syntax proto3)\n");
|
|
51
56
|
break;
|
|
52
57
|
default: {
|
|
53
|
-
|
|
58
|
+
// Report the raw edition from the descriptor so files using
|
|
59
|
+
// EDITION_UNSTABLE (which we collapse to maximumEdition internally)
|
|
60
|
+
// still render as "edition unstable".
|
|
61
|
+
const editionString = Edition[file.proto.edition];
|
|
54
62
|
if (typeof editionString == "string") {
|
|
55
63
|
const e = editionString.replace("EDITION_", "").toLowerCase();
|
|
56
64
|
builder.push(`edition ${e})\n`);
|
package/dist/esm/import-path.js
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/jsdoc.js
CHANGED
package/dist/esm/names.js
CHANGED
package/dist/esm/parameter.d.ts
CHANGED
|
@@ -37,6 +37,12 @@ export interface EcmaScriptPluginOptions {
|
|
|
37
37
|
* The default is false.
|
|
38
38
|
*/
|
|
39
39
|
tsNocheck: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Elide the plugin's version at the top of each file.
|
|
42
|
+
*
|
|
43
|
+
* The default is false.
|
|
44
|
+
*/
|
|
45
|
+
elidePluginVersion: boolean;
|
|
40
46
|
/**
|
|
41
47
|
* Prune empty files from the output.
|
|
42
48
|
*
|
package/dist/esm/parameter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2021-
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -15,6 +15,7 @@ import { PluginOptionError } from "./error.js";
|
|
|
15
15
|
export function parseParameter(parameter, parseExtraOptions) {
|
|
16
16
|
let targets = ["js", "dts"];
|
|
17
17
|
let tsNocheck = false;
|
|
18
|
+
let elidePluginVersion = false;
|
|
18
19
|
let bootstrapWkt = false;
|
|
19
20
|
let keepEmptyFiles = false;
|
|
20
21
|
const rewriteImports = [];
|
|
@@ -59,6 +60,20 @@ export function parseParameter(parameter, parseExtraOptions) {
|
|
|
59
60
|
throw new PluginOptionError(raw);
|
|
60
61
|
}
|
|
61
62
|
break;
|
|
63
|
+
case "elide_plugin_version":
|
|
64
|
+
switch (value) {
|
|
65
|
+
case "true":
|
|
66
|
+
case "1":
|
|
67
|
+
elidePluginVersion = true;
|
|
68
|
+
break;
|
|
69
|
+
case "false":
|
|
70
|
+
case "0":
|
|
71
|
+
elidePluginVersion = false;
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
throw new PluginOptionError(raw);
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
62
77
|
case "bootstrap_wkt":
|
|
63
78
|
switch (value) {
|
|
64
79
|
case "true":
|
|
@@ -149,6 +164,7 @@ export function parseParameter(parameter, parseExtraOptions) {
|
|
|
149
164
|
const ecmaScriptPluginOptions = {
|
|
150
165
|
targets,
|
|
151
166
|
tsNocheck,
|
|
167
|
+
elidePluginVersion,
|
|
152
168
|
bootstrapWkt,
|
|
153
169
|
rewriteImports,
|
|
154
170
|
importExtension,
|
package/dist/esm/plugin.js
CHANGED
package/dist/esm/printable.d.ts
CHANGED
package/dist/esm/printable.js
CHANGED
package/dist/esm/run-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2021-
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -58,7 +58,12 @@ export function runNodeJs(plugin) {
|
|
|
58
58
|
function readBytes(stream) {
|
|
59
59
|
return new Promise((resolve, reject) => {
|
|
60
60
|
const chunks = [];
|
|
61
|
-
stream.on("data", (chunk) =>
|
|
61
|
+
stream.on("data", (chunk) => {
|
|
62
|
+
if (typeof chunk === "string") {
|
|
63
|
+
throw new Error("unexpected chunk type string");
|
|
64
|
+
}
|
|
65
|
+
chunks.push(chunk);
|
|
66
|
+
});
|
|
62
67
|
stream.on("end", () => {
|
|
63
68
|
resolve(Buffer.concat(chunks));
|
|
64
69
|
});
|
package/dist/esm/schema.d.ts
CHANGED
|
@@ -43,5 +43,5 @@ interface SchemaController<Options extends object> extends Schema<Options> {
|
|
|
43
43
|
getFileInfo: () => FileInfo[];
|
|
44
44
|
prepareGenerate(target: Target): void;
|
|
45
45
|
}
|
|
46
|
-
export declare function createSchema<T extends object>(request: CodeGeneratorRequest, parameter: ParsedParameter<T>, pluginName: string, pluginVersion: string, minimumEdition: Edition, maximumEdition: Edition): SchemaController<T>;
|
|
46
|
+
export declare function createSchema<T extends object>(request: CodeGeneratorRequest, parameter: ParsedParameter<T>, pluginName: string, pluginVersion: string | undefined, minimumEdition: Edition, maximumEdition: Edition): SchemaController<T>;
|
|
47
47
|
export {};
|
package/dist/esm/schema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2021-
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -83,6 +83,11 @@ function getFilesToGenerate(request, minimumEdition, maximumEdition) {
|
|
|
83
83
|
edition = Edition.EDITION_UNKNOWN;
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
|
+
// EDITION_UNSTABLE is a sandbox for in-development features; accept
|
|
87
|
+
// it regardless of the plugin's min/max bounds.
|
|
88
|
+
if (edition === Edition.EDITION_UNSTABLE) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
86
91
|
if (edition < minimumEdition) {
|
|
87
92
|
throw new Error(`${file.name}: unsupported edition ${editionToString(edition)} - the earliest supported edition is ${editionToString(minimumEdition)}`);
|
|
88
93
|
}
|
package/dist/esm/transpile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright 2021-
|
|
1
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -36,9 +36,11 @@ import { createDefaultMapFromNodeModules, createSystem, createVirtualCompilerHos
|
|
|
36
36
|
* npm does not support that yet.
|
|
37
37
|
*/
|
|
38
38
|
function createTranspiler(options, files) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const fsMapOptions = {};
|
|
40
|
+
if (options.target) {
|
|
41
|
+
fsMapOptions.target = options.target;
|
|
42
|
+
}
|
|
43
|
+
const fsMap = createDefaultMapFromNodeModules(fsMapOptions);
|
|
42
44
|
for (const file of files) {
|
|
43
45
|
fsMap.set(file.name, file.content);
|
|
44
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoplugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Helps to create your own Protocol Buffers code generators.",
|
|
6
6
|
"keywords": [
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@bufbuild/protobuf": "2.
|
|
38
|
+
"@bufbuild/protobuf": "2.12.0",
|
|
39
39
|
"@typescript/vfs": "^1.6.2",
|
|
40
40
|
"typescript": "5.4.5"
|
|
41
41
|
},
|