livekit-client 0.18.4-RC7 → 0.18.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 (127) hide show
  1. package/README.md +2 -5
  2. package/dist/api/RequestQueue.d.ts +13 -12
  3. package/dist/api/RequestQueue.d.ts.map +1 -0
  4. package/dist/api/SignalClient.d.ts +67 -66
  5. package/dist/api/SignalClient.d.ts.map +1 -0
  6. package/dist/connect.d.ts +24 -23
  7. package/dist/connect.d.ts.map +1 -0
  8. package/dist/index.d.ts +27 -26
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/livekit-client.esm.mjs +638 -517
  11. package/dist/livekit-client.esm.mjs.map +1 -1
  12. package/dist/livekit-client.umd.js +1 -1
  13. package/dist/livekit-client.umd.js.map +1 -1
  14. package/dist/logger.d.ts +26 -25
  15. package/dist/logger.d.ts.map +1 -0
  16. package/dist/options.d.ts +128 -127
  17. package/dist/options.d.ts.map +1 -0
  18. package/dist/proto/google/protobuf/timestamp.d.ts +133 -132
  19. package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -0
  20. package/dist/proto/livekit_models.d.ts +876 -875
  21. package/dist/proto/livekit_models.d.ts.map +1 -0
  22. package/dist/proto/livekit_rtc.d.ts +3904 -3903
  23. package/dist/proto/livekit_rtc.d.ts.map +1 -0
  24. package/dist/room/DeviceManager.d.ts +8 -7
  25. package/dist/room/DeviceManager.d.ts.map +1 -0
  26. package/dist/room/PCTransport.d.ts +16 -15
  27. package/dist/room/PCTransport.d.ts.map +1 -0
  28. package/dist/room/RTCEngine.d.ts +67 -66
  29. package/dist/room/RTCEngine.d.ts.map +1 -0
  30. package/dist/room/Room.d.ts +166 -165
  31. package/dist/room/Room.d.ts.map +1 -0
  32. package/dist/room/errors.d.ts +29 -28
  33. package/dist/room/errors.d.ts.map +1 -0
  34. package/dist/room/events.d.ts +391 -390
  35. package/dist/room/events.d.ts.map +1 -0
  36. package/dist/room/participant/LocalParticipant.d.ts +126 -125
  37. package/dist/room/participant/LocalParticipant.d.ts.map +1 -0
  38. package/dist/room/participant/Participant.d.ts +94 -93
  39. package/dist/room/participant/Participant.d.ts.map +1 -0
  40. package/dist/room/participant/ParticipantTrackPermission.d.ts +26 -25
  41. package/dist/room/participant/ParticipantTrackPermission.d.ts.map +1 -0
  42. package/dist/room/participant/RemoteParticipant.d.ts +40 -39
  43. package/dist/room/participant/RemoteParticipant.d.ts.map +1 -0
  44. package/dist/room/participant/publishUtils.d.ts +18 -17
  45. package/dist/room/participant/publishUtils.d.ts.map +1 -0
  46. package/dist/room/stats.d.ts +66 -65
  47. package/dist/room/stats.d.ts.map +1 -0
  48. package/dist/room/track/LocalAudioTrack.d.ts +20 -19
  49. package/dist/room/track/LocalAudioTrack.d.ts.map +1 -0
  50. package/dist/room/track/LocalTrack.d.ts +28 -27
  51. package/dist/room/track/LocalTrack.d.ts.map +1 -0
  52. package/dist/room/track/LocalTrackPublication.d.ts +38 -37
  53. package/dist/room/track/LocalTrackPublication.d.ts.map +1 -0
  54. package/dist/room/track/LocalVideoTrack.d.ts +31 -30
  55. package/dist/room/track/LocalVideoTrack.d.ts.map +1 -0
  56. package/dist/room/track/RemoteAudioTrack.d.ts +20 -19
  57. package/dist/room/track/RemoteAudioTrack.d.ts.map +1 -0
  58. package/dist/room/track/RemoteTrack.d.ts +16 -15
  59. package/dist/room/track/RemoteTrack.d.ts.map +1 -0
  60. package/dist/room/track/RemoteTrackPublication.d.ts +51 -50
  61. package/dist/room/track/RemoteTrackPublication.d.ts.map +1 -0
  62. package/dist/room/track/RemoteVideoTrack.d.ts +29 -27
  63. package/dist/room/track/RemoteVideoTrack.d.ts.map +1 -0
  64. package/dist/room/track/Track.d.ts +105 -100
  65. package/dist/room/track/Track.d.ts.map +1 -0
  66. package/dist/room/track/TrackPublication.d.ts +50 -49
  67. package/dist/room/track/TrackPublication.d.ts.map +1 -0
  68. package/dist/room/track/create.d.ts +24 -23
  69. package/dist/room/track/create.d.ts.map +1 -0
  70. package/dist/room/track/defaults.d.ts +5 -4
  71. package/dist/room/track/defaults.d.ts.map +1 -0
  72. package/dist/room/track/options.d.ts +232 -222
  73. package/dist/room/track/options.d.ts.map +1 -0
  74. package/dist/room/track/types.d.ts +19 -18
  75. package/dist/room/track/types.d.ts.map +1 -0
  76. package/dist/room/track/utils.d.ts +14 -13
  77. package/dist/room/track/utils.d.ts.map +1 -0
  78. package/dist/room/utils.d.ts +17 -15
  79. package/dist/room/utils.d.ts.map +1 -0
  80. package/dist/test/mocks.d.ts +12 -11
  81. package/dist/test/mocks.d.ts.map +1 -0
  82. package/dist/version.d.ts +3 -2
  83. package/dist/version.d.ts.map +1 -0
  84. package/package.json +4 -5
  85. package/src/api/RequestQueue.ts +53 -0
  86. package/src/api/SignalClient.ts +497 -0
  87. package/src/connect.ts +98 -0
  88. package/src/index.ts +49 -0
  89. package/src/logger.ts +56 -0
  90. package/src/options.ts +156 -0
  91. package/src/proto/google/protobuf/timestamp.ts +216 -0
  92. package/src/proto/livekit_models.ts +2456 -0
  93. package/src/proto/livekit_rtc.ts +2859 -0
  94. package/src/room/DeviceManager.ts +80 -0
  95. package/src/room/PCTransport.ts +88 -0
  96. package/src/room/RTCEngine.ts +695 -0
  97. package/src/room/Room.ts +970 -0
  98. package/src/room/errors.ts +65 -0
  99. package/src/room/events.ts +438 -0
  100. package/src/room/participant/LocalParticipant.ts +779 -0
  101. package/src/room/participant/Participant.ts +287 -0
  102. package/src/room/participant/ParticipantTrackPermission.ts +42 -0
  103. package/src/room/participant/RemoteParticipant.ts +263 -0
  104. package/src/room/participant/publishUtils.test.ts +144 -0
  105. package/src/room/participant/publishUtils.ts +258 -0
  106. package/src/room/stats.ts +134 -0
  107. package/src/room/track/LocalAudioTrack.ts +134 -0
  108. package/src/room/track/LocalTrack.ts +229 -0
  109. package/src/room/track/LocalTrackPublication.ts +87 -0
  110. package/src/room/track/LocalVideoTrack.test.ts +72 -0
  111. package/src/room/track/LocalVideoTrack.ts +295 -0
  112. package/src/room/track/RemoteAudioTrack.ts +86 -0
  113. package/src/room/track/RemoteTrack.ts +62 -0
  114. package/src/room/track/RemoteTrackPublication.ts +207 -0
  115. package/src/room/track/RemoteVideoTrack.ts +249 -0
  116. package/src/room/track/Track.ts +365 -0
  117. package/src/room/track/TrackPublication.ts +120 -0
  118. package/src/room/track/create.ts +122 -0
  119. package/src/room/track/defaults.ts +26 -0
  120. package/src/room/track/options.ts +292 -0
  121. package/src/room/track/types.ts +20 -0
  122. package/src/room/track/utils.test.ts +110 -0
  123. package/src/room/track/utils.ts +113 -0
  124. package/src/room/utils.ts +115 -0
  125. package/src/test/mocks.ts +17 -0
  126. package/src/version.ts +2 -0
  127. package/CHANGELOG.md +0 -5
package/src/index.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { setLogLevel, setLogExtension, LogLevel } from './logger';
2
+ import { DataPacket_Kind, VideoQuality } from './proto/livekit_models';
3
+ import LocalParticipant from './room/participant/LocalParticipant';
4
+ import Participant, { ConnectionQuality } from './room/participant/Participant';
5
+ import { ParticipantTrackPermission } from './room/participant/ParticipantTrackPermission';
6
+ import RemoteParticipant from './room/participant/RemoteParticipant';
7
+ import Room, { RoomState } from './room/Room';
8
+ import LocalAudioTrack from './room/track/LocalAudioTrack';
9
+ import LocalTrack from './room/track/LocalTrack';
10
+ import LocalTrackPublication from './room/track/LocalTrackPublication';
11
+ import LocalVideoTrack from './room/track/LocalVideoTrack';
12
+ import RemoteAudioTrack from './room/track/RemoteAudioTrack';
13
+ import RemoteTrack from './room/track/RemoteTrack';
14
+ import RemoteTrackPublication from './room/track/RemoteTrackPublication';
15
+ import RemoteVideoTrack from './room/track/RemoteVideoTrack';
16
+ import { TrackPublication } from './room/track/TrackPublication';
17
+
18
+ export * from './connect';
19
+ export * from './options';
20
+ export * from './room/errors';
21
+ export * from './room/events';
22
+ export * from './room/track/create';
23
+ export * from './room/track/options';
24
+ export * from './room/track/Track';
25
+ export * from './room/track/types';
26
+ export * from './version';
27
+ export {
28
+ setLogLevel,
29
+ setLogExtension,
30
+ LogLevel,
31
+ Room,
32
+ RoomState,
33
+ DataPacket_Kind,
34
+ Participant,
35
+ RemoteParticipant,
36
+ LocalParticipant,
37
+ LocalAudioTrack,
38
+ LocalVideoTrack,
39
+ LocalTrack,
40
+ LocalTrackPublication,
41
+ RemoteTrack,
42
+ RemoteAudioTrack,
43
+ RemoteVideoTrack,
44
+ RemoteTrackPublication,
45
+ ParticipantTrackPermission,
46
+ TrackPublication,
47
+ VideoQuality,
48
+ ConnectionQuality,
49
+ };
package/src/logger.ts ADDED
@@ -0,0 +1,56 @@
1
+ import * as log from 'loglevel';
2
+
3
+ export enum LogLevel {
4
+ trace = 0,
5
+ debug = 1,
6
+ info = 2,
7
+ warn = 3,
8
+ error = 4,
9
+ silent = 5,
10
+ }
11
+
12
+ type LogLevelString = keyof typeof LogLevel;
13
+
14
+ type StructuredLogger = {
15
+ trace: (msg: string, context?: object) => void;
16
+ debug: (msg: string, context?: object) => void;
17
+ info: (msg: string, context?: object) => void;
18
+ warn: (msg: string, context?: object) => void;
19
+ error: (msg: string, context?: object) => void;
20
+ };
21
+
22
+ const livekitLogger = log.getLogger('livekit');
23
+
24
+ livekitLogger.setLevel(LogLevel.info);
25
+
26
+ export default livekitLogger as StructuredLogger;
27
+
28
+ export function setLogLevel(level: LogLevel | LogLevelString) {
29
+ livekitLogger.setLevel(level);
30
+ }
31
+
32
+ export type LogExtension = (level: LogLevel, msg: string, context?: object) => void;
33
+
34
+ /**
35
+ * use this to hook into the logging function to allow sending internal livekit logs to third party services
36
+ * if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
37
+ */
38
+ export function setLogExtension(extension: LogExtension) {
39
+ const originalFactory = livekitLogger.methodFactory;
40
+
41
+ livekitLogger.methodFactory = (methodName, logLevel, loggerName) => {
42
+ const rawMethod = originalFactory(methodName, logLevel, loggerName);
43
+
44
+ const configLevel = livekitLogger.getLevel();
45
+ const needLog = logLevel >= configLevel && logLevel < LogLevel.silent;
46
+
47
+ return (msg, context?: [msg: string, context: object]) => {
48
+ if (context) rawMethod(msg, context);
49
+ else rawMethod(msg);
50
+ if (needLog) {
51
+ extension(logLevel, msg, context);
52
+ }
53
+ };
54
+ };
55
+ livekitLogger.setLevel(livekitLogger.getLevel()); // Be sure to call setLevel method in order to apply plugin
56
+ }
package/src/options.ts ADDED
@@ -0,0 +1,156 @@
1
+ import { LogLevel } from './logger';
2
+ import {
3
+ AudioCaptureOptions,
4
+ CreateLocalTracksOptions,
5
+ TrackPublishDefaults,
6
+ VideoCaptureOptions,
7
+ } from './room/track/options';
8
+ import { AdaptiveStreamSettings } from './room/track/types';
9
+
10
+ /**
11
+ * Options for when creating a new room
12
+ */
13
+ export interface RoomOptions {
14
+ /**
15
+ * AdaptiveStream lets LiveKit automatically manage quality of subscribed
16
+ * video tracks to optimize for bandwidth and CPU.
17
+ * When attached video elements are visible, it'll choose an appropriate
18
+ * resolution based on the size of largest video element it's attached to.
19
+ *
20
+ * When none of the video elements are visible, it'll temporarily pause
21
+ * the data flow until they are visible again.
22
+ */
23
+ adaptiveStream?: AdaptiveStreamSettings | boolean;
24
+
25
+ /**
26
+ * enable Dynacast, off by default. With Dynacast dynamically pauses
27
+ * video layers that are not being consumed by any subscribers, significantly
28
+ * reducing publishing CPU and bandwidth usage.
29
+ */
30
+ dynacast?: boolean;
31
+
32
+ /**
33
+ * default options to use when capturing user's audio
34
+ */
35
+ audioCaptureDefaults?: AudioCaptureOptions;
36
+
37
+ /**
38
+ * default options to use when capturing user's video
39
+ */
40
+ videoCaptureDefaults?: VideoCaptureOptions;
41
+
42
+ /**
43
+ * default options to use when publishing tracks
44
+ */
45
+ publishDefaults?: TrackPublishDefaults;
46
+
47
+ /**
48
+ * should local tracks be stopped when they are unpublished. defaults to true
49
+ * set this to false if you would prefer to clean up unpublished local tracks manually.
50
+ */
51
+ stopLocalTrackOnUnpublish?: boolean;
52
+
53
+ /**
54
+ * @internal
55
+ * experimental flag, introduce a delay before sending signaling messages
56
+ */
57
+ expSignalLatency?: number;
58
+ }
59
+
60
+ /**
61
+ * Options for Room.connect()
62
+ */
63
+ export interface RoomConnectOptions {
64
+ /** autosubscribe to room tracks after joining, defaults to true */
65
+ autoSubscribe?: boolean;
66
+
67
+ /**
68
+ * use to override any RTCConfiguration options.
69
+ */
70
+ rtcConfig?: RTCConfiguration;
71
+
72
+ /**
73
+ * publish only mode
74
+ */
75
+ publishOnly?: string;
76
+ }
77
+
78
+ /**
79
+ * @deprecated use new Room([[RoomOptions]]) and room.connect([[RoomConnectOptions]]) instead
80
+ *
81
+ * if video or audio tracks are created as part of [[connect]], it'll automatically
82
+ * publish those tracks to the room.
83
+ */
84
+ export interface ConnectOptions extends CreateLocalTracksOptions {
85
+ /** autosubscribe to room tracks upon connect, defaults to true */
86
+ autoSubscribe?: boolean;
87
+
88
+ /**
89
+ * publish only mode
90
+ */
91
+ publishOnly?: string;
92
+
93
+ /**
94
+ * see [[RoomOptions.adaptiveStream]]
95
+ */
96
+ adaptiveStream?: AdaptiveStreamSettings | boolean;
97
+
98
+ /**
99
+ * alias for adaptiveStream
100
+ * @deprecated
101
+ */
102
+ autoManageVideo?: boolean;
103
+
104
+ /**
105
+ * see [[RoomOptions.dynacast]]
106
+ */
107
+ dynacast?: boolean;
108
+
109
+ /** configures LiveKit internal log level */
110
+ logLevel?: LogLevel;
111
+
112
+ /**
113
+ * set ICE servers. When deployed correctly, LiveKit automatically uses the built-in TURN servers
114
+ */
115
+ iceServers?: RTCIceServer[];
116
+
117
+ /**
118
+ * use to override any RTCConfiguration options.
119
+ */
120
+ rtcConfig?: RTCConfiguration;
121
+
122
+ /**
123
+ * capture and publish audio track on connect, defaults to false
124
+ *
125
+ * If this option is used, you will not be notified if user denies capture permission.
126
+ */
127
+ audio?: boolean;
128
+
129
+ /**
130
+ * capture and publish video track on connect, defaults to false
131
+ *
132
+ * If this option is used, you will not be notified if user denies capture permission.
133
+ */
134
+ video?: boolean;
135
+
136
+ /**
137
+ * default options to use when capturing user's audio
138
+ */
139
+ audioCaptureDefaults?: AudioCaptureOptions;
140
+
141
+ /**
142
+ * default options to use when capturing user's video
143
+ */
144
+ videoCaptureDefaults?: VideoCaptureOptions;
145
+
146
+ /**
147
+ * default options to use when publishing tracks
148
+ */
149
+ publishDefaults?: TrackPublishDefaults;
150
+
151
+ /**
152
+ * should local tracks be stopped when they are unpublished. defaults to true
153
+ * set this to false if you would prefer to clean up unpublished local tracks manually.
154
+ */
155
+ stopLocalTrackOnUnpublish?: boolean;
156
+ }
@@ -0,0 +1,216 @@
1
+ /* eslint-disable */
2
+ import Long from 'long';
3
+ import * as _m0 from 'protobufjs/minimal';
4
+
5
+ export const protobufPackage = 'google.protobuf';
6
+
7
+ /**
8
+ * A Timestamp represents a point in time independent of any time zone or local
9
+ * calendar, encoded as a count of seconds and fractions of seconds at
10
+ * nanosecond resolution. The count is relative to an epoch at UTC midnight on
11
+ * January 1, 1970, in the proleptic Gregorian calendar which extends the
12
+ * Gregorian calendar backwards to year one.
13
+ *
14
+ * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
15
+ * second table is needed for interpretation, using a [24-hour linear
16
+ * smear](https://developers.google.com/time/smear).
17
+ *
18
+ * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
19
+ * restricting to that range, we ensure that we can convert to and from [RFC
20
+ * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
21
+ *
22
+ * # Examples
23
+ *
24
+ * Example 1: Compute Timestamp from POSIX `time()`.
25
+ *
26
+ * Timestamp timestamp;
27
+ * timestamp.set_seconds(time(NULL));
28
+ * timestamp.set_nanos(0);
29
+ *
30
+ * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
31
+ *
32
+ * struct timeval tv;
33
+ * gettimeofday(&tv, NULL);
34
+ *
35
+ * Timestamp timestamp;
36
+ * timestamp.set_seconds(tv.tv_sec);
37
+ * timestamp.set_nanos(tv.tv_usec * 1000);
38
+ *
39
+ * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
40
+ *
41
+ * FILETIME ft;
42
+ * GetSystemTimeAsFileTime(&ft);
43
+ * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
44
+ *
45
+ * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
46
+ * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
47
+ * Timestamp timestamp;
48
+ * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
49
+ * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
50
+ *
51
+ * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
52
+ *
53
+ * long millis = System.currentTimeMillis();
54
+ *
55
+ * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
56
+ * .setNanos((int) ((millis % 1000) * 1000000)).build();
57
+ *
58
+ *
59
+ * Example 5: Compute Timestamp from Java `Instant.now()`.
60
+ *
61
+ * Instant now = Instant.now();
62
+ *
63
+ * Timestamp timestamp =
64
+ * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
65
+ * .setNanos(now.getNano()).build();
66
+ *
67
+ *
68
+ * Example 6: Compute Timestamp from current time in Python.
69
+ *
70
+ * timestamp = Timestamp()
71
+ * timestamp.GetCurrentTime()
72
+ *
73
+ * # JSON Mapping
74
+ *
75
+ * In JSON format, the Timestamp type is encoded as a string in the
76
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
77
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
78
+ * where {year} is always expressed using four digits while {month}, {day},
79
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
80
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
81
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
82
+ * is required. A proto3 JSON serializer should always use UTC (as indicated by
83
+ * "Z") when printing the Timestamp type and a proto3 JSON parser should be
84
+ * able to accept both UTC and other timezones (as indicated by an offset).
85
+ *
86
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
87
+ * 01:30 UTC on January 15, 2017.
88
+ *
89
+ * In JavaScript, one can convert a Date object to this format using the
90
+ * standard
91
+ * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
92
+ * method. In Python, a standard `datetime.datetime` object can be converted
93
+ * to this format using
94
+ * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
95
+ * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
96
+ * the Joda Time's [`ISODateTimeFormat.dateTime()`](
97
+ * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
98
+ * ) to obtain a formatter capable of generating timestamps in this format.
99
+ */
100
+ export interface Timestamp {
101
+ /**
102
+ * Represents seconds of UTC time since Unix epoch
103
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
104
+ * 9999-12-31T23:59:59Z inclusive.
105
+ */
106
+ seconds: number;
107
+ /**
108
+ * Non-negative fractions of a second at nanosecond resolution. Negative
109
+ * second values with fractions must still have non-negative nanos values
110
+ * that count forward in time. Must be from 0 to 999,999,999
111
+ * inclusive.
112
+ */
113
+ nanos: number;
114
+ }
115
+
116
+ function createBaseTimestamp(): Timestamp {
117
+ return { seconds: 0, nanos: 0 };
118
+ }
119
+
120
+ export const Timestamp = {
121
+ encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
122
+ if (message.seconds !== 0) {
123
+ writer.uint32(8).int64(message.seconds);
124
+ }
125
+ if (message.nanos !== 0) {
126
+ writer.uint32(16).int32(message.nanos);
127
+ }
128
+ return writer;
129
+ },
130
+
131
+ decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp {
132
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
133
+ let end = length === undefined ? reader.len : reader.pos + length;
134
+ const message = createBaseTimestamp();
135
+ while (reader.pos < end) {
136
+ const tag = reader.uint32();
137
+ switch (tag >>> 3) {
138
+ case 1:
139
+ message.seconds = longToNumber(reader.int64() as Long);
140
+ break;
141
+ case 2:
142
+ message.nanos = reader.int32();
143
+ break;
144
+ default:
145
+ reader.skipType(tag & 7);
146
+ break;
147
+ }
148
+ }
149
+ return message;
150
+ },
151
+
152
+ fromJSON(object: any): Timestamp {
153
+ return {
154
+ seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
155
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
156
+ };
157
+ },
158
+
159
+ toJSON(message: Timestamp): unknown {
160
+ const obj: any = {};
161
+ message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
162
+ message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
163
+ return obj;
164
+ },
165
+
166
+ fromPartial<I extends Exact<DeepPartial<Timestamp>, I>>(object: I): Timestamp {
167
+ const message = createBaseTimestamp();
168
+ message.seconds = object.seconds ?? 0;
169
+ message.nanos = object.nanos ?? 0;
170
+ return message;
171
+ },
172
+ };
173
+
174
+ declare var self: any | undefined;
175
+ declare var window: any | undefined;
176
+ declare var global: any | undefined;
177
+ var globalThis: any = (() => {
178
+ if (typeof globalThis !== 'undefined') return globalThis;
179
+ if (typeof self !== 'undefined') return self;
180
+ if (typeof window !== 'undefined') return window;
181
+ if (typeof global !== 'undefined') return global;
182
+ throw 'Unable to locate global object';
183
+ })();
184
+
185
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
186
+
187
+ export type DeepPartial<T> = T extends Builtin
188
+ ? T
189
+ : T extends Array<infer U>
190
+ ? Array<DeepPartial<U>>
191
+ : T extends ReadonlyArray<infer U>
192
+ ? ReadonlyArray<DeepPartial<U>>
193
+ : T extends {}
194
+ ? { [K in keyof T]?: DeepPartial<T[K]> }
195
+ : Partial<T>;
196
+
197
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
198
+ export type Exact<P, I extends P> = P extends Builtin
199
+ ? P
200
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>;
201
+
202
+ function longToNumber(long: Long): number {
203
+ if (long.gt(Number.MAX_SAFE_INTEGER)) {
204
+ throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER');
205
+ }
206
+ return long.toNumber();
207
+ }
208
+
209
+ if (_m0.util.Long !== Long) {
210
+ _m0.util.Long = Long as any;
211
+ _m0.configure();
212
+ }
213
+
214
+ function isSet(value: any): boolean {
215
+ return value !== null && value !== undefined;
216
+ }