@songloft/lynx-plugin-sdk 2.22.0 → 2.24.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 +8 -0
- package/dist/audio-effects.d.ts +25 -0
- package/dist/audio-effects.js +1 -0
- package/dist/bridge.js +10 -1
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,6 +50,14 @@ const theme = getTheme()
|
|
|
50
50
|
|
|
51
51
|
`PlayerState` 包含:`queue`、`current_index`、`current_song`、`is_playing`、`current_time`、`duration`、`volume`、`play_mode`、`source_playlist_id`。
|
|
52
52
|
|
|
53
|
+
### 打开外链和全屏视频
|
|
54
|
+
|
|
55
|
+
使用 `invokeHost('plugin', 'openUrl', { url })` 打开绝对 HTTP(S) 链接,用 `invokeHost('player', 'openVideo', { id })` 全屏播放曲库视频。先通过 `host.getInfo` 检查 `plugin.openUrl` 或 `player.openVideo`。 [宿主接口文档](https://github.com/songloft-org/songloft-player-lynx/blob/main/docs/reference/plugin-client-sdk.md#插件外链和全屏视频)
|
|
56
|
+
|
|
57
|
+
### 播放音效
|
|
58
|
+
|
|
59
|
+
`host.getInfo` 公布 `player.audioEffects` 能力时,可通过 `invokeHost('player', 'getAudioEffects')` 获取会话和预设。沿用 `player` 命名空间的 `applyAudioEffects` 和 `clearAudioEffects` 操作该会话。类型定义为 `PlaybackAudioEffectsState`、`PlaybackAudioEffects` 和 `ApplyPlaybackAudioEffectsOptions`。见 [宿主接口文档](https://github.com/songloft-org/songloft-player-lynx/blob/main/docs/reference/plugin-client-sdk.md#插件播放音效)。
|
|
60
|
+
|
|
53
61
|
### `onThemeChange(cb): () => void`
|
|
54
62
|
|
|
55
63
|
监听宿主推送的主题变更(`'light'` / `'dark'`)。返回取消订阅函数。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Temporary host audio effects for a plugin's playback session. */
|
|
2
|
+
export interface PlaybackAudioEffects {
|
|
3
|
+
equalizer?: {
|
|
4
|
+
preset: string;
|
|
5
|
+
};
|
|
6
|
+
reverb?: {
|
|
7
|
+
preset: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PlaybackAudioEffectsState {
|
|
11
|
+
playbackId: string | null;
|
|
12
|
+
supported: {
|
|
13
|
+
equalizer?: {
|
|
14
|
+
presets: string[];
|
|
15
|
+
};
|
|
16
|
+
reverb?: {
|
|
17
|
+
presets: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
applied: PlaybackAudioEffects | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ApplyPlaybackAudioEffectsOptions {
|
|
23
|
+
playbackId: string;
|
|
24
|
+
effects: PlaybackAudioEffects;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/bridge.js
CHANGED
|
@@ -29,8 +29,15 @@ function ensureInit() {
|
|
|
29
29
|
if (pending.timer !== undefined)
|
|
30
30
|
clearTimeout(pending.timer);
|
|
31
31
|
try {
|
|
32
|
-
const result = JSON.parse(payload.result ?? '{"ok":false,"error":"empty reply"}');
|
|
32
|
+
const { acknowledge, ...result } = JSON.parse(payload.result ?? '{"ok":false,"error":"empty reply"}');
|
|
33
33
|
pending.resolve(result);
|
|
34
|
+
if (result.ok && acknowledge === true) {
|
|
35
|
+
const callId = payload.callId;
|
|
36
|
+
void Promise.resolve().then(() => {
|
|
37
|
+
const bridge = typeof NativeModules !== 'undefined' && NativeModules.SongloftPluginBridge;
|
|
38
|
+
bridge && bridge.hostCall(getFrameId(), callId, 'lifecycle', 'hostReplyReceived', '{}');
|
|
39
|
+
}).catch(error => console.error('Could not confirm host reply', error));
|
|
40
|
+
}
|
|
34
41
|
}
|
|
35
42
|
catch {
|
|
36
43
|
pending.resolve({ ok: false, error: 'invalid reply JSON' });
|
|
@@ -52,6 +59,8 @@ export function invokeHost(ns, method, params, timeoutMs = 10000) {
|
|
|
52
59
|
ensureInit();
|
|
53
60
|
const frameId = getFrameId();
|
|
54
61
|
const callId = `c${++callIdCounter}`;
|
|
62
|
+
if (ns === 'player' && method === 'openVideo')
|
|
63
|
+
params = { ...params, __songloftReplyAck: true };
|
|
55
64
|
return new Promise((resolve) => {
|
|
56
65
|
const pending = {
|
|
57
66
|
resolve,
|
package/dist/index.d.ts
CHANGED
|
@@ -16,3 +16,4 @@ export { apiGet, apiPost, apiPut, apiDelete } from './api.js';
|
|
|
16
16
|
export { onPlayerState, onThemeChange, onPush, type PlayerState, } from './events.js';
|
|
17
17
|
export { getGlobalProps, getFrameId, getTheme } from './globals.js';
|
|
18
18
|
export { PluginSocket } from './socket.js';
|
|
19
|
+
export type { ApplyPlaybackAudioEffectsOptions, PlaybackAudioEffects, PlaybackAudioEffectsState, } from './audio-effects.js';
|