@bufbuild/protoplugin 2.12.0 → 2.13.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This package helps you create your own code generator plugin using the
4
4
  Protobuf-ES plugin framework.
5
5
 
6
- **Protobuf-ES** is a complete implementation of [Protocol Buffers](https://protobuf.dev) in TypeScript, suitable for web browsers, Node.js, and Deno.
6
+ **Protobuf-ES** is a complete implementation of [Protocol Buffers](https://protobuf.dev) in TypeScript, suitable for web browsers, Node.js, Deno, and Bun.
7
7
 
8
8
  In addition to a full Protobuf runtime library, it provides the [`protoc-gen-es`](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
9
9
  code generator, which uses a plugin framework to generate base types from
@@ -31,4 +31,4 @@ ECMAScript-compliant code.
31
31
 
32
32
  ## Usage
33
33
 
34
- Get started now with our [plugin documentation](https://github.com/bufbuild/protobuf-es/blob/main/MANUAL.md#writing-plugins).
34
+ Get started now with our [plugin documentation](https://protobufes.com/guides/writing-plugins/).
@@ -61,9 +61,9 @@ function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck)
61
61
  // Report the raw edition from the descriptor so files using
62
62
  // EDITION_UNSTABLE (which we collapse to maximumEdition internally)
63
63
  // still render as "edition unstable".
64
- const editionString = wkt_1.Edition[file.proto.edition];
65
- if (typeof editionString == "string") {
66
- const e = editionString.replace("EDITION_", "").toLowerCase();
64
+ const editionValue = wkt_1.EditionSchema.value[file.proto.edition];
65
+ if (editionValue !== undefined) {
66
+ const e = editionValue.name.replace("EDITION_", "").toLowerCase();
67
67
  builder.push(`edition ${e})\n`);
68
68
  }
69
69
  else {
@@ -121,8 +121,9 @@ function getFilesToGenerate(request, minimumEdition, maximumEdition) {
121
121
  return { allFiles, filesToGenerate };
122
122
  }
123
123
  function editionToString(edition) {
124
- if (edition in wkt_1.Edition) {
125
- return wkt_1.Edition[edition].replace(/^EDITION_/, "");
124
+ const value = wkt_1.EditionSchema.values.find((e) => e.number == edition);
125
+ if (value !== undefined) {
126
+ return value.name.replace(/^EDITION_/, "");
126
127
  }
127
128
  return `unknown (${edition})`;
128
129
  }
@@ -213,7 +213,8 @@ function getDeclarationString(desc) {
213
213
  }
214
214
  if (protoOptions !== undefined &&
215
215
  (0, protobuf_1.isFieldSet)(protoOptions, wkt_1.FieldOptionsSchema.field.jstype)) {
216
- options.push(`jstype = ${wkt_1.FieldOptions_JSType[protoOptions.jstype]}`);
216
+ const value = wkt_1.FieldOptions_JSTypeSchema.value[protoOptions.jstype];
217
+ options.push(`jstype = ${value.name}`);
217
218
  }
218
219
  if (protoOptions !== undefined &&
219
220
  (0, protobuf_1.isFieldSet)(protoOptions, wkt_1.FieldOptionsSchema.field.deprecated)) {
@@ -11,7 +11,7 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { Edition } from "@bufbuild/protobuf/wkt";
14
+ import { Edition, EditionSchema } from "@bufbuild/protobuf/wkt";
15
15
  import { getPackageComments, getSyntaxComments, getFeatureOptionStrings, } from "./source-code-info.js";
16
16
  export function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck) {
17
17
  const builder = [];
@@ -58,9 +58,9 @@ export function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsN
58
58
  // Report the raw edition from the descriptor so files using
59
59
  // EDITION_UNSTABLE (which we collapse to maximumEdition internally)
60
60
  // still render as "edition unstable".
61
- const editionString = Edition[file.proto.edition];
62
- if (typeof editionString == "string") {
63
- const e = editionString.replace("EDITION_", "").toLowerCase();
61
+ const editionValue = EditionSchema.value[file.proto.edition];
62
+ if (editionValue !== undefined) {
63
+ const e = editionValue.name.replace("EDITION_", "").toLowerCase();
64
64
  builder.push(`edition ${e})\n`);
65
65
  }
66
66
  else {
@@ -12,7 +12,7 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
  import { create, createFileRegistry } from "@bufbuild/protobuf";
15
- import { Edition, FileDescriptorSetSchema } from "@bufbuild/protobuf/wkt";
15
+ import { Edition, EditionSchema, FileDescriptorSetSchema, } from "@bufbuild/protobuf/wkt";
16
16
  import { nestedTypes } from "@bufbuild/protobuf/reflect";
17
17
  import { createGeneratedFile } from "./generated-file.js";
18
18
  import { createImportSymbol } from "./import-symbol.js";
@@ -118,8 +118,9 @@ function getFilesToGenerate(request, minimumEdition, maximumEdition) {
118
118
  return { allFiles, filesToGenerate };
119
119
  }
120
120
  function editionToString(edition) {
121
- if (edition in Edition) {
122
- return Edition[edition].replace(/^EDITION_/, "");
121
+ const value = EditionSchema.values.find((e) => e.number == edition);
122
+ if (value !== undefined) {
123
+ return value.name.replace(/^EDITION_/, "");
123
124
  }
124
125
  return `unknown (${edition})`;
125
126
  }
@@ -13,7 +13,7 @@
13
13
  // limitations under the License.
14
14
  import { isFieldSet, ScalarType, } from "@bufbuild/protobuf";
15
15
  import { protoCamelCase, reflect } from "@bufbuild/protobuf/reflect";
16
- import { Edition, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldDescriptorProtoSchema, FieldOptions_JSType, FieldOptionsSchema, FeatureSetSchema, SourceCodeInfo_LocationSchema, FileDescriptorProtoSchema, DescriptorProtoSchema, EnumDescriptorProtoSchema, ServiceDescriptorProtoSchema, } from "@bufbuild/protobuf/wkt";
16
+ import { Edition, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldDescriptorProtoSchema, FieldOptionsSchema, FeatureSetSchema, SourceCodeInfo_LocationSchema, FileDescriptorProtoSchema, DescriptorProtoSchema, EnumDescriptorProtoSchema, ServiceDescriptorProtoSchema, FieldOptions_JSTypeSchema, } from "@bufbuild/protobuf/wkt";
17
17
  /**
18
18
  * Get comments on the package element in the protobuf source.
19
19
  */
@@ -206,7 +206,8 @@ export function getDeclarationString(desc) {
206
206
  }
207
207
  if (protoOptions !== undefined &&
208
208
  isFieldSet(protoOptions, FieldOptionsSchema.field.jstype)) {
209
- options.push(`jstype = ${FieldOptions_JSType[protoOptions.jstype]}`);
209
+ const value = FieldOptions_JSTypeSchema.value[protoOptions.jstype];
210
+ options.push(`jstype = ${value.name}`);
210
211
  }
211
212
  if (protoOptions !== undefined &&
212
213
  isFieldSet(protoOptions, FieldOptionsSchema.field.deprecated)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoplugin",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Helps to create your own Protocol Buffers code generators.",
6
6
  "keywords": [
@@ -10,6 +10,7 @@
10
10
  "ecmascript",
11
11
  "protoc-plugin"
12
12
  ],
13
+ "homepage": "https://protobufes.com/",
13
14
  "repository": {
14
15
  "type": "git",
15
16
  "url": "https://github.com/bufbuild/protobuf-es.git",
@@ -35,7 +36,7 @@
35
36
  }
36
37
  },
37
38
  "dependencies": {
38
- "@bufbuild/protobuf": "2.12.0",
39
+ "@bufbuild/protobuf": "2.13.0",
39
40
  "@typescript/vfs": "^1.6.2",
40
41
  "typescript": "5.4.5"
41
42
  },