@clockworkdog/cogs-client 3.0.0-alpha.8 → 3.0.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 +20 -9
- package/dist/CogsConnection.d.ts +0 -4
- package/dist/CogsConnection.js +0 -10
- package/dist/browser/index.mjs +1871 -2773
- package/dist/browser/index.umd.js +13 -13
- package/dist/index.d.ts +1 -7
- package/dist/index.js +1 -5
- package/dist/state-based/MediaClipManager.d.ts +66 -0
- package/dist/state-based/MediaClipManager.js +420 -0
- package/dist/state-based/MediaPreloader.d.ts +2 -2
- package/dist/state-based/MediaPreloader.js +10 -3
- package/dist/state-based/SurfaceManager.d.ts +5 -1
- package/dist/state-based/SurfaceManager.js +31 -10
- package/dist/types/MediaSchema.d.ts +19 -13
- package/dist/types/MediaSchema.js +3 -1
- package/dist/utils/device.d.ts +2 -0
- package/dist/utils/device.js +4 -0
- package/dist/utils/getStateAtTime.d.ts +12 -2
- package/dist/utils/getStateAtTime.js +6 -1
- package/dist/utils/modulo.d.ts +6 -0
- package/dist/utils/modulo.js +17 -0
- package/package.json +3 -6
- package/dist/AudioPlayer.d.ts +0 -49
- package/dist/AudioPlayer.js +0 -474
- package/dist/VideoPlayer.d.ts +0 -49
- package/dist/VideoPlayer.js +0 -385
- package/dist/state-based/AudioManager.d.ts +0 -17
- package/dist/state-based/AudioManager.js +0 -114
- package/dist/state-based/ClipManager.d.ts +0 -23
- package/dist/state-based/ClipManager.js +0 -60
- package/dist/state-based/ImageManager.d.ts +0 -9
- package/dist/state-based/ImageManager.js +0 -54
- package/dist/state-based/VideoManager.d.ts +0 -19
- package/dist/state-based/VideoManager.js +0 -215
- package/dist/types/AllMediaClipStatesMessage.d.ts +0 -5
- package/dist/types/AllMediaClipStatesMessage.js +0 -1
- package/dist/types/AudioState.d.ts +0 -39
- package/dist/types/AudioState.js +0 -1
- package/dist/types/MediaClipStateMessage.d.ts +0 -7
- package/dist/types/MediaClipStateMessage.js +0 -1
- package/dist/types/VideoState.d.ts +0 -26
- package/dist/types/VideoState.js +0 -5
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ We'll make an annoying bell that rings every second.
|
|
|
10
10
|
```bash
|
|
11
11
|
mkdir plugins/test-plugin
|
|
12
12
|
```
|
|
13
|
-
1. Create a manifest file at `plugins/test-plugin/cogs-plugin-manifest.json
|
|
13
|
+
1. Create a manifest file at `plugins/test-plugin/cogs-plugin-manifest.json`. This tells COGS about your plugin.
|
|
14
14
|
```json
|
|
15
15
|
{
|
|
16
16
|
"name": "test-plugin",
|
|
@@ -39,7 +39,7 @@ We'll make an annoying bell that rings every second.
|
|
|
39
39
|
</head>
|
|
40
40
|
<body>
|
|
41
41
|
<script type="module">
|
|
42
|
-
const { CogsConnection
|
|
42
|
+
const { CogsConnection } = COGS;
|
|
43
43
|
const manifest = await (await fetch('./cogs-plugin-manifest.json')).json();
|
|
44
44
|
|
|
45
45
|
let interval;
|
|
@@ -148,19 +148,19 @@ module.exports =
|
|
|
148
148
|
#### Browser
|
|
149
149
|
|
|
150
150
|
```js
|
|
151
|
-
const { CogsConnection
|
|
151
|
+
const { CogsConnection } = COGS;
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
#### Javascript
|
|
155
155
|
|
|
156
156
|
```js
|
|
157
|
-
const { CogsConnection
|
|
157
|
+
const { CogsConnection } = require('@clockworkdog/cogs-client');
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
#### Typescript / ES6
|
|
161
161
|
|
|
162
162
|
```ts
|
|
163
|
-
import { CogsConnection
|
|
163
|
+
import { CogsConnection } from '@clockworkdog/cogs-client';
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
### Connect to COGS
|
|
@@ -240,14 +240,25 @@ Add `audio` to `cogs-plugin-manifest.js`:
|
|
|
240
240
|
}
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
Add [
|
|
243
|
+
Add a [SurfaceManager](https://clockwork-dog.github.io/cogs-sdk/javascript/classes/SurfaceManager.html) to your page:
|
|
244
244
|
|
|
245
245
|
```ts
|
|
246
|
-
|
|
246
|
+
import { CogsConnection, SurfaceManager } from '@clockworkdog/cogs-client'
|
|
247
|
+
import * as manifest from './cogs-plugin-manifest.js'; // Requires `"allowJs": true` in `tsconfig.json`
|
|
248
|
+
|
|
249
|
+
const cogsConnection = new CogsConnection(manifest);
|
|
250
|
+
const constructURL = (url: string) => cogsConnection.getAssetUrl(url);
|
|
251
|
+
const surfaceManager = new SurfaceManager(constructURL);
|
|
247
252
|
|
|
248
253
|
// Optional
|
|
249
|
-
|
|
250
|
-
|
|
254
|
+
cogsConnection.addEventListener('message', (message) => {
|
|
255
|
+
if (message.type === 'media_state') {
|
|
256
|
+
// (preferred) Listen to media states
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if ('media_strategy' in message && message.media_strategy === 'events') {
|
|
260
|
+
// Listen to media events
|
|
261
|
+
}
|
|
251
262
|
});
|
|
252
263
|
```
|
|
253
264
|
|
package/dist/CogsConnection.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import ShowPhase from './types/ShowPhase';
|
|
2
2
|
import CogsClientMessage, { MediaClientConfig } from './types/CogsClientMessage';
|
|
3
|
-
import MediaClipStateMessage from './types/MediaClipStateMessage';
|
|
4
|
-
import AllMediaClipStatesMessage from './types/AllMediaClipStatesMessage';
|
|
5
3
|
import { CogsPluginManifest, PluginManifestEventJson } from './types/CogsPluginManifest';
|
|
6
4
|
import * as ManifestTypes from './types/ManifestTypes';
|
|
7
5
|
import { DeepReadonly } from './types/utils';
|
|
@@ -53,8 +51,6 @@ export default class CogsConnection<Manifest extends CogsPluginManifest, DataT e
|
|
|
53
51
|
writableFromClient: true;
|
|
54
52
|
}>>): void;
|
|
55
53
|
getAudioSinkId(audioOutput: string): string | undefined;
|
|
56
|
-
sendInitialMediaClipStates(allMediaClipStates: AllMediaClipStatesMessage): void;
|
|
57
|
-
sendMediaClipState(mediaClipState: MediaClipStateMessage): void;
|
|
58
54
|
sendAudioOutputs(audioOutputs: MediaDeviceInfo[]): void;
|
|
59
55
|
private sendDataStoreItems;
|
|
60
56
|
/**
|
package/dist/CogsConnection.js
CHANGED
|
@@ -195,16 +195,6 @@ export default class CogsConnection {
|
|
|
195
195
|
getAudioSinkId(audioOutput) {
|
|
196
196
|
return audioOutput ? this.audioOutputs?.find(({ label }) => label === audioOutput)?.deviceId : '';
|
|
197
197
|
}
|
|
198
|
-
sendInitialMediaClipStates(allMediaClipStates) {
|
|
199
|
-
if (this.isConnected) {
|
|
200
|
-
this.websocket.send(JSON.stringify({ allMediaClipStates }));
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
sendMediaClipState(mediaClipState) {
|
|
204
|
-
if (this.isConnected) {
|
|
205
|
-
this.websocket.send(JSON.stringify({ mediaClipState }));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
198
|
sendAudioOutputs(audioOutputs) {
|
|
209
199
|
if (this.isConnected) {
|
|
210
200
|
this.websocket.send(JSON.stringify({ audioOutputs }));
|