@clockworkdog/cogs-client 3.0.0-alpha.6 → 3.0.0-alpha.7
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/browser/index.mjs +1308 -1306
- package/dist/browser/index.umd.js +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/state-based/AudioManager.d.ts +1 -1
- package/dist/state-based/AudioManager.js +6 -5
- package/dist/state-based/ClipManager.d.ts +2 -1
- package/dist/state-based/ClipManager.js +3 -1
- package/dist/state-based/ImageManager.d.ts +1 -1
- package/dist/state-based/ImageManager.js +6 -5
- package/dist/state-based/SurfaceManager.d.ts +2 -1
- package/dist/state-based/SurfaceManager.js +7 -4
- package/dist/state-based/VideoManager.d.ts +1 -1
- package/dist/state-based/VideoManager.js +5 -4
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { default as MediaClipStateMessage } from './types/MediaClipStateMes
|
|
|
5
5
|
export type { default as ShowPhase } from './types/ShowPhase';
|
|
6
6
|
export type { default as MediaObjectFit } from './types/MediaObjectFit';
|
|
7
7
|
export * as MediaSchema from './types/MediaSchema';
|
|
8
|
+
export * from './state-based/SurfaceManager';
|
|
8
9
|
export { default as CogsAudioPlayer } from './AudioPlayer';
|
|
9
10
|
export { default as CogsVideoPlayer } from './VideoPlayer';
|
|
10
11
|
export { SurfaceManager } from './state-based/SurfaceManager';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as CogsConnection } from './CogsConnection';
|
|
2
2
|
export * from './CogsConnection';
|
|
3
3
|
export * as MediaSchema from './types/MediaSchema';
|
|
4
|
+
export * from './state-based/SurfaceManager';
|
|
4
5
|
export { default as CogsAudioPlayer } from './AudioPlayer';
|
|
5
6
|
export { default as CogsVideoPlayer } from './VideoPlayer';
|
|
6
7
|
export { SurfaceManager } from './state-based/SurfaceManager';
|
|
@@ -3,7 +3,7 @@ import { ClipManager } from './ClipManager';
|
|
|
3
3
|
export declare class AudioManager extends ClipManager<AudioState> {
|
|
4
4
|
private audioElement?;
|
|
5
5
|
private isSeeking;
|
|
6
|
-
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: AudioState);
|
|
6
|
+
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: AudioState, constructAssetURL: (file: string) => string);
|
|
7
7
|
private updateAudioElement;
|
|
8
8
|
/**
|
|
9
9
|
* Helper function to seek to a specified time.
|
|
@@ -14,8 +14,8 @@ function playbackSmoothing(deltaTime) {
|
|
|
14
14
|
export class AudioManager extends ClipManager {
|
|
15
15
|
audioElement;
|
|
16
16
|
isSeeking = false;
|
|
17
|
-
constructor(surfaceElement, clipElement, state) {
|
|
18
|
-
super(surfaceElement, clipElement, state);
|
|
17
|
+
constructor(surfaceElement, clipElement, state, constructAssetURL) {
|
|
18
|
+
super(surfaceElement, clipElement, state, constructAssetURL);
|
|
19
19
|
this.clipElement = clipElement;
|
|
20
20
|
}
|
|
21
21
|
updateAudioElement() {
|
|
@@ -53,9 +53,10 @@ export class AudioManager extends ClipManager {
|
|
|
53
53
|
if (!currentState || !this.audioElement)
|
|
54
54
|
return;
|
|
55
55
|
const { t, rate, volume } = { ...defaultAudioOptions, ...currentState };
|
|
56
|
-
// this.
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
// this.videoElement.src will be a fully qualified URL
|
|
57
|
+
const assetURL = this.constructAssetURL(this._state.file);
|
|
58
|
+
if (!this.audioElement.src.includes(assetURL)) {
|
|
59
|
+
this.audioElement.src = assetURL;
|
|
59
60
|
}
|
|
60
61
|
if (this.audioElement.volume !== volume) {
|
|
61
62
|
this.audioElement.volume = volume;
|
|
@@ -6,7 +6,8 @@ import { MediaClipState } from '../types/MediaSchema';
|
|
|
6
6
|
export declare abstract class ClipManager<T extends MediaClipState> {
|
|
7
7
|
private surfaceElement;
|
|
8
8
|
protected clipElement: HTMLElement;
|
|
9
|
-
|
|
9
|
+
protected constructAssetURL: (file: string) => string;
|
|
10
|
+
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: T, constructAssetURL: (file: string) => string);
|
|
10
11
|
/**
|
|
11
12
|
* This is the delay to be used in the update loop.
|
|
12
13
|
* It is intended to be dynamic for each loop.
|
|
@@ -6,9 +6,11 @@ const DEFAULT_DELAY = 1_000;
|
|
|
6
6
|
export class ClipManager {
|
|
7
7
|
surfaceElement;
|
|
8
8
|
clipElement;
|
|
9
|
-
|
|
9
|
+
constructAssetURL;
|
|
10
|
+
constructor(surfaceElement, clipElement, state, constructAssetURL) {
|
|
10
11
|
this.surfaceElement = surfaceElement;
|
|
11
12
|
this.clipElement = clipElement;
|
|
13
|
+
this.constructAssetURL = constructAssetURL;
|
|
12
14
|
this._state = state;
|
|
13
15
|
// Allow the class to be constructed, then call the loop
|
|
14
16
|
setTimeout(this.loop);
|
|
@@ -2,7 +2,7 @@ import { ImageState } from '../types/MediaSchema';
|
|
|
2
2
|
import { ClipManager } from './ClipManager';
|
|
3
3
|
export declare class ImageManager extends ClipManager<ImageState> {
|
|
4
4
|
private imageElement?;
|
|
5
|
-
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: ImageState);
|
|
5
|
+
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: ImageState, constructAssetURL: (file: string) => string);
|
|
6
6
|
private updateImageElement;
|
|
7
7
|
protected update(): void;
|
|
8
8
|
destroy(): void;
|
|
@@ -3,8 +3,8 @@ import { getStateAtTime } from '../utils/getStateAtTime';
|
|
|
3
3
|
import { ClipManager } from './ClipManager';
|
|
4
4
|
export class ImageManager extends ClipManager {
|
|
5
5
|
imageElement;
|
|
6
|
-
constructor(surfaceElement, clipElement, state) {
|
|
7
|
-
super(surfaceElement, clipElement, state);
|
|
6
|
+
constructor(surfaceElement, clipElement, state, constructAssetURL) {
|
|
7
|
+
super(surfaceElement, clipElement, state, constructAssetURL);
|
|
8
8
|
this.clipElement = clipElement;
|
|
9
9
|
}
|
|
10
10
|
updateImageElement() {
|
|
@@ -28,9 +28,10 @@ export class ImageManager extends ClipManager {
|
|
|
28
28
|
}
|
|
29
29
|
if (!this.imageElement || !currentState)
|
|
30
30
|
return;
|
|
31
|
-
// this.
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
// this.videoElement.src will be a fully qualified URL
|
|
32
|
+
const assetURL = this.constructAssetURL(this._state.file);
|
|
33
|
+
if (!this.imageElement.src.includes(assetURL)) {
|
|
34
|
+
this.imageElement.src = assetURL;
|
|
34
35
|
}
|
|
35
36
|
if (this.imageElement.style.objectFit !== this._state.fit) {
|
|
36
37
|
this.imageElement.style.objectFit = this._state.fit;
|
|
@@ -6,11 +6,12 @@ export declare const DATA_CLIP_ID = "data-clip-id";
|
|
|
6
6
|
* - Instantiate a ClipManager attached to each respective element
|
|
7
7
|
*/
|
|
8
8
|
export declare class SurfaceManager {
|
|
9
|
+
private constructAssetUrl;
|
|
9
10
|
private _state;
|
|
10
11
|
setState(newState: MediaSurfaceState): void;
|
|
11
12
|
private _element;
|
|
12
13
|
get element(): HTMLDivElement;
|
|
13
14
|
private resources;
|
|
14
|
-
constructor(testState?: MediaSurfaceState);
|
|
15
|
+
constructor(constructAssetUrl: (file: string) => string, testState?: MediaSurfaceState);
|
|
15
16
|
update(): void;
|
|
16
17
|
}
|
|
@@ -8,6 +8,7 @@ export const DATA_CLIP_ID = 'data-clip-id';
|
|
|
8
8
|
* - Instantiate a ClipManager attached to each respective element
|
|
9
9
|
*/
|
|
10
10
|
export class SurfaceManager {
|
|
11
|
+
constructAssetUrl;
|
|
11
12
|
_state = {};
|
|
12
13
|
setState(newState) {
|
|
13
14
|
this._state = newState;
|
|
@@ -18,8 +19,10 @@ export class SurfaceManager {
|
|
|
18
19
|
return this._element;
|
|
19
20
|
}
|
|
20
21
|
resources = {};
|
|
21
|
-
constructor(testState) {
|
|
22
|
+
constructor(constructAssetUrl, testState) {
|
|
23
|
+
this.constructAssetUrl = constructAssetUrl;
|
|
22
24
|
this._element = document.createElement('div');
|
|
25
|
+
this._element.className = 'surface-manager';
|
|
23
26
|
this._element.style.width = '100%';
|
|
24
27
|
this._element.style.height = '100%';
|
|
25
28
|
this._state = testState || {};
|
|
@@ -62,13 +65,13 @@ export class SurfaceManager {
|
|
|
62
65
|
if (!resource.manager) {
|
|
63
66
|
switch (clip.type) {
|
|
64
67
|
case 'image':
|
|
65
|
-
resource.manager = new ImageManager(this._element, resource.element, clip);
|
|
68
|
+
resource.manager = new ImageManager(this._element, resource.element, clip, this.constructAssetUrl);
|
|
66
69
|
break;
|
|
67
70
|
case 'audio':
|
|
68
|
-
resource.manager = new AudioManager(this._element, resource.element, clip);
|
|
71
|
+
resource.manager = new AudioManager(this._element, resource.element, clip, this.constructAssetUrl);
|
|
69
72
|
break;
|
|
70
73
|
case 'video':
|
|
71
|
-
resource.manager = new VideoManager(this._element, resource.element, clip);
|
|
74
|
+
resource.manager = new VideoManager(this._element, resource.element, clip, this.constructAssetUrl);
|
|
72
75
|
break;
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -4,7 +4,7 @@ export declare class VideoManager extends ClipManager<VideoState> {
|
|
|
4
4
|
private videoElement?;
|
|
5
5
|
private isSeeking;
|
|
6
6
|
private timeToIntercept;
|
|
7
|
-
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: VideoState);
|
|
7
|
+
constructor(surfaceElement: HTMLElement, clipElement: HTMLElement, state: VideoState, constructAssetURL: (file: string) => string);
|
|
8
8
|
private updateVideoElement;
|
|
9
9
|
private get videoDuration();
|
|
10
10
|
/**
|
|
@@ -34,8 +34,8 @@ export class VideoManager extends ClipManager {
|
|
|
34
34
|
isSeeking = false;
|
|
35
35
|
// We change playbackRate to intercept the server time of the video and don't change course until we intercept
|
|
36
36
|
timeToIntercept = undefined;
|
|
37
|
-
constructor(surfaceElement, clipElement, state) {
|
|
38
|
-
super(surfaceElement, clipElement, state);
|
|
37
|
+
constructor(surfaceElement, clipElement, state, constructAssetURL) {
|
|
38
|
+
super(surfaceElement, clipElement, state, constructAssetURL);
|
|
39
39
|
this.clipElement = clipElement;
|
|
40
40
|
}
|
|
41
41
|
updateVideoElement() {
|
|
@@ -86,8 +86,9 @@ export class VideoManager extends ClipManager {
|
|
|
86
86
|
return;
|
|
87
87
|
const { t, rate, volume } = { ...defaultVideoOptions, ...currentState };
|
|
88
88
|
// this.videoElement.src will be a fully qualified URL
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const assetURL = this.constructAssetURL(this._state.file);
|
|
90
|
+
if (!this.videoElement.src.includes(assetURL)) {
|
|
91
|
+
this.videoElement.src = assetURL;
|
|
91
92
|
}
|
|
92
93
|
if (this.videoElement.style.objectFit !== this._state.fit) {
|
|
93
94
|
this.videoElement.style.objectFit = this._state.fit;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Connect to COGS to build a custom Media Master",
|
|
4
4
|
"author": "Clockwork Dog <info@clockwork.dog>",
|
|
5
5
|
"homepage": "https://github.com/clockwork-dog/cogs-sdk/tree/main/packages/javascript",
|
|
6
|
-
"version": "3.0.0-alpha.
|
|
6
|
+
"version": "3.0.0-alpha.7",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"cy:generate": "cypress run --e2e"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@clockworkdog/timesync": "^3.0.0-alpha.
|
|
40
|
+
"@clockworkdog/timesync": "^3.0.0-alpha.7",
|
|
41
41
|
"howler": "clockwork-dog/howler.js#fix-looping-clips",
|
|
42
42
|
"reconnecting-websocket": "^4.4.0",
|
|
43
43
|
"zod": "^4.1.13"
|