narraleaf-react 0.12.2 → 0.12.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/LICENSE +373 -373
- package/README.md +165 -165
- package/dist/game/nlcore/elements/built-in/DevTools.d.ts +21 -0
- package/dist/game/player/gameState.d.ts +27 -0
- package/dist/main.js +34 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
<picture>
|
|
2
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-transparent.png">
|
|
3
|
-
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
|
|
4
|
-
<img alt="NarraLeaf Logo" src="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
|
|
5
|
-
</picture>
|
|
6
|
-
|
|
7
|
-
<h1 align="center">NarraLeaf-React</h1>
|
|
8
|
-
|
|
9
|
-
<h4 align="center">A React visual novel player framework</h4>
|
|
10
|
-
|
|
11
|
-
<p align="center">English | <a href="docs/README.zh-CN.md">简体中文</a></p>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## What is NarraLeaf-React?
|
|
15
|
-
|
|
16
|
-
NarraLeaf-React is a lightweight front-end visual novel player.
|
|
17
|
-
NL focuses on visual novel playing, so the user interface can be customized very easily.
|
|
18
|
-
|
|
19
|
-
It doesn't use any rendering libraries and can be used on any web platform (e.g. Electron)
|
|
20
|
-
|
|
21
|
-
## Why NarraLeaf-React?
|
|
22
|
-
|
|
23
|
-
- **Lightweight**: NarraLeaf-React is a front-end framework, and it doesn't use any rendering libraries.
|
|
24
|
-
- **Customizable**: You can customize the UI as you like, even replace the whole components.
|
|
25
|
-
- **Easy to use**: It is easy to use and has a simple API that is built for developers. Based on OOP principles.
|
|
26
|
-
|
|
27
|
-
### Scripting
|
|
28
|
-
|
|
29
|
-
NarraLeaf-React uses TypeScript for all scripting, so you don't have to learn a whole new language to use it.
|
|
30
|
-
|
|
31
|
-
It also has a highly abstracted and easy-to-use API, for example:
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import {Character, Menu, Scene, c, b} from "narraleaf-react";
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
const scene1 = new Scene("Scene1: Hello World", {
|
|
39
|
-
background: "/link/to/background.jpg",
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const jS = new Character("John Smith");
|
|
43
|
-
const jD = new Character("John Doe");
|
|
44
|
-
|
|
45
|
-
scene1.action([
|
|
46
|
-
jS`Hello, world!`,
|
|
47
|
-
jS`This is my first ${b("NarraLeaf")} story.`,
|
|
48
|
-
jS`Start editing ${c("src/story.js", "#00f")} and enjoy the journey!`,
|
|
49
|
-
|
|
50
|
-
jD`Also, don't forget to check out the ${c("documentation", "#00f")}!`,
|
|
51
|
-
|
|
52
|
-
"By the way, the documentation is available on https://www.narraleaf.com/docs/narraleaf-react",
|
|
53
|
-
"You can also visit the website for demo and more information.",
|
|
54
|
-
|
|
55
|
-
Menu.prompt("Start the journey")
|
|
56
|
-
|
|
57
|
-
.choose("Yes I will!", [
|
|
58
|
-
jS`Great! Let's start the journey!`,
|
|
59
|
-
jS`You can open issues on GitHub if you have any questions.`
|
|
60
|
-
])
|
|
61
|
-
|
|
62
|
-
.choose("No, I'm going to check the documentation", [
|
|
63
|
-
jS`Sure! Take your time!`
|
|
64
|
-
])
|
|
65
|
-
]);
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
For more information, please visit the [NarraLeaf-React documentation](https://www.narraleaf.com/docs/narraleaf-react).
|
|
69
|
-
|
|
70
|
-
## Get Started
|
|
71
|
-
|
|
72
|
-
### Install
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
npm install narraleaf-react
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Documentation
|
|
79
|
-
|
|
80
|
-
- [Introduction](https://www.narraleaf.com/docs/narraleaf-react)
|
|
81
|
-
- [Quick Start](https://www.narraleaf.com/docs/narraleaf-react/quick-start)
|
|
82
|
-
- [Installation](https://www.narraleaf.com/docs/narraleaf-react/installation)
|
|
83
|
-
- [Basic](https://www.narraleaf.com/docs/narraleaf-react/basic)
|
|
84
|
-
- [Create a Scene](https://www.narraleaf.com/docs/narraleaf-react/basic/create-scene)
|
|
85
|
-
- [Add Actions](https://www.narraleaf.com/docs/narraleaf-react/basic/add-actions)
|
|
86
|
-
- [Show Dialog](https://www.narraleaf.com/docs/narraleaf-react/basic/show-dialog)
|
|
87
|
-
- [Show Image](https://www.narraleaf.com/docs/narraleaf-react/basic/show-image)
|
|
88
|
-
- [Play Story](https://www.narraleaf.com/docs/narraleaf-react/basic/play-story)
|
|
89
|
-
- [Make Choices](https://www.narraleaf.com/docs/narraleaf-react/basic/make-choices)
|
|
90
|
-
- [Play Sound](https://www.narraleaf.com/docs/narraleaf-react/basic/sound)
|
|
91
|
-
- [Store Data](https://www.narraleaf.com/docs/narraleaf-react/basic/store-data)
|
|
92
|
-
- [Conditional](https://www.narraleaf.com/docs/narraleaf-react/basic/conditional)
|
|
93
|
-
- [Voice](https://www.narraleaf.com/docs/narraleaf-react/basic/voice)
|
|
94
|
-
- [Manage Preferences](https://www.narraleaf.com/docs/narraleaf-react/basic/manage-preferences)
|
|
95
|
-
- [Solutions](https://www.narraleaf.com/docs/narraleaf-react/solutions)
|
|
96
|
-
- [Customizing the Font](https://www.narraleaf.com/docs/narraleaf-react/solutions/font)
|
|
97
|
-
- [Migration from Ren'Py](https://www.narraleaf.com/docs/narraleaf-react/solutions/from-renpy)
|
|
98
|
-
- [Quick Menu](https://www.narraleaf.com/docs/narraleaf-react/solutions/quick-menu)
|
|
99
|
-
- [Dialog Avatar](https://www.narraleaf.com/docs/narraleaf-react/solutions/dialog-avatar)
|
|
100
|
-
- [Custom Dialog](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-dialog)
|
|
101
|
-
- [Custom NVL Dialog](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-nvl-dialog)
|
|
102
|
-
- [Custom Menu](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-menu)
|
|
103
|
-
- [Page Overlay Settings](https://www.narraleaf.com/docs/narraleaf-react/solutions/page-overlay-settings)
|
|
104
|
-
- [Save System with localStorage](https://www.narraleaf.com/docs/narraleaf-react/solutions/save-system-localstorage)
|
|
105
|
-
- [Custom Notification](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-notification)
|
|
106
|
-
- [Gallery Service with localStorage](https://www.narraleaf.com/docs/narraleaf-react/solutions/gallery-service-localstorage)
|
|
107
|
-
- [Core](https://www.narraleaf.com/docs/narraleaf-react/core)
|
|
108
|
-
- [Elements](https://www.narraleaf.com/docs/narraleaf-react/core/elements)
|
|
109
|
-
- [Scene](https://www.narraleaf.com/docs/narraleaf-react/core/elements/scene)
|
|
110
|
-
- [Character](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character)
|
|
111
|
-
- [Sentence](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character/sentence)
|
|
112
|
-
- [Word](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character/word)
|
|
113
|
-
- [Pause](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character/pause)
|
|
114
|
-
- [Image](https://www.narraleaf.com/docs/narraleaf-react/core/elements/image)
|
|
115
|
-
- [Sound](https://www.narraleaf.com/docs/narraleaf-react/core/elements/sound)
|
|
116
|
-
- [Menu](https://www.narraleaf.com/docs/narraleaf-react/core/elements/menu)
|
|
117
|
-
- [Script](https://www.narraleaf.com/docs/narraleaf-react/core/elements/script)
|
|
118
|
-
- [Condition](https://www.narraleaf.com/docs/narraleaf-react/core/elements/condition)
|
|
119
|
-
- [Control](https://www.narraleaf.com/docs/narraleaf-react/core/elements/control)
|
|
120
|
-
- [Text](https://www.narraleaf.com/docs/narraleaf-react/core/elements/text)
|
|
121
|
-
- [Persistent](https://www.narraleaf.com/docs/narraleaf-react/core/elements/persistent)
|
|
122
|
-
- [Story](https://www.narraleaf.com/docs/narraleaf-react/core/elements/story)
|
|
123
|
-
- [Displayable](https://www.narraleaf.com/docs/narraleaf-react/core/elements/displayable)
|
|
124
|
-
- [Layer](https://www.narraleaf.com/docs/narraleaf-react/core/elements/layer)
|
|
125
|
-
- [Service](https://www.narraleaf.com/docs/narraleaf-react/core/elements/service)
|
|
126
|
-
- [Video](https://www.narraleaf.com/docs/narraleaf-react/core/elements/video)
|
|
127
|
-
- [Built-in Gallery](https://www.narraleaf.com/docs/narraleaf-react/core/elements/built-in/gallery)
|
|
128
|
-
- [Animation](https://www.narraleaf.com/docs/narraleaf-react/core/animation)
|
|
129
|
-
- [Transform](https://www.narraleaf.com/docs/narraleaf-react/core/animation/transform)
|
|
130
|
-
- [Transitions](https://www.narraleaf.com/docs/narraleaf-react/core/animation/transition)
|
|
131
|
-
- [Game](https://www.narraleaf.com/docs/narraleaf-react/core/game)
|
|
132
|
-
- [LiveGame](https://www.narraleaf.com/docs/narraleaf-react/core/game/live-game)
|
|
133
|
-
- [Storable](https://www.narraleaf.com/docs/narraleaf-react/core/game/storable)
|
|
134
|
-
- [Preference](https://www.narraleaf.com/docs/narraleaf-react/core/game/preference/preference)
|
|
135
|
-
- [Key Map](https://www.narraleaf.com/docs/narraleaf-react/core/game/key-map)
|
|
136
|
-
- [Hooks](https://www.narraleaf.com/docs/narraleaf-react/core/game/hooks)
|
|
137
|
-
- [Plugin](https://www.narraleaf.com/docs/narraleaf-react/core/plugin)
|
|
138
|
-
- [Utils](https://www.narraleaf.com/docs/narraleaf-react/core/utils)
|
|
139
|
-
- [Player](https://www.narraleaf.com/docs/narraleaf-react/player)
|
|
140
|
-
- [Player](https://www.narraleaf.com/docs/narraleaf-react/player/player)
|
|
141
|
-
- [FixedAspectRatioContainer](https://www.narraleaf.com/docs/narraleaf-react/player/fixed-aspect-ratio-container)
|
|
142
|
-
- [GameProviders](https://www.narraleaf.com/docs/narraleaf-react/player/game-providers)
|
|
143
|
-
- [Hooks](https://www.narraleaf.com/docs/narraleaf-react/player/hooks)
|
|
144
|
-
- [LayoutRouter](https://www.narraleaf.com/docs/narraleaf-react/player/page-router)
|
|
145
|
-
- [Dialog](https://www.narraleaf.com/docs/narraleaf-react/player/dialog)
|
|
146
|
-
- [Notification](https://www.narraleaf.com/docs/narraleaf-react/player/notification)
|
|
147
|
-
- [Menu](https://www.narraleaf.com/docs/narraleaf-react/player/menu)
|
|
148
|
-
- [NvlContainer](https://www.narraleaf.com/docs/narraleaf-react/player/nvl-container)
|
|
149
|
-
- About
|
|
150
|
-
- [License](https://www.narraleaf.com/docs/narraleaf-react/info/license)
|
|
151
|
-
- [Incompatible Changes](https://www.narraleaf.com/docs/narraleaf-react/info/incompatible-changes)
|
|
152
|
-
|
|
153
|
-
Read more in the [NarraLeaf-React documentation](https://www.narraleaf.com/docs/narraleaf-react).
|
|
154
|
-
|
|
155
|
-
## License
|
|
156
|
-
|
|
157
|
-
> NarraLeaf-React is licensed under the MPL-2.0 License.
|
|
158
|
-
>
|
|
159
|
-
> We updated the license to MPL-2.0 on 2024-9-24.
|
|
160
|
-
|
|
161
|
-
## Contributing
|
|
162
|
-
|
|
163
|
-
We welcome all contributions.
|
|
164
|
-
If you have any ideas, just open an issue or a pull request.
|
|
165
|
-
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-transparent.png">
|
|
3
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
|
|
4
|
+
<img alt="NarraLeaf Logo" src="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
|
|
5
|
+
</picture>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">NarraLeaf-React</h1>
|
|
8
|
+
|
|
9
|
+
<h4 align="center">A React visual novel player framework</h4>
|
|
10
|
+
|
|
11
|
+
<p align="center">English | <a href="docs/README.zh-CN.md">简体中文</a></p>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## What is NarraLeaf-React?
|
|
15
|
+
|
|
16
|
+
NarraLeaf-React is a lightweight front-end visual novel player.
|
|
17
|
+
NL focuses on visual novel playing, so the user interface can be customized very easily.
|
|
18
|
+
|
|
19
|
+
It doesn't use any rendering libraries and can be used on any web platform (e.g. Electron)
|
|
20
|
+
|
|
21
|
+
## Why NarraLeaf-React?
|
|
22
|
+
|
|
23
|
+
- **Lightweight**: NarraLeaf-React is a front-end framework, and it doesn't use any rendering libraries.
|
|
24
|
+
- **Customizable**: You can customize the UI as you like, even replace the whole components.
|
|
25
|
+
- **Easy to use**: It is easy to use and has a simple API that is built for developers. Based on OOP principles.
|
|
26
|
+
|
|
27
|
+
### Scripting
|
|
28
|
+
|
|
29
|
+
NarraLeaf-React uses TypeScript for all scripting, so you don't have to learn a whole new language to use it.
|
|
30
|
+
|
|
31
|
+
It also has a highly abstracted and easy-to-use API, for example:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {Character, Menu, Scene, c, b} from "narraleaf-react";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
const scene1 = new Scene("Scene1: Hello World", {
|
|
39
|
+
background: "/link/to/background.jpg",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const jS = new Character("John Smith");
|
|
43
|
+
const jD = new Character("John Doe");
|
|
44
|
+
|
|
45
|
+
scene1.action([
|
|
46
|
+
jS`Hello, world!`,
|
|
47
|
+
jS`This is my first ${b("NarraLeaf")} story.`,
|
|
48
|
+
jS`Start editing ${c("src/story.js", "#00f")} and enjoy the journey!`,
|
|
49
|
+
|
|
50
|
+
jD`Also, don't forget to check out the ${c("documentation", "#00f")}!`,
|
|
51
|
+
|
|
52
|
+
"By the way, the documentation is available on https://www.narraleaf.com/docs/narraleaf-react",
|
|
53
|
+
"You can also visit the website for demo and more information.",
|
|
54
|
+
|
|
55
|
+
Menu.prompt("Start the journey")
|
|
56
|
+
|
|
57
|
+
.choose("Yes I will!", [
|
|
58
|
+
jS`Great! Let's start the journey!`,
|
|
59
|
+
jS`You can open issues on GitHub if you have any questions.`
|
|
60
|
+
])
|
|
61
|
+
|
|
62
|
+
.choose("No, I'm going to check the documentation", [
|
|
63
|
+
jS`Sure! Take your time!`
|
|
64
|
+
])
|
|
65
|
+
]);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For more information, please visit the [NarraLeaf-React documentation](https://www.narraleaf.com/docs/narraleaf-react).
|
|
69
|
+
|
|
70
|
+
## Get Started
|
|
71
|
+
|
|
72
|
+
### Install
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install narraleaf-react
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Documentation
|
|
79
|
+
|
|
80
|
+
- [Introduction](https://www.narraleaf.com/docs/narraleaf-react)
|
|
81
|
+
- [Quick Start](https://www.narraleaf.com/docs/narraleaf-react/quick-start)
|
|
82
|
+
- [Installation](https://www.narraleaf.com/docs/narraleaf-react/installation)
|
|
83
|
+
- [Basic](https://www.narraleaf.com/docs/narraleaf-react/basic)
|
|
84
|
+
- [Create a Scene](https://www.narraleaf.com/docs/narraleaf-react/basic/create-scene)
|
|
85
|
+
- [Add Actions](https://www.narraleaf.com/docs/narraleaf-react/basic/add-actions)
|
|
86
|
+
- [Show Dialog](https://www.narraleaf.com/docs/narraleaf-react/basic/show-dialog)
|
|
87
|
+
- [Show Image](https://www.narraleaf.com/docs/narraleaf-react/basic/show-image)
|
|
88
|
+
- [Play Story](https://www.narraleaf.com/docs/narraleaf-react/basic/play-story)
|
|
89
|
+
- [Make Choices](https://www.narraleaf.com/docs/narraleaf-react/basic/make-choices)
|
|
90
|
+
- [Play Sound](https://www.narraleaf.com/docs/narraleaf-react/basic/sound)
|
|
91
|
+
- [Store Data](https://www.narraleaf.com/docs/narraleaf-react/basic/store-data)
|
|
92
|
+
- [Conditional](https://www.narraleaf.com/docs/narraleaf-react/basic/conditional)
|
|
93
|
+
- [Voice](https://www.narraleaf.com/docs/narraleaf-react/basic/voice)
|
|
94
|
+
- [Manage Preferences](https://www.narraleaf.com/docs/narraleaf-react/basic/manage-preferences)
|
|
95
|
+
- [Solutions](https://www.narraleaf.com/docs/narraleaf-react/solutions)
|
|
96
|
+
- [Customizing the Font](https://www.narraleaf.com/docs/narraleaf-react/solutions/font)
|
|
97
|
+
- [Migration from Ren'Py](https://www.narraleaf.com/docs/narraleaf-react/solutions/from-renpy)
|
|
98
|
+
- [Quick Menu](https://www.narraleaf.com/docs/narraleaf-react/solutions/quick-menu)
|
|
99
|
+
- [Dialog Avatar](https://www.narraleaf.com/docs/narraleaf-react/solutions/dialog-avatar)
|
|
100
|
+
- [Custom Dialog](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-dialog)
|
|
101
|
+
- [Custom NVL Dialog](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-nvl-dialog)
|
|
102
|
+
- [Custom Menu](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-menu)
|
|
103
|
+
- [Page Overlay Settings](https://www.narraleaf.com/docs/narraleaf-react/solutions/page-overlay-settings)
|
|
104
|
+
- [Save System with localStorage](https://www.narraleaf.com/docs/narraleaf-react/solutions/save-system-localstorage)
|
|
105
|
+
- [Custom Notification](https://www.narraleaf.com/docs/narraleaf-react/solutions/custom-notification)
|
|
106
|
+
- [Gallery Service with localStorage](https://www.narraleaf.com/docs/narraleaf-react/solutions/gallery-service-localstorage)
|
|
107
|
+
- [Core](https://www.narraleaf.com/docs/narraleaf-react/core)
|
|
108
|
+
- [Elements](https://www.narraleaf.com/docs/narraleaf-react/core/elements)
|
|
109
|
+
- [Scene](https://www.narraleaf.com/docs/narraleaf-react/core/elements/scene)
|
|
110
|
+
- [Character](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character)
|
|
111
|
+
- [Sentence](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character/sentence)
|
|
112
|
+
- [Word](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character/word)
|
|
113
|
+
- [Pause](https://www.narraleaf.com/docs/narraleaf-react/core/elements/character/pause)
|
|
114
|
+
- [Image](https://www.narraleaf.com/docs/narraleaf-react/core/elements/image)
|
|
115
|
+
- [Sound](https://www.narraleaf.com/docs/narraleaf-react/core/elements/sound)
|
|
116
|
+
- [Menu](https://www.narraleaf.com/docs/narraleaf-react/core/elements/menu)
|
|
117
|
+
- [Script](https://www.narraleaf.com/docs/narraleaf-react/core/elements/script)
|
|
118
|
+
- [Condition](https://www.narraleaf.com/docs/narraleaf-react/core/elements/condition)
|
|
119
|
+
- [Control](https://www.narraleaf.com/docs/narraleaf-react/core/elements/control)
|
|
120
|
+
- [Text](https://www.narraleaf.com/docs/narraleaf-react/core/elements/text)
|
|
121
|
+
- [Persistent](https://www.narraleaf.com/docs/narraleaf-react/core/elements/persistent)
|
|
122
|
+
- [Story](https://www.narraleaf.com/docs/narraleaf-react/core/elements/story)
|
|
123
|
+
- [Displayable](https://www.narraleaf.com/docs/narraleaf-react/core/elements/displayable)
|
|
124
|
+
- [Layer](https://www.narraleaf.com/docs/narraleaf-react/core/elements/layer)
|
|
125
|
+
- [Service](https://www.narraleaf.com/docs/narraleaf-react/core/elements/service)
|
|
126
|
+
- [Video](https://www.narraleaf.com/docs/narraleaf-react/core/elements/video)
|
|
127
|
+
- [Built-in Gallery](https://www.narraleaf.com/docs/narraleaf-react/core/elements/built-in/gallery)
|
|
128
|
+
- [Animation](https://www.narraleaf.com/docs/narraleaf-react/core/animation)
|
|
129
|
+
- [Transform](https://www.narraleaf.com/docs/narraleaf-react/core/animation/transform)
|
|
130
|
+
- [Transitions](https://www.narraleaf.com/docs/narraleaf-react/core/animation/transition)
|
|
131
|
+
- [Game](https://www.narraleaf.com/docs/narraleaf-react/core/game)
|
|
132
|
+
- [LiveGame](https://www.narraleaf.com/docs/narraleaf-react/core/game/live-game)
|
|
133
|
+
- [Storable](https://www.narraleaf.com/docs/narraleaf-react/core/game/storable)
|
|
134
|
+
- [Preference](https://www.narraleaf.com/docs/narraleaf-react/core/game/preference/preference)
|
|
135
|
+
- [Key Map](https://www.narraleaf.com/docs/narraleaf-react/core/game/key-map)
|
|
136
|
+
- [Hooks](https://www.narraleaf.com/docs/narraleaf-react/core/game/hooks)
|
|
137
|
+
- [Plugin](https://www.narraleaf.com/docs/narraleaf-react/core/plugin)
|
|
138
|
+
- [Utils](https://www.narraleaf.com/docs/narraleaf-react/core/utils)
|
|
139
|
+
- [Player](https://www.narraleaf.com/docs/narraleaf-react/player)
|
|
140
|
+
- [Player](https://www.narraleaf.com/docs/narraleaf-react/player/player)
|
|
141
|
+
- [FixedAspectRatioContainer](https://www.narraleaf.com/docs/narraleaf-react/player/fixed-aspect-ratio-container)
|
|
142
|
+
- [GameProviders](https://www.narraleaf.com/docs/narraleaf-react/player/game-providers)
|
|
143
|
+
- [Hooks](https://www.narraleaf.com/docs/narraleaf-react/player/hooks)
|
|
144
|
+
- [LayoutRouter](https://www.narraleaf.com/docs/narraleaf-react/player/page-router)
|
|
145
|
+
- [Dialog](https://www.narraleaf.com/docs/narraleaf-react/player/dialog)
|
|
146
|
+
- [Notification](https://www.narraleaf.com/docs/narraleaf-react/player/notification)
|
|
147
|
+
- [Menu](https://www.narraleaf.com/docs/narraleaf-react/player/menu)
|
|
148
|
+
- [NvlContainer](https://www.narraleaf.com/docs/narraleaf-react/player/nvl-container)
|
|
149
|
+
- About
|
|
150
|
+
- [License](https://www.narraleaf.com/docs/narraleaf-react/info/license)
|
|
151
|
+
- [Incompatible Changes](https://www.narraleaf.com/docs/narraleaf-react/info/incompatible-changes)
|
|
152
|
+
|
|
153
|
+
Read more in the [NarraLeaf-React documentation](https://www.narraleaf.com/docs/narraleaf-react).
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
> NarraLeaf-React is licensed under the MPL-2.0 License.
|
|
158
|
+
>
|
|
159
|
+
> We updated the license to MPL-2.0 on 2024-9-24.
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
We welcome all contributions.
|
|
164
|
+
If you have any ideas, just open an issue or a pull request.
|
|
165
|
+
|
|
@@ -2,9 +2,18 @@ import { ControlAction } from "../../action/actions/controlAction";
|
|
|
2
2
|
import { Chained, Proxied } from "../../action/chain";
|
|
3
3
|
import { GameState } from "../../common/game";
|
|
4
4
|
import { LogicAction } from "../../game";
|
|
5
|
+
import type { LiveGameEventToken } from "../../types";
|
|
5
6
|
import { Layer } from "../layer";
|
|
6
7
|
import { DynamicPersistent, Persistent } from "../persistent";
|
|
7
8
|
import { Scene } from "../scene";
|
|
9
|
+
/** Snapshot of the dialog line currently presented to the player (ADV or NVL). */
|
|
10
|
+
export type DevToolsCurrentDialog = {
|
|
11
|
+
/** Id of the say action that produced the line (static id when assigned). */
|
|
12
|
+
actionId: string | null;
|
|
13
|
+
/** True once the line finished displaying and awaits advance. */
|
|
14
|
+
ended: boolean;
|
|
15
|
+
mode: "adv" | "nvl";
|
|
16
|
+
};
|
|
8
17
|
export declare class DevTools {
|
|
9
18
|
static getActionId(action: LogicAction.Actions): string;
|
|
10
19
|
static setActionId(action: LogicAction.Actions, id: string): LogicAction.Actions;
|
|
@@ -49,5 +58,17 @@ export declare class DevTools {
|
|
|
49
58
|
static setDisplayableTransformProps(gameState: GameState, displayable: LogicAction.DisplayableElements, props: Record<string, unknown>, options?: {
|
|
50
59
|
merge?: boolean;
|
|
51
60
|
}): void;
|
|
61
|
+
/**
|
|
62
|
+
* Read the dialog line currently presented to the player, or null when no
|
|
63
|
+
* dialog is on screen. Covers both ADV (tracked via GameState.beginAdvDialog)
|
|
64
|
+
* and NVL (active entry + phase) presentation.
|
|
65
|
+
*/
|
|
66
|
+
static getCurrentDialog(gameState: GameState): DevToolsCurrentDialog | null;
|
|
67
|
+
/**
|
|
68
|
+
* Subscribe to changes of the currently presented dialog line (creation,
|
|
69
|
+
* typing completion, advance/settle) across ADV and NVL modes. The listener
|
|
70
|
+
* carries no payload; call {@link getCurrentDialog} to read the new state.
|
|
71
|
+
*/
|
|
72
|
+
static onDialogStateChange(gameState: GameState, listener: () => void): LiveGameEventToken;
|
|
52
73
|
static DynamicPersistent: typeof DynamicPersistent;
|
|
53
74
|
}
|
|
@@ -37,6 +37,17 @@ export type NvlDialogEntry = {
|
|
|
37
37
|
text: string;
|
|
38
38
|
};
|
|
39
39
|
export type NvlDialogPhase = "idle" | "typing" | "awaitAdvance";
|
|
40
|
+
/**
|
|
41
|
+
* Transient tracking record for the currently displayed ADV dialog line.
|
|
42
|
+
* Rebuilt naturally on load/undo because the pending say action re-executes;
|
|
43
|
+
* never serialized.
|
|
44
|
+
*/
|
|
45
|
+
export type AdvDialogState = {
|
|
46
|
+
dialogId: string;
|
|
47
|
+
actionId: string | null;
|
|
48
|
+
/** True once the sentence finished displaying (typing done or skipped to full text). */
|
|
49
|
+
ended: boolean;
|
|
50
|
+
};
|
|
40
51
|
export type NvlState = {
|
|
41
52
|
active: boolean;
|
|
42
53
|
visible: boolean;
|
|
@@ -118,6 +129,7 @@ type GameStateEvents = {
|
|
|
118
129
|
"event:state.end": [];
|
|
119
130
|
"event:state.player.skip": [force?: boolean];
|
|
120
131
|
"event:state.player.lineEnd": [];
|
|
132
|
+
"event:state.dialog.change": [];
|
|
121
133
|
"event:state.player.requestFlush": [];
|
|
122
134
|
"event:state.player.stageClick": [];
|
|
123
135
|
"event:state.scene.mount": [scene: Scene];
|
|
@@ -165,6 +177,7 @@ export declare class GameState {
|
|
|
165
177
|
pageRouter: null;
|
|
166
178
|
private stageClickBuffer;
|
|
167
179
|
private readonly nvlAdvanceWaiters;
|
|
180
|
+
private advDialogState;
|
|
168
181
|
constructor(game: Game, stage: StageUtils);
|
|
169
182
|
get deps(): number;
|
|
170
183
|
addVideo(video: Video): this;
|
|
@@ -268,6 +281,20 @@ export declare class GameState {
|
|
|
268
281
|
settleNvlDialog(dialogId: string): this;
|
|
269
282
|
suppressNextNvlTyping(): this;
|
|
270
283
|
consumeNvlTypingSuppression(): boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Track the ADV dialog created by a say action. Emits `event:state.dialog.change`.
|
|
286
|
+
*/
|
|
287
|
+
beginAdvDialog(dialogId: string, actionId: string | null): this;
|
|
288
|
+
/**
|
|
289
|
+
* Mark the tracked ADV dialog as fully displayed. No-op when the dialog id
|
|
290
|
+
* does not match the tracked one (e.g. DialogState reused outside ADV flow).
|
|
291
|
+
*/
|
|
292
|
+
completeAdvDialogTyping(dialogId: string | undefined): this;
|
|
293
|
+
/**
|
|
294
|
+
* Clear the tracked ADV dialog when the line is advanced past or cancelled.
|
|
295
|
+
*/
|
|
296
|
+
settleAdvDialog(dialogId: string): this;
|
|
297
|
+
getAdvDialogState(): AdvDialogState | null;
|
|
271
298
|
recordStageClick(): this;
|
|
272
299
|
consumeStageClick(maxAgeMs?: number): boolean;
|
|
273
300
|
createDisplayable(displayable: LogicAction.DisplayableElements, scene?: Scene | null, layer?: Layer | null): this;
|