narraleaf-react 0.2.2 → 0.2.3
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/game/nlcore/action/actions/controlAction.d.ts +1 -1
- package/dist/game/nlcore/common/Utils.d.ts +1 -51
- package/dist/game/nlcore/common/elements.d.ts +2 -1
- package/dist/game/nlcore/elements/character/pause.d.ts +0 -1
- package/dist/game/nlcore/elements/character/sentence.d.ts +0 -22
- package/dist/game/nlcore/elements/character.d.ts +0 -6
- package/dist/game/nlcore/elements/condition.d.ts +0 -13
- package/dist/game/nlcore/elements/control.d.ts +1 -4
- package/dist/game/nlcore/elements/displayable/displayable.d.ts +1 -38
- package/dist/game/nlcore/elements/displayable/image.d.ts +12 -22
- package/dist/game/nlcore/elements/displayable/text.d.ts +0 -8
- package/dist/game/nlcore/elements/menu.d.ts +0 -4
- package/dist/game/nlcore/elements/persistent/type.d.ts +0 -18
- package/dist/game/nlcore/elements/persistent.d.ts +3 -14
- package/dist/game/nlcore/elements/scene.d.ts +3 -43
- package/dist/game/nlcore/elements/script.d.ts +0 -1
- package/dist/game/nlcore/elements/sound.d.ts +0 -5
- package/dist/game/nlcore/elements/story.d.ts +0 -2
- package/dist/game/nlcore/elements/transform/position.d.ts +3 -46
- package/dist/game/nlcore/elements/transform/transform.d.ts +4 -0
- package/dist/game/nlcore/elements/transform/type.d.ts +0 -9
- package/dist/game/nlcore/elements/transition/type.d.ts +0 -15
- package/dist/game/nlcore/game/liveGame.d.ts +0 -33
- package/dist/game/nlcore/game/preference.d.ts +3 -7
- package/dist/game/nlcore/gameTypes.d.ts +4 -0
- package/dist/game/player/elements/displayable/Displayable.d.ts +1 -23
- package/dist/game/player/elements/displayable/Displayables.d.ts +1 -7
- package/dist/game/player/elements/displayable/Text.d.ts +1 -7
- package/dist/game/player/elements/displayable/type.d.ts +1 -15
- package/dist/game/player/elements/image/AspectScaleImage.d.ts +1 -8
- package/dist/game/player/elements/image/Image.d.ts +1 -7
- package/dist/game/player/elements/menu/Menu.d.ts +1 -3
- package/dist/game/player/elements/player/KeyEventAnnouncer.d.ts +1 -5
- package/dist/game/player/elements/player/SizeUpdateAnnouncer.d.ts +1 -4
- package/dist/game/player/elements/preload/Preload.d.ts +1 -4
- package/dist/game/player/elements/say/Say.d.ts +1 -3
- package/dist/game/player/elements/say/Sentence.d.ts +1 -15
- package/dist/game/player/elements/scene/Background.d.ts +1 -5
- package/dist/game/player/elements/scene/BackgroundTransition.d.ts +1 -8
- package/dist/game/player/elements/scene/Scene.d.ts +1 -9
- package/dist/game/player/elements/type.d.ts +1 -1
- package/dist/game/player/gameState.d.ts +0 -1
- package/dist/game/player/gameState.type.d.ts +1 -20
- package/dist/game/player/lib/PlayerFrames.d.ts +5 -1
- package/dist/game/player/lib/preferences.d.ts +3 -0
- package/dist/game/player/libElements.d.ts +3 -2
- package/dist/game/player/provider/game-state.d.ts +0 -5
- package/dist/game/player/provider/preloaded.d.ts +0 -11
- package/dist/game/player/provider/ratio.d.ts +0 -50
- package/dist/main.js +5 -5
- package/dist/util/data.d.ts +2 -2
- package/package.json +8 -6
- package/dist/game/player/elements/say/TypingEffect.d.ts +0 -13
|
@@ -23,7 +23,7 @@ export declare class ControlAction<T extends typeof ControlActionTypes[keyof typ
|
|
|
23
23
|
* will wait for awaitable actions to resolve
|
|
24
24
|
*/
|
|
25
25
|
executeAllActions(state: GameState, action: LogicAction.Actions): Promise<void>;
|
|
26
|
-
executeSingleAction(state: GameState, action: LogicAction.Actions): Promise<
|
|
26
|
+
executeSingleAction(state: GameState, action: LogicAction.Actions): Promise<ContentNode | null>;
|
|
27
27
|
execute(state: GameState, awaitable: Awaitable<any, any>, content: LogicAction.Actions[]): {
|
|
28
28
|
type: any;
|
|
29
29
|
node: ContentNode<any> | null;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Scene } from "../elements/scene";
|
|
3
|
-
import type { Image } from "../elements/displayable/image";
|
|
4
|
-
import { Action } from "../action/action";
|
|
5
|
-
import { Story } from "../elements/story";
|
|
1
|
+
import type { HexColor, ImageColor } from "../types";
|
|
6
2
|
export declare class RGBColor {
|
|
7
3
|
static isHexString(color: any): color is HexColor;
|
|
8
4
|
static fromHex(hex: HexColor): RGBColor;
|
|
@@ -15,49 +11,3 @@ export declare class RGBColor {
|
|
|
15
11
|
toHex(): string;
|
|
16
12
|
toImageColor(): ImageColor;
|
|
17
13
|
}
|
|
18
|
-
export declare class Utils {
|
|
19
|
-
static RGBColor: typeof RGBColor;
|
|
20
|
-
static srcToString(src: string | NextJSStaticImageData): string;
|
|
21
|
-
static staticImageDataToSrc(image: NextJSStaticImageData | string): string;
|
|
22
|
-
static isStaticImageData(src: any): src is NextJSStaticImageData;
|
|
23
|
-
static backgroundToSrc(background: Background["background"]): string | null;
|
|
24
|
-
static isExternalSrc(src: string): boolean;
|
|
25
|
-
static isImageSrc(src: any): src is ImageSrc;
|
|
26
|
-
static isImageColor(color: any): color is ImageColor;
|
|
27
|
-
static isPlainColor(color: any): color is color;
|
|
28
|
-
static isHexString(color: any): color is HexColor;
|
|
29
|
-
static toBackgroundSrc(src: ImageSrc): string;
|
|
30
|
-
static toHex(color: ImageColor): HexColor;
|
|
31
|
-
}
|
|
32
|
-
export declare class UseError<T = Record<string, any>> extends Error {
|
|
33
|
-
static isUseError(error: any): error is UseError;
|
|
34
|
-
props: T;
|
|
35
|
-
constructor(message: string, props: T, name?: string);
|
|
36
|
-
}
|
|
37
|
-
export declare class StaticScriptWarning extends UseError<{
|
|
38
|
-
stack?: string;
|
|
39
|
-
info?: any;
|
|
40
|
-
}> {
|
|
41
|
-
static isWarning(error: any): error is StaticScriptWarning;
|
|
42
|
-
constructor(message: string, info?: any);
|
|
43
|
-
}
|
|
44
|
-
type ImageState = {
|
|
45
|
-
isDisposed: boolean;
|
|
46
|
-
usedExternalSrc: boolean;
|
|
47
|
-
};
|
|
48
|
-
export declare class StaticChecker {
|
|
49
|
-
private readonly scene;
|
|
50
|
-
constructor(target: Scene);
|
|
51
|
-
run(story: Story): Map<Image<import("../elements/displayable/image").TagGroupDefinition | null>, ImageState> | null;
|
|
52
|
-
private checkAction;
|
|
53
|
-
private checkImage;
|
|
54
|
-
}
|
|
55
|
-
export declare class RuntimeScriptError extends Error {
|
|
56
|
-
static toMessage(msg: string | string[], trace?: Action | Action[]): string;
|
|
57
|
-
static getActionTrace(action: Action): string;
|
|
58
|
-
constructor(message: string | string[], trace?: Action | Action[]);
|
|
59
|
-
}
|
|
60
|
-
export declare class RuntimeGameError extends Error {
|
|
61
|
-
constructor(message: string);
|
|
62
|
-
}
|
|
63
|
-
export {};
|
|
@@ -24,4 +24,5 @@ interface ImageConstructor {
|
|
|
24
24
|
} : never)): ImageClass<T>;
|
|
25
25
|
}
|
|
26
26
|
declare const Image: ImageConstructor;
|
|
27
|
-
|
|
27
|
+
declare const AbstractImage: typeof ImageClass;
|
|
28
|
+
export { Character, Condition, Control, Image, Lambda, Menu, Scene, Script, Sentence, Sound, SoundType, Story, Transform, Word, Text, Pause, Persistent, AbstractImage, };
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import { Sound } from "../../elements/sound";
|
|
2
|
-
import type { Character } from "../../elements/character";
|
|
3
|
-
import { Word } from "../../elements/character/word";
|
|
4
|
-
import { Color, Font } from "../../types";
|
|
5
|
-
import type { ScriptCtx } from "../../elements/script";
|
|
6
|
-
import { Pausing } from "../../elements/character/pause";
|
|
7
|
-
export type SentenceConfig = {
|
|
8
|
-
pause?: boolean | number;
|
|
9
|
-
voice: Sound | null;
|
|
10
|
-
character: Character | null;
|
|
11
|
-
voiceId: string | number | null;
|
|
12
|
-
} & Color & Font;
|
|
13
|
-
export type SentenceDataRaw = {
|
|
14
|
-
state: SentenceState;
|
|
15
|
-
};
|
|
16
|
-
export type SentenceState = {
|
|
17
|
-
display: boolean;
|
|
18
|
-
};
|
|
19
2
|
export type SentenceUserConfig = Partial<Omit<SentenceConfig, "voice"> & {
|
|
20
3
|
voice: Sound | string | null | undefined;
|
|
21
4
|
}>;
|
|
22
|
-
export type DynamicWord = (ctx: ScriptCtx) => DynamicWordResult;
|
|
23
|
-
export type DynamicWordResult = string | Word | Pausing | (string | Word | Pausing)[];
|
|
24
|
-
export type StaticWord<T extends string | DynamicWord | Pausing = string | DynamicWord | Pausing> = string | Pausing | Word<T>;
|
|
25
|
-
export type SingleWord = StaticWord | DynamicWord;
|
|
26
|
-
export type SentencePrompt = SingleWord[] | SingleWord;
|
|
27
5
|
export declare class Sentence {
|
|
28
6
|
constructor(text: SentencePrompt, config?: SentenceUserConfig);
|
|
29
7
|
copy(): Sentence;
|
|
@@ -5,12 +5,6 @@ import { Actionable } from "../action/actionable";
|
|
|
5
5
|
import { Chained, Proxied } from "../action/chain";
|
|
6
6
|
import { Sentence, SentencePrompt, SentenceUserConfig, SingleWord } from "../elements/character/sentence";
|
|
7
7
|
export type CharacterConfig = {} & Color;
|
|
8
|
-
export type CharacterStateData = {
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
export type CharacterState = {
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
8
|
export declare class Character extends Actionable<CharacterStateData, Character> {
|
|
15
9
|
constructor(name: string | null, config?: DeepPartial<CharacterConfig>);
|
|
16
10
|
/**
|
|
@@ -4,19 +4,6 @@ import { Chained, ChainedActions, Proxied } from "../action/chain";
|
|
|
4
4
|
import { LambdaHandler } from "../elements/type";
|
|
5
5
|
export declare class Lambda<T = any> {
|
|
6
6
|
}
|
|
7
|
-
export type ConditionData = {
|
|
8
|
-
If: {
|
|
9
|
-
condition: Lambda | null;
|
|
10
|
-
action: LogicAction.Actions[] | null;
|
|
11
|
-
};
|
|
12
|
-
ElseIf: {
|
|
13
|
-
condition: Lambda | null;
|
|
14
|
-
action: (LogicAction.Actions[]) | null;
|
|
15
|
-
}[];
|
|
16
|
-
Else: {
|
|
17
|
-
action: (LogicAction.Actions[]) | null;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
7
|
export declare class Condition<Closed extends true | false = false> extends Actionable {
|
|
21
8
|
/**
|
|
22
9
|
* @chainable
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Actionable } from "../action/actionable";
|
|
2
|
-
import { LogicAction } from "../action/logicAction";
|
|
3
2
|
import { Awaitable } from "../../../util/data";
|
|
4
|
-
import {
|
|
5
|
-
type ChainedControl = Proxied<Control, Chained<LogicAction.Actions>>;
|
|
3
|
+
import { ChainedActions } from "../action/chain";
|
|
6
4
|
export declare class Control extends Actionable {
|
|
7
5
|
/**
|
|
8
6
|
* Execute actions in order, waiting for each action to complete
|
|
@@ -76,4 +74,3 @@ export declare class Control extends Actionable {
|
|
|
76
74
|
*/
|
|
77
75
|
sleep(duration: number | Awaitable<any> | Promise<any>): ChainedControl;
|
|
78
76
|
}
|
|
79
|
-
export {};
|
|
@@ -1,38 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { EventfulDisplayable } from "../../types";
|
|
3
|
-
import { Transform } from "../../elements/transform/transform";
|
|
4
|
-
import { Values } from "../../../../util/data";
|
|
5
|
-
import { ITransition } from "../../elements/transition/type";
|
|
6
|
-
import { DisplayableAction } from "../../action/actions/displayableAction";
|
|
7
|
-
import { DisplayableActionTypes } from "../../action/actionTypes";
|
|
8
|
-
import { Chained, Proxied } from "../../action/chain";
|
|
9
|
-
import { LogicAction } from "../../action/logicAction";
|
|
10
|
-
export type DisplayableEventTypes = {
|
|
11
|
-
"event:displayable.applyTransition": [ITransition];
|
|
12
|
-
"event:displayable.applyTransform": [Transform];
|
|
13
|
-
"event:displayable.init": [];
|
|
14
|
-
};
|
|
15
|
-
export declare abstract class Displayable<StateData extends Record<string, any>, Self extends Actionable> extends Actionable<StateData, Self> implements EventfulDisplayable {
|
|
16
|
-
abstract toDisplayableTransform(): Transform;
|
|
17
|
-
/**
|
|
18
|
-
* Move the layer up
|
|
19
|
-
* @chainable
|
|
20
|
-
*/
|
|
21
|
-
layerMoveUp(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
22
|
-
/**
|
|
23
|
-
* Move the layer down
|
|
24
|
-
* @chainable
|
|
25
|
-
*/
|
|
26
|
-
layerMoveDown(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
27
|
-
/**
|
|
28
|
-
* Move the layer to the top
|
|
29
|
-
* @chainable
|
|
30
|
-
*/
|
|
31
|
-
layerMoveTop(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
32
|
-
/**
|
|
33
|
-
* Move the layer to the bottom
|
|
34
|
-
* @chainable
|
|
35
|
-
*/
|
|
36
|
-
layerMoveBottom(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
37
|
-
protected constructLayerAction<T extends Values<typeof DisplayableActionTypes>>(chain: Proxied<Self, Chained<LogicAction.Actions>>, type: T): DisplayableAction;
|
|
38
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
2
2
|
import { Transform } from "../transform/transform";
|
|
3
|
-
import {
|
|
3
|
+
import { EventfulDisplayable, StaticImageData } from "../../types";
|
|
4
4
|
import { LogicAction } from "../../game";
|
|
5
5
|
import { IImageTransition } from "../../elements/transition/type";
|
|
6
6
|
import { FlexibleTuple, SelectElementFromEach } from "../../../../util/data";
|
|
7
7
|
import { Chained, Proxied } from "../../action/chain";
|
|
8
|
-
import { Displayable
|
|
9
|
-
export type ImageConfig = {
|
|
10
|
-
display: boolean;
|
|
11
|
-
wearables: Image[];
|
|
12
|
-
isWearable?: boolean;
|
|
13
|
-
name?: string;
|
|
14
|
-
/**
|
|
15
|
-
* If set to false, the image won't be initialized unless you call `init` method
|
|
16
|
-
*/
|
|
17
|
-
autoInit: boolean;
|
|
18
|
-
} & CommonDisplayable;
|
|
19
|
-
export type ImageDataRaw = {
|
|
20
|
-
state: Record<string, any>;
|
|
21
|
-
};
|
|
22
|
-
export type ImageEventTypes = {
|
|
23
|
-
"event:wearable.create": [Image];
|
|
24
|
-
} & DisplayableEventTypes;
|
|
8
|
+
import { Displayable } from "../../elements/displayable/displayable";
|
|
25
9
|
export type TagDefinitions<T extends TagGroupDefinition | null> = T extends TagGroupDefinition ? {
|
|
26
10
|
groups: T;
|
|
27
11
|
defaults: SelectElementFromEach<T>;
|
|
28
12
|
} : never;
|
|
29
|
-
export type TagGroupDefinition = string[][];
|
|
30
|
-
export type TagSrcResolver<T extends TagGroupDefinition> = (...tags: SelectElementFromEach<T>) => string;
|
|
31
13
|
export type RichImageUserConfig<T extends TagGroupDefinition | null> = ImageConfig & {} & (T extends null ? {
|
|
32
14
|
src: string | StaticImageData;
|
|
33
15
|
tag?: never;
|
|
@@ -35,8 +17,6 @@ export type RichImageUserConfig<T extends TagGroupDefinition | null> = ImageConf
|
|
|
35
17
|
src: TagSrcResolver<T>;
|
|
36
18
|
tag: TagDefinitions<T>;
|
|
37
19
|
} : never);
|
|
38
|
-
export type RichImageConfig<T extends TagGroupDefinition | null> = RichImageUserConfig<T> & {};
|
|
39
|
-
export type StaticRichConfig = RichImageUserConfig<TagGroupDefinition | null>;
|
|
40
20
|
export declare class Image<Tags extends TagGroupDefinition | null = TagGroupDefinition | null> extends Displayable<ImageDataRaw, Image> implements EventfulDisplayable {
|
|
41
21
|
constructor(config?: Partial<RichImageUserConfig<Tags>>, tagDefinition?: TagDefinitions<Tags>);
|
|
42
22
|
/**
|
|
@@ -125,6 +105,16 @@ export declare class Image<Tags extends TagGroupDefinition | null = TagGroupDefi
|
|
|
125
105
|
hide(): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
126
106
|
hide(transform: Transform<TransformDefinitions.ImageTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
127
107
|
hide(transform: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
108
|
+
/**
|
|
109
|
+
* Alia of {@link Image.setAppearance}
|
|
110
|
+
* @chainable
|
|
111
|
+
*/
|
|
112
|
+
setTags(tags: Tags extends TagGroupDefinition ? FlexibleTuple<SelectElementFromEach<Tags>> : string[], transition?: IImageTransition): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
113
|
+
/**
|
|
114
|
+
* Set Image Position
|
|
115
|
+
* @chainable
|
|
116
|
+
*/
|
|
117
|
+
setPosition(position: TransformDefinitions.ImageTransformProps["position"], duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
128
118
|
/**
|
|
129
119
|
* Add a wearable to the image
|
|
130
120
|
* @param children - Wearable image or images
|
|
@@ -5,7 +5,6 @@ import { LogicAction } from "../../action/logicAction";
|
|
|
5
5
|
import { Transform } from "../../elements/transform/transform";
|
|
6
6
|
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
7
7
|
import { ITextTransition } from "../../elements/transition/type";
|
|
8
|
-
import { DisplayableEventTypes } from "../../elements/displayable/displayable";
|
|
9
8
|
export type TextConfig = {
|
|
10
9
|
alignX: "left" | "center" | "right";
|
|
11
10
|
alignY: "top" | "center" | "bottom";
|
|
@@ -15,13 +14,6 @@ export type TextConfig = {
|
|
|
15
14
|
display: boolean;
|
|
16
15
|
text: string;
|
|
17
16
|
} & CommonDisplayable;
|
|
18
|
-
export type TextDataRaw = {
|
|
19
|
-
state: Record<string, any>;
|
|
20
|
-
};
|
|
21
|
-
export type TextEventTypes = {
|
|
22
|
-
"event:text.show": [Transform];
|
|
23
|
-
"event:text.hide": [Transform];
|
|
24
|
-
} & DisplayableEventTypes;
|
|
25
17
|
export declare class Text extends Actionable<TextDataRaw, Text> implements EventfulDisplayable {
|
|
26
18
|
constructor(config: Partial<TextConfig>);
|
|
27
19
|
constructor(text: string, config?: Partial<TextConfig>);
|
|
@@ -3,14 +3,11 @@ import { Actionable } from "../action/actionable";
|
|
|
3
3
|
import { Chained, Proxied } from "../action/chain";
|
|
4
4
|
import { Sentence, SentencePrompt } from "../elements/character/sentence";
|
|
5
5
|
import Actions = LogicAction.Actions;
|
|
6
|
-
import GameElement = LogicAction.GameElement;
|
|
7
6
|
export type MenuConfig = {};
|
|
8
7
|
export type MenuChoice = {
|
|
9
8
|
action: ChainedActions;
|
|
10
9
|
prompt: SentencePrompt | Sentence;
|
|
11
10
|
};
|
|
12
|
-
type ChainedAction = Proxied<GameElement, Chained<LogicAction.Actions>>;
|
|
13
|
-
type ChainedActions = (ChainedAction | ChainedAction[] | Actions | Actions[])[];
|
|
14
11
|
export type Choice = {
|
|
15
12
|
action: Actions[];
|
|
16
13
|
prompt: Sentence;
|
|
@@ -34,4 +31,3 @@ export declare class Menu extends Actionable<any, Menu> {
|
|
|
34
31
|
choose(prompt: Sentence, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
35
32
|
choose(prompt: SentencePrompt, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
36
33
|
}
|
|
37
|
-
export {};
|
|
@@ -1,21 +1,3 @@
|
|
|
1
1
|
export type StorableData<K extends string = string> = {
|
|
2
2
|
[key in K]: number | boolean | string | StorableData | StorableData[] | undefined | null | Date;
|
|
3
3
|
};
|
|
4
|
-
export type BaseStorableType = number | boolean | string | undefined | null | Date;
|
|
5
|
-
export type UnserializableStorableType = Date;
|
|
6
|
-
export type BaseStorableTypeName = "any" | "date";
|
|
7
|
-
export type StorableType = BaseStorableType | Record<string, BaseStorableType> | Array<BaseStorableType>;
|
|
8
|
-
export type WrappedStorableData<T extends StorableType = any> = {
|
|
9
|
-
type: BaseStorableTypeName;
|
|
10
|
-
data: T;
|
|
11
|
-
};
|
|
12
|
-
export type StorableTypeSerializer<T, U extends StorableType = any> = (value: T) => WrappedStorableData<U>;
|
|
13
|
-
export type BaseStorableSerializeHandlers = {
|
|
14
|
-
[K in BaseStorableTypeName]: K extends "any" ? StorableTypeSerializer<Exclude<BaseStorableType, UnserializableStorableType>> : K extends "date" ? StorableTypeSerializer<Date> : never;
|
|
15
|
-
};
|
|
16
|
-
export type BaseStorableDeserializeHandlers = {
|
|
17
|
-
[K in BaseStorableTypeName]: K extends "any" ? (data: WrappedStorableData<Exclude<BaseStorableType, UnserializableStorableType>>) => Exclude<BaseStorableType, UnserializableStorableType> : K extends "date" ? (data: WrappedStorableData<Date>) => Date : never;
|
|
18
|
-
};
|
|
19
|
-
export type NameSpaceContent<T extends string | number | symbol> = {
|
|
20
|
-
[K in T]?: StorableType;
|
|
21
|
-
};
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
import { Actionable } from "../action/actionable";
|
|
2
|
-
import {
|
|
3
|
-
import { Chained, Proxied } from "../action/chain";
|
|
4
|
-
import { LogicAction } from "../game";
|
|
5
|
-
import { BooleanKeys, StringKeyOf } from "../../../util/data";
|
|
2
|
+
import { BooleanValueKeyOf, StringKeyOf } from "../../../util/data";
|
|
6
3
|
import { Lambda } from "../elements/condition";
|
|
7
4
|
import { Word } from "../elements/character/word";
|
|
8
5
|
import { DynamicWord, DynamicWordResult } from "../elements/character/sentence";
|
|
9
6
|
import { LambdaHandler } from "../elements/type";
|
|
10
|
-
type PersistentContent = {
|
|
11
|
-
[K in string]: StorableType;
|
|
12
|
-
};
|
|
13
|
-
type ChainedPersistent<T extends PersistentContent> = Proxied<Persistent<T>, Chained<LogicAction.Actions>>;
|
|
14
|
-
type DynamicPersistentData = {
|
|
15
|
-
[K in string]: StorableType;
|
|
16
|
-
};
|
|
17
7
|
export declare class Persistent<T extends PersistentContent> extends Actionable<null> {
|
|
18
8
|
constructor(namespace: string, defaultContent: T);
|
|
19
9
|
/**
|
|
@@ -32,11 +22,11 @@ export declare class Persistent<T extends PersistentContent> extends Actionable<
|
|
|
32
22
|
/**
|
|
33
23
|
* Determine whether the value is true, can be used in {@link Condition}
|
|
34
24
|
*/
|
|
35
|
-
isTrue<K extends Extract<keyof T,
|
|
25
|
+
isTrue<K extends Extract<keyof T, BooleanValueKeyOf<T>>>(key: K): Lambda<boolean>;
|
|
36
26
|
/**
|
|
37
27
|
* Determine whether the value is false, can be used in {@link Condition}
|
|
38
28
|
*/
|
|
39
|
-
isFalse<K extends Extract<keyof T,
|
|
29
|
+
isFalse<K extends Extract<keyof T, BooleanValueKeyOf<T>>>(key: K): Lambda<boolean>;
|
|
40
30
|
/**
|
|
41
31
|
* Determine whether the value isn't null or undefined, can be used in {@link Condition}
|
|
42
32
|
*/
|
|
@@ -79,4 +69,3 @@ export declare class Persistent<T extends PersistentContent> extends Actionable<
|
|
|
79
69
|
*/
|
|
80
70
|
export declare class DynamicPersistent extends Persistent<DynamicPersistentData> {
|
|
81
71
|
}
|
|
82
|
-
export {};
|
|
@@ -1,28 +1,14 @@
|
|
|
1
1
|
import { Constructable } from "../action/constructable";
|
|
2
2
|
import { Awaitable } from "../../../util/data";
|
|
3
|
-
import {
|
|
3
|
+
import { EventfulDisplayable, ImageColor, ImageSrc } from "../types";
|
|
4
4
|
import { LogicAction } from "../action/logicAction";
|
|
5
5
|
import { Transform } from "../elements/transform/transform";
|
|
6
|
-
import { IImageTransition
|
|
7
|
-
import { Sound,
|
|
6
|
+
import { IImageTransition } from "../elements/transition/type";
|
|
7
|
+
import { Sound, VoiceIdMap, VoiceSrcGenerator } from "../elements/sound";
|
|
8
8
|
import { TransformDefinitions } from "../elements/transform/type";
|
|
9
|
-
import { ImageDataRaw, VirtualImageProxy } from "../elements/displayable/image";
|
|
10
9
|
import { Persistent } from "../common/core";
|
|
11
|
-
import { Chained, Proxied } from "../action/chain";
|
|
12
|
-
import { RGBColor } from "../common/Utils";
|
|
13
10
|
import Actions = LogicAction.Actions;
|
|
14
11
|
import ImageTransformProps = TransformDefinitions.ImageTransformProps;
|
|
15
|
-
import GameElement = LogicAction.GameElement;
|
|
16
|
-
export type UserImageInput = ImageSrc | RGBColor | ImageColor;
|
|
17
|
-
export type SceneConfig = {
|
|
18
|
-
invertY: boolean;
|
|
19
|
-
invertX: boolean;
|
|
20
|
-
backgroundMusic: Sound | null;
|
|
21
|
-
backgroundMusicFade: number;
|
|
22
|
-
voices: VoiceIdMap | VoiceSrcGenerator | null;
|
|
23
|
-
} & {
|
|
24
|
-
background: ImageSrc | ImageColor | null;
|
|
25
|
-
};
|
|
26
12
|
export interface ISceneConfig {
|
|
27
13
|
invertY: boolean;
|
|
28
14
|
invertX: boolean;
|
|
@@ -31,35 +17,10 @@ export interface ISceneConfig {
|
|
|
31
17
|
voices?: VoiceIdMap | VoiceSrcGenerator;
|
|
32
18
|
background?: ImageSrc | ImageColor;
|
|
33
19
|
}
|
|
34
|
-
export type SceneState = {
|
|
35
|
-
backgroundImageProxy: VirtualImageProxy;
|
|
36
|
-
};
|
|
37
20
|
export type JumpConfig = {
|
|
38
21
|
transition: IImageTransition;
|
|
39
22
|
unloadScene: boolean;
|
|
40
23
|
};
|
|
41
|
-
type ChainableAction = Proxied<GameElement, Chained<LogicAction.Actions>> | Actions;
|
|
42
|
-
type ChainedScene = Proxied<Scene, Chained<LogicAction.Actions>>;
|
|
43
|
-
export type SceneDataRaw = {
|
|
44
|
-
state: {
|
|
45
|
-
backgroundMusic?: SoundDataRaw | null;
|
|
46
|
-
background?: color | StaticImageData | null;
|
|
47
|
-
};
|
|
48
|
-
backgroundImageState?: ImageDataRaw | null;
|
|
49
|
-
};
|
|
50
|
-
export type SceneEventTypes = {
|
|
51
|
-
"event:scene.remove": [];
|
|
52
|
-
"event:scene.load": [];
|
|
53
|
-
"event:scene.unload": [];
|
|
54
|
-
"event:scene.mount": [];
|
|
55
|
-
"event:scene.unmount": [];
|
|
56
|
-
"event:scene.preUnmount": [];
|
|
57
|
-
"event:scene.imageLoaded": [];
|
|
58
|
-
"event:scene.setBackgroundMusic": [Sound | null, number];
|
|
59
|
-
"event:displayable.applyTransition": [ITransition];
|
|
60
|
-
"event:displayable.applyTransform": [Transform];
|
|
61
|
-
"event:displayable.init": [];
|
|
62
|
-
};
|
|
63
24
|
export declare class Scene extends Constructable<Actions, Scene> implements EventfulDisplayable {
|
|
64
25
|
readonly local: Persistent<any>;
|
|
65
26
|
constructor(name: string, config?: Partial<ISceneConfig>);
|
|
@@ -127,4 +88,3 @@ export declare class Scene extends Constructable<Actions, Scene> implements Even
|
|
|
127
88
|
*/
|
|
128
89
|
requestImagePreload(src: ImageSrc): void;
|
|
129
90
|
}
|
|
130
|
-
export {};
|
|
@@ -10,7 +10,6 @@ export interface ScriptCtx {
|
|
|
10
10
|
storable: Storable;
|
|
11
11
|
}
|
|
12
12
|
type ScriptRun = (ctx: ScriptCtx) => ScriptCleaner | void;
|
|
13
|
-
export type ScriptCleaner = () => void;
|
|
14
13
|
export declare class Script extends Actionable<object> {
|
|
15
14
|
constructor(handler: ScriptRun);
|
|
16
15
|
}
|
|
@@ -9,11 +9,6 @@ export declare enum SoundType {
|
|
|
9
9
|
voice = "voice",
|
|
10
10
|
backgroundMusic = "backgroundMusic"
|
|
11
11
|
}
|
|
12
|
-
export type SoundDataRaw = {
|
|
13
|
-
config: SoundConfig;
|
|
14
|
-
};
|
|
15
|
-
export type VoiceIdMap = Record<string | number, string | Sound>;
|
|
16
|
-
export type VoiceSrcGenerator = (id: string | number) => string | Sound;
|
|
17
12
|
export type SoundConfig = {
|
|
18
13
|
/**
|
|
19
14
|
* Sound type
|
|
@@ -3,8 +3,6 @@ import { Scene } from "../elements/scene";
|
|
|
3
3
|
import { SceneAction } from "../action/actions/sceneAction";
|
|
4
4
|
import { Persistent } from "../elements/persistent";
|
|
5
5
|
export type StoryConfig = {};
|
|
6
|
-
export type ElementStateRaw = Record<string, any>;
|
|
7
|
-
export type NodeChildIdMap = Map<string, string>;
|
|
8
6
|
export declare class Story extends Constructable<SceneAction<"scene:action">, Story> {
|
|
9
7
|
constructor(name: string, config?: StoryConfig);
|
|
10
8
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CSSProps } from "../../elements/transition/type";
|
|
2
1
|
export declare enum CommonPositionType {
|
|
3
2
|
Left = "left",
|
|
4
3
|
Center = "center",
|
|
@@ -12,51 +11,8 @@ export declare const CommonPositions: {
|
|
|
12
11
|
export interface IPosition {
|
|
13
12
|
toCSS(): D2Position;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
y: number | `${"-" | ""}${number}%`;
|
|
18
|
-
} & Partial<OffsetPosition>;
|
|
19
|
-
export type AlignPosition = {
|
|
20
|
-
xalign: number;
|
|
21
|
-
yalign: number;
|
|
22
|
-
} & Partial<OffsetPosition>;
|
|
23
|
-
export type OffsetPosition = {
|
|
24
|
-
xoffset: number;
|
|
25
|
-
yoffset: number;
|
|
26
|
-
};
|
|
27
|
-
export type D2Position<X = any, Y = any> = {
|
|
28
|
-
x: UnknownAble<X>;
|
|
29
|
-
y: UnknownAble<Y>;
|
|
30
|
-
xoffset: UnknownAble<number>;
|
|
31
|
-
yoffset: UnknownAble<number>;
|
|
32
|
-
};
|
|
33
|
-
export type RawPosition = CommonPositionType | (Coord2DPosition & {
|
|
34
|
-
xalign?: never;
|
|
35
|
-
yalign?: never;
|
|
36
|
-
}) | (AlignPosition & {
|
|
37
|
-
x?: never;
|
|
38
|
-
y?: never;
|
|
39
|
-
});
|
|
40
|
-
export type Unknown = typeof PositionUtils.Unknown;
|
|
41
|
-
export type UnknownAble<T> = T | Unknown;
|
|
42
|
-
export declare class PositionUtils {
|
|
43
|
-
static readonly Unknown: unique symbol;
|
|
44
|
-
static isUnknown(arg: any): arg is typeof PositionUtils.Unknown;
|
|
45
|
-
static wrap(def: CSSProps): CSSProps;
|
|
46
|
-
static D2PositionToCSS(pos: D2Position, invertX?: boolean, invertY?: boolean): CSSProps;
|
|
47
|
-
static calc(pos: number | string, offset?: UnknownAble<number>): string;
|
|
48
|
-
static toCoord2D(pos: IPosition | D2Position): Coord2D;
|
|
49
|
-
static orUnknown<T>(arg: T | UnknownAble<T> | undefined): T | Unknown;
|
|
50
|
-
static mergePosition(a: IPosition, b: IPosition): Coord2D;
|
|
51
|
-
static serializePosition(pos: IPosition): D2Position;
|
|
52
|
-
static isRawCommonPositionType(arg: any): arg is CommonPositionType;
|
|
53
|
-
static isRawCoord2DPosition(arg: any): arg is Coord2DPosition;
|
|
54
|
-
static isRawAlignPosition(arg: any): arg is AlignPosition;
|
|
55
|
-
static isRawPosition(arg: any): arg is RawPosition;
|
|
56
|
-
static isPosition(arg: any): arg is IPosition;
|
|
57
|
-
static rawPositionToCoord2D(arg: any): Coord2D;
|
|
58
|
-
static tryParsePosition(arg: any): IPosition;
|
|
59
|
-
}
|
|
14
|
+
type Unknown = typeof PositionUtils.Unknown;
|
|
15
|
+
type UnknownAble<T> = T | Unknown;
|
|
60
16
|
export declare class CommonPosition implements IPosition {
|
|
61
17
|
static Positions: typeof CommonPositionType;
|
|
62
18
|
static isCommonPositionType(arg: any): arg is CommonPosition;
|
|
@@ -123,3 +79,4 @@ export declare class Align implements IPosition {
|
|
|
123
79
|
});
|
|
124
80
|
toCSS(): D2Position;
|
|
125
81
|
}
|
|
82
|
+
export {};
|
|
@@ -18,6 +18,10 @@ export type TransformersMap = {
|
|
|
18
18
|
"fontColor": color;
|
|
19
19
|
};
|
|
20
20
|
export declare class Transform<T extends TransformDefinitions.Types = object> {
|
|
21
|
+
/**
|
|
22
|
+
* Apply transform immediately
|
|
23
|
+
*/
|
|
24
|
+
static immediate<T extends TransformDefinitions.Types>(props: SequenceProps<T>): Transform<T>;
|
|
21
25
|
/**
|
|
22
26
|
* Go to the left side of the stage
|
|
23
27
|
*/
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { color, CommonDisplayable } from "../../types";
|
|
2
2
|
import { DeepPartial } from "../../../../util/data";
|
|
3
|
-
import type { AnimationPlaybackControls, AnimationScope, AnimationSequence, DOMKeyframesDefinition, DynamicAnimationOptions, ElementOrSelector, MotionValue, ValueAnimationTransition } from "framer-motion";
|
|
4
3
|
export declare namespace TransformDefinitions {
|
|
5
4
|
type BezierDefinition = [number, number, number, number];
|
|
6
5
|
type CustomEasingFunction = (t: number) => number;
|
|
7
6
|
type EasingDefinition = CustomEasingFunction | BezierDefinition | "linear" | "easeIn" | "easeOut" | "easeInOut" | "circIn" | "circOut" | "circInOut" | "backIn" | "backOut" | "backInOut" | "anticipate";
|
|
8
|
-
type GenericKeyframesTarget<V> = [null, ...V[]] | V[];
|
|
9
|
-
type FramerAnimationScope<T> = AnimationScope<T>;
|
|
10
|
-
type FramerAnimate = {
|
|
11
|
-
<V>(from: V, to: V | GenericKeyframesTarget<V>, options?: ValueAnimationTransition<V> | undefined): AnimationPlaybackControls;
|
|
12
|
-
<V_1>(value: MotionValue<V_1>, keyframes: V_1 | GenericKeyframesTarget<V_1>, options?: ValueAnimationTransition<V_1> | undefined): AnimationPlaybackControls;
|
|
13
|
-
(value: ElementOrSelector, keyframes: DOMKeyframesDefinition, options?: DynamicAnimationOptions | undefined): AnimationPlaybackControls;
|
|
14
|
-
(sequence: AnimationSequence, options?: SequenceOptions | undefined): AnimationPlaybackControls;
|
|
15
|
-
};
|
|
16
7
|
type CommonTransformProps = {
|
|
17
8
|
duration: number;
|
|
18
9
|
ease: EasingDefinition;
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { DOMKeyframesDefinition } from "framer-motion";
|
|
3
1
|
import { ImageColor, ImageSrc } from "../../types";
|
|
4
|
-
export type ElementProp<T extends Element = Element, U extends React.HTMLAttributes<T> = React.HTMLAttributes<T>> = React.JSX.IntrinsicAttributes & React.ClassAttributes<T> & React.HTMLAttributes<T> & U;
|
|
5
|
-
export type ImgElementProp = ElementProp<HTMLImageElement, React.ImgHTMLAttributes<HTMLImageElement>>;
|
|
6
|
-
export type SpanElementProp = ElementProp<HTMLSpanElement, React.HTMLAttributes<HTMLSpanElement>>;
|
|
7
|
-
export type DivElementProp = ElementProp<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>;
|
|
8
|
-
export type CSSElementProp<T extends React.CSSProperties | DOMKeyframesDefinition> = ElementProp & {
|
|
9
|
-
style: T;
|
|
10
|
-
};
|
|
11
|
-
export type CSSProps = React.CSSProperties;
|
|
12
2
|
export interface ITransition<T extends ElementProp = Record<string, any>> {
|
|
13
3
|
start(onComplete?: () => void): void;
|
|
14
4
|
toElementProps(): T[];
|
|
@@ -21,11 +11,6 @@ export interface IImageTransition<T extends ElementProp = ImgElementProp> extend
|
|
|
21
11
|
export interface ITextTransition<T extends ElementProp = SpanElementProp> extends ITransition<T> {
|
|
22
12
|
copy(): ITextTransition<T>;
|
|
23
13
|
}
|
|
24
|
-
export type EventTypes<T extends any[]> = {
|
|
25
|
-
"start": [null];
|
|
26
|
-
"update": T;
|
|
27
|
-
"end": [null];
|
|
28
|
-
};
|
|
29
14
|
export declare const TransitionEventTypes: {
|
|
30
15
|
[K in keyof EventTypes<any>]: K;
|
|
31
16
|
};
|
|
@@ -4,38 +4,6 @@ import { GameState } from "../../player/gameState";
|
|
|
4
4
|
import { Storable } from "../elements/persistent/storable";
|
|
5
5
|
import { Game } from "../game";
|
|
6
6
|
import { LiveGameEventHandler, LiveGameEventToken } from "../types";
|
|
7
|
-
import { Character } from "../elements/character";
|
|
8
|
-
import { Sentence } from "../elements/character/sentence";
|
|
9
|
-
type LiveGameEvent = {
|
|
10
|
-
"event:character.prompt": [
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* The character who says the sentence
|
|
14
|
-
*/
|
|
15
|
-
character: Character | null;
|
|
16
|
-
/**
|
|
17
|
-
* The sentence said by the character
|
|
18
|
-
*/
|
|
19
|
-
sentence: Sentence;
|
|
20
|
-
/**
|
|
21
|
-
* The text of the sentence
|
|
22
|
-
*/
|
|
23
|
-
text: string;
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
"event:menu.choose": [
|
|
27
|
-
{
|
|
28
|
-
/**
|
|
29
|
-
* The sentence selected by the player
|
|
30
|
-
*/
|
|
31
|
-
sentence: Sentence;
|
|
32
|
-
/**
|
|
33
|
-
* The text of the sentence
|
|
34
|
-
*/
|
|
35
|
-
text: string;
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
};
|
|
39
7
|
export declare class LiveGame {
|
|
40
8
|
static DefaultNamespaces: {
|
|
41
9
|
game: {};
|
|
@@ -81,4 +49,3 @@ export declare class LiveGame {
|
|
|
81
49
|
newGame(): this;
|
|
82
50
|
getGameState(): GameState | undefined;
|
|
83
51
|
}
|
|
84
|
-
export {};
|