pixi-fusion 1.1.0 → 2.0.1

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/README.md CHANGED
@@ -14,14 +14,14 @@ npm i --save pixi-fusion
14
14
 
15
15
  # Basic Usage Example
16
16
 
17
- 1. Create a component with `GameContextProvider` and `World`.
17
+ 1. Create a component with `GameContextProvider` and `Stage`.
18
18
 
19
19
  ```
20
20
  <GameContextProvider timeout={10}>
21
21
  <World size={{width: 300, height: 300}} eventMode="dynamic">
22
- <layer>
22
+ <Layer>
23
23
  <MyAwesomeStage />
24
- </Layer>
24
+ </layer>
25
25
  </World>
26
26
  </GameContextProvider>
27
27
  ```
@@ -76,12 +76,6 @@ export const MyAwesomeStage: React.FC<MazeHeroProps> = () => {
76
76
  };
77
77
  ```
78
78
 
79
- # Demos
80
-
81
- - [Maze](https://laverve.github.io/fusion/?path=/story/games-maze-gameplay--maze-story)
82
- - [WordSearch](https://laverve.github.io/fusion/?path=/story/games-wordsearch-gameplay--word-search-story)
83
- - [Spelling spree](https://laverve.github.io/fusion/?path=/story/games-spelling-spree-gameplay--spelling-spree)
84
-
85
79
  # Contribution guidelines
86
80
 
87
81
  You are encouraged to contribute to this project as soon as you see any defects or issues.
@@ -96,7 +90,6 @@ This monorepo contains configuration for VSCode editor. It doesn't mean that you
96
90
  2. To build monorepo use: `npm run build`
97
91
  3. To lint monorepo use: `npm run lint`
98
92
  4. To initialize pre-commit hooks use: `npm run prepare`
99
- 5. To run storybook `npm run storybook`
100
93
 
101
94
  ## Workflow
102
95
 
@@ -12,7 +12,7 @@ export const GameContext = createContext({
12
12
  endTime: null
13
13
  });
14
14
  export const GameContextProvider = ({ children, timeout: inputTimeout = 0, events }) => {
15
- const timerRef = useRef();
15
+ const timerRef = useRef(null);
16
16
  const timeout = Math.max(0, inputTimeout);
17
17
  const [status, setStatus] = useState(GameStatus.READY);
18
18
  const [startTime, setStartTime] = useState(null);
@@ -80,7 +80,9 @@ export const GameContextProvider = ({ children, timeout: inputTimeout = 0, event
80
80
  const stop = () => {
81
81
  const newStatus = GameStatus.COMPLETED;
82
82
  const newEndTime = +new Date();
83
- clearTimeout(timerRef.current);
83
+ if (timerRef.current) {
84
+ clearTimeout(timerRef.current);
85
+ }
84
86
  setEndTime(+new Date());
85
87
  setStatus(GameStatus.COMPLETED);
86
88
  events?.onStop?.({
@@ -94,7 +96,9 @@ export const GameContextProvider = ({ children, timeout: inputTimeout = 0, event
94
96
  const pause = () => {
95
97
  const newStatus = GameStatus.PAUSED;
96
98
  const newPausedAtTime = +new Date();
97
- clearTimeout(timerRef.current);
99
+ if (timerRef.current) {
100
+ clearTimeout(timerRef.current);
101
+ }
98
102
  setStatus(GameStatus.PAUSED);
99
103
  setPausedAtTime(newPausedAtTime);
100
104
  events?.onPause?.({
@@ -1 +1 @@
1
- export declare const useCamera: () => import("../camera").CameraContextValue;
1
+ export declare const useCamera: () => import("..").CameraContextValue;
@@ -1 +1 @@
1
- export declare const useGame: () => import("../game-context").GameContextValue;
1
+ export declare const useGame: () => import("..").GameContextValue;
@@ -1,5 +1,5 @@
1
1
  import { useEffect } from "react";
2
- import { useWorld } from "../hooks";
2
+ import { useWorld } from ".";
3
3
  export const useTickerCallback = ({ isEnabled = true, callback }) => {
4
4
  const { application } = useWorld();
5
5
  useEffect(() => {
@@ -1 +1 @@
1
- export declare const useWorld: () => import("../world/World.context").WorldContextValue;
1
+ export declare const useWorld: () => import("..").WorldContextValue;
package/package.json CHANGED
@@ -5,13 +5,22 @@
5
5
  "url": "https://github.com/laverve/fusion/issues"
6
6
  },
7
7
  "dependencies": {
8
- "@types/matter-js": "^0.19.7",
8
+ "@types/matter-js": "^0.19.8",
9
9
  "matter-js": "^0.20.0",
10
- "pixi.js": "^8.5.1",
11
- "pixi-viewport": "^5.0.3"
10
+ "pixi.js": "^8.8.0",
11
+ "pixi-viewport": "^6.0.3"
12
12
  },
13
13
  "peerDependencies": {
14
- "react": "^18.2.0"
14
+ "react": "^19.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "@laverve/eslint-utils": "^5.1.11",
18
+ "@laverve/test-utils": "^5.1.11",
19
+ "@types/react": "^19.0.10",
20
+ "husky": "9.1.7",
21
+ "lint-staged": "^15.4.3",
22
+ "ts-node": "^10.9.1",
23
+ "typescript": "^5.7.3"
15
24
  },
16
25
  "description": "This module offers a set of common components needed for playing games.",
17
26
  "keywords": [
@@ -41,12 +50,14 @@
41
50
  "url": "https://github.com/laverve/fusion.git"
42
51
  },
43
52
  "scripts": {
44
- "lint": "eslint .",
53
+ "lint": "eslint ./src/",
54
+ "lint:fix": "eslint ./src/ --fix",
45
55
  "lint:staged": "lint-staged",
56
+ "prepare": "husky",
46
57
  "test": "jest --passWithNoTests",
47
58
  "build": "tsc",
48
59
  "build:dev": "tsc -w"
49
60
  },
50
- "version": "1.1.0",
61
+ "version": "2.0.1",
51
62
  "webpack": "./src/index.ts"
52
63
  }
@@ -43,7 +43,7 @@ export const GameContextProvider: React.FC<GameContextProviderProps> = ({
43
43
  timeout: inputTimeout = 0,
44
44
  events
45
45
  }) => {
46
- const timerRef = useRef<NodeJS.Timeout>();
46
+ const timerRef = useRef<NodeJS.Timeout>(null);
47
47
  const timeout = Math.max(0, inputTimeout);
48
48
 
49
49
  const [status, setStatus] = useState(GameStatus.READY);
@@ -125,7 +125,9 @@ export const GameContextProvider: React.FC<GameContextProviderProps> = ({
125
125
  const newStatus = GameStatus.COMPLETED;
126
126
  const newEndTime = +new Date();
127
127
 
128
- clearTimeout(timerRef.current);
128
+ if (timerRef.current) {
129
+ clearTimeout(timerRef.current);
130
+ }
129
131
  setEndTime(+new Date());
130
132
  setStatus(GameStatus.COMPLETED);
131
133
 
@@ -142,7 +144,9 @@ export const GameContextProvider: React.FC<GameContextProviderProps> = ({
142
144
  const newStatus = GameStatus.PAUSED;
143
145
  const newPausedAtTime = +new Date();
144
146
 
145
- clearTimeout(timerRef.current);
147
+ if (timerRef.current) {
148
+ clearTimeout(timerRef.current);
149
+ }
146
150
  setStatus(GameStatus.PAUSED);
147
151
  setPausedAtTime(newPausedAtTime);
148
152
 
@@ -1,7 +1,7 @@
1
1
  import { useEffect } from "react";
2
2
  import { TickerCallback } from "pixi.js";
3
3
 
4
- import { useWorld } from "../hooks";
4
+ import { useWorld } from ".";
5
5
 
6
6
  export const useTickerCallback = <T = unknown>({
7
7
  isEnabled = true,