@openhps/protobuf 1.0.1 → 1.1.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 +58 -38
- package/dist/cjs/InternalProtobufDeserializer.js +30 -15
- package/dist/cjs/InternalProtobufDeserializer.js.map +1 -1
- package/dist/cjs/InternalProtobufSerializer.js +7 -7
- package/dist/cjs/InternalProtobufSerializer.js.map +1 -1
- package/dist/cjs/PrimitiveWrapper.js +13 -0
- package/dist/cjs/PrimitiveWrapper.js.map +1 -0
- package/dist/cjs/ProtobufSerializer.js +27 -2
- package/dist/cjs/ProtobufSerializer.js.map +1 -1
- package/dist/cjs/bin/generator.js +3 -3
- package/dist/cjs/bin/generator.js.map +1 -1
- package/dist/cjs/generator/ObjectGenerator.js +30 -12
- package/dist/cjs/generator/ObjectGenerator.js.map +1 -1
- package/dist/cjs/generator/ProjectGenerator.js +89 -38
- package/dist/cjs/generator/ProjectGenerator.js.map +1 -1
- package/dist/cjs/generator/constants.js +11 -4
- package/dist/cjs/generator/constants.js.map +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/tsconfig.bundle.cjs.tsbuildinfo +1 -0
- package/dist/esm/InternalProtobufDeserializer.js +30 -14
- package/dist/esm/InternalProtobufDeserializer.js.map +1 -1
- package/dist/esm/InternalProtobufSerializer.js +7 -6
- package/dist/esm/InternalProtobufSerializer.js.map +1 -1
- package/dist/esm/PrimitiveWrapper.js +9 -0
- package/dist/esm/PrimitiveWrapper.js.map +1 -0
- package/dist/esm/ProtobufSerializer.js +30 -5
- package/dist/esm/ProtobufSerializer.js.map +1 -1
- package/dist/esm/bin/generator.js +5 -5
- package/dist/esm/bin/generator.js.map +1 -1
- package/dist/esm/decorators/index.js +1 -1
- package/dist/esm/generator/ObjectGenerator.js +32 -14
- package/dist/esm/generator/ObjectGenerator.js.map +1 -1
- package/dist/esm/generator/ProjectGenerator.js +92 -40
- package/dist/esm/generator/ProjectGenerator.js.map +1 -1
- package/dist/esm/generator/ServiceGenerator.js +1 -1
- package/dist/esm/generator/constants.js +11 -4
- package/dist/esm/generator/constants.js.map +1 -1
- package/dist/esm/generator/index.js +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/package.json +3 -0
- package/dist/esm/tsconfig.bundle.esm.tsbuildinfo +1 -0
- package/dist/esm/tsconfig.bundle.types.tsbuildinfo +1 -0
- package/dist/types/InternalProtobufDeserializer.d.ts +0 -2
- package/dist/types/InternalProtobufDeserializer.d.ts.map +1 -1
- package/dist/types/InternalProtobufSerializer.d.ts +0 -2
- package/dist/types/InternalProtobufSerializer.d.ts.map +1 -1
- package/dist/types/PrimitiveWrapper.d.ts +8 -0
- package/dist/types/PrimitiveWrapper.d.ts.map +1 -0
- package/dist/types/ProtobufSerializer.d.ts +6 -0
- package/dist/types/ProtobufSerializer.d.ts.map +1 -1
- package/dist/types/generator/ObjectGenerator.d.ts +2 -8
- package/dist/types/generator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/generator/ProjectGenerator.d.ts +1 -1
- package/dist/types/generator/ProjectGenerator.d.ts.map +1 -1
- package/dist/types/generator/constants.d.ts +1 -1
- package/dist/types/generator/constants.d.ts.map +1 -1
- package/dist/web/openhps-protobuf.es.js +17112 -12881
- package/dist/web/openhps-protobuf.es.js.map +1 -1
- package/dist/web/openhps-protobuf.es.min.js +2 -1
- package/dist/web/openhps-protobuf.es.min.js.LICENSE.txt +19 -0
- package/dist/web/openhps-protobuf.es.min.js.map +1 -1
- package/dist/web/openhps-protobuf.js +17434 -14605
- package/dist/web/openhps-protobuf.js.map +1 -1
- package/dist/web/openhps-protobuf.min.js +2 -1
- package/dist/web/openhps-protobuf.min.js.LICENSE.txt +19 -0
- package/dist/web/openhps-protobuf.min.js.map +1 -1
- package/package.json +125 -94
- package/src/InternalProtobufDeserializer.ts +52 -34
- package/src/InternalProtobufSerializer.ts +9 -10
- package/src/PrimitiveWrapper.ts +9 -0
- package/src/ProtobufSerializer.ts +33 -2
- package/src/bin/generator.ts +4 -4
- package/src/generator/ObjectGenerator.ts +34 -21
- package/src/generator/ProjectGenerator.ts +100 -42
- package/src/generator/constants.ts +11 -4
- package/dist/esm5/InternalProtobufDeserializer.js +0 -147
- package/dist/esm5/InternalProtobufDeserializer.js.map +0 -1
- package/dist/esm5/InternalProtobufSerializer.js +0 -132
- package/dist/esm5/InternalProtobufSerializer.js.map +0 -1
- package/dist/esm5/ProtobufSerializer.js +0 -131
- package/dist/esm5/ProtobufSerializer.js.map +0 -1
- package/dist/esm5/bin/generator.js +0 -104
- package/dist/esm5/bin/generator.js.map +0 -1
- package/dist/esm5/decorators/index.js +0 -2
- package/dist/esm5/decorators/index.js.map +0 -1
- package/dist/esm5/decorators/options.js +0 -2
- package/dist/esm5/decorators/options.js.map +0 -1
- package/dist/esm5/generator/ObjectGenerator.js +0 -311
- package/dist/esm5/generator/ObjectGenerator.js.map +0 -1
- package/dist/esm5/generator/ProjectGenerator.js +0 -115
- package/dist/esm5/generator/ProjectGenerator.js.map +0 -1
- package/dist/esm5/generator/ProtobufGenerator.js +0 -27
- package/dist/esm5/generator/ProtobufGenerator.js.map +0 -1
- package/dist/esm5/generator/ServiceGenerator.js +0 -10
- package/dist/esm5/generator/ServiceGenerator.js.map +0 -1
- package/dist/esm5/generator/constants.js +0 -18
- package/dist/esm5/generator/constants.js.map +0 -1
- package/dist/esm5/generator/index.js +0 -4
- package/dist/esm5/generator/index.js.map +0 -1
- package/dist/esm5/generator/types.js +0 -2
- package/dist/esm5/generator/types.js.map +0 -1
- package/dist/esm5/index.js +0 -3
- package/dist/esm5/index.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
|
177
177
|
|
|
178
|
-
Copyright 2019-
|
|
178
|
+
Copyright 2019-2026 Maxim Van de Wynckel & Vrije Universiteit Brussel
|
|
179
179
|
|
|
180
180
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
181
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
<br />
|
|
25
25
|
|
|
26
|
-
When serializing data generated by OpenHPS, the framework will use a modified serialization strategy of [TypedJSON](https://github.com/JohnWeisz/TypedJSON/) to convert the data to JSON format. This serialized JSON data can be used for socket, MQTT and REST communication when transmitting data from client to server. In real-time situations, JSON messages might be too large to transmit from embedded devices to a server.
|
|
26
|
+
When serializing data generated by OpenHPS, the framework will use a modified serialization strategy of [TypedJSON](https://github.com/JohnWeisz/TypedJSON/) to convert the data to JSON format. This serialized JSON data can be used for socket, MQTT and REST communication when transmitting data from client to server. In real-time situations, JSON messages might be too large to transmit from embedded devices to a server.
|
|
27
27
|
|
|
28
|
-
[Protocol buffers](https://protobuf.dev/) are language-neutral and platform-neutral mechanisms for serializing structured data to lightweight buffers. Instead of encoding the structure of your data within the JSON data that is being serialized, a structured
|
|
28
|
+
[Protocol buffers](https://protobuf.dev/) are language-neutral and platform-neutral mechanisms for serializing structured data to lightweight buffers. Instead of encoding the structure of your data within the JSON data that is being serialized, a structured _message type_ is defined beforehand that can be used by the serializer and deserializer. This structured _message type_ will ensure that the data adheres to a specific structure while also prevent the need to encode this structure within the serialized data, lowering the size of the serialized data drastically.
|
|
29
29
|
|
|
30
30
|
This OpenHPS module includes the serialization and deserialization engine for Protocol Buffer Messages to OpenHPS classes and object instances. In addition, this module provides a CLI tool for generating protocol message types of all OpenHPS modules installed in your project. Combined, these two features ensure that you do not have to manually create message types and do not manually have to create a custom deserialization strategy for each class you might need to serialize.
|
|
31
31
|
|
|
@@ -37,13 +37,14 @@ This OpenHPS module includes the serialization and deserialization engine for Pr
|
|
|
37
37
|
## Known Limitations/Workarounds
|
|
38
38
|
|
|
39
39
|
- JavaScript only uses `Number` as a primitive. Protocol buffers use integers, floats, ... OpenHPS includes the `NumberType` enum option for `SerializableMember` decorators. When no number type is specified a number will be serialized to a string to ensure compatibility.
|
|
40
|
-
- Polymorphism and inheritance is not possible in protocol buffer v3. In order to ensure maintainable messages, any serializable object with known types will be treated as a `google.protobuf.Any` type with an included `type_url` that can be used for deserialization.
|
|
41
|
-
- Objects that use generic types will also make use of `google.protobuf.Any`. However, generic types that include primitives will be serialized using a primitive wrapper.
|
|
40
|
+
- Polymorphism and inheritance is not possible in protocol buffer v3. In order to ensure maintainable messages, any serializable object with known types will be treated as a `google.protobuf.Any` type with an included `type_url` that can be used for deserialization.
|
|
41
|
+
- Objects that use generic types will also make use of `google.protobuf.Any`. However, generic types that include primitives will be serialized using a primitive wrapper.
|
|
42
42
|
|
|
43
43
|
## Usage
|
|
44
44
|
|
|
45
45
|
### CLI Generator
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
This module can generate the protocol files (*.proto) automatically.
|
|
47
48
|
|
|
48
49
|
1. Install the module using `npm install @openhps/protobuf@latest`
|
|
49
50
|
2. Open the root directory of your project containing your `package.json` file
|
|
@@ -51,19 +52,22 @@ This module can generate the protocol files (*.proto) automatically.
|
|
|
51
52
|
|
|
52
53
|
#### Parameters
|
|
53
54
|
|
|
54
|
-
`-d <directory>`
|
|
55
|
-
`-v`
|
|
55
|
+
`-d <directory>` Output directory\
|
|
56
|
+
`-v` Verbose logging
|
|
56
57
|
|
|
57
58
|
#### Output Data
|
|
59
|
+
|
|
58
60
|
The output directory will include a subdirectory for each OpenHPS package.
|
|
59
61
|
|
|
60
62
|
### Serialization and Deserialization
|
|
63
|
+
|
|
61
64
|
First the protocol buffer serializer has to be initialized with the messages.
|
|
65
|
+
|
|
62
66
|
```typescript
|
|
63
67
|
import { ProtobufSerializer } from '@openhps/protobuf';
|
|
64
68
|
|
|
65
69
|
// Initialize the protocol buffer serializer with the protocol files
|
|
66
|
-
ProtobufSerializer.initialize(
|
|
70
|
+
ProtobufSerializer.initialize('/home/openhps/protobuf/');
|
|
67
71
|
|
|
68
72
|
// Or
|
|
69
73
|
|
|
@@ -86,6 +90,7 @@ message DataObject {
|
|
|
86
90
|
repeated google.protobuf.Any relativePositions = 6;
|
|
87
91
|
}
|
|
88
92
|
```
|
|
93
|
+
|
|
89
94
|
```proto
|
|
90
95
|
package openhps.core;
|
|
91
96
|
syntax = "proto3";
|
|
@@ -108,58 +113,73 @@ message Absolute3DPosition {
|
|
|
108
113
|
```
|
|
109
114
|
|
|
110
115
|
### @openhps/socket
|
|
116
|
+
|
|
111
117
|
```ts
|
|
112
118
|
ModelBuilder.create()
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
.addService(
|
|
120
|
+
new SocketServer({
|
|
121
|
+
srv: server,
|
|
122
|
+
path: '/api/v1',
|
|
123
|
+
}),
|
|
124
|
+
)
|
|
125
|
+
.from(
|
|
126
|
+
new SocketServerSource({
|
|
127
|
+
uid: 'source',
|
|
128
|
+
// Override serializer and deserializer with protocol buffer
|
|
129
|
+
serialize: (obj) => ProtobufSerializer.serialize(obj),
|
|
130
|
+
deserialize: (obj) => ProtobufSerializer.deserialize(obj),
|
|
131
|
+
}),
|
|
132
|
+
)
|
|
133
|
+
.to()
|
|
134
|
+
.build();
|
|
125
135
|
```
|
|
126
136
|
|
|
127
137
|
### @openhps/mqtt
|
|
138
|
+
|
|
128
139
|
```ts
|
|
129
140
|
ModelBuilder.create()
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
.addService(
|
|
142
|
+
new MQTTServer({
|
|
143
|
+
port: 1443,
|
|
144
|
+
}),
|
|
145
|
+
)
|
|
146
|
+
.from(
|
|
147
|
+
new MQTTSourceNode({
|
|
148
|
+
uid: 'source',
|
|
149
|
+
// Override frame serializer (not the options)
|
|
150
|
+
serialize: (obj, options) => ({
|
|
151
|
+
frame: ProtobufSerializer.serialize(obj),
|
|
152
|
+
options,
|
|
153
|
+
}),
|
|
154
|
+
deserialize: (obj) => ProtobufSerializer.deserialize(obj.frame),
|
|
155
|
+
}),
|
|
156
|
+
)
|
|
157
|
+
.to()
|
|
158
|
+
.build();
|
|
144
159
|
```
|
|
145
160
|
|
|
146
161
|
## Getting Started
|
|
162
|
+
|
|
147
163
|
If you have [npm installed](https://www.npmjs.com/get-npm), start using @openhps/protobuf with the following command.
|
|
164
|
+
|
|
148
165
|
```bash
|
|
149
166
|
npm install @openhps/protobuf --save
|
|
150
167
|
```
|
|
151
168
|
|
|
152
169
|
## Contributors
|
|
153
|
-
|
|
170
|
+
|
|
171
|
+
The framework is open source and was developed as part of the PhD of Maxim Van de Wynckel under the supervision of Prof. Dr. Beat Signer. It is currently maintained by [MVdW-Software](https://mvdw-software.com).
|
|
154
172
|
|
|
155
173
|
## Contributing
|
|
156
|
-
|
|
174
|
+
|
|
175
|
+
Use of OpenHPS, contributions and feedback is highly appreciated. Please read our [contributing guidelines](https://github.com/OpenHPS/.github/blob/HEAD/CONTRIBUTING.md) for more information.
|
|
157
176
|
|
|
158
177
|
## License
|
|
159
|
-
|
|
178
|
+
|
|
179
|
+
Copyright (C) 2019-2026 Maxim Van de Wynckel & Vrije Universiteit Brussel
|
|
160
180
|
|
|
161
181
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
|
162
182
|
|
|
163
183
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
164
184
|
|
|
165
|
-
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
185
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalProtobufDeserializer = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const core_1 = require("@openhps/core");
|
|
6
|
-
const protobuf = tslib_1.__importStar(require("protobufjs"));
|
|
7
5
|
const typedjson_1 = require("typedjson");
|
|
6
|
+
const PrimitiveWrapper_1 = require("./PrimitiveWrapper");
|
|
8
7
|
class InternalProtobufDeserializer extends core_1.Deserializer {
|
|
9
8
|
constructor() {
|
|
10
9
|
super();
|
|
11
|
-
InternalProtobufDeserializer.primitiveWrapper = new protobuf.Type('PrimitiveWrapperMessage');
|
|
12
|
-
InternalProtobufDeserializer.primitiveWrapper.add(new protobuf.Field('value', 1, 'string'));
|
|
13
10
|
this.setDeserializationStrategy(Number, (object) => {
|
|
14
11
|
if (typeof object === 'number') {
|
|
15
12
|
return object;
|
|
@@ -53,7 +50,7 @@ class InternalProtobufDeserializer extends core_1.Deserializer {
|
|
|
53
50
|
convertAsObject(sourceObject, typeDescriptor, knownTypes, memberName, deserializer, memberOptions, serializerOptions) {
|
|
54
51
|
let expectedSelfType = typeDescriptor.ctor;
|
|
55
52
|
let sourceObjectMetadata = typedjson_1.JsonObjectMetadata.getFromConstructor(expectedSelfType);
|
|
56
|
-
if (
|
|
53
|
+
if (Object.prototype.hasOwnProperty.call(sourceObject, '_type') && sourceObject._type !== 0) {
|
|
57
54
|
const enumTypeClassname = sourceObjectMetadata.protobuf.enumMapping.get(sourceObject._type);
|
|
58
55
|
if (enumTypeClassname) {
|
|
59
56
|
const enumType = knownTypes.get(enumTypeClassname);
|
|
@@ -65,9 +62,21 @@ class InternalProtobufDeserializer extends core_1.Deserializer {
|
|
|
65
62
|
}
|
|
66
63
|
else if (sourceObject.type_url && sourceObject.value) {
|
|
67
64
|
const MessageType = serializerOptions.types.get(sourceObject.type_url);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
if (MessageType) {
|
|
66
|
+
const message = MessageType.decode(sourceObject.value);
|
|
67
|
+
const data = this.convertAsObject(message, new core_1.ConcreteTypeDescriptor(knownTypes.get(sourceObject.type_url)), knownTypes, memberName, deserializer, memberOptions, serializerOptions);
|
|
68
|
+
return data;
|
|
69
|
+
}
|
|
70
|
+
// Unknown type: fall back to the primitive wrapper for primitive values
|
|
71
|
+
const message = PrimitiveWrapper_1.primitiveWrapper.decode(sourceObject.value);
|
|
72
|
+
switch (sourceObject.type_url) {
|
|
73
|
+
case 'Boolean':
|
|
74
|
+
return (message.value === 'true');
|
|
75
|
+
case 'Number':
|
|
76
|
+
return Number(message.value);
|
|
77
|
+
default:
|
|
78
|
+
return message.value;
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
const sourceMetadata = sourceObjectMetadata;
|
|
73
82
|
// Strong-typed deserialization available, get to it.
|
|
@@ -84,30 +93,36 @@ class InternalProtobufDeserializer extends core_1.Deserializer {
|
|
|
84
93
|
const objMemberValue = sourceObject[memberName];
|
|
85
94
|
let revivedValue;
|
|
86
95
|
if (objMemberMetadata.name === 'uid') {
|
|
87
|
-
if (
|
|
96
|
+
if (Object.prototype.hasOwnProperty.call(sourceObject, 'uid_bytes') &&
|
|
97
|
+
sourceObject['uid_bytes'].byteLength > 0) {
|
|
88
98
|
revivedValue = core_1.UUID.fromBuffer(sourceObject['uid_bytes']).toString();
|
|
89
99
|
}
|
|
90
|
-
else if (
|
|
100
|
+
else if (Object.prototype.hasOwnProperty.call(sourceObject, 'uid_string')) {
|
|
91
101
|
revivedValue = sourceObject['uid_string'];
|
|
92
102
|
}
|
|
93
103
|
else {
|
|
94
104
|
return;
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
|
-
else if (!
|
|
107
|
+
else if (!Object.prototype.hasOwnProperty.call(sourceObject, memberName) ||
|
|
108
|
+
objMemberValue === undefined ||
|
|
109
|
+
objMemberValue === null) {
|
|
98
110
|
return;
|
|
99
111
|
}
|
|
100
112
|
else if (objMemberMetadata.type() === typedjson_1.AnyT && objMemberValue.type_url) {
|
|
101
113
|
const MessageType = serializerOptions.types.get(sourceObject[memberName].type_url);
|
|
102
114
|
if (MessageType) {
|
|
103
|
-
const
|
|
104
|
-
|
|
115
|
+
const messageType = knownTypes.get(objMemberValue.type_url);
|
|
116
|
+
if (messageType !== undefined) {
|
|
117
|
+
const message = MessageType.decode(objMemberValue.value);
|
|
118
|
+
revivedValue = deserializer.convertSingleValue(message, new core_1.ConcreteTypeDescriptor(messageType), knownTypes, objMemberDebugName, objMemberOptions, serializerOptions);
|
|
119
|
+
}
|
|
105
120
|
}
|
|
106
121
|
else if (objMemberValue.value) {
|
|
107
|
-
const message =
|
|
122
|
+
const message = PrimitiveWrapper_1.primitiveWrapper.decode(objMemberValue.value);
|
|
108
123
|
switch (objMemberValue.type_url) {
|
|
109
124
|
case 'Boolean':
|
|
110
|
-
revivedValue =
|
|
125
|
+
revivedValue = message.value === 'true';
|
|
111
126
|
break;
|
|
112
127
|
case 'Number':
|
|
113
128
|
revivedValue = Number(message.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalProtobufDeserializer.js","sourceRoot":"","sources":["../../src/InternalProtobufDeserializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InternalProtobufDeserializer.js","sourceRoot":"","sources":["../../src/InternalProtobufDeserializer.ts"],"names":[],"mappings":";;;AAAA,wCAWuB;AACvB,yCAAqD;AAErD,yDAAsD;AAEtD,MAAa,4BAA6B,SAAQ,mBAAY;IAC1D;QACI,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,CAAC,MAAW,EAAE,EAAE;YACpD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC7B,OAAO,MAAM,CAAC;YACl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ChB,iBAAiB,CACpB,CAAC;YACN,CAAC;YAED,IAAI,gBAAS,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC/C,sCAAsC,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC;YACjF,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,mCAAmC;QACnC,MAAM,YAAY,GAAkB,YAAY,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAEnF,4DAA4D;QAC5D,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,sCAAsC,CAAC,CAAC;QAEpE,uCAAuC;QACvC,MAAM,UAAU,GAAG,oBAAoB,CAAC,wBAAwB,CAAC;QACjE,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,OAAQ,YAAoB,CAAC,UAAU,CAAC,KAAK,UAAU,EAAE,CAAC;gBAC1D,yBAAyB;gBACxB,YAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;YACxC,CAAC;iBAAM,IAAI,OAAQ,YAAY,CAAC,WAAmB,CAAC,UAAU,CAAC,KAAK,UAAU,EAAE,CAAC;gBAC7E,mBAAmB;gBAClB,YAAY,CAAC,WAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;YACpD,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,eAAe,EAAE,CAC1B,IAAI,SAAS,CACT,yBAAyB;oBACrB,IAAI,gBAAS,CAAC,KAAK,CAAC,MAAM,CACtB,oBAAoB,CAAC,SAAS,CACjC,IAAI,UAAU,oBAAoB,CAC1C,CACJ,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ;AAtPD,oEAsPC"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalProtobufSerializer = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const core_1 = require("@openhps/core");
|
|
6
5
|
const typedjson_1 = require("typedjson");
|
|
7
|
-
const
|
|
6
|
+
const PrimitiveWrapper_1 = require("./PrimitiveWrapper");
|
|
8
7
|
class InternalProtobufSerializer extends core_1.Serializer {
|
|
9
8
|
constructor() {
|
|
10
9
|
super();
|
|
11
10
|
this.setSerializationStrategy(Map, this.convertAsMap.bind(this));
|
|
12
|
-
InternalProtobufSerializer.primitiveWrapper = new protobuf.Type('PrimitiveWrapperMessage');
|
|
13
|
-
InternalProtobufSerializer.primitiveWrapper.add(new protobuf.Field('value', 1, 'string'));
|
|
14
11
|
}
|
|
15
12
|
convertSingleValue(sourceObject, typeDescriptor, memberName, memberOptions, serializerOptions) {
|
|
16
13
|
if (!core_1.TypedJSON.utils.isValueDefined(sourceObject)) {
|
|
@@ -73,7 +70,10 @@ class InternalProtobufSerializer extends core_1.Serializer {
|
|
|
73
70
|
}
|
|
74
71
|
else {
|
|
75
72
|
const MessageType = sourceTypeMetadata.protobuf.messageType;
|
|
76
|
-
|
|
73
|
+
// Look the field up by its wire name: members renamed through
|
|
74
|
+
// `options.protobuf.name` are emitted under that name, so the
|
|
75
|
+
// metadata name would not resolve for them.
|
|
76
|
+
const field = MessageType.get(memberName);
|
|
77
77
|
serialized = this.convertSingleValue(sourceObject[objMemberMetadata.key], objMemberMetadata.type(), `${core_1.TypedJSON.utils.nameof(sourceMeta.classType)}.${objMemberMetadata.key}`, objMemberOptions, Object.assign(Object.assign({}, serializerOptions), { field }));
|
|
78
78
|
}
|
|
79
79
|
if (core_1.TypedJSON.utils.isValueDefined(serialized)) {
|
|
@@ -87,12 +87,12 @@ class InternalProtobufSerializer extends core_1.Serializer {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
const message =
|
|
90
|
+
const message = PrimitiveWrapper_1.primitiveWrapper.create({
|
|
91
91
|
value: String(sourceObject[objMemberMetadata.key]),
|
|
92
92
|
});
|
|
93
93
|
serialized = {
|
|
94
94
|
type_url: sourceObject[objMemberMetadata.key].constructor.name,
|
|
95
|
-
value:
|
|
95
|
+
value: PrimitiveWrapper_1.primitiveWrapper.encode(message).finish(),
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalProtobufSerializer.js","sourceRoot":"","sources":["../../src/InternalProtobufSerializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InternalProtobufSerializer.js","sourceRoot":"","sources":["../../src/InternalProtobufSerializer.ts"],"names":[],"mappings":";;;AAAA,wCAUuB;AACvB,yCAAqD;AAErD,yDAAsD;AAEtD,MAAa,0BAA2B,SAAQ,iBAAU;IACtD;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,wBAAwB,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,kBAAkB,CACd,YAAiB,EACjB,cAA8B,EAC9B,UAAmB,EACnB,aAAoC,EACpC,iBAAuB;QAEvB,IAAI,CAAC,gBAAS,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,CAAC;YAChD,OAAO;QACX,CAAC;QAED,IAAI,CAAC,gBAAS,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACnE,MAAM,YAAY,GAAG,gBAAS,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACjE,MAAM,UAAU,GAAG,gBAAS,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;YAEpE,IAAI,CAAC,YAAY,CACb,IAAI,SAAS,CACT,wBAAwB,UAAU,gBAAgB,YAAY,IAAI,GAAG,SAAS,UAAU,IAAI,CAC/F,CACJ,CAAC;YACF,OAAO;QACX,CAAC;QAED,MAAM,UAAU,GAAG,IAA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AC,SAAS,EACxB,UAAU,EACV,aAAa,EACb,iBAAiB,CACpB,CAAC;QACN,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAnMD,gEAmMC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.primitiveWrapper = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const protobuf = tslib_1.__importStar(require("protobufjs"));
|
|
6
|
+
/**
|
|
7
|
+
* Protobuf type wrapping a primitive value as a string.
|
|
8
|
+
* Shared by the serializer and the deserializer as the `google.protobuf.Any`
|
|
9
|
+
* fallback for primitive values that protobuf cannot express directly.
|
|
10
|
+
*/
|
|
11
|
+
exports.primitiveWrapper = new protobuf.Type('PrimitiveWrapperMessage');
|
|
12
|
+
exports.primitiveWrapper.add(new protobuf.Field('value', 1, 'string'));
|
|
13
|
+
//# sourceMappingURL=PrimitiveWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrimitiveWrapper.js","sourceRoot":"","sources":["../../src/PrimitiveWrapper.ts"],"names":[],"mappings":";;;;AAAA,6DAAuC;AAEvC;;;;GAIG;AACU,QAAA,gBAAgB,GAAkB,IAAI,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AAC5F,wBAAgB,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -34,6 +34,26 @@ class ProtobufSerializer extends core_1.DataSerializer {
|
|
|
34
34
|
static initialize(directory) {
|
|
35
35
|
return new Promise((resolve, reject) => {
|
|
36
36
|
ProtobufSerializer.root = new protobuf.Root();
|
|
37
|
+
// Reinitialisation (e.g. per test) must not accumulate stale type entries:
|
|
38
|
+
// build the new map first and only swap it in once the schemas have
|
|
39
|
+
// loaded, so a failed load keeps the previous types instead of wiping them
|
|
40
|
+
const types = new Map();
|
|
41
|
+
// The generated schemas extend google.protobuf.EnumValueOptions, which is
|
|
42
|
+
// declared in descriptor.proto. protobufjs resolves imports relative to the
|
|
43
|
+
// origin file, so it looked for google/protobuf/descriptor.proto inside the
|
|
44
|
+
// generated output directory and failed with "unresolvable extensions".
|
|
45
|
+
// protobufjs ships the well-known types itself; point the resolver at them.
|
|
46
|
+
// Resolve the package root from a literal specifier: a template literal here
|
|
47
|
+
// makes webpack build a context module over the whole protobufjs package,
|
|
48
|
+
// which then tries to parse its .d.ts and tsconfig.json as bundle input.
|
|
49
|
+
const protobufRoot = path.dirname(require.resolve('protobufjs/package.json'));
|
|
50
|
+
const defaultResolve = ProtobufSerializer.root.resolvePath.bind(ProtobufSerializer.root);
|
|
51
|
+
ProtobufSerializer.root.resolvePath = (origin, target) => {
|
|
52
|
+
if (target.startsWith('google/protobuf/')) {
|
|
53
|
+
return path.join(protobufRoot, target);
|
|
54
|
+
}
|
|
55
|
+
return defaultResolve(origin, target);
|
|
56
|
+
};
|
|
37
57
|
Promise.resolve(!directory ? generator_1.ProjectGenerator.buildProject(path.resolve('tmp')) : Promise.resolve())
|
|
38
58
|
.then(() => {
|
|
39
59
|
const files = this.getFiles(path.resolve(directory !== null && directory !== void 0 ? directory : 'tmp'));
|
|
@@ -73,22 +93,24 @@ class ProtobufSerializer extends core_1.DataSerializer {
|
|
|
73
93
|
messageTypeEnum: enumNumber,
|
|
74
94
|
enumMapping,
|
|
75
95
|
};
|
|
76
|
-
|
|
96
|
+
types.set(className, MessageType);
|
|
77
97
|
}
|
|
78
98
|
});
|
|
99
|
+
this.options.types = types;
|
|
79
100
|
resolve();
|
|
80
101
|
})
|
|
81
102
|
.catch((error) => {
|
|
82
103
|
return reject(error);
|
|
83
104
|
});
|
|
84
105
|
});
|
|
106
|
+
this.wrapperRoot = new protobuf.Root();
|
|
85
107
|
this.wrapperMessage = new protobuf.Type('WrapperMessage');
|
|
86
108
|
this.wrapperMessage.add(new protobuf.Field('data', 1, 'google.protobuf.Any'));
|
|
87
109
|
this.wrapperMessage.addJSON(protobuf.common['google/protobuf/any.proto'].nested);
|
|
110
|
+
this.wrapperRoot.add(this.wrapperMessage);
|
|
88
111
|
return loadPromise;
|
|
89
112
|
})
|
|
90
113
|
.then(() => {
|
|
91
|
-
console.log(ProtobufSerializer.root.toJSON());
|
|
92
114
|
resolve();
|
|
93
115
|
})
|
|
94
116
|
.catch(reject);
|
|
@@ -122,6 +144,9 @@ class ProtobufSerializer extends core_1.DataSerializer {
|
|
|
122
144
|
const decodedData = this.wrapperMessage.decode(serializedData);
|
|
123
145
|
const typeURL = decodedData.data.type_url;
|
|
124
146
|
const MessageType = this.options.types.get(typeURL);
|
|
147
|
+
if (MessageType === undefined) {
|
|
148
|
+
throw new Error(`Unknown protobuf type '${typeURL}'`);
|
|
149
|
+
}
|
|
125
150
|
const decodedMessage = MessageType.decode(decodedData.data.value);
|
|
126
151
|
const finalType = dataType !== null && dataType !== void 0 ? dataType : this.knownTypes.get(typeURL);
|
|
127
152
|
return this.options.deserializer.convertSingleValue(decodedMessage, core_1.DataSerializerUtils.ensureTypeDescriptor(finalType), core_1.DataSerializer.knownTypes, undefined, undefined, Object.assign(Object.assign({}, config), this.options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtobufSerializer.js","sourceRoot":"","sources":["../../src/ProtobufSerializer.ts"],"names":[],"mappings":";;;;AAAA,wCAAuG;AACvG,mDAA6B;AAC7B,6DAAuC;AACvC,+CAAyB;AACzB,2CAA+C;AAC/C,iFAA8E;AAC9E,6EAA0E;AAE1E,MAAa,kBAAmB,SAAQ,qBAAc;
|
|
1
|
+
{"version":3,"file":"ProtobufSerializer.js","sourceRoot":"","sources":["../../src/ProtobufSerializer.ts"],"names":[],"mappings":";;;;AAAA,wCAAuG;AACvG,mDAA6B;AAC7B,6DAAuC;AACvC,+CAAyB;AACzB,2CAA+C;AAC/C,iFAA8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CAAC,EACnD,qBAAc,CAAC,UAAU,EACzB,SAAS,EACT,SAAS,kCAEF,MAAM,GACN,IAAI,CAAC,OAAO,EAEtB,CAAC;IACN,CAAC;;AAzLL,gDA0LC;AAlLoB,0BAAO,GAA6B;IACjD,UAAU,EAAE,IAAI,uDAA0B,EAAE;IAC5C,YAAY,EAAE,IAAI,2DAA4B,EAAE;IAChD,KAAK,EAAE,IAAI,GAAG,EAAE;CACnB,CAAC"}
|
|
@@ -10,7 +10,7 @@ const prompts_1 = require("@inquirer/prompts");
|
|
|
10
10
|
const yargs = tslib_1.__importStar(require("yargs"));
|
|
11
11
|
const core_1 = require("@openhps/core");
|
|
12
12
|
const ProtobufSerializer_1 = require("../ProtobufSerializer");
|
|
13
|
-
const
|
|
13
|
+
const strict_1 = tslib_1.__importDefault(require("node:assert/strict"));
|
|
14
14
|
const args = yargs.argv;
|
|
15
15
|
const data = {
|
|
16
16
|
directory: path.normalize('tmp'),
|
|
@@ -90,13 +90,13 @@ function test() {
|
|
|
90
90
|
frame.addObject(new core_1.DataObject('test2', 'Test Object 2'));
|
|
91
91
|
const buffer = ProtobufSerializer_1.ProtobufSerializer.serialize(frame);
|
|
92
92
|
const deserialized = ProtobufSerializer_1.ProtobufSerializer.deserialize(buffer);
|
|
93
|
-
(
|
|
93
|
+
strict_1.default.notStrictEqual(deserialized, undefined, 'deserialization returned undefined');
|
|
94
94
|
const compare1 = JSON.stringify(core_1.DataSerializer.serialize(deserialized), null, 2);
|
|
95
95
|
const compare2 = JSON.stringify(core_1.DataSerializer.serialize(frame), null, 2);
|
|
96
96
|
// console.log(compare1);
|
|
97
97
|
// console.log('\n');
|
|
98
98
|
// console.log(compare2);
|
|
99
|
-
(
|
|
99
|
+
strict_1.default.deepStrictEqual(compare1, compare2, 'round-tripped frame differs from the original');
|
|
100
100
|
console.log(chalk_1.default.green(`Basic serialization and deserialization test completed!`));
|
|
101
101
|
resolve();
|
|
102
102
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/bin/generator.ts"],"names":[],"mappings":";;;;AAEA,0DAA0B;AAC1B,6CAAiD;AACjD,uBAAqB;AACrB,mDAA6B;AAC7B,+CAA0C;AAC1C,qDAA+B;AAC/B,wCAYuB;AACvB,8DAA2D;AAC3D
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/bin/generator.ts"],"names":[],"mappings":";;;;AAEA,0DAA0B;AAC1B,6CAAiD;AACjD,uBAAqB;AACrB,mDAA6B;AAC7B,+CAA0C;AAC1C,qDAA+B;AAC/B,wCAYuB;AACvB,8DAA2D;AAC3D,wEAAwC;AAExC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;AACxB,MAAM,IAAI,GAAG;IACT,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,SAAS,IAAI;;IACT,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC,CAAC;IAElE,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;QAChG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,OAAO,CACX,MAAA,IAAI,CAAC,GAAG,CAAC,mCACL,IAAA,eAAK,EAAC;QACF,OAAO,EAAE,4BAA4B;KACxC,CAAC,CACT,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAA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