@react-text-game/core 0.5.12 → 0.5.14
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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/passages/story/types.d.ts +31 -2
- package/dist/passages/story/types.d.ts.map +1 -1
- package/dist/passages/widget.d.ts +35 -5
- package/dist/passages/widget.d.ts.map +1 -1
- package/dist/passages/widget.js +22 -4
- package/dist/passages/widget.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from "./hooks";
|
|
|
10
10
|
export type * from "./types";
|
|
11
11
|
export type { SimpleObject } from "./gameObjects/simpleObject";
|
|
12
12
|
export type { AnyHotspot, InteractiveMapOptions, InteractiveMapType, LabelHotspot, MapImageHotspot, MapLabelHotspot, MapMenu, SideImageHotspot, SideLabelHotspot, } from "./passages/interactiveMap";
|
|
13
|
-
export type { ActionsComponent, ActionType, AnotherStoryComponent, Component, ConversationAppearance, ConversationBubble, ConversationBubbleSide, ConversationComponent, ConversationVariant, HeaderComponent, HeaderLevel, ImageComponent, StoryContent, StoryOptions, TextComponent, VideoComponent, } from "./passages/story";
|
|
13
|
+
export type { ActionsComponent, ActionType, AnotherStoryComponent, Component, ConversationAppearance, ConversationBubble, ConversationBubbleSide, ConversationComponent, ConversationVariant, HeaderComponent, HeaderLevel, ImageComponent, StoryComponents, StoryContent, StoryOptions, TextComponent, VideoComponent, } from "./passages/story";
|
|
14
|
+
export type { WidgetContent } from "./passages/widget";
|
|
14
15
|
export { BaseGameObject, createEntity, Game, InteractiveMap, newInteractiveMap, NewOptions, newStory, newWidget, Options, Passage, Story, Widget, };
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[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AAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,mBAAmB,QAAQ,CAAC;AAG5B,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,YAAY,EACR,UAAU,EACV,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,OAAO,EACP,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACR,gBAAgB,EAChB,UAAU,EACV,qBAAqB,EACrB,SAAS,EACT,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,cAAc,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,GACjB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EACH,cAAc,EACd,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,GACT,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAuCxB,OAAO,EACH,cAAc,EACd,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,iBAAiB,EAEjB,QAAQ,EACR,SAAS,EAET,OAAO,EACP,KAAK,EACL,MAAM,GACT,CAAC"}
|
|
@@ -71,6 +71,30 @@ export interface TextComponent extends BaseComponent {
|
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
className?: string;
|
|
74
|
+
/**
|
|
75
|
+
* When `true`, renders the content as raw HTML using `dangerouslySetInnerHTML`.
|
|
76
|
+
* This allows using HTML markup in `.ts` files without needing JSX/TSX.
|
|
77
|
+
*
|
|
78
|
+
* @defaultValue false
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* - Only works when `content` is a string. If `content` is a ReactNode,
|
|
82
|
+
* this prop is ignored and the content is rendered normally.
|
|
83
|
+
* - The browser handles HTML parsing natively and is forgiving with malformed HTML.
|
|
84
|
+
* - **Security:** Since game authors control their own content, XSS is not
|
|
85
|
+
* a concern. Do not use with untrusted user input.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // In a .ts file (no JSX needed)
|
|
90
|
+
* {
|
|
91
|
+
* type: 'text',
|
|
92
|
+
* content: '<strong>Bold</strong> and <em>italic</em> text',
|
|
93
|
+
* props: { isHTML: true }
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
isHTML?: boolean;
|
|
74
98
|
};
|
|
75
99
|
}
|
|
76
100
|
/**
|
|
@@ -799,13 +823,18 @@ export interface ConversationComponent extends BaseComponent {
|
|
|
799
823
|
* based on the `type` property when rendering or processing components.
|
|
800
824
|
*/
|
|
801
825
|
export type Component = TextComponent | HeaderComponent | ImageComponent | VideoComponent | ActionsComponent | ConversationComponent | AnotherStoryComponent;
|
|
826
|
+
/**
|
|
827
|
+
* Array of story components.
|
|
828
|
+
* Used to define the structure of a story passage.
|
|
829
|
+
*/
|
|
830
|
+
export type StoryComponents = Array<Component>;
|
|
802
831
|
/**
|
|
803
832
|
* Function type for story content generation.
|
|
804
833
|
* Receives props and returns an array of components to display.
|
|
805
834
|
*
|
|
806
835
|
* @template T - Type of props passed to the story (extends InitVarsType)
|
|
807
836
|
* @param props - Properties used for conditional rendering or dynamic content
|
|
808
|
-
* @returns Array of components
|
|
837
|
+
* @returns Array of story components to render
|
|
809
838
|
*
|
|
810
839
|
* @example
|
|
811
840
|
* ```typescript
|
|
@@ -840,7 +869,7 @@ export type Component = TextComponent | HeaderComponent | ImageComponent | Video
|
|
|
840
869
|
* - Access reactive game state through props for dynamic content
|
|
841
870
|
* - Return value is memoized based on props
|
|
842
871
|
*/
|
|
843
|
-
export type StoryContent = <T extends InitVarsType = EmptyObject>(props: T) =>
|
|
872
|
+
export type StoryContent = <T extends InitVarsType = EmptyObject>(props: T) => StoryComponents;
|
|
844
873
|
/**
|
|
845
874
|
* Configuration options for story appearance and behavior.
|
|
846
875
|
* Applied to the entire story passage.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/passages/story/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;;;;;OAQG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;CACxD;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAChD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,OAAO,EAAE,SAAS,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE;QACJ;;;;;;;;WAQG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/passages/story/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B;;;;;;;;OAQG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;CACxD;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAc,SAAQ,aAAa;IAChD;;OAE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tB,CAAC;CACL,CAAC"}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Passage } from "../passages/passage";
|
|
3
|
+
/**
|
|
4
|
+
* Content type for Widget passages.
|
|
5
|
+
* Can be a ReactNode directly, or a function that returns a ReactNode.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // As ReactNode
|
|
10
|
+
* const content: WidgetContent = <div>Hello</div>;
|
|
11
|
+
*
|
|
12
|
+
* // As function
|
|
13
|
+
* const content: WidgetContent = () => <div>Hello</div>;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export type WidgetContent = ReactNode | (() => ReactNode);
|
|
3
17
|
/**
|
|
4
18
|
* Custom React component passage for fully customized UI.
|
|
5
19
|
*
|
|
@@ -11,6 +25,7 @@ import { Passage } from "../passages/passage";
|
|
|
11
25
|
* ```typescript
|
|
12
26
|
* import { newWidget } from '@react-text-game/core';
|
|
13
27
|
*
|
|
28
|
+
* // With ReactNode
|
|
14
29
|
* const inventoryUI = newWidget('inventory', (
|
|
15
30
|
* <div className="inventory">
|
|
16
31
|
* <h2>Your Inventory</h2>
|
|
@@ -19,6 +34,14 @@ import { Passage } from "../passages/passage";
|
|
|
19
34
|
* </div>
|
|
20
35
|
* ));
|
|
21
36
|
*
|
|
37
|
+
* // With function component
|
|
38
|
+
* const dynamicUI = newWidget('dynamic', () => (
|
|
39
|
+
* <div>
|
|
40
|
+
* <h2>Dynamic Content</h2>
|
|
41
|
+
* <p>Current time: {Date.now()}</p>
|
|
42
|
+
* </div>
|
|
43
|
+
* ));
|
|
44
|
+
*
|
|
22
45
|
* // Navigate to custom UI
|
|
23
46
|
* Game.jumpTo(inventoryUI);
|
|
24
47
|
* ```
|
|
@@ -27,18 +50,19 @@ import { Passage } from "../passages/passage";
|
|
|
27
50
|
*/
|
|
28
51
|
export declare class Widget extends Passage {
|
|
29
52
|
/**
|
|
30
|
-
* The React component/element to render.
|
|
53
|
+
* The React component/element or function to render.
|
|
31
54
|
*/
|
|
32
55
|
private readonly content;
|
|
33
56
|
/**
|
|
34
57
|
* Creates a new Widget passage.
|
|
35
58
|
*
|
|
36
59
|
* @param id - Unique identifier for this widget
|
|
37
|
-
* @param content - React node
|
|
60
|
+
* @param content - React node or function returning React node to display
|
|
38
61
|
*/
|
|
39
|
-
constructor(id: string, content:
|
|
62
|
+
constructor(id: string, content: WidgetContent);
|
|
40
63
|
/**
|
|
41
64
|
* Returns the React node for rendering.
|
|
65
|
+
* If content is a function, it will be called to get the ReactNode.
|
|
42
66
|
*
|
|
43
67
|
* @returns The React content to be rendered
|
|
44
68
|
*/
|
|
@@ -48,15 +72,21 @@ export declare class Widget extends Passage {
|
|
|
48
72
|
* Factory function for creating Widget passages.
|
|
49
73
|
*
|
|
50
74
|
* @param id - Unique identifier for the widget
|
|
51
|
-
* @param content - React node to display
|
|
75
|
+
* @param content - React node or function returning React node to display
|
|
52
76
|
* @returns New Widget instance
|
|
53
77
|
*
|
|
54
78
|
* @example
|
|
55
79
|
* ```typescript
|
|
80
|
+
* // With ReactNode
|
|
56
81
|
* const customMenu = newWidget('menu', (
|
|
57
82
|
* <CustomMenuComponent />
|
|
58
83
|
* ));
|
|
84
|
+
*
|
|
85
|
+
* // With function component
|
|
86
|
+
* const dynamicMenu = newWidget('dynamic-menu', () => (
|
|
87
|
+
* <CustomMenuComponent data={getCurrentData()} />
|
|
88
|
+
* ));
|
|
59
89
|
* ```
|
|
60
90
|
*/
|
|
61
|
-
export declare const newWidget: (id: string, content:
|
|
91
|
+
export declare const newWidget: (id: string, content: WidgetContent) => Widget;
|
|
62
92
|
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/passages/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/passages/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,MAAO,SAAQ,OAAO;IAC/B;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IAExC;;;;;OAKG;gBACS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAK9C;;;;;OAKG;IACH,OAAO;CAKV;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS,GAAI,IAAI,MAAM,EAAE,SAAS,aAAa,WACjC,CAAC"}
|
package/dist/passages/widget.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Passage } from "../passages/passage";
|
|
|
10
10
|
* ```typescript
|
|
11
11
|
* import { newWidget } from '@react-text-game/core';
|
|
12
12
|
*
|
|
13
|
+
* // With ReactNode
|
|
13
14
|
* const inventoryUI = newWidget('inventory', (
|
|
14
15
|
* <div className="inventory">
|
|
15
16
|
* <h2>Your Inventory</h2>
|
|
@@ -18,6 +19,14 @@ import { Passage } from "../passages/passage";
|
|
|
18
19
|
* </div>
|
|
19
20
|
* ));
|
|
20
21
|
*
|
|
22
|
+
* // With function component
|
|
23
|
+
* const dynamicUI = newWidget('dynamic', () => (
|
|
24
|
+
* <div>
|
|
25
|
+
* <h2>Dynamic Content</h2>
|
|
26
|
+
* <p>Current time: {Date.now()}</p>
|
|
27
|
+
* </div>
|
|
28
|
+
* ));
|
|
29
|
+
*
|
|
21
30
|
* // Navigate to custom UI
|
|
22
31
|
* Game.jumpTo(inventoryUI);
|
|
23
32
|
* ```
|
|
@@ -26,14 +35,14 @@ import { Passage } from "../passages/passage";
|
|
|
26
35
|
*/
|
|
27
36
|
export class Widget extends Passage {
|
|
28
37
|
/**
|
|
29
|
-
* The React component/element to render.
|
|
38
|
+
* The React component/element or function to render.
|
|
30
39
|
*/
|
|
31
40
|
content;
|
|
32
41
|
/**
|
|
33
42
|
* Creates a new Widget passage.
|
|
34
43
|
*
|
|
35
44
|
* @param id - Unique identifier for this widget
|
|
36
|
-
* @param content - React node
|
|
45
|
+
* @param content - React node or function returning React node to display
|
|
37
46
|
*/
|
|
38
47
|
constructor(id, content) {
|
|
39
48
|
super(id, "widget");
|
|
@@ -41,25 +50,34 @@ export class Widget extends Passage {
|
|
|
41
50
|
}
|
|
42
51
|
/**
|
|
43
52
|
* Returns the React node for rendering.
|
|
53
|
+
* If content is a function, it will be called to get the ReactNode.
|
|
44
54
|
*
|
|
45
55
|
* @returns The React content to be rendered
|
|
46
56
|
*/
|
|
47
57
|
display() {
|
|
48
|
-
return this.content
|
|
58
|
+
return typeof this.content === "function"
|
|
59
|
+
? this.content()
|
|
60
|
+
: this.content;
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
/**
|
|
52
64
|
* Factory function for creating Widget passages.
|
|
53
65
|
*
|
|
54
66
|
* @param id - Unique identifier for the widget
|
|
55
|
-
* @param content - React node to display
|
|
67
|
+
* @param content - React node or function returning React node to display
|
|
56
68
|
* @returns New Widget instance
|
|
57
69
|
*
|
|
58
70
|
* @example
|
|
59
71
|
* ```typescript
|
|
72
|
+
* // With ReactNode
|
|
60
73
|
* const customMenu = newWidget('menu', (
|
|
61
74
|
* <CustomMenuComponent />
|
|
62
75
|
* ));
|
|
76
|
+
*
|
|
77
|
+
* // With function component
|
|
78
|
+
* const dynamicMenu = newWidget('dynamic-menu', () => (
|
|
79
|
+
* <CustomMenuComponent data={getCurrentData()} />
|
|
80
|
+
* ));
|
|
63
81
|
* ```
|
|
64
82
|
*/
|
|
65
83
|
export const newWidget = (id, content) => new Widget(id, content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../src/passages/widget.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../../src/passages/widget.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAiB5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,MAAO,SAAQ,OAAO;IAC/B;;OAEG;IACc,OAAO,CAAgB;IAExC;;;;;OAKG;IACH,YAAY,EAAU,EAAE,OAAsB;QAC1C,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACH,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU;YACrC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE;YAChB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,OAAsB,EAAE,EAAE,CAC5D,IAAI,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-text-game/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.14",
|
|
4
4
|
"description": "A powerful React-based text game engine with reactive state management, passage-based navigation, and persistent save system for building interactive narrative experiences",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|