ts-proto 1.147.2 → 1.147.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/README.markdown +1 -1
- package/build/generate-grpc-web.js +9 -13
- package/build/main.js +4 -4
- package/package.json +1 -1
package/README.markdown
CHANGED
|
@@ -78,7 +78,7 @@ It will also generate client implementations of `PingService`; currently [Twirp]
|
|
|
78
78
|
- `npm install ts-proto`
|
|
79
79
|
- `protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=. ./simple.proto`
|
|
80
80
|
- (Note that the output parameter name, `ts_proto_out`, is named based on the suffix of the plugin's name, i.e. "ts_proto" suffix in the `--plugin=./node_modules/.bin/protoc-gen-ts_proto` parameter becomes the `_out` prefix, per `protoc`'s CLI conventions.)
|
|
81
|
-
- On Windows, use `protoc --plugin=protoc-gen-ts_proto
|
|
81
|
+
- On Windows, use `protoc --plugin=protoc-gen-ts_proto=".\\node_modules\\.bin\\protoc-gen-ts_proto.cmd" --ts_proto_out=. ./simple.proto` (see [#93](https://github.com/stephenh/ts-proto/issues/93))
|
|
82
82
|
- Ensure you're using a modern `protoc`, i.e. the original `protoc` `3.0.0` doesn't support the `_opt` flag
|
|
83
83
|
|
|
84
84
|
This will generate `*.ts` source files for the given `*.proto` types.
|
|
@@ -214,12 +214,10 @@ function createPromiseUnaryMethod(ctx) {
|
|
|
214
214
|
const { useAbortSignal } = options;
|
|
215
215
|
const maybeAbortSignal = useAbortSignal
|
|
216
216
|
? `
|
|
217
|
-
|
|
217
|
+
if (abortSignal) abortSignal.addEventListener("abort", () => {
|
|
218
218
|
client.close();
|
|
219
|
-
reject(
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (abortSignal) abortSignal.addEventListener("abort", abortHandler);`
|
|
219
|
+
reject(abortSignal.reason);
|
|
220
|
+
});`
|
|
223
221
|
: "";
|
|
224
222
|
return (0, ts_poet_1.code) `
|
|
225
223
|
unary<T extends UnaryMethodDefinitionish>(
|
|
@@ -260,11 +258,10 @@ function createObservableUnaryMethod(ctx) {
|
|
|
260
258
|
const { useAbortSignal } = options;
|
|
261
259
|
const maybeAbortSignal = useAbortSignal
|
|
262
260
|
? `
|
|
263
|
-
|
|
264
|
-
observer.error(
|
|
261
|
+
if (abortSignal) abortSignal.addEventListener("abort", () => {
|
|
262
|
+
observer.error(abortSignal.reason);
|
|
265
263
|
client.close();
|
|
266
|
-
}
|
|
267
|
-
if (abortSignal) abortSignal.addEventListener("abort", abortHandler);`
|
|
264
|
+
});`
|
|
268
265
|
: "";
|
|
269
266
|
return (0, ts_poet_1.code) `
|
|
270
267
|
unary<T extends UnaryMethodDefinitionish>(
|
|
@@ -308,11 +305,10 @@ function createInvokeMethod(ctx) {
|
|
|
308
305
|
const { useAbortSignal } = options;
|
|
309
306
|
const maybeAbortSignal = useAbortSignal
|
|
310
307
|
? `
|
|
311
|
-
|
|
312
|
-
observer.error(
|
|
308
|
+
if (abortSignal) abortSignal.addEventListener("abort", () => {
|
|
309
|
+
observer.error(abortSignal.reason);
|
|
313
310
|
client.close();
|
|
314
|
-
}
|
|
315
|
-
if (abortSignal) abortSignal.addEventListener("abort", abortHandler);`
|
|
311
|
+
});`
|
|
316
312
|
: "";
|
|
317
313
|
return (0, ts_poet_1.code) `
|
|
318
314
|
invoke<T extends UnaryMethodDefinitionish>(
|
package/build/main.js
CHANGED
|
@@ -507,15 +507,15 @@ function makeTimestampMethods(options, longs) {
|
|
|
507
507
|
const fromTimestamp = (0, ts_poet_1.conditionalOutput)("fromTimestamp", options.useDate === options_1.DateOption.STRING
|
|
508
508
|
? (0, ts_poet_1.code) `
|
|
509
509
|
function fromTimestamp(t: ${Timestamp}): string {
|
|
510
|
-
let millis = ${toNumberCode} * 1_000;
|
|
511
|
-
millis += t.nanos / 1_000_000;
|
|
510
|
+
let millis = (${toNumberCode} || 0) * 1_000;
|
|
511
|
+
millis += (t.nanos || 0) / 1_000_000;
|
|
512
512
|
return new Date(millis).toISOString();
|
|
513
513
|
}
|
|
514
514
|
`
|
|
515
515
|
: (0, ts_poet_1.code) `
|
|
516
516
|
function fromTimestamp(t: ${Timestamp}): Date {
|
|
517
|
-
let millis = ${toNumberCode} * 1_000;
|
|
518
|
-
millis += t.nanos / 1_000_000;
|
|
517
|
+
let millis = (${toNumberCode} || 0) * 1_000;
|
|
518
|
+
millis += (t.nanos || 0) / 1_000_000;
|
|
519
519
|
return new Date(millis);
|
|
520
520
|
}
|
|
521
521
|
`);
|