@doki-land/live2d-core 0.0.23 → 0.0.24

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/dist/index.d.ts CHANGED
@@ -66,7 +66,7 @@ interface FrameProfile {
66
66
  readonly indexCount: number;
67
67
  }
68
68
  /** Minimal event bus used by sessions and loaders. */
69
- type Live2DEventMap = {
69
+ type Live2dEventMap = {
70
70
  ready: {
71
71
  modelId: string;
72
72
  };
@@ -96,13 +96,19 @@ type Live2DEventMap = {
96
96
  generation: number;
97
97
  };
98
98
  };
99
- type Live2DEventName = keyof Live2DEventMap;
100
- type Live2DListener<K extends Live2DEventName> = (payload: Live2DEventMap[K]) => void;
99
+ type Live2dEventName = keyof Live2dEventMap;
100
+ type Live2dListener<K extends Live2dEventName> = (payload: Live2dEventMap[K]) => void;
101
+ /** @deprecated Use `Live2dEventMap`. */
102
+ type Live2DEventMap = Live2dEventMap;
103
+ /** @deprecated Use `Live2dEventName`. */
104
+ type Live2DEventName = Live2dEventName;
105
+ /** @deprecated Use `Live2dListener`. */
106
+ type Live2DListener<K extends Live2dEventName> = Live2dListener<K>;
101
107
  declare class EventEmitter {
102
108
  #private;
103
- on<K extends Live2DEventName>(event: K, listener: Live2DListener<K>): () => void;
104
- off<K extends Live2DEventName>(event: K, listener: Live2DListener<K>): void;
105
- emit<K extends Live2DEventName>(event: K, payload: Live2DEventMap[K]): void;
109
+ on<K extends Live2dEventName>(event: K, listener: Live2dListener<K>): () => void;
110
+ off<K extends Live2dEventName>(event: K, listener: Live2dListener<K>): void;
111
+ emit<K extends Live2dEventName>(event: K, payload: Live2dEventMap[K]): void;
106
112
  clear(): void;
107
113
  }
108
114
 
@@ -248,19 +254,23 @@ interface ModelInstance {
248
254
  }
249
255
 
250
256
  /** High-level runtime session for one mounted surface. */
251
- interface Live2DSession {
257
+ interface Live2dSession {
252
258
  readonly events: EventEmitter;
253
259
  readonly model: InternalModel | null;
254
260
  readonly state: SessionState;
255
261
  mount(canvas: HTMLCanvasElement): void;
256
- loadModel(source: ModelSource, resolver?: AssetResolver): Promise<InternalModel>;
262
+ loadModel(source: ModelSource, resolver?: AssetResolver, options?: {
263
+ signal?: AbortSignal;
264
+ }): Promise<InternalModel>;
257
265
  /** Latest CPU frame after update, or null if no model. */
258
266
  captureFrame(): FrameSnapshot | null;
259
267
  update(deltaTimeSeconds: number): void;
260
268
  hitTest(x: number, y: number): string | null;
261
269
  destroy(): void;
262
270
  }
263
- declare function createSessionStub(): Live2DSession;
271
+ /** @deprecated Use `Live2dSession`. */
272
+ type Live2DSession = Live2dSession;
273
+ declare function createSessionStub(): Live2dSession;
264
274
 
265
275
  /** Normalized stage placement for one actor (0,0) top-left → (1,1) bottom-right. */
266
276
  interface ActorTransform {
@@ -417,4 +427,4 @@ interface Live2dStage {
417
427
 
418
428
  declare const LIVE2D_CORE_VERSION: "0.0.0";
419
429
 
420
- export { type ActorHit, type ActorInstance, type ActorTransform, type AssetKey, type AssetResolver, type CreateActorOptions, type CreateLive2dStageOptions, DEFAULT_ACTOR_TRANSFORM, type DrawableProgram, EventEmitter, type ExpressionDefinition, FrameBlendMode, type FrameDrawable, type FrameProfile, type FrameSnapshot, type HitAreaDefinition, type InternalModel, LIVE2D_CORE_VERSION, type Live2DEventMap, type Live2DEventName, type Live2DListener, type Live2DSession, type Live2dActor, type Live2dStage, type Live2dStageAssets, type LoadProgress, type LoadProgressStage, type ModelAsset, type ModelFormat, type ModelInstance, type ModelProgram, type ModelSettings, type ModelSource, type MotionDefinition, type ParameterProgram, type PlayMotionActorOptions, type PointerTrackingMode, type PointerTrackingPolicy, type SessionPhase, type SessionState, type StagePointerEvent, type StageUpdateMode, createSessionStub, detectModelSettingsFormat, modelSourceUrl };
430
+ export { type ActorHit, type ActorInstance, type ActorTransform, type AssetKey, type AssetResolver, type CreateActorOptions, type CreateLive2dStageOptions, DEFAULT_ACTOR_TRANSFORM, type DrawableProgram, EventEmitter, type ExpressionDefinition, FrameBlendMode, type FrameDrawable, type FrameProfile, type FrameSnapshot, type HitAreaDefinition, type InternalModel, LIVE2D_CORE_VERSION, type Live2DEventMap, type Live2DEventName, type Live2DListener, type Live2DSession, type Live2dActor, type Live2dEventMap, type Live2dEventName, type Live2dListener, type Live2dSession, type Live2dStage, type Live2dStageAssets, type LoadProgress, type LoadProgressStage, type ModelAsset, type ModelFormat, type ModelInstance, type ModelProgram, type ModelSettings, type ModelSource, type MotionDefinition, type ParameterProgram, type PlayMotionActorOptions, type PointerTrackingMode, type PointerTrackingPolicy, type SessionPhase, type SessionState, type StagePointerEvent, type StageUpdateMode, createSessionStub, detectModelSettingsFormat, modelSourceUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doki-land/live2d-core",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Shared TypeScript contracts for live2d.ts — ModelSource, Live2dStage/Actor, ModelAsset, events (no DOM/GPU).",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/events.ts CHANGED
@@ -37,7 +37,7 @@ export interface FrameProfile {
37
37
  }
38
38
 
39
39
  /** Minimal event bus used by sessions and loaders. */
40
- export type Live2DEventMap = {
40
+ export type Live2dEventMap = {
41
41
  ready: { modelId: string };
42
42
  error: { error: unknown };
43
43
  progress: LoadProgress;
@@ -49,18 +49,25 @@ export type Live2DEventMap = {
49
49
  phase: { phase: string; generation: number };
50
50
  };
51
51
 
52
- export type Live2DEventName = keyof Live2DEventMap;
52
+ export type Live2dEventName = keyof Live2dEventMap;
53
53
 
54
- export type Live2DListener<K extends Live2DEventName> = (
55
- payload: Live2DEventMap[K],
54
+ export type Live2dListener<K extends Live2dEventName> = (
55
+ payload: Live2dEventMap[K],
56
56
  ) => void;
57
57
 
58
+ /** @deprecated Use `Live2dEventMap`. */
59
+ export type Live2DEventMap = Live2dEventMap;
60
+ /** @deprecated Use `Live2dEventName`. */
61
+ export type Live2DEventName = Live2dEventName;
62
+ /** @deprecated Use `Live2dListener`. */
63
+ export type Live2DListener<K extends Live2dEventName> = Live2dListener<K>;
64
+
58
65
  export class EventEmitter {
59
66
  #listeners = new Map<string, Set<(payload: unknown) => void>>();
60
67
 
61
- on<K extends Live2DEventName>(
68
+ on<K extends Live2dEventName>(
62
69
  event: K,
63
- listener: Live2DListener<K>,
70
+ listener: Live2dListener<K>,
64
71
  ): () => void {
65
72
  const set = this.#listeners.get(event) ?? new Set();
66
73
  set.add(listener as (payload: unknown) => void);
@@ -68,18 +75,18 @@ export class EventEmitter {
68
75
  return () => this.off(event, listener);
69
76
  }
70
77
 
71
- off<K extends Live2DEventName>(
78
+ off<K extends Live2dEventName>(
72
79
  event: K,
73
- listener: Live2DListener<K>,
80
+ listener: Live2dListener<K>,
74
81
  ): void {
75
82
  this.#listeners
76
83
  .get(event)
77
84
  ?.delete(listener as (payload: unknown) => void);
78
85
  }
79
86
 
80
- emit<K extends Live2DEventName>(
87
+ emit<K extends Live2dEventName>(
81
88
  event: K,
82
- payload: Live2DEventMap[K],
89
+ payload: Live2dEventMap[K],
83
90
  ): void {
84
91
  for (const listener of this.#listeners.get(event) ?? []) {
85
92
  listener(payload);
package/src/index.ts CHANGED
@@ -19,11 +19,17 @@ export { modelSourceUrl } from "./contracts.js";
19
19
  export {
20
20
  EventEmitter,
21
21
  type FrameProfile,
22
+ type Live2dEventMap,
23
+ type Live2dEventName,
24
+ type Live2dListener,
25
+ type LoadProgress,
26
+ type LoadProgressStage,
27
+ /** @deprecated Use `Live2dEventMap`. */
22
28
  type Live2DEventMap,
29
+ /** @deprecated Use `Live2dEventName`. */
23
30
  type Live2DEventName,
31
+ /** @deprecated Use `Live2dListener`. */
24
32
  type Live2DListener,
25
- type LoadProgress,
26
- type LoadProgressStage,
27
33
  } from "./events.js";
28
34
  export { detectModelSettingsFormat } from "./format/detect-format.js";
29
35
  export {
@@ -52,6 +58,8 @@ export type {
52
58
  } from "./program.js";
53
59
  export {
54
60
  createSessionStub,
61
+ type Live2dSession,
62
+ /** @deprecated Use `Live2dSession`. */
55
63
  type Live2DSession,
56
64
  } from "./session.js";
57
65
  export type {
package/src/session.ts CHANGED
@@ -4,7 +4,7 @@ import type { FrameSnapshot } from "./frame.js";
4
4
  import type { InternalModel } from "./model/model.js";
5
5
 
6
6
  /** High-level runtime session for one mounted surface. */
7
- export interface Live2DSession {
7
+ export interface Live2dSession {
8
8
  readonly events: EventEmitter;
9
9
  readonly model: InternalModel | null;
10
10
  readonly state: SessionState;
@@ -14,6 +14,7 @@ export interface Live2DSession {
14
14
  loadModel(
15
15
  source: ModelSource,
16
16
  resolver?: AssetResolver,
17
+ options?: { signal?: AbortSignal },
17
18
  ): Promise<InternalModel>;
18
19
 
19
20
  /** Latest CPU frame after update, or null if no model. */
@@ -26,7 +27,10 @@ export interface Live2DSession {
26
27
  destroy(): void;
27
28
  }
28
29
 
29
- export function createSessionStub(): Live2DSession {
30
+ /** @deprecated Use `Live2dSession`. */
31
+ export type Live2DSession = Live2dSession;
32
+
33
+ export function createSessionStub(): Live2dSession {
30
34
  let canvas: HTMLCanvasElement | null = null;
31
35
  let model: InternalModel | null = null;
32
36
  const events = new EventEmitter();