@bufbuild/protoplugin 1.7.2 → 1.9.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.
Files changed (55) hide show
  1. package/dist/cjs/create-es-plugin.d.ts +1 -1
  2. package/dist/cjs/ecmascript/file-preamble.d.ts +2 -0
  3. package/dist/cjs/ecmascript/file-preamble.js +74 -0
  4. package/dist/cjs/ecmascript/generated-file.d.ts +2 -2
  5. package/dist/cjs/ecmascript/generated-file.js +90 -31
  6. package/dist/cjs/ecmascript/import-path.d.ts +1 -1
  7. package/dist/cjs/ecmascript/index.d.ts +4 -8
  8. package/dist/cjs/ecmascript/index.js +10 -17
  9. package/dist/cjs/ecmascript/jsdoc.d.ts +6 -0
  10. package/dist/cjs/ecmascript/jsdoc.js +1 -0
  11. package/dist/cjs/ecmascript/{custom-options.d.ts → legacy-custom-options.d.ts} +2 -2
  12. package/dist/cjs/ecmascript/{gencommon.d.ts → legacy-gencommon.d.ts} +12 -7
  13. package/dist/cjs/ecmascript/{gencommon.js → legacy-gencommon.js} +50 -98
  14. package/dist/cjs/ecmascript/opaque-printables.d.ts +27 -0
  15. package/dist/{esm/ecmascript/export-declaration.js → cjs/ecmascript/opaque-printables.js} +2 -7
  16. package/dist/cjs/ecmascript/parameter.d.ts +2 -2
  17. package/dist/cjs/ecmascript/schema.d.ts +2 -2
  18. package/dist/cjs/ecmascript/schema.js +2 -2
  19. package/dist/cjs/ecmascript/transpile.js +1 -1
  20. package/dist/cjs/error.d.ts +2 -0
  21. package/dist/cjs/error.js +9 -1
  22. package/dist/cjs/index.d.ts +2 -2
  23. package/dist/cjs/run-node.js +1 -1
  24. package/dist/esm/create-es-plugin.d.ts +1 -1
  25. package/dist/esm/ecmascript/file-preamble.d.ts +2 -0
  26. package/dist/esm/ecmascript/file-preamble.js +70 -0
  27. package/dist/esm/ecmascript/generated-file.d.ts +2 -2
  28. package/dist/esm/ecmascript/generated-file.js +90 -31
  29. package/dist/esm/ecmascript/import-path.d.ts +1 -1
  30. package/dist/esm/ecmascript/index.d.ts +4 -8
  31. package/dist/esm/ecmascript/index.js +3 -10
  32. package/dist/esm/ecmascript/jsdoc.d.ts +6 -0
  33. package/dist/esm/ecmascript/jsdoc.js +1 -0
  34. package/dist/esm/ecmascript/{custom-options.d.ts → legacy-custom-options.d.ts} +2 -2
  35. package/dist/esm/ecmascript/{custom-options.js → legacy-custom-options.js} +1 -1
  36. package/dist/esm/ecmascript/{gencommon.d.ts → legacy-gencommon.d.ts} +12 -7
  37. package/dist/esm/ecmascript/{gencommon.js → legacy-gencommon.js} +49 -95
  38. package/dist/esm/ecmascript/opaque-printables.d.ts +27 -0
  39. package/dist/{cjs/ecmascript/export-declaration.js → esm/ecmascript/opaque-printables.js} +1 -11
  40. package/dist/esm/ecmascript/parameter.d.ts +2 -2
  41. package/dist/esm/ecmascript/schema.d.ts +2 -2
  42. package/dist/esm/ecmascript/schema.js +2 -2
  43. package/dist/esm/ecmascript/transpile.js +1 -1
  44. package/dist/esm/error.d.ts +2 -0
  45. package/dist/esm/error.js +7 -0
  46. package/dist/esm/index.d.ts +2 -2
  47. package/dist/esm/run-node.js +2 -2
  48. package/package.json +5 -16
  49. package/dist/cjs/ecmascript/export-declaration.d.ts +0 -7
  50. package/dist/esm/ecmascript/export-declaration.d.ts +0 -7
  51. package/dist/proxy/ecmascript/index.d.ts +0 -1
  52. package/dist/proxy/ecmascript/index.js +0 -1
  53. package/dist/proxy/index.d.ts +0 -1
  54. package/dist/proxy/index.js +0 -1
  55. /package/dist/cjs/ecmascript/{custom-options.js → legacy-custom-options.js} +0 -0
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  // Copyright 2021-2024 Buf Technologies, Inc.
2
3
  //
3
4
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,10 +12,4 @@
11
12
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13
  // See the License for the specific language governing permissions and
13
14
  // limitations under the License.
14
- export function createExportDeclaration(declaration, name) {
15
- return {
16
- kind: "es_export_decl",
17
- declaration,
18
- name,
19
- };
20
- }
15
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
- import { Target } from "./target.js";
2
- import { RewriteImports } from "./import-path.js";
1
+ import type { Target } from "./target.js";
2
+ import type { RewriteImports } from "./import-path.js";
3
3
  export interface ParsedParameter {
4
4
  targets: Target[];
5
5
  tsNocheck: boolean;
@@ -1,9 +1,9 @@
1
1
  import type { CodeGeneratorRequest, DescFile } from "@bufbuild/protobuf";
2
2
  import { FeatureSetDefaults } from "@bufbuild/protobuf";
3
3
  import type { FileInfo, GeneratedFile } from "./generated-file.js";
4
- import { RuntimeImports } from "./runtime-imports.js";
4
+ import type { RuntimeImports } from "./runtime-imports.js";
5
5
  import type { Target } from "./target.js";
6
- import { ParsedParameter } from "./parameter";
6
+ import type { ParsedParameter } from "./parameter.js";
7
7
  /**
8
8
  * Schema describes the files and types that the plugin is requested to
9
9
  * generate.
@@ -19,7 +19,7 @@ const generated_file_js_1 = require("./generated-file.js");
19
19
  const runtime_imports_js_1 = require("./runtime-imports.js");
20
20
  const import_symbol_js_1 = require("./import-symbol.js");
21
21
  const import_path_js_1 = require("./import-path.js");
22
- const gencommon_1 = require("./gencommon");
22
+ const file_preamble_js_1 = require("./file-preamble.js");
23
23
  function createSchema(request, parameter, pluginName, pluginVersion, featureSetDefaults) {
24
24
  const descriptorSet = (0, protobuf_1.createDescriptorSet)(request.protoFile, {
25
25
  featureSetDefaults,
@@ -31,7 +31,7 @@ function createSchema(request, parameter, pluginName, pluginVersion, featureSetD
31
31
  const from = (0, import_path_js_1.makeImportPath)(desc.file, parameter.bootstrapWkt, filesToGenerate);
32
32
  return (0, import_symbol_js_1.createImportSymbol)(name, from);
33
33
  };
34
- const createPreamble = (descFile) => (0, gencommon_1.makeFilePreamble)(descFile, pluginName, pluginVersion, parameter.sanitizedParameter, parameter.tsNocheck);
34
+ const createPreamble = (descFile) => (0, file_preamble_js_1.makeFilePreamble)(descFile, pluginName, pluginVersion, parameter.sanitizedParameter, parameter.tsNocheck);
35
35
  let target;
36
36
  const generatedFiles = [];
37
37
  return {
@@ -118,7 +118,7 @@ function transpile(files, transpileJs, transpileDts, jsImportStyle) {
118
118
  throw err;
119
119
  }
120
120
  if (result.emitSkipped) {
121
- throw Error("An problem occurred during transpilation and files were not generated. Contact the plugin author for support.");
121
+ throw Error("A problem occurred during transpilation and files were not generated. Contact the plugin author for support.");
122
122
  }
123
123
  return results;
124
124
  }
@@ -1,4 +1,6 @@
1
1
  export declare class PluginOptionError extends Error {
2
+ name: string;
2
3
  constructor(option: string, reason?: unknown);
3
4
  }
4
5
  export declare function reasonToString(reason: unknown): string;
6
+ export declare function isPluginOptionError(arg: unknown): arg is PluginOptionError;
package/dist/cjs/error.js CHANGED
@@ -13,13 +13,14 @@
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.reasonToString = exports.PluginOptionError = void 0;
16
+ exports.isPluginOptionError = exports.reasonToString = exports.PluginOptionError = void 0;
17
17
  class PluginOptionError extends Error {
18
18
  constructor(option, reason) {
19
19
  const detail = reason !== undefined ? reasonToString(reason) : "";
20
20
  super(detail.length > 0
21
21
  ? `invalid option "${option}": ${detail}`
22
22
  : `invalid option "${option}"`);
23
+ this.name = "PluginOptionError";
23
24
  }
24
25
  }
25
26
  exports.PluginOptionError = PluginOptionError;
@@ -33,3 +34,10 @@ function reasonToString(reason) {
33
34
  return String(reason);
34
35
  }
35
36
  exports.reasonToString = reasonToString;
37
+ function isPluginOptionError(arg) {
38
+ if (!(arg instanceof Error)) {
39
+ return false;
40
+ }
41
+ return arg.name === "PluginOptionError";
42
+ }
43
+ exports.isPluginOptionError = isPluginOptionError;
@@ -1,5 +1,5 @@
1
- import { Schema as SchemaInternal } from "./ecmascript/schema.js";
2
- export { Plugin } from "./plugin.js";
1
+ import type { Schema as SchemaInternal } from "./ecmascript/schema.js";
2
+ export type { Plugin } from "./plugin.js";
3
3
  export { runNodeJs } from "./run-node.js";
4
4
  export { createEcmaScriptPlugin } from "./create-es-plugin.js";
5
5
  /**
@@ -46,7 +46,7 @@ function runNodeJs(plugin) {
46
46
  })
47
47
  .then(() => process.exit(0))
48
48
  .catch((reason) => {
49
- const message = reason instanceof error_js_1.PluginOptionError
49
+ const message = (0, error_js_1.isPluginOptionError)(reason)
50
50
  ? reason.message
51
51
  : (0, error_js_1.reasonToString)(reason);
52
52
  process.stderr.write(`${plugin.name}: ${message}\n`);
@@ -1,4 +1,4 @@
1
- import { Schema } from "./ecmascript/schema.js";
1
+ import type { Schema } from "./ecmascript/schema.js";
2
2
  import type { FileInfo } from "./ecmascript/generated-file.js";
3
3
  import type { Plugin } from "./plugin.js";
4
4
  import type { FeatureSetDefaults } from "@bufbuild/protobuf";
@@ -0,0 +1,2 @@
1
+ import type { DescFile } from "@bufbuild/protobuf";
2
+ export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string, parameter: string, tsNoCheck: boolean): string;
@@ -0,0 +1,70 @@
1
+ // Copyright 2021-2024 Buf Technologies, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { Edition } from "@bufbuild/protobuf";
15
+ export function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck) {
16
+ const builder = [];
17
+ const trimSuffix = (str, suffix) => str.endsWith(suffix) ? str.substring(0, str.length - suffix.length) : str;
18
+ const writeLeadingComments = (comments) => {
19
+ for (let comment of comments.leadingDetached) {
20
+ comment = trimSuffix(comment, "\n");
21
+ for (const line of comment.split("\n")) {
22
+ builder.push(`//${line}\n`);
23
+ }
24
+ builder.push("\n");
25
+ }
26
+ if (comments.leading !== undefined) {
27
+ const comment = trimSuffix(comments.leading, "\n");
28
+ for (const line of comment.split("\n")) {
29
+ builder.push(`//${line}\n`);
30
+ }
31
+ builder.push("\n");
32
+ }
33
+ };
34
+ writeLeadingComments(file.getSyntaxComments());
35
+ builder.push(`// @generated by ${pluginName} ${pluginVersion}`);
36
+ if (parameter !== "") {
37
+ builder.push(` with parameter "${parameter}"`);
38
+ }
39
+ builder.push("\n");
40
+ builder.push(`// @generated from file ${file.name}.proto (`);
41
+ if (file.proto.package !== undefined) {
42
+ builder.push(`package ${file.proto.package}, `);
43
+ }
44
+ switch (file.edition) {
45
+ case Edition.EDITION_PROTO2:
46
+ builder.push(`syntax proto2)\n`);
47
+ break;
48
+ case Edition.EDITION_PROTO3:
49
+ builder.push(`syntax proto3)\n`);
50
+ break;
51
+ default: {
52
+ const editionString = Edition[file.edition];
53
+ if (typeof editionString == "string") {
54
+ const e = editionString.replace("EDITION_", "").toLowerCase();
55
+ builder.push(`edition ${e})\n`);
56
+ }
57
+ else {
58
+ builder.push(`unknown edition\n`);
59
+ }
60
+ break;
61
+ }
62
+ }
63
+ builder.push("/* eslint-disable */\n");
64
+ if (tsNoCheck) {
65
+ builder.push("// @ts-nocheck\n");
66
+ }
67
+ builder.push("\n");
68
+ writeLeadingComments(file.getPackageComments());
69
+ return trimSuffix(builder.join(""), "\n");
70
+ }
@@ -1,12 +1,12 @@
1
1
  import type { AnyDesc, DescEnum, DescExtension, DescFile, DescMessage } from "@bufbuild/protobuf";
2
2
  import type { ImportSymbol } from "./import-symbol.js";
3
3
  import type { RuntimeImports } from "./runtime-imports.js";
4
- import type { ExportDeclaration } from "./export-declaration.js";
5
4
  import type { JSDocBlock } from "./jsdoc.js";
5
+ import type { ExportDeclaration, LiteralProtoInt64, LiteralString, RefDescEnum, RefDescMessage } from "./opaque-printables.js";
6
6
  /**
7
7
  * All types that can be passed to GeneratedFile.print()
8
8
  */
9
- export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | ExportDeclaration | JSDocBlock | DescMessage | DescEnum | DescExtension | Printable[];
9
+ export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | ExportDeclaration | JSDocBlock | LiteralString | LiteralProtoInt64 | RefDescMessage | RefDescEnum | DescMessage | DescEnum | DescExtension | Printable[];
10
10
  /**
11
11
  * FileInfo represents an intermediate type using for transpiling TypeScript internally.
12
12
  */
@@ -11,10 +11,9 @@
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 { LongType, protoInt64, ScalarType } from "@bufbuild/protobuf";
14
15
  import { createImportSymbol } from "./import-symbol.js";
15
- import { literalString } from "./gencommon.js";
16
16
  import { makeImportPathRelative } from "./import-path.js";
17
- import { createExportDeclaration } from "./export-declaration.js";
18
17
  import { createJsDocBlock } from "./jsdoc.js";
19
18
  export function createGeneratedFile(name, importPath, jsImportStyle, rewriteImportPath, createTypeImport, runtimeImports, createPreamble) {
20
19
  let preamble;
@@ -44,10 +43,15 @@ export function createGeneratedFile(name, importPath, jsImportStyle, rewriteImpo
44
43
  return createImportSymbol(name, importPath);
45
44
  },
46
45
  exportDecl(declaration, name) {
47
- return createExportDeclaration(declaration, name);
46
+ return {
47
+ kind: "es_export_decl",
48
+ declaration,
49
+ name,
50
+ };
48
51
  },
49
52
  string(string) {
50
- return literalString(string);
53
+ // We do not use LiteralString, which was added later, to maintain backwards compatibility
54
+ return escapeString(string);
51
55
  },
52
56
  jsDoc(textOrDesc, indentation) {
53
57
  return createJsDocBlock(textOrDesc, indentation);
@@ -83,16 +87,16 @@ function elToContent(el, importerPath, rewriteImportPath, legacyCommonJs) {
83
87
  if (legacyCommonJs) {
84
88
  const p = names.map(({ name, alias }) => alias == undefined ? name : `${name}: ${alias}`);
85
89
  const what = `{ ${p.join(", ")} }`;
86
- c.push(`const ${what} = require(${literalString(from)});\n`);
90
+ c.push(`const ${what} = require(${escapeString(from)});\n`);
87
91
  }
88
92
  else {
89
93
  const p = names.map(({ name, alias }) => alias == undefined ? name : `${name} as ${alias}`);
90
94
  const what = `{ ${p.join(", ")} }`;
91
95
  if (typeOnly) {
92
- c.push(`import type ${what} from ${literalString(from)};\n`);
96
+ c.push(`import type ${what} from ${escapeString(from)};\n`);
93
97
  }
94
98
  else {
95
- c.push(`import ${what} from ${literalString(from)};\n`);
99
+ c.push(`import ${what} from ${escapeString(from)};\n`);
96
100
  }
97
101
  }
98
102
  });
@@ -149,17 +153,17 @@ function printableToEl(printables, el, createTypeImport, runtimeImports) {
149
153
  el.push(p);
150
154
  break;
151
155
  case "number":
152
- el.push(...literalNumber(p, runtimeImports));
156
+ elNumber(el, p, runtimeImports);
153
157
  break;
154
158
  case "boolean":
155
159
  el.push(p.toString());
156
160
  break;
157
161
  case "bigint":
158
- el.push(...literalBigint(p, runtimeImports));
162
+ elBigint(el, p, runtimeImports);
159
163
  break;
160
164
  case "object":
161
165
  if (p instanceof Uint8Array) {
162
- el.push(literalUint8Array(p));
166
+ elUint8Array(el, p);
163
167
  break;
164
168
  }
165
169
  switch (p.kind) {
@@ -169,6 +173,12 @@ function printableToEl(printables, el, createTypeImport, runtimeImports) {
169
173
  case "es_jsdoc":
170
174
  el.push(p.toString());
171
175
  break;
176
+ case "es_string":
177
+ el.push(escapeString(p.value));
178
+ break;
179
+ case "es_proto_int64":
180
+ elProtoInt64(el, p, runtimeImports);
181
+ break;
172
182
  case "es_export_decl":
173
183
  el.push({
174
184
  kind: "es_export_stmt",
@@ -178,6 +188,12 @@ function printableToEl(printables, el, createTypeImport, runtimeImports) {
178
188
  : createTypeImport(p.name).name,
179
189
  });
180
190
  break;
191
+ case "es_ref_message":
192
+ case "es_ref_enum":
193
+ el.push(p.typeOnly
194
+ ? createTypeImport(p.type).toTypeOnly()
195
+ : createTypeImport(p.type));
196
+ break;
181
197
  case "message":
182
198
  case "extension":
183
199
  case "enum":
@@ -307,37 +323,80 @@ function processImports(el, importerPath, rewriteImportPath, makeImportStatement
307
323
  }
308
324
  return symbolToIdentifier;
309
325
  }
310
- function literalNumber(value, runtimeImports) {
326
+ function elBigint(el, value, runtimeImports) {
327
+ if (value == protoInt64.zero) {
328
+ // Loose comparison will match between 0n and 0.
329
+ el.push(runtimeImports.protoInt64, ".zero");
330
+ }
331
+ else {
332
+ el.push(runtimeImports.protoInt64, value > 0 ? ".uParse(" : ".parse(", escapeString(value.toString()), ")");
333
+ }
334
+ }
335
+ function elNumber(el, value, runtimeImports) {
311
336
  if (Number.isNaN(value)) {
312
- return [runtimeImports.protoDouble, ".NaN"];
337
+ el.push(runtimeImports.protoDouble, ".NaN");
313
338
  }
314
- if (value === Number.POSITIVE_INFINITY) {
315
- return [runtimeImports.protoDouble, ".POSITIVE_INFINITY"];
339
+ else if (value === Number.POSITIVE_INFINITY) {
340
+ el.push(runtimeImports.protoDouble, ".POSITIVE_INFINITY");
316
341
  }
317
- if (value === Number.NEGATIVE_INFINITY) {
318
- return [runtimeImports.protoDouble, ".NEGATIVE_INFINITY"];
342
+ else if (value === Number.NEGATIVE_INFINITY) {
343
+ el.push(runtimeImports.protoDouble, ".NEGATIVE_INFINITY");
319
344
  }
320
- return value.toString(10);
321
- }
322
- function literalBigint(value, runtimeImports) {
323
- // Loose comparison will match between 0n and 0.
324
- if (value == 0) {
325
- return [runtimeImports.protoInt64, ".zero"];
345
+ else {
346
+ el.push(value.toString(10));
326
347
  }
327
- return [
328
- runtimeImports.protoInt64,
329
- value > 0 ? ".uParse(" : ".parse(",
330
- literalString(value.toString()),
331
- ")",
332
- ];
333
348
  }
334
- function literalUint8Array(value) {
349
+ function elUint8Array(el, value) {
335
350
  if (value.length === 0) {
336
- return "new Uint8Array(0)";
351
+ el.push("new Uint8Array(0)");
352
+ return;
337
353
  }
354
+ el.push("new Uint8Array([");
338
355
  const strings = [];
339
356
  for (const n of value) {
340
357
  strings.push("0x" + n.toString(16).toUpperCase().padStart(2, "0"));
341
358
  }
342
- return `new Uint8Array([${strings.join(", ")}])`;
359
+ el.push(strings.join(", "));
360
+ el.push("])");
361
+ }
362
+ function elProtoInt64(el, literal, runtimeImports) {
363
+ switch (literal.longType) {
364
+ case LongType.STRING:
365
+ el.push(escapeString(literal.value.toString()));
366
+ break;
367
+ case LongType.BIGINT:
368
+ if (literal.value == protoInt64.zero) {
369
+ // Loose comparison will match between 0n and 0.
370
+ el.push(runtimeImports.protoInt64, ".zero");
371
+ break;
372
+ }
373
+ switch (literal.type) {
374
+ case ScalarType.UINT64:
375
+ case ScalarType.FIXED64:
376
+ el.push(runtimeImports.protoInt64);
377
+ el.push(".uParse(");
378
+ el.push(escapeString(literal.value.toString()));
379
+ el.push(")");
380
+ break;
381
+ default:
382
+ el.push(runtimeImports.protoInt64);
383
+ el.push(".parse(");
384
+ el.push(escapeString(literal.value.toString()));
385
+ el.push(")");
386
+ break;
387
+ }
388
+ }
389
+ }
390
+ function escapeString(value) {
391
+ return ('"' +
392
+ value
393
+ .split("\\")
394
+ .join("\\\\")
395
+ .split('"')
396
+ .join('\\"')
397
+ .split("\r")
398
+ .join("\\r")
399
+ .split("\n")
400
+ .join("\\n") +
401
+ '"');
343
402
  }
@@ -1,4 +1,4 @@
1
- import { DescFile } from "@bufbuild/protobuf";
1
+ import type { DescFile } from "@bufbuild/protobuf";
2
2
  /**
3
3
  * A configuration for rewriting import paths, a feature mainly used for
4
4
  * remote code generation in the BSR npm registry, which makes it possible
@@ -1,5 +1,5 @@
1
- import { AnyDesc, DescExtension, DescFile } from "@bufbuild/protobuf";
2
- import { Printable } from "./generated-file.js";
1
+ import type { AnyDesc, DescExtension, DescFile } from "@bufbuild/protobuf";
2
+ import type { Printable } from "./generated-file.js";
3
3
  export { reifyWkt } from "./reify-wkt.js";
4
4
  export type { Target } from "./target.js";
5
5
  export type { Schema } from "./schema.js";
@@ -8,12 +8,8 @@ export type { GeneratedFile, FileInfo, Printable } from "./generated-file.js";
8
8
  export type { ImportSymbol } from "./import-symbol.js";
9
9
  export { createImportSymbol } from "./import-symbol.js";
10
10
  export declare const localName: (desc: import("@bufbuild/protobuf").DescEnum | import("@bufbuild/protobuf").DescMessage | import("@bufbuild/protobuf").DescService | DescExtension | import("@bufbuild/protobuf").DescEnumValue | import("@bufbuild/protobuf").DescField | import("@bufbuild/protobuf").DescOneof | import("@bufbuild/protobuf").DescMethod) => string;
11
- export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, } from "./gencommon.js";
12
- export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
13
- /**
14
- * @deprecated Please use GeneratedFile.string() instead
15
- */
16
- export declare function literalString(value: string): string;
11
+ export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, literalString, } from "./legacy-gencommon.js";
12
+ export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./legacy-custom-options.js";
17
13
  /**
18
14
  * @deprecated Please use GeneratedFile.jsDoc() instead
19
15
  */
@@ -11,20 +11,13 @@
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 { codegenInfo, } from "@bufbuild/protobuf";
14
+ import { codegenInfo } from "@bufbuild/protobuf";
15
15
  import { createJsDocBlock as createJsDocBlockInternal } from "./jsdoc.js";
16
- import { literalString as literalStringInternal } from "./gencommon.js";
17
16
  export { reifyWkt } from "./reify-wkt.js";
18
17
  export { createImportSymbol } from "./import-symbol.js";
19
18
  export const { localName } = codegenInfo;
20
- export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, } from "./gencommon.js";
21
- export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
22
- /**
23
- * @deprecated Please use GeneratedFile.string() instead
24
- */
25
- export function literalString(value) {
26
- return literalStringInternal(value);
27
- }
19
+ export { getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, literalString, } from "./legacy-gencommon.js";
20
+ export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./legacy-custom-options.js";
28
21
  /**
29
22
  * @deprecated Please use GeneratedFile.jsDoc() instead
30
23
  */
@@ -1,8 +1,14 @@
1
1
  import type { AnyDesc, DescFile } from "@bufbuild/protobuf";
2
2
  export type JSDocBlock = {
3
3
  readonly kind: "es_jsdoc";
4
+ /**
5
+ * @deprecated In a future release, we will make this property optional.
6
+ */
4
7
  text: string;
5
8
  indentation?: string;
9
+ /**
10
+ * @deprecated In a future release, we will remove this method.
11
+ */
6
12
  toString(): string;
7
13
  };
8
14
  export declare function createJsDocBlock(textOrDesc: string | Exclude<AnyDesc, DescFile>, indentation?: string): JSDocBlock;
@@ -11,6 +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
+ // TODO simplify type JSDocBlock to bring it in line with others in opaque-printables.ts
14
15
  export function createJsDocBlock(textOrDesc, indentation) {
15
16
  const text = typeof textOrDesc == "string" ? textOrDesc : createTextForDesc(textOrDesc);
16
17
  return {
@@ -1,5 +1,5 @@
1
- import type { AnyDesc } from "@bufbuild/protobuf";
2
- import { Message, MessageType, ScalarType } from "@bufbuild/protobuf";
1
+ import type { AnyDesc, MessageType } from "@bufbuild/protobuf";
2
+ import { Message, ScalarType } from "@bufbuild/protobuf";
3
3
  /**
4
4
  * @deprecated Please use extensions instead.
5
5
  *
@@ -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 { proto3, BinaryReader, ScalarType, } from "@bufbuild/protobuf";
14
+ import { proto3, BinaryReader, Message, ScalarType } from "@bufbuild/protobuf";
15
15
  /**
16
16
  * @deprecated Please use extensions instead.
17
17
  *
@@ -1,19 +1,24 @@
1
- import type { DescExtension } from "@bufbuild/protobuf";
2
- import { DescField, DescFile, LongType, ScalarType } from "@bufbuild/protobuf";
1
+ import type { DescExtension, DescField } from "@bufbuild/protobuf";
3
2
  import type { GeneratedFile, Printable } from "./generated-file.js";
4
3
  import type { ImportSymbol } from "./import-symbol.js";
5
- export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string, parameter: string, tsNoCheck: boolean): string;
6
4
  /**
7
- * Returns an expression for the TypeScript typing of a field,
8
- * and whether the property should be optional.
5
+ * @deprecated Please use GeneratedFile.string() instead
6
+ */
7
+ export declare function literalString(value: string): string;
8
+ /**
9
+ * @deprecated
9
10
  */
10
11
  export declare function getFieldTyping(field: DescField | DescExtension, file: GeneratedFile): {
11
12
  typing: Printable;
12
13
  optional: boolean;
13
14
  };
14
- export declare function scalarTypeScriptType(type: ScalarType, longType: LongType): Printable;
15
- export declare function literalString(value: string): string;
15
+ /**
16
+ * @deprecated
17
+ */
16
18
  export declare function getFieldExplicitDefaultValue(field: DescField | DescExtension, protoInt64Symbol: ImportSymbol): Printable | undefined;
19
+ /**
20
+ * @deprecated
21
+ */
17
22
  export declare function getFieldIntrinsicDefaultValue(field: DescField): {
18
23
  defaultValue: Printable | undefined;
19
24
  typingInferrable: boolean;