narraleaf-react 0.0.3 → 0.0.4
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/actionTypes.d.ts +5 -1
- package/dist/game/nlcore/action/actions.d.ts +10 -5
- package/dist/game/nlcore/action/chain.d.ts +3 -3
- package/dist/game/nlcore/action/tree/actionTree.d.ts +0 -6
- package/dist/game/nlcore/elements/image.d.ts +4 -2
- package/dist/game/nlcore/elements/scene.d.ts +3 -2
- package/dist/game/nlcore/elements/transform/position.d.ts +7 -6
- package/dist/game/nlcore/elements/transform/transform.d.ts +5 -3
- package/dist/game/nlcore/game.d.ts +11 -16
- package/dist/game/player/elements/preload/Preload.d.ts +1 -3
- package/dist/game/player/gameState.d.ts +3 -0
- package/dist/game/player/lib/isolated.d.ts +3 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
|
@@ -48,11 +48,15 @@ export declare const ImageActionTypes: {
|
|
|
48
48
|
readonly applyTransform: "image:applyTransform";
|
|
49
49
|
readonly init: "image:init";
|
|
50
50
|
readonly dispose: "image:dispose";
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated
|
|
53
|
+
*/
|
|
51
54
|
readonly setTransition: "image:setTransition";
|
|
52
55
|
readonly applyTransition: "image:applyTransition";
|
|
56
|
+
readonly flush: "image:flush";
|
|
53
57
|
};
|
|
54
58
|
export type ImageActionContentType = {
|
|
55
|
-
[K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [string] : K extends "image:setPosition" ? [CommonImage["position"], Transform] : K extends "image:show" ? [void, Transform] : K extends "image:hide" ? [void, Transform] : K extends "image:applyTransform" ? [void, Transform, string] : K extends "image:init" ? [Scene?] : K extends "image:dispose" ? [] : K extends "image:setTransition" ? [ITransition | null] : K extends "image:applyTransition" ? [ITransition] : any;
|
|
59
|
+
[K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [string] : K extends "image:setPosition" ? [CommonImage["position"], Transform] : K extends "image:show" ? [void, Transform] : K extends "image:hide" ? [void, Transform] : K extends "image:applyTransform" ? [void, Transform, string] : K extends "image:init" ? [Scene?] : K extends "image:dispose" ? [] : K extends "image:setTransition" ? [ITransition | null] : K extends "image:applyTransition" ? [ITransition] : K extends "image:flush" ? [] : any;
|
|
56
60
|
};
|
|
57
61
|
export declare const ConditionActionTypes: {
|
|
58
62
|
readonly action: "condition:action";
|
|
@@ -41,6 +41,13 @@ export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof
|
|
|
41
41
|
readonly preUnmount: "scene:preUnmount";
|
|
42
42
|
readonly applyTransform: "scene:applyTransform";
|
|
43
43
|
};
|
|
44
|
+
static handleSceneInit(sceneAction: SceneAction, state: GameState, awaitable: Awaitable<CalledActionResult, any>): Awaitable<CalledActionResult<any>, any> | {
|
|
45
|
+
type: number | Scene | [] | [import("../common/transition").ITransition<{}> | null] | [import("../common/transition").ITransition<{}>] | [import("../types").StaticImageData | {
|
|
46
|
+
url: string;
|
|
47
|
+
} | import("../types").color | null | undefined] | Promise<any> | Awaitable<any, any> | [Scene] | [Sound | null, (number | undefined)?] | [import("../common/elements").Transform<import("../common/types").TransformDefinitions.ImageTransformProps>];
|
|
48
|
+
node: import("../action/tree/actionTree").RenderableNode | null;
|
|
49
|
+
};
|
|
50
|
+
static registerEventListeners(scene: Scene, state: GameState, onInit?: () => void): void;
|
|
44
51
|
executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
|
|
45
52
|
getFutureActions(): LogicAction.Actions[];
|
|
46
53
|
}
|
|
@@ -61,6 +68,7 @@ export declare class ImageAction<T extends typeof ImageActionTypes[keyof typeof
|
|
|
61
68
|
readonly dispose: "image:dispose";
|
|
62
69
|
readonly setTransition: "image:setTransition";
|
|
63
70
|
readonly applyTransition: "image:applyTransition";
|
|
71
|
+
readonly flush: "image:flush";
|
|
64
72
|
};
|
|
65
73
|
executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
|
|
66
74
|
}
|
|
@@ -70,7 +78,7 @@ export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof
|
|
|
70
78
|
};
|
|
71
79
|
executeAction(gameState: GameState): {
|
|
72
80
|
type: any;
|
|
73
|
-
node:
|
|
81
|
+
node: import("../action/tree/actionTree").RenderableNode | null;
|
|
74
82
|
};
|
|
75
83
|
getFutureActions(): LogicAction.Actions[];
|
|
76
84
|
}
|
|
@@ -78,10 +86,7 @@ export declare class ScriptAction<T extends typeof ScriptActionTypes[keyof typeo
|
|
|
78
86
|
static ActionTypes: {
|
|
79
87
|
readonly action: "script:action";
|
|
80
88
|
};
|
|
81
|
-
executeAction(gameState: GameState):
|
|
82
|
-
type: any;
|
|
83
|
-
node: ContentNode<ScriptActionContentType[T]>;
|
|
84
|
-
};
|
|
89
|
+
executeAction(gameState: GameState): CalledActionResult<any> | Awaitable<CalledActionResult<any>, any>;
|
|
85
90
|
}
|
|
86
91
|
export declare class MenuAction<T extends typeof MenuActionTypes[keyof typeof MenuActionTypes] = typeof MenuActionTypes[keyof typeof MenuActionTypes]> extends TypedAction<MenuActionContentType, T, Menu> {
|
|
87
92
|
static ActionTypes: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LogicAction } from "../action/logicAction";
|
|
2
|
+
import { BaseElement } from "../action/baseElement";
|
|
2
3
|
import Actions = LogicAction.Actions;
|
|
3
4
|
import GameElement = LogicAction.GameElement;
|
|
4
|
-
import { BaseElement } from "../action/baseElement";
|
|
5
5
|
export type Proxied<T extends Record<any, any>, U extends Record<any, any>> = T & U;
|
|
6
6
|
export type ChainedAction = Proxied<GameElement, Chained<LogicAction.Actions>>;
|
|
7
7
|
export type ChainedActions = (ChainedAction | ChainedAction[] | Actions | Actions[])[];
|
|
8
|
-
export declare class Chained<T, Self = any> {
|
|
8
|
+
export declare class Chained<T, Self extends Chainable<any, any> = any> {
|
|
9
9
|
static isChained<T>(value: any): value is Chained<T>;
|
|
10
10
|
static toActions(chainedActions: ChainedActions): Actions[];
|
|
11
11
|
}
|
|
@@ -13,5 +13,5 @@ export declare class Chained<T, Self = any> {
|
|
|
13
13
|
* - T - the action type
|
|
14
14
|
* - U - self constructor
|
|
15
15
|
*/
|
|
16
|
-
export declare class Chainable<T, U extends
|
|
16
|
+
export declare class Chainable<T, U extends Chainable<any, any>> extends BaseElement {
|
|
17
17
|
}
|
|
@@ -23,7 +23,6 @@ export type ContentNodeData = {
|
|
|
23
23
|
export declare class ContentNode<T = any> extends Node<T> {
|
|
24
24
|
static forEachParent(node: RenderableNode, callback: (node: RenderableNode) => void): void;
|
|
25
25
|
static forEachChild(node: RenderableNode, callback: (node: RenderableNode) => void): void;
|
|
26
|
-
initChild?: RenderableNode | null;
|
|
27
26
|
action: LogicAction.Actions | null;
|
|
28
27
|
private child?;
|
|
29
28
|
private parent;
|
|
@@ -32,11 +31,6 @@ export declare class ContentNode<T = any> extends Node<T> {
|
|
|
32
31
|
setChild(child: RenderableNode | null): this;
|
|
33
32
|
getChild(): RenderableNode | null;
|
|
34
33
|
getParent(): RenderableNode | null;
|
|
35
|
-
/**
|
|
36
|
-
* To track the changes of the child
|
|
37
|
-
* should only be called when constructing the tree
|
|
38
|
-
*/
|
|
39
|
-
setInitChild(child: RenderableNode): this;
|
|
40
34
|
/**
|
|
41
35
|
* Public method for setting the content of the node
|
|
42
36
|
* should only be called when changing the state in-game
|
|
@@ -22,9 +22,11 @@ export type ImageEventTypes = {
|
|
|
22
22
|
"event:image.applyTransform": [Transform];
|
|
23
23
|
"event:image.mount": [];
|
|
24
24
|
"event:image.unmount": [];
|
|
25
|
-
"event:image.ready": [React.MutableRefObject<
|
|
25
|
+
"event:image.ready": [React.MutableRefObject<HTMLDivElement | null>];
|
|
26
26
|
"event:image.elementLoaded": [];
|
|
27
|
-
"event:image.
|
|
27
|
+
"event:image.applyTransition": [ITransition];
|
|
28
|
+
"event:image.flush": [];
|
|
29
|
+
"event:image.flushComponent": [];
|
|
28
30
|
};
|
|
29
31
|
export declare class Image extends Actionable<ImageDataRaw, Image> {
|
|
30
32
|
static EventTypes: {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Constructable } from "../action/constructable";
|
|
2
2
|
import { Awaitable, DeepPartial } from "../../../util/data";
|
|
3
|
-
import { Background
|
|
3
|
+
import { Background } from "../types";
|
|
4
4
|
import { LogicAction } from "../action/logicAction";
|
|
5
5
|
import { Transform } from "../elements/transform/transform";
|
|
6
6
|
import { ITransition } from "../elements/transition/type";
|
|
7
7
|
import { Sound, SoundDataRaw } from "../elements/sound";
|
|
8
8
|
import { TransformDefinitions } from "../elements/transform/type";
|
|
9
|
+
import { ImageDataRaw } from "../elements/image";
|
|
9
10
|
import { Chained, Proxied } from "../action/chain";
|
|
10
11
|
import Actions = LogicAction.Actions;
|
|
11
12
|
import ImageTransformProps = TransformDefinitions.ImageTransformProps;
|
|
@@ -29,7 +30,7 @@ export type SceneDataRaw = {
|
|
|
29
30
|
backgroundMusic?: SoundDataRaw | null;
|
|
30
31
|
background?: Background["background"];
|
|
31
32
|
};
|
|
32
|
-
backgroundImageState?:
|
|
33
|
+
backgroundImageState?: ImageDataRaw | null;
|
|
33
34
|
};
|
|
34
35
|
export type SceneEventTypes = {
|
|
35
36
|
"event:scene.applyTransition": [ITransition | null];
|
|
@@ -46,6 +46,7 @@ export declare class PositionUtils {
|
|
|
46
46
|
static D2PositionToCSS(pos: D2Position, invertX?: boolean, invertY?: boolean): CSSProps;
|
|
47
47
|
static calc(pos: number | string, offset?: UnknownAble<number>): string;
|
|
48
48
|
static toCoord2D(pos: IPosition | D2Position): Coord2D;
|
|
49
|
+
static orUnknown<T>(arg: T | UnknownAble<T> | undefined): T | Unknown;
|
|
49
50
|
static mergePosition(a: IPosition, b: IPosition): Coord2D;
|
|
50
51
|
static serializePosition(pos: IPosition): D2Position;
|
|
51
52
|
static isRawCommonPositionType(arg: any): arg is CommonPositionType;
|
|
@@ -58,6 +59,7 @@ export declare class PositionUtils {
|
|
|
58
59
|
}
|
|
59
60
|
export declare class CommonPosition implements IPosition {
|
|
60
61
|
static Positions: typeof CommonPositionType;
|
|
62
|
+
static isCommonPositionType(arg: any): arg is CommonPosition;
|
|
61
63
|
readonly position: CommonPositionType;
|
|
62
64
|
/**
|
|
63
65
|
* Create a new CommonPosition instance
|
|
@@ -68,10 +70,13 @@ export declare class CommonPosition implements IPosition {
|
|
|
68
70
|
* ```
|
|
69
71
|
*/
|
|
70
72
|
constructor(position: CommonPositionType);
|
|
71
|
-
static isCommonPositionType(arg: any): arg is CommonPosition;
|
|
72
73
|
toCSS(): D2Position;
|
|
73
74
|
}
|
|
74
75
|
export declare class Coord2D implements IPosition {
|
|
76
|
+
static isCoord2DPosition(arg: any): arg is Coord2D;
|
|
77
|
+
static fromCommonPosition(position: CommonPosition): Coord2D;
|
|
78
|
+
static fromAlignPosition(position: AlignPosition): Coord2D;
|
|
79
|
+
static merge(a: Coord2D, b: Coord2D): Coord2D;
|
|
75
80
|
readonly x: UnknownAble<Coord2DPosition["x"]>;
|
|
76
81
|
readonly y: UnknownAble<Coord2DPosition["y"]>;
|
|
77
82
|
readonly xoffset: UnknownAble<number>;
|
|
@@ -92,13 +97,10 @@ export declare class Coord2D implements IPosition {
|
|
|
92
97
|
yoffset?: UnknownAble<number>;
|
|
93
98
|
});
|
|
94
99
|
constructor(x: UnknownAble<Coord2DPosition["x"]>, y: UnknownAble<Coord2DPosition["y"]>);
|
|
95
|
-
static isCoord2DPosition(arg: any): arg is Coord2D;
|
|
96
|
-
static fromCommonPosition(position: CommonPosition): Coord2D;
|
|
97
|
-
static fromAlignPosition(position: AlignPosition): Coord2D;
|
|
98
|
-
static merge(a: Coord2D, b: Coord2D): Coord2D;
|
|
99
100
|
toCSS(): D2Position<Coord2DPosition["x"], Coord2DPosition["y"]>;
|
|
100
101
|
}
|
|
101
102
|
export declare class Align implements IPosition {
|
|
103
|
+
static isAlignPosition(arg: any): arg is AlignPosition;
|
|
102
104
|
readonly xalign: UnknownAble<number>;
|
|
103
105
|
readonly yalign: UnknownAble<number>;
|
|
104
106
|
readonly xoffset: UnknownAble<number>;
|
|
@@ -119,6 +121,5 @@ export declare class Align implements IPosition {
|
|
|
119
121
|
xoffset?: UnknownAble<number>;
|
|
120
122
|
yoffset?: UnknownAble<number>;
|
|
121
123
|
});
|
|
122
|
-
static isAlignPosition(arg: any): arg is AlignPosition;
|
|
123
124
|
toCSS(): D2Position;
|
|
124
125
|
}
|
|
@@ -8,6 +8,7 @@ import { CSSProps } from "../../elements/transition/type";
|
|
|
8
8
|
import Sequence = TransformDefinitions.Sequence;
|
|
9
9
|
import SequenceProps = TransformDefinitions.SequenceProps;
|
|
10
10
|
import React from "react";
|
|
11
|
+
import { Image } from "../../elements/image";
|
|
11
12
|
export type Transformers = "position" | "opacity" | "scale" | "rotation" | "display" | "src" | "backgroundColor" | "backgroundOpacity" | "transform";
|
|
12
13
|
export type TransformHandler<T> = (value: T) => DOMKeyframesDefinition;
|
|
13
14
|
export type TransformersMap = {
|
|
@@ -63,12 +64,13 @@ export declare class Transform<T extends TransformDefinitions.Types = TransformD
|
|
|
63
64
|
* return <div ref={scope} />
|
|
64
65
|
* ```
|
|
65
66
|
*/
|
|
66
|
-
animate({ scope, overwrites }: {
|
|
67
|
-
scope: React.MutableRefObject<
|
|
67
|
+
animate({ scope, overwrites, image }: {
|
|
68
|
+
scope: React.MutableRefObject<HTMLDivElement | null>;
|
|
68
69
|
overwrites?: Partial<{
|
|
69
70
|
[K in Transformers]?: TransformHandler<any>;
|
|
70
71
|
}>;
|
|
71
|
-
|
|
72
|
+
image: Image;
|
|
73
|
+
}, gameState: GameState, initState?: SequenceProps<T>, after?: (state: DeepPartial<T>) => void): Promise<void>;
|
|
72
74
|
/**
|
|
73
75
|
* @example
|
|
74
76
|
* ```ts
|
|
@@ -35,31 +35,26 @@ export declare class LiveGame {
|
|
|
35
35
|
game: Game;
|
|
36
36
|
getStorable(): Storable;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Serialize the current game state
|
|
39
|
+
*
|
|
40
|
+
* You can use this to save the game state to a file or a database
|
|
41
|
+
*
|
|
42
|
+
* Note: Even if you change just a single line of script, the saved game might not be compatible with the new version
|
|
39
43
|
*/
|
|
40
|
-
|
|
41
|
-
gameState: GameState;
|
|
42
|
-
}): this;
|
|
44
|
+
serialize(): SavedGame;
|
|
43
45
|
/**
|
|
44
46
|
* Load a saved game
|
|
45
47
|
*
|
|
46
|
-
* Note: Even if you change just a single line of
|
|
48
|
+
* Note: Even if you change just a single line of script, the saved game might not be compatible with the new version
|
|
47
49
|
*
|
|
48
50
|
* After calling this method, the current game state will be lost, and the stage will trigger force reset
|
|
49
51
|
*/
|
|
50
|
-
deserialize(savedGame: SavedGame
|
|
51
|
-
gameState: GameState;
|
|
52
|
-
}): void;
|
|
52
|
+
deserialize(savedGame: SavedGame): void;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* You can use this to save the game state to a file or a database
|
|
57
|
-
*
|
|
58
|
-
* Note: Even if you change just a single line of code, the saved game might not be compatible with the new version
|
|
54
|
+
* Start a new game
|
|
59
55
|
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}): SavedGame;
|
|
56
|
+
newGame(): this;
|
|
57
|
+
getGameState(): GameState | undefined;
|
|
63
58
|
}
|
|
64
59
|
declare const _default: {
|
|
65
60
|
Game: typeof Game;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { GameState } from "../../gameState";
|
|
2
|
-
|
|
3
|
-
export declare function Preload({ state, srcManager }: Readonly<{
|
|
2
|
+
export declare function Preload({ state, }: Readonly<{
|
|
4
3
|
state: GameState;
|
|
5
|
-
srcManager: SrcManager;
|
|
6
4
|
}>): null;
|
|
@@ -44,6 +44,8 @@ type GameStateEvents = {
|
|
|
44
44
|
"event:state.end": [];
|
|
45
45
|
"event:state.player.skip": [];
|
|
46
46
|
"event:state.preload.unmount": [];
|
|
47
|
+
"event:state.preload.loaded": [];
|
|
48
|
+
"event:state.player.flush": [];
|
|
47
49
|
};
|
|
48
50
|
export declare class GameState {
|
|
49
51
|
static EventTypes: {
|
|
@@ -87,6 +89,7 @@ export declare class GameState {
|
|
|
87
89
|
getStorable(): Storable;
|
|
88
90
|
toData(): PlayerStateData;
|
|
89
91
|
loadData(data: PlayerStateData, elementMap: Map<string, LogicAction.GameElement>): void;
|
|
92
|
+
initScenes(): void;
|
|
90
93
|
private getElementMap;
|
|
91
94
|
private removeElements;
|
|
92
95
|
private _getLastSceneIfNot;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
-
export default function Isolated({ children, className }: Readonly<{
|
|
2
|
+
export default function Isolated({ children, className, props, ref }: Readonly<{
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
+
props?: Record<any, any>;
|
|
6
|
+
ref?: React.MutableRefObject<HTMLDivElement | null>;
|
|
5
7
|
}>): React.JSX.Element;
|