narraleaf-react 0.8.6 → 0.9.0-beta.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/README.md +1 -5
- package/dist/game/nlcore/action/actionTypes.d.ts +1 -1
- package/dist/game/nlcore/action/actions/sceneAction.d.ts +6 -1
- package/dist/game/nlcore/common/interface.d.ts +1 -0
- package/dist/game/nlcore/common/types.d.ts +4 -2
- package/dist/game/nlcore/elements/built-in/DevTools.d.ts +12 -0
- package/dist/game/nlcore/elements/built-in/built-in.d.ts +1 -0
- package/dist/game/nlcore/elements/persistent/storable.d.ts +5 -0
- package/dist/game/nlcore/elements/persistent/type.d.ts +1 -0
- package/dist/game/nlcore/elements/scene.d.ts +0 -1
- package/dist/game/player/lib/AudioManager.d.ts +23 -25
- package/dist/main.js +43 -45
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -123,11 +123,7 @@ npm install narraleaf-react
|
|
|
123
123
|
- [Player](https://react.narraleaf.com/documentation/player/player)
|
|
124
124
|
- [GameProviders](https://react.narraleaf.com/documentation/player/game-providers)
|
|
125
125
|
- Hooks
|
|
126
|
-
|
|
127
|
-
- [usePreferences](https://react.narraleaf.com/documentation/player/hooks/usePreferences)
|
|
128
|
-
- [useRouter](https://react.narraleaf.com/documentation/player/hooks/useRouter)
|
|
129
|
-
- [useDialog](https://react.narraleaf.com/documentation/player/hooks/useDialog)
|
|
130
|
-
- [Page Router](https://react.narraleaf.com/documentation/player/page-router)
|
|
126
|
+
- [LayoutRouter](https://react.narraleaf.com/documentation/player/page-router)
|
|
131
127
|
- [Dialog](https://react.narraleaf.com/documentation/player/dialog)
|
|
132
128
|
- [Notification](https://react.narraleaf.com/documentation/player/notification)
|
|
133
129
|
- [Menu](https://react.narraleaf.com/documentation/player/menu)
|
|
@@ -89,7 +89,7 @@ export declare const SoundActionTypes: {
|
|
|
89
89
|
readonly resume: "sound:resume";
|
|
90
90
|
};
|
|
91
91
|
export type SoundActionContentType = {
|
|
92
|
-
[K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [FadeOptions] : K extends "sound:stop" ? [FadeOptions] : K extends "sound:setVolume" ? [
|
|
92
|
+
[K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [FadeOptions] : K extends "sound:stop" ? [FadeOptions] : K extends "sound:setVolume" ? [volume: number, duration: number] : K extends "sound:setRate" ? [number] : K extends "sound:pause" ? [FadeOptions] : K extends "sound:resume" ? [FadeOptions] : any;
|
|
93
93
|
};
|
|
94
94
|
export declare const ControlActionTypes: {
|
|
95
95
|
readonly action: "control:action";
|
|
@@ -33,7 +33,12 @@ export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof
|
|
|
33
33
|
node: ContentNode<any> | null;
|
|
34
34
|
wait?: import("../../gameTypes").StackModelWaiting | null;
|
|
35
35
|
} | Awaitable<CalledActionResult, any>;
|
|
36
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Initialize background music for the target scene.
|
|
38
|
+
* Waits until the previous BGM has completely faded out (if any) before
|
|
39
|
+
* resolving, ensuring seamless audio transition when jumping between scenes.
|
|
40
|
+
*/
|
|
41
|
+
static initBackgroundMusic(scene: Scene, exposed: ExposedState[ExposedStateType.scene]): Promise<void>;
|
|
37
42
|
static createSceneSnapshot(scene: Scene, state: GameState): SceneSnapshot;
|
|
38
43
|
static restoreSceneSnapshot(snapshot: SceneSnapshot, state: GameState): void;
|
|
39
44
|
applyTransition(gameState: GameState, transition: ImageTransition, injection: ActionExecutionInjection): Awaitable<CalledActionResult, CalledActionResult>;
|
|
@@ -8,6 +8,8 @@ import { GameConfig, SavedGame, NotificationToken, SavedGameMetaData } from "../
|
|
|
8
8
|
import type { LayoutRouter } from "../../../game/player/lib/PageRouter/router";
|
|
9
9
|
import { KeyBindingType, WebKeyboardKey } from "../game/types";
|
|
10
10
|
import { KeyBindingValue } from "../game/keyMap";
|
|
11
|
+
import { SoundType } from "../elements/sound";
|
|
12
|
+
import { StorableType } from "../elements/persistent/type";
|
|
11
13
|
export * from "../elements/type";
|
|
12
|
-
export type { GameHistory, IGamePluginRegistry, LiveGameEventToken, Origins, ServiceHandlerCtx, TransformDefinitions, GameConfig, SavedGame, NotificationToken, SavedGameMetaData, LayoutRouter, KeyBindingValue, WebKeyboardKey, };
|
|
13
|
-
export { KeyBindingType, };
|
|
14
|
+
export type { GameHistory, IGamePluginRegistry, LiveGameEventToken, Origins, ServiceHandlerCtx, TransformDefinitions, GameConfig, SavedGame, NotificationToken, SavedGameMetaData, LayoutRouter, KeyBindingValue, WebKeyboardKey, StorableType, };
|
|
15
|
+
export { KeyBindingType, SoundType, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ControlAction } from "../../action/actions/controlAction";
|
|
2
|
+
import { Chained, Proxied } from "../../action/chain";
|
|
3
|
+
import { LogicAction } from "../../game";
|
|
4
|
+
import { DynamicPersistent, Persistent } from "../persistent";
|
|
5
|
+
export declare class DevTools {
|
|
6
|
+
static getActionId(action: LogicAction.Actions): string;
|
|
7
|
+
static setActionId(action: LogicAction.Actions, id: string): LogicAction.Actions;
|
|
8
|
+
static chainToActions(chain: Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>>): LogicAction.Actions[];
|
|
9
|
+
static wrapAction(action: LogicAction.Actions[] | Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>>): ControlAction;
|
|
10
|
+
static getNamespaceName(persistent: Persistent<any>): string;
|
|
11
|
+
static DynamicPersistent: typeof DynamicPersistent;
|
|
12
|
+
}
|
|
@@ -7,9 +7,14 @@ export declare class Namespace<T extends NameSpaceContent<keyof T>> {
|
|
|
7
7
|
get<Key extends keyof T = any>(key: Key): T[Key];
|
|
8
8
|
equals<Key extends keyof T = any>(key: Key, value: T[Key]): boolean;
|
|
9
9
|
assign(values: Partial<T>): this;
|
|
10
|
+
has(key: keyof T): boolean;
|
|
11
|
+
keys(): (keyof T)[];
|
|
12
|
+
values(): T[keyof T][];
|
|
13
|
+
entries(): [keyof T, T[keyof T]][];
|
|
10
14
|
reset(): this;
|
|
11
15
|
}
|
|
12
16
|
export declare class Storable {
|
|
17
|
+
static createNamespace<T extends NameSpaceContent<keyof T>>(name: string, initContent: T, key?: string): Namespace<T>;
|
|
13
18
|
addNamespace<T extends NameSpaceContent<keyof T>>(namespace: Namespace<T>): this | undefined;
|
|
14
19
|
getNamespace<T extends NameSpaceContent<keyof T> = any>(key: string): Namespace<T>;
|
|
15
20
|
setNamespace<T extends NameSpaceContent<keyof T> = any>(key: string, namespace: Namespace<T>): this;
|
|
@@ -31,7 +31,6 @@ export interface ISceneUserConfig {
|
|
|
31
31
|
}
|
|
32
32
|
export type JumpConfig = {
|
|
33
33
|
transition: ImageTransition;
|
|
34
|
-
unloadScene: boolean;
|
|
35
34
|
};
|
|
36
35
|
type ChainableAction = Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>> | LogicAction.Actions;
|
|
37
36
|
type ChainedScene = Proxied<Scene, Chained<LogicAction.Actions>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Sound, SoundType } from "../../nlcore/elements/sound";
|
|
1
|
+
import { Sound as SoundElement, SoundType } from "../../nlcore/elements/sound";
|
|
2
2
|
import { FadeOptions } from "../../nlcore/elements/type";
|
|
3
3
|
import { Awaitable } from "../../../util/data";
|
|
4
4
|
import { GameState } from "../gameState";
|
|
@@ -14,37 +14,35 @@ export type AudioManagerDataRaw = {
|
|
|
14
14
|
export declare class AudioManager {
|
|
15
15
|
private gameState;
|
|
16
16
|
private state;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
17
|
+
private channels;
|
|
18
|
+
private channelVolumes;
|
|
19
|
+
private globalVolume;
|
|
20
|
+
private sound;
|
|
21
|
+
private ready;
|
|
22
|
+
private isReady;
|
|
19
23
|
constructor(gameState: GameState);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Must be called ONCE on the client side to prepare audio subsystem.
|
|
26
|
+
* Doing it here avoids "AudioContext is not defined" on the server.
|
|
27
|
+
*/
|
|
28
|
+
initialize(): void;
|
|
29
|
+
play(sound: SoundElement, options?: FadeOptions): Awaitable<void>;
|
|
30
|
+
stop(sound: SoundElement, duration?: number): Awaitable<void>;
|
|
31
|
+
setVolume(sound: SoundElement, volume: number, duration?: number): Awaitable<void>;
|
|
32
|
+
pause(sound: SoundElement, duration?: number): Awaitable<void>;
|
|
33
|
+
resume(sound: SoundElement, duration?: number): Awaitable<void>;
|
|
34
|
+
setRate(sound: SoundElement, rate: number): Awaitable<void>;
|
|
35
|
+
getPosition(sound: SoundElement): number;
|
|
36
|
+
isPlaying(sound: SoundElement): boolean;
|
|
28
37
|
toData(): AudioManagerDataRaw;
|
|
29
38
|
fromData(data: AudioManagerDataRaw, elementMap: Map<string, LogicAction.GameElement>): this;
|
|
30
|
-
soundFromData(sound:
|
|
31
|
-
isManaged(sound:
|
|
39
|
+
soundFromData(sound: SoundElement, data: AudioDataRaw): void;
|
|
40
|
+
isManaged(sound: SoundElement): boolean;
|
|
32
41
|
reset(): void;
|
|
33
42
|
setGroupVolume(type: SoundType, volume: number): void;
|
|
34
43
|
setGlobalVolume(volume: number): void;
|
|
35
44
|
getGlobalVolume(): number;
|
|
36
45
|
getGroupVolume(type: SoundType): number;
|
|
46
|
+
destroy(): void;
|
|
37
47
|
private setupGroupVolume;
|
|
38
|
-
private initSound;
|
|
39
|
-
private pushTask;
|
|
40
|
-
private getState;
|
|
41
|
-
private abortTask;
|
|
42
|
-
private fadeTo;
|
|
43
|
-
private stopSound;
|
|
44
|
-
private pauseSound;
|
|
45
|
-
private resumeSound;
|
|
46
|
-
private getHowlConfig;
|
|
47
|
-
private createTask;
|
|
48
|
-
private wrapTask;
|
|
49
|
-
private applyEffectiveVolume;
|
|
50
48
|
}
|