mioku-plugin-music 2.4.0 → 2.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mioku-plugin-music",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "音乐插件:点歌、搜索音乐、听歌语音发送",
5
5
  "main": "index.ts",
6
6
  "type": "module",
@@ -142,7 +142,7 @@ export class MusicPluginRuntime {
142
142
 
143
143
  async searchSongs(event: any, query: string): Promise<MusicSearchResult> {
144
144
  const session = this.getOrCreateSession(event);
145
- const provider = this.createProvider(
145
+ const provider = await this.createProvider(
146
146
  session.provider,
147
147
  session.mediaUserToken,
148
148
  );
@@ -157,7 +157,7 @@ export class MusicPluginRuntime {
157
157
 
158
158
  async getSongDetail(event: any, songId: string) {
159
159
  const session = this.getOrCreateSession(event);
160
- const provider = this.createProvider(
160
+ const provider = await this.createProvider(
161
161
  session.provider,
162
162
  session.mediaUserToken,
163
163
  );
@@ -166,7 +166,7 @@ export class MusicPluginRuntime {
166
166
 
167
167
  async getAlbumDetail(event: any, albumId: string) {
168
168
  const session = this.getOrCreateSession(event);
169
- const provider = this.createProvider(
169
+ const provider = await this.createProvider(
170
170
  session.provider,
171
171
  session.mediaUserToken,
172
172
  );
@@ -181,7 +181,7 @@ export class MusicPluginRuntime {
181
181
  options?: { forceFile?: boolean },
182
182
  ): Promise<void> {
183
183
  const session = this.getOrCreateSession(event);
184
- const provider = this.createProvider(
184
+ const provider = await this.createProvider(
185
185
  session.provider,
186
186
  session.mediaUserToken,
187
187
  );
@@ -346,11 +346,11 @@ export class MusicPluginRuntime {
346
346
  return next;
347
347
  }
348
348
 
349
- private createProvider(provider: MusicProviderName, mediaUserToken?: string) {
349
+ private async createProvider(provider: MusicProviderName, mediaUserToken?: string) {
350
350
  const resolvedProvider = this.resolveProviderName(provider);
351
351
 
352
- const amDefaults = this.deps.applemusicService?.getDefaultOptions();
353
- const neDefaults = this.deps.neteaseService?.getDefaultOptions();
352
+ const amDefaults = await this.deps.applemusicService?.getDefaultOptions();
353
+ const neDefaults = await this.deps.neteaseService?.getDefaultOptions();
354
354
 
355
355
  const finalMediaUserToken =
356
356
  String(mediaUserToken || "").trim() ||
package/runtime.ts CHANGED
@@ -12,11 +12,11 @@ export interface MusicRuntimeState {
12
12
  const MUSIC_PLUGIN_NAME = "music";
13
13
 
14
14
  export function getMusicRuntimeState(): MusicRuntimeState {
15
- return getPluginRuntimeState<MusicRuntimeState>(MUSIC_PLUGIN_NAME);
15
+ return getPluginRuntimeState(MUSIC_PLUGIN_NAME) as MusicRuntimeState;
16
16
  }
17
17
 
18
18
  export function setMusicRuntimeState(nextState: MusicRuntimeState): MusicRuntimeState {
19
- return setPluginRuntimeState<MusicRuntimeState>(MUSIC_PLUGIN_NAME, nextState);
19
+ return setPluginRuntimeState(MUSIC_PLUGIN_NAME, nextState) as MusicRuntimeState;
20
20
  }
21
21
 
22
22
  export function resetMusicRuntimeState(): void {