react-simple-game-engine 0.0.7 → 0.0.8
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/lib/ui-components/SceneRunner.d.ts +7 -4
- package/lib/ui-components/SceneRunner.d.ts.map +1 -1
- package/lib/ui-components/SceneRunner.js +9 -3
- package/lib/ui-components/ScenesProcess.d.ts +3 -4
- package/lib/ui-components/ScenesProcess.d.ts.map +1 -1
- package/lib/ui-components/ScenesProcess.js +24 -2
- package/package.json +1 -1
@@ -1,10 +1,13 @@
|
|
1
|
-
|
1
|
+
import { ComponentType, ReactNode } from "react";
|
2
2
|
import { Scene } from "../classes/scene";
|
3
|
-
declare type
|
4
|
-
current: Scene;
|
3
|
+
export declare type SceneRunnerPublicProps = {
|
5
4
|
width: number;
|
6
5
|
height: number;
|
6
|
+
assetsLoader?: ReactNode | ComponentType;
|
7
|
+
};
|
8
|
+
declare type SceneRunnerProps = SceneRunnerPublicProps & {
|
9
|
+
current: Scene;
|
7
10
|
};
|
8
|
-
export declare function SceneRunner({ current, width, height }: SceneRunnerProps): JSX.Element;
|
11
|
+
export declare function SceneRunner({ current, width, height, assetsLoader: AssetsLoader, }: SceneRunnerProps): JSX.Element;
|
9
12
|
export {};
|
10
13
|
//# sourceMappingURL=SceneRunner.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SceneRunner.d.ts","sourceRoot":"","sources":["../../src/ui-components/SceneRunner.tsx"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"SceneRunner.d.ts","sourceRoot":"","sources":["../../src/ui-components/SceneRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAGV,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;CAC1C,CAAC;AAEF,aAAK,gBAAgB,GAAG,sBAAsB,GAAG;IAC/C,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EAAE,YAAY,GAC3B,EAAE,gBAAgB,eAwClB"}
|
@@ -10,10 +10,10 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
-
import { useEffect } from "react";
|
13
|
+
import { useEffect, useMemo, } from "react";
|
14
14
|
import { Sketch } from "./Sketch";
|
15
15
|
export function SceneRunner(_a) {
|
16
|
-
var current = _a.current, width = _a.width, height = _a.height;
|
16
|
+
var current = _a.current, width = _a.width, height = _a.height, AssetsLoader = _a.assetsLoader;
|
17
17
|
useEffect(function () {
|
18
18
|
current.loadAssets();
|
19
19
|
}, [current]);
|
@@ -23,6 +23,12 @@ export function SceneRunner(_a) {
|
|
23
23
|
var draw = function () {
|
24
24
|
current.action();
|
25
25
|
};
|
26
|
+
var assetsLoader = useMemo(function () {
|
27
|
+
if (typeof AssetsLoader === "function") {
|
28
|
+
return _jsx(AssetsLoader, {});
|
29
|
+
}
|
30
|
+
return (AssetsLoader !== null && AssetsLoader !== void 0 ? AssetsLoader : _jsx("div", { children: "Assets loading..." }));
|
31
|
+
}, [AssetsLoader]);
|
26
32
|
return current.loadedAssets ? (_jsxs("div", __assign({ style: { width: width, height: height, position: "relative" } }, { children: [_jsx(Sketch, { width: width, height: height, onSetup: setup, onDraw: draw }), _jsx("div", __assign({ style: {
|
27
33
|
position: "absolute",
|
28
34
|
top: 0,
|
@@ -31,5 +37,5 @@ export function SceneRunner(_a) {
|
|
31
37
|
right: 0,
|
32
38
|
userSelect: "none",
|
33
39
|
zIndex: 2,
|
34
|
-
} }, { children: _jsx(current.UI, __assign({}, current.UIProps)) }))] }))) : (
|
40
|
+
} }, { children: _jsx(current.UI, __assign({}, current.UIProps)) }))] }))) : (assetsLoader);
|
35
41
|
}
|
@@ -1,10 +1,9 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { SceneManagement } from "../classes/scene-management";
|
3
|
-
|
3
|
+
import { SceneRunnerPublicProps } from "./SceneRunner";
|
4
|
+
declare type WorldViewProps = SceneRunnerPublicProps & {
|
4
5
|
list: ConstructorParameters<typeof SceneManagement>[0];
|
5
|
-
width: number;
|
6
|
-
height: number;
|
7
6
|
};
|
8
|
-
export declare function ScenesProcess({ list,
|
7
|
+
export declare function ScenesProcess({ list, ...props }: WorldViewProps): JSX.Element;
|
9
8
|
export {};
|
10
9
|
//# sourceMappingURL=ScenesProcess.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ScenesProcess.d.ts","sourceRoot":"","sources":["../../src/ui-components/ScenesProcess.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;
|
1
|
+
{"version":3,"file":"ScenesProcess.d.ts","sourceRoot":"","sources":["../../src/ui-components/ScenesProcess.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAe,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEpE,aAAK,cAAc,GAAG,sBAAsB,GAAG;IAC7C,IAAI,EAAE,qBAAqB,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CACxD,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,eA8B/D"}
|
@@ -1,9 +1,31 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
+
var t = {};
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
+
t[p] = s[p];
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
+
t[p[i]] = s[p[i]];
|
20
|
+
}
|
21
|
+
return t;
|
22
|
+
};
|
1
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
24
|
import { useEffect, useMemo, useState } from "react";
|
3
25
|
import { SceneManagement } from "../classes/scene-management";
|
4
26
|
import { SceneRunner } from "./SceneRunner";
|
5
27
|
export function ScenesProcess(_a) {
|
6
|
-
var list = _a.list,
|
28
|
+
var list = _a.list, props = __rest(_a, ["list"]);
|
7
29
|
var sceneManagement = useMemo(function () {
|
8
30
|
return new SceneManagement(list);
|
9
31
|
}, [list]);
|
@@ -20,5 +42,5 @@ export function ScenesProcess(_a) {
|
|
20
42
|
setLoadedAssets(isLoaded);
|
21
43
|
});
|
22
44
|
}, [currentScene]);
|
23
|
-
return (_jsx(SceneRunner, { current: currentScene
|
45
|
+
return (_jsx(SceneRunner, __assign({ current: currentScene }, props), currentScene.sessionId));
|
24
46
|
}
|