react-simple-game-engine 0.2.94 → 0.2.96
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/classes/saver.d.ts +3 -1
- package/lib/classes/saver.d.ts.map +1 -1
- package/lib/classes/saver.js +7 -2
- package/lib/hooks/watcher.d.ts +3 -0
- package/lib/hooks/watcher.d.ts.map +1 -0
- package/lib/hooks/watcher.js +42 -0
- package/lib/ui-components/game-bootstrap.d.ts.map +1 -1
- package/lib/ui-components/game-bootstrap.js +1 -1
- package/lib/ui-components/scaler-container.d.ts.map +1 -1
- package/lib/ui-components/scaler-container.js +2 -11
- package/package.json +1 -1
package/lib/classes/saver.d.ts
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
declare type Typed = never | undefined | BooleanConstructor | StringConstructor | NumberConstructor;
|
1
|
+
declare type Typed = never | undefined | BooleanConstructor | StringConstructor | NumberConstructor | Record<string, any> | Record<string, any>[];
|
2
2
|
declare type ValueType<V extends any = undefined, T extends Typed = Typed> = V extends undefined ? T extends BooleanConstructor ? boolean : T extends StringConstructor ? string : T extends NumberConstructor ? number : V : V;
|
3
3
|
declare class _Saver {
|
4
|
+
static STORAGE_PREFIX: string;
|
4
5
|
private store;
|
5
6
|
constructor();
|
6
7
|
set<V extends any = any>(key: string, value: V): void;
|
7
8
|
get<V extends any = undefined, T extends Typed = Typed>(key: string, type?: T): ValueType<V, T>;
|
9
|
+
getWithDefault<V extends any = undefined, T extends Typed = Typed>(key: string, defaultValue: any, type?: T): ValueType<V, T>;
|
8
10
|
}
|
9
11
|
export declare const Saver: _Saver;
|
10
12
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"saver.d.ts","sourceRoot":"","sources":["../../src/classes/saver.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,GACN,KAAK,GACL,SAAS,GACT,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"saver.d.ts","sourceRoot":"","sources":["../../src/classes/saver.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK,GACN,KAAK,GACL,SAAS,GACT,kBAAkB,GAClB,iBAAiB,GACjB,iBAAiB,GACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;AAE1B,aAAK,SAAS,CACZ,CAAC,SAAS,GAAG,GAAG,SAAS,EACzB,CAAC,SAAS,KAAK,GAAG,KAAK,IACrB,CAAC,SAAS,SAAS,GACnB,CAAC,SAAS,kBAAkB,GAC1B,OAAO,GACP,CAAC,SAAS,iBAAiB,GAC3B,MAAM,GACN,CAAC,SAAS,iBAAiB,GAC3B,MAAM,GACN,CAAC,GACH,CAAC,CAAC;AAEN,cAAM,MAAM;IACV,MAAM,CAAC,cAAc,SAAY;IACjC,OAAO,CAAC,KAAK,CAAuB;;IAQpC,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAIrD,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,SAAS,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,EACpD,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,CAAC,GACP,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IA0BlB,cAAc,CAAC,CAAC,SAAS,GAAG,GAAG,SAAS,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,EAC/D,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,GAAG,EACjB,IAAI,CAAC,EAAE,CAAC,GACP,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;CAKnB;AAED,eAAO,MAAM,KAAK,QAAe,CAAC"}
|
package/lib/classes/saver.js
CHANGED
@@ -6,10 +6,10 @@ var _Saver = /** @class */ (function () {
|
|
6
6
|
: console.log("Initial saver fail");
|
7
7
|
}
|
8
8
|
_Saver.prototype.set = function (key, value) {
|
9
|
-
this.store.setItem(key, JSON.stringify(value));
|
9
|
+
this.store.setItem("".concat(_Saver.STORAGE_PREFIX).concat(key), JSON.stringify(value));
|
10
10
|
};
|
11
11
|
_Saver.prototype.get = function (key, type) {
|
12
|
-
var raw = this.store.getItem(key);
|
12
|
+
var raw = this.store.getItem("".concat(_Saver.STORAGE_PREFIX).concat(key));
|
13
13
|
var parsed = (raw == null ? raw : JSON.parse(raw));
|
14
14
|
if (type === Boolean) {
|
15
15
|
if (raw == null) {
|
@@ -31,6 +31,11 @@ var _Saver = /** @class */ (function () {
|
|
31
31
|
}
|
32
32
|
return parsed;
|
33
33
|
};
|
34
|
+
_Saver.prototype.getWithDefault = function (key, defaultValue, type) {
|
35
|
+
var value = this.get(key, type);
|
36
|
+
return value === undefined ? defaultValue : value;
|
37
|
+
};
|
38
|
+
_Saver.STORAGE_PREFIX = "rsgn::";
|
34
39
|
return _Saver;
|
35
40
|
}());
|
36
41
|
export var Saver = new _Saver();
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/hooks/watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,wBAAgB,UAAU,CACxB,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpD,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,aAAa,EAAE,EAAE,MAqBzD"}
|
@@ -0,0 +1,42 @@
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
14
|
+
if (ar || !(i in from)) {
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
16
|
+
ar[i] = from[i];
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
20
|
+
};
|
21
|
+
import { useEffect, useState } from "react";
|
22
|
+
export function useWatcher(scene, name, initialValues) {
|
23
|
+
var names = Array.isArray(name) ? name : [name];
|
24
|
+
var _a = useState(initialValues), values = _a[0], setValues = _a[1];
|
25
|
+
useEffect(function () {
|
26
|
+
var unsubs = names.map(function (name) {
|
27
|
+
return scene.onEntityPropsChange(name, function (value) {
|
28
|
+
setValues(function (prev) {
|
29
|
+
var _a;
|
30
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[name] = value, _a)));
|
31
|
+
});
|
32
|
+
});
|
33
|
+
});
|
34
|
+
return function () {
|
35
|
+
for (var _i = 0, unsubs_1 = unsubs; _i < unsubs_1.length; _i++) {
|
36
|
+
var unsub = unsubs_1[_i];
|
37
|
+
unsub();
|
38
|
+
}
|
39
|
+
};
|
40
|
+
}, __spreadArray(__spreadArray([], names, true), [scene], false));
|
41
|
+
return values;
|
42
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"game-bootstrap.d.ts","sourceRoot":"","sources":["../../src/ui-components/game-bootstrap.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAmB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG1E,OAAO,EAAe,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAErE,aAAK,cAAc,GAAG,sBAAsB,GAAG;IAC7C,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,
|
1
|
+
{"version":3,"file":"game-bootstrap.d.ts","sourceRoot":"","sources":["../../src/ui-components/game-bootstrap.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAmB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG1E,OAAO,EAAe,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAErE,aAAK,cAAc,GAAG,sBAAsB,GAAG;IAC7C,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,eAqM3E"}
|
@@ -55,7 +55,7 @@ export function GameBootstrap(_a) {
|
|
55
55
|
document.head.appendChild(style);
|
56
56
|
var gameRootClass = getClassname("game-root");
|
57
57
|
var gameLoggerClass = getClassname("game-logger");
|
58
|
-
style.appendChild(document.createTextNode("\n .".concat(getClassname("assets-fail-view"), "{\n background-color: #f28181a1;\n min-height: 100px;\n padding: 10px;\n color: #000;\n }\n \n .").concat(getClassname("game-modal"), " {\n position: fixed;\n top: 0;\n left: 0;\n }\n\n .").concat(getClassname("scene-modal-stack"), "{\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n z-index: 2;\n }\n \n .").concat(getClassname("modal-content-main"), "{\n position: relative;\n z-index: 1;\n min-width: 200px;\n min-height: 200px;\n }\n\n .").concat(getClassname("modal-content-closer"), "{\n width: 100%;\n height: 100%;\n position: absolute;\n z-index: 0;\n }\n .").concat(getClassname("modal-content-centered"), "{\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .").concat(getClassname("modal-content-wrap"), "{\n width: 100%;\n height: 100%;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .").concat(gameRootClass, ", .").concat(gameRootClass, " *,\n .").concat(gameLoggerClass, ", .").concat(gameLoggerClass, " *\n {\n box-sizing: border-box;\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n text-size-adjust: none;\n }\n\n .").concat(gameRootClass, " {\n overflow: hidden;\n position: relative;\n }\n\n .").concat(gameLoggerClass, " {\n z-index: 4;\n position: fixed;\n top:0;\n right:0;\n }\n\n .").concat(getClassname("message-stack"), " {\n width: cacl(100vw - 40px);\n max-width: 300px;\n max-height: calc(50vh - 50px);\n min-width: 200px;\n min-height: 150px;\n position: absolute;\n top: 5px;\n right: 5px;\n padding: 5px;\n background-color: #0000007b;\n color: #fff;\n font-size: 0.8rem;\n\n display: flex;\n flex-direction: column;\n }\n\n .").concat(getClassname("message-stack-heading"), "{\n width: 100%;\n display: flex;\n justify-content: flex-end;\n }\n\n .").concat(getClassname("message-stack-content"), "{\n flex: 1;\n width: 100%;\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n\n .").concat(getClassname("float-container"), " {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .").concat(getClassname("float-container"), " > div {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .").concat(getClassname("ui-control"), " {\n position: absolute;\n display: inline-flex;\n }\n ")));
|
58
|
+
style.appendChild(document.createTextNode("\n .".concat(getClassname("assets-fail-view"), "{\n background-color: #f28181a1;\n min-height: 100px;\n padding: 10px;\n color: #000;\n }\n \n .").concat(getClassname("game-modal"), " {\n position: fixed;\n top: 0;\n left: 0;\n }\n\n .").concat(getClassname("scene-modal-stack"), "{\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n z-index: 2;\n }\n \n .").concat(getClassname("modal-content-main"), "{\n position: relative;\n z-index: 1;\n min-width: 200px;\n min-height: 200px;\n }\n\n .").concat(getClassname("modal-content-closer"), "{\n width: 100%;\n height: 100%;\n position: absolute;\n z-index: 0;\n }\n .").concat(getClassname("modal-content-centered"), "{\n width: 100%;\n height: 100%;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .").concat(getClassname("modal-content-wrap"), "{\n width: 100%;\n height: 100%;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .").concat(gameRootClass, ", .").concat(gameRootClass, " *,\n .").concat(gameLoggerClass, ", .").concat(gameLoggerClass, " *\n {\n box-sizing: border-box;\n -webkit-touch-callout: none;\n -webkit-tap-highlight-color: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n text-size-adjust: none;\n }\n\n .").concat(gameRootClass, " {\n overflow: hidden;\n position: relative;\n }\n\n .").concat(gameLoggerClass, " {\n z-index: 4;\n position: fixed;\n top:0;\n right:0;\n }\n\n .").concat(getClassname("message-stack"), " {\n width: cacl(100vw - 40px);\n max-width: 300px;\n max-height: calc(50vh - 50px);\n min-width: 200px;\n min-height: 150px;\n position: absolute;\n top: 5px;\n right: 5px;\n padding: 5px;\n background-color: #0000007b;\n color: #fff;\n font-size: 0.8rem;\n\n display: flex;\n flex-direction: column;\n }\n\n .").concat(getClassname("message-stack-heading"), "{\n width: 100%;\n display: flex;\n justify-content: flex-end;\n }\n\n .").concat(getClassname("message-stack-content"), "{\n flex: 1;\n width: 100%;\n overflow-x: hidden;\n overflow-y: auto;\n }\n\n\n .").concat(getClassname("float-container"), " {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .").concat(getClassname("float-container"), " > div {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .").concat(getClassname("ui-control"), " {\n position: absolute;\n display: inline-flex;\n }\n\n .").concat(getClassname("scaler-container"), " {\n width: 100%;\n height: 100%;\n position: relative;\n top: 0;\n left: 0;\n }\n\n .").concat(getClassname("scaler-container"), " > div {\n transform-origin: left top;\n position: relative;\n top: 50%;\n left: 50%;\n }\n ")));
|
59
59
|
}, []);
|
60
60
|
return (_jsxs(_Fragment, { children: [_jsx(SceneRunner, __assign({ current: currentScene }, props), currentScene.sessionId), logPopup && _jsx(Logger, {})] }));
|
61
61
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"scaler-container.d.ts","sourceRoot":"","sources":["../../src/ui-components/scaler-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"scaler-container.d.ts","sourceRoot":"","sources":["../../src/ui-components/scaler-container.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,aAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,MAAM,EACN,KAAK,EACL,QAAQ,GACT,EAAE,oBAAoB,eActB"}
|
@@ -10,21 +10,12 @@ var __assign = (this && this.__assign) || function () {
|
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
+
import { getClassname } from "../utils";
|
13
14
|
export function ScalerContainer(_a) {
|
14
15
|
var width = _a.width, height = _a.height, value = _a.value, children = _a.children;
|
15
|
-
return (_jsx("div", __assign({ style: {
|
16
|
-
width: "100%",
|
17
|
-
height: "100%",
|
18
|
-
position: "relative",
|
19
|
-
top: 0,
|
20
|
-
left: 0,
|
21
|
-
} }, { children: _jsx("div", __assign({ style: {
|
16
|
+
return (_jsx("div", __assign({ className: getClassname("scaler-container") }, { children: _jsx("div", __assign({ style: {
|
22
17
|
width: width,
|
23
18
|
height: height,
|
24
19
|
transform: "scale(".concat(value, ") translate(-50%, -50%)"),
|
25
|
-
transformOrigin: "left top",
|
26
|
-
position: "relative",
|
27
|
-
top: "50%",
|
28
|
-
left: "50%",
|
29
20
|
} }, { children: children })) })));
|
30
21
|
}
|