narraleaf-react 0.0.1-beta.4 → 0.0.1-beta.5

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 CHANGED
@@ -102,6 +102,9 @@ export default nextConfig;
102
102
 
103
103
  ## Documentation
104
104
 
105
+ - [Quick Start](./docs/quick-start.md)
106
+ - [Customization](./docs/customization.md)
107
+
105
108
  in progress...
106
109
 
107
110
  ## License
@@ -79,15 +79,17 @@ export declare const SoundActionTypes: {
79
79
  readonly fade: "sound:fade";
80
80
  readonly setVolume: "sound:setVolume";
81
81
  readonly setRate: "sound:setRate";
82
+ readonly pause: "sound:pause";
83
+ readonly resume: "sound:resume";
82
84
  };
83
85
  export type SoundActionContentType = {
84
86
  [K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [void] : K extends "sound:stop" ? [void] : K extends "sound:fade" ? [
85
87
  {
86
- start: number;
88
+ start?: number;
87
89
  end: number;
88
90
  duration: number;
89
91
  }
90
- ] : K extends "sound:setVolume" ? [number] : K extends "sound:setRate" ? [number] : any;
92
+ ] : K extends "sound:setVolume" ? [number] : K extends "sound:setRate" ? [number] : K extends "sound:pause" ? [void] : K extends "sound:resume" ? [void] : any;
91
93
  };
92
94
  export declare const ControlActionTypes: {
93
95
  readonly action: "control:action";
@@ -97,6 +97,8 @@ export declare class SoundAction<T extends typeof SoundActionTypes[keyof typeof
97
97
  readonly fade: "sound:fade";
98
98
  readonly setVolume: "sound:setVolume";
99
99
  readonly setRate: "sound:setRate";
100
+ readonly pause: "sound:pause";
101
+ readonly resume: "sound:resume";
100
102
  };
101
103
  static initSound(state: GameState, sound: Sound): void;
102
104
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
@@ -1,4 +1,7 @@
1
1
  import Player from "../../player/elements/Player";
2
2
  import GameProviders from "../../player/provider/providers";
3
3
  import { GameState } from "../../player/gameState";
4
- export { GameProviders, Player, GameState, };
4
+ import { useGame } from "../../../game/player/provider/game-state";
5
+ export * from "../../player/type";
6
+ export * from "../../player/libElements";
7
+ export { GameProviders, Player, useGame, GameState, };
@@ -1,12 +1,12 @@
1
- import { CommonImage, NextJSStaticImageData, StaticImageData } from "../types";
2
- import { DeepPartial, EventDispatcher } from "../../../util/data";
3
- import { Transform } from "./transform/transform";
4
- import { ImageAction } from "../action/actions";
5
- import { Actionable } from "../action/actionable";
6
- import type { TransformDefinitions } from "../elements/transform/type";
7
1
  import React from "react";
2
+ import type { TransformDefinitions } from "../elements/transform/type";
8
3
  import { AnimationScope } from "framer-motion";
4
+ import { ImageAction } from "../action/actions";
5
+ import { Actionable } from "../action/actionable";
6
+ import { Transform } from "./transform/transform";
7
+ import { CommonImage, NextJSStaticImageData, StaticImageData } from "../types";
9
8
  import { ITransition } from "../elements/transition/type";
9
+ import { DeepPartial, EventDispatcher } from "../../../util/data";
10
10
  export type ImageConfig = {
11
11
  src: string | NextJSStaticImageData;
12
12
  display: boolean;
@@ -42,9 +42,11 @@ export declare class Sound extends Actionable<SoundDataRaw> {
42
42
  constructor(config?: DeepPartial<SoundConfig>);
43
43
  play(): this;
44
44
  stop(): this;
45
- fade(start: number, end: number, duration: number): this;
45
+ fade(start: number | undefined, end: number, duration: number): this;
46
46
  setVolume(volume: number): this;
47
47
  setRate(rate: number): this;
48
+ pause(fade?: number): this;
49
+ resume(fade?: number): this;
48
50
  getHowlOptions(): HowlOptions;
49
51
  getSrc(): string;
50
52
  $setToken(token: any): void;
@@ -4,6 +4,7 @@ import { Storable } from "./store/storable";
4
4
  import { Story } from "./elements/story";
5
5
  import { LogicAction } from "./action/logicAction";
6
6
  import { GameState } from "../player/gameState";
7
+ import { ComponentsTypes } from "../player/elements/type";
7
8
  declare const IdManager_base: {
8
9
  new (): {};
9
10
  _instance: {} | null;
@@ -26,6 +27,9 @@ declare enum GameSettingsNamespace {
26
27
  }
27
28
  export declare class Game {
28
29
  static defaultSettings: GameSettings;
30
+ static ComponentTypes: {
31
+ [K in keyof ComponentsTypes]: K;
32
+ };
29
33
  static DefaultConfig: GameConfig;
30
34
  static GameSettingsNamespace: typeof GameSettingsNamespace;
31
35
  readonly config: Readonly<GameConfig>;
@@ -36,6 +40,7 @@ export declare class Game {
36
40
  */
37
41
  constructor(config: DeepPartial<GameConfig>);
38
42
  static getIdManager(): IdManager;
43
+ useComponent<T extends keyof ComponentsTypes>(key: T, components: ComponentsTypes[T]): this;
39
44
  getLiveGame(): LiveGame;
40
45
  private createLiveGame;
41
46
  }
@@ -40,7 +40,8 @@ export type CommonImage = {
40
40
  scale?: number;
41
41
  rotation?: number;
42
42
  position?: IPosition;
43
- opacity: number;
43
+ opacity?: number;
44
+ alt?: string;
44
45
  };
45
46
  export declare const ImagePosition: {
46
47
  [K in CommonImagePosition]: K;
@@ -1,13 +1,5 @@
1
1
  import "client-only";
2
2
  import "@player/lib/styles/style.css";
3
- import clsx from "clsx";
4
3
  import React from "react";
5
- import { Story } from "../../nlcore/elements/story";
6
- import { Game } from "../../nlcore/game";
7
- export default function Player({ story, onReady, width, height, className, }: Readonly<{
8
- story: Story;
9
- onReady?: (game: Game) => void;
10
- width?: string | number;
11
- height?: string | number;
12
- className?: clsx.ClassValue;
13
- }>): React.JSX.Element;
4
+ import { PlayerProps } from "../elements/type";
5
+ export default function Player({ story, width, height, className, onReady, onEnd, }: Readonly<PlayerProps>): React.JSX.Element;
@@ -3,6 +3,9 @@ export interface SayElementProps {
3
3
  action: {
4
4
  sentence: Sentence;
5
5
  };
6
+ /**
7
+ * Callback function to be called when player triggers the next action
8
+ */
6
9
  onClick?: () => void;
7
10
  useTypeEffect?: boolean;
8
11
  className?: string;
@@ -1,6 +1,32 @@
1
1
  import React from "react";
2
2
  import { SayElementProps } from "../elements/say/type";
3
3
  import { MenuElementProps } from "../elements/menu/type";
4
+ import { Story } from "../../nlcore/elements/story";
5
+ import clsx from "clsx";
6
+ import { Game } from "../../nlcore/game";
4
7
  export type Components<T extends Record<string, any>> = (props: Readonly<T>) => React.JSX.Element;
5
8
  export type SayComponent = Components<SayElementProps>;
6
9
  export type MenuComponent = Components<MenuElementProps>;
10
+ export type ComponentsTypes = {
11
+ say: SayComponent;
12
+ menu: MenuComponent;
13
+ };
14
+ export type { SayElementProps, MenuElementProps, };
15
+ export interface PlayerProps {
16
+ story: Story;
17
+ width?: string | number;
18
+ height?: string | number;
19
+ className?: clsx.ClassValue;
20
+ /**
21
+ * Once the game is ready to be played
22
+ *
23
+ * only called once each lifecycle
24
+ */
25
+ onReady?: (game: Game) => void;
26
+ /**
27
+ * Once the game is ended
28
+ *
29
+ * only called once each lifecycle
30
+ */
31
+ onEnd?: (game: Game) => void;
32
+ }
@@ -40,6 +40,7 @@ interface StageUtils {
40
40
  }
41
41
  type GameStateEvents = {
42
42
  "event:state.ready": [];
43
+ "event:state.end": [];
43
44
  };
44
45
  export declare class GameState {
45
46
  static EventTypes: {
@@ -0,0 +1,4 @@
1
+ import Isolated from "./lib/isolated";
2
+ import Say from "./elements/say/Say";
3
+ import ColoredSentence from "./elements/menu/Sentence";
4
+ export { Isolated, Say, ColoredSentence, };
@@ -1,5 +1,7 @@
1
1
  import "client-only";
2
2
  import React from "react";
3
- export default function GameProviders({ children }: Readonly<{
3
+ import { Game } from "../../nlcore/game";
4
+ export default function GameProviders({ children, game }: Readonly<{
4
5
  children?: React.ReactNode;
6
+ game?: Game;
5
7
  }>): React.JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./elements/type";