@remvst/game-navigation-react 1.4.0 → 2.0.0
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/CHANGELOG.md +9 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -18
- package/lib/index.js.map +1 -0
- package/lib/react-game-plugin.js +4 -7
- package/lib/react-game-plugin.js.map +1 -0
- package/lib/react-screen.d.ts +1 -4
- package/lib/react-screen.js +23 -26
- package/lib/react-screen.js.map +1 -0
- package/package.json +24 -22
- package/src/index.ts +2 -2
- package/src/react-game-plugin.ts +1 -1
- package/src/react-screen.ts +16 -21
- package/tsconfig.json +6 -8
package/CHANGELOG.md
ADDED
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./react-game-plugin";
|
|
2
|
+
export * from "./react-screen";
|
package/lib/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./react-game-plugin"), exports);
|
|
18
|
-
__exportStar(require("./react-screen"), exports);
|
|
1
|
+
export * from "./react-game-plugin";
|
|
2
|
+
export * from "./react-screen";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
package/lib/react-game-plugin.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ReactGamePlugin = void 0;
|
|
4
|
-
const game_navigation_core_1 = require("@remvst/game-navigation-core");
|
|
5
|
-
class ReactGamePlugin extends game_navigation_core_1.GamePlugin {
|
|
1
|
+
import { GamePlugin } from "@remvst/game-navigation-core";
|
|
2
|
+
export class ReactGamePlugin extends GamePlugin {
|
|
6
3
|
constructor() {
|
|
7
4
|
super(...arguments);
|
|
8
5
|
this.key = ReactGamePlugin.key;
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
ReactGamePlugin.key = "react";
|
|
9
|
+
//# sourceMappingURL=react-game-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-game-plugin.js","sourceRoot":"","sources":["../src/react-game-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAA/C;;QAEa,QAAG,GAAG,eAAe,CAAC,GAAG,CAAC;IACvC,CAAC;CAAA;AAFmB,mBAAG,GAAG,OAAO,AAAV,CAAW"}
|
package/lib/react-screen.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { HTMLScreen } from '@remvst/game-navigation-html';
|
|
1
|
+
import { HTMLScreen } from "@remvst/game-navigation-html";
|
|
3
2
|
export declare abstract class ReactScreen extends HTMLScreen {
|
|
4
3
|
private root;
|
|
5
4
|
private rootContainer;
|
|
6
5
|
abstract rootComponent(): Promise<React.ReactElement>;
|
|
7
6
|
setup(): void;
|
|
8
|
-
foreground(): void;
|
|
9
|
-
background(): void;
|
|
10
7
|
destroy(): void;
|
|
11
8
|
rebuild(): void;
|
|
12
9
|
}
|
package/lib/react-screen.js
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const client_1 = require("react-dom/client");
|
|
5
|
-
const game_navigation_html_1 = require("@remvst/game-navigation-html");
|
|
6
|
-
class ReactScreen extends game_navigation_html_1.HTMLScreen {
|
|
1
|
+
import { HTMLScreen } from "@remvst/game-navigation-html";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
export class ReactScreen extends HTMLScreen {
|
|
7
4
|
constructor() {
|
|
8
5
|
super(...arguments);
|
|
9
|
-
this.rootContainer = document.createElement(
|
|
6
|
+
this.rootContainer = document.createElement("div");
|
|
10
7
|
}
|
|
11
8
|
setup() {
|
|
12
9
|
super.setup();
|
|
13
|
-
this.root =
|
|
14
|
-
this.rootComponent().then(component => {
|
|
15
|
-
|
|
10
|
+
this.root = createRoot(this.rootContainer);
|
|
11
|
+
this.rootComponent().then((component) => {
|
|
12
|
+
var _a;
|
|
13
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.render(component);
|
|
16
14
|
});
|
|
17
|
-
this.rootContainer.style.width =
|
|
18
|
-
this.rootContainer.style.height =
|
|
19
|
-
}
|
|
20
|
-
foreground() {
|
|
21
|
-
super.foreground();
|
|
22
|
-
this.view.style.display = 'block';
|
|
15
|
+
this.rootContainer.style.width = "100%";
|
|
16
|
+
this.rootContainer.style.height = "100%";
|
|
23
17
|
this.view.appendChild(this.rootContainer);
|
|
24
18
|
}
|
|
25
|
-
background() {
|
|
26
|
-
super.background();
|
|
27
|
-
this.view.style.display = 'none';
|
|
28
|
-
this.rootContainer.parentNode?.removeChild(this.rootContainer);
|
|
29
|
-
}
|
|
30
19
|
destroy() {
|
|
20
|
+
var _a;
|
|
31
21
|
super.destroy();
|
|
32
|
-
this.root.unmount();
|
|
22
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
33
23
|
this.root = null;
|
|
34
24
|
}
|
|
35
25
|
rebuild() {
|
|
36
|
-
|
|
37
|
-
this.root
|
|
38
|
-
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
28
|
+
const root = createRoot(this.rootContainer);
|
|
29
|
+
this.root = root;
|
|
30
|
+
this.rootComponent().then((component) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (this.root !== root)
|
|
33
|
+
return;
|
|
34
|
+
(_a = this.root) === null || _a === void 0 ? void 0 : _a.render(component);
|
|
35
|
+
});
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
|
-
|
|
38
|
+
//# sourceMappingURL=react-screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-screen.js","sourceRoot":"","sources":["../src/react-screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AAEpD,MAAM,OAAgB,WAAY,SAAQ,UAAU;IAApD;;QAEY,kBAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAmC1D,CAAC;IA/BG,KAAK;QACD,KAAK,CAAC,KAAK,EAAE,CAAC;QAEd,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC3C,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;;YACpC,MAAA,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;QACxC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QAEzC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO;;QACH,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,OAAO;;QACH,MAAA,IAAI,CAAC,IAAI,0CAAE,OAAO,EAAE,CAAC;QAErB,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;;YACpC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;gBAAE,OAAO;YAC/B,MAAA,IAAI,CAAC,IAAI,0CAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
"name": "@remvst/game-navigation-react",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Plugin for displaying screens as React containers",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"author": "Rémi Vansteelandt",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"@types/react-dom": "^18.2.0",
|
|
10
|
+
"react": "^18.2.0",
|
|
11
|
+
"react-dom": "^18.2.0",
|
|
12
|
+
"@remvst/game-navigation-core": "^2.0.0",
|
|
13
|
+
"@remvst/game-navigation-html": "^2.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/react-dom": "^18.2.0",
|
|
17
|
+
"react": "^18.2.0",
|
|
18
|
+
"react-dom": "^18.2.0",
|
|
19
|
+
"typescript": "^7.0.2",
|
|
20
|
+
"@remvst/game-navigation-core": "2.0.0",
|
|
21
|
+
"@remvst/game-navigation-html": "2.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rm -rf lib && tsc"
|
|
24
25
|
}
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./react-game-plugin";
|
|
2
|
+
export * from "./react-screen";
|
package/src/react-game-plugin.ts
CHANGED
package/src/react-screen.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HTMLScreen } from "@remvst/game-navigation-html";
|
|
2
|
+
import { createRoot, Root } from "react-dom/client";
|
|
3
3
|
|
|
4
4
|
export abstract class ReactScreen extends HTMLScreen {
|
|
5
|
-
|
|
6
5
|
private root: Root;
|
|
7
|
-
private rootContainer = document.createElement(
|
|
6
|
+
private rootContainer = document.createElement("div");
|
|
8
7
|
|
|
9
8
|
abstract rootComponent(): Promise<React.ReactElement>;
|
|
10
9
|
|
|
@@ -12,35 +11,31 @@ export abstract class ReactScreen extends HTMLScreen {
|
|
|
12
11
|
super.setup();
|
|
13
12
|
|
|
14
13
|
this.root = createRoot(this.rootContainer);
|
|
15
|
-
this.rootComponent().then(component => {
|
|
14
|
+
this.rootComponent().then((component) => {
|
|
16
15
|
this.root?.render(component);
|
|
17
16
|
});
|
|
18
17
|
|
|
19
|
-
this.rootContainer.style.width =
|
|
20
|
-
this.rootContainer.style.height =
|
|
21
|
-
}
|
|
18
|
+
this.rootContainer.style.width = "100%";
|
|
19
|
+
this.rootContainer.style.height = "100%";
|
|
22
20
|
|
|
23
|
-
foreground(): void {
|
|
24
|
-
super.foreground();
|
|
25
|
-
this.view.style.display = 'block';
|
|
26
21
|
this.view.appendChild(this.rootContainer);
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
background(): void {
|
|
30
|
-
super.background();
|
|
31
|
-
this.view.style.display = 'none';
|
|
32
|
-
this.rootContainer.parentNode?.removeChild(this.rootContainer);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
24
|
destroy() {
|
|
36
25
|
super.destroy();
|
|
37
|
-
this.root
|
|
26
|
+
this.root?.unmount();
|
|
38
27
|
this.root = null;
|
|
39
28
|
}
|
|
40
29
|
|
|
41
30
|
rebuild() {
|
|
42
|
-
this.root
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
this.root?.unmount();
|
|
32
|
+
|
|
33
|
+
const root = createRoot(this.rootContainer);
|
|
34
|
+
this.root = root;
|
|
35
|
+
|
|
36
|
+
this.rootComponent().then((component) => {
|
|
37
|
+
if (this.root !== root) return;
|
|
38
|
+
this.root?.render(component);
|
|
39
|
+
});
|
|
45
40
|
}
|
|
46
41
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"declaration": true,
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
6
|
"strict": false,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"allowJs": false,
|
|
9
7
|
"outDir": "./lib",
|
|
10
|
-
"
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"rootDir": "./src"
|
|
11
10
|
},
|
|
12
|
-
"include": ["./src/**/*"]
|
|
13
|
-
"exclude": ["node_modules"]
|
|
11
|
+
"include": ["./src/**/*"]
|
|
14
12
|
}
|