@aptre/protobuf-es-lite 0.2.15 → 0.3.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/LICENSE +1 -1
- package/README.md +10 -15
- package/dist/binary.d.ts +13 -10
- package/dist/binary.js +24 -23
- package/dist/codegen-info.d.ts +8 -0
- package/dist/codegen-info.js +12 -4
- package/dist/descriptor-set.d.ts +8 -9
- package/dist/google/protobuf/any.pb.d.ts +55 -2
- package/dist/google/protobuf/any.pb.js +74 -4
- package/dist/google/protobuf/api.pb.js +13 -10
- package/dist/google/protobuf/descriptor.pb.js +125 -93
- package/dist/google/protobuf/duration.pb.d.ts +7 -2
- package/dist/google/protobuf/duration.pb.js +54 -4
- package/dist/google/protobuf/empty.pb.js +1 -0
- package/dist/google/protobuf/source_context.pb.js +3 -2
- package/dist/google/protobuf/struct.pb.d.ts +17 -4
- package/dist/google/protobuf/struct.pb.js +104 -8
- package/dist/google/protobuf/timestamp.pb.d.ts +8 -2
- package/dist/google/protobuf/timestamp.pb.js +54 -4
- package/dist/google/protobuf/type.pb.js +21 -16
- package/dist/google/protobuf/wrappers.pb.d.ts +47 -10
- package/dist/google/protobuf/wrappers.pb.js +190 -19
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/json.d.ts +30 -4
- package/dist/json.js +17 -16
- package/dist/message.d.ts +5 -12
- package/dist/message.js +75 -77
- package/dist/protoc-gen-es-lite/typescript.d.ts +2 -2
- package/dist/protoc-gen-es-lite/typescript.js +323 -26
- package/dist/protoplugin/ecmascript/reify-wkt.d.ts +1 -5
- package/dist/protoplugin/ecmascript/reify-wkt.js +0 -10
- package/dist/type-registry.d.ts +43 -0
- package/dist/type-registry.js +14 -0
- package/example/example.pb.ts +6 -7
- package/package.json +3 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EnumType } from "./enum.js";
|
|
2
|
+
import type { Message, MessageType } from "./message.js";
|
|
3
|
+
import type { ServiceType } from "./service-type.js";
|
|
4
|
+
/**
|
|
5
|
+
* IMessageTypeRegistry provides look-up for message types.
|
|
6
|
+
*
|
|
7
|
+
* You can conveniently create a registry using the createRegistry()
|
|
8
|
+
* function:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { createTypeRegistry, IMessageTypeRegistry } from "@aptre/protobuf-es-lite";
|
|
12
|
+
* import { MyMessage, MyOtherMessage } from "./gen/my_message.pb.js";
|
|
13
|
+
*
|
|
14
|
+
* const reg: IMessageTypeRegistry = createRegistry(
|
|
15
|
+
* MyMessage,
|
|
16
|
+
* MyOtherMessage,
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface IMessageTypeRegistry {
|
|
21
|
+
/**
|
|
22
|
+
* Find a message type by its protobuf type name.
|
|
23
|
+
*/
|
|
24
|
+
findMessage<T extends Message<T>>(typeName: string): MessageType<T> | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* IEnumTypeRegistry provides look-up for enum types.
|
|
28
|
+
*/
|
|
29
|
+
export interface IEnumTypeRegistry {
|
|
30
|
+
/**
|
|
31
|
+
* Find an enum type by its protobuf type name.
|
|
32
|
+
*/
|
|
33
|
+
findEnum(typeName: string): EnumType | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* IServiceTypeRegistry provides look-up for service types.
|
|
37
|
+
*/
|
|
38
|
+
export interface IServiceTypeRegistry {
|
|
39
|
+
/**
|
|
40
|
+
* Find a service type by its protobuf type name.
|
|
41
|
+
*/
|
|
42
|
+
findService(typeName: string): ServiceType | undefined;
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 {};
|
package/example/example.pb.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
|
5
5
|
import type { MessageType, PartialFieldInfo } from "@aptre/protobuf-es-lite";
|
|
6
|
-
import { createEnumType, createMessageType, Message, Timestamp } from "@aptre/protobuf-es-lite";
|
|
6
|
+
import { createEnumType, createMessageType, Message, ScalarType, Timestamp } from "@aptre/protobuf-es-lite";
|
|
7
7
|
|
|
8
8
|
export const protobufPackage = "example";
|
|
9
9
|
|
|
@@ -77,17 +77,16 @@ export type EchoMsg = Message<{
|
|
|
77
77
|
|
|
78
78
|
}>;
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
// EchoMsg contains the message type declaration for EchoMsg.
|
|
81
|
+
export const EchoMsg: MessageType<EchoMsg> = createMessageType({
|
|
82
82
|
typeName: "example.EchoMsg",
|
|
83
83
|
fields: [
|
|
84
|
-
{ no: 1, name: "body", kind: "scalar", T:
|
|
84
|
+
{ no: 1, name: "body", kind: "scalar", T: ScalarType.STRING },
|
|
85
85
|
{ no: 2, name: "ts", kind: "message", T: () => Timestamp },
|
|
86
86
|
{ no: 3, name: "example_enum", kind: "enum", T: ExampleEnum_Enum, oneof: "demo" },
|
|
87
|
-
{ no: 4, name: "example_string", kind: "scalar", T:
|
|
87
|
+
{ no: 4, name: "example_string", kind: "scalar", T: ScalarType.STRING, oneof: "demo" },
|
|
88
88
|
{ no: 5, name: "timestamps", kind: "message", T: () => Timestamp, repeated: true },
|
|
89
89
|
] as readonly PartialFieldInfo[],
|
|
90
90
|
packedByDefault: true,
|
|
91
|
-
|
|
92
|
-
);
|
|
91
|
+
});
|
|
93
92
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptre/protobuf-es-lite",
|
|
3
3
|
"description": "Lightweight Protobuf codegen for TypeScript and JavaScript.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "git+ssh://git@github.com/aperturerobotics/protobuf-es-lite.git"
|
|
@@ -50,9 +50,11 @@
|
|
|
50
50
|
"clean": "rimraf ./dist",
|
|
51
51
|
"build": "npm run clean && tsc --project tsconfig.json --outDir ./dist",
|
|
52
52
|
"release:version": "npm version patch -m \"release: v%s\" --no-git-tag-version",
|
|
53
|
+
"release:version:minor": "npm version minor -m \"release: v%s\" --no-git-tag-version",
|
|
53
54
|
"release:commit": "git reset && git add package.json && git commit -s -m \"release: v$npm_package_version\" && git tag v$npm_package_version",
|
|
54
55
|
"release:publish": "git push && git push --tags && npm run build && npm publish",
|
|
55
56
|
"release": "npm run release:version && npm run release:commit",
|
|
57
|
+
"release:minor": "npm run release:version:minor && npm run release:commit",
|
|
56
58
|
"typecheck": "tsc --noEmit --project tsconfig.json --outDir ./dist",
|
|
57
59
|
"gen": "npm run build && npm run gen:wkt && npm run gen:example",
|
|
58
60
|
"gen:wkt": "cd ./src && bash gen.bash",
|