@bufbuild/protoc-gen-es 1.1.1 → 1.2.1

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
@@ -15,13 +15,18 @@ npm install @bufbuild/protobuf
15
15
  ```
16
16
 
17
17
  We use peer dependencies to ensure that code generator and runtime library are
18
- compatible with each other. Note that yarn and pnpm only emit a warning in this case.
18
+ compatible with each other. Note that npm installs them automatically, but yarn
19
+ and pnpm do not.
19
20
 
20
21
 
21
22
  ## Generating code
22
23
 
23
24
  ### With buf
24
25
 
26
+ ```bash
27
+ npm install --save-dev @bufbuild/buf
28
+ ```
29
+
25
30
  Add a new configuration file `buf.gen.yaml`:
26
31
 
27
32
  ```yaml
@@ -30,28 +35,17 @@ Add a new configuration file `buf.gen.yaml`:
30
35
  version: v1
31
36
  plugins:
32
37
  # This will invoke protoc-gen-es and write output to src/gen
33
- - name: es
38
+ - plugin: es
34
39
  out: src/gen
35
- opt: target=ts
36
- ```
37
-
38
- Add the following script to your `package.json`:
39
-
40
- ```json
41
- {
42
- "name": "your-package",
43
- "version": "1.0.0",
44
- "scripts": {
45
- "generate": "buf generate"
46
- },
47
- // ...
48
- }
40
+ opt:
41
+ # Add more plugin options here
42
+ - target=ts
49
43
  ```
50
44
 
51
45
  To generate code for all protobuf files within your project, simply run:
52
46
 
53
47
  ```bash
54
- npm run generate
48
+ npx buf generate
55
49
  ```
56
50
 
57
51
  Note that `buf` can generate from various [inputs](https://docs.buf.build/reference/inputs),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Protocol Buffers code generator for ECMAScript",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  },
21
21
  "preferUnplugged": true,
22
22
  "dependencies": {
23
- "@bufbuild/protoplugin": "1.1.1"
23
+ "@bufbuild/protoplugin": "1.2.1"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bufbuild/protobuf": "1.1.1"
26
+ "@bufbuild/protobuf": "1.2.1"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@bufbuild/protobuf": {
@@ -473,7 +473,7 @@ function generateWktMethods(schema, f, message) {
473
473
  f.print(` }`);
474
474
  f.print(` return this.`, (0, ecmascript_1.localName)(ref.paths), `.map(p => {`);
475
475
  f.print(` if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {`);
476
- f.print(` throw new Error("cannot decode `, message.typeName, ` from JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`);
476
+ f.print(` throw new Error("cannot encode `, message.typeName, ` to JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`);
477
477
  f.print(` }`);
478
478
  f.print(` return protoCamelCase(p);`);
479
479
  f.print(` }).join(",");`);
@@ -476,7 +476,7 @@ function generateWktMethods(schema, f, message) {
476
476
  f.print(` }`);
477
477
  f.print(` return this.`, (0, ecmascript_1.localName)(ref.paths), `.map(p => {`);
478
478
  f.print(` if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {`);
479
- f.print(` throw new Error("cannot decode `, message.typeName, ` from JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`);
479
+ f.print(` throw new Error("cannot encode `, message.typeName, ` to JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`);
480
480
  f.print(` }`);
481
481
  f.print(` return protoCamelCase(p);`);
482
482
  f.print(` }).join(",");`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "Protocol Buffers code generator for ECMAScript",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  },
21
21
  "preferUnplugged": true,
22
22
  "dependencies": {
23
- "@bufbuild/protoplugin": "1.1.1"
23
+ "@bufbuild/protoplugin": "1.2.1"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bufbuild/protobuf": "1.1.1"
26
+ "@bufbuild/protobuf": "1.2.1"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@bufbuild/protobuf": {
package/src/javascript.ts CHANGED
@@ -359,7 +359,7 @@ function generateWktMethods(schema: Schema, f: GeneratedFile, message: DescMessa
359
359
  f.print(` text += "." + nanosStr;`)
360
360
  f.print(" if (this.", localName(ref.nanos), " < 0 && this.", localName(ref.seconds), " === ", protoInt64, ".zero) {");
361
361
  f.print(` text = "-" + text;`);
362
- f.print(` }`);
362
+ f.print(` }`);
363
363
  f.print(" }")
364
364
  f.print(` return text + "s";`)
365
365
  f.print("};");
@@ -486,7 +486,7 @@ function generateWktMethods(schema: Schema, f: GeneratedFile, message: DescMessa
486
486
  f.print(` }`)
487
487
  f.print(` return this.`, localName(ref.paths), `.map(p => {`)
488
488
  f.print(` if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {`)
489
- f.print(` throw new Error("cannot decode `, message.typeName, ` from JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`)
489
+ f.print(` throw new Error("cannot encode `, message.typeName, ` to JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`)
490
490
  f.print(` }`)
491
491
  f.print(` return protoCamelCase(p);`)
492
492
  f.print(` }).join(",");`)
package/src/typescript.ts CHANGED
@@ -384,7 +384,7 @@ function generateWktMethods(schema: Schema, f: GeneratedFile, message: DescMessa
384
384
  f.print(` text += "." + nanosStr;`)
385
385
  f.print(" if (this.", localName(ref.nanos), " < 0 && this.", localName(ref.seconds), " === ", protoInt64, ".zero) {");
386
386
  f.print(` text = "-" + text;`);
387
- f.print(` }`);
387
+ f.print(` }`);
388
388
  f.print(" }")
389
389
  f.print(` return text + "s";`)
390
390
  f.print(" }")
@@ -513,7 +513,7 @@ function generateWktMethods(schema: Schema, f: GeneratedFile, message: DescMessa
513
513
  f.print(` }`)
514
514
  f.print(` return this.`, localName(ref.paths), `.map(p => {`)
515
515
  f.print(` if (p.match(/_[0-9]?_/g) || p.match(/[A-Z]/g)) {`)
516
- f.print(` throw new Error("cannot decode `, message.typeName, ` from JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`)
516
+ f.print(` throw new Error("cannot encode `, message.typeName, ` to JSON: lowerCamelCase of path name \\"" + p + "\\" is irreversible");`)
517
517
  f.print(` }`)
518
518
  f.print(` return protoCamelCase(p);`)
519
519
  f.print(` }).join(",");`)