lxns-rhythm-api 0.1.2 → 0.1.4

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
@@ -1,4 +1,4 @@
1
- # lxns-sdk
1
+ # lxns-rhythm-api
2
2
 
3
3
  一个用于访问 Lxns API 的轻量 TypeScript SDK。
4
4
 
@@ -10,19 +10,19 @@
10
10
 
11
11
  ```bash
12
12
  # npm
13
- npm i lxns-sdk
13
+ npm i lxns-rhythm-api
14
14
 
15
15
  # pnpm
16
- pnpm add lxns-sdk
16
+ pnpm add lxns-rhythm-api
17
17
 
18
18
  # yarn
19
- yarn add lxns-sdk
19
+ yarn add lxns-rhythm-api
20
20
  ```
21
21
 
22
22
  ## 快速开始
23
23
 
24
24
  ```ts
25
- import { LxnsApiClient } from "lxns-sdk";
25
+ import { LxnsApiClient } from "lxns-rhythm-api";
26
26
 
27
27
  // 无 token:仅可用 public API
28
28
  const client = new LxnsApiClient();
@@ -69,6 +69,11 @@ new LxnsApiClient(options?: {
69
69
 
70
70
  > 注意:`baseURL` 默认值为 `https://maimai.lxns.net/api/v0/`。
71
71
 
72
+ ## TODO
73
+
74
+ - [ ] 支持 Chuni API
75
+ - [x] 支持 Maimai API
76
+
72
77
  ## API 概览
73
78
 
74
79
  - `maimai.public`
package/dist/index.d.ts CHANGED
@@ -184,6 +184,7 @@ interface CollectionGenre {
184
184
  type FCType = "app" | "ap" | "fcp" | "fc";
185
185
  type FSType = "fsdp" | "fsd" | "fsp" | "fs" | "sync";
186
186
  type RateType = "sssp" | "sss" | "ssp" | "ss" | "sp" | "s" | "aaa" | "aa" | "a" | "bbb" | "bb" | "b" | "c" | "d";
187
+ type AssetType = "icon" | "plate" | "frame" | "jacket" | "music";
187
188
  interface Score {
188
189
  /** 曲目 ID */
189
190
  id: number;
@@ -254,6 +255,7 @@ interface Frame extends Collection {
254
255
  }
255
256
 
256
257
  type models_Alias = Alias;
258
+ type models_AssetType = AssetType;
257
259
  type models_BuddyNotes = BuddyNotes;
258
260
  type models_Collection = Collection;
259
261
  type models_CollectionGenre = CollectionGenre;
@@ -280,7 +282,7 @@ type models_SongType = SongType;
280
282
  type models_Trophy = Trophy;
281
283
  type models_Version = Version;
282
284
  declare namespace models {
283
- export { type models_Alias as Alias, type models_BuddyNotes as BuddyNotes, type models_Collection as Collection, type models_CollectionGenre as CollectionGenre, type models_CollectionRequired as CollectionRequired, type models_CollectionRequiredSong as CollectionRequiredSong, type models_FCType as FCType, type models_FSType as FSType, type models_Frame as Frame, type models_Genre as Genre, type models_Icon as Icon, models_LevelIndex as LevelIndex, type models_NamePlate as NamePlate, type models_Notes as Notes, type models_Player as Player, type models_RateType as RateType, type models_RatingTrend as RatingTrend, type models_Score as Score, type models_SimpleScore as SimpleScore, type Song$1 as Song, type models_SongDifficulties as SongDifficulties, type models_SongDifficulty as SongDifficulty, type models_SongDifficultyUtage as SongDifficultyUtage, type models_SongType as SongType, type models_Trophy as Trophy, type models_Version as Version };
285
+ export { type models_Alias as Alias, type models_AssetType as AssetType, type models_BuddyNotes as BuddyNotes, type models_Collection as Collection, type models_CollectionGenre as CollectionGenre, type models_CollectionRequired as CollectionRequired, type models_CollectionRequiredSong as CollectionRequiredSong, type models_FCType as FCType, type models_FSType as FSType, type models_Frame as Frame, type models_Genre as Genre, type models_Icon as Icon, models_LevelIndex as LevelIndex, type models_NamePlate as NamePlate, type models_Notes as Notes, type models_Player as Player, type models_RateType as RateType, type models_RatingTrend as RatingTrend, type models_Score as Score, type models_SimpleScore as SimpleScore, type Song$1 as Song, type models_SongDifficulties as SongDifficulties, type models_SongDifficulty as SongDifficulty, type models_SongDifficultyUtage as SongDifficultyUtage, type models_SongType as SongType, type models_Trophy as Trophy, type models_Version as Version };
284
286
  }
285
287
 
286
288
  interface SongList {
@@ -513,9 +515,13 @@ type Simplify<T> = {
513
515
  [K in keyof T]: T[K];
514
516
  } & {};
515
517
  type IfDefined<T, Then, Else = {}> = [T] extends [NonNullable<T>] ? Then : Else;
516
- type MaiMaiOf<O extends Flags> = Simplify<{
518
+ type MaiMai = {
517
519
  public: MaimaiPublicApi;
518
- } & IfDefined<O["devAccessToken"], {
520
+ dev?: MaimaiDevApi;
521
+ personal?: MaimaiPersonalApi;
522
+ getAsset: (type: AssetType, id: number) => Promise<Buffer>;
523
+ };
524
+ type MaiMaiOf<O extends Flags> = Simplify<Omit<MaiMai, "dev" | "personal"> & IfDefined<O["devAccessToken"], {
519
525
  dev: MaimaiDevApi;
520
526
  }> & IfDefined<O["personalAccessToken"], {
521
527
  personal: MaimaiPersonalApi;
package/dist/index.js CHANGED
@@ -334,7 +334,14 @@ var LxnsApiClient = class {
334
334
  }
335
335
  }) : void 0;
336
336
  const maimai = {
337
- public: new MaimaiPublicApi(httpPublic)
337
+ public: new MaimaiPublicApi(httpPublic),
338
+ getAsset: async (type, id) => {
339
+ return Buffer.from(
340
+ await ky.get(
341
+ `https://assets2.lxns.net/maimai/${type}/${id + (type === "music" ? ".mp3" : ".png")}`
342
+ ).arrayBuffer()
343
+ );
344
+ }
338
345
  };
339
346
  if (httpDev) {
340
347
  maimai.dev = new MaimaiDevApi(httpDev);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lxns-rhythm-api",
3
3
  "description": "A simple SDK for lxns api.",
4
4
  "author": "amatsuka <amatsukamao@qq.com>",
5
- "version": "0.1.2",
5
+ "version": "0.1.4",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/wsyzxjn/lxns-rhythm-api.git"
@@ -19,10 +19,19 @@
19
19
  "README.md",
20
20
  "LICENSE"
21
21
  ],
22
+ "packageManager": "pnpm@10.16.1",
22
23
  "type": "module",
23
24
  "main": "./dist/index.js",
24
25
  "module": "./dist/index.js",
25
26
  "types": "./dist/index.d.ts",
27
+ "scripts": {
28
+ "lint": "eslint --ext .ts,.js src",
29
+ "prettier": "prettier --write 'src/**/*.ts'",
30
+ "test": "tsx tests/index.ts",
31
+ "build": "tsup",
32
+ "build:production": "cross-env NODE_ENV=production tsup",
33
+ "prepublishOnly": "pnpm run prettier && pnpm run build"
34
+ },
26
35
  "devDependencies": {
27
36
  "@types/node": "^24.5.1",
28
37
  "@typescript-eslint/eslint-plugin": "^8.44.0",
@@ -37,12 +46,5 @@
37
46
  },
38
47
  "dependencies": {
39
48
  "ky": "^1.10.0"
40
- },
41
- "scripts": {
42
- "lint": "eslint --ext .ts,.js src",
43
- "prettier": "prettier --write 'src/**/*.ts'",
44
- "test": "tsx tests/index.ts",
45
- "build": "tsup",
46
- "build:production": "cross-env NODE_ENV=production tsup"
47
49
  }
48
- }
50
+ }