@bufbuild/protoplugin 1.2.1 → 1.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.
@@ -103,7 +103,7 @@ function printableToEl(printables, el, createTypeImport, runtimeImports) {
103
103
  el.push(p);
104
104
  break;
105
105
  case "number":
106
- el.push(literalNumber(p));
106
+ el.push(...literalNumber(p, runtimeImports));
107
107
  break;
108
108
  case "boolean":
109
109
  el.push(p.toString());
@@ -241,15 +241,15 @@ function processImports(el, importerPath, rewriteImportPath, makeImportStatement
241
241
  }
242
242
  return symbolToIdentifier;
243
243
  }
244
- function literalNumber(value) {
244
+ function literalNumber(value, runtimeImports) {
245
245
  if (Number.isNaN(value)) {
246
- return "globalThis.Number.NaN";
246
+ return [runtimeImports.protoDouble, ".NaN"];
247
247
  }
248
248
  if (value === Number.POSITIVE_INFINITY) {
249
- return "globalThis.Number.POSITIVE_INFINITY";
249
+ return [runtimeImports.protoDouble, ".POSITIVE_INFINITY"];
250
250
  }
251
251
  if (value === Number.NEGATIVE_INFINITY) {
252
- return "globalThis.Number.NEGATIVE_INFINITY";
252
+ return [runtimeImports.protoDouble, ".NEGATIVE_INFINITY"];
253
253
  }
254
254
  return value.toString(10);
255
255
  }
@@ -32,6 +32,7 @@ function createRuntimeImports(bootstrapWkt) {
32
32
  JsonWriteOptions: infoToSymbol("JsonWriteOptions", bootstrapWkt),
33
33
  JsonValue: infoToSymbol("JsonValue", bootstrapWkt),
34
34
  JsonObject: infoToSymbol("JsonObject", bootstrapWkt),
35
+ protoDouble: infoToSymbol("protoDouble", bootstrapWkt),
35
36
  protoInt64: infoToSymbol("protoInt64", bootstrapWkt),
36
37
  ScalarType: infoToSymbol("ScalarType", bootstrapWkt),
37
38
  MethodKind: infoToSymbol("MethodKind", bootstrapWkt),
@@ -99,7 +99,7 @@ function printableToEl(printables, el, createTypeImport, runtimeImports) {
99
99
  el.push(p);
100
100
  break;
101
101
  case "number":
102
- el.push(literalNumber(p));
102
+ el.push(...literalNumber(p, runtimeImports));
103
103
  break;
104
104
  case "boolean":
105
105
  el.push(p.toString());
@@ -237,15 +237,15 @@ function processImports(el, importerPath, rewriteImportPath, makeImportStatement
237
237
  }
238
238
  return symbolToIdentifier;
239
239
  }
240
- function literalNumber(value) {
240
+ function literalNumber(value, runtimeImports) {
241
241
  if (Number.isNaN(value)) {
242
- return "globalThis.Number.NaN";
242
+ return [runtimeImports.protoDouble, ".NaN"];
243
243
  }
244
244
  if (value === Number.POSITIVE_INFINITY) {
245
- return "globalThis.Number.POSITIVE_INFINITY";
245
+ return [runtimeImports.protoDouble, ".POSITIVE_INFINITY"];
246
246
  }
247
247
  if (value === Number.NEGATIVE_INFINITY) {
248
- return "globalThis.Number.NEGATIVE_INFINITY";
248
+ return [runtimeImports.protoDouble, ".NEGATIVE_INFINITY"];
249
249
  }
250
250
  return value.toString(10);
251
251
  }
@@ -29,6 +29,7 @@ export function createRuntimeImports(bootstrapWkt) {
29
29
  JsonWriteOptions: infoToSymbol("JsonWriteOptions", bootstrapWkt),
30
30
  JsonValue: infoToSymbol("JsonValue", bootstrapWkt),
31
31
  JsonObject: infoToSymbol("JsonObject", bootstrapWkt),
32
+ protoDouble: infoToSymbol("protoDouble", bootstrapWkt),
32
33
  protoInt64: infoToSymbol("protoInt64", bootstrapWkt),
33
34
  ScalarType: infoToSymbol("ScalarType", bootstrapWkt),
34
35
  MethodKind: infoToSymbol("MethodKind", bootstrapWkt),
@@ -13,6 +13,7 @@ export interface RuntimeImports {
13
13
  JsonWriteOptions: ImportSymbol;
14
14
  JsonValue: ImportSymbol;
15
15
  JsonObject: ImportSymbol;
16
+ protoDouble: ImportSymbol;
16
17
  protoInt64: ImportSymbol;
17
18
  ScalarType: ImportSymbol;
18
19
  MethodKind: ImportSymbol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoplugin",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "license": "(Apache-2.0 AND BSD-3-Clause)",
5
5
  "description": "Helps to create your own Protocol Buffers code generators.",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@bufbuild/protobuf": "1.2.1",
38
+ "@bufbuild/protobuf": "1.3.0",
39
39
  "@typescript/vfs": "^1.4.0",
40
40
  "typescript": "4.5.2"
41
41
  },