@bufbuild/protoplugin 0.1.0 → 0.2.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.
@@ -1,11 +1,18 @@
1
1
  import type { DescEnum, DescFile, DescMessage } from "@bufbuild/protobuf";
2
- import { CodeGeneratorResponse } from "@bufbuild/protobuf";
3
2
  import type { ImportSymbol } from "./import-symbol.js";
4
3
  import type { RuntimeImports } from "./runtime-imports.js";
5
4
  /**
6
5
  * All types that can be passed to GeneratedFile.print()
7
6
  */
8
- declare type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | DescMessage | DescEnum | Printable[];
7
+ export declare type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | DescMessage | DescEnum | Printable[];
8
+ /**
9
+ * FileInfo represents an intermediate type using for transpiling TypeScript internally.
10
+ */
11
+ export interface FileInfo {
12
+ name: string;
13
+ content: string;
14
+ preamble?: string | undefined;
15
+ }
9
16
  /**
10
17
  * Represents a JavaScript, TypeScript, or TypeScript declaration file.
11
18
  */
@@ -50,8 +57,8 @@ export interface GeneratedFile {
50
57
  */
51
58
  import(name: string, from: string): ImportSymbol;
52
59
  }
53
- export interface GenerateFileToResponse {
54
- toResponse(res: CodeGeneratorResponse): void;
60
+ export interface GenerateFileToFileInfo {
61
+ getFileInfo(): FileInfo | undefined;
55
62
  }
56
63
  declare type CreateTypeImportFn = (desc: DescMessage | DescEnum) => ImportSymbol;
57
64
  export declare function createGeneratedFile(name: string, importPath: string, createTypeImport: CreateTypeImportFn, runtimeImports: RuntimeImports, preambleSettings: {
@@ -59,5 +66,5 @@ export declare function createGeneratedFile(name: string, importPath: string, cr
59
66
  pluginVersion: string;
60
67
  parameter: string | undefined;
61
68
  tsNocheck: boolean;
62
- }): GeneratedFile & GenerateFileToResponse;
69
+ }, keepEmpty: boolean): GeneratedFile & GenerateFileToFileInfo;
63
70
  export {};
@@ -1,7 +1,8 @@
1
1
  export { Target } from "./target.js";
2
2
  export { Schema } from "./schema.js";
3
3
  export { RuntimeImports } from "./runtime-imports.js";
4
- export { GeneratedFile } from "./generated-file.js";
4
+ export { GeneratedFile, FileInfo, Printable } from "./generated-file.js";
5
5
  export { ImportSymbol } from "./import-symbol.js";
6
6
  export declare const localName: typeof import("@bufbuild/protobuf/dist/types/private/names.js").localName;
7
7
  export { createJsDocBlock, getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, makeJsDoc, literalString, } from "./gencommon.js";
8
+ export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
@@ -1,6 +1,6 @@
1
1
  import type { CodeGeneratorRequest, DescFile } from "@bufbuild/protobuf";
2
2
  import { CodeGeneratorResponse } from "@bufbuild/protobuf";
3
- import type { GeneratedFile } from "./generated-file.js";
3
+ import type { GeneratedFile, FileInfo } from "./generated-file.js";
4
4
  import { RuntimeImports } from "./runtime-imports.js";
5
5
  import type { Target } from "./target.js";
6
6
  import { RewriteImports } from "./import-path.js";
@@ -36,7 +36,8 @@ export interface Schema {
36
36
  }
37
37
  interface SchemaController {
38
38
  schema: Schema;
39
- toResponse: (res: CodeGeneratorResponse) => void;
39
+ getFileInfo: () => FileInfo[];
40
40
  }
41
- export declare function createSchema(request: CodeGeneratorRequest, targets: Target[], pluginName: string, pluginVersion: string, tsNocheck: boolean, bootstrapWkt: boolean, rewriteImports: RewriteImports): SchemaController;
41
+ export declare function createSchema(request: CodeGeneratorRequest, targets: Target[], pluginName: string, pluginVersion: string, tsNocheck: boolean, bootstrapWkt: boolean, rewriteImports: RewriteImports, keepEmptyFiles: boolean): SchemaController;
42
+ export declare function toResponse(files: FileInfo[]): CodeGeneratorResponse;
42
43
  export {};
@@ -0,0 +1,2 @@
1
+ import type { FileInfo } from "./generated-file.js";
2
+ export declare function transpile(files: FileInfo[], transpileJs: boolean, transpileDts: boolean): FileInfo[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoplugin",
3
- "version": "0.1.0",
3
+ "version": "0.2.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,12 +35,14 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@bufbuild/protobuf": "0.1.0"
39
- },
40
- "devDependencies": {
41
- "typescript": "^4.7.4"
38
+ "@bufbuild/protobuf": "0.2.0",
39
+ "@typescript/vfs": "^1.4.0",
40
+ "typescript": "4.5.2"
42
41
  },
43
42
  "files": [
44
43
  "dist/**/"
45
- ]
44
+ ],
45
+ "devDependencies": {
46
+ "@types/lz-string": "^1.3.34"
47
+ }
46
48
  }