narraleaf-react 0.0.1-beta.5 → 0.0.1-beta.6
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 -1
- package/dist/game/nlcore/elements/image.d.ts +1 -3
- package/dist/game/nlcore/elements/text.d.ts +11 -2
- package/dist/game/nlcore/elements/transform/position.d.ts +22 -8
- package/dist/game/nlcore/elements/transform/transform.d.ts +5 -5
- package/dist/game/nlcore/elements/transition/base.d.ts +1 -1
- package/dist/game/nlcore/elements/transition/type.d.ts +1 -1
- package/dist/game/nlcore/types.d.ts +2 -4
- package/dist/game/player/elements/say/type.d.ts +2 -1
- package/dist/game/player/elements/scene/Background.d.ts +1 -1
- package/dist/game/player/gameState.d.ts +2 -1
- package/dist/game/player/lib/{main.d.ts → AspectRatio.d.ts} +1 -1
- package/dist/game/player/lib/isolated.d.ts +1 -2
- package/dist/game/player/provider/ratio.d.ts +41 -17
- package/dist/main.js +31 -0
- package/dist/util/data.d.ts +9 -0
- package/package.json +2 -2
- package/dist/index.js +0 -31
package/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { TransformDefinitions } from "../elements/transform/type";
|
|
3
|
-
import { AnimationScope } from "framer-motion";
|
|
4
3
|
import { ImageAction } from "../action/actions";
|
|
5
4
|
import { Actionable } from "../action/actionable";
|
|
6
5
|
import { Transform } from "./transform/transform";
|
|
@@ -22,7 +21,7 @@ export type ImageEventTypes = {
|
|
|
22
21
|
"event:image.applyTransform": [Transform];
|
|
23
22
|
"event:image.mount": [];
|
|
24
23
|
"event:image.unmount": [];
|
|
25
|
-
"event:image.ready": [
|
|
24
|
+
"event:image.ready": [React.MutableRefObject<HTMLImageElement | null>];
|
|
26
25
|
"event:image.elementLoaded": [];
|
|
27
26
|
"event:image.setTransition": [ITransition | null];
|
|
28
27
|
};
|
|
@@ -117,7 +116,6 @@ export declare class Image extends Actionable<ImageDataRaw> {
|
|
|
117
116
|
hide(transform: Transform): this;
|
|
118
117
|
hide(transform: Partial<TransformDefinitions.CommonTransformProps>): this;
|
|
119
118
|
toTransform(): Transform;
|
|
120
|
-
toHTMLElementProps(): React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
121
119
|
setScope(scope: React.RefObject<HTMLImageElement>): this;
|
|
122
120
|
getScope(): React.RefObject<HTMLImageElement> | undefined;
|
|
123
121
|
copy(): Image;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Color } from "../types";
|
|
2
|
+
import { DeepPartial } from "../../../util/data";
|
|
2
3
|
import { Actionable } from "../action/actionable";
|
|
3
4
|
export type SentenceConfig = {
|
|
4
5
|
pause?: boolean | number;
|
|
@@ -34,12 +35,20 @@ export declare class Word {
|
|
|
34
35
|
constructor(text: string, config?: Partial<WordConfig>);
|
|
35
36
|
static isWord(obj: any): obj is Word;
|
|
36
37
|
}
|
|
37
|
-
export
|
|
38
|
+
export declare enum CharacterMode {
|
|
39
|
+
"adv" = "adv",
|
|
40
|
+
"nvl" = "nvl"
|
|
41
|
+
}
|
|
42
|
+
export type CharacterConfig = {
|
|
43
|
+
mode: CharacterMode;
|
|
44
|
+
};
|
|
38
45
|
export type CharacterStateData = {};
|
|
39
46
|
export declare class Character extends Actionable<CharacterStateData> {
|
|
47
|
+
static Modes: typeof CharacterMode;
|
|
48
|
+
static defaultConfig: CharacterConfig;
|
|
40
49
|
name: string | null;
|
|
41
50
|
config: CharacterConfig;
|
|
42
|
-
constructor(name: string | null, config?: CharacterConfig);
|
|
51
|
+
constructor(name: string | null, config?: DeepPartial<CharacterConfig>);
|
|
43
52
|
/**
|
|
44
53
|
* Say something
|
|
45
54
|
* @example
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CSSProps } from "../../elements/transition/type";
|
|
2
2
|
export declare enum CommonPositionType {
|
|
3
|
-
Left =
|
|
4
|
-
Center =
|
|
5
|
-
Right =
|
|
3
|
+
Left = "left",
|
|
4
|
+
Center = "center",
|
|
5
|
+
Right = "right"
|
|
6
6
|
}
|
|
7
7
|
export declare const CommonPositions: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
left: `${number}%`;
|
|
9
|
+
center: `${number}%`;
|
|
10
|
+
right: `${number}%`;
|
|
11
11
|
};
|
|
12
12
|
export interface IPosition {
|
|
13
13
|
toCSS(): D2Position;
|
|
@@ -30,6 +30,13 @@ export type D2Position<X = any, Y = any> = {
|
|
|
30
30
|
xoffset: UnknownAble<number>;
|
|
31
31
|
yoffset: UnknownAble<number>;
|
|
32
32
|
};
|
|
33
|
+
export type RawPosition = CommonPositionType | (Coord2DPosition & {
|
|
34
|
+
xalign?: never;
|
|
35
|
+
yalign?: never;
|
|
36
|
+
}) | (AlignPosition & {
|
|
37
|
+
x: never;
|
|
38
|
+
y: never;
|
|
39
|
+
});
|
|
33
40
|
export type Unknown = typeof PositionUtils.Unknown;
|
|
34
41
|
export type UnknownAble<T> = T | Unknown;
|
|
35
42
|
export declare class PositionUtils {
|
|
@@ -41,6 +48,13 @@ export declare class PositionUtils {
|
|
|
41
48
|
static toCoord2D(pos: IPosition | D2Position): Coord2D;
|
|
42
49
|
static mergePosition(a: IPosition, b: IPosition): Coord2D;
|
|
43
50
|
static serializePosition(pos: IPosition): D2Position;
|
|
51
|
+
static isRawCommonPositionType(arg: any): arg is CommonPositionType;
|
|
52
|
+
static isRawCoord2DPosition(arg: any): arg is Coord2DPosition;
|
|
53
|
+
static isRawAlignPosition(arg: any): arg is AlignPosition;
|
|
54
|
+
static isRawPosition(arg: any): arg is IPosition;
|
|
55
|
+
static isPosition(arg: any): arg is IPosition;
|
|
56
|
+
static rawPositionToCoord2D(arg: any): Coord2D;
|
|
57
|
+
static tryParsePosition(arg: any): IPosition;
|
|
44
58
|
}
|
|
45
59
|
export declare class CommonPosition implements IPosition {
|
|
46
60
|
static Positions: typeof CommonPositionType;
|
|
@@ -50,10 +64,10 @@ export declare class CommonPosition implements IPosition {
|
|
|
50
64
|
* @example
|
|
51
65
|
* ```ts
|
|
52
66
|
* new CommonPosition(CommonPosition.Positions.Center);
|
|
53
|
-
* new CommonPosition("
|
|
67
|
+
* new CommonPosition("center");
|
|
54
68
|
* ```
|
|
55
69
|
*/
|
|
56
|
-
constructor(position: CommonPositionType
|
|
70
|
+
constructor(position: CommonPositionType);
|
|
57
71
|
static isCommonPositionType(arg: any): arg is CommonPosition;
|
|
58
72
|
toCSS(): D2Position;
|
|
59
73
|
}
|
|
@@ -3,10 +3,11 @@ import type { AnimationPlaybackControls, DOMKeyframesDefinition, DynamicAnimatio
|
|
|
3
3
|
import { DeepPartial } from "../../../../util/data";
|
|
4
4
|
import { GameState } from "../../../player/gameState";
|
|
5
5
|
import { TransformDefinitions } from "./type";
|
|
6
|
-
import { Align, Coord2D, IPosition } from "./position";
|
|
6
|
+
import { Align, Coord2D, IPosition, RawPosition } from "./position";
|
|
7
7
|
import { CSSProps } from "../../elements/transition/type";
|
|
8
8
|
import Sequence = TransformDefinitions.Sequence;
|
|
9
9
|
import SequenceProps = TransformDefinitions.SequenceProps;
|
|
10
|
+
import React from "react";
|
|
10
11
|
export type Transformers = "position" | "opacity" | "scale" | "rotation" | "display" | "src" | "backgroundColor" | "backgroundOpacity" | "transform";
|
|
11
12
|
export type TransformHandler<T> = (value: T) => DOMKeyframesDefinition;
|
|
12
13
|
export type TransformersMap = {
|
|
@@ -52,7 +53,7 @@ export declare class Transform<T extends TransformDefinitions.Types = TransformD
|
|
|
52
53
|
backgroundImage?: string;
|
|
53
54
|
backgroundColor?: string;
|
|
54
55
|
};
|
|
55
|
-
static mergePosition(a:
|
|
56
|
+
static mergePosition(a: RawPosition | undefined, b: RawPosition | undefined): Coord2D;
|
|
56
57
|
static mergeState<T>(state: any, props: any): DeepPartial<T>;
|
|
57
58
|
/**
|
|
58
59
|
* @example
|
|
@@ -62,9 +63,8 @@ export declare class Transform<T extends TransformDefinitions.Types = TransformD
|
|
|
62
63
|
* return <div ref={scope} />
|
|
63
64
|
* ```
|
|
64
65
|
*/
|
|
65
|
-
animate
|
|
66
|
-
scope:
|
|
67
|
-
animate: TransformDefinitions.FramerAnimate;
|
|
66
|
+
animate({ scope, overwrites }: {
|
|
67
|
+
scope: React.MutableRefObject<HTMLImageElement | null>;
|
|
68
68
|
overwrites?: Partial<{
|
|
69
69
|
[K in Transformers]?: TransformHandler<any>;
|
|
70
70
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventDispatcher } from "../../../../util/data";
|
|
2
2
|
import { ElementProp, EventTypes, ITransition } from "./type";
|
|
3
|
-
import { AnimationPlaybackControls, ValueAnimationTransition } from "framer-motion";
|
|
3
|
+
import type { AnimationPlaybackControls, ValueAnimationTransition } from "framer-motion";
|
|
4
4
|
export declare class Base<T extends ElementProp> implements ITransition<T> {
|
|
5
5
|
events: EventDispatcher<EventTypes<[T[]]>>;
|
|
6
6
|
start(_onComplete?: () => void): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EventDispatcher } from "../../../../util/data";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { DOMKeyframesDefinition } from "framer-motion";
|
|
3
|
+
import type { DOMKeyframesDefinition } from "framer-motion";
|
|
4
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
5
|
export type ImgElementProp = ElementProp<HTMLImageElement, React.ImgHTMLAttributes<HTMLImageElement>>;
|
|
6
6
|
export type CSSElementProp<T extends React.CSSProperties | DOMKeyframesDefinition> = ElementProp & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPosition } from "./elements/transform/position";
|
|
1
|
+
import { IPosition, RawPosition } from "./elements/transform/position";
|
|
2
2
|
export type color = string | {
|
|
3
3
|
r: number;
|
|
4
4
|
g: number;
|
|
@@ -35,11 +35,9 @@ export type Background = {
|
|
|
35
35
|
};
|
|
36
36
|
export type CommonImagePosition = "left" | "center" | "right";
|
|
37
37
|
export type CommonImage = {
|
|
38
|
-
height?: number;
|
|
39
|
-
width?: number;
|
|
40
38
|
scale?: number;
|
|
41
39
|
rotation?: number;
|
|
42
|
-
position?: IPosition;
|
|
40
|
+
position?: RawPosition | IPosition;
|
|
43
41
|
opacity?: number;
|
|
44
42
|
alt?: string;
|
|
45
43
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Sentence } from "../../../nlcore/elements/text";
|
|
1
|
+
import { Character, Sentence } from "../../../nlcore/elements/text";
|
|
2
2
|
export interface SayElementProps {
|
|
3
3
|
action: {
|
|
4
4
|
sentence: Sentence;
|
|
5
|
+
character: Character | null;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* Callback function to be called when player triggers the next action
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CalledActionResult } from "@core/gameTypes";
|
|
2
|
-
import { EventDispatcher } from "../../util/data";
|
|
2
|
+
import { EventDispatcher, Logger } from "../../util/data";
|
|
3
3
|
import { Sentence } from "../nlcore/elements/text";
|
|
4
4
|
import { Choice, MenuData } from "../nlcore/elements/menu";
|
|
5
5
|
import { Image, ImageEventTypes } from "../nlcore/elements/image";
|
|
@@ -51,6 +51,7 @@ export declare class GameState {
|
|
|
51
51
|
stage: StageUtils;
|
|
52
52
|
game: Game;
|
|
53
53
|
readonly events: EventDispatcher<GameStateEvents>;
|
|
54
|
+
readonly logger: Logger;
|
|
54
55
|
constructor(game: Game, stage: StageUtils);
|
|
55
56
|
findElementByScene(scene: Scene): {
|
|
56
57
|
scene: Scene;
|
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
min: {
|
|
11
|
-
w: number;
|
|
12
|
-
h: number;
|
|
13
|
-
};
|
|
2
|
+
import { EventDispatcher } from "../../../util/data";
|
|
3
|
+
export type AspectRatioState = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
minWidth: number;
|
|
7
|
+
minHeight: number;
|
|
8
|
+
paused: boolean;
|
|
14
9
|
};
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
type AspectRatioEvents = {
|
|
11
|
+
"event:aspectRatio.update": [width: number, height: number];
|
|
12
|
+
"event:aspectRatio.pause": [];
|
|
13
|
+
"event:aspectRatio.resume": [];
|
|
18
14
|
};
|
|
19
|
-
|
|
15
|
+
declare class AspectRatio {
|
|
16
|
+
static EventTypes: {
|
|
17
|
+
[K in keyof AspectRatioEvents]: K;
|
|
18
|
+
};
|
|
19
|
+
state: AspectRatioState;
|
|
20
|
+
readonly events: EventDispatcher<AspectRatioEvents, AspectRatioEvents & {
|
|
21
|
+
"event:EventDispatcher.register": [string | number, import("../../../util/data").EventListener<any>];
|
|
22
|
+
}>;
|
|
23
|
+
private lockers;
|
|
24
|
+
private updater;
|
|
25
|
+
constructor();
|
|
26
|
+
update(width: number, height: number): void;
|
|
27
|
+
updateMin(width: number, height: number): void;
|
|
28
|
+
lock(): symbol;
|
|
29
|
+
unlock(locker: symbol | null | undefined): null;
|
|
30
|
+
isLocked(): boolean;
|
|
31
|
+
getStyle(): {
|
|
32
|
+
width: string;
|
|
33
|
+
height: string;
|
|
34
|
+
};
|
|
35
|
+
setUpdate(updater: () => void): void;
|
|
36
|
+
pause(): void;
|
|
37
|
+
resume(): void;
|
|
38
|
+
onUpdate(callback: (width: number, height: number) => void): () => void;
|
|
39
|
+
private triggerUpdate;
|
|
40
|
+
}
|
|
41
|
+
export declare function RatioProvider({ children }: {
|
|
20
42
|
children: React.ReactNode;
|
|
21
43
|
}): React.JSX.Element;
|
|
22
|
-
export declare function
|
|
44
|
+
export declare function useRatio(): {
|
|
45
|
+
ratio: AspectRatio;
|
|
46
|
+
};
|
|
23
47
|
export {};
|