@seayoo-web/pixi-live2d 0.0.10 → 0.1.1

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,30 +1,27 @@
1
1
  {
2
2
  "name": "@seayoo-web/pixi-live2d",
3
+ "version": "0.1.1",
3
4
  "description": "pixi-live2d viewer",
4
- "version": "0.0.10",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
5
+ "keywords": [
6
+ "pixi-live2d"
7
+ ],
8
+ "license": "MIT",
9
+ "author": "web@seayoo.com",
8
10
  "source": "./index.ts",
9
- "types": "./types/index.d.ts",
10
- "sideEffects": false,
11
11
  "files": [
12
12
  "dist",
13
13
  "types",
14
14
  "docs",
15
15
  "README.md"
16
16
  ],
17
+ "type": "module",
18
+ "sideEffects": false,
19
+ "main": "./dist/index.js",
20
+ "module": "./dist/index.js",
21
+ "types": "./types/index.d.ts",
17
22
  "publishConfig": {
18
23
  "access": "public"
19
24
  },
20
- "engines": {
21
- "node": ">=22"
22
- },
23
- "keywords": [
24
- "pixi-live2d"
25
- ],
26
- "author": "web@seayoo.com",
27
- "license": "MIT",
28
25
  "dependencies": {
29
26
  "@pixi/constants": "6.5.2",
30
27
  "@pixi/core": "6.5.2",
@@ -43,13 +40,16 @@
43
40
  "devDependencies": {
44
41
  "@types/node": "^22.13.1",
45
42
  "@seayoo-web/tsconfig": "^1.0.6",
46
- "@seayoo-web/utils": "^4.4.1"
43
+ "@seayoo-web/utils": "^4.5.2"
44
+ },
45
+ "engines": {
46
+ "node": ">=22"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "vite build && tsc --build --force --emitDeclarationOnly",
50
50
  "type-check": "tsc --noEmit",
51
- "lint": "eslint ./**/*.ts",
52
- "lint:fix": "eslint ./**/*.ts --fix",
51
+ "lint": "oxlint -c ../../oxlint.config.mjs",
52
+ "lint:fix": "oxlint -c ../../oxlint.config.mjs --fix",
53
53
  "prepublish": "pnpm lint:fix && pnpm build",
54
54
  "test": "vitest --dom",
55
55
  "coverage": "vitest run --coverage"
package/types/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import { InternalModel, Live2DModel, MotionPriority } from "pixi-live2d-display/cubism4";
2
1
  import * as PIXI from "pixi.js";
2
+ declare const coreLoadPromise: Promise<boolean>;
3
+ export { coreLoadPromise };
4
+ import type { InternalModel as InternalModelType, Live2DModel as Live2DModelType } from "pixi-live2d-display/cubism4";
5
+ export type { MotionPriority } from "pixi-live2d-display/cubism4";
3
6
  declare global {
4
7
  interface Window {
5
8
  PIXI?: typeof PIXI;
@@ -28,13 +31,13 @@ export interface Live2DViewerOptions {
28
31
  /** 是否响应点击事件触发 TapBody 动作,默认为 true */
29
32
  enableTapBody?: boolean;
30
33
  /** 模型加载完成后的回调函数 */
31
- onModelLoaded?: (model: Live2DModel<InternalModel>) => void;
34
+ onModelLoaded?: (model: Live2DModelType<InternalModelType>) => void;
32
35
  /** 模型加载失败的回调函数 */
33
36
  onModelError?: (error: Error) => void;
34
37
  }
35
- export { MotionPriority } from "pixi-live2d-display/cubism4";
36
- export { Live2DModel } from "pixi-live2d-display/cubism4";
37
38
  export declare class Live2DViewer {
39
+ /** 单例 PIXI 应用 */
40
+ static sharedApp: PIXI.Application | null;
38
41
  /** 引擎加载状态 Promise,用于确保全局只加载一次 Core 库 */
39
42
  private static coreLoadingPromise;
40
43
  /**
@@ -42,10 +45,14 @@ export declare class Live2DViewer {
42
45
  * @param url - Core 库的 URL 地址
43
46
  */
44
47
  static loadCubismCore(url?: string): Promise<void>;
48
+ /** 最新发起的加载任务 token,防频繁加载的竞态泄漏 */
49
+ private static loadingToken;
50
+ /** 整个页面生命周期内 Cubism 渲染管线是否已完成首次预热 */
51
+ private static hasWarmedUp;
45
52
  /** PIXI 应用实例 */
46
53
  app: PIXI.Application;
47
54
  /** Live2D 模型实例 */
48
- model: Live2DModel<InternalModel> | null;
55
+ model: Live2DModelType<InternalModelType> | null;
49
56
  /** 配置项副本 */
50
57
  private options;
51
58
  /**
@@ -86,7 +93,7 @@ export declare class Live2DViewer {
86
93
  * @param startTime - 动作开始时间(秒),默认值为 0
87
94
  * @returns Promise,动作开始播放后 resolve
88
95
  */
89
- startMotion(group: string, no: number, priority?: MotionPriority, startTime?: number): Promise<boolean>;
96
+ startMotion(group: string, no: number, priority?: number, startTime?: number): Promise<boolean>;
90
97
  /**
91
98
  * 播放指定表情
92
99
  * @param name - 表情名称或索引
@@ -94,13 +101,6 @@ export declare class Live2DViewer {
94
101
  expression(name: string | number): Promise<boolean> | undefined;
95
102
  /** 等待当前动作播放结束 */
96
103
  waitForMotionFinish(): Promise<boolean>;
97
- /**
98
- * 启用动作循环播放模式
99
- * 从第 startTime 秒开始循环播放,直到动画结束
100
- * @param startTime - 循环开始时间(秒),默认为 2 秒
101
- * @returns 停止循环的函数
102
- */
103
- loop(startTime?: number): () => void;
104
104
  /** 销毁实例,清理资源和监听器 */
105
105
  destroy(): void;
106
106
  }