@bufbuild/protoc-gen-es 2.0.0-beta.1 → 2.0.0-beta.3

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
@@ -1,11 +1,13 @@
1
1
  # @bufbuild/protoc-gen-es
2
2
 
3
- The code generator plugin for Protocol Buffers for ECMAScript. Learn more about the project at [github.com/bufbuild/protobuf-es](https://github.com/bufbuild/protobuf-es).
3
+ The code generator plugin for Protocol Buffers for ECMAScript. Learn more about the project at
4
+ [github.com/bufbuild/protobuf-es](https://github.com/bufbuild/protobuf-es).
4
5
 
5
6
  ## Installation
6
7
 
7
- `protoc-gen-es` generates base types - messages and enumerations - from your Protocol Buffer
8
- schema. The generated code requires the runtime library [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/protobuf). It is compatible with Protocol Buffer compilers like [buf](https://github.com/bufbuild/buf) and [protoc](https://github.com/protocolbuffers/protobuf/releases).
8
+ `protoc-gen-es` generates base typesmessages and enumerationsfrom your Protocol Buffer
9
+ schema. The generated code requires the runtime library [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/protobuf).
10
+ It's compatible with Protocol Buffer compilers like [buf](https://github.com/bufbuild/buf) and [protoc](https://github.com/protocolbuffers/protobuf/releases).
9
11
 
10
12
  To install the plugin and the runtime library, run:
11
13
 
@@ -14,11 +16,10 @@ npm install --save-dev @bufbuild/protoc-gen-es
14
16
  npm install @bufbuild/protobuf
15
17
  ```
16
18
 
17
- We use peer dependencies to ensure that code generator and runtime library are
18
- compatible with each other. Note that npm installs them automatically, but yarn
19
+ We use peer dependencies to ensure that the code generator and runtime library are
20
+ compatible with each other. Note that npm installs them automatically, but Yarn
19
21
  and pnpm do not.
20
22
 
21
-
22
23
  ## Generating code
23
24
 
24
25
  ### With buf
@@ -27,32 +28,30 @@ and pnpm do not.
27
28
  npm install --save-dev @bufbuild/buf
28
29
  ```
29
30
 
30
- Add a new configuration file `buf.gen.yaml`:
31
+ Add a new `buf.gen.yaml` configuration file:
31
32
 
32
33
  ```yaml
33
- # buf.gen.yaml defines a local generation template.
34
- # For details, see https://docs.buf.build/configuration/v1/buf-gen-yaml
35
- version: v1
34
+ # Learn more: https://buf.build/docs/configuration/v2/buf-gen-yaml
35
+ version: v2
36
36
  plugins:
37
37
  # This will invoke protoc-gen-es and write output to src/gen
38
- - plugin: es
38
+ - local: protoc-gen-es
39
39
  out: src/gen
40
40
  opt:
41
41
  # Add more plugin options here
42
42
  - target=ts
43
43
  ```
44
44
 
45
- To generate code for all protobuf files within your project, simply run:
45
+ To generate code for all Protobuf files within your project, run:
46
46
 
47
47
  ```bash
48
48
  npx buf generate
49
49
  ```
50
50
 
51
- Note that `buf` can generate from various [inputs](https://docs.buf.build/reference/inputs),
52
- not just local protobuf files.
53
-
51
+ Note that `buf` can generate from various [inputs](https://buf.build/docs/reference/inputs),
52
+ not just local Protobuf files.
54
53
 
55
- ### With protoc
54
+ ### With `protoc`
56
55
 
57
56
  ```bash
58
57
  PATH=$PATH:$(pwd)/node_modules/.bin \
@@ -62,13 +61,13 @@ PATH=$PATH:$(pwd)/node_modules/.bin \
62
61
  a.proto b.proto c.proto
63
62
  ```
64
63
 
65
- Note that we are adding `node_modules/.bin` to the `$PATH`, so that the protocol
66
- buffer compiler can find them. This happens automatically with npm scripts.
64
+ Note that `node_modules/.bin` needs to be added to the `$PATH` so that the Protobuf compiler can find the plugin. This
65
+ happens automatically with npm scripts.
67
66
 
68
- Since yarn v2 and above does not use a `node_modules` directory, you need to
69
- change the variable a bit:
67
+ If you use Yarn, versions v2 and above don't use a `node_modules` directory, so you need to change the variable a
68
+ bit:
70
69
 
71
- ```bash
70
+ ```shellsession
72
71
  PATH=$(dirname $(yarn bin protoc-gen-es)):$PATH
73
72
  ```
74
73
 
@@ -76,67 +75,50 @@ PATH=$(dirname $(yarn bin protoc-gen-es)):$PATH
76
75
 
77
76
  ### `target`
78
77
 
79
- This option controls whether the plugin generates JavaScript, TypeScript,
80
- or TypeScript declaration files.
78
+ This option controls whether the plugin generates JavaScript, TypeScript, or TypeScript declaration files. Possible
79
+ values:
81
80
 
82
- Possible values:
83
- - `target=js` - generates a `_pb.js` file for every `.proto` input file.
84
- - `target=ts` - generates a `_pb.ts` file for every `.proto` input file.
85
- - `target=dts` - generates a `_pb.d.ts` file for every `.proto` input file.
81
+ - `target=js`: Generates a `_pb.js` file for every `.proto` input file.
82
+ - `target=ts`: Generates a `_pb.ts` file for every `.proto` input file.
83
+ - `target=dts`: Generates a `_pb.d.ts` file for every `.proto` input file.
86
84
 
87
- Multiple values can be given by separating them with `+`, for example
88
- `target=js+dts`.
85
+ You can pass multiple values by separating them with `+`—for example, `target=js+dts`.
89
86
 
90
- By default, we generate JavaScript and TypeScript declaration files, which
91
- produces the smallest code size and is the most compatible with various
92
- bundler configurations. If you prefer to generate TypeScript, use `target=ts`.
87
+ By default, it generates JavaScript and TypeScript declaration files, which produces the smallest code size and is the
88
+ most compatible with various bundler configurations. If you prefer to generate TypeScript, use `target=ts`.
93
89
 
94
90
  ### `import_extension`
95
91
 
96
- By default, [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
97
- (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
98
- does not add a file extensions to import paths.
92
+ By default, `protoc-gen-es` doesn't add file extensions to import paths. However, some
93
+ environments require an import extension. For example, using ECMAScript modules in Node.js
94
+ requires the `.js` extension, and Deno requires `.ts`. With this plugin option, you can add `.js`/`.ts` extensions in
95
+ import paths with the given value. Possible values:
99
96
 
100
- Some environments require an import extension. For example, using [ECMAScript modules in Node.js](https://www.typescriptlang.org/docs/handbook/esm-node.html) requires the `.js` extension, and Deno requires `.ts`. With this plugin option, you can add `.js`/`.ts` extensions
101
- in import paths with the given value. For example, set
102
-
103
- - `import_extension=.js` to add the `.js` extension.
104
- - `import_extension=.ts` to add the `.ts` extension.
105
- - `import_extension=none` to not add an extension. (Default)
97
+ - `import_extension=none`: Doesn't add an extension. (Default)
98
+ - `import_extension=js`: Adds the `.js` extension.
99
+ - `import_extension=ts`. Adds the `.ts` extension.
106
100
 
107
101
  ### `js_import_style`
108
102
 
109
- By default, [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
110
- (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
111
- generate ECMAScript `import` and `export` statements. For use cases where
112
- CommonJS is difficult to avoid, this option can be used to generate CommonJS
113
- `require()` calls.
103
+ By default, `protoc-gen-es` generates ECMAScript `import` and `export` statements. For use cases where CommonJS is
104
+ difficult to avoid, this option can be used to generate CommonJS `require()` calls. Possible values:
114
105
 
115
- Possible values:
116
- - `js_import_style=module` generate ECMAScript `import` / `export` statements -
117
- the default behavior.
118
- - `js_import_style=legacy_commonjs` generate CommonJS `require()` calls.
106
+ - `js_import_style=module`: Generates ECMAScript `import`/`export` statements. (Default)
107
+ - `js_import_style=legacy_commonjs`: Generates CommonJS `require()` calls.
119
108
 
120
109
  ### `keep_empty_files=true`
121
110
 
122
- By default, [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
123
- (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
124
- omit empty files from the plugin output. This option disables pruning of
125
- empty files, to allow for smooth interoperation with Bazel and similar
126
- tooling that requires all output files to be declared ahead of time.
127
- Unless you use Bazel, it is very unlikely that you need this option.
111
+ By default, `protoc-gen-es` omits empty files from the plugin output. This option disables pruning of empty files to
112
+ allow for smooth interoperation with Bazel and similar tooling that requires all output files to be declared ahead of
113
+ time. Unless you use Bazel, you probably don't need this option.
128
114
 
129
115
  ### `ts_nocheck=true`
130
116
 
131
- [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es) generates
132
- valid TypeScript for current versions of the TypeScript compiler with standard
133
- settings.
134
-
135
- In case you use compiler settings that yield an error for generated code, you
136
- can set the plugin option `ts_nocheck=true`. This will generate an annotation at
117
+ `protoc-gen-es` generates valid TypeScript for current versions of the TypeScript compiler with standard settings.
118
+ If you use compiler settings that yield an error for generated code, setting this option generates an annotation at
137
119
  the top of each file to skip type checks: `// @ts-nocheck`.
138
120
 
139
121
  ### `json_types=true`
140
122
 
141
- Generates JSON types for every Protobuf message and enumeration. Calling `toJson()`
142
- will automatically return the JSON type if available.
123
+ Generates JSON types for every Protobuf message and enumeration. Calling `toJson()` automatically returns the JSON type
124
+ if available. Learn more about [JSON types](https://github.com/bufbuild/protobuf-es/blob/main/MANUAL.md#json-types).
package/bin/protoc-gen-es CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const {runNodeJs} = require("@bufbuild/protoplugin");
4
- const {protocGenEs} = require("../dist/cjs/src/protoc-gen-es-plugin.js");
3
+ const { runNodeJs } = require("@bufbuild/protoplugin");
4
+ const { protocGenEs } = require("../dist/cjs/src/protoc-gen-es-plugin.js");
5
5
 
6
6
  runNodeJs(protocGenEs);
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "2.0.0-beta.1",
4
- "description": "Protocol Buffers code generator for ECMAScript",
3
+ "version": "2.0.0-beta.3",
5
4
  "license": "Apache-2.0",
5
+ "description": "Protocol Buffers code generator for ECMAScript",
6
+ "keywords": [
7
+ "protobuf",
8
+ "schema",
9
+ "typescript",
10
+ "ecmascript",
11
+ "protoc-plugin"
12
+ ],
6
13
  "repository": {
7
14
  "type": "git",
8
15
  "url": "https://github.com/bufbuild/protobuf-es.git",
@@ -15,16 +22,19 @@
15
22
  "node": ">=14"
16
23
  },
17
24
  "scripts": {
18
- "clean": "rm -rf ./dist/cjs/*",
19
- "build": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist/cjs"
25
+ "prebuild": "rm -rf ./dist/cjs/*",
26
+ "build": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist/cjs",
27
+ "format": "prettier --write --ignore-unknown '.' '!dist' '!.turbo'",
28
+ "license-header": "license-header",
29
+ "lint": "eslint --max-warnings 0 ."
20
30
  },
21
31
  "preferUnplugged": true,
22
32
  "dependencies": {
23
- "@bufbuild/protobuf": "^2.0.0-beta.1",
24
- "@bufbuild/protoplugin": "2.0.0-beta.1"
33
+ "@bufbuild/protobuf": "^2.0.0-beta.3",
34
+ "@bufbuild/protoplugin": "2.0.0-beta.3"
25
35
  },
26
36
  "peerDependencies": {
27
- "@bufbuild/protobuf": "2.0.0-beta.1"
37
+ "@bufbuild/protobuf": "2.0.0-beta.3"
28
38
  },
29
39
  "peerDependenciesMeta": {
30
40
  "@bufbuild/protobuf": {
@@ -0,0 +1 @@
1
+ export declare const protocGenEs: import("@bufbuild/protoplugin").Plugin;
@@ -54,10 +54,10 @@ function generateTs(schema) {
54
54
  for (const file of schema.files) {
55
55
  const f = schema.generateFile(file.name + "_pb.ts");
56
56
  f.preamble(file);
57
- const { GenDescFile } = f.runtime.codegen;
57
+ const { GenFile } = f.runtime.codegen;
58
58
  const fileDesc = f.importSchema(file);
59
59
  generateDescDoc(f, file);
60
- f.print(f.export("const", fileDesc.name), ": ", GenDescFile, " = ", pure);
60
+ f.print(f.export("const", fileDesc.name), ": ", GenFile, " = ", pure);
61
61
  f.print(" ", getFileDescCall(f, file, schema), ";");
62
62
  f.print();
63
63
  for (const desc of schema.typesInFile(file)) {
@@ -70,13 +70,13 @@ function generateTs(schema) {
70
70
  generateDescDoc(f, desc);
71
71
  const name = f.importSchema(desc).name;
72
72
  const Shape = f.importShape(desc);
73
- const { GenDescMessage, messageDesc } = f.runtime.codegen;
73
+ const { GenMessage, messageDesc } = f.runtime.codegen;
74
74
  if (schema.options.jsonTypes) {
75
75
  const JsonType = f.importJson(desc);
76
- f.print(f.export("const", name), ": ", GenDescMessage, "<", Shape, ", ", JsonType, ">", " = ", pure);
76
+ f.print(f.export("const", name), ": ", GenMessage, "<", Shape, ", ", JsonType, ">", " = ", pure);
77
77
  }
78
78
  else {
79
- f.print(f.export("const", name), ": ", GenDescMessage, "<", Shape, ">", " = ", pure);
79
+ f.print(f.export("const", name), ": ", GenMessage, "<", Shape, ">", " = ", pure);
80
80
  }
81
81
  const call = (0, util_1.functionCall)(messageDesc, [fileDesc, ...(0, codegenv1_1.pathInFileDesc)(desc)]);
82
82
  f.print(" ", call, ";");
@@ -91,13 +91,13 @@ function generateTs(schema) {
91
91
  generateDescDoc(f, desc);
92
92
  const name = f.importSchema(desc).name;
93
93
  const Shape = f.importShape(desc);
94
- const { GenDescEnum, enumDesc } = f.runtime.codegen;
94
+ const { GenEnum, enumDesc } = f.runtime.codegen;
95
95
  if (schema.options.jsonTypes) {
96
96
  const JsonType = f.importJson(desc);
97
- f.print(f.export("const", name), ": ", GenDescEnum, "<", Shape, ", ", JsonType, ">", " = ", pure);
97
+ f.print(f.export("const", name), ": ", GenEnum, "<", Shape, ", ", JsonType, ">", " = ", pure);
98
98
  }
99
99
  else {
100
- f.print(f.export("const", name), ": ", GenDescEnum, "<", Shape, ">", " = ", pure);
100
+ f.print(f.export("const", name), ": ", GenEnum, "<", Shape, ">", " = ", pure);
101
101
  }
102
102
  const call = (0, util_1.functionCall)(enumDesc, [fileDesc, ...(0, codegenv1_1.pathInFileDesc)(desc)]);
103
103
  f.print(" ", call, ";");
@@ -105,23 +105,23 @@ function generateTs(schema) {
105
105
  break;
106
106
  }
107
107
  case "extension": {
108
- const { GenDescExtension, extDesc } = f.runtime.codegen;
108
+ const { GenExtension, extDesc } = f.runtime.codegen;
109
109
  const name = f.importSchema(desc).name;
110
110
  const E = f.importShape(desc.extendee);
111
111
  const V = (0, util_1.fieldTypeScriptType)(desc, f.runtime).typing;
112
112
  const call = (0, util_1.functionCall)(extDesc, [fileDesc, ...(0, codegenv1_1.pathInFileDesc)(desc)]);
113
113
  f.print(f.jsDoc(desc));
114
- f.print(f.export("const", name), ": ", GenDescExtension, "<", E, ", ", V, ">", " = ", pure);
114
+ f.print(f.export("const", name), ": ", GenExtension, "<", E, ", ", V, ">", " = ", pure);
115
115
  f.print(" ", call, ";");
116
116
  f.print();
117
117
  break;
118
118
  }
119
119
  case "service": {
120
- const { GenDescService, serviceDesc } = f.runtime.codegen;
120
+ const { GenService, serviceDesc } = f.runtime.codegen;
121
121
  const name = f.importSchema(desc).name;
122
122
  const call = (0, util_1.functionCall)(serviceDesc, [fileDesc, ...(0, codegenv1_1.pathInFileDesc)(desc)]);
123
123
  f.print(f.jsDoc(desc));
124
- f.print(f.export("const", name), ": ", GenDescService, "<", getServiceShapeExpr(f, desc), "> = ", pure);
124
+ f.print(f.export("const", name), ": ", GenService, "<", getServiceShapeExpr(f, desc), "> = ", pure);
125
125
  f.print(" ", call, ";");
126
126
  f.print();
127
127
  break;
@@ -203,10 +203,10 @@ function generateDts(schema) {
203
203
  for (const file of schema.files) {
204
204
  const f = schema.generateFile(file.name + "_pb.d.ts");
205
205
  f.preamble(file);
206
- const { GenDescFile } = f.runtime.codegen;
206
+ const { GenFile } = f.runtime.codegen;
207
207
  const fileDesc = f.importSchema(file);
208
208
  generateDescDoc(f, file);
209
- f.print(f.export("declare const", fileDesc.name), ": ", GenDescFile, ";");
209
+ f.print(f.export("declare const", fileDesc.name), ": ", GenFile, ";");
210
210
  f.print();
211
211
  for (const desc of schema.typesInFile(file)) {
212
212
  switch (desc.kind) {
@@ -217,14 +217,14 @@ function generateDts(schema) {
217
217
  }
218
218
  const name = f.importSchema(desc).name;
219
219
  const Shape = f.importShape(desc);
220
- const { GenDescMessage } = f.runtime.codegen;
220
+ const { GenMessage } = f.runtime.codegen;
221
221
  generateDescDoc(f, desc);
222
222
  if (schema.options.jsonTypes) {
223
223
  const JsonType = f.importJson(desc);
224
- f.print(f.export("declare const", name), ": ", GenDescMessage, "<", Shape, ", ", JsonType, ">", ";");
224
+ f.print(f.export("declare const", name), ": ", GenMessage, "<", Shape, ", ", JsonType, ">", ";");
225
225
  }
226
226
  else {
227
- f.print(f.export("declare const", name), ": ", GenDescMessage, "<", Shape, ">", ";");
227
+ f.print(f.export("declare const", name), ": ", GenMessage, "<", Shape, ">", ";");
228
228
  }
229
229
  f.print();
230
230
  break;
@@ -237,32 +237,32 @@ function generateDts(schema) {
237
237
  generateDescDoc(f, desc);
238
238
  const name = f.importSchema(desc).name;
239
239
  const Shape = f.importShape(desc);
240
- const { GenDescEnum } = f.runtime.codegen;
240
+ const { GenEnum } = f.runtime.codegen;
241
241
  if (schema.options.jsonTypes) {
242
242
  const JsonType = f.importJson(desc);
243
- f.print(f.export("declare const", name), ": ", GenDescEnum, "<", Shape, ", ", JsonType, ">;");
243
+ f.print(f.export("declare const", name), ": ", GenEnum, "<", Shape, ", ", JsonType, ">;");
244
244
  }
245
245
  else {
246
- f.print(f.export("declare const", name), ": ", GenDescEnum, "<", Shape, ">;");
246
+ f.print(f.export("declare const", name), ": ", GenEnum, "<", Shape, ">;");
247
247
  }
248
248
  f.print();
249
249
  break;
250
250
  }
251
251
  case "extension": {
252
- const { GenDescExtension } = f.runtime.codegen;
252
+ const { GenExtension } = f.runtime.codegen;
253
253
  const name = f.importSchema(desc).name;
254
254
  const E = f.importShape(desc.extendee);
255
255
  const V = (0, util_1.fieldTypeScriptType)(desc, f.runtime).typing;
256
256
  f.print(f.jsDoc(desc));
257
- f.print(f.export("declare const", name), ": ", GenDescExtension, "<", E, ", ", V, ">;");
257
+ f.print(f.export("declare const", name), ": ", GenExtension, "<", E, ", ", V, ">;");
258
258
  f.print();
259
259
  break;
260
260
  }
261
261
  case "service": {
262
- const { GenDescService } = f.runtime.codegen;
262
+ const { GenService } = f.runtime.codegen;
263
263
  const name = f.importSchema(desc).name;
264
264
  f.print(f.jsDoc(desc));
265
- f.print(f.export("declare const", name), ": ", GenDescService, "<", getServiceShapeExpr(f, desc), ">;");
265
+ f.print(f.export("declare const", name), ": ", GenService, "<", getServiceShapeExpr(f, desc), ">;");
266
266
  f.print();
267
267
  break;
268
268
  }
@@ -316,27 +316,23 @@ function getFileDescCall(f, file, schema) {
316
316
  }));
317
317
  return (0, util_1.functionCall)(fileDesc, [
318
318
  f.string(info.base64()),
319
- (0, util_1.arrayLiteral)(deps),
319
+ f.array(deps),
320
320
  ]);
321
321
  }
322
322
  return (0, util_1.functionCall)(fileDesc, [f.string(info.base64())]);
323
323
  }
324
324
  // prettier-ignore
325
325
  function getServiceShapeExpr(f, service) {
326
- const p = [];
327
- function print(...printables) {
328
- p.push(...printables, "\n");
329
- }
330
- print("{");
326
+ const p = ["{\n"];
331
327
  for (const method of service.methods) {
332
- print(f.jsDoc(method, " "));
333
- print(" ", method.localName, ": {");
334
- print(" methodKind: ", f.string(method.methodKind), ";");
335
- print(" input: typeof ", f.importSchema(method.input, true), ";");
336
- print(" output: typeof ", f.importSchema(method.output, true), ";");
337
- print(" },");
328
+ p.push(f.jsDoc(method, " "), "\n");
329
+ p.push(" ", method.localName, ": {\n");
330
+ p.push(" methodKind: ", f.string(method.methodKind), ";\n");
331
+ p.push(" input: typeof ", f.importSchema(method.input, true), ";\n");
332
+ p.push(" output: typeof ", f.importSchema(method.output, true), ";\n");
333
+ p.push(" },\n");
338
334
  }
339
- print("}");
335
+ p.push("}");
340
336
  return p;
341
337
  }
342
338
  // prettier-ignore
@@ -0,0 +1,8 @@
1
+ import { type DescExtension, type DescField } from "@bufbuild/protobuf";
2
+ import type { GeneratedFile, Printable } from "@bufbuild/protoplugin";
3
+ export declare function fieldTypeScriptType(field: DescField | DescExtension, imports: GeneratedFile["runtime"]): {
4
+ typing: Printable;
5
+ optional: boolean;
6
+ };
7
+ export declare function fieldJsonType(field: DescField | DescExtension): Printable;
8
+ export declare function functionCall(fn: Printable, args: Printable[], typeParams?: Printable[]): Printable;
@@ -13,7 +13,9 @@
13
13
  // See the License for the specific language governing permissions and
14
14
  // limitations under the License.
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.arrayLiteral = exports.functionCall = exports.fieldJsonType = exports.fieldTypeScriptType = void 0;
16
+ exports.fieldTypeScriptType = fieldTypeScriptType;
17
+ exports.fieldJsonType = fieldJsonType;
18
+ exports.functionCall = functionCall;
17
19
  const protobuf_1 = require("@bufbuild/protobuf");
18
20
  const codegenv1_1 = require("@bufbuild/protobuf/codegenv1");
19
21
  const wkt_1 = require("@bufbuild/protobuf/wkt");
@@ -91,7 +93,6 @@ function fieldTypeScriptType(field, imports) {
91
93
  }
92
94
  return { typing, optional };
93
95
  }
94
- exports.fieldTypeScriptType = fieldTypeScriptType;
95
96
  function messageFieldTypeScriptType(field, imports) {
96
97
  var _a;
97
98
  if ((0, wkt_1.isWrapperDesc)(field.message) &&
@@ -186,7 +187,6 @@ function fieldJsonType(field) {
186
187
  }
187
188
  }
188
189
  }
189
- exports.fieldJsonType = fieldJsonType;
190
190
  function functionCall(fn, args, typeParams) {
191
191
  let tp = [];
192
192
  if (typeParams !== undefined && typeParams.length > 0) {
@@ -194,11 +194,6 @@ function functionCall(fn, args, typeParams) {
194
194
  }
195
195
  return [fn, ...tp, "(", commaSeparate(args), ")"];
196
196
  }
197
- exports.functionCall = functionCall;
198
- function arrayLiteral(elements) {
199
- return ["[", commaSeparate(elements), "]"];
200
- }
201
- exports.arrayLiteral = arrayLiteral;
202
197
  function commaSeparate(elements) {
203
198
  const r = [];
204
199
  for (let i = 0; i < elements.length; i++) {
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "2.0.0-beta.1",
4
- "description": "Protocol Buffers code generator for ECMAScript",
3
+ "version": "2.0.0-beta.3",
5
4
  "license": "Apache-2.0",
5
+ "description": "Protocol Buffers code generator for ECMAScript",
6
+ "keywords": [
7
+ "protobuf",
8
+ "schema",
9
+ "typescript",
10
+ "ecmascript",
11
+ "protoc-plugin"
12
+ ],
6
13
  "repository": {
7
14
  "type": "git",
8
15
  "url": "https://github.com/bufbuild/protobuf-es.git",
@@ -15,16 +22,19 @@
15
22
  "node": ">=14"
16
23
  },
17
24
  "scripts": {
18
- "clean": "rm -rf ./dist/cjs/*",
19
- "build": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist/cjs"
25
+ "prebuild": "rm -rf ./dist/cjs/*",
26
+ "build": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist/cjs",
27
+ "format": "prettier --write --ignore-unknown '.' '!dist' '!.turbo'",
28
+ "license-header": "license-header",
29
+ "lint": "eslint --max-warnings 0 ."
20
30
  },
21
31
  "preferUnplugged": true,
22
32
  "dependencies": {
23
- "@bufbuild/protobuf": "^2.0.0-beta.1",
24
- "@bufbuild/protoplugin": "2.0.0-beta.1"
33
+ "@bufbuild/protobuf": "^2.0.0-beta.3",
34
+ "@bufbuild/protoplugin": "2.0.0-beta.3"
25
35
  },
26
36
  "peerDependencies": {
27
- "@bufbuild/protobuf": "2.0.0-beta.1"
37
+ "@bufbuild/protobuf": "2.0.0-beta.3"
28
38
  },
29
39
  "peerDependenciesMeta": {
30
40
  "@bufbuild/protobuf": {