@ktfun/pulse-protocol 0.0.4

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.
@@ -0,0 +1,382 @@
1
+ import { z } from "zod";
2
+ export declare const CLIENT_MEDIA_WS_PROTOCOL = "client.media.ws.v1";
3
+ export declare const ClientMediaHelloFrameSchema: z.ZodObject<{
4
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
5
+ type: z.ZodLiteral<"hello">;
6
+ supportedProtocols: z.ZodTuple<[z.ZodLiteral<"client.media.ws.v1">], null>;
7
+ sdkVersion: z.ZodString;
8
+ sessionId: z.ZodString;
9
+ tabId: z.ZodString;
10
+ }, z.core.$strip>;
11
+ export declare const ClientMediaStreamRequestFrameSchema: z.ZodObject<{
12
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
13
+ type: z.ZodLiteral<"stream.request">;
14
+ requestId: z.ZodString;
15
+ }, z.core.$strip>;
16
+ export declare const ClientMediaStreamStopFrameSchema: z.ZodObject<{
17
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
18
+ type: z.ZodLiteral<"stream.stop">;
19
+ }, z.core.$strip>;
20
+ export declare const ClientMediaAckFrameSchema: z.ZodObject<{
21
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
22
+ type: z.ZodLiteral<"ack">;
23
+ streamId: z.ZodString;
24
+ generation: z.ZodNumber;
25
+ seq: z.ZodNumber;
26
+ }, z.core.$strip>;
27
+ export declare const ClientMediaHelloAckFrameSchema: z.ZodObject<{
28
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
29
+ type: z.ZodLiteral<"hello_ack">;
30
+ selectedProtocol: z.ZodLiteral<"client.media.ws.v1">;
31
+ connectionId: z.ZodString;
32
+ }, z.core.$strip>;
33
+ export declare const ClientMediaStreamSourceSchema: z.ZodObject<{
34
+ state: z.ZodEnum<{
35
+ disabled: "disabled";
36
+ idle: "idle";
37
+ offline: "offline";
38
+ ready: "ready";
39
+ }>;
40
+ }, z.core.$strip>;
41
+ export declare const ClientMediaNowPlayingSchema: z.ZodObject<{
42
+ current: z.ZodObject<{
43
+ provider: z.ZodOptional<z.ZodString>;
44
+ providerId: z.ZodOptional<z.ZodString>;
45
+ source: z.ZodOptional<z.ZodString>;
46
+ itemType: z.ZodOptional<z.ZodString>;
47
+ id: z.ZodOptional<z.ZodString>;
48
+ trackId: z.ZodOptional<z.ZodString>;
49
+ title: z.ZodOptional<z.ZodString>;
50
+ artist: z.ZodOptional<z.ZodString>;
51
+ album: z.ZodOptional<z.ZodString>;
52
+ albumArtist: z.ZodOptional<z.ZodString>;
53
+ artworkUrl: z.ZodOptional<z.ZodString>;
54
+ linkUrl: z.ZodOptional<z.ZodString>;
55
+ progressSeconds: z.ZodOptional<z.ZodNumber>;
56
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
57
+ playbackState: z.ZodOptional<z.ZodEnum<{
58
+ paused: "paused";
59
+ playing: "playing";
60
+ }>>;
61
+ trackNumber: z.ZodOptional<z.ZodNumber>;
62
+ discNumber: z.ZodOptional<z.ZodNumber>;
63
+ collectionId: z.ZodOptional<z.ZodString>;
64
+ collectionTitle: z.ZodOptional<z.ZodString>;
65
+ collectionLinkUrl: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$strip>;
67
+ clock: z.ZodOptional<z.ZodObject<{
68
+ mediaProgressSeconds: z.ZodOptional<z.ZodNumber>;
69
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
70
+ updatedAt: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>>;
72
+ playback: z.ZodEnum<{
73
+ paused: "paused";
74
+ playing: "playing";
75
+ }>;
76
+ updatedAt: z.ZodString;
77
+ }, z.core.$strip>;
78
+ export declare const ClientMediaStateFrameSchema: z.ZodObject<{
79
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
80
+ type: z.ZodLiteral<"state">;
81
+ revision: z.ZodNumber;
82
+ updatedAt: z.ZodString;
83
+ media: z.ZodNullable<z.ZodObject<{
84
+ current: z.ZodObject<{
85
+ provider: z.ZodOptional<z.ZodString>;
86
+ providerId: z.ZodOptional<z.ZodString>;
87
+ source: z.ZodOptional<z.ZodString>;
88
+ itemType: z.ZodOptional<z.ZodString>;
89
+ id: z.ZodOptional<z.ZodString>;
90
+ trackId: z.ZodOptional<z.ZodString>;
91
+ title: z.ZodOptional<z.ZodString>;
92
+ artist: z.ZodOptional<z.ZodString>;
93
+ album: z.ZodOptional<z.ZodString>;
94
+ albumArtist: z.ZodOptional<z.ZodString>;
95
+ artworkUrl: z.ZodOptional<z.ZodString>;
96
+ linkUrl: z.ZodOptional<z.ZodString>;
97
+ progressSeconds: z.ZodOptional<z.ZodNumber>;
98
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
99
+ playbackState: z.ZodOptional<z.ZodEnum<{
100
+ paused: "paused";
101
+ playing: "playing";
102
+ }>>;
103
+ trackNumber: z.ZodOptional<z.ZodNumber>;
104
+ discNumber: z.ZodOptional<z.ZodNumber>;
105
+ collectionId: z.ZodOptional<z.ZodString>;
106
+ collectionTitle: z.ZodOptional<z.ZodString>;
107
+ collectionLinkUrl: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strip>;
109
+ clock: z.ZodOptional<z.ZodObject<{
110
+ mediaProgressSeconds: z.ZodOptional<z.ZodNumber>;
111
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
112
+ updatedAt: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strip>>;
114
+ playback: z.ZodEnum<{
115
+ paused: "paused";
116
+ playing: "playing";
117
+ }>;
118
+ updatedAt: z.ZodString;
119
+ }, z.core.$strip>>;
120
+ stream: z.ZodObject<{
121
+ source: z.ZodObject<{
122
+ state: z.ZodEnum<{
123
+ disabled: "disabled";
124
+ idle: "idle";
125
+ offline: "offline";
126
+ ready: "ready";
127
+ }>;
128
+ }, z.core.$strip>;
129
+ }, z.core.$strip>;
130
+ }, z.core.$strip>;
131
+ export declare const ClientMediaStreamAcceptedFrameSchema: z.ZodObject<{
132
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
133
+ type: z.ZodLiteral<"stream.accepted">;
134
+ requestId: z.ZodString;
135
+ stream: z.ZodObject<{
136
+ streamId: z.ZodString;
137
+ generation: z.ZodNumber;
138
+ replay: z.ZodOptional<z.ZodObject<{
139
+ fromSeq: z.ZodNumber;
140
+ availableFromSeq: z.ZodNumber;
141
+ latestSeq: z.ZodNumber;
142
+ }, z.core.$strip>>;
143
+ }, z.core.$strip>;
144
+ }, z.core.$strip>;
145
+ export declare const ClientMediaStreamRejectedFrameSchema: z.ZodObject<{
146
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
147
+ type: z.ZodLiteral<"stream.rejected">;
148
+ requestId: z.ZodString;
149
+ source: z.ZodObject<{
150
+ state: z.ZodEnum<{
151
+ disabled: "disabled";
152
+ idle: "idle";
153
+ offline: "offline";
154
+ ready: "ready";
155
+ }>;
156
+ }, z.core.$strip>;
157
+ }, z.core.$strip>;
158
+ export declare const ClientMediaStreamStoppedFrameSchema: z.ZodObject<{
159
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
160
+ type: z.ZodLiteral<"stream.stopped">;
161
+ }, z.core.$strip>;
162
+ export declare const ClientMediaAudioChunkFrameSchema: z.ZodObject<{
163
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
164
+ type: z.ZodLiteral<"audio.chunk">;
165
+ streamId: z.ZodString;
166
+ generation: z.ZodNumber;
167
+ seq: z.ZodNumber;
168
+ sentAt: z.ZodString;
169
+ durationMs: z.ZodNumber;
170
+ codec: z.ZodEnum<{
171
+ aac: "aac";
172
+ mp3: "mp3";
173
+ opus: "opus";
174
+ "pcm16-wav": "pcm16-wav";
175
+ }>;
176
+ byteLength: z.ZodNumber;
177
+ replayed: z.ZodBoolean;
178
+ }, z.core.$strip>;
179
+ export declare const ClientMediaStreamTransitionFrameSchema: z.ZodObject<{
180
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
181
+ type: z.ZodLiteral<"stream.transition">;
182
+ streamId: z.ZodString;
183
+ fromGeneration: z.ZodNumber;
184
+ toGeneration: z.ZodNumber;
185
+ firstSeq: z.ZodNumber;
186
+ }, z.core.$strip>;
187
+ export declare const ClientMediaStreamEndedFrameSchema: z.ZodObject<{
188
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
189
+ type: z.ZodLiteral<"stream.ended">;
190
+ streamId: z.ZodString;
191
+ generation: z.ZodNumber;
192
+ }, z.core.$strip>;
193
+ export declare const ClientMediaStreamErrorFrameSchema: z.ZodObject<{
194
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
195
+ type: z.ZodLiteral<"stream.error">;
196
+ streamId: z.ZodOptional<z.ZodString>;
197
+ generation: z.ZodOptional<z.ZodNumber>;
198
+ }, z.core.$strip>;
199
+ export declare const ClientMediaErrorFrameSchema: z.ZodObject<{
200
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
201
+ type: z.ZodLiteral<"error">;
202
+ code: z.ZodEnum<{
203
+ hello_required: "hello_required";
204
+ internal_error: "internal_error";
205
+ invalid_frame: "invalid_frame";
206
+ invalid_session: "invalid_session";
207
+ unsupported_protocol: "unsupported_protocol";
208
+ }>;
209
+ message: z.ZodString;
210
+ fatal: z.ZodLiteral<true>;
211
+ }, z.core.$strip>;
212
+ export declare const ClientMediaClientFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
213
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
214
+ type: z.ZodLiteral<"hello">;
215
+ supportedProtocols: z.ZodTuple<[z.ZodLiteral<"client.media.ws.v1">], null>;
216
+ sdkVersion: z.ZodString;
217
+ sessionId: z.ZodString;
218
+ tabId: z.ZodString;
219
+ }, z.core.$strip>, z.ZodObject<{
220
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
221
+ type: z.ZodLiteral<"stream.request">;
222
+ requestId: z.ZodString;
223
+ }, z.core.$strip>, z.ZodObject<{
224
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
225
+ type: z.ZodLiteral<"stream.stop">;
226
+ }, z.core.$strip>, z.ZodObject<{
227
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
228
+ type: z.ZodLiteral<"ack">;
229
+ streamId: z.ZodString;
230
+ generation: z.ZodNumber;
231
+ seq: z.ZodNumber;
232
+ }, z.core.$strip>], "type">;
233
+ export declare const ClientMediaServerFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
234
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
235
+ type: z.ZodLiteral<"hello_ack">;
236
+ selectedProtocol: z.ZodLiteral<"client.media.ws.v1">;
237
+ connectionId: z.ZodString;
238
+ }, z.core.$strip>, z.ZodObject<{
239
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
240
+ type: z.ZodLiteral<"state">;
241
+ revision: z.ZodNumber;
242
+ updatedAt: z.ZodString;
243
+ media: z.ZodNullable<z.ZodObject<{
244
+ current: z.ZodObject<{
245
+ provider: z.ZodOptional<z.ZodString>;
246
+ providerId: z.ZodOptional<z.ZodString>;
247
+ source: z.ZodOptional<z.ZodString>;
248
+ itemType: z.ZodOptional<z.ZodString>;
249
+ id: z.ZodOptional<z.ZodString>;
250
+ trackId: z.ZodOptional<z.ZodString>;
251
+ title: z.ZodOptional<z.ZodString>;
252
+ artist: z.ZodOptional<z.ZodString>;
253
+ album: z.ZodOptional<z.ZodString>;
254
+ albumArtist: z.ZodOptional<z.ZodString>;
255
+ artworkUrl: z.ZodOptional<z.ZodString>;
256
+ linkUrl: z.ZodOptional<z.ZodString>;
257
+ progressSeconds: z.ZodOptional<z.ZodNumber>;
258
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
259
+ playbackState: z.ZodOptional<z.ZodEnum<{
260
+ paused: "paused";
261
+ playing: "playing";
262
+ }>>;
263
+ trackNumber: z.ZodOptional<z.ZodNumber>;
264
+ discNumber: z.ZodOptional<z.ZodNumber>;
265
+ collectionId: z.ZodOptional<z.ZodString>;
266
+ collectionTitle: z.ZodOptional<z.ZodString>;
267
+ collectionLinkUrl: z.ZodOptional<z.ZodString>;
268
+ }, z.core.$strip>;
269
+ clock: z.ZodOptional<z.ZodObject<{
270
+ mediaProgressSeconds: z.ZodOptional<z.ZodNumber>;
271
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
272
+ updatedAt: z.ZodOptional<z.ZodString>;
273
+ }, z.core.$strip>>;
274
+ playback: z.ZodEnum<{
275
+ paused: "paused";
276
+ playing: "playing";
277
+ }>;
278
+ updatedAt: z.ZodString;
279
+ }, z.core.$strip>>;
280
+ stream: z.ZodObject<{
281
+ source: z.ZodObject<{
282
+ state: z.ZodEnum<{
283
+ disabled: "disabled";
284
+ idle: "idle";
285
+ offline: "offline";
286
+ ready: "ready";
287
+ }>;
288
+ }, z.core.$strip>;
289
+ }, z.core.$strip>;
290
+ }, z.core.$strip>, z.ZodObject<{
291
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
292
+ type: z.ZodLiteral<"stream.accepted">;
293
+ requestId: z.ZodString;
294
+ stream: z.ZodObject<{
295
+ streamId: z.ZodString;
296
+ generation: z.ZodNumber;
297
+ replay: z.ZodOptional<z.ZodObject<{
298
+ fromSeq: z.ZodNumber;
299
+ availableFromSeq: z.ZodNumber;
300
+ latestSeq: z.ZodNumber;
301
+ }, z.core.$strip>>;
302
+ }, z.core.$strip>;
303
+ }, z.core.$strip>, z.ZodObject<{
304
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
305
+ type: z.ZodLiteral<"stream.rejected">;
306
+ requestId: z.ZodString;
307
+ source: z.ZodObject<{
308
+ state: z.ZodEnum<{
309
+ disabled: "disabled";
310
+ idle: "idle";
311
+ offline: "offline";
312
+ ready: "ready";
313
+ }>;
314
+ }, z.core.$strip>;
315
+ }, z.core.$strip>, z.ZodObject<{
316
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
317
+ type: z.ZodLiteral<"stream.stopped">;
318
+ }, z.core.$strip>, z.ZodObject<{
319
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
320
+ type: z.ZodLiteral<"audio.chunk">;
321
+ streamId: z.ZodString;
322
+ generation: z.ZodNumber;
323
+ seq: z.ZodNumber;
324
+ sentAt: z.ZodString;
325
+ durationMs: z.ZodNumber;
326
+ codec: z.ZodEnum<{
327
+ aac: "aac";
328
+ mp3: "mp3";
329
+ opus: "opus";
330
+ "pcm16-wav": "pcm16-wav";
331
+ }>;
332
+ byteLength: z.ZodNumber;
333
+ replayed: z.ZodBoolean;
334
+ }, z.core.$strip>, z.ZodObject<{
335
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
336
+ type: z.ZodLiteral<"stream.transition">;
337
+ streamId: z.ZodString;
338
+ fromGeneration: z.ZodNumber;
339
+ toGeneration: z.ZodNumber;
340
+ firstSeq: z.ZodNumber;
341
+ }, z.core.$strip>, z.ZodObject<{
342
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
343
+ type: z.ZodLiteral<"stream.ended">;
344
+ streamId: z.ZodString;
345
+ generation: z.ZodNumber;
346
+ }, z.core.$strip>, z.ZodObject<{
347
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
348
+ type: z.ZodLiteral<"stream.error">;
349
+ streamId: z.ZodOptional<z.ZodString>;
350
+ generation: z.ZodOptional<z.ZodNumber>;
351
+ }, z.core.$strip>, z.ZodObject<{
352
+ protocol: z.ZodLiteral<"client.media.ws.v1">;
353
+ type: z.ZodLiteral<"error">;
354
+ code: z.ZodEnum<{
355
+ hello_required: "hello_required";
356
+ internal_error: "internal_error";
357
+ invalid_frame: "invalid_frame";
358
+ invalid_session: "invalid_session";
359
+ unsupported_protocol: "unsupported_protocol";
360
+ }>;
361
+ message: z.ZodString;
362
+ fatal: z.ZodLiteral<true>;
363
+ }, z.core.$strip>], "type">;
364
+ export type ClientMediaHelloFrame = z.infer<typeof ClientMediaHelloFrameSchema>;
365
+ export type ClientMediaStreamRequestFrame = z.infer<typeof ClientMediaStreamRequestFrameSchema>;
366
+ export type ClientMediaStreamStopFrame = z.infer<typeof ClientMediaStreamStopFrameSchema>;
367
+ export type ClientMediaAckFrame = z.infer<typeof ClientMediaAckFrameSchema>;
368
+ export type ClientMediaHelloAckFrame = z.infer<typeof ClientMediaHelloAckFrameSchema>;
369
+ export type ClientMediaStreamSource = z.infer<typeof ClientMediaStreamSourceSchema>;
370
+ export type ClientMediaNowPlaying = z.infer<typeof ClientMediaNowPlayingSchema>;
371
+ export type ClientMediaStateFrame = z.infer<typeof ClientMediaStateFrameSchema>;
372
+ export type ClientMediaStreamAcceptedFrame = z.infer<typeof ClientMediaStreamAcceptedFrameSchema>;
373
+ export type ClientMediaStreamRejectedFrame = z.infer<typeof ClientMediaStreamRejectedFrameSchema>;
374
+ export type ClientMediaStreamStoppedFrame = z.infer<typeof ClientMediaStreamStoppedFrameSchema>;
375
+ export type ClientMediaAudioChunkFrame = z.infer<typeof ClientMediaAudioChunkFrameSchema>;
376
+ export type ClientMediaStreamTransitionFrame = z.infer<typeof ClientMediaStreamTransitionFrameSchema>;
377
+ export type ClientMediaStreamEndedFrame = z.infer<typeof ClientMediaStreamEndedFrameSchema>;
378
+ export type ClientMediaStreamErrorFrame = z.infer<typeof ClientMediaStreamErrorFrameSchema>;
379
+ export type ClientMediaErrorFrame = z.infer<typeof ClientMediaErrorFrameSchema>;
380
+ export type ClientMediaClientFrame = z.infer<typeof ClientMediaClientFrameSchema>;
381
+ export type ClientMediaServerFrame = z.infer<typeof ClientMediaServerFrameSchema>;
382
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,eAAO,MAAM,2BAA2B;;;;;;;iBAOtC,CAAC;AAEH,eAAO,MAAM,mCAAmC;;;;iBAI9C,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;iBAG3C,CAAC;AAEH,eAAO,MAAM,yBA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
package/dist/media.js ADDED
@@ -0,0 +1,141 @@
1
+ import { z } from "zod";
2
+ import { IsoDateTimeSchema, MediaClockSchema, MediaItemSchema, MediaPlaybackSchema, StreamCodecSchema, } from "./shared";
3
+ export const CLIENT_MEDIA_WS_PROTOCOL = "client.media.ws.v1";
4
+ export const ClientMediaHelloFrameSchema = z.object({
5
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
6
+ type: z.literal("hello"),
7
+ supportedProtocols: z.tuple([z.literal(CLIENT_MEDIA_WS_PROTOCOL)]),
8
+ sdkVersion: z.string().min(1),
9
+ sessionId: z.string().min(1),
10
+ tabId: z.string().min(1),
11
+ });
12
+ export const ClientMediaStreamRequestFrameSchema = z.object({
13
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
14
+ type: z.literal("stream.request"),
15
+ requestId: z.string().min(1),
16
+ });
17
+ export const ClientMediaStreamStopFrameSchema = z.object({
18
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
19
+ type: z.literal("stream.stop"),
20
+ });
21
+ export const ClientMediaAckFrameSchema = z.object({
22
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
23
+ type: z.literal("ack"),
24
+ streamId: z.string().min(1),
25
+ generation: z.number().int().nonnegative(),
26
+ seq: z.number().int().nonnegative(),
27
+ });
28
+ export const ClientMediaHelloAckFrameSchema = z.object({
29
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
30
+ type: z.literal("hello_ack"),
31
+ selectedProtocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
32
+ connectionId: z.string().min(1),
33
+ });
34
+ export const ClientMediaStreamSourceSchema = z.object({
35
+ state: z.enum(["ready", "disabled", "offline", "idle"]),
36
+ });
37
+ export const ClientMediaNowPlayingSchema = z.object({
38
+ current: MediaItemSchema,
39
+ clock: MediaClockSchema.optional(),
40
+ playback: MediaPlaybackSchema,
41
+ updatedAt: IsoDateTimeSchema,
42
+ });
43
+ export const ClientMediaStateFrameSchema = z.object({
44
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
45
+ type: z.literal("state"),
46
+ revision: z.number().int().nonnegative(),
47
+ updatedAt: IsoDateTimeSchema,
48
+ media: ClientMediaNowPlayingSchema.nullable(),
49
+ stream: z.object({
50
+ source: ClientMediaStreamSourceSchema,
51
+ }),
52
+ });
53
+ export const ClientMediaStreamAcceptedFrameSchema = z.object({
54
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
55
+ type: z.literal("stream.accepted"),
56
+ requestId: z.string().min(1),
57
+ stream: z.object({
58
+ streamId: z.string().min(1),
59
+ generation: z.number().int().nonnegative(),
60
+ replay: z
61
+ .object({
62
+ fromSeq: z.number().int().nonnegative(),
63
+ availableFromSeq: z.number().int().nonnegative(),
64
+ latestSeq: z.number().int().nonnegative(),
65
+ })
66
+ .optional(),
67
+ }),
68
+ });
69
+ export const ClientMediaStreamRejectedFrameSchema = z.object({
70
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
71
+ type: z.literal("stream.rejected"),
72
+ requestId: z.string().min(1),
73
+ source: ClientMediaStreamSourceSchema,
74
+ });
75
+ export const ClientMediaStreamStoppedFrameSchema = z.object({
76
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
77
+ type: z.literal("stream.stopped"),
78
+ });
79
+ export const ClientMediaAudioChunkFrameSchema = z.object({
80
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
81
+ type: z.literal("audio.chunk"),
82
+ streamId: z.string().min(1),
83
+ generation: z.number().int().nonnegative(),
84
+ seq: z.number().int().nonnegative(),
85
+ sentAt: IsoDateTimeSchema,
86
+ durationMs: z.number().int().positive(),
87
+ codec: StreamCodecSchema,
88
+ byteLength: z.number().int().nonnegative(),
89
+ replayed: z.boolean(),
90
+ });
91
+ export const ClientMediaStreamTransitionFrameSchema = z.object({
92
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
93
+ type: z.literal("stream.transition"),
94
+ streamId: z.string().min(1),
95
+ fromGeneration: z.number().int().nonnegative(),
96
+ toGeneration: z.number().int().nonnegative(),
97
+ firstSeq: z.number().int().nonnegative(),
98
+ });
99
+ export const ClientMediaStreamEndedFrameSchema = z.object({
100
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
101
+ type: z.literal("stream.ended"),
102
+ streamId: z.string().min(1),
103
+ generation: z.number().int().nonnegative(),
104
+ });
105
+ export const ClientMediaStreamErrorFrameSchema = z.object({
106
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
107
+ type: z.literal("stream.error"),
108
+ streamId: z.string().min(1).optional(),
109
+ generation: z.number().int().nonnegative().optional(),
110
+ });
111
+ export const ClientMediaErrorFrameSchema = z.object({
112
+ protocol: z.literal(CLIENT_MEDIA_WS_PROTOCOL),
113
+ type: z.literal("error"),
114
+ code: z.enum([
115
+ "invalid_frame",
116
+ "hello_required",
117
+ "unsupported_protocol",
118
+ "invalid_session",
119
+ "internal_error",
120
+ ]),
121
+ message: z.string(),
122
+ fatal: z.literal(true),
123
+ });
124
+ export const ClientMediaClientFrameSchema = z.discriminatedUnion("type", [
125
+ ClientMediaHelloFrameSchema,
126
+ ClientMediaStreamRequestFrameSchema,
127
+ ClientMediaStreamStopFrameSchema,
128
+ ClientMediaAckFrameSchema,
129
+ ]);
130
+ export const ClientMediaServerFrameSchema = z.discriminatedUnion("type", [
131
+ ClientMediaHelloAckFrameSchema,
132
+ ClientMediaStateFrameSchema,
133
+ ClientMediaStreamAcceptedFrameSchema,
134
+ ClientMediaStreamRejectedFrameSchema,
135
+ ClientMediaStreamStoppedFrameSchema,
136
+ ClientMediaAudioChunkFrameSchema,
137
+ ClientMediaStreamTransitionFrameSchema,
138
+ ClientMediaStreamEndedFrameSchema,
139
+ ClientMediaStreamErrorFrameSchema,
140
+ ClientMediaErrorFrameSchema,
141
+ ]);