@stinkycomputing/sesame-api-client 1.4.0-alpha.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.
@@ -0,0 +1,97 @@
1
+ import { EventEmitter } from 'events';
2
+ import * as protobuf from 'protobufjs/minimal';
3
+ import * as WebSocket from 'ws';
4
+ import { sesame } from './proto/api';
5
+ import { SesameConnection } from './sesame-connection';
6
+ export declare let WS: typeof WebSocket;
7
+ export interface IProtobufType {
8
+ encode(message: any, writer?: protobuf.Writer): protobuf.Writer;
9
+ decode(reader: (protobuf.Reader | Uint8Array), length?: number): any;
10
+ toObject(message: any, options?: protobuf.IConversionOptions): {
11
+ [k: string]: any;
12
+ };
13
+ }
14
+ /**
15
+ * RPC Client options
16
+ * ------------------
17
+ * *Note* - The options inherited from `WebSocket.IClientOptions` are only
18
+ * valid when running in node.js, they have no effect in the browser.
19
+ */
20
+ export interface IClientOptions extends WebSocket.ClientOptions {
21
+ /**
22
+ * Event names to protobuf types, any event assigned a type will have
23
+ * its payload decoded before the event is posted.
24
+ */
25
+ eventTypes?: {
26
+ [topic: number]: IProtobufType;
27
+ };
28
+ /**
29
+ * How long in milliseconds before a message times out, set to `0` to disable.
30
+ * Default = `5 * 1000`.
31
+ */
32
+ sendTimeout?: number;
33
+ }
34
+ /**
35
+ * RPC Client events
36
+ * -----------------
37
+ */
38
+ export interface IClientEvents {
39
+ /**
40
+ * Emitted when the connection closes/opens.
41
+ */
42
+ on(event: 'open' | 'close', listener: () => void): this;
43
+ /**
44
+ * Emitted on error, throws if there is no listener.
45
+ */
46
+ on(event: 'error', listener: (error: Error) => void): this;
47
+ /**
48
+ * RPC event sent by the server. If the event topic is given a type
49
+ * constructor in {@link IClientOptions.eventTypes} the data will
50
+ * be decoded before the event is emitted.
51
+ */
52
+ on(event: 'event', listener: (topic: sesame.v1.common.EventTopic, data?: Uint8Array | {
53
+ [k: string]: any;
54
+ }) => void): this;
55
+ }
56
+ /**
57
+ * RPC Client
58
+ * ----------
59
+ * Can be used in both node.js and the browser. Also see {@link IClientOptions}.
60
+ */
61
+ export declare class RPCClient<T extends protobuf.rpc.Service> extends EventEmitter implements IClientEvents {
62
+ /**
63
+ * Client options, *readonly*.
64
+ */
65
+ readonly options: IClientOptions;
66
+ /**
67
+ * The protobuf service instance which holds all the rpc methods defined in your protocol.
68
+ */
69
+ readonly service: T;
70
+ private connection;
71
+ private eventTypes;
72
+ private messageBuffer;
73
+ private nextSeq;
74
+ private sendTimeout;
75
+ /**
76
+ * @param address The address to the {@link Server}, eg `ws://example.com:8042`.
77
+ * @param service The protocol buffer service class to use, an instance of this
78
+ * will be available as {@link Client.service}.
79
+ */
80
+ constructor(connection: SesameConnection, service: {
81
+ create(rpcImpl: protobuf.RPCImpl): T;
82
+ }, options?: IClientOptions);
83
+ private openHandler;
84
+ private rpcImpl;
85
+ private rpcCallback;
86
+ private writeMessage;
87
+ private flushMessageBuffer;
88
+ private errorHandler;
89
+ private messageHandler;
90
+ private responseHandler;
91
+ private eventHandler;
92
+ }
93
+ /**
94
+ * Default backoff function.
95
+ * ```min(tries*10^2, 10 seconds)```
96
+ */
97
+ //# sourceMappingURL=rpc-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../src/rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AACnC,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,SAAS,MAAM,IAAI,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,IAAI,EAAE,kBAAY,CAAC;AAE1B,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,QAAQ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OAAO,EAAE,CAAC,CAAA;IAE1B,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,WAAW,CAAQ;IAE3B;;;;OAIG;gBACS,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE;QAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,CAAC,CAAA;KAAC,EAAE,OAAO,GAAE,cAAmB;IAcvH,OAAO,CAAC,WAAW,CAKlB;IAED,OAAO,CAAC,OAAO,CA2Bd;IAED,OAAO,CAAC,WAAW,CAalB;IAED,OAAO,CAAC,YAAY,CAInB;YAEa,kBAAkB;IAmBhC,OAAO,CAAC,YAAY,CAMnB;IAED,OAAO,CAAC,cAAc,CAcrB;YAEa,eAAe;IAQ7B,OAAO,CAAC,YAAY;CA0BvB;AAED;;;GAGG"}
@@ -0,0 +1,94 @@
1
+ import { VideoCallback, AudioCallback } from './sesame-connection';
2
+ import { RPCClient } from './rpc-client';
3
+ import { sesame } from './proto/api';
4
+ import { CommandList } from './command-list';
5
+ import { EventEmitter } from 'events';
6
+ import Long from 'long';
7
+ export interface IPlaylist {
8
+ clips: Array<{
9
+ id: number | Long;
10
+ recorderId: string;
11
+ transitionTime?: number;
12
+ speed?: number;
13
+ audioRouting?: any;
14
+ }>;
15
+ }
16
+ export declare enum EaseKind {
17
+ STEPPED = "stepped",
18
+ LINEAR = "linear",
19
+ QUADRATIC_IN = "quadraticIn",
20
+ QUADRATIC_OUT = "quadraticOut",
21
+ QUADRATIC_INOUT = "quadraticInOut",
22
+ CUBIC_IN = "cubicIn",
23
+ CUBIC_OUT = "cubicOut",
24
+ CUBIC_INOUT = "cubicInOut",
25
+ QUARTIC_IN = "quarticIn",
26
+ QUARTIC_OUT = "quarticOut",
27
+ QUARTIC_INOUT = "quarticInOut",
28
+ QUINTIC_IN = "quinticIn",
29
+ QUINTIC_OUT = "quinticOut",
30
+ QUINTIC_INOUT = "quinticInOut",
31
+ SINUSOIDAL_IN = "sinusoidalIn",
32
+ SINUSOIDAL_OUT = "sinusoidalOut",
33
+ SINUSOIDAL_INOUT = "sinusoidalInOut",
34
+ EXPONENTIAL_IN = "exponentialIn",
35
+ EXPONENTIAL_OUT = "exponentialOut",
36
+ EXPONENTIAL_INOUT = "exponentialInOut",
37
+ CIRCULAR_IN = "circularIn",
38
+ CIRCULAR_OUT = "circularOut",
39
+ CIRCULAR_INOUT = "circularInOut",
40
+ BOUNCE_IN = "bounceIn",
41
+ BOUNCE_OUT = "bounceOut",
42
+ BOUNCE_INOUT = "bounceInOut",
43
+ ELASTIC_IN = "elasticIn",
44
+ ELASTIC_OUT = "elasticOut",
45
+ ELASTIC_INOUT = "elasticInOut",
46
+ BACK_IN = "backIn",
47
+ BACK_OUT = "backOut",
48
+ BACK_INOUT = "backInOut"
49
+ }
50
+ interface TopicDataCallback {
51
+ (topic: sesame.v1.common.EventTopic, msg: sesame.v1.status.Event): void;
52
+ }
53
+ interface CallbackMessage {
54
+ (event: string, data: string): void;
55
+ }
56
+ export declare class SesameClient extends EventEmitter {
57
+ private conn;
58
+ private rpc;
59
+ private video_subscription;
60
+ private subscriptions;
61
+ private errorIsLogged;
62
+ onVideoPacket: VideoCallback;
63
+ onAudioPacket: AudioCallback;
64
+ onCallbackMessage: CallbackMessage;
65
+ isConnected(): boolean;
66
+ constructor(portOrUrl: number | string);
67
+ private send_subscriptions;
68
+ get_status(): Promise<sesame.v1.status.Status>;
69
+ get_io_devices(): Promise<sesame.v1.status.IODeviceListResponse>;
70
+ add_video_subscription(id: string): void;
71
+ add_subscription(topic: sesame.v1.common.EventTopic, callback: TopicDataCallback): void;
72
+ getService(): RPCClient<sesame.v1.rpc.SesameAPIService>;
73
+ execute(cl: CommandList): Promise<void>;
74
+ addClip(recorderId: string, clip: sesame.v1.recorder.IRecorderClip): Promise<void>;
75
+ removeClip(recorderId: string, id: number): Promise<void>;
76
+ setMetadata(recorderId: string, metadata: sesame.v1.common.ITransportMetadata): Promise<void>;
77
+ getClips(recorderId: string): Promise<{
78
+ id: number;
79
+ startTime: number;
80
+ endTime: number;
81
+ lockedStart: number;
82
+ lockedEnd: number;
83
+ userTime: number | undefined;
84
+ }[]>;
85
+ getImportClipStatus(): Promise<sesame.v1.jobs.JobListResponse>;
86
+ getExportPlaylistStatus(): Promise<sesame.v1.jobs.JobListResponse>;
87
+ exportPlaylist(playlist: IPlaylist, config: sesame.v1.jobs.IExportConfiguration): Promise<void>;
88
+ importClip(config: sesame.v1.jobs.IImportConfiguration): Promise<sesame.v1.jobs.JobStatusResponse>;
89
+ abortExportJob(jobId: number): Promise<sesame.v1.jobs.JobStatusResponse>;
90
+ abortImportJob(jobId: number): Promise<sesame.v1.jobs.JobStatusResponse>;
91
+ disconnect(): void;
92
+ }
93
+ export {};
94
+ //# sourceMappingURL=sesame-api-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sesame-api-client.d.ts","sourceRoot":"","sources":["../src/sesame-api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAoB,MAAM,qBAAqB,CAAA;AACpF,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,KAAK,CAAC;QACX,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,GAAG,CAAC;KACpB,CAA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E9C,WAAW,IAAI,OAAO;gBAIjB,SAAS,EAAE,MAAM,GAAG,MAAM;IA6DtC,OAAO,CAAC,kBAAkB;IAYb,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;IAK9C,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC;IAKtE,sBAAsB,CAAC,EAAE,EAAE,MAAM;IAKjC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,iBAAiB;IAUhF,UAAU;IAIJ,OAAO,CAAC,EAAE,EAAE,WAAW;IAOvB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,aAAa;IAKlE,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAKzC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB;IAK7E,QAAQ,CAAC,UAAU,EAAE,MAAM;;;;;;;;IAiB3B,mBAAmB;IAKnB,uBAAuB;IAKvB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB;IA6B/E,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,oBAAoB;IAWtD,cAAc,CAAC,KAAK,EAAE,MAAM;IAK5B,cAAc,CAAC,KAAK,EAAE,MAAM;IAKlC,UAAU;CAIlB"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Sesame Binary Protocol - TypeScript Implementation
3
+ *
4
+ * This module provides TypeScript implementation of the Sesame binary protocol
5
+ * for serializing and deserializing multimedia data packets.
6
+ */
7
+ export declare const PROTOCOL_MAGIC = 1297302867;
8
+ export declare const PROTOCOL_VERSION = 1;
9
+ export declare const HEADER_DATA_SIZE = 32;
10
+ export declare const HEADER_CODEC_DATA_SIZE = 24;
11
+ export declare const HEADER_METADATA_SIZE = 64;
12
+ export declare const FLAG_HAS_CODEC_DATA: number;
13
+ export declare const FLAG_HAS_METADATA: number;
14
+ export declare const FLAG_IS_KEYFRAME: number;
15
+ export declare enum PacketType {
16
+ VIDEO_FRAME = 1,
17
+ AUDIO_FRAME = 2,
18
+ RPC = 3,
19
+ MUXED_DATA = 4,
20
+ DECODER_DATA = 5
21
+ }
22
+ export declare enum CodecType {
23
+ VIDEO_VP8 = 1,
24
+ VIDEO_VP9 = 2,
25
+ VIDEO_AVC = 3,
26
+ VIDEO_HEVC = 4,
27
+ VIDEO_AV1 = 5,
28
+ AUDIO_OPUS = 64,
29
+ AUDIO_AAC = 65,
30
+ AUDIO_PCM = 66
31
+ }
32
+ export interface HeaderData {
33
+ magic: number;
34
+ flags: number;
35
+ pts: bigint;
36
+ id: bigint;
37
+ version: number;
38
+ header_size: number;
39
+ type: PacketType;
40
+ reserved: number;
41
+ }
42
+ export interface HeaderCodecData {
43
+ sample_rate: number;
44
+ timebase_num: number;
45
+ timebase_den: number;
46
+ codec_profile: number;
47
+ codec_level: number;
48
+ width: number;
49
+ height: number;
50
+ codec_type: CodecType;
51
+ channels: number;
52
+ bit_depth: number;
53
+ reserved: number;
54
+ }
55
+ export interface HeaderMetadata {
56
+ metadata: string;
57
+ }
58
+ export interface ParsedData {
59
+ valid: boolean;
60
+ header: HeaderData | null;
61
+ metadata: HeaderMetadata | null;
62
+ codec_data: HeaderCodecData | null;
63
+ payload: Uint8Array | null;
64
+ payload_size: number;
65
+ }
66
+ /**
67
+ * Main binary protocol class with static methods for serialization/deserialization
68
+ */
69
+ export declare class SesameBinaryProtocol {
70
+ /**
71
+ * Initialize a header data structure with proper defaults
72
+ */
73
+ static initHeader(type: PacketType, flags: number, pts: bigint, id: bigint): HeaderData;
74
+ /**
75
+ * Calculate the total header size based on flags
76
+ */
77
+ static calculateHeaderSize(flags: number): number;
78
+ /**
79
+ * Validate a header structure
80
+ */
81
+ static validateHeader(header: HeaderData, totalSize: number): boolean;
82
+ /**
83
+ * Serialize data into a Uint8Array buffer
84
+ */
85
+ static serialize(header: HeaderData, metadata?: HeaderMetadata | null, codecData?: HeaderCodecData | null, payload?: Uint8Array | null): Uint8Array | null;
86
+ /**
87
+ * Parse incoming binary data
88
+ */
89
+ static parseData(data: Uint8Array): ParsedData;
90
+ /**
91
+ * Helper: Convert string to fixed-size byte array (null-terminated)
92
+ */
93
+ private static stringToFixedBytes;
94
+ /**
95
+ * Helper: Convert fixed-size byte array to string (null-terminated)
96
+ */
97
+ private static fixedBytesToString;
98
+ }
99
+ //# sourceMappingURL=sesame-binary-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sesame-binary-protocol.d.ts","sourceRoot":"","sources":["../src/sesame-binary-protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,cAAc,aAAa,CAAC;AACzC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAIlC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAGvC,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAGvC,oBAAY,UAAU;IACpB,WAAW,IAAI;IACf,WAAW,IAAI;IACf,GAAG,IAAI;IACP,UAAU,IAAI;IACd,YAAY,IAAI;CACjB;AAED,oBAAY,SAAS;IACnB,SAAS,IAAI;IACb,SAAS,IAAI;IACb,SAAS,IAAI;IACb,UAAU,IAAI;IACd,SAAS,IAAI;IACb,UAAU,KAAK;IACf,SAAS,KAAK;IACd,SAAS,KAAK;CACf;AAID,MAAM,WAAW,UAAU;IACzB,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AAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAyBrE;;OAEG;IACH,MAAM,CAAC,SAAS,CACd,MAAM,EAAE,UAAU,EAClB,QAAQ,GAAE,cAAc,GAAG,IAAW,EACtC,SAAS,GAAE,eAAe,GAAG,IAAW,EACxC,OAAO,GAAE,UAAU,GAAG,IAAW,GAChC,UAAU,GAAG,IAAI;IA4DpB;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;IAmF9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAuBjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAmBlC"}
@@ -0,0 +1,35 @@
1
+ import { EventEmitter } from 'events';
2
+ import WebSocket from 'ws';
3
+ export type VideoCallback = (id: string, data: Uint8Array) => void;
4
+ export type AudioCallback = (id: string, data: Uint8Array) => void;
5
+ export declare function waitForEvent<T>(emitter: EventEmitter, eventName: string | symbol): Promise<T>;
6
+ export interface IConnectionOptions {
7
+ autoConnect: boolean;
8
+ autoReconnect: boolean;
9
+ url: string;
10
+ }
11
+ export declare class SesameConnection extends EventEmitter {
12
+ private socket;
13
+ private active;
14
+ private numRetries;
15
+ private url;
16
+ private autoReconnect;
17
+ constructor(options: IConnectionOptions);
18
+ isConnected(): boolean;
19
+ send(data: Uint8Array): Promise<void>;
20
+ connect(): Promise<void>;
21
+ /**
22
+ * Disconnect from the server.
23
+ */
24
+ disconnect(): Promise<void>;
25
+ private retryHandler;
26
+ private closeHandler;
27
+ private errorHandler;
28
+ private openHandler;
29
+ protected messageHandler: (event: {
30
+ data: any;
31
+ type: string;
32
+ target: WebSocket;
33
+ }) => void;
34
+ }
35
+ //# sourceMappingURL=sesame-connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sesame-connection.d.ts","sourceRoot":"","sources":["../src/sesame-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,SAAS,MAAM,IAAI,CAAC;AAI3B,MAAM,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAEnE,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAC,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAI3F;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,aAAa,CAAiB;gBAE1B,OAAO,EAAE,kBAAkB;IAShC,WAAW,IAAI,OAAO;IAIhB,IAAI,CAAC,IAAI,EAAE,UAAU;IASrB,OAAO;IAoBpB;;OAEG;IACU,UAAU;IAUvB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,WAAW,CAGlB;IAED,SAAS,CAAC,cAAc,GAAI,OAAO;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAC,UAc9E;CACF"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@stinkycomputing/sesame-api-client",
3
+ "version": "1.4.0-alpha.0",
4
+ "description": "Sesame API client library with protobuf definitions and command list helpers",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./browser": {
15
+ "types": "./dist/browser.d.ts",
16
+ "import": "./dist/browser.mjs",
17
+ "require": "./dist/browser.cjs"
18
+ },
19
+ "./proto": {
20
+ "types": "./dist/proto/api.d.ts",
21
+ "import": "./dist/proto/api.js",
22
+ "default": "./dist/proto/api.js"
23
+ }
24
+ },
25
+ "scripts": {
26
+ "build": "npm run compile-proto && npm run build-bundle && npm run build-types",
27
+ "compile-proto": "node scripts/compile-proto.cjs",
28
+ "build-bundle": "node scripts/build.cjs",
29
+ "build-types": "tsc --emitDeclarationOnly",
30
+ "prepublishOnly": "npm run build",
31
+ "test": "echo \"Error: no test specified\" && exit 1"
32
+ },
33
+ "keywords": [
34
+ "sesame",
35
+ "protobuf",
36
+ "api",
37
+ "client",
38
+ "grpc",
39
+ "video",
40
+ "streaming"
41
+ ],
42
+ "author": "Stinky Computing AB",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/stinkydev/sesame.git",
47
+ "directory": "packages/sesame-api-client"
48
+ },
49
+ "files": [
50
+ "dist/**/*",
51
+ "README.md"
52
+ ],
53
+ "dependencies": {
54
+ "protobufjs": "^7.2.2",
55
+ "ws": "^8.13.0",
56
+ "long": "^4.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^20.5.10",
60
+ "@types/ws": "^8.5.4",
61
+ "@types/long": "^4.0.0",
62
+ "typescript": "^5.5.3",
63
+ "protobufjs-cli": "^1.1.1",
64
+ "esbuild": "^0.24.0"
65
+ }
66
+ }
67
+