@decartai/sdk 0.0.67 → 0.1.0
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/README.md +55 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +43 -28
- package/dist/process/client.js +1 -3
- package/dist/process/request.js +1 -3
- package/dist/queue/client.js +1 -3
- package/dist/queue/polling.js +1 -2
- package/dist/queue/request.js +1 -3
- package/dist/realtime/client.d.ts +23 -13
- package/dist/realtime/client.js +74 -244
- package/dist/realtime/config-realtime.js +49 -0
- package/dist/realtime/event-buffer.js +1 -3
- package/dist/realtime/initial-state-gate.js +21 -0
- package/dist/realtime/media-channel.js +82 -0
- package/dist/realtime/methods.js +12 -42
- package/dist/realtime/mirror-stream.js +1 -2
- package/dist/realtime/observability/diagnostics.d.ts +39 -0
- package/dist/realtime/observability/livekit-stats-provider.js +25 -0
- package/dist/realtime/observability/realtime-observability.js +173 -0
- package/dist/realtime/{telemetry-reporter.js → observability/telemetry-reporter.js} +12 -31
- package/dist/realtime/observability/webrtc-stats.d.ts +148 -0
- package/dist/realtime/observability/webrtc-stats.js +276 -0
- package/dist/realtime/signaling-channel.js +286 -0
- package/dist/realtime/stream-session.js +252 -0
- package/dist/realtime/subscribe-client.d.ts +2 -1
- package/dist/realtime/subscribe-client.js +115 -11
- package/dist/realtime/types.d.ts +25 -1
- package/dist/shared/model.d.ts +11 -1
- package/dist/shared/model.js +51 -14
- package/dist/shared/request.js +1 -3
- package/dist/shared/types.js +1 -3
- package/dist/tokens/client.js +1 -3
- package/dist/utils/env.js +1 -2
- package/dist/utils/errors.js +1 -2
- package/dist/utils/logger.js +1 -2
- package/dist/utils/media.js +43 -0
- package/dist/utils/platform.js +13 -0
- package/dist/utils/user-agent.js +1 -3
- package/dist/version.js +1 -2
- package/package.json +2 -1
- package/dist/realtime/diagnostics.d.ts +0 -78
- package/dist/realtime/webrtc-connection.js +0 -501
- package/dist/realtime/webrtc-manager.js +0 -189
- package/dist/realtime/webrtc-stats.d.ts +0 -59
- package/dist/realtime/webrtc-stats.js +0 -154
package/README.md
CHANGED
|
@@ -15,12 +15,15 @@ yarn add @decartai/sdk
|
|
|
15
15
|
## Documentation
|
|
16
16
|
|
|
17
17
|
For complete documentation, guides, and examples, visit:
|
|
18
|
-
**https://docs.platform.decart.ai/sdks/javascript**
|
|
18
|
+
**[https://docs.platform.decart.ai/sdks/javascript](https://docs.platform.decart.ai/sdks/javascript)**
|
|
19
19
|
|
|
20
20
|
## Quick Start
|
|
21
21
|
|
|
22
22
|
### Real-time Video Transformation
|
|
23
23
|
|
|
24
|
+
Realtime connections are LiveKit-backed in the SDK. Existing client usage stays the same: provide a
|
|
25
|
+
camera `MediaStream`, choose a realtime model, and handle the transformed remote stream.
|
|
26
|
+
|
|
24
27
|
```typescript
|
|
25
28
|
import { createDecartClient, models } from "@decartai/sdk";
|
|
26
29
|
|
|
@@ -79,6 +82,53 @@ Options:
|
|
|
79
82
|
- `"auto"` — mirror when the input track reports `facingMode: "user"` (mobile front cameras).
|
|
80
83
|
- `true` — always mirror (e.g. desktop webcams).
|
|
81
84
|
|
|
85
|
+
### Watch a Stream
|
|
86
|
+
|
|
87
|
+
A connected realtime session exposes an SDK `subscribeToken` once it reaches a
|
|
88
|
+
connected state. Share that SDK token with viewers — `client.realtime.subscribe`
|
|
89
|
+
uses it to request receive-only LiveKit credentials from Decart, then connects to
|
|
90
|
+
the LiveKit room for the styled output stream. No viewer camera is required.
|
|
91
|
+
|
|
92
|
+
**Producer** — capture the token from the active session:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const realtimeClient = await client.realtime.connect(stream, {
|
|
96
|
+
model,
|
|
97
|
+
onRemoteStream: (transformedStream) => {
|
|
98
|
+
videoElement.srcObject = transformedStream;
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
realtimeClient.on("connectionChange", (state) => {
|
|
103
|
+
if ((state === "connected" || state === "generating") && realtimeClient.subscribeToken) {
|
|
104
|
+
const subscribeToken = realtimeClient.subscribeToken;
|
|
105
|
+
// Pass `subscribeToken` to the viewer snippet below.
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Viewer** — attach to the producer's stream with the token:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { createDecartClient, type RealTimeSubscribeClient } from "@decartai/sdk";
|
|
114
|
+
|
|
115
|
+
const client = createDecartClient({ apiKey: "your-api-key-here" });
|
|
116
|
+
|
|
117
|
+
const subscriber: RealTimeSubscribeClient = await client.realtime.subscribe({
|
|
118
|
+
token: subscribeToken,
|
|
119
|
+
onRemoteStream: (stream) => {
|
|
120
|
+
videoElement.srcObject = stream;
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
subscriber.on("connectionChange", (state) => {
|
|
125
|
+
console.log(`Viewer state: ${state}`);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Disconnect when done
|
|
129
|
+
subscriber.disconnect();
|
|
130
|
+
```
|
|
131
|
+
|
|
82
132
|
### Async Processing (Queue API)
|
|
83
133
|
|
|
84
134
|
For video generation jobs, use the queue API to submit jobs and poll for results:
|
|
@@ -151,12 +201,12 @@ pnpm install
|
|
|
151
201
|
|
|
152
202
|
1. **Version bump**: Run `pnpm release` to bump the version (this uses `bumpp` to create a new version tag) and push it to GitHub
|
|
153
203
|
2. **Automated publish**: The GitHub Actions workflow will:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
204
|
+
- Build the project
|
|
205
|
+
- Publish to npm
|
|
206
|
+
- Create a GitHub release with changelog
|
|
157
207
|
|
|
158
208
|
The package is published to npm as `@decartai/sdk`.
|
|
159
209
|
|
|
160
210
|
## License
|
|
161
211
|
|
|
162
|
-
MIT
|
|
212
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { ProcessClient } from "./process/client.js";
|
|
|
5
5
|
import { JobStatus, JobStatusResponse, JobSubmitResponse, QueueJobResult, QueueSubmitAndPollOptions, QueueSubmitOptions } from "./queue/types.js";
|
|
6
6
|
import { QueueClient } from "./queue/client.js";
|
|
7
7
|
import { DecartSDKError, ERROR_CODES } from "./utils/errors.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { ClientSessionConnectionBreakdownEvent, ClientSessionConnectionBreakdownPhase, DiagnosticEvent, DiagnosticEventName, DiagnosticEvents, ReconnectEvent, VideoStallEvent } from "./realtime/observability/diagnostics.js";
|
|
9
|
+
import { WebRTCStats } from "./realtime/observability/webrtc-stats.js";
|
|
10
|
+
import { ConnectionState, GenerationEndedMessage, QueuePosition, QueuePositionMessage } from "./realtime/types.js";
|
|
10
11
|
import { SetInput } from "./realtime/methods.js";
|
|
11
|
-
import { RealTimeSubscribeClient, SubscribeEvents, SubscribeOptions } from "./realtime/subscribe-client.js";
|
|
12
|
-
import { WebRTCStats } from "./realtime/webrtc-stats.js";
|
|
13
12
|
import { Events, RealTimeClient, RealTimeClientConnectOptions, RealTimeClientInitialState } from "./realtime/client.js";
|
|
13
|
+
import { RealTimeSubscribeClient, SubscribeEvents, SubscribeOptions } from "./realtime/subscribe-client.js";
|
|
14
14
|
import { ModelState } from "./shared/types.js";
|
|
15
15
|
import { CreateTokenOptions, CreateTokenResponse, TokensClient } from "./tokens/client.js";
|
|
16
16
|
|
|
@@ -42,6 +42,8 @@ type DecartClientOptions = {
|
|
|
42
42
|
* @param options.realtimeBaseUrl - Override the default WebSocket base URL for realtime connections.
|
|
43
43
|
* @param options.integration - Optional integration identifier.
|
|
44
44
|
*
|
|
45
|
+
* Realtime media uses LiveKit only (inference must enable it in `TRANSPORTS_ENABLED`).
|
|
46
|
+
*
|
|
45
47
|
* @example
|
|
46
48
|
* ```ts
|
|
47
49
|
* // (direct API access)Option 1: Explicit API key
|
|
@@ -134,4 +136,4 @@ declare const createDecartClient: (options?: DecartClientOptions) => {
|
|
|
134
136
|
tokens: TokensClient;
|
|
135
137
|
};
|
|
136
138
|
//#endregion
|
|
137
|
-
export { type CanonicalModel, type
|
|
139
|
+
export { type CanonicalModel, type ClientSessionConnectionBreakdownEvent, type ClientSessionConnectionBreakdownPhase, type ConnectionState, type CreateTokenOptions, type CreateTokenResponse, type CustomModelDefinition, DecartClientOptions, type DecartSDKError, type DiagnosticEvent, type DiagnosticEventName, type DiagnosticEvents, ERROR_CODES, type FileInput, type GenerationEndedMessage, type ImageModelDefinition, type ImageModels, type JobStatus, type JobStatusResponse, type JobSubmitResponse, type ListedModelDefinition, type LogLevel, type Logger, type Model, type ModelDefinition, type ModelKind, type ModelState, type ProcessClient, type ProcessOptions, type QueueClient, type QueueJobResult, type QueuePosition, type QueuePositionMessage, type QueueSubmitAndPollOptions, type QueueSubmitOptions, type ReactNativeFile, type RealTimeClient, type RealTimeClientConnectOptions, type RealTimeClientInitialState, type Events as RealTimeEvents, type RealTimeModels, type RealTimeSubscribeClient, type ReconnectEvent, type SetInput, type SubscribeEvents, type SubscribeOptions, type TokensClient, type VideoModelDefinition, type VideoModels, type VideoStallEvent, type WebRTCStats, createConsoleLogger, createDecartClient, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, noopLogger, resolveCanonicalModelAlias, resolveModelAlias };
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,12 @@ import { ERROR_CODES, createInvalidApiKeyError, createInvalidBaseUrlError } from
|
|
|
2
2
|
import { createProcessClient } from "./process/client.js";
|
|
3
3
|
import { createQueueClient } from "./queue/client.js";
|
|
4
4
|
import { isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, resolveCanonicalModelAlias, resolveModelAlias } from "./shared/model.js";
|
|
5
|
+
import { createConsoleLogger, noopLogger } from "./utils/logger.js";
|
|
5
6
|
import { createRealTimeClient } from "./realtime/client.js";
|
|
7
|
+
import { createRealTimeSubscribeClient } from "./realtime/subscribe-client.js";
|
|
6
8
|
import { createTokensClient } from "./tokens/client.js";
|
|
7
9
|
import { readEnv } from "./utils/env.js";
|
|
8
|
-
import { createConsoleLogger, noopLogger } from "./utils/logger.js";
|
|
9
10
|
import { z } from "zod";
|
|
10
|
-
|
|
11
11
|
//#region src/index.ts
|
|
12
12
|
const proxySchema = z.union([z.string().url(), z.string().startsWith("/")]);
|
|
13
13
|
const decartClientOptionsSchema = z.object({
|
|
@@ -31,6 +31,8 @@ const decartClientOptionsSchema = z.object({
|
|
|
31
31
|
* @param options.realtimeBaseUrl - Override the default WebSocket base URL for realtime connections.
|
|
32
32
|
* @param options.integration - Optional integration identifier.
|
|
33
33
|
*
|
|
34
|
+
* Realtime media uses LiveKit only (inference must enable it in `TRANSPORTS_ENABLED`).
|
|
35
|
+
*
|
|
34
36
|
* @example
|
|
35
37
|
* ```ts
|
|
36
38
|
* // (direct API access)Option 1: Explicit API key
|
|
@@ -59,33 +61,46 @@ const createDecartClient = (options = {}) => {
|
|
|
59
61
|
if (isProxyMode && "proxy" in parsedOptions.data && parsedOptions.data.proxy) baseUrl = parsedOptions.data.proxy;
|
|
60
62
|
else baseUrl = parsedOptions.data.baseUrl || "https://api.decart.ai";
|
|
61
63
|
const { integration } = parsedOptions.data;
|
|
62
|
-
const logger = "logger" in options && options.logger ? options.logger :
|
|
63
|
-
const telemetryEnabled = "telemetry" in options && options.telemetry === false
|
|
64
|
+
const logger = "logger" in options && options.logger ? options.logger : createConsoleLogger("info");
|
|
65
|
+
const telemetryEnabled = !("telemetry" in options && options.telemetry === false);
|
|
66
|
+
const wsBaseUrl = parsedOptions.data.realtimeBaseUrl || "wss://api3.decart.ai";
|
|
67
|
+
const realtimePublish = createRealTimeClient({
|
|
68
|
+
baseUrl: wsBaseUrl,
|
|
69
|
+
apiKey: apiKey || "",
|
|
70
|
+
integration,
|
|
71
|
+
logger,
|
|
72
|
+
telemetryEnabled
|
|
73
|
+
});
|
|
74
|
+
const realtimeSubscribe = createRealTimeSubscribeClient({
|
|
75
|
+
baseUrl: isProxyMode || parsedOptions.data.baseUrl !== void 0 ? baseUrl : wsBaseUrl.replace(/^wss?:\/\//i, "https://"),
|
|
76
|
+
apiKey: apiKey || "",
|
|
77
|
+
integration,
|
|
78
|
+
logger
|
|
79
|
+
});
|
|
80
|
+
const process = createProcessClient({
|
|
81
|
+
baseUrl,
|
|
82
|
+
apiKey: apiKey || "",
|
|
83
|
+
integration
|
|
84
|
+
});
|
|
85
|
+
const queue = createQueueClient({
|
|
86
|
+
baseUrl,
|
|
87
|
+
apiKey: apiKey || "",
|
|
88
|
+
integration
|
|
89
|
+
});
|
|
90
|
+
const tokens = createTokensClient({
|
|
91
|
+
baseUrl,
|
|
92
|
+
apiKey: apiKey || "",
|
|
93
|
+
integration
|
|
94
|
+
});
|
|
64
95
|
return {
|
|
65
|
-
realtime:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
process: createProcessClient({
|
|
73
|
-
baseUrl,
|
|
74
|
-
apiKey: apiKey || "",
|
|
75
|
-
integration
|
|
76
|
-
}),
|
|
77
|
-
queue: createQueueClient({
|
|
78
|
-
baseUrl,
|
|
79
|
-
apiKey: apiKey || "",
|
|
80
|
-
integration
|
|
81
|
-
}),
|
|
82
|
-
tokens: createTokensClient({
|
|
83
|
-
baseUrl,
|
|
84
|
-
apiKey: apiKey || "",
|
|
85
|
-
integration
|
|
86
|
-
})
|
|
96
|
+
realtime: {
|
|
97
|
+
connect: realtimePublish.connect,
|
|
98
|
+
subscribe: realtimeSubscribe.subscribe
|
|
99
|
+
},
|
|
100
|
+
process,
|
|
101
|
+
queue,
|
|
102
|
+
tokens
|
|
87
103
|
};
|
|
88
104
|
};
|
|
89
|
-
|
|
90
105
|
//#endregion
|
|
91
|
-
export { ERROR_CODES, createConsoleLogger, createDecartClient, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, noopLogger, resolveCanonicalModelAlias, resolveModelAlias };
|
|
106
|
+
export { ERROR_CODES, createConsoleLogger, createDecartClient, isCanonicalModel, isImageModel, isModel, isRealtimeModel, isVideoModel, listModels, modelAliases, models, noopLogger, resolveCanonicalModelAlias, resolveModelAlias };
|
package/dist/process/client.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createInvalidInputError } from "../utils/errors.js";
|
|
2
2
|
import { fileInputToBlob } from "../shared/request.js";
|
|
3
3
|
import { sendRequest } from "./request.js";
|
|
4
|
-
|
|
5
4
|
//#region src/process/client.ts
|
|
6
5
|
const createProcessClient = (opts) => {
|
|
7
6
|
const { apiKey, baseUrl, integration } = opts;
|
|
@@ -23,6 +22,5 @@ const createProcessClient = (opts) => {
|
|
|
23
22
|
};
|
|
24
23
|
return _process;
|
|
25
24
|
};
|
|
26
|
-
|
|
27
25
|
//#endregion
|
|
28
|
-
export { createProcessClient };
|
|
26
|
+
export { createProcessClient };
|
package/dist/process/request.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createSDKError } from "../utils/errors.js";
|
|
2
2
|
import { buildAuthHeaders, buildFormData } from "../shared/request.js";
|
|
3
|
-
|
|
4
3
|
//#region src/process/request.ts
|
|
5
4
|
async function sendRequest({ baseUrl, apiKey, model, inputs, signal, integration }) {
|
|
6
5
|
const formData = buildFormData(inputs);
|
|
@@ -21,6 +20,5 @@ async function sendRequest({ baseUrl, apiKey, model, inputs, signal, integration
|
|
|
21
20
|
}
|
|
22
21
|
return response.blob();
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
//#endregion
|
|
26
|
-
export { sendRequest };
|
|
24
|
+
export { sendRequest };
|
package/dist/queue/client.js
CHANGED
|
@@ -2,7 +2,6 @@ import { createInvalidInputError } from "../utils/errors.js";
|
|
|
2
2
|
import { fileInputToBlob } from "../shared/request.js";
|
|
3
3
|
import { pollUntilComplete } from "./polling.js";
|
|
4
4
|
import { getJobContent, getJobStatus, submitJob } from "./request.js";
|
|
5
|
-
|
|
6
5
|
//#region src/queue/client.ts
|
|
7
6
|
const createQueueClient = (opts) => {
|
|
8
7
|
const { apiKey, baseUrl, integration } = opts;
|
|
@@ -68,6 +67,5 @@ const createQueueClient = (opts) => {
|
|
|
68
67
|
submitAndPoll
|
|
69
68
|
};
|
|
70
69
|
};
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
|
-
export { createQueueClient };
|
|
71
|
+
export { createQueueClient };
|
package/dist/queue/polling.js
CHANGED
package/dist/queue/request.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createQueueResultError, createQueueStatusError, createQueueSubmitError } from "../utils/errors.js";
|
|
2
2
|
import { buildAuthHeaders, buildFormData } from "../shared/request.js";
|
|
3
|
-
|
|
4
3
|
//#region src/queue/request.ts
|
|
5
4
|
/**
|
|
6
5
|
* Submit a job to the queue.
|
|
@@ -68,6 +67,5 @@ async function getJobContent({ baseUrl, apiKey, jobId, signal, integration }) {
|
|
|
68
67
|
}
|
|
69
68
|
return response.blob();
|
|
70
69
|
}
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
|
-
export { getJobContent, getJobStatus, submitJob };
|
|
71
|
+
export { getJobContent, getJobStatus, submitJob };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CustomModelDefinition, ModelDefinition } from "../shared/model.js";
|
|
2
2
|
import { DecartSDKError } from "../utils/errors.js";
|
|
3
|
-
import { DiagnosticEvent } from "./diagnostics.js";
|
|
4
|
-
import {
|
|
3
|
+
import { DiagnosticEvent } from "./observability/diagnostics.js";
|
|
4
|
+
import { WebRTCStats } from "./observability/webrtc-stats.js";
|
|
5
|
+
import { ConnectionState, GenerationEnded, GenerationTick, ImageSetOptions, QueuePosition } from "./types.js";
|
|
5
6
|
import { SetInput } from "./methods.js";
|
|
6
|
-
import { WebRTCStats } from "./webrtc-stats.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
|
9
9
|
//#region src/realtime/client.d.ts
|
|
@@ -16,18 +16,27 @@ declare const realTimeClientInitialStateSchema: z.ZodObject<{
|
|
|
16
16
|
image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Blob, Blob>, z.ZodCustom<File, File>, z.ZodString]>>;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
type OnRemoteStreamFn = (stream: MediaStream) => void;
|
|
19
|
+
type OnConnectionChangeFn = (state: ConnectionState) => void;
|
|
20
|
+
type OnQueuePositionFn = (queuePosition: QueuePosition) => void;
|
|
19
21
|
type RealTimeClientInitialState = z.infer<typeof realTimeClientInitialStateSchema>;
|
|
20
22
|
declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
|
|
21
23
|
model: z.ZodObject<{
|
|
22
24
|
name: z.ZodString;
|
|
23
25
|
urlPath: z.ZodString;
|
|
24
26
|
queueUrlPath: z.ZodOptional<z.ZodString>;
|
|
25
|
-
fps: z.ZodNumber
|
|
27
|
+
fps: z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
28
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
ideal: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
exact: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
}, z.core.$strip>]>;
|
|
26
33
|
width: z.ZodNumber;
|
|
27
34
|
height: z.ZodNumber;
|
|
28
35
|
inputSchema: z.ZodOptional<z.ZodAny>;
|
|
29
36
|
}, z.core.$strip>;
|
|
30
37
|
onRemoteStream: z.ZodCustom<OnRemoteStreamFn, OnRemoteStreamFn>;
|
|
38
|
+
onConnectionChange: z.ZodOptional<z.ZodCustom<OnConnectionChangeFn, OnConnectionChangeFn>>;
|
|
39
|
+
onQueuePosition: z.ZodOptional<z.ZodCustom<OnQueuePositionFn, OnQueuePositionFn>>;
|
|
31
40
|
initialState: z.ZodOptional<z.ZodObject<{
|
|
32
41
|
prompt: z.ZodOptional<z.ZodObject<{
|
|
33
42
|
text: z.ZodString;
|
|
@@ -35,18 +44,22 @@ declare const realTimeClientConnectOptionsSchema: z.ZodObject<{
|
|
|
35
44
|
}, z.core.$strip>>;
|
|
36
45
|
image: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<Blob, Blob>, z.ZodCustom<File, File>, z.ZodString]>>;
|
|
37
46
|
}, z.core.$strip>>;
|
|
38
|
-
|
|
47
|
+
queryParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
39
48
|
mirror: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodBoolean]>>;
|
|
49
|
+
resolution: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
"720p": "720p";
|
|
51
|
+
"1080p": "1080p";
|
|
52
|
+
}>>;
|
|
40
53
|
}, z.core.$strip>;
|
|
41
54
|
type RealTimeClientConnectOptions = Omit<z.infer<typeof realTimeClientConnectOptionsSchema>, "model"> & {
|
|
42
55
|
model: ModelDefinition | CustomModelDefinition;
|
|
43
56
|
};
|
|
44
57
|
type Events = {
|
|
45
58
|
connectionChange: ConnectionState;
|
|
59
|
+
queuePosition: QueuePosition;
|
|
46
60
|
error: DecartSDKError;
|
|
47
|
-
generationTick:
|
|
48
|
-
|
|
49
|
-
};
|
|
61
|
+
generationTick: GenerationTick;
|
|
62
|
+
generationEnded: GenerationEnded;
|
|
50
63
|
diagnostic: DiagnosticEvent;
|
|
51
64
|
stats: WebRTCStats;
|
|
52
65
|
};
|
|
@@ -64,11 +77,8 @@ type RealTimeClient = {
|
|
|
64
77
|
off: <K extends keyof Events>(event: K, listener: (data: Events[K]) => void) => void;
|
|
65
78
|
sessionId: string | null;
|
|
66
79
|
subscribeToken: string | null;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
enhance?: boolean;
|
|
70
|
-
timeout?: number;
|
|
71
|
-
}) => Promise<void>;
|
|
80
|
+
getSubscribeToken: () => string | null;
|
|
81
|
+
setImage: (image: Blob | File | string | null, options?: ImageSetOptions) => Promise<void>;
|
|
72
82
|
};
|
|
73
83
|
//#endregion
|
|
74
84
|
export { Events, RealTimeClient, RealTimeClientConnectOptions, RealTimeClientInitialState };
|