mezon-js 2.13.84 → 2.13.86
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/client.ts +25 -15
- package/dist/client.d.ts +2 -2
- package/dist/mezon-js/client.d.ts +2 -2
- package/dist/mezon-js.cjs.js +27061 -223
- package/dist/mezon-js.esm.mjs +27061 -223
- package/dist/mezon-js.esm.mjs.map +1 -1
- package/gateway.api.ts +1 -1
- package/package.json +2 -1
- package/socket.ts +19 -4
package/client.ts
CHANGED
|
@@ -316,10 +316,16 @@ import {
|
|
|
316
316
|
ApiListClanDiscover,
|
|
317
317
|
ApiLoginIDResponse,
|
|
318
318
|
ApiLoginRequest,
|
|
319
|
+
ApiMessageRef,
|
|
319
320
|
} from "./types";
|
|
320
321
|
import { GatewayMezonApi } from "./gateway.api";
|
|
321
322
|
import { safeJSONParse } from "./utils";
|
|
322
323
|
import { EmptySchema } from "./proto/gen/google/protobuf/empty_pb";
|
|
324
|
+
import {
|
|
325
|
+
decodeMentions,
|
|
326
|
+
decodeAttachments,
|
|
327
|
+
decodeRefs,
|
|
328
|
+
} from "mezon-js-protobuf";
|
|
323
329
|
|
|
324
330
|
const DEFAULT_HOST = "127.0.0.1";
|
|
325
331
|
const DEFAULT_PORT = "7350";
|
|
@@ -367,8 +373,8 @@ export enum WebrtcSignalingType {
|
|
|
367
373
|
export class Client {
|
|
368
374
|
/** The low level API client for Mezon server. */
|
|
369
375
|
private readonly gatewayClient: GatewayMezonApi;
|
|
370
|
-
private grpcTransport: Transport;
|
|
371
|
-
private mezonClient: RPCClient<typeof MezonService>;
|
|
376
|
+
private readonly grpcTransport: Transport;
|
|
377
|
+
private readonly mezonClient: RPCClient<typeof MezonService>;
|
|
372
378
|
|
|
373
379
|
/** thre refreshTokenPromise */
|
|
374
380
|
private refreshTokenPromise: Promise<Session> | null = null;
|
|
@@ -390,16 +396,16 @@ export class Client {
|
|
|
390
396
|
const scheme = useSSL ? "https://" : "http://";
|
|
391
397
|
const basePath = `${scheme}${host}:${port}`;
|
|
392
398
|
|
|
393
|
-
this.grpcTransport = createGrpcWebTransport({
|
|
394
|
-
baseUrl: basePath,
|
|
395
|
-
useBinaryFormat: true,
|
|
396
|
-
});
|
|
397
|
-
|
|
398
399
|
this.gatewayClient = new GatewayMezonApi(
|
|
399
400
|
DEFAULT_SERVER_KEY,
|
|
400
401
|
DEFAULT_TIMEOUT_MS,
|
|
401
402
|
basePath
|
|
402
403
|
);
|
|
404
|
+
|
|
405
|
+
this.grpcTransport = createGrpcWebTransport({
|
|
406
|
+
baseUrl: basePath,
|
|
407
|
+
useBinaryFormat: true,
|
|
408
|
+
});
|
|
403
409
|
this.mezonClient = createClient(MezonService, this.grpcTransport);
|
|
404
410
|
}
|
|
405
411
|
|
|
@@ -425,10 +431,7 @@ export class Client {
|
|
|
425
431
|
|
|
426
432
|
const scheme = useSSL ? "https://" : "http://";
|
|
427
433
|
const basePath = `${scheme}${host}:${port}`;
|
|
428
|
-
this.
|
|
429
|
-
baseUrl: basePath,
|
|
430
|
-
});
|
|
431
|
-
this.mezonClient = createClient(MezonService, this.grpcTransport);
|
|
434
|
+
return this.gatewayClient.setBasePath(basePath);
|
|
432
435
|
}
|
|
433
436
|
|
|
434
437
|
//#region Mezon Gateway APIs
|
|
@@ -1494,17 +1497,23 @@ export class Client {
|
|
|
1494
1497
|
console.log("error parse reactions", e);
|
|
1495
1498
|
}
|
|
1496
1499
|
try {
|
|
1497
|
-
mentions =
|
|
1500
|
+
mentions =
|
|
1501
|
+
decodeMentions(m.mentions)?.mentions ||
|
|
1502
|
+
safeJSONParse(m.mentions || "[]");
|
|
1498
1503
|
} catch (e) {
|
|
1499
1504
|
console.log("error parse mentions", e);
|
|
1500
1505
|
}
|
|
1501
1506
|
try {
|
|
1502
|
-
attachments =
|
|
1507
|
+
attachments =
|
|
1508
|
+
decodeAttachments(m.attachments)?.attachments ||
|
|
1509
|
+
safeJSONParse(m.attachments || "[]");
|
|
1503
1510
|
} catch (e) {
|
|
1504
1511
|
console.log("error parse attachments", e);
|
|
1505
1512
|
}
|
|
1506
1513
|
try {
|
|
1507
|
-
references =
|
|
1514
|
+
references =
|
|
1515
|
+
(decodeRefs(m.references)?.refs as unknown as ApiMessageRef[]) ||
|
|
1516
|
+
safeJSONParse(m.references || "[]");
|
|
1508
1517
|
} catch (e) {
|
|
1509
1518
|
console.log("error parse references", e);
|
|
1510
1519
|
}
|
|
@@ -1535,7 +1544,7 @@ export class Client {
|
|
|
1535
1544
|
hideEditted: m.hideEditted,
|
|
1536
1545
|
});
|
|
1537
1546
|
});
|
|
1538
|
-
|
|
1547
|
+
|
|
1539
1548
|
return response;
|
|
1540
1549
|
}
|
|
1541
1550
|
|
|
@@ -2307,6 +2316,7 @@ export class Client {
|
|
|
2307
2316
|
this.refreshTokenPromise = new Promise<Session>(async (resolve, reject) => {
|
|
2308
2317
|
try {
|
|
2309
2318
|
const sessionRefreshRequest = create(SessionRefreshRequestSchema, {
|
|
2319
|
+
//token: session.refreshToken,
|
|
2310
2320
|
vars: vars,
|
|
2311
2321
|
isRemember: session.isRemember,
|
|
2312
2322
|
});
|
package/dist/client.d.ts
CHANGED
|
@@ -59,8 +59,8 @@ export declare class Client {
|
|
|
59
59
|
readonly autoRefreshSession: boolean;
|
|
60
60
|
/** The low level API client for Mezon server. */
|
|
61
61
|
private readonly gatewayClient;
|
|
62
|
-
private grpcTransport;
|
|
63
|
-
private mezonClient;
|
|
62
|
+
private readonly grpcTransport;
|
|
63
|
+
private readonly mezonClient;
|
|
64
64
|
/** thre refreshTokenPromise */
|
|
65
65
|
private refreshTokenPromise;
|
|
66
66
|
host: string;
|
|
@@ -59,8 +59,8 @@ export declare class Client {
|
|
|
59
59
|
readonly autoRefreshSession: boolean;
|
|
60
60
|
/** The low level API client for Mezon server. */
|
|
61
61
|
private readonly gatewayClient;
|
|
62
|
-
private grpcTransport;
|
|
63
|
-
private mezonClient;
|
|
62
|
+
private readonly grpcTransport;
|
|
63
|
+
private readonly mezonClient;
|
|
64
64
|
/** thre refreshTokenPromise */
|
|
65
65
|
private refreshTokenPromise;
|
|
66
66
|
host: string;
|