@react-text-game/core 0.5.13 → 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
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":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0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,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"}
|
|
@@ -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",
|