Skip to content

Commit

Permalink
Merge pull request #1 from jinpill/master
Browse files Browse the repository at this point in the history
fix: resolve the error caused by named import
  • Loading branch information
rixcian authored Sep 2, 2024
2 parents 379669e + d2dab83 commit 76473b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/core/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Long from 'long';
import path from 'path';
import tls from 'tls';
import net from 'net';
import { load, Root } from 'protobufjs';
import protobuf from 'protobufjs';

import { EVENTS } from './events.d.js';
import { checkIn, type CheckInOptions } from './gcm/index.js';
Expand All @@ -15,7 +15,7 @@ const HOST = 'mtalk.google.com';
const PORT = 5228;
const MAX_RETRY_TIMEOUT = 15;

let proto: Root | null = null;
let proto: protobuf.Root | null = null;

export interface Credentials {
gcm: {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class Client extends EventEmitter {
if (proto) {
return;
}
proto = await load(path.resolve(__dirname, 'utils', 'mcs.proto'));
proto = await protobuf.load(path.resolve(__dirname, 'utils', 'mcs.proto'));
}

constructor(credentials: ClientCredentials, persistentIds: string[]) {
Expand Down
8 changes: 4 additions & 4 deletions src/core/utils/parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EventEmitter from 'events';
import path from 'path';
import { load, BufferReader, Root } from 'protobufjs';
import protobuf from 'protobufjs';
import {
ProcessingState,
kVersionPacketLen,
Expand All @@ -13,7 +13,7 @@ import {
const DEBUG_ENABLED = false;
const DEBUG = DEBUG_ENABLED ? console.log : (log: string): void => {};

let proto: Root | null = null;
let proto: protobuf.Root | null = null;

// Parser parses wire data from gcm.
// This takes the role of WaitForData in the chromium connection handler.
Expand All @@ -39,7 +39,7 @@ export default class Parser extends EventEmitter {
if (proto) {
return;
}
proto = await load(path.resolve(__dirname, 'mcs.proto'));
proto = await protobuf.load(path.resolve(__dirname, 'mcs.proto'));
}

constructor(socket: any) {
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class Parser extends EventEmitter {

private _onGotMessageSize(): void {
let incompleteSizePacket = false;
const reader = new BufferReader(this._data);
const reader = new protobuf.BufferReader(this._data);

try {
this._messageSize = reader.int32();
Expand Down

0 comments on commit 76473b1

Please sign in to comment.