@serimo/player 0.1.0 → 0.2.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 -8
- package/dist/composition-player.d.ts.map +1 -1
- package/dist/index.js +314 -81
- package/dist/player-audio.d.ts +12 -0
- package/dist/player-audio.d.ts.map +1 -0
- package/dist/player-session.d.ts +15 -3
- package/dist/player-session.d.ts.map +1 -1
- package/dist/renderer-bridge.d.ts.map +1 -1
- package/package.json +23 -23
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ React runtime for mounting frame-based Serimo compositions, seeking Core timelin
|
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
The
|
|
15
|
+
The bootstrap release `@serimo/player@0.1.0` is available on npm. This README follows the current checkout, including changes awaiting the next release; local tarballs provide that checkout's API. See the [npm release runbook](../../docs/guides/npm-releases.md). From the [repository root](../../README.md), use Node.js `>=22.16.0` and npm `>=11.21.1`:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install
|
|
@@ -25,7 +25,7 @@ Build from the root so workspace dependencies such as `@serimo/core` are built b
|
|
|
25
25
|
npx playwright install chromium
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
Pack Player with `npm pack --workspace=@serimo/player --ignore-scripts --pack-destination <existing-absolute-directory>` after building, using an existing directory outside the checkout. Install `serimo-player-0.1.0.tgz` alongside Core's archive and React. Player has external peers `@serimo/core
|
|
28
|
+
Pack Player with `npm pack --workspace=@serimo/player --ignore-scripts --pack-destination <existing-absolute-directory>` after building, using an existing directory outside the checkout. Install `serimo-player-0.1.0.tgz` alongside Core's archive and React. Player has external peers `@serimo/core@0.1.0` and `react@19.3.1`; the browser host supplies `react-dom@19.3.1`, and Core requires `gsap@3.15.0`. Required UI JavaScript and styles are compiled at build time, so the consumer needs neither a private UI package nor a Tailwind compiler. See the [CLI preview setup](../cli/README.md#preview-a-source-composition) for all three archives and the [migration guide](../cli/README.md#migrate-private-runtime-consumers) for older projects.
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
@@ -199,11 +199,13 @@ async function seekToStart(handle: PlayerHandle) {
|
|
|
199
199
|
}
|
|
200
200
|
```
|
|
201
201
|
|
|
202
|
-
| Parameter / member
|
|
203
|
-
|
|
|
204
|
-
| `whenReady()`
|
|
205
|
-
| `seek(frame)`
|
|
206
|
-
| `getComposition()`
|
|
202
|
+
| Parameter / member | Type | Description |
|
|
203
|
+
| :------------------- | :---------------------------------------------- | :--------------------------------------------------------------------------------------------------- |
|
|
204
|
+
| `whenReady()` | `() => Promise<void>` | Resolves after all clip timelines register, optional prepared PCM decodes, and frame 0 is applied. |
|
|
205
|
+
| `seek(frame)` | `(number) => Promise<void>` | **Required** `frame` is a safe integer from `0` through `durationInFrames - 1`; waits for readiness. |
|
|
206
|
+
| `getComposition()` | `() => object` | Returns validated metadata and a detached optional `audio` declaration. |
|
|
207
|
+
| `audio?.play(frame)` | `(number) => Promise<{ originTimeMs: number }>` | Activates and schedules continuous audio from a valid composition frame. |
|
|
208
|
+
| `audio?.pause()` | `() => void` | Immediately stops scheduled audio and cancels pending activation. |
|
|
207
209
|
|
|
208
210
|
Pass an optional `ref` to `CompositionPlayer` to obtain this handle, or access the same methods through the internal Renderer bridge. Readiness rejects if the initial seek fails, the Player unmounts, or timeline registration exceeds **10 seconds**. A handle from a cleaned-up session cannot seek again.
|
|
209
211
|
|
|
@@ -211,6 +213,16 @@ Synchronous composition and adapter errors occur during React render and may be
|
|
|
211
213
|
|
|
212
214
|
Exported types also include `CompositionPlayerProps` (the props accepted by `CompositionPlayer`) and `PlayerHandle`.
|
|
213
215
|
|
|
216
|
+
### Prepared audio and host playback
|
|
217
|
+
|
|
218
|
+
Composition `audio` accepts an existing track object or a nonempty array of tracks. Each `src` passed directly to Player must already resolve to PCM16 WAV at 48 kHz, mono or stereo, within 256 MiB and long enough for its declared track. The unique prepared PCM sources together must fit within 512 MiB. The [CLI host](../cli/README.md#mix-music-and-voiceover) acquires local/public HTTPS media and normalizes it with FFmpeg before mounting. Other hosts must provide equivalent preparation; Player does not include FFmpeg or decode arbitrary compressed sources directly.
|
|
219
|
+
|
|
220
|
+
Readiness fetches and decodes all unique PCM sources without resuming the AudioContext or starting a source. Duplicate source URLs decode once, but every track's duration is checked, including volume zero. A failure rejects the whole session. One AudioContext schedules all sources against one output epoch, with per-track volume and a constant master gain from Core. Mono is duplicated to left/right when another source is stereo. `getComposition()` returns a detached object or array matching the declaration; use `getAudioTracks` from Core or `Array.isArray` before reading track fields.
|
|
221
|
+
|
|
222
|
+
After readiness, invoke `audio.play(frame)` directly in the user's click/keyboard handler, before any asynchronous wait that could consume activation. Playback rejects when activation or an output timestamp cannot be obtained. The returned epoch is an **absolute browser performance timestamp**: a parent subtracts its own `performance.timeOrigin` to start its single integer-frame scheduler. Pause before a manual seek, then play from the chosen frame. Visual `seek()` ticks do not restart sources. Pause, errors and disposal stop every scheduled source; stale activation and its timeout cannot stop or revive a newer generation.
|
|
223
|
+
|
|
224
|
+
Player supplies audio controls; the host owns playback scheduling and terminal behavior. The CLI holds frame N−1 until N/FPS for audio compositions, then pauses, and never seeks frame N. Replacement, failure and unmount fence old handles and dispose audio resources. Silent handles retain their existing three methods without an `audio` member. See the [integration guide](../../docs/guides/composition-player-renderer.md#voiceover-preparation-playback-dan-ekspor) for measured timing and limitations.
|
|
225
|
+
|
|
214
226
|
## Tests and limitations
|
|
215
227
|
|
|
216
228
|
From the repository root, after building dependencies:
|
|
@@ -224,7 +236,7 @@ npm run format:check
|
|
|
224
236
|
|
|
225
237
|
Tests cover invalid inputs, clip layering and frame boundaries, future clips, readiness timeouts, cleanup/remount, React Strict Mode, mapping changes, and browser bridge behavior. The Chromium integration captures `TitleScale` and `TextReveal` through Renderer, compares sequential versus random-seek PNG output, and rejects invalid props or failed asset requests. Pixel-identical output across different browsers, fonts, or operating systems is **not** guaranteed.
|
|
226
238
|
|
|
227
|
-
The [CLI](../cli/README.md#preview-a-source-composition) provides a local source host and playback controls using this runtime.
|
|
239
|
+
The [CLI](../cli/README.md#preview-a-source-composition) provides a local source host and playback controls using this runtime. Player does not load network components. See the [Composition → Player → Renderer guide](../../docs/guides/composition-player-renderer.md) for package boundaries and capture behavior.
|
|
228
240
|
|
|
229
241
|
## Related
|
|
230
242
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition-player.d.ts","sourceRoot":"","sources":["../src/composition-player.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,GAAG,EAMT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,qBAAqB,CAAA;AAG5E,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA;IACnD,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,sBAAsB,KAAK,YAAY,CAAA;AAE/E,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;CACxB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,UAAU,EACV,GAAG,EACJ,EAAE,sBAAsB,+
|
|
1
|
+
{"version":3,"file":"composition-player.d.ts","sourceRoot":"","sources":["../src/composition-player.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,GAAG,EAMT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,qBAAqB,CAAA;AAG5E,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA;IACnD,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,sBAAsB,KAAK,YAAY,CAAA;AAE/E,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C,GAAG,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;CACxB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,UAAU,EACV,GAAG,EACJ,EAAE,sBAAsB,+BA4GxB"}
|
package/dist/index.js
CHANGED
|
@@ -1,58 +1,292 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { validateComposition } from "@serimo/core/composition";
|
|
2
|
+
import { getAudioMixGain, getAudioTracks, validateComposition } from "@serimo/core/composition";
|
|
3
3
|
import { createTimelineRegistry } from "@serimo/core/timeline-registry";
|
|
4
4
|
import { createContext, createElement, forwardRef, isValidElement, useContext, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { getFrameState } from "@serimo/core/clock";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
// src/player-audio.ts
|
|
8
|
+
const MAX_PCM_BYTES = 268435456;
|
|
9
|
+
function inspectPCM(bytes, required) {
|
|
10
|
+
const invalid = () => /* @__PURE__ */ new Error("E_ASSET: prepared audio must be sufficient PCM16 48 kHz mono or stereo WAV");
|
|
11
|
+
if (bytes.byteLength < 44 || bytes.byteLength > MAX_PCM_BYTES) throw invalid();
|
|
12
|
+
const view = new DataView(bytes);
|
|
13
|
+
const text = (offset) => String.fromCharCode(...new Uint8Array(bytes, offset, 4));
|
|
14
|
+
if (text(0) !== "RIFF" || text(8) !== "WAVE" || view.getUint32(4, true) + 8 !== bytes.byteLength) throw invalid();
|
|
15
|
+
let channels = 0;
|
|
16
|
+
let dataBytes = 0;
|
|
17
|
+
for (let offset = 12; offset + 8 <= bytes.byteLength;) {
|
|
18
|
+
const size = view.getUint32(offset + 4, true);
|
|
19
|
+
if (offset + 8 + size > bytes.byteLength) throw invalid();
|
|
20
|
+
if (text(offset) === "fmt ") {
|
|
21
|
+
if (channels || size < 16 || view.getUint16(offset + 8, true) !== 1 || view.getUint32(offset + 12, true) !== 48e3 || view.getUint16(offset + 22, true) !== 16) throw invalid();
|
|
22
|
+
channels = view.getUint16(offset + 10, true);
|
|
23
|
+
if (channels !== 1 && channels !== 2 || view.getUint16(offset + 20, true) !== channels * 2 || view.getUint32(offset + 16, true) !== 48e3 * channels * 2) throw invalid();
|
|
24
|
+
}
|
|
25
|
+
if (text(offset) === "data") {
|
|
26
|
+
if (dataBytes) throw invalid();
|
|
27
|
+
dataBytes = size;
|
|
28
|
+
}
|
|
29
|
+
offset += 8 + size + size % 2;
|
|
30
|
+
}
|
|
31
|
+
const samples = dataBytes / (channels * 2);
|
|
32
|
+
if (!channels || !Number.isSafeInteger(samples) || samples < required) throw invalid();
|
|
33
|
+
return {
|
|
34
|
+
channels,
|
|
35
|
+
samples
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function readPCM(src, signal) {
|
|
39
|
+
const response = await fetch(src, {
|
|
40
|
+
signal,
|
|
41
|
+
credentials: "omit"
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok || !response.body || Number(response.headers.get("content-length") ?? 0) > MAX_PCM_BYTES) throw new Error("E_ASSET: prepared PCM audio unavailable or too large");
|
|
44
|
+
const native = response.clone();
|
|
45
|
+
const reader = response.body.getReader();
|
|
46
|
+
let size = 0;
|
|
47
|
+
try {
|
|
48
|
+
while (true) {
|
|
49
|
+
signal.throwIfAborted();
|
|
50
|
+
const { done, value } = await reader.read();
|
|
51
|
+
if (done) break;
|
|
52
|
+
size += value.byteLength;
|
|
53
|
+
if (size > MAX_PCM_BYTES) throw new Error("E_ASSET: prepared PCM audio exceeds its size limit");
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
await Promise.allSettled([reader.cancel(), native.body?.cancel()]);
|
|
57
|
+
throw error;
|
|
58
|
+
} finally {
|
|
59
|
+
reader.releaseLock();
|
|
60
|
+
}
|
|
61
|
+
const bytes = await native.arrayBuffer();
|
|
62
|
+
if (bytes.byteLength !== size) throw new Error("E_ASSET: prepared PCM byte count changed");
|
|
63
|
+
return bytes;
|
|
64
|
+
}
|
|
65
|
+
function createPlayerAudio(composition, signal) {
|
|
66
|
+
const tracks = getAudioTracks(composition.audio);
|
|
67
|
+
if (!tracks.length) throw new Error("E_ASSET: audio declaration missing");
|
|
68
|
+
const context = new AudioContext({ sampleRate: 48e3 });
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
const activeSignal = AbortSignal.any([signal, controller.signal]);
|
|
71
|
+
const gains = tracks.map((track) => {
|
|
72
|
+
const gain = context.createGain();
|
|
73
|
+
gain.gain.value = track.volume;
|
|
74
|
+
return gain;
|
|
75
|
+
});
|
|
76
|
+
const master = context.createGain();
|
|
77
|
+
master.gain.value = getAudioMixGain(tracks);
|
|
78
|
+
master.channelCountMode = "explicit";
|
|
79
|
+
master.channelInterpretation = "speakers";
|
|
80
|
+
master.connect(context.destination);
|
|
81
|
+
for (const gain of gains) gain.connect(master);
|
|
82
|
+
const sources = /* @__PURE__ */ new Set();
|
|
83
|
+
const buffers = /* @__PURE__ */ new Map();
|
|
84
|
+
let version = 0;
|
|
85
|
+
let disposed = false;
|
|
86
|
+
let closing;
|
|
87
|
+
const pause = () => {
|
|
88
|
+
version++;
|
|
89
|
+
for (const source of sources) {
|
|
90
|
+
source.stop();
|
|
91
|
+
source.disconnect();
|
|
92
|
+
}
|
|
93
|
+
sources.clear();
|
|
94
|
+
};
|
|
95
|
+
activeSignal.addEventListener("abort", pause, { once: true });
|
|
96
|
+
const dispose = () => {
|
|
97
|
+
if (closing) return closing;
|
|
98
|
+
pause();
|
|
99
|
+
disposed = true;
|
|
100
|
+
controller.abort();
|
|
101
|
+
for (const gain of gains) gain.disconnect();
|
|
102
|
+
master.disconnect();
|
|
103
|
+
buffers.clear();
|
|
104
|
+
activeSignal.removeEventListener("abort", pause);
|
|
105
|
+
return closing = context.state === "closed" ? Promise.resolve() : context.close();
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
ready: (async () => {
|
|
109
|
+
activeSignal.throwIfAborted();
|
|
110
|
+
let bytesTotal = 0;
|
|
111
|
+
let channels = 1;
|
|
112
|
+
for (const track of tracks) {
|
|
113
|
+
const required = Math.ceil(track.durationInFrames * 48e3 / composition.fps);
|
|
114
|
+
let decoded = buffers.get(track.src);
|
|
115
|
+
if (!decoded) {
|
|
116
|
+
const bytes = await readPCM(track.src, activeSignal);
|
|
117
|
+
bytesTotal += bytes.byteLength;
|
|
118
|
+
if (bytesTotal > MAX_PCM_BYTES * 2) throw new Error("E_ASSET: prepared PCM audio exceeds its session size limit");
|
|
119
|
+
const pcm = inspectPCM(bytes, required);
|
|
120
|
+
decoded = await context.decodeAudioData(bytes);
|
|
121
|
+
activeSignal.throwIfAborted();
|
|
122
|
+
if (decoded.sampleRate !== 48e3 || decoded.numberOfChannels !== pcm.channels || decoded.length !== pcm.samples) throw new Error("E_ASSET: decoded PCM audio does not match its prepared samples");
|
|
123
|
+
buffers.set(track.src, decoded);
|
|
124
|
+
}
|
|
125
|
+
if (decoded.length < required) throw new Error("E_ASSET: prepared PCM audio is shorter than its declared track");
|
|
126
|
+
channels = Math.max(channels, decoded.numberOfChannels);
|
|
127
|
+
}
|
|
128
|
+
master.channelCount = channels;
|
|
129
|
+
})().catch(async (error) => {
|
|
130
|
+
await dispose();
|
|
131
|
+
if (error instanceof Error && error.message.startsWith("E_ASSET:")) throw error;
|
|
132
|
+
throw new Error("E_ASSET: prepared PCM audio failed to load or decode", { cause: error });
|
|
133
|
+
}),
|
|
134
|
+
pause,
|
|
135
|
+
dispose,
|
|
136
|
+
play(frame) {
|
|
137
|
+
try {
|
|
138
|
+
getFrameState({
|
|
139
|
+
...composition,
|
|
140
|
+
audio: void 0
|
|
141
|
+
}, frame);
|
|
142
|
+
activeSignal.throwIfAborted();
|
|
143
|
+
if (disposed || tracks.some((track) => !buffers.has(track.src))) throw new Error("E_ASSET: audio is not ready");
|
|
144
|
+
} catch (error) {
|
|
145
|
+
return Promise.reject(error);
|
|
146
|
+
}
|
|
147
|
+
pause();
|
|
148
|
+
const generation = version;
|
|
149
|
+
const resume = context.resume();
|
|
150
|
+
return (async () => {
|
|
151
|
+
let timer;
|
|
152
|
+
const check = () => {
|
|
153
|
+
if (generation !== version || disposed || activeSignal.aborted) throw new DOMException("Stale audio playback", "AbortError");
|
|
154
|
+
};
|
|
155
|
+
try {
|
|
156
|
+
const stamp = await Promise.race([resume.then(async () => {
|
|
157
|
+
while (true) {
|
|
158
|
+
check();
|
|
159
|
+
const stamp = context.getOutputTimestamp();
|
|
160
|
+
if (Number.isFinite(stamp.contextTime) && Number.isFinite(stamp.performanceTime) && stamp.contextTime > 0 && stamp.performanceTime > 0) return stamp;
|
|
161
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
162
|
+
}
|
|
163
|
+
}), new Promise((_resolve, reject) => {
|
|
164
|
+
timer = setTimeout(() => {
|
|
165
|
+
if (generation === version) pause();
|
|
166
|
+
reject(/* @__PURE__ */ new Error("E_ASSET: audio activation blocked or output clock unavailable"));
|
|
167
|
+
}, 1e3);
|
|
168
|
+
})]);
|
|
169
|
+
check();
|
|
170
|
+
const start = context.currentTime + .05;
|
|
171
|
+
const seconds = frame / composition.fps;
|
|
172
|
+
for (const [index, track] of tracks.entries()) {
|
|
173
|
+
const offset = Math.max(0, seconds - track.startFrame / composition.fps);
|
|
174
|
+
const remaining = track.durationInFrames / composition.fps - offset;
|
|
175
|
+
if (remaining > 0) {
|
|
176
|
+
const source = context.createBufferSource();
|
|
177
|
+
source.buffer = buffers.get(track.src) ?? null;
|
|
178
|
+
const gain = gains[index];
|
|
179
|
+
if (!gain) throw new Error("E_ASSET: audio gain unavailable");
|
|
180
|
+
source.connect(gain);
|
|
181
|
+
source.onended = () => {
|
|
182
|
+
if (sources.delete(source)) source.disconnect();
|
|
183
|
+
};
|
|
184
|
+
try {
|
|
185
|
+
source.start(start + Math.max(0, track.startFrame / composition.fps - seconds), offset, remaining);
|
|
186
|
+
sources.add(source);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
source.disconnect();
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return { originTimeMs: performance.timeOrigin + stamp.performanceTime + (start - stamp.contextTime) * 1e3 };
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (generation === version) pause();
|
|
196
|
+
throw error;
|
|
197
|
+
} finally {
|
|
198
|
+
clearTimeout(timer);
|
|
199
|
+
}
|
|
200
|
+
})();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
// src/player-session.ts
|
|
8
205
|
function createPlayerSession(composition, registry) {
|
|
9
206
|
let current;
|
|
207
|
+
const stop = () => {
|
|
208
|
+
const active = current;
|
|
209
|
+
current = void 0;
|
|
210
|
+
active?.controller.abort(new DOMException("Player unmounted", "AbortError"));
|
|
211
|
+
return active?.audio?.dispose() ?? Promise.resolve();
|
|
212
|
+
};
|
|
10
213
|
const handle = {
|
|
11
214
|
whenReady() {
|
|
12
215
|
return current?.ready ?? Promise.reject(/* @__PURE__ */ new Error("Player is not mounted"));
|
|
13
216
|
},
|
|
14
217
|
async seek(frame) {
|
|
15
218
|
getFrameState(composition, frame);
|
|
219
|
+
const active = current;
|
|
16
220
|
await handle.whenReady();
|
|
17
|
-
if (!current) throw new Error("Player is not mounted");
|
|
221
|
+
if (!active || current !== active) throw new Error("Player is not mounted");
|
|
222
|
+
active.controller.signal.throwIfAborted();
|
|
18
223
|
registry.seek(frame);
|
|
19
224
|
},
|
|
20
225
|
getComposition() {
|
|
21
|
-
const { id, width, height, fps, durationInFrames } = composition;
|
|
226
|
+
const { id, width, height, fps, durationInFrames, audio } = composition;
|
|
22
227
|
return {
|
|
23
228
|
id,
|
|
24
229
|
width,
|
|
25
230
|
height,
|
|
26
231
|
fps,
|
|
27
|
-
durationInFrames
|
|
232
|
+
durationInFrames,
|
|
233
|
+
...audio ? { audio: Array.isArray(audio) ? audio.map((track) => ({ ...track })) : { ...audio } } : {}
|
|
28
234
|
};
|
|
29
|
-
}
|
|
235
|
+
},
|
|
236
|
+
...composition.audio ? { audio: {
|
|
237
|
+
play(frame) {
|
|
238
|
+
if (!current || current.controller.signal.aborted) return Promise.reject(/* @__PURE__ */ new Error("Player is not mounted"));
|
|
239
|
+
if (!current.audio) return Promise.reject(/* @__PURE__ */ new Error("E_ASSET: audio is not ready"));
|
|
240
|
+
return current.audio.play(frame);
|
|
241
|
+
},
|
|
242
|
+
pause() {
|
|
243
|
+
current?.audio?.pause();
|
|
244
|
+
}
|
|
245
|
+
} } : {}
|
|
30
246
|
};
|
|
31
247
|
return {
|
|
32
248
|
...handle,
|
|
33
249
|
start() {
|
|
34
250
|
const controller = new AbortController();
|
|
251
|
+
stop().catch((error) => controller.abort(error));
|
|
252
|
+
const active = {
|
|
253
|
+
controller,
|
|
254
|
+
ready: Promise.resolve()
|
|
255
|
+
};
|
|
256
|
+
current = active;
|
|
35
257
|
const timeout = setTimeout(() => {
|
|
36
258
|
controller.abort(/* @__PURE__ */ new Error("Player timelines were not ready within 10000ms"));
|
|
37
259
|
}, 1e4);
|
|
38
|
-
const
|
|
260
|
+
const abortReady = () => rejectReady(controller.signal.reason);
|
|
261
|
+
let rejectReady = () => {};
|
|
262
|
+
const cancelled = new Promise((_resolve, reject) => {
|
|
263
|
+
rejectReady = reject;
|
|
264
|
+
});
|
|
265
|
+
controller.signal.addEventListener("abort", abortReady, { once: true });
|
|
266
|
+
const ready = Promise.race([cancelled, Promise.all([registry.whenReady({ signal: controller.signal }), Promise.resolve().then(() => {
|
|
267
|
+
controller.signal.throwIfAborted();
|
|
268
|
+
if (composition.audio) {
|
|
269
|
+
active.audio = createPlayerAudio(composition, controller.signal);
|
|
270
|
+
return active.audio.ready;
|
|
271
|
+
}
|
|
272
|
+
})])]).then(() => {
|
|
39
273
|
controller.signal.throwIfAborted();
|
|
40
274
|
registry.seek(0);
|
|
41
|
-
}).
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
275
|
+
}).catch(async (error) => {
|
|
276
|
+
controller.abort(error);
|
|
277
|
+
await active.audio?.dispose();
|
|
278
|
+
throw error;
|
|
279
|
+
}).finally(() => {
|
|
280
|
+
clearTimeout(timeout);
|
|
281
|
+
controller.signal.removeEventListener("abort", abortReady);
|
|
282
|
+
});
|
|
283
|
+
active.ready = ready;
|
|
46
284
|
return ready;
|
|
47
285
|
},
|
|
48
|
-
stop
|
|
49
|
-
current?.controller.abort(new DOMException("Player unmounted", "AbortError"));
|
|
50
|
-
current = void 0;
|
|
51
|
-
}
|
|
286
|
+
stop
|
|
52
287
|
};
|
|
53
288
|
}
|
|
54
|
-
|
|
55
|
-
//#region ../../node_modules/clsx/dist/clsx.mjs
|
|
289
|
+
// ../../node_modules/clsx/dist/clsx.mjs
|
|
56
290
|
function r(e) {
|
|
57
291
|
var t, f, n = "";
|
|
58
292
|
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
@@ -66,8 +300,7 @@ function clsx() {
|
|
|
66
300
|
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
67
301
|
return n;
|
|
68
302
|
}
|
|
69
|
-
|
|
70
|
-
//#region ../../node_modules/class-variance-authority/dist/index.mjs
|
|
303
|
+
// ../../node_modules/class-variance-authority/dist/index.mjs
|
|
71
304
|
/**
|
|
72
305
|
* Copyright 2022 Joe Bell. All rights reserved.
|
|
73
306
|
*
|
|
@@ -120,8 +353,7 @@ const cva = (base, config) => (props) => {
|
|
|
120
353
|
}, []);
|
|
121
354
|
return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
122
355
|
};
|
|
123
|
-
|
|
124
|
-
//#region ../../node_modules/cn/dist/tables.js
|
|
356
|
+
// ../../node_modules/cn/dist/tables.js
|
|
125
357
|
const P = 48;
|
|
126
358
|
const U = (s, o = 0) => {
|
|
127
359
|
const out = new Int32Array(s.length);
|
|
@@ -248,8 +480,7 @@ var tables_generated_default = {
|
|
|
248
480
|
postfixLookupGroups,
|
|
249
481
|
orderSensitiveModifiers: "* ** after backdrop before details-content file first-letter first-line marker placeholder selection"
|
|
250
482
|
};
|
|
251
|
-
|
|
252
|
-
//#region ../../node_modules/cn/dist/engine.js
|
|
483
|
+
// ../../node_modules/cn/dist/engine.js
|
|
253
484
|
const IS_JSC = "line" in /* @__PURE__ */ new Error();
|
|
254
485
|
const EXTERNAL = -1;
|
|
255
486
|
const DEAD = -1;
|
|
@@ -1276,8 +1507,7 @@ const wrapClsx = (mergeString, fresh) => {
|
|
|
1276
1507
|
return resolveArgs(vals, true);
|
|
1277
1508
|
};
|
|
1278
1509
|
};
|
|
1279
|
-
|
|
1280
|
-
//#region ../../node_modules/cn/dist/index.js
|
|
1510
|
+
// ../../node_modules/cn/dist/index.js
|
|
1281
1511
|
const instance = /* @__PURE__ */ createEngine(tables_generated_default);
|
|
1282
1512
|
/**
|
|
1283
1513
|
* Merge Tailwind CSS classes with clsx-style arguments (strings, arrays,
|
|
@@ -1285,8 +1515,7 @@ const instance = /* @__PURE__ */ createEngine(tables_generated_default);
|
|
|
1285
1515
|
*/
|
|
1286
1516
|
const cn = /* @__PURE__ */ wrapClsx(instance.mergeString, instance);
|
|
1287
1517
|
instance.merge;
|
|
1288
|
-
|
|
1289
|
-
//#region ../ui/src/components/alert.tsx
|
|
1518
|
+
// ../ui/src/components/alert.tsx
|
|
1290
1519
|
const alertVariants = cva("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-start text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pe-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", {
|
|
1291
1520
|
variants: { variant: {
|
|
1292
1521
|
default: "bg-card text-card-foreground",
|
|
@@ -1316,19 +1545,17 @@ function AlertDescription({ className, ...props }) {
|
|
|
1316
1545
|
...props
|
|
1317
1546
|
});
|
|
1318
1547
|
}
|
|
1319
|
-
|
|
1320
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
|
|
1548
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
|
|
1321
1549
|
/**
|
|
1322
|
-
* @license lucide-react v1.
|
|
1550
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1323
1551
|
*
|
|
1324
1552
|
* This source code is licensed under the ISC license.
|
|
1325
1553
|
* See the LICENSE file in the root directory of this source tree.
|
|
1326
1554
|
*/
|
|
1327
1555
|
const toKebabCase = (string) => string?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1328
|
-
|
|
1329
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toLucideIconData.mjs
|
|
1556
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils/toLucideIconData.mjs
|
|
1330
1557
|
/**
|
|
1331
|
-
* @license lucide-react v1.
|
|
1558
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1332
1559
|
*
|
|
1333
1560
|
* This source code is licensed under the ISC license.
|
|
1334
1561
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1342,10 +1569,9 @@ function toLucideIconData(iconName, iconNode, aliases = []) {
|
|
|
1342
1569
|
...aliases.length > 0 ? { aliases } : {}
|
|
1343
1570
|
};
|
|
1344
1571
|
}
|
|
1345
|
-
|
|
1346
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
|
|
1572
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
|
|
1347
1573
|
/**
|
|
1348
|
-
* @license lucide-react v1.
|
|
1574
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1349
1575
|
*
|
|
1350
1576
|
* This source code is licensed under the ISC license.
|
|
1351
1577
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1364,10 +1590,9 @@ const toCamelCase = (string) => {
|
|
|
1364
1590
|
}
|
|
1365
1591
|
return out;
|
|
1366
1592
|
};
|
|
1367
|
-
|
|
1368
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
|
|
1593
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
|
|
1369
1594
|
/**
|
|
1370
|
-
* @license lucide-react v1.
|
|
1595
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1371
1596
|
*
|
|
1372
1597
|
* This source code is licensed under the ISC license.
|
|
1373
1598
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1376,10 +1601,9 @@ const toPascalCase = (string) => {
|
|
|
1376
1601
|
const camelCase = toCamelCase(string);
|
|
1377
1602
|
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
1378
1603
|
};
|
|
1379
|
-
|
|
1380
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
1604
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
1381
1605
|
/**
|
|
1382
|
-
* @license lucide-react v1.
|
|
1606
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1383
1607
|
*
|
|
1384
1608
|
* This source code is licensed under the ISC license.
|
|
1385
1609
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1387,10 +1611,9 @@ const toPascalCase = (string) => {
|
|
|
1387
1611
|
const mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
1388
1612
|
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
1389
1613
|
}).join(" ").trim();
|
|
1390
|
-
|
|
1391
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/build/defaultAttributes.mjs
|
|
1614
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/build/defaultAttributes.mjs
|
|
1392
1615
|
/**
|
|
1393
|
-
* @license lucide-react v1.
|
|
1616
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1394
1617
|
*
|
|
1395
1618
|
* This source code is licensed under the ISC license.
|
|
1396
1619
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1406,10 +1629,9 @@ const defaultAttributes = {
|
|
|
1406
1629
|
"stroke-linecap": "round",
|
|
1407
1630
|
"stroke-linejoin": "round"
|
|
1408
1631
|
};
|
|
1409
|
-
|
|
1410
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconNode.mjs
|
|
1632
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconNode.mjs
|
|
1411
1633
|
/**
|
|
1412
|
-
* @license lucide-react v1.
|
|
1634
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1413
1635
|
*
|
|
1414
1636
|
* This source code is licensed under the ISC license.
|
|
1415
1637
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1461,10 +1683,9 @@ function buildLucideIconNode(icon, params = {}) {
|
|
|
1461
1683
|
})
|
|
1462
1684
|
];
|
|
1463
1685
|
}
|
|
1464
|
-
|
|
1465
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconForReact.mjs
|
|
1686
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconForReact.mjs
|
|
1466
1687
|
/**
|
|
1467
|
-
* @license lucide-react v1.
|
|
1688
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1468
1689
|
*
|
|
1469
1690
|
* This source code is licensed under the ISC license.
|
|
1470
1691
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1482,10 +1703,9 @@ function buildLucideIconForReact(icon, params = {}) {
|
|
|
1482
1703
|
}
|
|
1483
1704
|
});
|
|
1484
1705
|
}
|
|
1485
|
-
|
|
1486
|
-
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
|
|
1706
|
+
// ../../node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
|
|
1487
1707
|
/**
|
|
1488
|
-
* @license lucide-react v1.
|
|
1708
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1489
1709
|
*
|
|
1490
1710
|
* This source code is licensed under the ISC license.
|
|
1491
1711
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1494,20 +1714,18 @@ const hasA11yProp = (props) => {
|
|
|
1494
1714
|
for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
|
|
1495
1715
|
return false;
|
|
1496
1716
|
};
|
|
1497
|
-
|
|
1498
|
-
//#region ../../node_modules/lucide-react/dist/esm/context.mjs
|
|
1717
|
+
// ../../node_modules/lucide-react/dist/esm/context.mjs
|
|
1499
1718
|
/**
|
|
1500
|
-
* @license lucide-react v1.
|
|
1719
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1501
1720
|
*
|
|
1502
1721
|
* This source code is licensed under the ISC license.
|
|
1503
1722
|
* See the LICENSE file in the root directory of this source tree.
|
|
1504
1723
|
*/
|
|
1505
1724
|
const LucideContext = createContext({});
|
|
1506
1725
|
const useLucideContext = () => useContext(LucideContext);
|
|
1507
|
-
|
|
1508
|
-
//#region ../../node_modules/lucide-react/dist/esm/Icon.mjs
|
|
1726
|
+
// ../../node_modules/lucide-react/dist/esm/Icon.mjs
|
|
1509
1727
|
/**
|
|
1510
|
-
* @license lucide-react v1.
|
|
1728
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1511
1729
|
*
|
|
1512
1730
|
* This source code is licensed under the ISC license.
|
|
1513
1731
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1535,10 +1753,9 @@ const Icon = forwardRef(({ color, size, width, height, strokeWidth, absoluteStro
|
|
|
1535
1753
|
...svgAttributes
|
|
1536
1754
|
}, [...builtIconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
|
|
1537
1755
|
});
|
|
1538
|
-
|
|
1539
|
-
//#region ../../node_modules/lucide-react/dist/esm/createLucideIcon.mjs
|
|
1756
|
+
// ../../node_modules/lucide-react/dist/esm/createLucideIcon.mjs
|
|
1540
1757
|
/**
|
|
1541
|
-
* @license lucide-react v1.
|
|
1758
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1542
1759
|
*
|
|
1543
1760
|
* This source code is licensed under the ISC license.
|
|
1544
1761
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1554,10 +1771,9 @@ function createLucideIcon(iconDataOrName, iconNode = [], aliases = []) {
|
|
|
1554
1771
|
if (iconData.name) Component.displayName = toPascalCase(iconData.name);
|
|
1555
1772
|
return Component;
|
|
1556
1773
|
}
|
|
1557
|
-
|
|
1558
|
-
//#region ../../node_modules/lucide-react/dist/esm/icons/loader-circle.mjs
|
|
1774
|
+
// ../../node_modules/lucide-react/dist/esm/icons/loader-circle.mjs
|
|
1559
1775
|
/**
|
|
1560
|
-
* @license lucide-react v1.
|
|
1776
|
+
* @license lucide-react v1.62.0 - ISC
|
|
1561
1777
|
*
|
|
1562
1778
|
* This source code is licensed under the ISC license.
|
|
1563
1779
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1573,8 +1789,7 @@ const __iconData = {
|
|
|
1573
1789
|
};
|
|
1574
1790
|
__iconData.node;
|
|
1575
1791
|
const LoaderCircle = createLucideIcon(__iconData);
|
|
1576
|
-
|
|
1577
|
-
//#region ../ui/src/components/spinner.tsx
|
|
1792
|
+
// ../ui/src/components/spinner.tsx
|
|
1578
1793
|
function Spinner({ className, ...props }) {
|
|
1579
1794
|
return /* @__PURE__ */ jsx(LoaderCircle, {
|
|
1580
1795
|
"data-slot": "spinner",
|
|
@@ -1584,8 +1799,7 @@ function Spinner({ className, ...props }) {
|
|
|
1584
1799
|
...props
|
|
1585
1800
|
});
|
|
1586
1801
|
}
|
|
1587
|
-
|
|
1588
|
-
//#region src/player-status.tsx
|
|
1802
|
+
// src/player-status.tsx
|
|
1589
1803
|
function PlayerStatus({ state, error }) {
|
|
1590
1804
|
if (state === "loading") return /* @__PURE__ */ jsx(Spinner, { "aria-label": "Composition loading" });
|
|
1591
1805
|
if (state === "error") return /* @__PURE__ */ jsxs(Alert, {
|
|
@@ -1594,8 +1808,7 @@ function PlayerStatus({ state, error }) {
|
|
|
1594
1808
|
});
|
|
1595
1809
|
return null;
|
|
1596
1810
|
}
|
|
1597
|
-
|
|
1598
|
-
//#region src/composition-player.tsx
|
|
1811
|
+
// src/composition-player.tsx
|
|
1599
1812
|
function CompositionPlayer({ composition, components, ref }) {
|
|
1600
1813
|
const { validated, registry, clips } = useMemo(() => {
|
|
1601
1814
|
const validated = validateComposition(composition);
|
|
@@ -1638,7 +1851,8 @@ function CompositionPlayer({ composition, components, ref }) {
|
|
|
1638
1851
|
useImperativeHandle(ref, () => ({
|
|
1639
1852
|
whenReady: session.whenReady,
|
|
1640
1853
|
seek: session.seek,
|
|
1641
|
-
getComposition: session.getComposition
|
|
1854
|
+
getComposition: session.getComposition,
|
|
1855
|
+
...session.audio ? { audio: session.audio } : {}
|
|
1642
1856
|
}), [session]);
|
|
1643
1857
|
useLayoutEffect(() => {
|
|
1644
1858
|
let active = true;
|
|
@@ -1656,7 +1870,12 @@ function CompositionPlayer({ composition, components, ref }) {
|
|
|
1656
1870
|
});
|
|
1657
1871
|
return () => {
|
|
1658
1872
|
active = false;
|
|
1659
|
-
session.stop()
|
|
1873
|
+
session.stop().catch((error) => {
|
|
1874
|
+
window.dispatchEvent(new ErrorEvent("error", {
|
|
1875
|
+
error,
|
|
1876
|
+
message: "E_ASSET: audio shutdown failed"
|
|
1877
|
+
}));
|
|
1878
|
+
});
|
|
1660
1879
|
};
|
|
1661
1880
|
}, [session]);
|
|
1662
1881
|
const currentStatus = status.session === session ? status : {
|
|
@@ -1677,16 +1896,17 @@ function CompositionPlayer({ composition, components, ref }) {
|
|
|
1677
1896
|
error: currentStatus.error
|
|
1678
1897
|
})] });
|
|
1679
1898
|
}
|
|
1680
|
-
|
|
1681
|
-
//#region src/renderer-bridge.tsx
|
|
1899
|
+
// src/renderer-bridge.tsx
|
|
1682
1900
|
function CompositionPlayerBridge(props) {
|
|
1683
1901
|
const playerRef = useRef(null);
|
|
1684
1902
|
useLayoutEffect(() => {
|
|
1685
1903
|
const browserWindow = window;
|
|
1686
1904
|
if (browserWindow.__serimoRenderer) throw new Error("Renderer bridge already installed");
|
|
1905
|
+
const installedPlayer = playerRef.current;
|
|
1906
|
+
let active = true;
|
|
1687
1907
|
const currentPlayer = () => {
|
|
1688
1908
|
const player = playerRef.current;
|
|
1689
|
-
if (!player) throw new Error("Player is not mounted");
|
|
1909
|
+
if (!active || !player || player !== installedPlayer) throw new Error("Player is not mounted");
|
|
1690
1910
|
return player;
|
|
1691
1911
|
};
|
|
1692
1912
|
const bridge = {
|
|
@@ -1698,17 +1918,30 @@ function CompositionPlayerBridge(props) {
|
|
|
1698
1918
|
},
|
|
1699
1919
|
getComposition() {
|
|
1700
1920
|
return currentPlayer().getComposition();
|
|
1701
|
-
}
|
|
1921
|
+
},
|
|
1922
|
+
...installedPlayer?.audio ? { audio: {
|
|
1923
|
+
play(frame) {
|
|
1924
|
+
try {
|
|
1925
|
+
return currentPlayer().audio.play(frame);
|
|
1926
|
+
} catch (error) {
|
|
1927
|
+
return Promise.reject(error);
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
pause() {
|
|
1931
|
+
if (active) installedPlayer.audio?.pause();
|
|
1932
|
+
}
|
|
1933
|
+
} } : {}
|
|
1702
1934
|
};
|
|
1703
1935
|
browserWindow.__serimoRenderer = bridge;
|
|
1704
1936
|
return () => {
|
|
1937
|
+
active = false;
|
|
1938
|
+
installedPlayer?.audio?.pause();
|
|
1705
1939
|
if (browserWindow.__serimoRenderer === bridge) delete browserWindow.__serimoRenderer;
|
|
1706
1940
|
};
|
|
1707
|
-
}, []);
|
|
1941
|
+
}, [props.composition, props.components]);
|
|
1708
1942
|
return /* @__PURE__ */ jsx(CompositionPlayer, {
|
|
1709
1943
|
...props,
|
|
1710
1944
|
ref: playerRef
|
|
1711
1945
|
});
|
|
1712
1946
|
}
|
|
1713
|
-
//#endregion
|
|
1714
1947
|
export { CompositionPlayer, CompositionPlayerBridge };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MotionAudioTrack, type MotionComposition } from '@serimo/core/composition';
|
|
2
|
+
export declare function createPlayerAudio(composition: Omit<MotionComposition, 'audio'> & {
|
|
3
|
+
audio?: MotionAudioTrack | MotionAudioTrack[];
|
|
4
|
+
}, signal: AbortSignal): {
|
|
5
|
+
ready: Promise<void>;
|
|
6
|
+
pause: () => void;
|
|
7
|
+
dispose: () => Promise<void>;
|
|
8
|
+
play(frame: number): Promise<{
|
|
9
|
+
originTimeMs: number;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=player-audio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"player-audio.d.ts","sourceRoot":"","sources":["../src/player-audio.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAGvB,MAAM,0BAA0B,CAAA;AAwFjC,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,GAAG;IAC9C,KAAK,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,CAAA;CAC9C,EACD,MAAM,EAAE,WAAW;;;;gBA6FL,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;EA8FzD"}
|
package/dist/player-session.d.ts
CHANGED
|
@@ -4,14 +4,26 @@ type Registry = ReturnType<typeof createTimelineRegistry>;
|
|
|
4
4
|
export interface PlayerHandle {
|
|
5
5
|
whenReady(): Promise<void>;
|
|
6
6
|
seek(frame: number): Promise<void>;
|
|
7
|
-
getComposition(): Pick<MotionComposition, 'id' | 'width' | 'height' | 'fps' | 'durationInFrames'>;
|
|
7
|
+
getComposition(): Pick<MotionComposition, 'id' | 'width' | 'height' | 'fps' | 'durationInFrames' | 'audio'>;
|
|
8
|
+
audio?: {
|
|
9
|
+
play(frame: number): Promise<{
|
|
10
|
+
originTimeMs: number;
|
|
11
|
+
}>;
|
|
12
|
+
pause(): void;
|
|
13
|
+
};
|
|
8
14
|
}
|
|
9
15
|
export declare function createPlayerSession(composition: MotionComposition, registry: Registry): {
|
|
10
16
|
whenReady(): Promise<void>;
|
|
11
17
|
seek(frame: number): Promise<void>;
|
|
12
|
-
getComposition(): Pick<MotionComposition, 'id' | 'width' | 'height' | 'fps' | 'durationInFrames'>;
|
|
18
|
+
getComposition(): Pick<MotionComposition, 'id' | 'width' | 'height' | 'fps' | 'durationInFrames' | 'audio'>;
|
|
19
|
+
audio?: {
|
|
20
|
+
play(frame: number): Promise<{
|
|
21
|
+
originTimeMs: number;
|
|
22
|
+
}>;
|
|
23
|
+
pause(): void;
|
|
24
|
+
};
|
|
13
25
|
start(): Promise<void>;
|
|
14
|
-
stop()
|
|
26
|
+
stop: () => Promise<void>;
|
|
15
27
|
};
|
|
16
28
|
export {};
|
|
17
29
|
//# sourceMappingURL=player-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player-session.d.ts","sourceRoot":"","sources":["../src/player-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"player-session.d.ts","sourceRoot":"","sources":["../src/player-session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAI5E,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAEzD,MAAM,WAAW,YAAY;IAC3B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClC,cAAc,IAAI,IAAI,CACpB,iBAAiB,EACjB,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,kBAAkB,GAAG,OAAO,CACjE,CAAA;IACD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QACtD,KAAK,IAAI,IAAI,CAAA;KACd,CAAA;CACF;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,iBAAiB,EAC9B,QAAQ,EAAE,QAAQ;iBAdL,OAAO,CAAC,IAAI,CAAC;gBACd,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;sBAChB,IAAI,CACpB,iBAAiB,EACjB,IAAI,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,kBAAkB,GAAG,OAAO,CACjE;YACO;QACN,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;YAAE,YAAY,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QACtD,KAAK,IAAI,IAAI,CAAA;KACd;;;EA2HF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer-bridge.d.ts","sourceRoot":"","sources":["../src/renderer-bridge.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAA;AAKhC,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,+
|
|
1
|
+
{"version":3,"file":"renderer-bridge.d.ts","sourceRoot":"","sources":["../src/renderer-bridge.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAA;AAKhC,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC,+BAuD3C"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serimo/player",
|
|
3
|
-
"
|
|
3
|
+
"description": "React composition player and renderer bridge for Serimo",
|
|
4
|
+
"version": "0.2.0",
|
|
4
5
|
"devDependencies": {
|
|
5
6
|
"@repo/eslint-config": "0.0.0",
|
|
6
7
|
"@repo/motion-ui": "0.0.0",
|
|
7
8
|
"@repo/renderer": "0.0.0",
|
|
8
9
|
"@repo/typescript-config": "0.0.0",
|
|
10
|
+
"@repo/ui": "0.0.0",
|
|
11
|
+
"@serimo/core": "0.2.0",
|
|
9
12
|
"@tailwindcss/postcss": "^4",
|
|
10
13
|
"@types/node": "26.6.5",
|
|
11
14
|
"@types/react": "^19",
|
|
12
15
|
"@types/react-dom": "^19",
|
|
13
16
|
"gsap": "3.15.0",
|
|
14
|
-
"happy-dom": "^21.0.
|
|
15
|
-
"postcss": "^8.5.
|
|
16
|
-
"react-dom": "19.3.1",
|
|
17
|
-
"rolldown": "1.2.14",
|
|
18
|
-
"vitest": "5.0.5",
|
|
19
|
-
"@repo/ui": "0.0.0",
|
|
17
|
+
"happy-dom": "^21.0.4",
|
|
18
|
+
"postcss": "^8.5.32",
|
|
20
19
|
"react": "19.3.1",
|
|
21
|
-
"
|
|
20
|
+
"react-dom": "19.3.1",
|
|
21
|
+
"rolldown": "1.2.15",
|
|
22
|
+
"vitest": "5.0.5"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.16.0"
|
|
22
26
|
},
|
|
23
27
|
"exports": {
|
|
24
28
|
".": {
|
|
@@ -27,30 +31,26 @@
|
|
|
27
31
|
},
|
|
28
32
|
"./styles.css": "./dist/styles.css"
|
|
29
33
|
},
|
|
30
|
-
"license": "Apache-2.0",
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "rolldown -c && tsc -p tsconfig.build.json && node scripts/build-styles.mjs",
|
|
33
|
-
"lint": "eslint src tests",
|
|
34
|
-
"test": "vitest run",
|
|
35
|
-
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
36
|
-
},
|
|
37
|
-
"type": "module",
|
|
38
34
|
"files": [
|
|
39
35
|
"dist",
|
|
40
36
|
"LICENSE.txt",
|
|
41
37
|
"THIRD_PARTY_NOTICES.txt"
|
|
42
38
|
],
|
|
43
|
-
"
|
|
39
|
+
"license": "Apache-2.0",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@serimo/core": "0.2.0",
|
|
42
|
+
"react": "19.3.1"
|
|
43
|
+
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
46
|
"url": "https://github.com/paben-id/serimo.git",
|
|
47
47
|
"directory": "packages/player"
|
|
48
48
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "rolldown -c && tsc -p tsconfig.build.json && node scripts/build-styles.mjs",
|
|
51
|
+
"lint": "eslint src tests",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
51
54
|
},
|
|
52
|
-
"
|
|
53
|
-
"@serimo/core": "^0.1.0",
|
|
54
|
-
"react": "19.3.1"
|
|
55
|
-
}
|
|
55
|
+
"type": "module"
|
|
56
56
|
}
|