@pulsesync/yamusic-types 0.0.4 → 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/LICENSE +21 -21
- package/README.md +18 -12
- package/dist/addonModules.d.ts +63 -0
- package/dist/addonModules.js +1 -0
- package/dist/index.d.ts +53 -1
- package/dist/index.js +4 -0
- package/package.json +9 -3
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 PulseSync
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PulseSync
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @pulsesync/yamusic-types
|
|
2
2
|
|
|
3
|
-
TypeScript
|
|
3
|
+
Типы TypeScript для API PulseSync и Яндекс Музыки. Для React-аддонов WebHost используйте [@pulsesync/addon-sdk](https://www.npmjs.com/package/@pulsesync/addon-sdk).
|
|
4
|
+
|
|
5
|
+
## Установка
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add --dev @pulsesync/yamusic-types
|
|
9
|
+
```
|
|
4
10
|
|
|
5
11
|
## Использование
|
|
6
12
|
|
|
@@ -8,22 +14,22 @@ TypeScript declaration package for PulseSync YaMusic addons.
|
|
|
8
14
|
import type { PulseSyncApi, SonataState } from '@pulsesync/yamusic-types'
|
|
9
15
|
```
|
|
10
16
|
|
|
17
|
+
Для типизации глобальных объектов `window` подключите отдельный модуль:
|
|
18
|
+
|
|
11
19
|
```ts
|
|
12
20
|
import '@pulsesync/yamusic-types/global'
|
|
13
|
-
```
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install
|
|
19
|
-
npm run check
|
|
20
|
-
npm run build
|
|
22
|
+
const api = window.pulsesyncApi
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
Пакет описывает API, но не устанавливает мод и не создаёт объекты во время выполнения. Доступность методов зависит от версии PulseSync и окружения; глобальные объекты могут отсутствовать.
|
|
26
|
+
|
|
27
|
+
## Разработка
|
|
24
28
|
|
|
25
29
|
```bash
|
|
26
|
-
|
|
30
|
+
yarn install
|
|
31
|
+
yarn run check
|
|
32
|
+
yarn build
|
|
27
33
|
```
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
Лицензия: GPL-3.0-or-later.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type AddonModuleKind = 'javascript' | 'wasm';
|
|
2
|
+
export type AddonModuleAccess = 'public' | 'protected';
|
|
3
|
+
export type AddonModuleStatus = 'draft' | 'pending' | 'accepted' | 'rejected' | 'revoked';
|
|
4
|
+
export type AddonModuleChannel = 'stable' | 'dev';
|
|
5
|
+
export type AddonModuleReference = Readonly<{
|
|
6
|
+
moduleId: string;
|
|
7
|
+
apiMajor: number;
|
|
8
|
+
optional?: boolean;
|
|
9
|
+
} & ({
|
|
10
|
+
channel: AddonModuleChannel;
|
|
11
|
+
version?: never;
|
|
12
|
+
} | {
|
|
13
|
+
version: string;
|
|
14
|
+
channel?: never;
|
|
15
|
+
})>;
|
|
16
|
+
export type AddonModuleReferences = Readonly<Record<string, AddonModuleReference>>;
|
|
17
|
+
export type AddonModuleErrorCode = 'unsupported-host' | 'undeclared-module' | 'unavailable' | 'revoked' | 'access-denied' | 'incompatible-api' | 'integrity-mismatch' | 'aborted' | 'initialization-failed' | 'reload-required';
|
|
18
|
+
export interface AddonModuleDescriptor {
|
|
19
|
+
readonly formatVersion: 1;
|
|
20
|
+
readonly moduleId: string;
|
|
21
|
+
readonly versionId: string;
|
|
22
|
+
readonly version: string;
|
|
23
|
+
readonly apiMajor: number;
|
|
24
|
+
readonly kind: AddonModuleKind;
|
|
25
|
+
readonly access: AddonModuleAccess;
|
|
26
|
+
readonly sha256: string;
|
|
27
|
+
readonly size: number;
|
|
28
|
+
}
|
|
29
|
+
export interface AddonModuleSecurityManifest {
|
|
30
|
+
readonly formatVersion: 1;
|
|
31
|
+
readonly runtime: 'isolated';
|
|
32
|
+
readonly kind: 'web-addon';
|
|
33
|
+
readonly apiVersion: number;
|
|
34
|
+
readonly capabilities: readonly ['modules-v1'];
|
|
35
|
+
readonly allowedUrls: readonly string[];
|
|
36
|
+
readonly modules: AddonModuleReferences;
|
|
37
|
+
}
|
|
38
|
+
export interface AddonModuleReleaseBinding {
|
|
39
|
+
readonly formatVersion: 1;
|
|
40
|
+
readonly catalogAddonId: string;
|
|
41
|
+
readonly releaseId: string;
|
|
42
|
+
readonly runtimeId: string;
|
|
43
|
+
readonly codeHash: string;
|
|
44
|
+
readonly manifestHash: string;
|
|
45
|
+
}
|
|
46
|
+
export interface AddonModuleResolution {
|
|
47
|
+
readonly activationId: string;
|
|
48
|
+
readonly releaseBinding: string;
|
|
49
|
+
readonly descriptors: Readonly<Record<string, AddonModuleDescriptor>>;
|
|
50
|
+
readonly errors: Readonly<Record<string, AddonModuleErrorCode>>;
|
|
51
|
+
}
|
|
52
|
+
export interface AddonModuleChallenge {
|
|
53
|
+
readonly challenge: string;
|
|
54
|
+
readonly moduleVersionId: string;
|
|
55
|
+
readonly expiresAt: number;
|
|
56
|
+
}
|
|
57
|
+
export interface AddonModuleLoadOptions {
|
|
58
|
+
readonly authorize?: (challenge: AddonModuleChallenge) => Promise<string>;
|
|
59
|
+
}
|
|
60
|
+
export interface AddonModules {
|
|
61
|
+
load<T = unknown>(alias: string, options?: AddonModuleLoadOptions): Promise<T>;
|
|
62
|
+
instantiateWasm<T = Readonly<Record<string, (...args: never[]) => unknown>>>(alias: string, options?: AddonModuleLoadOptions): Promise<T>;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type * from './addonModules.js';
|
|
1
2
|
export type AddonSettingValue<T> = {
|
|
2
3
|
value?: T;
|
|
3
4
|
default?: T;
|
|
@@ -20,6 +21,53 @@ export interface PulseSyncTrackSelector {
|
|
|
20
21
|
export interface PulseSyncToastOptions {
|
|
21
22
|
durationMs?: number;
|
|
22
23
|
}
|
|
24
|
+
export interface NotificationOptions {
|
|
25
|
+
durationMs?: number;
|
|
26
|
+
icon?: string;
|
|
27
|
+
coverUrl?: string;
|
|
28
|
+
link?: {
|
|
29
|
+
label: string;
|
|
30
|
+
href: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface ModalOptions {
|
|
34
|
+
title: string;
|
|
35
|
+
message: string;
|
|
36
|
+
confirmLabel?: string;
|
|
37
|
+
cancelLabel?: string;
|
|
38
|
+
}
|
|
39
|
+
export type NativeField = {
|
|
40
|
+
name: string;
|
|
41
|
+
label: string;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
} & ({
|
|
45
|
+
type: 'text';
|
|
46
|
+
value?: string;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
minLength?: number;
|
|
49
|
+
maxLength?: number;
|
|
50
|
+
} | {
|
|
51
|
+
type: 'switch';
|
|
52
|
+
value?: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'slider';
|
|
55
|
+
value?: number;
|
|
56
|
+
min?: number;
|
|
57
|
+
max?: number;
|
|
58
|
+
step?: number;
|
|
59
|
+
} | {
|
|
60
|
+
type: 'select';
|
|
61
|
+
value?: string;
|
|
62
|
+
options: readonly {
|
|
63
|
+
value: string;
|
|
64
|
+
label: string;
|
|
65
|
+
}[];
|
|
66
|
+
});
|
|
67
|
+
export type FormValues = Record<string, string | boolean | number>;
|
|
68
|
+
export interface FormModalOptions extends ModalOptions {
|
|
69
|
+
fields: readonly NativeField[];
|
|
70
|
+
}
|
|
23
71
|
export interface PulseSyncTrackArtist {
|
|
24
72
|
id?: string | number;
|
|
25
73
|
name?: string;
|
|
@@ -324,11 +372,15 @@ export interface PulseSyncApi {
|
|
|
324
372
|
getPlatform: () => string;
|
|
325
373
|
getPremiumStatus: () => Promise<boolean>;
|
|
326
374
|
showToast: (message: string, options?: PulseSyncToastOptions, ownerId?: string) => Promise<void>;
|
|
375
|
+
showNotification: (message: string, kind: 'info' | 'error', options?: NotificationOptions, ownerId?: string) => Promise<void>;
|
|
376
|
+
showModal: (kind: 'alert' | 'confirm', options: ModalOptions, ownerId?: string, requestId?: string) => Promise<boolean>;
|
|
377
|
+
closeModal: (requestId: string, ownerId?: string) => Promise<boolean>;
|
|
378
|
+
showFormModal: (options: FormModalOptions, ownerId?: string, requestId?: string) => Promise<FormValues | null>;
|
|
327
379
|
refreshPlayerBar: () => void;
|
|
328
380
|
getSettings: <TSettings extends AddonSettings = AddonSettings>(addonId: string) => AddonSettingsStore<TSettings>;
|
|
329
381
|
}
|
|
330
382
|
export declare const PULSESYNC_WEB_HOST_API_VERSION: 1;
|
|
331
|
-
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", "refreshPlayerBar", "getPageEntity", "setTrackReplacement", "setTrackReplacements", "removeTrackReplacement", "clearTrackReplacements"];
|
|
383
|
+
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"];
|
|
332
384
|
export type PulseSyncWebHostApiV1RpcMethod = (typeof PULSESYNC_WEB_HOST_API_V1_RPC_METHODS)[number];
|
|
333
385
|
export type PulseSyncWebHostRpcApiV1 = {
|
|
334
386
|
readonly [TMethod in PulseSyncWebHostApiV1RpcMethod]: PulseSyncApi[TMethod] extends (...args: infer TArgs) => infer TResult ? (...args: TArgs) => Promise<Awaited<TResult>> : never;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,10 @@ export const PULSESYNC_WEB_HOST_API_V1_RPC_METHODS = Object.freeze([
|
|
|
34
34
|
'getPlatform',
|
|
35
35
|
'getPremiumStatus',
|
|
36
36
|
'showToast',
|
|
37
|
+
'showNotification',
|
|
38
|
+
'showModal',
|
|
39
|
+
'closeModal',
|
|
40
|
+
'showFormModal',
|
|
37
41
|
'refreshPlayerBar',
|
|
38
42
|
'getPageEntity',
|
|
39
43
|
'setTrackReplacement',
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulsesync/yamusic-types",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "TypeScript declaration package for PulseSync YaMusic addon development",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/PulseSync-LLC/PulseSync-yamusic-types.git"
|
|
8
|
+
},
|
|
5
9
|
"license": "GPL-3.0-or-later",
|
|
6
10
|
"type": "module",
|
|
11
|
+
"packageManager": "yarn@1.22.22",
|
|
7
12
|
"sideEffects": false,
|
|
8
13
|
"types": "./dist/index.d.ts",
|
|
9
14
|
"exports": {
|
|
@@ -23,13 +28,14 @@
|
|
|
23
28
|
"LICENSE"
|
|
24
29
|
],
|
|
25
30
|
"publishConfig": {
|
|
26
|
-
"access": "public"
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
33
|
},
|
|
28
34
|
"scripts": {
|
|
29
35
|
"build": "tsc -p tsconfig.json",
|
|
30
36
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
31
37
|
"pack": "npm run build && npm pack --cache ./.npm-cache",
|
|
32
|
-
"publish:public": "
|
|
38
|
+
"publish:public": "yarn run check && yarn build && npm publish --access public --registry=https://registry.npmjs.org/ --cache ./.npm-cache"
|
|
33
39
|
},
|
|
34
40
|
"devDependencies": {
|
|
35
41
|
"dotenv-cli": "^11.0.0",
|