ts-proto 2.2.1 → 2.2.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/build/src/encode.js +1 -1
- package/build/src/main.js +3 -3
- package/build/src/visit.js +1 -1
- package/package.json +1 -1
package/build/src/encode.js
CHANGED
|
@@ -59,7 +59,7 @@ function generateDecoder(ctx, typeName) {
|
|
|
59
59
|
}
|
|
60
60
|
let TypeValue;
|
|
61
61
|
if (name == "Timestamp") {
|
|
62
|
-
TypeValue = (0, utils_1.impProto)(ctx.options, "google/protobuf/timestamp", name);
|
|
62
|
+
TypeValue = (0, utils_1.impProto)(ctx.options, "google/protobuf/timestamp", options.typePrefix + name + options.typeSuffix);
|
|
63
63
|
const decoder = (0, ts_poet_1.code) `${TypeValue}.decode(value)`;
|
|
64
64
|
if (ctx.options.useDate === options_1.DateOption.DATE ||
|
|
65
65
|
ctx.options.useDate === options_1.DateOption.STRING ||
|
package/build/src/main.js
CHANGED
|
@@ -636,7 +636,7 @@ function makeObjectIdMethods() {
|
|
|
636
636
|
return { fromJsonObjectId, fromProtoObjectId, toProtoObjectId };
|
|
637
637
|
}
|
|
638
638
|
function makeTimestampMethods(options, longs, bytes) {
|
|
639
|
-
const Timestamp = (0, utils_1.impProto)(options, "google/protobuf/timestamp",
|
|
639
|
+
const Timestamp = (0, utils_1.impProto)(options, "google/protobuf/timestamp", `${options.typePrefix}Timestamp${options.typeSuffix}`);
|
|
640
640
|
const NanoDate = (0, ts_poet_1.imp)("NanoDate=nano-date");
|
|
641
641
|
let seconds = "Math.trunc(date.getTime() / 1_000)";
|
|
642
642
|
let toNumberCode = "t.seconds";
|
|
@@ -726,12 +726,12 @@ function makeTimestampMethods(options, longs, bytes) {
|
|
|
726
726
|
} else if (typeof o === "string") {
|
|
727
727
|
return new ${bytes.globalThis}.Date(o);
|
|
728
728
|
} else {
|
|
729
|
-
return ${fromTimestamp}(Timestamp.fromJSON(o));
|
|
729
|
+
return ${fromTimestamp}(${options.typePrefix}Timestamp${options.typeSuffix}.fromJSON(o));
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
732
|
`
|
|
733
733
|
: (0, ts_poet_1.code) `
|
|
734
|
-
function fromJsonTimestamp(o: any): Timestamp {
|
|
734
|
+
function fromJsonTimestamp(o: any): ${options.typePrefix}Timestamp${options.typeSuffix} {
|
|
735
735
|
if (o instanceof ${bytes.globalThis}.Date) {
|
|
736
736
|
return ${toTimestamp}(o);
|
|
737
737
|
} else if (typeof o === "string") {
|
package/build/src/visit.js
CHANGED
|
@@ -30,7 +30,7 @@ function visit(proto, sourceInfo, messageFn, options, enumFn = () => { }, tsPref
|
|
|
30
30
|
visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + delim, protoFullName + ".");
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
const builtInNames = ["Date"];
|
|
33
|
+
const builtInNames = ["Date", "Function"];
|
|
34
34
|
/** Potentially suffixes `Message` to names to avoid conflicts, i.e. with `Date`. */
|
|
35
35
|
function messageName(message) {
|
|
36
36
|
const { name } = message;
|