@bufbuild/protoplugin 2.10.2 → 2.11.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.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 +7 -2
- 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.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 +1 -1
- package/dist/cjs/source-code-info.js +1 -1
- package/dist/cjs/transpile.js +1 -1
- 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 +7 -2
- 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.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 +1 -1
- package/dist/esm/source-code-info.js +1 -1
- package/dist/esm/transpile.js +1 -1
- package/package.json +2 -2
|
@@ -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
|
}
|
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.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
package/dist/cjs/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.
|
|
@@ -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
|
}
|
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.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
package/dist/esm/transpile.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoplugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.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.11.0",
|
|
39
39
|
"@typescript/vfs": "^1.6.2",
|
|
40
40
|
"typescript": "5.4.5"
|
|
41
41
|
},
|