livekit-client 1.4.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. package/dist/livekit-client.esm.mjs +2478 -5368
  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 +3 -2
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  8. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
  9. package/dist/src/connectionHelper/checks/Checker.d.ts +59 -0
  10. package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -0
  11. package/dist/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  12. package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
  13. package/dist/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  14. package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
  15. package/dist/src/connectionHelper/checks/reconnect.d.ts +6 -0
  16. package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
  17. package/dist/src/connectionHelper/checks/turn.d.ts +6 -0
  18. package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -0
  19. package/dist/src/connectionHelper/checks/webrtc.d.ts +6 -0
  20. package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
  21. package/dist/src/connectionHelper/checks/websocket.d.ts +6 -0
  22. package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -0
  23. package/dist/src/index.d.ts +6 -3
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/logger.d.ts +3 -3
  26. package/dist/src/logger.d.ts.map +1 -1
  27. package/dist/src/options.d.ts +4 -1
  28. package/dist/src/options.d.ts.map +1 -1
  29. package/dist/src/proto/google/protobuf/timestamp.d.ts +4 -4
  30. package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -1
  31. package/dist/src/proto/livekit_models.d.ts +4 -4
  32. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  33. package/dist/src/proto/livekit_rtc.d.ts +12 -4
  34. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  35. package/dist/src/room/DeviceManager.d.ts.map +1 -1
  36. package/dist/src/room/RTCEngine.d.ts +4 -3
  37. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  38. package/dist/src/room/Room.d.ts +27 -4
  39. package/dist/src/room/Room.d.ts.map +1 -1
  40. package/dist/src/room/events.d.ts +9 -1
  41. package/dist/src/room/events.d.ts.map +1 -1
  42. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  43. package/dist/src/room/participant/Participant.d.ts +1 -1
  44. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  45. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  46. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -0
  47. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  48. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  49. package/dist/src/room/track/Track.d.ts +2 -1
  50. package/dist/src/room/track/Track.d.ts.map +1 -1
  51. package/dist/src/room/track/TrackPublication.d.ts +1 -1
  52. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  53. package/dist/src/room/track/options.d.ts +3 -3
  54. package/dist/src/room/track/options.d.ts.map +1 -1
  55. package/dist/src/room/track/types.d.ts +3 -3
  56. package/dist/src/room/track/types.d.ts.map +1 -1
  57. package/dist/src/room/types.d.ts +13 -0
  58. package/dist/src/room/types.d.ts.map +1 -0
  59. package/dist/src/room/utils.d.ts +44 -0
  60. package/dist/src/room/utils.d.ts.map +1 -1
  61. package/dist/ts4.2/src/api/SignalClient.d.ts +86 -0
  62. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +25 -0
  63. package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +59 -0
  64. package/dist/ts4.2/src/connectionHelper/checks/publishAudio.d.ts +6 -0
  65. package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +6 -0
  66. package/dist/ts4.2/src/connectionHelper/checks/reconnect.d.ts +6 -0
  67. package/dist/ts4.2/src/connectionHelper/checks/turn.d.ts +6 -0
  68. package/dist/ts4.2/src/connectionHelper/checks/webrtc.d.ts +6 -0
  69. package/dist/ts4.2/src/connectionHelper/checks/websocket.d.ts +6 -0
  70. package/dist/ts4.2/src/index.d.ts +31 -0
  71. package/dist/ts4.2/src/logger.d.ts +26 -0
  72. package/dist/ts4.2/src/options.d.ts +94 -0
  73. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +141 -0
  74. package/dist/ts4.2/src/proto/livekit_models.d.ts +1421 -0
  75. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +7122 -0
  76. package/dist/ts4.2/src/room/DefaultReconnectPolicy.d.ts +8 -0
  77. package/dist/ts4.2/src/room/DeviceManager.d.ts +9 -0
  78. package/dist/ts4.2/src/room/PCTransport.d.ts +33 -0
  79. package/dist/ts4.2/src/room/RTCEngine.d.ts +97 -0
  80. package/dist/ts4.2/src/room/ReconnectPolicy.d.ts +23 -0
  81. package/dist/ts4.2/src/room/Room.d.ts +220 -0
  82. package/dist/ts4.2/src/room/defaults.d.ts +8 -0
  83. package/dist/ts4.2/src/room/errors.d.ts +39 -0
  84. package/dist/ts4.2/src/room/events.d.ts +426 -0
  85. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +141 -0
  86. package/dist/ts4.2/src/room/participant/Participant.d.ts +92 -0
  87. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
  88. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +52 -0
  89. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +19 -0
  90. package/dist/ts4.2/src/room/stats.d.ts +67 -0
  91. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +25 -0
  92. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +42 -0
  93. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +38 -0
  94. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +53 -0
  95. package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +53 -0
  96. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +15 -0
  97. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +61 -0
  98. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +52 -0
  99. package/dist/ts4.2/src/room/track/Track.d.ts +122 -0
  100. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +68 -0
  101. package/dist/ts4.2/src/room/track/create.d.ts +24 -0
  102. package/dist/ts4.2/src/room/track/options.d.ts +241 -0
  103. package/dist/ts4.2/src/room/track/types.d.ts +23 -0
  104. package/dist/ts4.2/src/room/track/utils.d.ts +14 -0
  105. package/dist/ts4.2/src/room/types.d.ts +13 -0
  106. package/dist/ts4.2/src/room/utils.d.ts +79 -0
  107. package/dist/ts4.2/src/test/MockMediaStreamTrack.d.ts +26 -0
  108. package/dist/ts4.2/src/test/mocks.d.ts +11 -0
  109. package/dist/ts4.2/src/version.d.ts +3 -0
  110. package/package.json +32 -22
  111. package/src/api/SignalClient.ts +41 -17
  112. package/src/connectionHelper/ConnectionCheck.ts +90 -0
  113. package/src/connectionHelper/checks/Checker.ts +164 -0
  114. package/src/connectionHelper/checks/publishAudio.ts +33 -0
  115. package/src/connectionHelper/checks/publishVideo.ts +33 -0
  116. package/src/connectionHelper/checks/reconnect.ts +45 -0
  117. package/src/connectionHelper/checks/turn.ts +53 -0
  118. package/src/connectionHelper/checks/webrtc.ts +18 -0
  119. package/src/connectionHelper/checks/websocket.ts +22 -0
  120. package/src/index.ts +8 -1
  121. package/src/options.ts +5 -1
  122. package/src/proto/livekit_rtc.ts +12 -1
  123. package/src/room/DeviceManager.ts +0 -17
  124. package/src/room/RTCEngine.ts +35 -26
  125. package/src/room/Room.ts +231 -63
  126. package/src/room/events.ts +9 -0
  127. package/src/room/participant/LocalParticipant.ts +18 -11
  128. package/src/room/participant/publishUtils.ts +1 -1
  129. package/src/room/track/LocalAudioTrack.ts +1 -1
  130. package/src/room/track/LocalTrack.ts +4 -0
  131. package/src/room/track/LocalVideoTrack.ts +1 -1
  132. package/src/room/track/RemoteTrackPublication.ts +20 -0
  133. package/src/room/track/RemoteVideoTrack.ts +4 -0
  134. package/src/room/track/Track.ts +1 -0
  135. package/src/room/types.ts +12 -0
  136. package/src/room/utils.ts +150 -12
@@ -0,0 +1,59 @@
1
+ import type TypedEmitter from 'typed-emitter';
2
+ import type { RoomConnectOptions, RoomOptions } from '../../options';
3
+ import Room from '../../room/Room';
4
+ import type RTCEngine from '../../room/RTCEngine';
5
+ type LogMessage = {
6
+ level: 'info' | 'warning' | 'error';
7
+ message: string;
8
+ };
9
+ export declare enum CheckStatus {
10
+ IDLE = 0,
11
+ RUNNING = 1,
12
+ SKIPPED = 2,
13
+ SUCCESS = 3,
14
+ FAILED = 4
15
+ }
16
+ export type CheckInfo = {
17
+ name: string;
18
+ logs: Array<LogMessage>;
19
+ status: CheckStatus;
20
+ description: string;
21
+ };
22
+ export interface CheckerOptions {
23
+ errorsAsWarnings?: boolean;
24
+ roomOptions?: RoomOptions;
25
+ connectOptions?: RoomConnectOptions;
26
+ }
27
+ declare const Checker_base: new () => TypedEmitter<CheckerCallbacks>;
28
+ export declare abstract class Checker extends Checker_base {
29
+ protected url: string;
30
+ protected token: string;
31
+ room: Room;
32
+ connectOptions?: RoomConnectOptions;
33
+ status: CheckStatus;
34
+ logs: Array<LogMessage>;
35
+ errorsAsWarnings: boolean;
36
+ name: string;
37
+ constructor(url: string, token: string, options?: CheckerOptions);
38
+ abstract get description(): string;
39
+ protected abstract perform(): Promise<void>;
40
+ run(onComplete?: () => void): Promise<CheckInfo>;
41
+ protected isSuccess(): boolean;
42
+ protected connect(): Promise<Room>;
43
+ protected disconnect(): Promise<void>;
44
+ protected skip(): void;
45
+ protected appendMessage(message: string): void;
46
+ protected appendWarning(message: string): void;
47
+ protected appendError(message: string): void;
48
+ protected setStatus(status: CheckStatus): void;
49
+ protected get engine(): RTCEngine | undefined;
50
+ getInfo(): CheckInfo;
51
+ }
52
+ export type InstantiableCheck<T extends Checker> = {
53
+ new (url: string, token: string, options?: CheckerOptions): T;
54
+ };
55
+ type CheckerCallbacks = {
56
+ update: (info: CheckInfo) => void;
57
+ };
58
+ export {};
59
+ //# sourceMappingURL=Checker.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Checker } from './Checker';
2
+ export declare class PublishAudioCheck extends Checker {
3
+ get description(): string;
4
+ perform(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=publishAudio.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Checker } from './Checker';
2
+ export declare class PublishVideoCheck extends Checker {
3
+ get description(): string;
4
+ perform(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=publishVideo.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Checker } from './Checker';
2
+ export declare class ReconnectCheck extends Checker {
3
+ get description(): string;
4
+ perform(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=reconnect.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Checker } from './Checker';
2
+ export declare class TURNCheck extends Checker {
3
+ get description(): string;
4
+ perform(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=turn.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Checker } from './Checker';
2
+ export declare class WebRTCCheck extends Checker {
3
+ get description(): string;
4
+ protected perform(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=webrtc.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Checker } from './Checker';
2
+ export declare class WebSocketCheck extends Checker {
3
+ get description(): string;
4
+ protected perform(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=websocket.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { LogLevel, setLogExtension, setLogLevel } from './logger';
2
+ import { DataPacket_Kind, DisconnectReason, VideoQuality } from './proto/livekit_models';
3
+ import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
4
+ import LocalParticipant from './room/participant/LocalParticipant';
5
+ import Participant, { ConnectionQuality } from './room/participant/Participant';
6
+ import type { ParticipantTrackPermission } from './room/participant/ParticipantTrackPermission';
7
+ import RemoteParticipant from './room/participant/RemoteParticipant';
8
+ import Room, { ConnectionState, RoomState } from './room/Room';
9
+ import LocalAudioTrack from './room/track/LocalAudioTrack';
10
+ import LocalTrack from './room/track/LocalTrack';
11
+ import LocalTrackPublication from './room/track/LocalTrackPublication';
12
+ import LocalVideoTrack from './room/track/LocalVideoTrack';
13
+ import RemoteAudioTrack from './room/track/RemoteAudioTrack';
14
+ import RemoteTrack from './room/track/RemoteTrack';
15
+ import RemoteTrackPublication from './room/track/RemoteTrackPublication';
16
+ import RemoteVideoTrack from './room/track/RemoteVideoTrack';
17
+ import type { ElementInfo } from './room/track/RemoteVideoTrack';
18
+ import { TrackPublication } from './room/track/TrackPublication';
19
+ import { getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, isBrowserSupported, supportsAdaptiveStream, supportsAV1, supportsDynacast, createAudioAnalyser } from './room/utils';
20
+ import type { AudioAnalyserOptions } from './room/utils';
21
+ export * from './options';
22
+ export * from './room/errors';
23
+ export * from './room/events';
24
+ export * from './room/track/create';
25
+ export * from './room/track/options';
26
+ export * from './room/track/Track';
27
+ export * from './room/track/types';
28
+ export * from './version';
29
+ export * from './connectionHelper/ConnectionCheck';
30
+ export { setLogLevel, setLogExtension, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, isBrowserSupported, supportsAdaptiveStream, supportsDynacast, supportsAV1, createAudioAnalyser, AudioAnalyserOptions, LogLevel, Room, ConnectionState, RoomState, DataPacket_Kind, DisconnectReason, Participant, RemoteParticipant, LocalParticipant, LocalAudioTrack, LocalVideoTrack, LocalTrack, LocalTrackPublication, RemoteTrack, RemoteAudioTrack, RemoteVideoTrack, RemoteTrackPublication, ParticipantTrackPermission, TrackPublication, VideoQuality, ConnectionQuality, ElementInfo, DefaultReconnectPolicy, };
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,26 @@
1
+ export declare enum LogLevel {
2
+ trace = 0,
3
+ debug = 1,
4
+ info = 2,
5
+ warn = 3,
6
+ error = 4,
7
+ silent = 5
8
+ }
9
+ type LogLevelString = keyof typeof LogLevel;
10
+ type StructuredLogger = {
11
+ trace: (msg: string, context?: object) => void;
12
+ debug: (msg: string, context?: object) => void;
13
+ info: (msg: string, context?: object) => void;
14
+ warn: (msg: string, context?: object) => void;
15
+ error: (msg: string, context?: object) => void;
16
+ };
17
+ declare const _default: StructuredLogger;
18
+ export default _default;
19
+ export declare function setLogLevel(level: LogLevel | LogLevelString): void;
20
+ export type LogExtension = (level: LogLevel, msg: string, context?: object) => void;
21
+ /**
22
+ * use this to hook into the logging function to allow sending internal livekit logs to third party services
23
+ * if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
24
+ */
25
+ export declare function setLogExtension(extension: LogExtension): void;
26
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1,94 @@
1
+ import type { ReconnectPolicy } from './room/ReconnectPolicy';
2
+ import type { AudioCaptureOptions, AudioOutputOptions, TrackPublishDefaults, VideoCaptureOptions } from './room/track/options';
3
+ import type { AdaptiveStreamSettings } from './room/track/types';
4
+ export interface WebAudioSettings {
5
+ audioContext: AudioContext;
6
+ }
7
+ /**
8
+ * @internal
9
+ */
10
+ export interface InternalRoomOptions {
11
+ /**
12
+ * AdaptiveStream lets LiveKit automatically manage quality of subscribed
13
+ * video tracks to optimize for bandwidth and CPU.
14
+ * When attached video elements are visible, it'll choose an appropriate
15
+ * resolution based on the size of largest video element it's attached to.
16
+ *
17
+ * When none of the video elements are visible, it'll temporarily pause
18
+ * the data flow until they are visible again.
19
+ */
20
+ adaptiveStream: AdaptiveStreamSettings | boolean;
21
+ /**
22
+ * enable Dynacast, off by default. With Dynacast dynamically pauses
23
+ * video layers that are not being consumed by any subscribers, significantly
24
+ * reducing publishing CPU and bandwidth usage.
25
+ */
26
+ dynacast: boolean;
27
+ /**
28
+ * default options to use when capturing user's audio
29
+ */
30
+ audioCaptureDefaults?: AudioCaptureOptions;
31
+ /**
32
+ * default options to use when capturing user's video
33
+ */
34
+ videoCaptureDefaults?: VideoCaptureOptions;
35
+ /**
36
+ * default options to use when publishing tracks
37
+ */
38
+ publishDefaults?: TrackPublishDefaults;
39
+ /**
40
+ * audio output for the room
41
+ */
42
+ audioOutput?: AudioOutputOptions;
43
+ /**
44
+ * should local tracks be stopped when they are unpublished. defaults to true
45
+ * set this to false if you would prefer to clean up unpublished local tracks manually.
46
+ */
47
+ stopLocalTrackOnUnpublish: boolean;
48
+ /**
49
+ * policy to use when attempting to reconnect
50
+ */
51
+ reconnectPolicy: ReconnectPolicy;
52
+ /**
53
+ * @internal
54
+ * experimental flag, introduce a delay before sending signaling messages
55
+ */
56
+ expSignalLatency?: number;
57
+ /**
58
+ * @internal
59
+ * @experimental
60
+ * experimental flag, mix all audio tracks in web audio
61
+ */
62
+ expWebAudioMix: boolean | WebAudioSettings;
63
+ }
64
+ /**
65
+ * Options for when creating a new room
66
+ */
67
+ export interface RoomOptions extends Partial<InternalRoomOptions> {
68
+ }
69
+ /**
70
+ * @internal
71
+ */
72
+ export interface InternalRoomConnectOptions {
73
+ /** autosubscribe to room tracks after joining, defaults to true */
74
+ autoSubscribe: boolean;
75
+ /** amount of time for PeerConnection to be established, defaults to 15s */
76
+ peerConnectionTimeout: number;
77
+ /**
78
+ * use to override any RTCConfiguration options.
79
+ */
80
+ rtcConfig?: RTCConfiguration;
81
+ /**
82
+ * @deprecated
83
+ * publish only mode
84
+ */
85
+ publishOnly?: string;
86
+ /** specifies how often an initial join connection is allowed to retry (only applicable if server is not reachable) */
87
+ maxRetries: number;
88
+ }
89
+ /**
90
+ * Options for Room.connect()
91
+ */
92
+ export interface RoomConnectOptions extends Partial<InternalRoomConnectOptions> {
93
+ }
94
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1,141 @@
1
+ import _m0 from "protobufjs/minimal";
2
+ export declare const protobufPackage = "google.protobuf";
3
+ /**
4
+ * A Timestamp represents a point in time independent of any time zone or local
5
+ * calendar, encoded as a count of seconds and fractions of seconds at
6
+ * nanosecond resolution. The count is relative to an epoch at UTC midnight on
7
+ * January 1, 1970, in the proleptic Gregorian calendar which extends the
8
+ * Gregorian calendar backwards to year one.
9
+ *
10
+ * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
11
+ * second table is needed for interpretation, using a [24-hour linear
12
+ * smear](https://developers.google.com/time/smear).
13
+ *
14
+ * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
15
+ * restricting to that range, we ensure that we can convert to and from [RFC
16
+ * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
17
+ *
18
+ * # Examples
19
+ *
20
+ * Example 1: Compute Timestamp from POSIX `time()`.
21
+ *
22
+ * Timestamp timestamp;
23
+ * timestamp.set_seconds(time(NULL));
24
+ * timestamp.set_nanos(0);
25
+ *
26
+ * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
27
+ *
28
+ * struct timeval tv;
29
+ * gettimeofday(&tv, NULL);
30
+ *
31
+ * Timestamp timestamp;
32
+ * timestamp.set_seconds(tv.tv_sec);
33
+ * timestamp.set_nanos(tv.tv_usec * 1000);
34
+ *
35
+ * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
36
+ *
37
+ * FILETIME ft;
38
+ * GetSystemTimeAsFileTime(&ft);
39
+ * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
40
+ *
41
+ * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
42
+ * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
43
+ * Timestamp timestamp;
44
+ * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
45
+ * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
46
+ *
47
+ * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
48
+ *
49
+ * long millis = System.currentTimeMillis();
50
+ *
51
+ * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
52
+ * .setNanos((int) ((millis % 1000) * 1000000)).build();
53
+ *
54
+ * Example 5: Compute Timestamp from Java `Instant.now()`.
55
+ *
56
+ * Instant now = Instant.now();
57
+ *
58
+ * Timestamp timestamp =
59
+ * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
60
+ * .setNanos(now.getNano()).build();
61
+ *
62
+ * Example 6: Compute Timestamp from current time in Python.
63
+ *
64
+ * timestamp = Timestamp()
65
+ * timestamp.GetCurrentTime()
66
+ *
67
+ * # JSON Mapping
68
+ *
69
+ * In JSON format, the Timestamp type is encoded as a string in the
70
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
71
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
72
+ * where {year} is always expressed using four digits while {month}, {day},
73
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
74
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
75
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
76
+ * is required. A proto3 JSON serializer should always use UTC (as indicated by
77
+ * "Z") when printing the Timestamp type and a proto3 JSON parser should be
78
+ * able to accept both UTC and other timezones (as indicated by an offset).
79
+ *
80
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
81
+ * 01:30 UTC on January 15, 2017.
82
+ *
83
+ * In JavaScript, one can convert a Date object to this format using the
84
+ * standard
85
+ * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
86
+ * method. In Python, a standard `datetime.datetime` object can be converted
87
+ * to this format using
88
+ * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
89
+ * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
90
+ * the Joda Time's [`ISODateTimeFormat.dateTime()`](
91
+ * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
92
+ * ) to obtain a formatter capable of generating timestamps in this format.
93
+ */
94
+ export interface Timestamp {
95
+ /**
96
+ * Represents seconds of UTC time since Unix epoch
97
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
98
+ * 9999-12-31T23:59:59Z inclusive.
99
+ */
100
+ seconds: number;
101
+ /**
102
+ * Non-negative fractions of a second at nanosecond resolution. Negative
103
+ * second values with fractions must still have non-negative nanos values
104
+ * that count forward in time. Must be from 0 to 999,999,999
105
+ * inclusive.
106
+ */
107
+ nanos: number;
108
+ }
109
+ export declare const Timestamp: {
110
+ encode(message: Timestamp, writer?: _m0.Writer): _m0.Writer;
111
+ decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp;
112
+ fromJSON(object: any): Timestamp;
113
+ toJSON(message: Timestamp): unknown;
114
+ fromPartial<I extends {
115
+ seconds?: number | undefined;
116
+ nanos?: number | undefined;
117
+ } & {
118
+ seconds?: number | undefined;
119
+ nanos?: number | undefined;
120
+ } & {
121
+ [K in Exclude<keyof I, keyof Timestamp>]: never;
122
+ }>(object: I): Timestamp;
123
+ };
124
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
125
+ export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
126
+ $case: string;
127
+ } ? {
128
+ [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
129
+ } & {
130
+ $case: T["$case"];
131
+ } : T extends {} ? {
132
+ [K in keyof T]?: DeepPartial<T[K]>;
133
+ } : Partial<T>;
134
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
135
+ export type Exact<P, I extends P> = P extends Builtin ? P : P & {
136
+ [K in keyof P]: Exact<P[K], I[K]>;
137
+ } & {
138
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
139
+ };
140
+ export {};
141
+ //# sourceMappingURL=timestamp.d.ts.map