@songloft/lynx-plugin-sdk 2.23.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 CHANGED
@@ -50,6 +50,10 @@ 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
+
53
57
  ### 播放音效
54
58
 
55
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#插件播放音效)。
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@songloft/lynx-plugin-sdk",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "description": "SDK for Songloft plugins rendered via Lynx native (renderEngine: lynx)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",