woofjs-engine 0.2.0 → 0.3.0
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/CHANGELOG.md +13 -0
- package/README.md +16 -106
- package/THIRD_PARTY_NOTICES.md +7 -0
- package/dist/canvas.js +4 -31
- package/dist/collision.js +8 -5
- package/dist/game.js +4 -84
- package/dist/index-1jykaz1m.js +142 -0
- package/dist/index-9mz0qg9d.js +39 -0
- package/dist/index-b9a70qgn.js +34 -0
- package/dist/index-dp75gf4w.js +57 -0
- package/dist/index-f63yb8zf.js +85 -0
- package/dist/index-gypg8d50.js +31 -0
- package/dist/index-pw0zq53c.js +2533 -0
- package/dist/index.js +134 -239
- package/dist/input.js +4 -33
- package/dist/play.js +296 -0
- package/dist/sound.js +4 -56
- package/dist/store.js +4 -30
- package/dist/types/canvas.d.ts +20 -2
- package/dist/types/collision.d.ts +62 -0
- package/dist/types/game.d.ts +21 -1
- package/dist/types/global.d.ts +4 -0
- package/dist/types/helpers.d.ts +92 -0
- package/dist/types/index.d.ts +23 -12
- package/dist/types/input.d.ts +4 -0
- package/dist/types/play.d.ts +159 -0
- package/dist/types/sound.d.ts +10 -3
- package/dist/types/sprites/custom.d.ts +9 -0
- package/dist/types/sprites/easing.d.ts +9 -0
- package/dist/types/sprites/geometry.d.ts +22 -0
- package/dist/types/sprites/options.d.ts +98 -0
- package/dist/types/sprites/render.d.ts +2 -0
- package/dist/types/sprites/sprite.d.ts +283 -0
- package/dist/types/store.d.ts +4 -0
- package/dist/types/ui.d.ts +65 -0
- package/dist/types/woof.d.ts +386 -0
- package/dist/types/world/audio.d.ts +118 -0
- package/dist/types/world/globals.d.ts +3 -0
- package/dist/types/world/keys.d.ts +2 -0
- package/dist/types/world/options.d.ts +44 -0
- package/dist/types/world/render.d.ts +13 -0
- package/dist/types/world/scheduler.d.ts +65 -0
- package/dist/ui.js +235 -0
- package/dist/woof.global.js +3577 -0
- package/docs/api.json +5359 -0
- package/docs/woof-parity.md +231 -0
- package/package.json +25 -8
- package/docs/architecture.md +0 -37
- package/docs/planning.md +0 -33
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/store.ts
|
|
2
|
+
function createStore2(initialState = {}) {
|
|
3
|
+
let state = initialState;
|
|
4
|
+
const listeners = new Set;
|
|
5
|
+
function setState(nextState) {
|
|
6
|
+
const next = typeof nextState === "function" ? nextState(state) : nextState;
|
|
7
|
+
if (Object.is(next, state))
|
|
8
|
+
return state;
|
|
9
|
+
state = next;
|
|
10
|
+
for (const listener of [...listeners])
|
|
11
|
+
listener(state);
|
|
12
|
+
return state;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
getState: () => state,
|
|
16
|
+
setState,
|
|
17
|
+
update(mutator) {
|
|
18
|
+
if (typeof mutator !== "function")
|
|
19
|
+
throw new TypeError("mutator must be a function");
|
|
20
|
+
return setState(mutator(state));
|
|
21
|
+
},
|
|
22
|
+
subscribe(listener) {
|
|
23
|
+
if (typeof listener !== "function")
|
|
24
|
+
throw new TypeError("listener must be a function");
|
|
25
|
+
listeners.add(listener);
|
|
26
|
+
return () => listeners.delete(listener);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { createStore2 };
|