@bufbuild/protoplugin 2.0.0-alpha.2 → 2.0.0-alpha.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/dist/cjs/create-es-plugin.d.ts +3 -3
- package/dist/cjs/create-es-plugin.js +6 -6
- package/dist/cjs/{ecmascript/file-preamble.js → file-preamble.js} +1 -1
- package/dist/cjs/{ecmascript/generated-file.d.ts → generated-file.d.ts} +3 -3
- package/dist/cjs/{ecmascript/generated-file.js → generated-file.js} +13 -14
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/{ecmascript/jsdoc.js → jsdoc.js} +1 -1
- package/dist/cjs/{ecmascript/parameter.js → parameter.js} +1 -1
- package/dist/{esm/ecmascript → cjs}/printable.d.ts +2 -3
- package/dist/cjs/{ecmascript/schema.js → schema.js} +1 -1
- package/dist/cjs/source-code-info.js +2 -2
- package/dist/esm/create-es-plugin.d.ts +3 -3
- package/dist/esm/create-es-plugin.js +4 -4
- package/dist/esm/{ecmascript/file-preamble.js → file-preamble.js} +1 -1
- package/dist/esm/{ecmascript/generated-file.d.ts → generated-file.d.ts} +3 -3
- package/dist/esm/{ecmascript/generated-file.js → generated-file.js} +12 -13
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/{ecmascript/jsdoc.js → jsdoc.js} +1 -1
- package/dist/esm/{ecmascript/parameter.js → parameter.js} +1 -1
- package/dist/{cjs/ecmascript → esm}/printable.d.ts +2 -3
- package/dist/esm/{ecmascript/schema.js → schema.js} +2 -2
- package/dist/esm/source-code-info.js +2 -2
- package/dist/esm/{ecmascript/printable.js → target.js} +1 -1
- package/package.json +2 -13
- package/dist/cjs/ecmascript/index.d.ts +0 -7
- package/dist/cjs/ecmascript/index.js +0 -20
- package/dist/esm/ecmascript/index.d.ts +0 -7
- package/dist/esm/ecmascript/index.js +0 -15
- /package/dist/cjs/{ecmascript/file-preamble.d.ts → file-preamble.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/import-path.d.ts → import-path.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/import-path.js → import-path.js} +0 -0
- /package/dist/cjs/{ecmascript/import-symbol.d.ts → import-symbol.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/import-symbol.js → import-symbol.js} +0 -0
- /package/dist/cjs/{ecmascript/jsdoc.d.ts → jsdoc.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/names.d.ts → names.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/names.js → names.js} +0 -0
- /package/dist/cjs/{ecmascript/parameter.d.ts → parameter.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/printable.js → printable.js} +0 -0
- /package/dist/cjs/{ecmascript/runtime-imports.d.ts → runtime-imports.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/runtime-imports.js → runtime-imports.js} +0 -0
- /package/dist/cjs/{ecmascript/safe-identifier.d.ts → safe-identifier.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/safe-identifier.js → safe-identifier.js} +0 -0
- /package/dist/cjs/{ecmascript/schema.d.ts → schema.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/target.d.ts → target.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/target.js → target.js} +0 -0
- /package/dist/cjs/{ecmascript/transpile.d.ts → transpile.d.ts} +0 -0
- /package/dist/cjs/{ecmascript/transpile.js → transpile.js} +0 -0
- /package/dist/esm/{ecmascript/file-preamble.d.ts → file-preamble.d.ts} +0 -0
- /package/dist/esm/{ecmascript/import-path.d.ts → import-path.d.ts} +0 -0
- /package/dist/esm/{ecmascript/import-path.js → import-path.js} +0 -0
- /package/dist/esm/{ecmascript/import-symbol.d.ts → import-symbol.d.ts} +0 -0
- /package/dist/esm/{ecmascript/import-symbol.js → import-symbol.js} +0 -0
- /package/dist/esm/{ecmascript/jsdoc.d.ts → jsdoc.d.ts} +0 -0
- /package/dist/esm/{ecmascript/names.d.ts → names.d.ts} +0 -0
- /package/dist/esm/{ecmascript/names.js → names.js} +0 -0
- /package/dist/esm/{ecmascript/parameter.d.ts → parameter.d.ts} +0 -0
- /package/dist/esm/{ecmascript/target.js → printable.js} +0 -0
- /package/dist/esm/{ecmascript/runtime-imports.d.ts → runtime-imports.d.ts} +0 -0
- /package/dist/esm/{ecmascript/runtime-imports.js → runtime-imports.js} +0 -0
- /package/dist/esm/{ecmascript/safe-identifier.d.ts → safe-identifier.d.ts} +0 -0
- /package/dist/esm/{ecmascript/safe-identifier.js → safe-identifier.js} +0 -0
- /package/dist/esm/{ecmascript/schema.d.ts → schema.d.ts} +0 -0
- /package/dist/esm/{ecmascript/target.d.ts → target.d.ts} +0 -0
- /package/dist/esm/{ecmascript/transpile.d.ts → transpile.d.ts} +0 -0
- /package/dist/esm/{ecmascript/transpile.js → transpile.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Schema } from "./
|
|
3
|
-
import type { FileInfo } from "./
|
|
1
|
+
import { type SupportedEdition } from "@bufbuild/protobuf";
|
|
2
|
+
import type { Schema } from "./schema.js";
|
|
3
|
+
import type { FileInfo } from "./generated-file.js";
|
|
4
4
|
import type { Plugin } from "./plugin.js";
|
|
5
5
|
interface PluginInit {
|
|
6
6
|
/**
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.createEcmaScriptPlugin = void 0;
|
|
17
17
|
const protobuf_1 = require("@bufbuild/protobuf");
|
|
18
|
-
const
|
|
18
|
+
const protobuf_2 = require("@bufbuild/protobuf");
|
|
19
19
|
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
20
|
-
const schema_js_1 = require("./
|
|
21
|
-
const transpile_js_1 = require("./
|
|
22
|
-
const parameter_js_1 = require("./
|
|
20
|
+
const schema_js_1 = require("./schema.js");
|
|
21
|
+
const transpile_js_1 = require("./transpile.js");
|
|
22
|
+
const parameter_js_1 = require("./parameter.js");
|
|
23
23
|
/**
|
|
24
24
|
* Create a new code generator plugin for ECMAScript.
|
|
25
25
|
* The plugin can generate JavaScript, TypeScript, or TypeScript declaration
|
|
@@ -33,8 +33,8 @@ function createEcmaScriptPlugin(init) {
|
|
|
33
33
|
version: init.version,
|
|
34
34
|
run(req) {
|
|
35
35
|
var _a, _b, _c;
|
|
36
|
-
const minimumEdition = (_a = init.minimumEdition) !== null && _a !== void 0 ? _a :
|
|
37
|
-
const maximumEdition = (_b = init.maximumEdition) !== null && _b !== void 0 ? _b :
|
|
36
|
+
const minimumEdition = (_a = init.minimumEdition) !== null && _a !== void 0 ? _a : protobuf_2.minimumEdition;
|
|
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.parseOption);
|
|
39
39
|
const schema = (0, schema_js_1.createSchema)(req, parameter, init.name, init.version, minimumEdition, maximumEdition);
|
|
40
40
|
const targetTs = schema.targets.includes("ts");
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.makeFilePreamble = void 0;
|
|
17
17
|
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
18
|
-
const source_code_info_js_1 = require("
|
|
18
|
+
const source_code_info_js_1 = require("./source-code-info.js");
|
|
19
19
|
function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck) {
|
|
20
20
|
const builder = [];
|
|
21
21
|
const trimSuffix = (str, suffix) => str.endsWith(suffix) ? str.substring(0, str.length - suffix.length) : str;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyDesc, type DescEnum, type DescExtension, type DescFile, type DescMessage, type DescService } from "@bufbuild/protobuf";
|
|
2
2
|
import type { ImportSymbol } from "./import-symbol.js";
|
|
3
3
|
import type { Printable } from "./printable.js";
|
|
4
4
|
import type { RuntimeImports } from "./runtime-imports.js";
|
|
@@ -63,7 +63,7 @@ export interface GeneratedFile {
|
|
|
63
63
|
* Create a printable export statement. For example:
|
|
64
64
|
*
|
|
65
65
|
* ```ts
|
|
66
|
-
* f.print(f.
|
|
66
|
+
* f.print(f.export("abstract class", "MyClass"), " {}")
|
|
67
67
|
* ```
|
|
68
68
|
*
|
|
69
69
|
* Will generate as:
|
|
@@ -75,7 +75,7 @@ export interface GeneratedFile {
|
|
|
75
75
|
* statement. If the plugin option `js_import_style=legacy_commonjs` is set,
|
|
76
76
|
* exports will automatically be generated for CommonJS.
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
export(declaration: string, name: string): Printable;
|
|
79
79
|
/**
|
|
80
80
|
* Import a message or enumeration generated by protoc-gen-es.
|
|
81
81
|
*/
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.createGeneratedFile = void 0;
|
|
17
17
|
const protobuf_1 = require("@bufbuild/protobuf");
|
|
18
|
-
const reflect_1 = require("@bufbuild/protobuf/reflect");
|
|
19
18
|
const import_symbol_js_1 = require("./import-symbol.js");
|
|
20
19
|
const import_path_js_1 = require("./import-path.js");
|
|
21
20
|
const jsdoc_js_1 = require("./jsdoc.js");
|
|
@@ -48,7 +47,7 @@ function createGeneratedFile(name, importPath, jsImportStyle, rewriteImport, res
|
|
|
48
47
|
}, printables);
|
|
49
48
|
el.push("\n");
|
|
50
49
|
},
|
|
51
|
-
|
|
50
|
+
export(declaration, name) {
|
|
52
51
|
return {
|
|
53
52
|
kind: "es_export_stmt",
|
|
54
53
|
name,
|
|
@@ -231,25 +230,25 @@ function printableToEl(opt, printables) {
|
|
|
231
230
|
el.push(escapeString(p.value));
|
|
232
231
|
break;
|
|
233
232
|
case "es_proto_int64":
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
233
|
+
if (p.longAsString) {
|
|
234
|
+
el.push(escapeString(p.value.toString()));
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
if (p.value == protobuf_1.protoInt64.zero) {
|
|
238
|
+
// Loose comparison will match between 0n and 0.
|
|
239
|
+
el.push(opt.runtime.protoInt64, ".zero");
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
244
242
|
switch (p.type) {
|
|
245
|
-
case
|
|
246
|
-
case
|
|
243
|
+
case protobuf_1.ScalarType.UINT64:
|
|
244
|
+
case protobuf_1.ScalarType.FIXED64:
|
|
247
245
|
el.push(opt.runtime.protoInt64, ".uParse(", escapeString(p.value.toString()), ")");
|
|
248
246
|
break;
|
|
249
247
|
default:
|
|
250
248
|
el.push(opt.runtime.protoInt64, ".parse(", escapeString(p.value.toString()), ")");
|
|
251
249
|
break;
|
|
252
250
|
}
|
|
251
|
+
}
|
|
253
252
|
}
|
|
254
253
|
break;
|
|
255
254
|
default:
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,3 +2,10 @@ export type { Plugin } from "./plugin.js";
|
|
|
2
2
|
export { runNodeJs } from "./run-node.js";
|
|
3
3
|
export { createEcmaScriptPlugin } from "./create-es-plugin.js";
|
|
4
4
|
export { getComments, getDeclarationString, getPackageComments, getSyntaxComments, } from "./source-code-info.js";
|
|
5
|
+
export type { Target } from "./target.js";
|
|
6
|
+
export type { Schema } from "./schema.js";
|
|
7
|
+
export type { GeneratedFile, FileInfo } from "./generated-file.js";
|
|
8
|
+
export type { ImportSymbol } from "./import-symbol.js";
|
|
9
|
+
export { createImportSymbol } from "./import-symbol.js";
|
|
10
|
+
export type { Printable } from "./printable.js";
|
|
11
|
+
export { safeIdentifier } from "./safe-identifier.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
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.getSyntaxComments = exports.getPackageComments = exports.getDeclarationString = exports.getComments = exports.createEcmaScriptPlugin = exports.runNodeJs = void 0;
|
|
16
|
+
exports.safeIdentifier = exports.createImportSymbol = exports.getSyntaxComments = exports.getPackageComments = exports.getDeclarationString = exports.getComments = exports.createEcmaScriptPlugin = exports.runNodeJs = void 0;
|
|
17
17
|
var run_node_js_1 = require("./run-node.js");
|
|
18
18
|
Object.defineProperty(exports, "runNodeJs", { enumerable: true, get: function () { return run_node_js_1.runNodeJs; } });
|
|
19
19
|
var create_es_plugin_js_1 = require("./create-es-plugin.js");
|
|
@@ -23,3 +23,7 @@ Object.defineProperty(exports, "getComments", { enumerable: true, get: function
|
|
|
23
23
|
Object.defineProperty(exports, "getDeclarationString", { enumerable: true, get: function () { return source_code_info_js_1.getDeclarationString; } });
|
|
24
24
|
Object.defineProperty(exports, "getPackageComments", { enumerable: true, get: function () { return source_code_info_js_1.getPackageComments; } });
|
|
25
25
|
Object.defineProperty(exports, "getSyntaxComments", { enumerable: true, get: function () { return source_code_info_js_1.getSyntaxComments; } });
|
|
26
|
+
var import_symbol_js_1 = require("./import-symbol.js");
|
|
27
|
+
Object.defineProperty(exports, "createImportSymbol", { enumerable: true, get: function () { return import_symbol_js_1.createImportSymbol; } });
|
|
28
|
+
var safe_identifier_js_1 = require("./safe-identifier.js");
|
|
29
|
+
Object.defineProperty(exports, "safeIdentifier", { enumerable: true, get: function () { return safe_identifier_js_1.safeIdentifier; } });
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.formatJsDocBlock = exports.createJsDocTextFromDesc = void 0;
|
|
17
|
-
const source_code_info_js_1 = require("
|
|
17
|
+
const source_code_info_js_1 = require("./source-code-info.js");
|
|
18
18
|
const reflect_1 = require("@bufbuild/protobuf/reflect");
|
|
19
19
|
function createJsDocTextFromDesc(desc) {
|
|
20
20
|
const comments = (0, source_code_info_js_1.getComments)(desc);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.parseParameter = void 0;
|
|
17
|
-
const error_js_1 = require("
|
|
17
|
+
const error_js_1 = require("./error.js");
|
|
18
18
|
function parseParameter(parameter, parseExtraOption) {
|
|
19
19
|
let targets = ["js", "dts"];
|
|
20
20
|
let tsNocheck = false;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { DescEnum, DescExtension, DescFile, DescMessage, DescService } from "@bufbuild/protobuf";
|
|
2
|
-
import { ScalarType, LongType } from "@bufbuild/protobuf/reflect";
|
|
1
|
+
import type { DescEnum, DescExtension, DescFile, DescMessage, DescService, ScalarType } from "@bufbuild/protobuf";
|
|
3
2
|
import type { ImportSymbol } from "./import-symbol.js";
|
|
4
3
|
/**
|
|
5
4
|
* All types that can be passed to GeneratedFile.print()
|
|
@@ -13,7 +12,7 @@ export type ExportStatement = {
|
|
|
13
12
|
export type LiteralProtoInt64 = {
|
|
14
13
|
readonly kind: "es_proto_int64";
|
|
15
14
|
type: ScalarType.INT64 | ScalarType.SINT64 | ScalarType.SFIXED64 | ScalarType.UINT64 | ScalarType.FIXED64;
|
|
16
|
-
|
|
15
|
+
longAsString: boolean;
|
|
17
16
|
value: bigint | string;
|
|
18
17
|
};
|
|
19
18
|
export type LiteralString = {
|
|
@@ -100,7 +100,7 @@ function getFilesToGenerate(request, minimumEdition, maximumEdition) {
|
|
|
100
100
|
const sourceFile = request.sourceFileDescriptors.find((s) => s.name == protoFile.name);
|
|
101
101
|
return sourceFile !== null && sourceFile !== void 0 ? sourceFile : protoFile;
|
|
102
102
|
});
|
|
103
|
-
const registry = (0,
|
|
103
|
+
const registry = (0, protobuf_1.createFileRegistry)((0, protobuf_1.create)(wkt_1.FileDescriptorSetDesc, {
|
|
104
104
|
file: allProtoWithSourceOptions,
|
|
105
105
|
}));
|
|
106
106
|
const allFiles = [];
|
|
@@ -169,7 +169,7 @@ function getDeclarationString(desc) {
|
|
|
169
169
|
if (f.enum) {
|
|
170
170
|
return f.enum.typeName;
|
|
171
171
|
}
|
|
172
|
-
return
|
|
172
|
+
return protobuf_1.ScalarType[f.scalar].toLowerCase();
|
|
173
173
|
}
|
|
174
174
|
switch (desc.fieldKind) {
|
|
175
175
|
case "scalar":
|
|
@@ -187,7 +187,7 @@ function getDeclarationString(desc) {
|
|
|
187
187
|
parts.push("repeated", typeName(desc));
|
|
188
188
|
break;
|
|
189
189
|
case "map": {
|
|
190
|
-
const k =
|
|
190
|
+
const k = protobuf_1.ScalarType[desc.mapKey].toLowerCase();
|
|
191
191
|
const v = typeName(desc);
|
|
192
192
|
parts.push(`map<${k}, ${v}>`);
|
|
193
193
|
break;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Schema } from "./
|
|
3
|
-
import type { FileInfo } from "./
|
|
1
|
+
import { type SupportedEdition } from "@bufbuild/protobuf";
|
|
2
|
+
import type { Schema } from "./schema.js";
|
|
3
|
+
import type { FileInfo } from "./generated-file.js";
|
|
4
4
|
import type { Plugin } from "./plugin.js";
|
|
5
5
|
interface PluginInit {
|
|
6
6
|
/**
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
import { create, protoInt64 } from "@bufbuild/protobuf";
|
|
15
|
-
import { minimumEdition as minimumEditionUpstream, maximumEdition as maximumEditionUpstream, } from "@bufbuild/protobuf
|
|
15
|
+
import { minimumEdition as minimumEditionUpstream, maximumEdition as maximumEditionUpstream, } from "@bufbuild/protobuf";
|
|
16
16
|
import { CodeGeneratorResponse_Feature, CodeGeneratorResponseDesc, } from "@bufbuild/protobuf/wkt";
|
|
17
|
-
import { createSchema } from "./
|
|
18
|
-
import { transpile } from "./
|
|
19
|
-
import { parseParameter } from "./
|
|
17
|
+
import { createSchema } from "./schema.js";
|
|
18
|
+
import { transpile } from "./transpile.js";
|
|
19
|
+
import { parseParameter } from "./parameter.js";
|
|
20
20
|
/**
|
|
21
21
|
* Create a new code generator plugin for ECMAScript.
|
|
22
22
|
* The plugin can generate JavaScript, TypeScript, or TypeScript declaration
|
|
@@ -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 { Edition } from "@bufbuild/protobuf/wkt";
|
|
15
|
-
import { getPackageComments, getSyntaxComments, getFeatureOptionStrings, } from "
|
|
15
|
+
import { getPackageComments, getSyntaxComments, getFeatureOptionStrings, } from "./source-code-info.js";
|
|
16
16
|
export function makeFilePreamble(file, pluginName, pluginVersion, parameter, tsNoCheck) {
|
|
17
17
|
const builder = [];
|
|
18
18
|
const trimSuffix = (str, suffix) => str.endsWith(suffix) ? str.substring(0, str.length - suffix.length) : str;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AnyDesc, type DescEnum, type DescExtension, type DescFile, type DescMessage, type DescService } from "@bufbuild/protobuf";
|
|
2
2
|
import type { ImportSymbol } from "./import-symbol.js";
|
|
3
3
|
import type { Printable } from "./printable.js";
|
|
4
4
|
import type { RuntimeImports } from "./runtime-imports.js";
|
|
@@ -63,7 +63,7 @@ export interface GeneratedFile {
|
|
|
63
63
|
* Create a printable export statement. For example:
|
|
64
64
|
*
|
|
65
65
|
* ```ts
|
|
66
|
-
* f.print(f.
|
|
66
|
+
* f.print(f.export("abstract class", "MyClass"), " {}")
|
|
67
67
|
* ```
|
|
68
68
|
*
|
|
69
69
|
* Will generate as:
|
|
@@ -75,7 +75,7 @@ export interface GeneratedFile {
|
|
|
75
75
|
* statement. If the plugin option `js_import_style=legacy_commonjs` is set,
|
|
76
76
|
* exports will automatically be generated for CommonJS.
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
export(declaration: string, name: string): Printable;
|
|
79
79
|
/**
|
|
80
80
|
* Import a message or enumeration generated by protoc-gen-es.
|
|
81
81
|
*/
|
|
@@ -11,8 +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 { protoInt64 } from "@bufbuild/protobuf";
|
|
15
|
-
import { LongType, ScalarType } from "@bufbuild/protobuf/reflect";
|
|
14
|
+
import { protoInt64, ScalarType, } from "@bufbuild/protobuf";
|
|
16
15
|
import { createImportSymbol } from "./import-symbol.js";
|
|
17
16
|
import { makeImportPathRelative } from "./import-path.js";
|
|
18
17
|
import { createJsDocTextFromDesc, formatJsDocBlock } from "./jsdoc.js";
|
|
@@ -45,7 +44,7 @@ export function createGeneratedFile(name, importPath, jsImportStyle, rewriteImpo
|
|
|
45
44
|
}, printables);
|
|
46
45
|
el.push("\n");
|
|
47
46
|
},
|
|
48
|
-
|
|
47
|
+
export(declaration, name) {
|
|
49
48
|
return {
|
|
50
49
|
kind: "es_export_stmt",
|
|
51
50
|
name,
|
|
@@ -227,16 +226,15 @@ function printableToEl(opt, printables) {
|
|
|
227
226
|
el.push(escapeString(p.value));
|
|
228
227
|
break;
|
|
229
228
|
case "es_proto_int64":
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
229
|
+
if (p.longAsString) {
|
|
230
|
+
el.push(escapeString(p.value.toString()));
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
if (p.value == protoInt64.zero) {
|
|
234
|
+
// Loose comparison will match between 0n and 0.
|
|
235
|
+
el.push(opt.runtime.protoInt64, ".zero");
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
240
238
|
switch (p.type) {
|
|
241
239
|
case ScalarType.UINT64:
|
|
242
240
|
case ScalarType.FIXED64:
|
|
@@ -246,6 +244,7 @@ function printableToEl(opt, printables) {
|
|
|
246
244
|
el.push(opt.runtime.protoInt64, ".parse(", escapeString(p.value.toString()), ")");
|
|
247
245
|
break;
|
|
248
246
|
}
|
|
247
|
+
}
|
|
249
248
|
}
|
|
250
249
|
break;
|
|
251
250
|
default:
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,3 +2,10 @@ export type { Plugin } from "./plugin.js";
|
|
|
2
2
|
export { runNodeJs } from "./run-node.js";
|
|
3
3
|
export { createEcmaScriptPlugin } from "./create-es-plugin.js";
|
|
4
4
|
export { getComments, getDeclarationString, getPackageComments, getSyntaxComments, } from "./source-code-info.js";
|
|
5
|
+
export type { Target } from "./target.js";
|
|
6
|
+
export type { Schema } from "./schema.js";
|
|
7
|
+
export type { GeneratedFile, FileInfo } from "./generated-file.js";
|
|
8
|
+
export type { ImportSymbol } from "./import-symbol.js";
|
|
9
|
+
export { createImportSymbol } from "./import-symbol.js";
|
|
10
|
+
export type { Printable } from "./printable.js";
|
|
11
|
+
export { safeIdentifier } from "./safe-identifier.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -14,3 +14,5 @@
|
|
|
14
14
|
export { runNodeJs } from "./run-node.js";
|
|
15
15
|
export { createEcmaScriptPlugin } from "./create-es-plugin.js";
|
|
16
16
|
export { getComments, getDeclarationString, getPackageComments, getSyntaxComments, } from "./source-code-info.js";
|
|
17
|
+
export { createImportSymbol } from "./import-symbol.js";
|
|
18
|
+
export { safeIdentifier } from "./safe-identifier.js";
|
|
@@ -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 { getComments, getDeclarationString, getFeatureOptionStrings, } from "
|
|
14
|
+
import { getComments, getDeclarationString, getFeatureOptionStrings, } from "./source-code-info.js";
|
|
15
15
|
import { parentTypes } from "@bufbuild/protobuf/reflect";
|
|
16
16
|
export function createJsDocTextFromDesc(desc) {
|
|
17
17
|
const comments = getComments(desc);
|
|
@@ -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 { PluginOptionError } from "
|
|
14
|
+
import { PluginOptionError } from "./error.js";
|
|
15
15
|
export function parseParameter(parameter, parseExtraOption) {
|
|
16
16
|
let targets = ["js", "dts"];
|
|
17
17
|
let tsNocheck = false;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { DescEnum, DescExtension, DescFile, DescMessage, DescService } from "@bufbuild/protobuf";
|
|
2
|
-
import { ScalarType, LongType } from "@bufbuild/protobuf/reflect";
|
|
1
|
+
import type { DescEnum, DescExtension, DescFile, DescMessage, DescService, ScalarType } from "@bufbuild/protobuf";
|
|
3
2
|
import type { ImportSymbol } from "./import-symbol.js";
|
|
4
3
|
/**
|
|
5
4
|
* All types that can be passed to GeneratedFile.print()
|
|
@@ -13,7 +12,7 @@ export type ExportStatement = {
|
|
|
13
12
|
export type LiteralProtoInt64 = {
|
|
14
13
|
readonly kind: "es_proto_int64";
|
|
15
14
|
type: ScalarType.INT64 | ScalarType.SINT64 | ScalarType.SFIXED64 | ScalarType.UINT64 | ScalarType.FIXED64;
|
|
16
|
-
|
|
15
|
+
longAsString: boolean;
|
|
17
16
|
value: bigint | string;
|
|
18
17
|
};
|
|
19
18
|
export type LiteralString = {
|
|
@@ -11,9 +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 { create } from "@bufbuild/protobuf";
|
|
14
|
+
import { create, createFileRegistry } from "@bufbuild/protobuf";
|
|
15
15
|
import { Edition, FileDescriptorSetDesc } from "@bufbuild/protobuf/wkt";
|
|
16
|
-
import {
|
|
16
|
+
import { nestedTypes } from "@bufbuild/protobuf/reflect";
|
|
17
17
|
import { createGeneratedFile } from "./generated-file.js";
|
|
18
18
|
import { createImportSymbol } from "./import-symbol.js";
|
|
19
19
|
import { deriveImportPath, rewriteImportPath } from "./import-path.js";
|
|
@@ -11,8 +11,8 @@
|
|
|
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 { isFieldSet, } from "@bufbuild/protobuf";
|
|
15
|
-
import { protoCamelCase, reflect
|
|
14
|
+
import { isFieldSet, ScalarType, } from "@bufbuild/protobuf";
|
|
15
|
+
import { protoCamelCase, reflect } from "@bufbuild/protobuf/reflect";
|
|
16
16
|
import { Edition, FieldDescriptorProto_Label, FieldDescriptorProto_Type, FieldDescriptorProtoDesc, FieldOptions_JSType, FieldOptionsDesc, FeatureSetDesc, SourceCodeInfo_LocationDesc, FileDescriptorProtoDesc, DescriptorProtoDesc, EnumDescriptorProtoDesc, ServiceDescriptorProtoDesc, } from "@bufbuild/protobuf/wkt";
|
|
17
17
|
/**
|
|
18
18
|
* Get comments on the package element in the protobuf source.
|
|
@@ -11,4 +11,4 @@
|
|
|
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
|
-
|
|
14
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoplugin",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
|
5
5
|
"description": "Helps to create your own Protocol Buffers code generators.",
|
|
6
6
|
"repository": {
|
|
@@ -22,21 +22,10 @@
|
|
|
22
22
|
".": {
|
|
23
23
|
"import": "./dist/esm/index.js",
|
|
24
24
|
"require": "./dist/cjs/index.js"
|
|
25
|
-
},
|
|
26
|
-
"./ecmascript": {
|
|
27
|
-
"import": "./dist/esm/ecmascript/index.js",
|
|
28
|
-
"require": "./dist/cjs/ecmascript/index.js"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"typesVersions": {
|
|
32
|
-
"*": {
|
|
33
|
-
"ecmascript": [
|
|
34
|
-
"./dist/cjs/ecmascript/index.d.ts"
|
|
35
|
-
]
|
|
36
25
|
}
|
|
37
26
|
},
|
|
38
27
|
"dependencies": {
|
|
39
|
-
"@bufbuild/protobuf": "2.0.0-alpha.
|
|
28
|
+
"@bufbuild/protobuf": "2.0.0-alpha.3",
|
|
40
29
|
"@typescript/vfs": "^1.4.0",
|
|
41
30
|
"typescript": "4.5.2"
|
|
42
31
|
},
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { Target } from "./target.js";
|
|
2
|
-
export type { Schema } from "./schema.js";
|
|
3
|
-
export type { GeneratedFile, FileInfo } from "./generated-file.js";
|
|
4
|
-
export type { ImportSymbol } from "./import-symbol.js";
|
|
5
|
-
export { createImportSymbol } from "./import-symbol.js";
|
|
6
|
-
export type { Printable } from "./printable.js";
|
|
7
|
-
export { safeIdentifier } from "./safe-identifier.js";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
3
|
-
//
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// you may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
//
|
|
8
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
//
|
|
10
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
// See the License for the specific language governing permissions and
|
|
14
|
-
// limitations under the License.
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.safeIdentifier = exports.createImportSymbol = void 0;
|
|
17
|
-
var import_symbol_js_1 = require("./import-symbol.js");
|
|
18
|
-
Object.defineProperty(exports, "createImportSymbol", { enumerable: true, get: function () { return import_symbol_js_1.createImportSymbol; } });
|
|
19
|
-
var safe_identifier_js_1 = require("./safe-identifier.js");
|
|
20
|
-
Object.defineProperty(exports, "safeIdentifier", { enumerable: true, get: function () { return safe_identifier_js_1.safeIdentifier; } });
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { Target } from "./target.js";
|
|
2
|
-
export type { Schema } from "./schema.js";
|
|
3
|
-
export type { GeneratedFile, FileInfo } from "./generated-file.js";
|
|
4
|
-
export type { ImportSymbol } from "./import-symbol.js";
|
|
5
|
-
export { createImportSymbol } from "./import-symbol.js";
|
|
6
|
-
export type { Printable } from "./printable.js";
|
|
7
|
-
export { safeIdentifier } from "./safe-identifier.js";
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
export { createImportSymbol } from "./import-symbol.js";
|
|
15
|
-
export { safeIdentifier } from "./safe-identifier.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|