ts-proto 1.166.2 → 1.166.4

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.
@@ -51,7 +51,7 @@ function generateWrapDeep(ctx, fullProtoTypeName, fieldNames) {
51
51
  } else if (typeof value === 'object') {
52
52
  result.${fieldNames.structValue} = Struct.wrap(value);
53
53
  } else if (typeof value !== 'undefined') {
54
- throw new Error('Unsupported any value type: ' + typeof value);
54
+ throw new ${ctx.utils.globalThis}.Error('Unsupported any value type: ' + typeof value);
55
55
  }
56
56
  return result;
57
57
  }`);
@@ -178,7 +178,7 @@ function generateWrapShallow(ctx, fullProtoTypeName, fieldNames) {
178
178
  } else if (typeof value === 'object') {
179
179
  result.kind = {$case: '${fieldNames.structValue}', ${fieldNames.structValue}: value};
180
180
  } else if (typeof value !== 'undefined') {
181
- throw new Error('Unsupported any value type: ' + typeof value);
181
+ throw new ${ctx.utils.globalThis}.Error('Unsupported any value type: ' + typeof value);
182
182
  }
183
183
  return result;
184
184
  }`);
@@ -199,7 +199,7 @@ function generateWrapShallow(ctx, fullProtoTypeName, fieldNames) {
199
199
  } else if (typeof value === 'object') {
200
200
  result.${fieldNames.structValue} = value;
201
201
  } else if (typeof value !== 'undefined') {
202
- throw new Error('Unsupported any value type: ' + typeof value);
202
+ throw new ${ctx.utils.globalThis}.Error('Unsupported any value type: ' + typeof value);
203
203
  }
204
204
  return result;
205
205
  }`);
package/build/main.js CHANGED
@@ -283,7 +283,7 @@ function makeUtils(options) {
283
283
  ...makeNiceGrpcServerStreamingMethodResult(),
284
284
  ...makeGrpcWebErrorClass(bytes),
285
285
  ...makeExtensionClass(options),
286
- ...makeAssertionUtils(),
286
+ ...makeAssertionUtils(bytes),
287
287
  };
288
288
  }
289
289
  exports.makeUtils = makeUtils;
@@ -611,10 +611,10 @@ function makeExtensionClass(options) {
611
611
  `);
612
612
  return { Extension };
613
613
  }
614
- function makeAssertionUtils() {
614
+ function makeAssertionUtils(bytes) {
615
615
  const fail = (0, ts_poet_1.conditionalOutput)("fail", (0, ts_poet_1.code) `
616
616
  function fail(message?: string): never {
617
- throw new Error(message ?? "Failed");
617
+ throw new ${bytes.globalThis}.Error(message ?? "Failed");
618
618
  }
619
619
  `);
620
620
  return { fail };
@@ -987,13 +987,13 @@ function getEncodeWriteSnippet(ctx, field) {
987
987
  case "sint64":
988
988
  case "sfixed64":
989
989
  return (place) => (0, ts_poet_1.code) `if (BigInt.asIntN(64, ${place}) !== ${place}) {
990
- throw new Error('value provided for field ${place} of type ${fieldType} too large');
990
+ throw new ${utils.globalThis}.Error('value provided for field ${place} of type ${fieldType} too large');
991
991
  }
992
992
  writer.uint32(${tag}).${(0, types_1.toReaderCall)(field)}(${place}.toString())`;
993
993
  case "uint64":
994
994
  case "fixed64":
995
995
  return (place) => (0, ts_poet_1.code) `if (BigInt.asUintN(64, ${place}) !== ${place}) {
996
- throw new Error('value provided for field ${place} of type ${fieldType} too large');
996
+ throw new ${utils.globalThis}.Error('value provided for field ${place} of type ${fieldType} too large');
997
997
  }
998
998
  writer.uint32(${tag}).${(0, types_1.toReaderCall)(field)}(${place}.toString())`;
999
999
  default:
@@ -1156,7 +1156,7 @@ function generateEncode(ctx, fullName, messageDesc) {
1156
1156
  writer.uint32(${tag}).fork();
1157
1157
  for (const v of ${messageProperty}) {
1158
1158
  if (BigInt.asIntN(64, v) !== v) {
1159
- throw new Error('a value provided in array field ${fieldName} of type ${fieldType} is too large');
1159
+ throw new ${utils.globalThis}.Error('a value provided in array field ${fieldName} of type ${fieldType} is too large');
1160
1160
  }
1161
1161
  writer.${(0, types_1.toReaderCall)(field)}(${rhs("v")});
1162
1162
  }
@@ -1169,7 +1169,7 @@ function generateEncode(ctx, fullName, messageDesc) {
1169
1169
  writer.uint32(${tag}).fork();
1170
1170
  for (const v of ${messageProperty}) {
1171
1171
  if (BigInt.asUintN(64, v) !== v) {
1172
- throw new Error('a value provided in array field ${fieldName} of type ${fieldType} is too large');
1172
+ throw new ${utils.globalThis}.Error('a value provided in array field ${fieldName} of type ${fieldType} is too large');
1173
1173
  }
1174
1174
  writer.${(0, types_1.toReaderCall)(field)}(${rhs("v")});
1175
1175
  }
package/build/utils.js CHANGED
@@ -22,7 +22,7 @@ function generateIndexFiles(files, options) {
22
22
  if (!(part in branch.leaves)) {
23
23
  const prePkgParts = pkgParts.slice(0, i + 1);
24
24
  const index = `index.${prePkgParts.join(".")}.ts`;
25
- branch.chunks.push((0, ts_poet_1.code) `export * as ${part} from "./${path.basename(index, ".ts")}";`);
25
+ branch.chunks.push((0, ts_poet_1.code) `export * as ${part} from "./${path.basename(index, ".ts") + options.importSuffix}";`);
26
26
  branch.leaves[part] = {
27
27
  index,
28
28
  leaves: {},
@@ -31,7 +31,7 @@ function generateIndexFiles(files, options) {
31
31
  }
32
32
  return branch.leaves[part];
33
33
  }, packageTree);
34
- branch.chunks.push((0, ts_poet_1.code) `export * from "./${moduleName}";`);
34
+ branch.chunks.push((0, ts_poet_1.code) `export * from "./${moduleName + options.importSuffix}";`);
35
35
  }
36
36
  const indexFiles = [];
37
37
  let branches = [packageTree];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.166.2",
3
+ "version": "1.166.4",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",