react-simple-game-engine 0.1.39 → 0.1.40

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.
@@ -2,10 +2,10 @@ import { ReactNode } from "react";
2
2
  import { Scene } from "./scene";
3
3
  declare type WatcherProps<IV> = {
4
4
  scene: Scene;
5
- names: string[];
6
- initialValues?: IV;
5
+ names: string | string[];
6
+ initialValues: IV;
7
7
  children: (value: Record<string, any>) => ReactNode;
8
8
  };
9
- export declare function Watcher<IV extends Record<string, any> = Record<string, any>>({ scene, names, children, initialValues, }: WatcherProps<IV>): ReactNode;
9
+ export declare function Watcher<IV extends Record<string, any> = Record<string, any>>({ scene, names: _names, children, initialValues, }: WatcherProps<IV>): JSX.Element;
10
10
  export {};
11
11
  //# sourceMappingURL=watcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/classes/watcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,YAAY,CAAC,EAAE,IAAI;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,SAAS,CAAC;CACrD,CAAC;AACF,wBAAgB,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC5E,KAAK,EACL,KAAK,EACL,QAAQ,EACR,aAAa,GACd,EAAE,YAAY,CAAC,EAAE,CAAC,aAmBlB"}
1
+ {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/classes/watcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,YAAY,CAAC,EAAE,IAAI;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,EAAE,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,SAAS,CAAC;CACrD,CAAC;AACF,wBAAgB,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC5E,KAAK,EACL,KAAK,EAAE,MAAM,EACb,QAAQ,EACR,aAAa,GACd,EAAE,YAAY,CAAC,EAAE,CAAC,eAqBlB"}
@@ -18,10 +18,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
18
  }
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
21
22
  import { useEffect, useState } from "react";
22
23
  export function Watcher(_a) {
23
- var scene = _a.scene, names = _a.names, children = _a.children, initialValues = _a.initialValues;
24
- var _b = useState(initialValues || {}), values = _b[0], setValues = _b[1];
24
+ var scene = _a.scene, _names = _a.names, children = _a.children, initialValues = _a.initialValues;
25
+ var names = Array.isArray(_names) ? _names : [_names];
26
+ var _b = useState(initialValues), values = _b[0], setValues = _b[1];
25
27
  useEffect(function () {
26
28
  var unsubs = names.map(function (name) {
27
29
  return scene.onEntityPropsChangeListener(name, function (value) {
@@ -38,5 +40,5 @@ export function Watcher(_a) {
38
40
  }
39
41
  };
40
42
  }, __spreadArray(__spreadArray([], names, true), [scene], false));
41
- return children(values);
43
+ return _jsx(_Fragment, { children: children(values) });
42
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",