@kawaijs/runtime 0.1.0 → 0.1.1
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 +42 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @kawaijs/runtime
|
|
2
|
+
|
|
3
|
+
**Headless Story VM, State Machine, Snapshot Rollback, and Persistence Engine for Kawaijs.**
|
|
4
|
+
|
|
5
|
+
Part of the [Kawaijs](https://github.com/biagio-scaglia/KawaiJS) visual novel engine.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @kawaijs/runtime
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { compileScript } from '@kawaijs/parser';
|
|
17
|
+
import { StoryVM } from '@kawaijs/runtime';
|
|
18
|
+
|
|
19
|
+
const story = compileScript(`
|
|
20
|
+
label start:
|
|
21
|
+
"Welcome to the story!"
|
|
22
|
+
"Step 2"
|
|
23
|
+
`);
|
|
24
|
+
|
|
25
|
+
const vm = new StoryVM(story);
|
|
26
|
+
vm.onStateChange((state) => {
|
|
27
|
+
console.log('Dialogue:', state.dialogue?.text);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
vm.start();
|
|
31
|
+
vm.next(); // Advances to Step 2
|
|
32
|
+
vm.rollback(); // Rolls back to Welcome
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
- **Deterministic Virtual Machine**: Headless execution loop.
|
|
37
|
+
- **Time-Travel Rollback**: Deep state snapshots for backwards navigation.
|
|
38
|
+
- **Save & Load**: Pluggable storage adapters (LocalStorage, Memory).
|
|
39
|
+
- **Dialogue History**: Built-in history logging for spoken lines.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
MIT © Biagio Scaglia
|
package/package.json
CHANGED