@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.
- package/dist/common.d.ts +283 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +92 -0
- package/dist/device.d.ts +864 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +304 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/media.d.ts +382 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +141 -0
- package/dist/page.d.ts +228 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +105 -0
- package/dist/shared.d.ts +107 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +76 -0
- package/package.json +33 -0
package/dist/page.d.ts
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CLIENT_PAGE_WS_PROTOCOL = "client.page.ws.v1";
|
|
3
|
+
export declare const ClientPageTransitionFromSchema: z.ZodObject<{
|
|
4
|
+
fromCanonicalUrl: z.ZodString;
|
|
5
|
+
navigationId: z.ZodString;
|
|
6
|
+
startedAt: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const ClientPageTransitionToSchema: z.ZodObject<{
|
|
9
|
+
toCanonicalUrl: z.ZodString;
|
|
10
|
+
navigationId: z.ZodString;
|
|
11
|
+
startedAt: z.ZodString;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export declare const ClientPageMetadataSchema: z.ZodObject<{
|
|
14
|
+
title: z.ZodOptional<z.ZodString>;
|
|
15
|
+
url: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const ClientPageHelloFrameSchema: z.ZodObject<{
|
|
18
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
19
|
+
type: z.ZodLiteral<"hello">;
|
|
20
|
+
supportedProtocols: z.ZodTuple<[z.ZodLiteral<"client.page.ws.v1">], null>;
|
|
21
|
+
sdkVersion: z.ZodString;
|
|
22
|
+
sessionId: z.ZodString;
|
|
23
|
+
tabId: z.ZodString;
|
|
24
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
title: z.ZodOptional<z.ZodString>;
|
|
26
|
+
url: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
transition: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
fromCanonicalUrl: z.ZodString;
|
|
30
|
+
navigationId: z.ZodString;
|
|
31
|
+
startedAt: z.ZodString;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const ClientPageUpdateFrameSchema: z.ZodObject<{
|
|
35
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
36
|
+
type: z.ZodLiteral<"page.update">;
|
|
37
|
+
seq: z.ZodNumber;
|
|
38
|
+
observedAt: z.ZodString;
|
|
39
|
+
reading: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
scrollY: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
title: z.ZodOptional<z.ZodString>;
|
|
45
|
+
url: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export declare const ClientPageLeaveFrameSchema: z.ZodObject<{
|
|
49
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
50
|
+
type: z.ZodLiteral<"leave">;
|
|
51
|
+
seq: z.ZodNumber;
|
|
52
|
+
observedAt: z.ZodString;
|
|
53
|
+
transition: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
toCanonicalUrl: z.ZodString;
|
|
55
|
+
navigationId: z.ZodString;
|
|
56
|
+
startedAt: z.ZodString;
|
|
57
|
+
}, z.core.$strip>>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export declare const ClientPageHelloAckFrameSchema: z.ZodObject<{
|
|
60
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
61
|
+
type: z.ZodLiteral<"hello_ack">;
|
|
62
|
+
selectedProtocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
63
|
+
connectionId: z.ZodString;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export declare const ClientPageSessionDetailSchema: z.ZodObject<{
|
|
66
|
+
sessionId: z.ZodString;
|
|
67
|
+
tabCount: z.ZodNumber;
|
|
68
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
scrollY: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
lastSeenAt: z.ZodString;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export declare const ClientPageSnapshotSchema: z.ZodObject<{
|
|
75
|
+
revision: z.ZodNumber;
|
|
76
|
+
updatedAt: z.ZodString;
|
|
77
|
+
page: z.ZodObject<{
|
|
78
|
+
canonicalUrl: z.ZodString;
|
|
79
|
+
url: z.ZodOptional<z.ZodString>;
|
|
80
|
+
title: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
sessions: z.ZodObject<{
|
|
83
|
+
totalCount: z.ZodNumber;
|
|
84
|
+
recent: z.ZodArray<z.ZodObject<{
|
|
85
|
+
sessionId: z.ZodString;
|
|
86
|
+
tabCount: z.ZodNumber;
|
|
87
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
88
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
scrollY: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
lastSeenAt: z.ZodString;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export declare const ClientPageSnapshotFrameSchema: z.ZodObject<{
|
|
96
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
97
|
+
type: z.ZodLiteral<"snapshot">;
|
|
98
|
+
snapshot: z.ZodObject<{
|
|
99
|
+
revision: z.ZodNumber;
|
|
100
|
+
updatedAt: z.ZodString;
|
|
101
|
+
page: z.ZodObject<{
|
|
102
|
+
canonicalUrl: z.ZodString;
|
|
103
|
+
url: z.ZodOptional<z.ZodString>;
|
|
104
|
+
title: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
sessions: z.ZodObject<{
|
|
107
|
+
totalCount: z.ZodNumber;
|
|
108
|
+
recent: z.ZodArray<z.ZodObject<{
|
|
109
|
+
sessionId: z.ZodString;
|
|
110
|
+
tabCount: z.ZodNumber;
|
|
111
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
113
|
+
scrollY: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
}, z.core.$strip>>;
|
|
115
|
+
lastSeenAt: z.ZodString;
|
|
116
|
+
}, z.core.$strip>>;
|
|
117
|
+
}, z.core.$strip>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export declare const ClientPageErrorFrameSchema: z.ZodObject<{
|
|
121
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
122
|
+
type: z.ZodLiteral<"error">;
|
|
123
|
+
code: z.ZodEnum<{
|
|
124
|
+
hello_required: "hello_required";
|
|
125
|
+
internal_error: "internal_error";
|
|
126
|
+
invalid_frame: "invalid_frame";
|
|
127
|
+
invalid_session: "invalid_session";
|
|
128
|
+
unsupported_protocol: "unsupported_protocol";
|
|
129
|
+
}>;
|
|
130
|
+
message: z.ZodString;
|
|
131
|
+
fatal: z.ZodLiteral<true>;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
export declare const ClientPageClientFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
134
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
135
|
+
type: z.ZodLiteral<"hello">;
|
|
136
|
+
supportedProtocols: z.ZodTuple<[z.ZodLiteral<"client.page.ws.v1">], null>;
|
|
137
|
+
sdkVersion: z.ZodString;
|
|
138
|
+
sessionId: z.ZodString;
|
|
139
|
+
tabId: z.ZodString;
|
|
140
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
title: z.ZodOptional<z.ZodString>;
|
|
142
|
+
url: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
144
|
+
transition: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
fromCanonicalUrl: z.ZodString;
|
|
146
|
+
navigationId: z.ZodString;
|
|
147
|
+
startedAt: z.ZodString;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
150
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
151
|
+
type: z.ZodLiteral<"page.update">;
|
|
152
|
+
seq: z.ZodNumber;
|
|
153
|
+
observedAt: z.ZodString;
|
|
154
|
+
reading: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
scrollY: z.ZodOptional<z.ZodNumber>;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
title: z.ZodOptional<z.ZodString>;
|
|
160
|
+
url: z.ZodOptional<z.ZodString>;
|
|
161
|
+
}, z.core.$strip>>;
|
|
162
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
163
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
164
|
+
type: z.ZodLiteral<"leave">;
|
|
165
|
+
seq: z.ZodNumber;
|
|
166
|
+
observedAt: z.ZodString;
|
|
167
|
+
transition: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
toCanonicalUrl: z.ZodString;
|
|
169
|
+
navigationId: z.ZodString;
|
|
170
|
+
startedAt: z.ZodString;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
}, z.core.$strip>], "type">;
|
|
173
|
+
export declare const ClientPageServerFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
174
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
175
|
+
type: z.ZodLiteral<"hello_ack">;
|
|
176
|
+
selectedProtocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
177
|
+
connectionId: z.ZodString;
|
|
178
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
179
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
180
|
+
type: z.ZodLiteral<"snapshot">;
|
|
181
|
+
snapshot: z.ZodObject<{
|
|
182
|
+
revision: z.ZodNumber;
|
|
183
|
+
updatedAt: z.ZodString;
|
|
184
|
+
page: z.ZodObject<{
|
|
185
|
+
canonicalUrl: z.ZodString;
|
|
186
|
+
url: z.ZodOptional<z.ZodString>;
|
|
187
|
+
title: z.ZodOptional<z.ZodString>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
sessions: z.ZodObject<{
|
|
190
|
+
totalCount: z.ZodNumber;
|
|
191
|
+
recent: z.ZodArray<z.ZodObject<{
|
|
192
|
+
sessionId: z.ZodString;
|
|
193
|
+
tabCount: z.ZodNumber;
|
|
194
|
+
progress: z.ZodOptional<z.ZodObject<{
|
|
195
|
+
percent: z.ZodOptional<z.ZodNumber>;
|
|
196
|
+
scrollY: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
lastSeenAt: z.ZodString;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
}, z.core.$strip>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
203
|
+
protocol: z.ZodLiteral<"client.page.ws.v1">;
|
|
204
|
+
type: z.ZodLiteral<"error">;
|
|
205
|
+
code: z.ZodEnum<{
|
|
206
|
+
hello_required: "hello_required";
|
|
207
|
+
internal_error: "internal_error";
|
|
208
|
+
invalid_frame: "invalid_frame";
|
|
209
|
+
invalid_session: "invalid_session";
|
|
210
|
+
unsupported_protocol: "unsupported_protocol";
|
|
211
|
+
}>;
|
|
212
|
+
message: z.ZodString;
|
|
213
|
+
fatal: z.ZodLiteral<true>;
|
|
214
|
+
}, z.core.$strip>], "type">;
|
|
215
|
+
export type ClientPageTransitionFrom = z.infer<typeof ClientPageTransitionFromSchema>;
|
|
216
|
+
export type ClientPageTransitionTo = z.infer<typeof ClientPageTransitionToSchema>;
|
|
217
|
+
export type ClientPageMetadata = z.infer<typeof ClientPageMetadataSchema>;
|
|
218
|
+
export type ClientPageHelloFrame = z.infer<typeof ClientPageHelloFrameSchema>;
|
|
219
|
+
export type ClientPageUpdateFrame = z.infer<typeof ClientPageUpdateFrameSchema>;
|
|
220
|
+
export type ClientPageLeaveFrame = z.infer<typeof ClientPageLeaveFrameSchema>;
|
|
221
|
+
export type ClientPageHelloAckFrame = z.infer<typeof ClientPageHelloAckFrameSchema>;
|
|
222
|
+
export type ClientPageSessionDetail = z.infer<typeof ClientPageSessionDetailSchema>;
|
|
223
|
+
export type ClientPageSnapshot = z.infer<typeof ClientPageSnapshotSchema>;
|
|
224
|
+
export type ClientPageSnapshotFrame = z.infer<typeof ClientPageSnapshotFrameSchema>;
|
|
225
|
+
export type ClientPageErrorFrame = z.infer<typeof ClientPageErrorFrameSchema>;
|
|
226
|
+
export type ClientPageClientFrame = z.infer<typeof ClientPageClientFrameSchema>;
|
|
227
|
+
export type ClientPageServerFrame = z.infer<typeof ClientPageServerFrameSchema>;
|
|
228
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAE3D,eAAO,MAAM,8BAA8B;;;;iBAIzC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;iBAIvC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;iBAGnC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBASrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;iBAYtC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;iBAMrC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;iBAKxC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;iBAUxC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;iBAYnC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;iBAYrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAItC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAItC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
|
package/dist/page.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { IsoDateTimeSchema } from "./shared";
|
|
3
|
+
export const CLIENT_PAGE_WS_PROTOCOL = "client.page.ws.v1";
|
|
4
|
+
export const ClientPageTransitionFromSchema = z.object({
|
|
5
|
+
fromCanonicalUrl: z.string().min(1),
|
|
6
|
+
navigationId: z.string().min(1),
|
|
7
|
+
startedAt: IsoDateTimeSchema,
|
|
8
|
+
});
|
|
9
|
+
export const ClientPageTransitionToSchema = z.object({
|
|
10
|
+
toCanonicalUrl: z.string().min(1),
|
|
11
|
+
navigationId: z.string().min(1),
|
|
12
|
+
startedAt: IsoDateTimeSchema,
|
|
13
|
+
});
|
|
14
|
+
export const ClientPageMetadataSchema = z.object({
|
|
15
|
+
title: z.string().min(1).optional(),
|
|
16
|
+
url: z.string().min(1).optional(),
|
|
17
|
+
});
|
|
18
|
+
export const ClientPageHelloFrameSchema = z.object({
|
|
19
|
+
protocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
20
|
+
type: z.literal("hello"),
|
|
21
|
+
supportedProtocols: z.tuple([z.literal(CLIENT_PAGE_WS_PROTOCOL)]),
|
|
22
|
+
sdkVersion: z.string().min(1),
|
|
23
|
+
sessionId: z.string().min(1),
|
|
24
|
+
tabId: z.string().min(1),
|
|
25
|
+
page: ClientPageMetadataSchema.optional(),
|
|
26
|
+
transition: ClientPageTransitionFromSchema.optional(),
|
|
27
|
+
});
|
|
28
|
+
export const ClientPageUpdateFrameSchema = z.object({
|
|
29
|
+
protocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
30
|
+
type: z.literal("page.update"),
|
|
31
|
+
seq: z.number().int().nonnegative(),
|
|
32
|
+
observedAt: IsoDateTimeSchema,
|
|
33
|
+
reading: z
|
|
34
|
+
.object({
|
|
35
|
+
percent: z.number().min(0).max(100).optional(),
|
|
36
|
+
scrollY: z.number().nonnegative().optional(),
|
|
37
|
+
})
|
|
38
|
+
.optional(),
|
|
39
|
+
page: ClientPageMetadataSchema.optional(),
|
|
40
|
+
});
|
|
41
|
+
export const ClientPageLeaveFrameSchema = z.object({
|
|
42
|
+
protocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
43
|
+
type: z.literal("leave"),
|
|
44
|
+
seq: z.number().int().nonnegative(),
|
|
45
|
+
observedAt: IsoDateTimeSchema,
|
|
46
|
+
transition: ClientPageTransitionToSchema.optional(),
|
|
47
|
+
});
|
|
48
|
+
export const ClientPageHelloAckFrameSchema = z.object({
|
|
49
|
+
protocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
50
|
+
type: z.literal("hello_ack"),
|
|
51
|
+
selectedProtocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
52
|
+
connectionId: z.string().min(1),
|
|
53
|
+
});
|
|
54
|
+
export const ClientPageSessionDetailSchema = z.object({
|
|
55
|
+
sessionId: z.string().min(1),
|
|
56
|
+
tabCount: z.number().int().nonnegative(),
|
|
57
|
+
progress: z
|
|
58
|
+
.object({
|
|
59
|
+
percent: z.number().min(0).max(100).optional(),
|
|
60
|
+
scrollY: z.number().nonnegative().optional(),
|
|
61
|
+
})
|
|
62
|
+
.optional(),
|
|
63
|
+
lastSeenAt: IsoDateTimeSchema,
|
|
64
|
+
});
|
|
65
|
+
export const ClientPageSnapshotSchema = z.object({
|
|
66
|
+
revision: z.number().int().nonnegative(),
|
|
67
|
+
updatedAt: IsoDateTimeSchema,
|
|
68
|
+
page: z.object({
|
|
69
|
+
canonicalUrl: z.string().min(1),
|
|
70
|
+
url: z.string().min(1).optional(),
|
|
71
|
+
title: z.string().min(1).optional(),
|
|
72
|
+
}),
|
|
73
|
+
sessions: z.object({
|
|
74
|
+
totalCount: z.number().int().nonnegative(),
|
|
75
|
+
recent: z.array(ClientPageSessionDetailSchema),
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
export const ClientPageSnapshotFrameSchema = z.object({
|
|
79
|
+
protocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
80
|
+
type: z.literal("snapshot"),
|
|
81
|
+
snapshot: ClientPageSnapshotSchema,
|
|
82
|
+
});
|
|
83
|
+
export const ClientPageErrorFrameSchema = z.object({
|
|
84
|
+
protocol: z.literal(CLIENT_PAGE_WS_PROTOCOL),
|
|
85
|
+
type: z.literal("error"),
|
|
86
|
+
code: z.enum([
|
|
87
|
+
"invalid_frame",
|
|
88
|
+
"hello_required",
|
|
89
|
+
"unsupported_protocol",
|
|
90
|
+
"invalid_session",
|
|
91
|
+
"internal_error",
|
|
92
|
+
]),
|
|
93
|
+
message: z.string(),
|
|
94
|
+
fatal: z.literal(true),
|
|
95
|
+
});
|
|
96
|
+
export const ClientPageClientFrameSchema = z.discriminatedUnion("type", [
|
|
97
|
+
ClientPageHelloFrameSchema,
|
|
98
|
+
ClientPageUpdateFrameSchema,
|
|
99
|
+
ClientPageLeaveFrameSchema,
|
|
100
|
+
]);
|
|
101
|
+
export const ClientPageServerFrameSchema = z.discriminatedUnion("type", [
|
|
102
|
+
ClientPageHelloAckFrameSchema,
|
|
103
|
+
ClientPageSnapshotFrameSchema,
|
|
104
|
+
ClientPageErrorFrameSchema,
|
|
105
|
+
]);
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const IsoDateTimeSchema: z.ZodString;
|
|
3
|
+
export declare const ClientUserSchema: z.ZodObject<{
|
|
4
|
+
userId: z.ZodString;
|
|
5
|
+
username: z.ZodOptional<z.ZodString>;
|
|
6
|
+
userAvatar: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export declare const OwnerFocusSchema: z.ZodObject<{
|
|
9
|
+
app: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
id: z.ZodOptional<z.ZodString>;
|
|
11
|
+
name: z.ZodOptional<z.ZodString>;
|
|
12
|
+
category: z.ZodOptional<z.ZodString>;
|
|
13
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
title: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
18
|
+
updatedAt: z.ZodString;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const StreamCodecSchema: z.ZodEnum<{
|
|
21
|
+
aac: "aac";
|
|
22
|
+
mp3: "mp3";
|
|
23
|
+
opus: "opus";
|
|
24
|
+
"pcm16-wav": "pcm16-wav";
|
|
25
|
+
}>;
|
|
26
|
+
export declare const StreamFormatSchema: z.ZodObject<{
|
|
27
|
+
codec: z.ZodEnum<{
|
|
28
|
+
aac: "aac";
|
|
29
|
+
mp3: "mp3";
|
|
30
|
+
opus: "opus";
|
|
31
|
+
"pcm16-wav": "pcm16-wav";
|
|
32
|
+
}>;
|
|
33
|
+
sampleRate: z.ZodNumber;
|
|
34
|
+
channels: z.ZodNumber;
|
|
35
|
+
bitDepth: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export declare const MediaPlaybackSchema: z.ZodEnum<{
|
|
38
|
+
paused: "paused";
|
|
39
|
+
playing: "playing";
|
|
40
|
+
}>;
|
|
41
|
+
export declare const MediaItemSchema: z.ZodObject<{
|
|
42
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
43
|
+
providerId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
source: z.ZodOptional<z.ZodString>;
|
|
45
|
+
itemType: z.ZodOptional<z.ZodString>;
|
|
46
|
+
id: z.ZodOptional<z.ZodString>;
|
|
47
|
+
trackId: z.ZodOptional<z.ZodString>;
|
|
48
|
+
title: z.ZodOptional<z.ZodString>;
|
|
49
|
+
artist: z.ZodOptional<z.ZodString>;
|
|
50
|
+
album: z.ZodOptional<z.ZodString>;
|
|
51
|
+
albumArtist: z.ZodOptional<z.ZodString>;
|
|
52
|
+
artworkUrl: z.ZodOptional<z.ZodString>;
|
|
53
|
+
linkUrl: z.ZodOptional<z.ZodString>;
|
|
54
|
+
progressSeconds: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
playbackState: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
paused: "paused";
|
|
58
|
+
playing: "playing";
|
|
59
|
+
}>>;
|
|
60
|
+
trackNumber: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
discNumber: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
collectionId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
collectionTitle: z.ZodOptional<z.ZodString>;
|
|
64
|
+
collectionLinkUrl: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export declare const MediaClockSchema: z.ZodObject<{
|
|
67
|
+
mediaProgressSeconds: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
durationSeconds: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
export declare const CaptureInfoSchema: z.ZodObject<{
|
|
72
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
73
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
74
|
+
appId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export declare const StreamBlockedReasonSchema: z.ZodEnum<{
|
|
77
|
+
capture_permission_missing: "capture_permission_missing";
|
|
78
|
+
capture_permission_revoked: "capture_permission_revoked";
|
|
79
|
+
capture_source_lost: "capture_source_lost";
|
|
80
|
+
capture_source_unavailable: "capture_source_unavailable";
|
|
81
|
+
native_error: "native_error";
|
|
82
|
+
no_playable_media: "no_playable_media";
|
|
83
|
+
unsupported_app: "unsupported_app";
|
|
84
|
+
}>;
|
|
85
|
+
export declare const DeviceStreamStoppedReasonSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
86
|
+
capture_permission_missing: "capture_permission_missing";
|
|
87
|
+
capture_permission_revoked: "capture_permission_revoked";
|
|
88
|
+
capture_source_lost: "capture_source_lost";
|
|
89
|
+
capture_source_unavailable: "capture_source_unavailable";
|
|
90
|
+
native_error: "native_error";
|
|
91
|
+
no_playable_media: "no_playable_media";
|
|
92
|
+
unsupported_app: "unsupported_app";
|
|
93
|
+
}>, z.ZodEnum<{
|
|
94
|
+
manual_stop: "manual_stop";
|
|
95
|
+
native_shutdown: "native_shutdown";
|
|
96
|
+
}>]>;
|
|
97
|
+
export type ClientUser = z.infer<typeof ClientUserSchema>;
|
|
98
|
+
export type OwnerFocus = z.infer<typeof OwnerFocusSchema>;
|
|
99
|
+
export type StreamCodec = z.infer<typeof StreamCodecSchema>;
|
|
100
|
+
export type StreamFormat = z.infer<typeof StreamFormatSchema>;
|
|
101
|
+
export type MediaPlayback = z.infer<typeof MediaPlaybackSchema>;
|
|
102
|
+
export type MediaItem = z.infer<typeof MediaItemSchema>;
|
|
103
|
+
export type MediaClock = z.infer<typeof MediaClockSchema>;
|
|
104
|
+
export type CaptureInfo = z.infer<typeof CaptureInfoSchema>;
|
|
105
|
+
export type StreamBlockedReason = z.infer<typeof StreamBlockedReasonSchema>;
|
|
106
|
+
export type DeviceStreamStoppedReason = z.infer<typeof DeviceStreamStoppedReasonSchema>;
|
|
107
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB,aAAoB,CAAC;AAEnD,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;iBAe3B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;EAA8C,CAAC;AAE7E,eAAO,MAAM,kBAAkB;;;;;;;;;;iBAK7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;EAAgC,CAAC;AAEjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;iBAqB1B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;EAQpC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;IAG1C,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const IsoDateTimeSchema = z.string().min(1);
|
|
3
|
+
export const ClientUserSchema = z.object({
|
|
4
|
+
userId: z.string().min(1),
|
|
5
|
+
username: z.string().min(1).optional(),
|
|
6
|
+
userAvatar: z.string().min(1).optional(),
|
|
7
|
+
});
|
|
8
|
+
export const OwnerFocusSchema = z.object({
|
|
9
|
+
app: z
|
|
10
|
+
.object({
|
|
11
|
+
id: z.string().min(1).optional(),
|
|
12
|
+
name: z.string().min(1).optional(),
|
|
13
|
+
category: z.string().min(1).optional(),
|
|
14
|
+
icon: z.string().min(1).optional(),
|
|
15
|
+
})
|
|
16
|
+
.optional(),
|
|
17
|
+
window: z
|
|
18
|
+
.object({
|
|
19
|
+
title: z.string().min(1).optional(),
|
|
20
|
+
})
|
|
21
|
+
.optional(),
|
|
22
|
+
updatedAt: IsoDateTimeSchema,
|
|
23
|
+
});
|
|
24
|
+
export const StreamCodecSchema = z.enum(["pcm16-wav", "opus", "aac", "mp3"]);
|
|
25
|
+
export const StreamFormatSchema = z.object({
|
|
26
|
+
codec: StreamCodecSchema,
|
|
27
|
+
sampleRate: z.number().int().positive(),
|
|
28
|
+
channels: z.number().int().positive(),
|
|
29
|
+
bitDepth: z.number().int().positive().optional(),
|
|
30
|
+
});
|
|
31
|
+
export const MediaPlaybackSchema = z.enum(["playing", "paused"]);
|
|
32
|
+
export const MediaItemSchema = z.object({
|
|
33
|
+
provider: z.string().min(1).optional(),
|
|
34
|
+
providerId: z.string().min(1).optional(),
|
|
35
|
+
source: z.string().min(1).optional(),
|
|
36
|
+
itemType: z.string().min(1).optional(),
|
|
37
|
+
id: z.string().min(1).optional(),
|
|
38
|
+
trackId: z.string().min(1).optional(),
|
|
39
|
+
title: z.string().min(1).optional(),
|
|
40
|
+
artist: z.string().min(1).optional(),
|
|
41
|
+
album: z.string().min(1).optional(),
|
|
42
|
+
albumArtist: z.string().min(1).optional(),
|
|
43
|
+
artworkUrl: z.string().min(1).optional(),
|
|
44
|
+
linkUrl: z.string().min(1).optional(),
|
|
45
|
+
progressSeconds: z.number().nonnegative().optional(),
|
|
46
|
+
durationSeconds: z.number().nonnegative().optional(),
|
|
47
|
+
playbackState: MediaPlaybackSchema.optional(),
|
|
48
|
+
trackNumber: z.number().int().nonnegative().optional(),
|
|
49
|
+
discNumber: z.number().int().nonnegative().optional(),
|
|
50
|
+
collectionId: z.string().min(1).optional(),
|
|
51
|
+
collectionTitle: z.string().min(1).optional(),
|
|
52
|
+
collectionLinkUrl: z.string().min(1).optional(),
|
|
53
|
+
});
|
|
54
|
+
export const MediaClockSchema = z.object({
|
|
55
|
+
mediaProgressSeconds: z.number().nonnegative().optional(),
|
|
56
|
+
durationSeconds: z.number().nonnegative().optional(),
|
|
57
|
+
updatedAt: IsoDateTimeSchema.optional(),
|
|
58
|
+
});
|
|
59
|
+
export const CaptureInfoSchema = z.object({
|
|
60
|
+
provider: z.string().min(1).optional(),
|
|
61
|
+
displayName: z.string().min(1).optional(),
|
|
62
|
+
appId: z.string().min(1).optional(),
|
|
63
|
+
});
|
|
64
|
+
export const StreamBlockedReasonSchema = z.enum([
|
|
65
|
+
"no_playable_media",
|
|
66
|
+
"capture_permission_missing",
|
|
67
|
+
"capture_permission_revoked",
|
|
68
|
+
"capture_source_unavailable",
|
|
69
|
+
"capture_source_lost",
|
|
70
|
+
"unsupported_app",
|
|
71
|
+
"native_error",
|
|
72
|
+
]);
|
|
73
|
+
export const DeviceStreamStoppedReasonSchema = z.union([
|
|
74
|
+
StreamBlockedReasonSchema,
|
|
75
|
+
z.enum(["native_shutdown", "manual_stop"]),
|
|
76
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ktfun/pulse-protocol",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"zod": "^4"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "npm:@typescript/native-preview",
|
|
25
|
+
"vitest": "^4.1.6"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsgo -p tsconfig.json",
|
|
29
|
+
"test": "vitest run --passWithNoTests",
|
|
30
|
+
"typecheck": "tsgo -p tsconfig.json --noEmit",
|
|
31
|
+
"pub": "pnpm publish --no-git-checks"
|
|
32
|
+
}
|
|
33
|
+
}
|