bg2e-js 2.3.5 → 2.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bg2e-js",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "description": "a graphics engine for productivity applications",
5
5
  "main": "./dist/bg2e-js.js",
6
6
  "types": "./src/index.ts",
@@ -31,21 +31,17 @@ export default function useBg2e<R extends Renderer, A extends AppController>(
31
31
  const mainLoopRef = useRef<MainLoop | null>(null);
32
32
  const createdRef = useRef(false);
33
33
 
34
- const [, forceUpdate] = useState(0);
35
-
36
34
  useEffect(() => {
37
35
  createdRef.current = false;
38
36
 
39
37
  if (!canvas) {
40
38
  mainLoopRef.current = null;
41
- forceUpdate((x) => x + 1);
42
39
  return;
43
40
  }
44
41
 
45
42
  const existing = mainLoopByCanvas.get(canvas);
46
43
  if (existing) {
47
44
  mainLoopRef.current = existing;
48
- forceUpdate((x) => x + 1);
49
45
  return;
50
46
  }
51
47
 
@@ -55,17 +51,15 @@ export default function useBg2e<R extends Renderer, A extends AppController>(
55
51
  const bg2Canvas = new Canvas(canvas, renderer);
56
52
  const mainLoop = new MainLoop(bg2Canvas, appController);
57
53
 
58
- mainLoop.run(); // Background execution
59
-
60
- mainLoopByCanvas.set(canvas, mainLoop);
61
- mainLoopRef.current = mainLoop;
62
- createdRef.current = true;
63
-
64
- forceUpdate((x) => x + 1);
65
-
66
- if (onLoad) {
67
- onLoad(bg2Canvas, mainLoop);
68
- }
54
+ mainLoop.run().then(() => {
55
+ mainLoopByCanvas.set(canvas, mainLoop);
56
+ mainLoopRef.current = mainLoop;
57
+ createdRef.current = true;
58
+
59
+ if (onLoad) {
60
+ onLoad(bg2Canvas, mainLoop);
61
+ }
62
+ })
69
63
  }, [canvas, RendererType, AppControllerType, onLoad]);
70
64
 
71
65
  return {