@pulsesync/yamusic-types 0.0.3 → 0.0.5
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 +14 -0
- package/dist/index.d.ts +56 -1
- package/dist/index.js +5 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -12,6 +12,20 @@ import type { PulseSyncApi, SonataState } from '@pulsesync/yamusic-types'
|
|
|
12
12
|
import '@pulsesync/yamusic-types/global'
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Уведомления
|
|
16
|
+
|
|
17
|
+
`showToast(message, options?)` показывает верхний тост ЯМ. `showNotification(message, 'info' | 'error', options?)` использует нижние нативные контейнеры. `NotificationOptions` и `PulseSyncToastOptions` принимают `durationMs` (по умолчанию 4000, от 1500 до 10000 мс).
|
|
18
|
+
|
|
19
|
+
В SDK используйте `api.toasts.show()` и `api.notifications.info()` / `error()`: WebHost сам связывает уведомления с аддоном. Нижние уведомления требуют обновлённого мода с подключёнными нативными контейнерами.
|
|
20
|
+
|
|
21
|
+
`NotificationOptions` также принимает `icon` или `coverUrl` и `link: { label, href }`. Ссылки и обложки допускают HTTP(S) либо путь приложения. Для SDK имя иконки типизировано каталогом.
|
|
22
|
+
|
|
23
|
+
## Модалки
|
|
24
|
+
|
|
25
|
+
`showModal('alert' | 'confirm', options)` показывает нативную модалку ЯМ. `ModalOptions` содержит обязательные `title` (до 200 символов) и `message` (до 5000), а также необязательные `confirmLabel` и `cancelLabel` (до 80). В `alert` показывается одна основная кнопка, в `confirm` — основная и отмена. HTML не обрабатывается.
|
|
26
|
+
|
|
27
|
+
Promise возвращает `true` при подтверждении и `false` при отмене, закрытии крестиком, Escape или клике снаружи. В SDK используйте `api.modals.alert(options)` / `api.modals.confirm(options)`: WebHost привязывает диалог к аддону и отменяет ожидание при его отключении. Незавершённые диалоги разных аддонов образуют очередь; второй одновременный вызов одного аддона отклоняется.
|
|
28
|
+
|
|
15
29
|
## Разработка
|
|
16
30
|
|
|
17
31
|
```bash
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,56 @@ export interface PulseSyncTrackSelector {
|
|
|
17
17
|
from?: string;
|
|
18
18
|
position?: 'next' | 'last' | string;
|
|
19
19
|
}
|
|
20
|
+
export interface PulseSyncToastOptions {
|
|
21
|
+
durationMs?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface NotificationOptions {
|
|
24
|
+
durationMs?: number;
|
|
25
|
+
icon?: string;
|
|
26
|
+
coverUrl?: string;
|
|
27
|
+
link?: {
|
|
28
|
+
label: string;
|
|
29
|
+
href: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface ModalOptions {
|
|
33
|
+
title: string;
|
|
34
|
+
message: string;
|
|
35
|
+
confirmLabel?: string;
|
|
36
|
+
cancelLabel?: string;
|
|
37
|
+
}
|
|
38
|
+
export type NativeField = {
|
|
39
|
+
name: string;
|
|
40
|
+
label: string;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
required?: boolean;
|
|
43
|
+
} & ({
|
|
44
|
+
type: 'text';
|
|
45
|
+
value?: string;
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
minLength?: number;
|
|
48
|
+
maxLength?: number;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'switch';
|
|
51
|
+
value?: boolean;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'slider';
|
|
54
|
+
value?: number;
|
|
55
|
+
min?: number;
|
|
56
|
+
max?: number;
|
|
57
|
+
step?: number;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'select';
|
|
60
|
+
value?: string;
|
|
61
|
+
options: readonly {
|
|
62
|
+
value: string;
|
|
63
|
+
label: string;
|
|
64
|
+
}[];
|
|
65
|
+
});
|
|
66
|
+
export type FormValues = Record<string, string | boolean | number>;
|
|
67
|
+
export interface FormModalOptions extends ModalOptions {
|
|
68
|
+
fields: readonly NativeField[];
|
|
69
|
+
}
|
|
20
70
|
export interface PulseSyncTrackArtist {
|
|
21
71
|
id?: string | number;
|
|
22
72
|
name?: string;
|
|
@@ -320,11 +370,16 @@ export interface PulseSyncApi {
|
|
|
320
370
|
getDisplayMaxFps: () => number;
|
|
321
371
|
getPlatform: () => string;
|
|
322
372
|
getPremiumStatus: () => Promise<boolean>;
|
|
373
|
+
showToast: (message: string, options?: PulseSyncToastOptions, ownerId?: string) => Promise<void>;
|
|
374
|
+
showNotification: (message: string, kind: 'info' | 'error', options?: NotificationOptions, ownerId?: string) => Promise<void>;
|
|
375
|
+
showModal: (kind: 'alert' | 'confirm', options: ModalOptions, ownerId?: string, requestId?: string) => Promise<boolean>;
|
|
376
|
+
closeModal: (requestId: string, ownerId?: string) => Promise<boolean>;
|
|
377
|
+
showFormModal: (options: FormModalOptions, ownerId?: string, requestId?: string) => Promise<FormValues | null>;
|
|
323
378
|
refreshPlayerBar: () => void;
|
|
324
379
|
getSettings: <TSettings extends AddonSettings = AddonSettings>(addonId: string) => AddonSettingsStore<TSettings>;
|
|
325
380
|
}
|
|
326
381
|
export declare const PULSESYNC_WEB_HOST_API_VERSION: 1;
|
|
327
|
-
export declare const PULSESYNC_WEB_HOST_API_V1_RPC_METHODS: readonly ["playVibe", "play", "pause", "togglePlayPause", "next", "previous", "setRepeatMode", "toggleShuffle", "setVolume", "setProgress", "playTrackById", "playPlaylistById", "addTrackToQueueById", "likeTrack", "unlikeTrack", "dislikeTrack", "undislikeTrack", "isTrackLiked", "isTrackDisliked", "isPlaying", "getPlayerSnapshot", "getQueueSnapshot", "getRouteSnapshot", "getCurrentTrack", "getQueue", "getProgress", "getDuration", "getVolume", "getRepeatMode", "isShuffle", "getDisplayMaxFps", "getPlatform", "getPremiumStatus", "refreshPlayerBar", "getPageEntity", "setTrackReplacement", "setTrackReplacements", "removeTrackReplacement", "clearTrackReplacements"];
|
|
382
|
+
export declare const PULSESYNC_WEB_HOST_API_V1_RPC_METHODS: readonly ["playVibe", "play", "pause", "togglePlayPause", "next", "previous", "setRepeatMode", "toggleShuffle", "setVolume", "setProgress", "playTrackById", "playPlaylistById", "addTrackToQueueById", "likeTrack", "unlikeTrack", "dislikeTrack", "undislikeTrack", "isTrackLiked", "isTrackDisliked", "isPlaying", "getPlayerSnapshot", "getQueueSnapshot", "getRouteSnapshot", "getCurrentTrack", "getQueue", "getProgress", "getDuration", "getVolume", "getRepeatMode", "isShuffle", "getDisplayMaxFps", "getPlatform", "getPremiumStatus", "showToast", "showNotification", "showModal", "closeModal", "showFormModal", "refreshPlayerBar", "getPageEntity", "setTrackReplacement", "setTrackReplacements", "removeTrackReplacement", "clearTrackReplacements"];
|
|
328
383
|
export type PulseSyncWebHostApiV1RpcMethod = (typeof PULSESYNC_WEB_HOST_API_V1_RPC_METHODS)[number];
|
|
329
384
|
export type PulseSyncWebHostRpcApiV1 = {
|
|
330
385
|
readonly [TMethod in PulseSyncWebHostApiV1RpcMethod]: PulseSyncApi[TMethod] extends (...args: infer TArgs) => infer TResult ? (...args: TArgs) => Promise<Awaited<TResult>> : never;
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,11 @@ export const PULSESYNC_WEB_HOST_API_V1_RPC_METHODS = Object.freeze([
|
|
|
33
33
|
'getDisplayMaxFps',
|
|
34
34
|
'getPlatform',
|
|
35
35
|
'getPremiumStatus',
|
|
36
|
+
'showToast',
|
|
37
|
+
'showNotification',
|
|
38
|
+
'showModal',
|
|
39
|
+
'closeModal',
|
|
40
|
+
'showFormModal',
|
|
36
41
|
'refreshPlayerBar',
|
|
37
42
|
'getPageEntity',
|
|
38
43
|
'setTrackReplacement',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulsesync/yamusic-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "TypeScript declaration package for PulseSync YaMusic addon development",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
"LICENSE"
|
|
24
24
|
],
|
|
25
25
|
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
26
|
+
"access": "public",
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "tsc -p tsconfig.json",
|
|
30
31
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
31
32
|
"pack": "npm run build && npm pack --cache ./.npm-cache",
|
|
32
|
-
"publish:public": "
|
|
33
|
+
"publish:public": "yarn run check && yarn build && npm publish --access public --registry=https://registry.npmjs.org/ --cache ./.npm-cache"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"dotenv-cli": "^11.0.0",
|