ts-proto 2.0.2 → 2.0.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 CHANGED
@@ -662,6 +662,11 @@ interface Rpc {
662
662
  If you're working with gRPC, a simple implementation could look like this:
663
663
 
664
664
  ```ts
665
+ const conn = new grpc.Client(
666
+ "localhost:8765",
667
+ grpc.credentials.createInsecure()
668
+ );
669
+
665
670
  type RpcImpl = (service: string, method: string, data: Uint8Array) => Promise<Uint8Array>;
666
671
 
667
672
  const sendRequest: RpcImpl = (service, method, data) => {
@@ -293,11 +293,17 @@ async function getVersions(request) {
293
293
  const { major, minor, patch } = request.compilerVersion;
294
294
  protocVersion = `v${major}.${minor}.${patch}`;
295
295
  }
296
- const path = "../../package.json";
297
- const packageJson = await Promise.resolve(`${path}`).then(s => require(s));
296
+ const packageJson = await readPackageJson();
298
297
  const tsProtoVersion = `v${packageJson?.version ?? "unknown"}`;
299
- return {
300
- protocVersion,
301
- tsProtoVersion,
302
- };
298
+ return { protocVersion, tsProtoVersion };
299
+ }
300
+ /** Read from the distributed package.json file, or our local package.json when running ts-proto tests locally. */
301
+ async function readPackageJson() {
302
+ try {
303
+ // Use `as string` to disable hints that the path doesn't exist
304
+ return await Promise.resolve(`${"../../package.json"}`).then(s => require(s));
305
+ }
306
+ catch (e) {
307
+ return await Promise.resolve(`${"../package.json"}`).then(s => require(s));
308
+ }
303
309
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "",
5
5
  "main": "build/src/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",