@bufbuild/protoplugin 0.4.0 → 1.0.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 +5 -3
- package/dist/types/create-es-plugin.d.ts +1 -1
- package/dist/types/ecmascript/custom-options.d.ts +1 -1
- package/dist/types/ecmascript/generated-file.d.ts +3 -3
- package/dist/types/ecmascript/import-path.d.ts +1 -1
- package/dist/types/ecmascript/import-symbol.d.ts +2 -2
- package/dist/types/ecmascript/target.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
This package helps to 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://developers.google.com/protocol-buffers) in TypeScript, suitable for web browsers and Node.js.
|
|
6
|
+
**Protobuf-ES** is a complete implementation of [Protocol Buffers](https://developers.google.com/protocol-buffers) in TypeScript, suitable for web browsers and Node.js.
|
|
7
7
|
|
|
8
8
|
In addition to a full Protobuf runtime library, it also provides a code generator
|
|
9
|
-
`protoc-gen-es
|
|
9
|
+
[`protoc-gen-es`](https://www.npmjs.com/package/@bufbuild/protoc-gen-es), which utilizes a plugin framework to generate base types from
|
|
10
10
|
your Protobuf schema. It is fully compatible with both Buf and protoc compilers.
|
|
11
11
|
|
|
12
|
-
And now, you can write your own Protobuf-ES compatible plugins using this same
|
|
12
|
+
And now, you can write your own **Protobuf-ES** compatible plugins using this same
|
|
13
13
|
plugin framework with the `@bufbuild/protoplugin` package.
|
|
14
14
|
|
|
15
15
|
With `@bufbuild/protoplugin`, you can generate your own TypeScript code tailored
|
|
@@ -29,4 +29,6 @@ TypeScript and your own compiler options.
|
|
|
29
29
|
With `protoplugin`, you have all the tools at your disposal to produce ECMAScript-compliant
|
|
30
30
|
code.
|
|
31
31
|
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
32
34
|
Get started now with our [plugin documentation](https://github.com/bufbuild/protobuf-es/blob/main/docs/writing_plugins.md).
|
|
@@ -54,7 +54,7 @@ interface PluginInit {
|
|
|
54
54
|
*/
|
|
55
55
|
transpile?: (files: FileInfo[], transpileJs: boolean, transpileDts: boolean) => FileInfo[];
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
type PluginOptionParseFn = (key: string, value: string | undefined) => void;
|
|
58
58
|
/**
|
|
59
59
|
* Create a new code generator plugin for ECMAScript.
|
|
60
60
|
* The plugin can generate JavaScript, TypeScript, or TypeScript declaration
|
|
@@ -28,5 +28,5 @@ export declare function findCustomEnumOption(desc: AnyDesc, extensionNumber: num
|
|
|
28
28
|
/**
|
|
29
29
|
* ScalarValue is a conditional type that pairs a ScalarType value with its concrete type.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
type ScalarValue<T> = T extends ScalarType.STRING ? string : T extends ScalarType.INT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.UINT32 ? number : T extends ScalarType.SINT32 ? number : T extends ScalarType.FIXED32 ? number : T extends ScalarType.SFIXED32 ? number : T extends ScalarType.FLOAT ? number : T extends ScalarType.DOUBLE ? number : T extends ScalarType.INT64 ? bigint | string : T extends ScalarType.SINT64 ? bigint | string : T extends ScalarType.SFIXED64 ? bigint | string : T extends ScalarType.UINT64 ? bigint | string : T extends ScalarType.FIXED64 ? bigint | string : T extends ScalarType.BOOL ? boolean : T extends ScalarType.BYTES ? Uint8Array : never;
|
|
32
32
|
export {};
|
|
@@ -4,7 +4,7 @@ import type { RuntimeImports } from "./runtime-imports.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* All types that can be passed to GeneratedFile.print()
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | DescMessage | DescEnum | Printable[];
|
|
8
8
|
/**
|
|
9
9
|
* FileInfo represents an intermediate type using for transpiling TypeScript internally.
|
|
10
10
|
*/
|
|
@@ -66,8 +66,8 @@ export interface GeneratedFile {
|
|
|
66
66
|
export interface GenerateFileToFileInfo {
|
|
67
67
|
getFileInfo(): FileInfo | undefined;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
type CreateTypeImportFn = (desc: DescMessage | DescEnum) => ImportSymbol;
|
|
70
|
+
type RewriteImportPathFn = (path: string) => string;
|
|
71
71
|
export declare function createGeneratedFile(name: string, importPath: string, rewriteImportPath: RewriteImportPathFn, createTypeImport: CreateTypeImportFn, runtimeImports: RuntimeImports, preambleSettings: {
|
|
72
72
|
pluginName: string;
|
|
73
73
|
pluginVersion: string;
|
|
@@ -35,7 +35,7 @@ import { DescFile } from "@bufbuild/protobuf";
|
|
|
35
35
|
* With the target `@scope/pkg`, the import path `./foo/bar_pb.js` is
|
|
36
36
|
* transformed to `@scope/pkg/foo/bar_pb.js`.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export type RewriteImports = {
|
|
39
39
|
pattern: string;
|
|
40
40
|
target: string;
|
|
41
41
|
}[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* An import symbol represents an ECMAScript import.
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ImportSymbol = {
|
|
5
5
|
readonly kind: "es_symbol";
|
|
6
6
|
/**
|
|
7
7
|
* The name to import.
|
|
@@ -35,5 +35,5 @@ export declare type ImportSymbol = {
|
|
|
35
35
|
* Create a new import symbol.
|
|
36
36
|
*/
|
|
37
37
|
export declare function createImportSymbol(name: string, from: string, typeOnly?: boolean): ImportSymbol;
|
|
38
|
-
|
|
38
|
+
type EsSymbolId = string;
|
|
39
39
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoplugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
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": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@bufbuild/protobuf": "0.
|
|
38
|
+
"@bufbuild/protobuf": "1.0.0",
|
|
39
39
|
"@typescript/vfs": "^1.4.0",
|
|
40
40
|
"typescript": "4.5.2"
|
|
41
41
|
},
|