@laplace.live/pixijs-live2d 0.2.0 → 0.4.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/dist/extra.d.ts +1 -2
- package/dist/index.d.ts +67 -64
- package/dist/index.js +48 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/extra.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Graphics, Renderer, Text } from "pixi.js";
|
|
2
2
|
//#region src/tools/HitAreaFrames.d.ts
|
|
3
|
-
declare class HitAreaFrames extends Graphics {
|
|
3
|
+
export declare class HitAreaFrames extends Graphics {
|
|
4
4
|
initialized: boolean;
|
|
5
5
|
texts: Text[];
|
|
6
6
|
strokeWidth: number;
|
|
@@ -12,5 +12,4 @@ declare class HitAreaFrames extends Graphics {
|
|
|
12
12
|
protected _render(renderer: Renderer): void;
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
|
-
export { HitAreaFrames };
|
|
16
15
|
//# sourceMappingURL=extra.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -103,17 +103,17 @@ declare class CubismIdManager {
|
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region vendor/cubism/src/live2dcubismframework.d.ts
|
|
106
|
-
declare function strtod(s: string, endPtr: string[]): number;
|
|
106
|
+
export declare function strtod(s: string, endPtr: string[]): number;
|
|
107
107
|
/**
|
|
108
108
|
* Framework内で使う定数の宣言
|
|
109
109
|
*/
|
|
110
|
-
declare const Constant: Readonly<Record<string, number>>;
|
|
111
|
-
declare function csmDelete<T>(address: T): void;
|
|
110
|
+
export declare const Constant: Readonly<Record<string, number>>;
|
|
111
|
+
export declare function csmDelete<T>(address: T): void;
|
|
112
112
|
/**
|
|
113
113
|
* Live2D Cubism SDK Original Workflow SDKのエントリポイント
|
|
114
114
|
* 利用開始時はCubismFramework.initialize()を呼び、CubismFramework.dispose()で終了する。
|
|
115
115
|
*/
|
|
116
|
-
declare class CubismFramework {
|
|
116
|
+
export declare class CubismFramework {
|
|
117
117
|
/**
|
|
118
118
|
* Cubism FrameworkのAPIを使用可能にする。
|
|
119
119
|
* APIを実行する前に必ずこの関数を実行すること。
|
|
@@ -178,14 +178,14 @@ declare class CubismFramework {
|
|
|
178
178
|
*/
|
|
179
179
|
private constructor();
|
|
180
180
|
}
|
|
181
|
-
declare class Option {
|
|
181
|
+
export declare class Option {
|
|
182
182
|
logFunction: Live2DCubismCore.csmLogFunction;
|
|
183
183
|
loggingLevel: LogLevel;
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* ログ出力のレベル
|
|
187
187
|
*/
|
|
188
|
-
declare enum LogLevel {
|
|
188
|
+
export declare enum LogLevel {
|
|
189
189
|
LogLevel_Verbose = 0 // 詳細ログ
|
|
190
190
|
,
|
|
191
191
|
LogLevel_Debug = 1 // デバッグログ
|
|
@@ -200,8 +200,8 @@ declare enum LogLevel {
|
|
|
200
200
|
}
|
|
201
201
|
//#endregion
|
|
202
202
|
//#region src/cubism-common/constants.d.ts
|
|
203
|
-
declare const LOGICAL_WIDTH = 2;
|
|
204
|
-
declare const LOGICAL_HEIGHT = 2;
|
|
203
|
+
export declare const LOGICAL_WIDTH = 2;
|
|
204
|
+
export declare const LOGICAL_HEIGHT = 2;
|
|
205
205
|
//#endregion
|
|
206
206
|
//#region src/types/helpers.d.ts
|
|
207
207
|
type JSONObject = object;
|
|
@@ -211,7 +211,7 @@ type Mutable<T> = { -readonly [P in keyof T]: T[P]; };
|
|
|
211
211
|
/**
|
|
212
212
|
* Parses, and provides access to the settings JSON.
|
|
213
213
|
*/
|
|
214
|
-
declare abstract class ModelSettings {
|
|
214
|
+
export declare abstract class ModelSettings {
|
|
215
215
|
json: JSONObject;
|
|
216
216
|
/**
|
|
217
217
|
* The model's name, typically used for displaying or logging. By default it's inferred from
|
|
@@ -2724,7 +2724,7 @@ interface CommonLayout {
|
|
|
2724
2724
|
/**
|
|
2725
2725
|
* Indicates the motion priority.
|
|
2726
2726
|
*/
|
|
2727
|
-
declare enum MotionPriority {
|
|
2727
|
+
export declare enum MotionPriority {
|
|
2728
2728
|
/** States that the model is currently not playing any motion. This priority cannot be applied to a motion. */
|
|
2729
2729
|
NONE = 0,
|
|
2730
2730
|
/** Low priority, used when starting idle motions automatically. */
|
|
@@ -2737,7 +2737,7 @@ declare enum MotionPriority {
|
|
|
2737
2737
|
/**
|
|
2738
2738
|
* Handles the state of a MotionManager.
|
|
2739
2739
|
*/
|
|
2740
|
-
declare class MotionState {
|
|
2740
|
+
export declare class MotionState {
|
|
2741
2741
|
/**
|
|
2742
2742
|
* Tag for logging.
|
|
2743
2743
|
*/
|
|
@@ -2937,7 +2937,7 @@ declare abstract class ParallelMotionManager<Motion = never, MotionSpec = never>
|
|
|
2937
2937
|
/**
|
|
2938
2938
|
* Interpolates the transition of focus position.
|
|
2939
2939
|
*/
|
|
2940
|
-
declare class FocusController {
|
|
2940
|
+
export declare class FocusController {
|
|
2941
2941
|
/** The focus position. */
|
|
2942
2942
|
targetX: number;
|
|
2943
2943
|
/** The focus position. */
|
|
@@ -2968,19 +2968,19 @@ declare class FocusController {
|
|
|
2968
2968
|
/**
|
|
2969
2969
|
* Common hit area definition shared between all Cubism versions.
|
|
2970
2970
|
*/
|
|
2971
|
-
interface CommonHitArea {
|
|
2971
|
+
export interface CommonHitArea {
|
|
2972
2972
|
id: string;
|
|
2973
2973
|
name: string;
|
|
2974
2974
|
index: number;
|
|
2975
2975
|
}
|
|
2976
|
-
declare function normalizeHitAreaDefs(raw: unknown, resolveIndex: (id: string) => number): CommonHitArea[];
|
|
2977
|
-
interface Bounds {
|
|
2976
|
+
export declare function normalizeHitAreaDefs(raw: unknown, resolveIndex: (id: string) => number): CommonHitArea[];
|
|
2977
|
+
export interface Bounds {
|
|
2978
2978
|
x: number;
|
|
2979
2979
|
y: number;
|
|
2980
2980
|
width: number;
|
|
2981
2981
|
height: number;
|
|
2982
2982
|
}
|
|
2983
|
-
interface InternalModelOptions extends MotionManagerOptions {
|
|
2983
|
+
export interface InternalModelOptions extends MotionManagerOptions {
|
|
2984
2984
|
/**
|
|
2985
2985
|
* Define natural movements depth (0.0-1.0).
|
|
2986
2986
|
* @default 1.0
|
|
@@ -3012,7 +3012,7 @@ interface InternalModelOptions extends MotionManagerOptions {
|
|
|
3012
3012
|
* A wrapper that manages the states of a Live2D core model, and delegates all operations to it.
|
|
3013
3013
|
* @emits {@link InternalModelEvents}
|
|
3014
3014
|
*/
|
|
3015
|
-
declare abstract class InternalModel extends EventEmitter {
|
|
3015
|
+
export declare abstract class InternalModel extends EventEmitter {
|
|
3016
3016
|
/**
|
|
3017
3017
|
* The managed Live2D core model.
|
|
3018
3018
|
*/
|
|
@@ -3198,7 +3198,7 @@ declare abstract class InternalModel extends EventEmitter {
|
|
|
3198
3198
|
}
|
|
3199
3199
|
//#endregion
|
|
3200
3200
|
//#region src/cubism-common/MotionManager.d.ts
|
|
3201
|
-
interface MotionManagerOptions {
|
|
3201
|
+
export interface MotionManagerOptions {
|
|
3202
3202
|
/**
|
|
3203
3203
|
* How to preload the motions.
|
|
3204
3204
|
* @default {@link MotionPreloadStrategy.NONE}
|
|
@@ -3215,7 +3215,7 @@ interface MotionManagerOptions {
|
|
|
3215
3215
|
*/
|
|
3216
3216
|
checkMotionConsistency?: boolean;
|
|
3217
3217
|
}
|
|
3218
|
-
interface MotionStartOptions {
|
|
3218
|
+
export interface MotionStartOptions {
|
|
3219
3219
|
sound?: string;
|
|
3220
3220
|
volume?: number;
|
|
3221
3221
|
expression?: number | string;
|
|
@@ -3228,11 +3228,11 @@ interface MotionStartOptions {
|
|
|
3228
3228
|
*/
|
|
3229
3229
|
loop?: boolean;
|
|
3230
3230
|
}
|
|
3231
|
-
type MotionStartRandomOptions = Omit<MotionStartOptions, 'ignoreParamIds'>;
|
|
3231
|
+
export type MotionStartRandomOptions = Omit<MotionStartOptions, 'ignoreParamIds'>;
|
|
3232
3232
|
/**
|
|
3233
3233
|
* Indicates how the motions will be preloaded.
|
|
3234
3234
|
*/
|
|
3235
|
-
declare enum MotionPreloadStrategy {
|
|
3235
|
+
export declare enum MotionPreloadStrategy {
|
|
3236
3236
|
/** Preload all the motions. */
|
|
3237
3237
|
ALL = "ALL",
|
|
3238
3238
|
/** Preload only the idle motions. */
|
|
@@ -3245,7 +3245,7 @@ declare enum MotionPreloadStrategy {
|
|
|
3245
3245
|
* Responsible for loading, playing, and managing motion states and audio.
|
|
3246
3246
|
* @emits {@link MotionManagerEvents}
|
|
3247
3247
|
*/
|
|
3248
|
-
declare abstract class MotionManager<Motion = unknown, MotionSpec = unknown> extends EventEmitter {
|
|
3248
|
+
export declare abstract class MotionManager<Motion = unknown, MotionSpec = unknown> extends EventEmitter {
|
|
3249
3249
|
/**
|
|
3250
3250
|
* Tag for logging.
|
|
3251
3251
|
* @type {string}
|
|
@@ -3530,7 +3530,7 @@ declare abstract class MotionManager<Motion = unknown, MotionSpec = unknown> ext
|
|
|
3530
3530
|
* any number can be active at once, each fading in/out on its own.
|
|
3531
3531
|
* @emits {@link ExpressionManagerEvents}
|
|
3532
3532
|
*/
|
|
3533
|
-
declare abstract class ExpressionManager<Expression = unknown, ExpressionSpec = unknown> extends EventEmitter<keyof ExpressionManagerEvents> {
|
|
3533
|
+
export declare abstract class ExpressionManager<Expression = unknown, ExpressionSpec = unknown> extends EventEmitter<keyof ExpressionManagerEvents> {
|
|
3534
3534
|
/**
|
|
3535
3535
|
* Indicates the content type used when loading expressions.
|
|
3536
3536
|
* @default "json"
|
|
@@ -3693,11 +3693,13 @@ declare abstract class ExpressionManager<Expression = unknown, ExpressionSpec =
|
|
|
3693
3693
|
}
|
|
3694
3694
|
//#endregion
|
|
3695
3695
|
//#region src/cubism-common/SoundManager.d.ts
|
|
3696
|
-
declare const VOLUME = 0.5;
|
|
3696
|
+
export declare const VOLUME = 0.5;
|
|
3697
3697
|
/**
|
|
3698
3698
|
* Manages all the sounds.
|
|
3699
3699
|
*/
|
|
3700
|
-
declare class SoundManager {
|
|
3700
|
+
export declare class SoundManager {
|
|
3701
|
+
/** Select the speaker used by current and future motion audio and speak() calls. */
|
|
3702
|
+
static setOutputDevice(deviceId: string): Promise<void>;
|
|
3701
3703
|
/**
|
|
3702
3704
|
* Audio elements playing or pending to play. Finished audios will be removed automatically.
|
|
3703
3705
|
*/
|
|
@@ -3873,7 +3875,7 @@ declare const CSM_LOG_LEVEL: number;
|
|
|
3873
3875
|
/**
|
|
3874
3876
|
* Global configs.
|
|
3875
3877
|
*/
|
|
3876
|
-
declare const config: {
|
|
3878
|
+
export declare const config: {
|
|
3877
3879
|
LOG_LEVEL_VERBOSE: number;
|
|
3878
3880
|
LOG_LEVEL_WARNING: number;
|
|
3879
3881
|
LOG_LEVEL_ERROR: number;
|
|
@@ -4020,7 +4022,7 @@ declare module '@/cubism-common/ModelSettings' {
|
|
|
4020
4022
|
_objectURL?: string;
|
|
4021
4023
|
}
|
|
4022
4024
|
}
|
|
4023
|
-
type ExtendedFileList = File[] & {
|
|
4025
|
+
export type ExtendedFileList = File[] & {
|
|
4024
4026
|
settings?: ModelSettings;
|
|
4025
4027
|
};
|
|
4026
4028
|
/**
|
|
@@ -4033,7 +4035,7 @@ type ExtendedFileList = File[] & {
|
|
|
4033
4035
|
* Though named as a "Loader", this class has nothing to do with Live2DLoader,
|
|
4034
4036
|
* it only contains a middleware for the Live2DFactory.
|
|
4035
4037
|
*/
|
|
4036
|
-
declare class FileLoader {
|
|
4038
|
+
export declare class FileLoader {
|
|
4037
4039
|
static live2dFactory?: typeof Live2DFactory;
|
|
4038
4040
|
/**
|
|
4039
4041
|
* Stores all the object URLs of uploaded files.
|
|
@@ -4139,10 +4141,10 @@ declare class Automator {
|
|
|
4139
4141
|
/**
|
|
4140
4142
|
* Useless class. May be useful in the future.
|
|
4141
4143
|
*/
|
|
4142
|
-
declare class Live2DTransform extends Transform {}
|
|
4144
|
+
export declare class Live2DTransform extends Transform {}
|
|
4143
4145
|
//#endregion
|
|
4144
4146
|
//#region src/Live2DModel.d.ts
|
|
4145
|
-
interface Live2DModelOptions extends InternalModelOptions, AutomatorOptions {
|
|
4147
|
+
export interface Live2DModelOptions extends InternalModelOptions, AutomatorOptions {
|
|
4146
4148
|
/**
|
|
4147
4149
|
* Defines which bounds are used to resolve the normalized {@link Live2DModel.anchor}.
|
|
4148
4150
|
* `'canvas'` preserves the historical model-canvas behavior, while `'drawable'`
|
|
@@ -4159,7 +4161,7 @@ interface Live2DModelOptions extends InternalModelOptions, AutomatorOptions {
|
|
|
4159
4161
|
*/
|
|
4160
4162
|
textureOptions?: Live2DTextureSourceOptions;
|
|
4161
4163
|
}
|
|
4162
|
-
type Live2DConstructor = {
|
|
4164
|
+
export type Live2DConstructor = {
|
|
4163
4165
|
new (options?: Live2DModelOptions): Live2DModel;
|
|
4164
4166
|
};
|
|
4165
4167
|
type Live2DPrepareInstruction = {
|
|
@@ -4200,7 +4202,7 @@ declare class Live2DPipe {
|
|
|
4200
4202
|
* extensions.add(Live2DPlugin)
|
|
4201
4203
|
* ```
|
|
4202
4204
|
*/
|
|
4203
|
-
declare const Live2DPlugin: typeof Live2DPipe;
|
|
4205
|
+
export declare const Live2DPlugin: typeof Live2DPipe;
|
|
4204
4206
|
/**
|
|
4205
4207
|
* A wrapper that allows the Live2D model to be used as a DisplayObject in PixiJS.
|
|
4206
4208
|
*
|
|
@@ -4210,7 +4212,7 @@ declare const Live2DPlugin: typeof Live2DPipe;
|
|
|
4210
4212
|
* ```
|
|
4211
4213
|
* @emits {@link Live2DModelEvents}
|
|
4212
4214
|
*/
|
|
4213
|
-
declare class Live2DModel<IM extends InternalModel = InternalModel> extends Container {
|
|
4215
|
+
export declare class Live2DModel<IM extends InternalModel = InternalModel> extends Container {
|
|
4214
4216
|
/** @internal */
|
|
4215
4217
|
renderPipeId: string;
|
|
4216
4218
|
/** @internal */
|
|
@@ -4521,7 +4523,7 @@ declare class Live2DModel<IM extends InternalModel = InternalModel> extends Cont
|
|
|
4521
4523
|
}
|
|
4522
4524
|
//#endregion
|
|
4523
4525
|
//#region src/factory/Live2DFactory.d.ts
|
|
4524
|
-
interface Live2DFactoryOptions extends Live2DModelOptions {
|
|
4526
|
+
export interface Live2DFactoryOptions extends Live2DModelOptions {
|
|
4525
4527
|
/**
|
|
4526
4528
|
* Whether to check the consistency of the moc file. It's an internal
|
|
4527
4529
|
* function of Cubism core and only available since Cubism 4 R7.
|
|
@@ -4560,7 +4562,7 @@ interface Live2DFactoryOptions extends Live2DModelOptions {
|
|
|
4560
4562
|
/**
|
|
4561
4563
|
* The context transferred through the model creation middlewares.
|
|
4562
4564
|
*/
|
|
4563
|
-
interface Live2DFactoryContext {
|
|
4565
|
+
export interface Live2DFactoryContext {
|
|
4564
4566
|
source: any;
|
|
4565
4567
|
options: Live2DFactoryOptions;
|
|
4566
4568
|
live2dModel: Live2DModel;
|
|
@@ -4570,7 +4572,7 @@ interface Live2DFactoryContext {
|
|
|
4570
4572
|
/**
|
|
4571
4573
|
* Represents a Cubism version.
|
|
4572
4574
|
*/
|
|
4573
|
-
interface Live2DRuntime {
|
|
4575
|
+
export interface Live2DRuntime {
|
|
4574
4576
|
/**
|
|
4575
4577
|
* The version number. Higher version takes priority when matching the runtime.
|
|
4576
4578
|
*/
|
|
@@ -4631,7 +4633,7 @@ interface Live2DRuntime {
|
|
|
4631
4633
|
* - Motion loading: implements the load method of MotionManager.
|
|
4632
4634
|
* - Expression loading: implements the load method of ExpressionManager.
|
|
4633
4635
|
*/
|
|
4634
|
-
declare class Live2DFactory {
|
|
4636
|
+
export declare class Live2DFactory {
|
|
4635
4637
|
/**
|
|
4636
4638
|
* All registered runtimes, sorted by versions in descending order.
|
|
4637
4639
|
*/
|
|
@@ -4695,11 +4697,11 @@ declare class Live2DFactory {
|
|
|
4695
4697
|
}
|
|
4696
4698
|
//#endregion
|
|
4697
4699
|
//#region src/factory/Live2DLoader.d.ts
|
|
4698
|
-
type Live2DLoaderTarget = Live2DModel | InternalModel | MotionManager | ExpressionManager;
|
|
4700
|
+
export type Live2DLoaderTarget = Live2DModel | InternalModel | MotionManager | ExpressionManager;
|
|
4699
4701
|
/**
|
|
4700
4702
|
* The context transferred through Live2DLoader middlewares.
|
|
4701
4703
|
*/
|
|
4702
|
-
interface Live2DLoaderContext {
|
|
4704
|
+
export interface Live2DLoaderContext {
|
|
4703
4705
|
/** The XHR's response type. */
|
|
4704
4706
|
type: XMLHttpRequestResponseType;
|
|
4705
4707
|
/** Will be resolved by {@link ModelSettings.resolveURL} if a ModelSettings is provided. */
|
|
@@ -4714,7 +4716,7 @@ interface Live2DLoaderContext {
|
|
|
4714
4716
|
/** Loaded data. */
|
|
4715
4717
|
result?: unknown;
|
|
4716
4718
|
}
|
|
4717
|
-
declare class Live2DLoader {
|
|
4719
|
+
export declare class Live2DLoader {
|
|
4718
4720
|
static middlewares: Middleware<Live2DLoaderContext>[];
|
|
4719
4721
|
/**
|
|
4720
4722
|
* Loads a resource.
|
|
@@ -4732,7 +4734,7 @@ declare class Live2DLoader {
|
|
|
4732
4734
|
* - `status` - The HTTP status.
|
|
4733
4735
|
* - `aborted` - True if the error is caused by aborting the XHR.
|
|
4734
4736
|
*/
|
|
4735
|
-
declare class XHRLoader {
|
|
4737
|
+
export declare class XHRLoader {
|
|
4736
4738
|
/**
|
|
4737
4739
|
* All the created XHRs, keyed by their owners respectively.
|
|
4738
4740
|
*/
|
|
@@ -4768,7 +4770,7 @@ declare class XHRLoader {
|
|
|
4768
4770
|
/**
|
|
4769
4771
|
* Remove an element from array.
|
|
4770
4772
|
*/
|
|
4771
|
-
declare function remove<T>(array: T[], item: T): void;
|
|
4773
|
+
export declare function remove<T>(array: T[], item: T): void;
|
|
4772
4774
|
//#endregion
|
|
4773
4775
|
//#region src/utils/log.d.ts
|
|
4774
4776
|
/**
|
|
@@ -4784,7 +4786,7 @@ declare function remove<T>(array: T[], item: T): void;
|
|
|
4784
4786
|
* };
|
|
4785
4787
|
* ```
|
|
4786
4788
|
*/
|
|
4787
|
-
declare const logger: {
|
|
4789
|
+
export declare const logger: {
|
|
4788
4790
|
log(tag: string, ...messages: unknown[]): void;
|
|
4789
4791
|
warn(tag: string, ...messages: unknown[]): void;
|
|
4790
4792
|
error(tag: string, ...messages: unknown[]): void;
|
|
@@ -4795,9 +4797,9 @@ declare const logger: {
|
|
|
4795
4797
|
* These functions can be slightly faster than the ones in Lodash.
|
|
4796
4798
|
* @packageDocumentation
|
|
4797
4799
|
*/
|
|
4798
|
-
declare function clamp(num: number, lower: number, upper: number): number;
|
|
4799
|
-
declare function rand(min: number, max: number): number;
|
|
4800
|
-
declare function MBToByte(value: number): number;
|
|
4800
|
+
export declare function clamp(num: number, lower: number, upper: number): number;
|
|
4801
|
+
export declare function rand(min: number, max: number): number;
|
|
4802
|
+
export declare function MBToByte(value: number): number;
|
|
4801
4803
|
//#endregion
|
|
4802
4804
|
//#region src/utils/obj.d.ts
|
|
4803
4805
|
/**
|
|
@@ -4808,7 +4810,7 @@ declare function MBToByte(value: number): number;
|
|
|
4808
4810
|
* @param fromKey - Key of the property in source object.
|
|
4809
4811
|
* @param toKey - Key of the property in destination object.
|
|
4810
4812
|
*/
|
|
4811
|
-
declare function copyProperty<From, FromKey extends keyof From, ToKey extends keyof any, To extends Partial<Record<ToKey, From[FromKey]>>>(type: string, from: From, to: To, fromKey: FromKey, toKey: ToKey): void;
|
|
4813
|
+
export declare function copyProperty<From, FromKey extends keyof From, ToKey extends keyof any, To extends Partial<Record<ToKey, From[FromKey]>>>(type: string, from: From, to: To, fromKey: FromKey, toKey: ToKey): void;
|
|
4812
4814
|
/**
|
|
4813
4815
|
* Copies an array at `key`, filtering the items that match the `type`.
|
|
4814
4816
|
* @param type - Type expected to match `typeof` on the items.
|
|
@@ -4817,11 +4819,11 @@ declare function copyProperty<From, FromKey extends keyof From, ToKey extends ke
|
|
|
4817
4819
|
* @param fromKey - Key of the array property in source object.
|
|
4818
4820
|
* @param toKey - Key of the array property in destination object.
|
|
4819
4821
|
*/
|
|
4820
|
-
declare function copyArray<FromKey extends keyof any, From extends Partial<Record<FromKey, any[]>>, ToKey extends keyof any, To extends Partial<Record<ToKey, any[]>>>(type: string, from: From, to: To, fromKey: FromKey, toKey: ToKey): void;
|
|
4822
|
+
export declare function copyArray<FromKey extends keyof any, From extends Partial<Record<FromKey, any[]>>, ToKey extends keyof any, To extends Partial<Record<ToKey, any[]>>>(type: string, from: From, to: To, fromKey: FromKey, toKey: ToKey): void;
|
|
4821
4823
|
/**
|
|
4822
4824
|
* @see {@link https://www.typescriptlang.org/docs/handbook/mixins.html}
|
|
4823
4825
|
*/
|
|
4824
|
-
declare function applyMixins(derivedCtor: new (...args: any[]) => any, baseCtors: Array<new (...args: any[]) => any>): void;
|
|
4826
|
+
export declare function applyMixins(derivedCtor: new (...args: any[]) => any, baseCtors: Array<new (...args: any[]) => any>): void;
|
|
4825
4827
|
//#endregion
|
|
4826
4828
|
//#region src/utils/string.d.ts
|
|
4827
4829
|
/**
|
|
@@ -4829,15 +4831,16 @@ declare function applyMixins(derivedCtor: new (...args: any[]) => any, baseCtors
|
|
|
4829
4831
|
* @param url - URL of a file.
|
|
4830
4832
|
* @return Name of the parent folder, or the file itself if it has no parent folder.
|
|
4831
4833
|
*/
|
|
4832
|
-
declare function folderName(url: string): string;
|
|
4834
|
+
export declare function folderName(url: string): string;
|
|
4833
4835
|
//#endregion
|
|
4834
4836
|
//#region src/utils/url.d.ts
|
|
4835
4837
|
/**
|
|
4836
4838
|
* Resolves a path/URL against a base string without relying on Node's `url` module.
|
|
4837
4839
|
*/
|
|
4838
|
-
declare function resolveURL(base: string, path: string): string;
|
|
4839
|
-
|
|
4840
|
-
|
|
4840
|
+
export declare function resolveURL(base: string, path: string): string;
|
|
4841
|
+
declare namespace cubism_shim_d_exports {
|
|
4842
|
+
export { Expression, FileReferences, Group, HitArea, ModelJSON, Motion };
|
|
4843
|
+
}
|
|
4841
4844
|
interface Motion {
|
|
4842
4845
|
File: string;
|
|
4843
4846
|
FadeInTime?: number;
|
|
@@ -5710,8 +5713,8 @@ declare class CubismModelSettingJson extends ICubismModelSetting {
|
|
|
5710
5713
|
//#endregion
|
|
5711
5714
|
//#region src/cubism/CubismModelSettings.d.ts
|
|
5712
5715
|
type CubismModelSettingJsonMixin = Omit<CubismModelSettingJson, 'name'>;
|
|
5713
|
-
interface CubismModelSettings extends CubismModelSettingJsonMixin {}
|
|
5714
|
-
declare class CubismModelSettings extends ModelSettings {
|
|
5716
|
+
export interface CubismModelSettings extends CubismModelSettingJsonMixin {}
|
|
5717
|
+
export declare class CubismModelSettings extends ModelSettings {
|
|
5715
5718
|
json: ModelJSON;
|
|
5716
5719
|
moc: string;
|
|
5717
5720
|
textures: string[];
|
|
@@ -5736,7 +5739,7 @@ declare class CubismModelSettings extends ModelSettings {
|
|
|
5736
5739
|
}
|
|
5737
5740
|
//#endregion
|
|
5738
5741
|
//#region src/cubism/CubismExpressionManager.d.ts
|
|
5739
|
-
declare class CubismExpressionManager extends ExpressionManager<CubismExpressionMotion, Expression> {
|
|
5742
|
+
export declare class CubismExpressionManager extends ExpressionManager<CubismExpressionMotion, Expression> {
|
|
5740
5743
|
readonly expressionDataType: "arraybuffer";
|
|
5741
5744
|
readonly definitions: Expression[];
|
|
5742
5745
|
/** Active fade entries in activation order; deactivated ones stay until fully faded out. */
|
|
@@ -6903,7 +6906,7 @@ declare class CubismRenderer_WebGL extends CubismRenderer {
|
|
|
6903
6906
|
}
|
|
6904
6907
|
//#endregion
|
|
6905
6908
|
//#region src/cubism/CubismMotionManager.d.ts
|
|
6906
|
-
declare class CubismMotionManager extends MotionManager<CubismMotion, Motion> {
|
|
6909
|
+
export declare class CubismMotionManager extends MotionManager<CubismMotion, Motion> {
|
|
6907
6910
|
readonly definitions: Partial<Record<string, Motion[]>>;
|
|
6908
6911
|
readonly groups: {
|
|
6909
6912
|
readonly idle: "Idle";
|
|
@@ -6932,7 +6935,7 @@ declare class CubismMotionManager extends MotionManager<CubismMotion, Motion> {
|
|
|
6932
6935
|
}
|
|
6933
6936
|
//#endregion
|
|
6934
6937
|
//#region src/cubism/CubismParallelMotionManager.d.ts
|
|
6935
|
-
declare class CubismParallelMotionManager extends ParallelMotionManager<CubismMotion, Motion> {
|
|
6938
|
+
export declare class CubismParallelMotionManager extends ParallelMotionManager<CubismMotion, Motion> {
|
|
6936
6939
|
readonly queueManager: CubismMotionQueueManager;
|
|
6937
6940
|
readonly settings: CubismModelSettings;
|
|
6938
6941
|
constructor(parent: CubismInternalModel);
|
|
@@ -6947,7 +6950,7 @@ declare class CubismParallelMotionManager extends ParallelMotionManager<CubismMo
|
|
|
6947
6950
|
}
|
|
6948
6951
|
//#endregion
|
|
6949
6952
|
//#region src/cubism/CubismInternalModel.d.ts
|
|
6950
|
-
declare class CubismInternalModel extends InternalModel {
|
|
6953
|
+
export declare class CubismInternalModel extends InternalModel {
|
|
6951
6954
|
settings: CubismModelSettings;
|
|
6952
6955
|
options: InternalModelOptions;
|
|
6953
6956
|
coreModel: CubismModel;
|
|
@@ -7022,20 +7025,20 @@ interface CubismConfig {
|
|
|
7022
7025
|
/**
|
|
7023
7026
|
* Configures global Cubism startup settings.
|
|
7024
7027
|
*/
|
|
7025
|
-
declare function configureCubismSDK(config?: CubismConfig): void;
|
|
7028
|
+
export declare function configureCubismSDK(config?: CubismConfig): void;
|
|
7026
7029
|
/**
|
|
7027
7030
|
* Promises that the Cubism framework is ready to work.
|
|
7028
7031
|
* @return Promise that resolves if the startup has succeeded, rejects if failed.
|
|
7029
7032
|
*/
|
|
7030
|
-
declare function cubismReady(): Promise<void>;
|
|
7033
|
+
export declare function cubismReady(): Promise<void>;
|
|
7031
7034
|
/**
|
|
7032
7035
|
* Starts up the Cubism framework.
|
|
7033
7036
|
*/
|
|
7034
|
-
declare function startUpCubism(options?: Option, memorySizeMB?: number): void;
|
|
7037
|
+
export declare function startUpCubism(options?: Option, memorySizeMB?: number): void;
|
|
7035
7038
|
/**
|
|
7036
7039
|
* Reconfigures Cubism settings and restarts the framework so they take effect.
|
|
7037
7040
|
*/
|
|
7038
|
-
declare function reconfigureCubismSDK(config?: CubismConfig): void;
|
|
7041
|
+
export declare function reconfigureCubismSDK(config?: CubismConfig): void;
|
|
7039
7042
|
//#endregion
|
|
7040
|
-
export {
|
|
7043
|
+
export type { CommonLayout, CreateTextureOptions, ExpressionManagerEvents, InternalModelEvents, JSONObject, Live2DModelEvents, Live2DTextureLODFilter, Live2DTextureLODMode, Live2DTextureLODOptions, Live2DTextureSourceOptions, MotionManagerEvents, Mutable, TextureLODPlan, TextureLODPlanInput };
|
|
7041
7044
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3663,17 +3663,33 @@ const VOLUME = .5;
|
|
|
3663
3663
|
const SOUND_ALIAS_PREFIX = "live2d-sound-";
|
|
3664
3664
|
let soundId = 0;
|
|
3665
3665
|
let pixiSoundPromise;
|
|
3666
|
-
const configuredLibraries = /* @__PURE__ */ new
|
|
3666
|
+
const configuredLibraries = /* @__PURE__ */ new Set();
|
|
3667
|
+
let outputDeviceId = "";
|
|
3668
|
+
let outputError = null;
|
|
3669
|
+
/** Device changes and first-use routing run in order, so a library never settles on a stale device. */
|
|
3670
|
+
let routing = Promise.resolve();
|
|
3671
|
+
function queueRouting(task) {
|
|
3672
|
+
const run = routing.then(task);
|
|
3673
|
+
routing = run.catch(() => void 0);
|
|
3674
|
+
return run;
|
|
3675
|
+
}
|
|
3676
|
+
async function routeContext(context, deviceId) {
|
|
3677
|
+
const routable = context;
|
|
3678
|
+
if (routable.setSinkId) await routable.setSinkId(deviceId);
|
|
3679
|
+
else if (deviceId) throw new Error("Audio output selection is not supported");
|
|
3680
|
+
}
|
|
3667
3681
|
function configureSoundLibrary(library) {
|
|
3668
|
-
|
|
3682
|
+
return queueRouting(async () => {
|
|
3683
|
+
if (configuredLibraries.has(library)) return library;
|
|
3669
3684
|
try {
|
|
3670
3685
|
library.disableAutoPause = true;
|
|
3671
3686
|
} catch (e) {
|
|
3672
3687
|
logger.warn(TAG$2, "Failed to disable @pixi/sound auto pause.", e);
|
|
3673
3688
|
}
|
|
3689
|
+
if (outputDeviceId) await routeContext(library.context.audioContext, outputDeviceId);
|
|
3674
3690
|
configuredLibraries.add(library);
|
|
3675
|
-
|
|
3676
|
-
|
|
3691
|
+
return library;
|
|
3692
|
+
});
|
|
3677
3693
|
}
|
|
3678
3694
|
function getGlobalSoundLibrary() {
|
|
3679
3695
|
return typeof PIXI !== "undefined" ? PIXI?.sound : void 0;
|
|
@@ -3681,11 +3697,12 @@ function getGlobalSoundLibrary() {
|
|
|
3681
3697
|
async function resolveSoundLibrary() {
|
|
3682
3698
|
const globalLibrary = getGlobalSoundLibrary();
|
|
3683
3699
|
if (globalLibrary) return configureSoundLibrary(globalLibrary);
|
|
3684
|
-
pixiSoundPromise ??= import("@pixi/sound").then(({ sound }) =>
|
|
3700
|
+
pixiSoundPromise ??= import("@pixi/sound").then(({ sound }) => sound).catch((e) => {
|
|
3685
3701
|
logger.warn(TAG$2, "@pixi/sound is not available. Load pixi-sound.js before using motion sounds, speak(), or lip sync.", e);
|
|
3686
3702
|
return null;
|
|
3687
3703
|
});
|
|
3688
|
-
|
|
3704
|
+
const library = await pixiSoundPromise;
|
|
3705
|
+
return library ? configureSoundLibrary(library) : null;
|
|
3689
3706
|
}
|
|
3690
3707
|
function removeSound(library, alias) {
|
|
3691
3708
|
try {
|
|
@@ -3710,6 +3727,25 @@ function getAudioBuffer(audio) {
|
|
|
3710
3727
|
* Manages all the sounds.
|
|
3711
3728
|
*/
|
|
3712
3729
|
var SoundManager = class SoundManager {
|
|
3730
|
+
/** Select the speaker used by current and future motion audio and speak() calls. */
|
|
3731
|
+
static setOutputDevice(deviceId) {
|
|
3732
|
+
return queueRouting(async () => {
|
|
3733
|
+
const changed = [];
|
|
3734
|
+
try {
|
|
3735
|
+
for (const library of configuredLibraries) {
|
|
3736
|
+
const context = library.context.audioContext;
|
|
3737
|
+
await routeContext(context, deviceId);
|
|
3738
|
+
changed.push(context);
|
|
3739
|
+
}
|
|
3740
|
+
outputDeviceId = deviceId;
|
|
3741
|
+
outputError = null;
|
|
3742
|
+
} catch (error) {
|
|
3743
|
+
outputError = error;
|
|
3744
|
+
await Promise.allSettled(changed.map((context) => routeContext(context, outputDeviceId)));
|
|
3745
|
+
throw error;
|
|
3746
|
+
}
|
|
3747
|
+
});
|
|
3748
|
+
}
|
|
3713
3749
|
/**
|
|
3714
3750
|
* Audio elements playing or pending to play. Finished audios will be removed automatically.
|
|
3715
3751
|
*/
|
|
@@ -3740,6 +3776,7 @@ var SoundManager = class SoundManager {
|
|
|
3740
3776
|
let library = null;
|
|
3741
3777
|
let alias;
|
|
3742
3778
|
try {
|
|
3779
|
+
if (outputError) throw outputError;
|
|
3743
3780
|
library = await resolveSoundLibrary();
|
|
3744
3781
|
if (!library) throw new Error("@pixi/sound is not available");
|
|
3745
3782
|
alias = `${SOUND_ALIAS_PREFIX}${soundId++}`;
|
|
@@ -3768,6 +3805,7 @@ var SoundManager = class SoundManager {
|
|
|
3768
3805
|
}
|
|
3769
3806
|
});
|
|
3770
3807
|
});
|
|
3808
|
+
if (outputError) throw outputError;
|
|
3771
3809
|
SoundManager.aliases.set(audio, {
|
|
3772
3810
|
alias: soundAlias,
|
|
3773
3811
|
library: soundLibrary
|
|
@@ -3787,6 +3825,10 @@ var SoundManager = class SoundManager {
|
|
|
3787
3825
|
* @param onFinish - Callback invoked when the playback has finished.
|
|
3788
3826
|
*/
|
|
3789
3827
|
static play(audio, onFinish) {
|
|
3828
|
+
if (outputError) {
|
|
3829
|
+
SoundManager.dispose(audio);
|
|
3830
|
+
return;
|
|
3831
|
+
}
|
|
3790
3832
|
audio.play({
|
|
3791
3833
|
singleInstance: true,
|
|
3792
3834
|
complete: () => {
|