@spatialwalk/avatarkit 1.0.0-beta.4 → 1.0.0-beta.41
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/CHANGELOG.md +378 -2
- package/README.md +261 -283
- package/dist/StreamingAudioPlayer-BXytpr5T.js +506 -0
- package/dist/animation/AnimationWebSocketClient.d.ts +9 -24
- package/dist/animation/utils/eventEmitter.d.ts +0 -4
- package/dist/animation/utils/flameConverter.d.ts +3 -11
- package/dist/audio/AnimationPlayer.d.ts +4 -32
- package/dist/audio/StreamingAudioPlayer.d.ts +12 -75
- package/dist/avatar_core_wasm-i0Ocpx6q.js +2693 -0
- package/dist/avatar_core_wasm.wasm +0 -0
- package/dist/config/app-config.d.ts +1 -6
- package/dist/config/constants.d.ts +5 -27
- package/dist/config/sdk-config-loader.d.ts +2 -9
- package/dist/core/Avatar.d.ts +0 -15
- package/dist/core/AvatarController.d.ts +35 -116
- package/dist/core/AvatarDownloader.d.ts +0 -95
- package/dist/core/AvatarManager.d.ts +10 -18
- package/dist/core/AvatarSDK.d.ts +21 -0
- package/dist/core/AvatarView.d.ts +24 -110
- package/dist/core/NetworkLayer.d.ts +1 -59
- package/dist/generated/common/v1/models.d.ts +29 -0
- package/dist/generated/driveningress/v1/driveningress.d.ts +1 -12
- package/dist/generated/driveningress/v2/driveningress.d.ts +81 -3
- package/dist/generated/google/protobuf/struct.d.ts +5 -39
- package/dist/generated/google/protobuf/timestamp.d.ts +1 -103
- package/dist/index-CRKYjlwp.js +14267 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.js +17 -18
- package/dist/renderer/RenderSystem.d.ts +1 -79
- package/dist/renderer/covariance.d.ts +0 -12
- package/dist/renderer/renderer.d.ts +6 -2
- package/dist/renderer/sortSplats.d.ts +0 -11
- package/dist/renderer/webgl/reorderData.d.ts +0 -13
- package/dist/renderer/webgl/webglRenderer.d.ts +19 -42
- package/dist/renderer/webgpu/webgpuRenderer.d.ts +18 -31
- package/dist/types/character-settings.d.ts +0 -5
- package/dist/types/character.d.ts +3 -21
- package/dist/types/index.d.ts +72 -36
- package/dist/utils/animation-interpolation.d.ts +3 -13
- package/dist/utils/client-id.d.ts +1 -0
- package/dist/utils/conversationId.d.ts +1 -0
- package/dist/utils/error-utils.d.ts +1 -25
- package/dist/utils/heartbeat-manager.d.ts +18 -0
- package/dist/utils/id-manager.d.ts +38 -0
- package/dist/utils/logger.d.ts +5 -11
- package/dist/utils/posthog-tracker.d.ts +11 -0
- package/dist/utils/usage-tracker.d.ts +5 -0
- package/dist/vanilla/vite.config.d.ts +2 -0
- package/dist/wasm/avatarCoreAdapter.d.ts +11 -97
- package/dist/wasm/avatarCoreMemory.d.ts +5 -54
- package/package.json +15 -13
- package/dist/StreamingAudioPlayer-L87IFoao.js +0 -319
- package/dist/StreamingAudioPlayer-L87IFoao.js.map +0 -1
- package/dist/animation/AnimationWebSocketClient.d.ts.map +0 -1
- package/dist/animation/utils/eventEmitter.d.ts.map +0 -1
- package/dist/animation/utils/flameConverter.d.ts.map +0 -1
- package/dist/audio/AnimationPlayer.d.ts.map +0 -1
- package/dist/audio/StreamingAudioPlayer.d.ts.map +0 -1
- package/dist/avatar_core_wasm-D4eEi7Eh.js +0 -1666
- package/dist/avatar_core_wasm-D4eEi7Eh.js.map +0 -1
- package/dist/config/app-config.d.ts.map +0 -1
- package/dist/config/constants.d.ts.map +0 -1
- package/dist/config/sdk-config-loader.d.ts.map +0 -1
- package/dist/core/Avatar.d.ts.map +0 -1
- package/dist/core/AvatarController.d.ts.map +0 -1
- package/dist/core/AvatarDownloader.d.ts.map +0 -1
- package/dist/core/AvatarKit.d.ts +0 -66
- package/dist/core/AvatarKit.d.ts.map +0 -1
- package/dist/core/AvatarManager.d.ts.map +0 -1
- package/dist/core/AvatarView.d.ts.map +0 -1
- package/dist/core/NetworkLayer.d.ts.map +0 -1
- package/dist/generated/driveningress/v1/driveningress.d.ts.map +0 -1
- package/dist/generated/driveningress/v2/driveningress.d.ts.map +0 -1
- package/dist/generated/google/protobuf/struct.d.ts.map +0 -1
- package/dist/generated/google/protobuf/timestamp.d.ts.map +0 -1
- package/dist/index-BDxVrKwm.js +0 -5942
- package/dist/index-BDxVrKwm.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/renderer/RenderSystem.d.ts.map +0 -1
- package/dist/renderer/covariance.d.ts.map +0 -1
- package/dist/renderer/renderer.d.ts.map +0 -1
- package/dist/renderer/sortSplats.d.ts.map +0 -1
- package/dist/renderer/webgl/reorderData.d.ts.map +0 -1
- package/dist/renderer/webgl/webglRenderer.d.ts.map +0 -1
- package/dist/renderer/webgpu/webgpuRenderer.d.ts.map +0 -1
- package/dist/types/character-settings.d.ts.map +0 -1
- package/dist/types/character.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/animation-interpolation.d.ts.map +0 -1
- package/dist/utils/cls-tracker.d.ts +0 -17
- package/dist/utils/cls-tracker.d.ts.map +0 -1
- package/dist/utils/error-utils.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/reqId.d.ts +0 -20
- package/dist/utils/reqId.d.ts.map +0 -1
- package/dist/wasm/avatarCoreAdapter.d.ts.map +0 -1
- package/dist/wasm/avatarCoreMemory.d.ts.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
export declare const protobufPackage = "common.v1";
|
|
3
|
+
|
|
4
|
+
export interface CustomAnimation {
|
|
5
|
+
key: string;
|
|
6
|
+
pbUrl: string;
|
|
7
|
+
wavUrl: string;
|
|
8
|
+
remark: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const CustomAnimation: MessageFns<CustomAnimation>;
|
|
11
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
12
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
13
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
14
|
+
} : Partial<T>;
|
|
15
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
16
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
17
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
18
|
+
} & {
|
|
19
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
20
|
+
};
|
|
21
|
+
export interface MessageFns<T> {
|
|
22
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
23
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
24
|
+
fromJSON(object: any): T;
|
|
25
|
+
toJSON(message: T): unknown;
|
|
26
|
+
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
27
|
+
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -9,29 +9,19 @@ export declare enum MessageType {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function messageTypeFromJSON(object: any): MessageType;
|
|
11
11
|
export declare function messageTypeToJSON(object: MessageType): string;
|
|
12
|
-
|
|
13
|
-
* 兼容流式传输,只要 req_id 相同,客户端可以将音频分段发若干个 ClientAudioInputData
|
|
14
|
-
* 新 req_id 出现后,老 req_id 的请求将被忽略
|
|
15
|
-
*/
|
|
12
|
+
|
|
16
13
|
export interface ClientAudioInputData {
|
|
17
14
|
reqId: string;
|
|
18
15
|
audio: Uint8Array;
|
|
19
16
|
end: boolean;
|
|
20
17
|
}
|
|
21
18
|
export interface Flame {
|
|
22
|
-
/** 平移 */
|
|
23
19
|
translation: number[];
|
|
24
|
-
/** 旋转 */
|
|
25
20
|
rotation: number[];
|
|
26
|
-
/** 脖子 */
|
|
27
21
|
neckPose: number[];
|
|
28
|
-
/** 下巴 */
|
|
29
22
|
jawPose: number[];
|
|
30
|
-
/** 眼睛 */
|
|
31
23
|
eyePose: number[];
|
|
32
|
-
/** 眼皮 */
|
|
33
24
|
eyeLid: number[];
|
|
34
|
-
/** 表情参数 */
|
|
35
25
|
expression: number[];
|
|
36
26
|
}
|
|
37
27
|
export interface FlameAnimation {
|
|
@@ -77,4 +67,3 @@ export interface MessageFns<T> {
|
|
|
77
67
|
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
78
68
|
}
|
|
79
69
|
export {};
|
|
80
|
-
//# sourceMappingURL=driveningress.d.ts.map
|
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
+
import { CustomAnimation } from '../../common/v1/models';
|
|
2
3
|
import { Timestamp } from '../../google/protobuf/timestamp';
|
|
3
4
|
export declare const protobufPackage = "driveningress.v2";
|
|
5
|
+
export declare enum MessageType {
|
|
6
|
+
MESSAGE_UNSPECIFIED = 0,
|
|
7
|
+
|
|
8
|
+
MESSAGE_CLIENT_CONFIGURE_SESSION = 1,
|
|
9
|
+
|
|
10
|
+
MESSAGE_SERVER_CONFIRM_SESSION = 2,
|
|
11
|
+
MESSAGE_CLIENT_AUDIO_INPUT = 3,
|
|
12
|
+
MESSAGE_SERVER_ERROR = 4,
|
|
13
|
+
MESSAGE_SERVER_RESPONSE_ANIMATION = 5,
|
|
14
|
+
UNRECOGNIZED = -1
|
|
15
|
+
}
|
|
16
|
+
export declare function messageTypeFromJSON(object: any): MessageType;
|
|
17
|
+
export declare function messageTypeToJSON(object: MessageType): string;
|
|
18
|
+
export declare enum AudioFormat {
|
|
19
|
+
AUDIO_FORMAT_PCM_S16LE = 0,
|
|
20
|
+
UNRECOGNIZED = -1
|
|
21
|
+
}
|
|
22
|
+
export declare function audioFormatFromJSON(object: any): AudioFormat;
|
|
23
|
+
export declare function audioFormatToJSON(object: AudioFormat): string;
|
|
24
|
+
export declare enum TransportCompression {
|
|
25
|
+
TRANSPORT_COMPRESSION_NONE = 0,
|
|
26
|
+
UNRECOGNIZED = -1
|
|
27
|
+
}
|
|
28
|
+
export declare function transportCompressionFromJSON(object: any): TransportCompression;
|
|
29
|
+
export declare function transportCompressionToJSON(object: TransportCompression): string;
|
|
4
30
|
export interface GetCharacterInfoRequest {
|
|
5
31
|
characterId: string;
|
|
6
32
|
}
|
|
7
33
|
export interface CharacterAsset {
|
|
8
|
-
/** 资产ID,例如 "v1/xxx" */
|
|
9
34
|
characterId: string;
|
|
10
|
-
/** 资产版本,例如 "1.0.0" */
|
|
11
35
|
version: string;
|
|
12
36
|
createdAt?: Timestamp | undefined;
|
|
13
37
|
updatedAt?: Timestamp | undefined;
|
|
@@ -18,6 +42,7 @@ export interface CharacterAsset {
|
|
|
18
42
|
characterSettings?: {
|
|
19
43
|
[key: string]: any;
|
|
20
44
|
} | undefined;
|
|
45
|
+
customAnimations: CustomAnimation[];
|
|
21
46
|
}
|
|
22
47
|
export interface Resource {
|
|
23
48
|
type: string;
|
|
@@ -38,12 +63,66 @@ export interface Animations {
|
|
|
38
63
|
frameMono?: ResourceHolder | undefined;
|
|
39
64
|
audioMono?: ResourceHolder | undefined;
|
|
40
65
|
}
|
|
66
|
+
export interface ClientConfigureSession {
|
|
67
|
+
sampleRate: number;
|
|
68
|
+
bitrate: number;
|
|
69
|
+
audioFormat: AudioFormat;
|
|
70
|
+
transportCompression: TransportCompression;
|
|
71
|
+
}
|
|
72
|
+
export interface ServerConfirmSession {
|
|
73
|
+
connectionId: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ClientAudioInput {
|
|
76
|
+
reqId: string;
|
|
77
|
+
end: boolean;
|
|
78
|
+
audio: Uint8Array;
|
|
79
|
+
}
|
|
80
|
+
export interface ServerError {
|
|
81
|
+
connectionId: string;
|
|
82
|
+
reqId: string;
|
|
83
|
+
code: number;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
export interface Flame {
|
|
87
|
+
translation: number[];
|
|
88
|
+
rotation: number[];
|
|
89
|
+
neckPose: number[];
|
|
90
|
+
jawPose: number[];
|
|
91
|
+
eyePose: number[];
|
|
92
|
+
eyeLid: number[];
|
|
93
|
+
expression: number[];
|
|
94
|
+
}
|
|
95
|
+
export interface FlameAnimation {
|
|
96
|
+
keyframes: Flame[];
|
|
97
|
+
}
|
|
98
|
+
export interface ServerResponseAnimation {
|
|
99
|
+
connectionId: string;
|
|
100
|
+
reqId: string;
|
|
101
|
+
end: boolean;
|
|
102
|
+
animation?: FlameAnimation | undefined;
|
|
103
|
+
}
|
|
104
|
+
export interface Message {
|
|
105
|
+
type: MessageType;
|
|
106
|
+
clientConfigureSession?: ClientConfigureSession | undefined;
|
|
107
|
+
serverConfirmSession?: ServerConfirmSession | undefined;
|
|
108
|
+
clientAudioInput?: ClientAudioInput | undefined;
|
|
109
|
+
serverError?: ServerError | undefined;
|
|
110
|
+
serverResponseAnimation?: ServerResponseAnimation | undefined;
|
|
111
|
+
}
|
|
41
112
|
export declare const GetCharacterInfoRequest: MessageFns<GetCharacterInfoRequest>;
|
|
42
113
|
export declare const CharacterAsset: MessageFns<CharacterAsset>;
|
|
43
114
|
export declare const Resource: MessageFns<Resource>;
|
|
44
115
|
export declare const ResourceHolder: MessageFns<ResourceHolder>;
|
|
45
116
|
export declare const Models: MessageFns<Models>;
|
|
46
117
|
export declare const Animations: MessageFns<Animations>;
|
|
118
|
+
export declare const ClientConfigureSession: MessageFns<ClientConfigureSession>;
|
|
119
|
+
export declare const ServerConfirmSession: MessageFns<ServerConfirmSession>;
|
|
120
|
+
export declare const ClientAudioInput: MessageFns<ClientAudioInput>;
|
|
121
|
+
export declare const ServerError: MessageFns<ServerError>;
|
|
122
|
+
export declare const Flame: MessageFns<Flame>;
|
|
123
|
+
export declare const FlameAnimation: MessageFns<FlameAnimation>;
|
|
124
|
+
export declare const ServerResponseAnimation: MessageFns<ServerResponseAnimation>;
|
|
125
|
+
export declare const Message: MessageFns<Message>;
|
|
47
126
|
export interface DrivenIngressService {
|
|
48
127
|
GetCharacterInfo(request: GetCharacterInfoRequest): Promise<CharacterAsset>;
|
|
49
128
|
}
|
|
@@ -78,4 +157,3 @@ export interface MessageFns<T> {
|
|
|
78
157
|
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
79
158
|
}
|
|
80
159
|
export {};
|
|
81
|
-
//# sourceMappingURL=driveningress.d.ts.map
|
|
@@ -1,30 +1,15 @@
|
|
|
1
1
|
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
2
|
export declare const protobufPackage = "google.protobuf";
|
|
3
|
-
|
|
4
|
-
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
5
|
-
* `Value` type union.
|
|
6
|
-
*
|
|
7
|
-
* The JSON representation for `NullValue` is JSON `null`.
|
|
8
|
-
*/
|
|
3
|
+
|
|
9
4
|
export declare enum NullValue {
|
|
10
|
-
|
|
5
|
+
|
|
11
6
|
NULL_VALUE = 0,
|
|
12
7
|
UNRECOGNIZED = -1
|
|
13
8
|
}
|
|
14
9
|
export declare function nullValueFromJSON(object: any): NullValue;
|
|
15
10
|
export declare function nullValueToJSON(object: NullValue): string;
|
|
16
|
-
|
|
17
|
-
* `Struct` represents a structured data value, consisting of fields
|
|
18
|
-
* which map to dynamically typed values. In some languages, `Struct`
|
|
19
|
-
* might be supported by a native representation. For example, in
|
|
20
|
-
* scripting languages like JS a struct is represented as an
|
|
21
|
-
* object. The details of that representation are described together
|
|
22
|
-
* with the proto support for the language.
|
|
23
|
-
*
|
|
24
|
-
* The JSON representation for `Struct` is JSON object.
|
|
25
|
-
*/
|
|
11
|
+
|
|
26
12
|
export interface Struct {
|
|
27
|
-
/** Unordered map of dynamically typed values. */
|
|
28
13
|
fields: {
|
|
29
14
|
[key: string]: any | undefined;
|
|
30
15
|
};
|
|
@@ -33,37 +18,19 @@ export interface Struct_FieldsEntry {
|
|
|
33
18
|
key: string;
|
|
34
19
|
value?: any | undefined;
|
|
35
20
|
}
|
|
36
|
-
|
|
37
|
-
* `Value` represents a dynamically typed value which can be either
|
|
38
|
-
* null, a number, a string, a boolean, a recursive struct value, or a
|
|
39
|
-
* list of values. A producer of value is expected to set one of these
|
|
40
|
-
* variants. Absence of any variant indicates an error.
|
|
41
|
-
*
|
|
42
|
-
* The JSON representation for `Value` is JSON value.
|
|
43
|
-
*/
|
|
21
|
+
|
|
44
22
|
export interface Value {
|
|
45
|
-
/** Represents a null value. */
|
|
46
23
|
nullValue?: NullValue | undefined;
|
|
47
|
-
/** Represents a double value. */
|
|
48
24
|
numberValue?: number | undefined;
|
|
49
|
-
/** Represents a string value. */
|
|
50
25
|
stringValue?: string | undefined;
|
|
51
|
-
/** Represents a boolean value. */
|
|
52
26
|
boolValue?: boolean | undefined;
|
|
53
|
-
/** Represents a structured value. */
|
|
54
27
|
structValue?: {
|
|
55
28
|
[key: string]: any;
|
|
56
29
|
} | undefined;
|
|
57
|
-
/** Represents a repeated `Value`. */
|
|
58
30
|
listValue?: Array<any> | undefined;
|
|
59
31
|
}
|
|
60
|
-
|
|
61
|
-
* `ListValue` is a wrapper around a repeated field of values.
|
|
62
|
-
*
|
|
63
|
-
* The JSON representation for `ListValue` is JSON array.
|
|
64
|
-
*/
|
|
32
|
+
|
|
65
33
|
export interface ListValue {
|
|
66
|
-
/** Repeated field of dynamically typed values. */
|
|
67
34
|
values: any[];
|
|
68
35
|
}
|
|
69
36
|
export declare const Struct: MessageFns<Struct> & StructWrapperFns;
|
|
@@ -105,4 +72,3 @@ export interface ListValueWrapperFns {
|
|
|
105
72
|
unwrap(message: ListValue): Array<any>;
|
|
106
73
|
}
|
|
107
74
|
export {};
|
|
108
|
-
//# sourceMappingURL=struct.d.ts.map
|
|
@@ -1,109 +1,8 @@
|
|
|
1
1
|
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
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://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
92
|
-
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
93
|
-
*/
|
|
3
|
+
|
|
94
4
|
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
5
|
seconds: string;
|
|
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
6
|
nanos: number;
|
|
108
7
|
}
|
|
109
8
|
export declare const Timestamp: MessageFns<Timestamp>;
|
|
@@ -126,4 +25,3 @@ export interface MessageFns<T> {
|
|
|
126
25
|
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
127
26
|
}
|
|
128
27
|
export {};
|
|
129
|
-
//# sourceMappingURL=timestamp.d.ts.map
|