@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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stinky Computing AB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ # @stinkycomputing/sesame-api-client
2
+
3
+ Official TypeScript/JavaScript client library for the Sesame video production server.
4
+
5
+ ## Features
6
+
7
+ - 🎯 **Full Protobuf API** - Complete type-safe protobuf definitions for all Sesame APIs
8
+ - 🔧 **Command List Helper** - Fluent API for building command lists
9
+ - 🌐 **RPC Client** - WebSocket-based RPC client with automatic reconnection
10
+ - 📦 **Modular Design** - New v1 API with domain-specific modules
11
+ - 🔄 **Backward Compatible** - Supports both legacy and new API structures
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @stinkycomputing/sesame-api-client
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ### Node.js (Full Client with RPC)
22
+
23
+ For Node.js applications that need the full RPC client:
24
+
25
+ ```typescript
26
+ import { SesameClient, CommandList } from '@stinkycomputing/sesame-api-client';
27
+
28
+ // Create client
29
+ const client = new SesameClient(8080);
30
+
31
+ // Build command list
32
+ const cl = new CommandList();
33
+ cl.add_source('my-source', {
34
+ type: 'file',
35
+ path: '/path/to/video.mp4'
36
+ });
37
+ cl.add_compositor('main', 1920, 1080, false);
38
+
39
+ // Execute commands
40
+ await client.execute(cl);
41
+
42
+ // Listen to events
43
+ client.on('status', (status) => {
44
+ console.log('Status update:', status);
45
+ });
46
+ ```
47
+
48
+ ### Browser (Protobuf Types Only)
49
+
50
+ For browser applications that only need protobuf types (e.g., for decoding messages from WebSocket):
51
+
52
+ ```typescript
53
+ import { Sesame } from '@stinkycomputing/sesame-api-client/browser';
54
+
55
+ // Decode a status message received from WebSocket
56
+ const statusBytes = new Uint8Array(data);
57
+ const status = Sesame.PB.StatusMessage.decode(statusBytes);
58
+ const statusObj = Sesame.PB.StatusMessage.toObject(status, { longs: Number });
59
+ console.log('Status:', statusObj);
60
+ ```
61
+
62
+ **Browser entry point (`/browser`) includes:**
63
+ - ✅ Protobuf types (`Sesame`, `sesame`, `Message`)
64
+ - ✅ `CommandList` helper
65
+ - ✅ `SesameBinaryProtocol` utilities
66
+ - ✅ Logger abstraction
67
+ - ❌ No Node.js dependencies (`events`, `ws`)
68
+ - ❌ No `RPCClient` or `SesameConnection` classes
69
+
70
+ ## API Structure
71
+
72
+ ### Legacy API (Sesame.PB)
73
+
74
+ The legacy API uses the `Sesame.PB` namespace:
75
+
76
+ ```typescript
77
+ import { Sesame } from '@stinkycomputing/sesame-api-client';
78
+
79
+ const msg: Sesame.PB.AddSourceMessage = {
80
+ id: 'source1',
81
+ type: Sesame.PB.SourceType.ST_FILE,
82
+ // ...
83
+ };
84
+ ```
85
+
86
+ ### New Modular API (sesame.v1.*)
87
+
88
+ The new API is organized into domain-specific modules:
89
+
90
+ ```typescript
91
+ import { sesame } from '@stinkycomputing/sesame-api-client';
92
+
93
+ const msg: sesame.v1.sources.SourceAddRequest = {
94
+ id: 'source1',
95
+ type: sesame.v1.sources.SourceType.SOURCE_TYPE_FILE,
96
+ // ...
97
+ };
98
+ ```
99
+
100
+ #### Available Modules
101
+
102
+ - `sesame.v1.common` - Common types (Empty, Vec4, PropValue, etc.)
103
+ - `sesame.v1.sources` - Source management
104
+ - `sesame.v1.outputs` - Output management
105
+ - `sesame.v1.compositor` - Compositor and scene graph
106
+ - `sesame.v1.audio` - Audio mixer
107
+ - `sesame.v1.recorder` - Recorder and clips
108
+ - `sesame.v1.jobs` - Background jobs (export/import)
109
+ - `sesame.v1.status` - Status and events
110
+ - `sesame.v1.commands` - Command list system
111
+ - `sesame.v1.rpc` - RPC protocol
112
+
113
+ ## Command List Helper
114
+
115
+ The `CommandList` class provides a fluent API for building command sequences:
116
+
117
+ ```typescript
118
+ const cl = new CommandList();
119
+
120
+ // Add source
121
+ cl.add_source('cam1', {
122
+ type: 'decklink',
123
+ deviceIndex: 0
124
+ });
125
+
126
+ // Add compositor
127
+ cl.add_compositor('main', 1920, 1080, false);
128
+
129
+ // Add node to compositor
130
+ cl.add_node('main', 'cam1-node', 'source', {
131
+ sourceId: 'cam1'
132
+ });
133
+
134
+ // Set properties
135
+ cl.set_property(
136
+ { compositor: 'main', node: 'cam1-node' },
137
+ 'transform',
138
+ 'position',
139
+ { vecValue: { r: 100, g: 100 } }
140
+ );
141
+
142
+ // Transport control
143
+ cl.add_transport_command('cam1', { type: 'play' });
144
+
145
+ // Execute all commands
146
+ await client.execute(cl);
147
+ ```
148
+
149
+ ## Deployment Notes
150
+
151
+ When using this package in a bundled application (e.g., with esbuild):
152
+
153
+ - **Bundle the package**: Include `@stinkycomputing/sesame-api-client` in your bundle for zero-dependency deployment
154
+ - **External native deps**: Only mark native binary modules as external (`ws`, `bufferutil`, `utf-8-validate`)
155
+ - **Production install**: Only `npm install` the native dependencies in production
156
+
157
+ This approach gives you:
158
+ - ✅ Single bundle file with all code
159
+ - ✅ Minimal production dependencies (3 packages)
160
+ - ✅ Fast deployment
161
+ - ✅ No version conflicts
162
+
163
+ ## Publishing
164
+
165
+ The package is published manually to npm from a local machine.
166
+
167
+ ### Prerequisites (one-time setup)
168
+
169
+ 1. Create the `@stinkycomputing` organization on [npmjs.com](https://www.npmjs.com/org/create)
170
+ 2. Log in to npm: `npm login`
171
+
172
+ ### Release process
173
+
174
+ 1. Update the version in `package.json`
175
+ 2. Build: `npm run build`
176
+ 3. Publish:
177
+ - **Stable release:** `npm publish --access public`
178
+ - **Prerelease:** `npm publish --access public --tag alpha` (or `beta`, etc.)
179
+ 4. Commit and tag: `git tag api-client-vX.Y.Z && git push origin api-client-vX.Y.Z`
180
+
181
+ ## License
182
+
183
+ MIT
184
+