livekit-client 1.6.3 → 1.6.5

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.
Files changed (50) hide show
  1. package/dist/livekit-client.esm.mjs +418 -70
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/api/SignalClient.d.ts +13 -2
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/connectionHelper/ConnectionCheck.d.ts +2 -2
  8. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_models.d.ts +20 -3
  10. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  11. package/dist/src/proto/livekit_rtc.d.ts +2565 -464
  12. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  13. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  14. package/dist/src/room/Room.d.ts +1 -1
  15. package/dist/src/room/Room.d.ts.map +1 -1
  16. package/dist/src/room/errors.d.ts +3 -0
  17. package/dist/src/room/errors.d.ts.map +1 -1
  18. package/dist/src/room/participant/LocalParticipant.d.ts +1 -3
  19. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  20. package/dist/src/room/participant/Participant.d.ts +1 -1
  21. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  22. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  23. package/dist/src/room/track/create.d.ts.map +1 -1
  24. package/dist/src/room/track/options.d.ts +2 -2
  25. package/dist/src/room/track/options.d.ts.map +1 -1
  26. package/dist/src/test/mocks.d.ts +1 -1
  27. package/dist/ts4.2/src/api/SignalClient.d.ts +13 -2
  28. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +2 -2
  29. package/dist/ts4.2/src/proto/livekit_models.d.ts +24 -3
  30. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +2775 -540
  31. package/dist/ts4.2/src/room/Room.d.ts +1 -1
  32. package/dist/ts4.2/src/room/errors.d.ts +3 -0
  33. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -3
  34. package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -1
  35. package/dist/ts4.2/src/room/track/options.d.ts +2 -2
  36. package/dist/ts4.2/src/test/mocks.d.ts +1 -1
  37. package/package.json +17 -17
  38. package/src/api/SignalClient.ts +46 -3
  39. package/src/connectionHelper/ConnectionCheck.ts +1 -1
  40. package/src/proto/google/protobuf/timestamp.ts +2 -2
  41. package/src/proto/livekit_models.ts +93 -9
  42. package/src/proto/livekit_rtc.ts +308 -6
  43. package/src/room/RTCEngine.ts +37 -16
  44. package/src/room/Room.ts +12 -11
  45. package/src/room/errors.ts +6 -0
  46. package/src/room/participant/LocalParticipant.ts +19 -20
  47. package/src/room/participant/Participant.ts +10 -2
  48. package/src/room/track/LocalAudioTrack.ts +5 -1
  49. package/src/room/track/create.ts +6 -1
  50. package/src/room/track/options.ts +2 -2
@@ -204,7 +204,7 @@ export type RoomEventCallbacks = {
204
204
  localTrackPublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
205
205
  localTrackUnpublished: (publication: LocalTrackPublication, participant: LocalParticipant) => void;
206
206
  participantMetadataChanged: (metadata: string | undefined, participant: RemoteParticipant | LocalParticipant) => void;
207
- participantPermissionsChanged: (prevPermissions: ParticipantPermission, participant: RemoteParticipant | LocalParticipant) => void;
207
+ participantPermissionsChanged: (prevPermissions: ParticipantPermission | undefined, participant: RemoteParticipant | LocalParticipant) => void;
208
208
  activeSpeakersChanged: (speakers: Array<Participant>) => void;
209
209
  roomMetadataChanged: (metadata: string) => void;
210
210
  dataReceived: (payload: Uint8Array, participant?: RemoteParticipant, kind?: DataPacket_Kind) => void;
@@ -12,6 +12,9 @@ export declare class ConnectionError extends LivekitError {
12
12
  reason?: ConnectionErrorReason;
13
13
  constructor(message?: string, reason?: ConnectionErrorReason, status?: number);
14
14
  }
15
+ export declare class DeviceUnsupportedError extends LivekitError {
16
+ constructor(message?: string);
17
+ }
15
18
  export declare class TrackInvalidError extends LivekitError {
16
19
  constructor(message?: string);
17
20
  }
@@ -1,6 +1,6 @@
1
1
  import 'webrtc-adapter';
2
2
  import type { InternalRoomOptions } from '../../options';
3
- import { DataPacket_Kind, ParticipantInfo, ParticipantPermission } from '../../proto/livekit_models';
3
+ import { DataPacket_Kind, ParticipantInfo } from '../../proto/livekit_models';
4
4
  import { DataChannelInfo, TrackPublishedResponse } from '../../proto/livekit_rtc';
5
5
  import type RTCEngine from '../RTCEngine';
6
6
  import LocalTrack from '../track/LocalTrack';
@@ -52,8 +52,6 @@ export default class LocalParticipant extends Participant {
52
52
  * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
53
53
  */
54
54
  setScreenShareEnabled(enabled: boolean, options?: ScreenShareCaptureOptions, publishOptions?: TrackPublishOptions): Promise<LocalTrackPublication | undefined>;
55
- /** @internal */
56
- setPermissions(permissions: ParticipantPermission): boolean;
57
55
  /**
58
56
  * Enable or disable publishing for a track by source. This serves as a simple
59
57
  * way to manage the common tracks (camera, mic, or screen share).
@@ -85,7 +85,7 @@ export type ParticipantEventCallbacks = {
85
85
  trackStreamStateChanged: (publication: RemoteTrackPublication, streamState: Track.StreamState) => void;
86
86
  trackSubscriptionPermissionChanged: (publication: RemoteTrackPublication, status: TrackPublication.PermissionStatus) => void;
87
87
  mediaDevicesError: (error: Error) => void;
88
- participantPermissionsChanged: (prevPermissions: ParticipantPermission) => void;
88
+ participantPermissionsChanged: (prevPermissions?: ParticipantPermission) => void;
89
89
  trackSubscriptionStatusChanged: (publication: RemoteTrackPublication, status: TrackPublication.SubscriptionStatus) => void;
90
90
  };
91
91
  export {};
@@ -187,8 +187,8 @@ declare const backupCodecs: readonly [
187
187
  "vp8",
188
188
  "h264"
189
189
  ];
190
- export type VideoCodec = typeof codecs[number];
191
- export type BackupVideoCodec = typeof backupCodecs[number];
190
+ export type VideoCodec = (typeof codecs)[number];
191
+ export type BackupVideoCodec = (typeof backupCodecs)[number];
192
192
  export declare function isBackupCodec(codec: string): codec is BackupVideoCodec;
193
193
  /**
194
194
  * scalability modes for svc, only supprot l3t3 now.
@@ -4,7 +4,7 @@ declare const mocks: {
4
4
  SignalClient: jest.MockedClass<typeof SignalClient>;
5
5
  RTCEngine: jest.MockedClass<typeof RTCEngine>;
6
6
  MockLocalVideoTrack: {
7
- stop: jest.Mock<any, any>;
7
+ stop: jest.Mock<any, any, any>;
8
8
  };
9
9
  };
10
10
  export default mocks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "JavaScript/TypeScript client SDK for LiveKit",
5
5
  "main": "./dist/livekit-client.umd.js",
6
6
  "unpkg": "./dist/livekit-client.umd.js",
@@ -51,40 +51,40 @@
51
51
  "webrtc-adapter": "^8.1.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@babel/core": "7.20.7",
54
+ "@babel/core": "7.20.12",
55
55
  "@babel/preset-env": "7.20.2",
56
56
  "@changesets/changelog-github": "0.4.8",
57
57
  "@changesets/cli": "2.26.0",
58
58
  "@rollup/plugin-babel": "6.0.3",
59
- "@rollup/plugin-commonjs": "24.0.0",
59
+ "@rollup/plugin-commonjs": "24.0.1",
60
60
  "@rollup/plugin-json": "6.0.0",
61
61
  "@rollup/plugin-node-resolve": "15.0.1",
62
- "@types/jest": "29.2.5",
62
+ "@types/jest": "29.4.0",
63
63
  "@types/sdp-transform": "2.4.5",
64
64
  "@types/ua-parser-js": "0.7.36",
65
65
  "@types/ws": "8.5.4",
66
- "@typescript-eslint/eslint-plugin": "5.47.1",
67
- "@typescript-eslint/parser": "5.47.1",
66
+ "@typescript-eslint/eslint-plugin": "5.50.0",
67
+ "@typescript-eslint/parser": "5.50.0",
68
68
  "downlevel-dts": "^0.11.0",
69
- "eslint": "8.31.0",
69
+ "eslint": "8.33.0",
70
70
  "eslint-config-airbnb-typescript": "17.0.0",
71
- "eslint-config-prettier": "8.5.0",
72
- "eslint-plugin-import": "2.26.0",
71
+ "eslint-config-prettier": "8.6.0",
72
+ "eslint-plugin-import": "2.27.5",
73
73
  "gh-pages": "4.0.0",
74
- "jest": "29.3.1",
75
- "prettier": "2.8.1",
76
- "rollup": "3.9.1",
74
+ "jest": "29.4.1",
75
+ "prettier": "2.8.3",
76
+ "rollup": "3.12.1",
77
77
  "rollup-plugin-delete": "^2.0.0",
78
78
  "rollup-plugin-filesize": "9.1.2",
79
79
  "rollup-plugin-re": "1.0.7",
80
80
  "rollup-plugin-terser": "7.0.2",
81
81
  "rollup-plugin-typescript2": "0.34.1",
82
- "ts-jest": "29.0.3",
83
- "ts-proto": "1.137.0",
84
- "typedoc": "0.23.23",
82
+ "ts-jest": "29.0.5",
83
+ "ts-proto": "1.139.0",
84
+ "typedoc": "0.23.24",
85
85
  "typedoc-plugin-no-inherit": "1.4.0",
86
- "typescript": "4.9.4",
87
- "vite": "4.0.3"
86
+ "typescript": "4.9.5",
87
+ "vite": "4.0.4"
88
88
  },
89
89
  "browserslist": [
90
90
  "safari >= 11",
@@ -5,6 +5,7 @@ import {
5
5
  ClientInfo,
6
6
  DisconnectReason,
7
7
  ParticipantInfo,
8
+ ReconnectReason,
8
9
  Room,
9
10
  SpeakerInfo,
10
11
  VideoLayer,
@@ -40,6 +41,9 @@ interface ConnectOpts {
40
41
  /** internal */
41
42
  reconnect?: boolean;
42
43
 
44
+ /** internal */
45
+ reconnectReason?: number;
46
+
43
47
  /** internal */
44
48
  sid?: string;
45
49
 
@@ -89,6 +93,9 @@ export class SignalClient {
89
93
 
90
94
  useJSON: boolean;
91
95
 
96
+ /** signal rtt in milliseconds */
97
+ rtt: number = 0;
98
+
92
99
  /** simulate signaling latency by delaying messages */
93
100
  signalLatency?: number;
94
101
 
@@ -166,7 +173,12 @@ export class SignalClient {
166
173
  return res as JoinResponse;
167
174
  }
168
175
 
169
- async reconnect(url: string, token: string, sid?: string): Promise<ReconnectResponse | void> {
176
+ async reconnect(
177
+ url: string,
178
+ token: string,
179
+ sid?: string,
180
+ reason?: ReconnectReason,
181
+ ): Promise<ReconnectResponse | void> {
170
182
  if (!this.options) {
171
183
  log.warn('attempted to reconnect without signal options being set, ignoring');
172
184
  return;
@@ -175,7 +187,12 @@ export class SignalClient {
175
187
  // clear ping interval and restart it once reconnected
176
188
  this.clearPingInterval();
177
189
 
178
- const res = await this.connect(url, token, { ...this.options, reconnect: true, sid });
190
+ const res = await this.connect(url, token, {
191
+ ...this.options,
192
+ reconnect: true,
193
+ sid,
194
+ reconnectReason: reason,
195
+ });
179
196
  return res;
180
197
  }
181
198
 
@@ -440,10 +457,18 @@ export class SignalClient {
440
457
  }
441
458
 
442
459
  sendPing() {
460
+ /** send both of ping and pingReq for compatibility to old and new server */
443
461
  this.sendRequest({
444
462
  $case: 'ping',
445
463
  ping: Date.now(),
446
464
  });
465
+ this.sendRequest({
466
+ $case: 'pingReq',
467
+ pingReq: {
468
+ timestamp: Date.now(),
469
+ rtt: this.rtt,
470
+ },
471
+ });
447
472
  }
448
473
 
449
474
  async sendLeave() {
@@ -493,7 +518,11 @@ export class SignalClient {
493
518
  }
494
519
 
495
520
  private handleSignalResponse(res: SignalResponse) {
496
- const msg = res.message!;
521
+ const msg = res.message;
522
+ if (msg == undefined) {
523
+ log.debug('received unsupported message');
524
+ return;
525
+ }
497
526
  if (msg.$case === 'answer') {
498
527
  const sd = fromProtoSessionDescription(msg.answer);
499
528
  if (this.onAnswer) {
@@ -559,6 +588,9 @@ export class SignalClient {
559
588
  }
560
589
  } else if (msg.$case === 'pong') {
561
590
  this.resetPingTimeout();
591
+ } else if (msg.$case === 'pongResp') {
592
+ this.rtt = Date.now() - msg.pongResp.lastPingTimestamp;
593
+ this.resetPingTimeout();
562
594
  } else {
563
595
  log.debug('unsupported message', msg);
564
596
  }
@@ -578,6 +610,10 @@ export class SignalClient {
578
610
  log.error('websocket error', ev);
579
611
  }
580
612
 
613
+ /**
614
+ * Resets the ping timeout and starts a new timeout.
615
+ * Call this after receiving a pong message
616
+ */
581
617
  private resetPingTimeout() {
582
618
  this.clearPingTimeout();
583
619
  if (!this.pingTimeoutDuration) {
@@ -596,6 +632,9 @@ export class SignalClient {
596
632
  }, this.pingTimeoutDuration * 1000);
597
633
  }
598
634
 
635
+ /**
636
+ * Clears ping timeout (does not start a new timeout)
637
+ */
599
638
  private clearPingTimeout() {
600
639
  if (this.pingTimeout) {
601
640
  CriticalTimers.clearTimeout(this.pingTimeout);
@@ -694,6 +733,10 @@ function createConnectionParams(token: string, info: ClientInfo, opts: ConnectOp
694
733
  params.set('adaptive_stream', '1');
695
734
  }
696
735
 
736
+ if (opts.reconnectReason) {
737
+ params.set('reconnect_reason', opts.reconnectReason.toString());
738
+ }
739
+
697
740
  // @ts-ignore
698
741
  if (navigator.connection?.type) {
699
742
  // @ts-ignore
@@ -9,7 +9,7 @@ import { TURNCheck } from './checks/turn';
9
9
  import { WebRTCCheck } from './checks/webrtc';
10
10
  import { WebSocketCheck } from './checks/websocket';
11
11
 
12
- export type { CheckInfo };
12
+ export type { CheckInfo, CheckStatus };
13
13
 
14
14
  export class ConnectionCheck extends (EventEmitter as new () => TypedEmitter<ConnectionCheckCallbacks>) {
15
15
  token: string;
@@ -172,7 +172,7 @@ export const Timestamp = {
172
172
  declare var self: any | undefined;
173
173
  declare var window: any | undefined;
174
174
  declare var global: any | undefined;
175
- var globalThis: any = (() => {
175
+ var tsProtoGlobalThis: any = (() => {
176
176
  if (typeof globalThis !== "undefined") {
177
177
  return globalThis;
178
178
  }
@@ -202,7 +202,7 @@ export type Exact<P, I extends P> = P extends Builtin ? P
202
202
 
203
203
  function longToNumber(long: Long): number {
204
204
  if (long.gt(Number.MAX_SAFE_INTEGER)) {
205
- throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
205
+ throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
206
206
  }
207
207
  return long.toNumber();
208
208
  }
@@ -287,6 +287,57 @@ export function disconnectReasonToJSON(object: DisconnectReason): string {
287
287
  }
288
288
  }
289
289
 
290
+ export enum ReconnectReason {
291
+ REASON_UNKOWN = 0,
292
+ REASON_SIGNAL_DISCONNECTED = 1,
293
+ REASON_PUBLISHER_FAILED = 2,
294
+ REASON_SUBSCRIBER_FAILED = 3,
295
+ REASON_SWITCH_CANDIDATE = 4,
296
+ UNRECOGNIZED = -1,
297
+ }
298
+
299
+ export function reconnectReasonFromJSON(object: any): ReconnectReason {
300
+ switch (object) {
301
+ case 0:
302
+ case "REASON_UNKOWN":
303
+ return ReconnectReason.REASON_UNKOWN;
304
+ case 1:
305
+ case "REASON_SIGNAL_DISCONNECTED":
306
+ return ReconnectReason.REASON_SIGNAL_DISCONNECTED;
307
+ case 2:
308
+ case "REASON_PUBLISHER_FAILED":
309
+ return ReconnectReason.REASON_PUBLISHER_FAILED;
310
+ case 3:
311
+ case "REASON_SUBSCRIBER_FAILED":
312
+ return ReconnectReason.REASON_SUBSCRIBER_FAILED;
313
+ case 4:
314
+ case "REASON_SWITCH_CANDIDATE":
315
+ return ReconnectReason.REASON_SWITCH_CANDIDATE;
316
+ case -1:
317
+ case "UNRECOGNIZED":
318
+ default:
319
+ return ReconnectReason.UNRECOGNIZED;
320
+ }
321
+ }
322
+
323
+ export function reconnectReasonToJSON(object: ReconnectReason): string {
324
+ switch (object) {
325
+ case ReconnectReason.REASON_UNKOWN:
326
+ return "REASON_UNKOWN";
327
+ case ReconnectReason.REASON_SIGNAL_DISCONNECTED:
328
+ return "REASON_SIGNAL_DISCONNECTED";
329
+ case ReconnectReason.REASON_PUBLISHER_FAILED:
330
+ return "REASON_PUBLISHER_FAILED";
331
+ case ReconnectReason.REASON_SUBSCRIBER_FAILED:
332
+ return "REASON_SUBSCRIBER_FAILED";
333
+ case ReconnectReason.REASON_SWITCH_CANDIDATE:
334
+ return "REASON_SWITCH_CANDIDATE";
335
+ case ReconnectReason.UNRECOGNIZED:
336
+ default:
337
+ return "UNRECOGNIZED";
338
+ }
339
+ }
340
+
290
341
  export interface Room {
291
342
  sid: string;
292
343
  name: string;
@@ -312,6 +363,8 @@ export interface ParticipantPermission {
312
363
  canPublish: boolean;
313
364
  /** allow participant to publish data */
314
365
  canPublishData: boolean;
366
+ /** sources that are allowed to be published */
367
+ canPublishSources: TrackSource[];
315
368
  /** indicates that it's hidden to others */
316
369
  hidden: boolean;
317
370
  /** indicates it's a recorder instance */
@@ -940,7 +993,14 @@ export const Codec = {
940
993
  };
941
994
 
942
995
  function createBaseParticipantPermission(): ParticipantPermission {
943
- return { canSubscribe: false, canPublish: false, canPublishData: false, hidden: false, recorder: false };
996
+ return {
997
+ canSubscribe: false,
998
+ canPublish: false,
999
+ canPublishData: false,
1000
+ canPublishSources: [],
1001
+ hidden: false,
1002
+ recorder: false,
1003
+ };
944
1004
  }
945
1005
 
946
1006
  export const ParticipantPermission = {
@@ -954,6 +1014,11 @@ export const ParticipantPermission = {
954
1014
  if (message.canPublishData === true) {
955
1015
  writer.uint32(24).bool(message.canPublishData);
956
1016
  }
1017
+ writer.uint32(74).fork();
1018
+ for (const v of message.canPublishSources) {
1019
+ writer.int32(v);
1020
+ }
1021
+ writer.ldelim();
957
1022
  if (message.hidden === true) {
958
1023
  writer.uint32(56).bool(message.hidden);
959
1024
  }
@@ -979,6 +1044,16 @@ export const ParticipantPermission = {
979
1044
  case 3:
980
1045
  message.canPublishData = reader.bool();
981
1046
  break;
1047
+ case 9:
1048
+ if ((tag & 7) === 2) {
1049
+ const end2 = reader.uint32() + reader.pos;
1050
+ while (reader.pos < end2) {
1051
+ message.canPublishSources.push(reader.int32() as any);
1052
+ }
1053
+ } else {
1054
+ message.canPublishSources.push(reader.int32() as any);
1055
+ }
1056
+ break;
982
1057
  case 7:
983
1058
  message.hidden = reader.bool();
984
1059
  break;
@@ -998,6 +1073,9 @@ export const ParticipantPermission = {
998
1073
  canSubscribe: isSet(object.canSubscribe) ? Boolean(object.canSubscribe) : false,
999
1074
  canPublish: isSet(object.canPublish) ? Boolean(object.canPublish) : false,
1000
1075
  canPublishData: isSet(object.canPublishData) ? Boolean(object.canPublishData) : false,
1076
+ canPublishSources: Array.isArray(object?.canPublishSources)
1077
+ ? object.canPublishSources.map((e: any) => trackSourceFromJSON(e))
1078
+ : [],
1001
1079
  hidden: isSet(object.hidden) ? Boolean(object.hidden) : false,
1002
1080
  recorder: isSet(object.recorder) ? Boolean(object.recorder) : false,
1003
1081
  };
@@ -1008,6 +1086,11 @@ export const ParticipantPermission = {
1008
1086
  message.canSubscribe !== undefined && (obj.canSubscribe = message.canSubscribe);
1009
1087
  message.canPublish !== undefined && (obj.canPublish = message.canPublish);
1010
1088
  message.canPublishData !== undefined && (obj.canPublishData = message.canPublishData);
1089
+ if (message.canPublishSources) {
1090
+ obj.canPublishSources = message.canPublishSources.map((e) => trackSourceToJSON(e));
1091
+ } else {
1092
+ obj.canPublishSources = [];
1093
+ }
1011
1094
  message.hidden !== undefined && (obj.hidden = message.hidden);
1012
1095
  message.recorder !== undefined && (obj.recorder = message.recorder);
1013
1096
  return obj;
@@ -1018,6 +1101,7 @@ export const ParticipantPermission = {
1018
1101
  message.canSubscribe = object.canSubscribe ?? false;
1019
1102
  message.canPublish = object.canPublish ?? false;
1020
1103
  message.canPublishData = object.canPublishData ?? false;
1104
+ message.canPublishSources = object.canPublishSources?.map((e) => e) || [];
1021
1105
  message.hidden = object.hidden ?? false;
1022
1106
  message.recorder = object.recorder ?? false;
1023
1107
  return message;
@@ -2940,7 +3024,7 @@ export const TimedVersion = {
2940
3024
  declare var self: any | undefined;
2941
3025
  declare var window: any | undefined;
2942
3026
  declare var global: any | undefined;
2943
- var globalThis: any = (() => {
3027
+ var tsProtoGlobalThis: any = (() => {
2944
3028
  if (typeof globalThis !== "undefined") {
2945
3029
  return globalThis;
2946
3030
  }
@@ -2957,10 +3041,10 @@ var globalThis: any = (() => {
2957
3041
  })();
2958
3042
 
2959
3043
  function bytesFromBase64(b64: string): Uint8Array {
2960
- if (globalThis.Buffer) {
2961
- return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
3044
+ if (tsProtoGlobalThis.Buffer) {
3045
+ return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, "base64"));
2962
3046
  } else {
2963
- const bin = globalThis.atob(b64);
3047
+ const bin = tsProtoGlobalThis.atob(b64);
2964
3048
  const arr = new Uint8Array(bin.length);
2965
3049
  for (let i = 0; i < bin.length; ++i) {
2966
3050
  arr[i] = bin.charCodeAt(i);
@@ -2970,14 +3054,14 @@ function bytesFromBase64(b64: string): Uint8Array {
2970
3054
  }
2971
3055
 
2972
3056
  function base64FromBytes(arr: Uint8Array): string {
2973
- if (globalThis.Buffer) {
2974
- return globalThis.Buffer.from(arr).toString("base64");
3057
+ if (tsProtoGlobalThis.Buffer) {
3058
+ return tsProtoGlobalThis.Buffer.from(arr).toString("base64");
2975
3059
  } else {
2976
3060
  const bin: string[] = [];
2977
3061
  arr.forEach((byte) => {
2978
3062
  bin.push(String.fromCharCode(byte));
2979
3063
  });
2980
- return globalThis.btoa(bin.join(""));
3064
+ return tsProtoGlobalThis.btoa(bin.join(""));
2981
3065
  }
2982
3066
  }
2983
3067
 
@@ -3017,7 +3101,7 @@ function fromJsonTimestamp(o: any): Date {
3017
3101
 
3018
3102
  function longToNumber(long: Long): number {
3019
3103
  if (long.gt(Number.MAX_SAFE_INTEGER)) {
3020
- throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
3104
+ throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
3021
3105
  }
3022
3106
  return long.toNumber();
3023
3107
  }