woofjs-engine 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +105 -2
- package/dist/canvas.js +33 -0
- package/dist/game.js +73 -0
- package/dist/index.js +190 -0
- package/dist/sound.js +58 -0
- package/dist/store.js +32 -0
- package/dist/types/canvas.d.ts +16 -0
- package/dist/types/game.d.ts +24 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/sound.d.ts +21 -0
- package/dist/types/store.d.ts +8 -0
- package/docs/architecture.md +37 -0
- package/docs/planning.md +32 -0
- package/examples/browser-sound.js +15 -0
- package/examples/multiple-canvases.js +21 -0
- package/examples/node-basic.mjs +16 -0
- package/examples/svelte/Game.svelte +43 -0
- package/package.json +62 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RatRad Works
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# woofjs-engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A small JavaScript engine for the parts of a game loop that are easy to get subtly wrong: advancing state by elapsed time, rendering the current state, and controlling sound playback.
|
|
4
|
+
|
|
5
|
+
The project takes inspiration from the approachable, component-oriented style of [WoofJS](https://github.com/stevekrouse/WoofJS) and [woofjs.com](https://woofjs.com/). This is an independent implementation; it does not claim upstream compatibility. The engine stays framework-neutral. You provide your game state and callbacks; a Node program, a browser page, or a Svelte component can decide when and where to run them.
|
|
6
|
+
|
|
7
|
+
[Documentation site](https://woofjs-engine-c23a47.gitlab.io/) · [Source and examples](https://gitlab.com/ratradworke/woofjs-engine)
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
Install the package in your JavaScript or TypeScript project:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install woofjs-engine
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The library is implemented in TypeScript and builds browser-ready ES modules plus `.d.ts` declarations with Bun. JavaScript consumers can import the package normally; TypeScript consumers receive typed APIs from the same entry points. Import the helpers:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { createGame, createSound, createStore, createCanvas } from 'woofjs-engine';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`createGame` takes an initial state plus an `update` callback and a `render` callback. The update callback receives elapsed time in **seconds**, so movement can be expressed in units per second rather than units per frame.
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { createGame } from 'woofjs-engine';
|
|
27
|
+
|
|
28
|
+
const game = createGame({
|
|
29
|
+
state: { x: 0 },
|
|
30
|
+
update(deltaSeconds, state) {
|
|
31
|
+
state.x += 120 * deltaSeconds;
|
|
32
|
+
},
|
|
33
|
+
render(state) {
|
|
34
|
+
console.log(`Player position: ${state.x.toFixed(1)}`);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// step() is useful for deterministic updates, tests, and non-browser hosts.
|
|
39
|
+
game.step(1000 / 60); // delta is supplied in milliseconds
|
|
40
|
+
console.log(game.getState());
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For an animation loop, provide the host's frame scheduling functions and call `start()`:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const game = createGame({
|
|
47
|
+
state: { x: 0 },
|
|
48
|
+
update(deltaSeconds, state) {
|
|
49
|
+
state.x += 120 * deltaSeconds;
|
|
50
|
+
},
|
|
51
|
+
render(state) {
|
|
52
|
+
drawPlayer(state.x);
|
|
53
|
+
},
|
|
54
|
+
requestFrame: callback => requestAnimationFrame(callback),
|
|
55
|
+
cancelFrame: id => cancelAnimationFrame(id),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
game.start();
|
|
59
|
+
// Later, for example when leaving the screen:
|
|
60
|
+
game.stop();
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`step(deltaMs)` advances one frame explicitly. `start()` schedules repeated frames; `stop()` cancels them. `getState()` returns the current state. See [the architecture notes](docs/architecture.md) for lifecycle and timing details, and the [examples](examples/) for Node and Svelte usage.
|
|
64
|
+
|
|
65
|
+
## Shared state and canvases
|
|
66
|
+
|
|
67
|
+
`createStore` lets multiple views share state and subscribe to changes. `createCanvas` creates an independent canvas surface, so a host can attach more than one canvas and draw each from the same store.
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const store = createStore({ score: 0 });
|
|
71
|
+
const unsubscribe = store.subscribe(state => console.log('score:', state.score));
|
|
72
|
+
store.update(state => ({ ...state, score: state.score + 1 }));
|
|
73
|
+
|
|
74
|
+
const surface = createCanvas({ parent: document.querySelector('#game'), width: 640, height: 360 });
|
|
75
|
+
// Draw through surface.context; call surface.destroy() when it is no longer needed.
|
|
76
|
+
// Call unsubscribe() when the subscriber is removed.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
See [examples/multiple-canvases.js](examples/multiple-canvases.js) for two canvases observing one store.
|
|
80
|
+
|
|
81
|
+
## Sound
|
|
82
|
+
|
|
83
|
+
Sound uses the Web Audio API supplied by the host. The engine does not fetch or decode audio files for you: pass a decoded `AudioBuffer` and an `AudioContext`.
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const sound = createSound(decodedBuffer, audioContext, {
|
|
87
|
+
volume: 0.7,
|
|
88
|
+
maxGain: 4,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const playback = sound.startPlaying();
|
|
92
|
+
playback.amplify(1.5); // clamps to the configured range [0, maxGain]
|
|
93
|
+
// playback.amplify('max') selects maxGain; playback.stop() ends playback.
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Numeric amplification multiplies the playback's initial `volume` before clamping to `maxGain` (for example, `volume: 0.7` and `amplify(4)` gives gain `2.8` when `maxGain` is at least `2.8`). This software gain cap does not guarantee protection from clipping, loud speakers, or hearing damage; keep application and device volume appropriate.
|
|
97
|
+
|
|
98
|
+
Browsers generally require audio to begin in response to a user gesture. See [examples/browser-sound.js](examples/browser-sound.js).
|
|
99
|
+
|
|
100
|
+
## Development
|
|
101
|
+
|
|
102
|
+
Run `npm ci`, `npm run build`, and `npm test` from the repository root. Bun builds the JS bundles; TypeScript emits declarations. Tests import the compiled JS from `dist/`.
|
|
103
|
+
|
|
104
|
+
## Current scope and direction
|
|
105
|
+
|
|
106
|
+
The current API is intentionally compact: deterministic stepping, a start/stop loop, shared state, canvas surfaces, and sound playback controls. The [architecture](docs/architecture.md) and [planning](docs/planning.md) documents describe the design boundaries and possible next steps without promising a release schedule. Richer UI component mappings and optional compilation remain ideas for future exploration, not capabilities promised by the current API.
|
package/dist/canvas.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/canvas.ts
|
|
2
|
+
function createCanvas({ document: doc = globalThis.document, parent, width = 300, height = 150, context = "2d", contextOptions } = {}) {
|
|
3
|
+
if (!doc || typeof doc.createElement !== "function")
|
|
4
|
+
throw new Error("A browser document is required; pass document explicitly");
|
|
5
|
+
const element = doc.createElement("canvas");
|
|
6
|
+
element.width = width;
|
|
7
|
+
element.height = height;
|
|
8
|
+
const drawingContext = element.getContext(context, contextOptions);
|
|
9
|
+
if (!drawingContext)
|
|
10
|
+
throw new Error(`Unable to create ${context} canvas context`);
|
|
11
|
+
parent?.appendChild(element);
|
|
12
|
+
let removed = false;
|
|
13
|
+
return {
|
|
14
|
+
element,
|
|
15
|
+
context: drawingContext,
|
|
16
|
+
resize(nextWidth, nextHeight) {
|
|
17
|
+
if (removed)
|
|
18
|
+
throw new Error("Cannot resize a removed canvas");
|
|
19
|
+
element.width = nextWidth;
|
|
20
|
+
element.height = nextHeight;
|
|
21
|
+
return this;
|
|
22
|
+
},
|
|
23
|
+
destroy() {
|
|
24
|
+
if (!removed) {
|
|
25
|
+
removed = true;
|
|
26
|
+
element.remove();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
createCanvas
|
|
33
|
+
};
|
package/dist/game.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/game.ts
|
|
2
|
+
function createGame({
|
|
3
|
+
state = {},
|
|
4
|
+
update = () => {},
|
|
5
|
+
render = () => {},
|
|
6
|
+
requestFrame,
|
|
7
|
+
cancelFrame
|
|
8
|
+
} = {}) {
|
|
9
|
+
let running = false;
|
|
10
|
+
let frameId = null;
|
|
11
|
+
let previousTime = null;
|
|
12
|
+
let frame = 0;
|
|
13
|
+
let currentState = state;
|
|
14
|
+
function step(deltaMs, timestamp = 0) {
|
|
15
|
+
if (!Number.isFinite(deltaMs) || deltaMs < 0)
|
|
16
|
+
throw new RangeError("deltaMs must be a finite, non-negative number");
|
|
17
|
+
const deltaSeconds = deltaMs / 1000;
|
|
18
|
+
const info = { deltaMs, timestamp, frame };
|
|
19
|
+
update(deltaSeconds, currentState, info);
|
|
20
|
+
render(currentState, { ...info, deltaSeconds });
|
|
21
|
+
frame += 1;
|
|
22
|
+
return currentState;
|
|
23
|
+
}
|
|
24
|
+
function getRequestFrame() {
|
|
25
|
+
const fn = requestFrame ?? globalThis.requestAnimationFrame;
|
|
26
|
+
if (typeof fn !== "function")
|
|
27
|
+
throw new Error("requestAnimationFrame is unavailable; provide requestFrame");
|
|
28
|
+
return fn;
|
|
29
|
+
}
|
|
30
|
+
function tick(timestamp) {
|
|
31
|
+
if (!running)
|
|
32
|
+
return;
|
|
33
|
+
const delta = previousTime === null ? 0 : Math.max(0, timestamp - previousTime);
|
|
34
|
+
previousTime = timestamp;
|
|
35
|
+
step(delta, timestamp);
|
|
36
|
+
if (running)
|
|
37
|
+
frameId = getRequestFrame()(tick);
|
|
38
|
+
}
|
|
39
|
+
const loop = {
|
|
40
|
+
step,
|
|
41
|
+
getState: () => currentState,
|
|
42
|
+
setState(nextState) {
|
|
43
|
+
currentState = nextState;
|
|
44
|
+
return currentState;
|
|
45
|
+
},
|
|
46
|
+
start() {
|
|
47
|
+
if (running)
|
|
48
|
+
return this;
|
|
49
|
+
running = true;
|
|
50
|
+
previousTime = null;
|
|
51
|
+
frameId = getRequestFrame()(tick);
|
|
52
|
+
return this;
|
|
53
|
+
},
|
|
54
|
+
stop() {
|
|
55
|
+
if (!running)
|
|
56
|
+
return this;
|
|
57
|
+
running = false;
|
|
58
|
+
const cancel = cancelFrame ?? globalThis.cancelAnimationFrame;
|
|
59
|
+
if (frameId !== null && typeof cancel === "function")
|
|
60
|
+
cancel(frameId);
|
|
61
|
+
frameId = null;
|
|
62
|
+
previousTime = null;
|
|
63
|
+
return this;
|
|
64
|
+
},
|
|
65
|
+
get running() {
|
|
66
|
+
return running;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return loop;
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
createGame
|
|
73
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// src/game.ts
|
|
2
|
+
function createGame({
|
|
3
|
+
state = {},
|
|
4
|
+
update = () => {},
|
|
5
|
+
render = () => {},
|
|
6
|
+
requestFrame,
|
|
7
|
+
cancelFrame
|
|
8
|
+
} = {}) {
|
|
9
|
+
let running = false;
|
|
10
|
+
let frameId = null;
|
|
11
|
+
let previousTime = null;
|
|
12
|
+
let frame = 0;
|
|
13
|
+
let currentState = state;
|
|
14
|
+
function step(deltaMs, timestamp = 0) {
|
|
15
|
+
if (!Number.isFinite(deltaMs) || deltaMs < 0)
|
|
16
|
+
throw new RangeError("deltaMs must be a finite, non-negative number");
|
|
17
|
+
const deltaSeconds = deltaMs / 1000;
|
|
18
|
+
const info = { deltaMs, timestamp, frame };
|
|
19
|
+
update(deltaSeconds, currentState, info);
|
|
20
|
+
render(currentState, { ...info, deltaSeconds });
|
|
21
|
+
frame += 1;
|
|
22
|
+
return currentState;
|
|
23
|
+
}
|
|
24
|
+
function getRequestFrame() {
|
|
25
|
+
const fn = requestFrame ?? globalThis.requestAnimationFrame;
|
|
26
|
+
if (typeof fn !== "function")
|
|
27
|
+
throw new Error("requestAnimationFrame is unavailable; provide requestFrame");
|
|
28
|
+
return fn;
|
|
29
|
+
}
|
|
30
|
+
function tick(timestamp) {
|
|
31
|
+
if (!running)
|
|
32
|
+
return;
|
|
33
|
+
const delta = previousTime === null ? 0 : Math.max(0, timestamp - previousTime);
|
|
34
|
+
previousTime = timestamp;
|
|
35
|
+
step(delta, timestamp);
|
|
36
|
+
if (running)
|
|
37
|
+
frameId = getRequestFrame()(tick);
|
|
38
|
+
}
|
|
39
|
+
const loop = {
|
|
40
|
+
step,
|
|
41
|
+
getState: () => currentState,
|
|
42
|
+
setState(nextState) {
|
|
43
|
+
currentState = nextState;
|
|
44
|
+
return currentState;
|
|
45
|
+
},
|
|
46
|
+
start() {
|
|
47
|
+
if (running)
|
|
48
|
+
return this;
|
|
49
|
+
running = true;
|
|
50
|
+
previousTime = null;
|
|
51
|
+
frameId = getRequestFrame()(tick);
|
|
52
|
+
return this;
|
|
53
|
+
},
|
|
54
|
+
stop() {
|
|
55
|
+
if (!running)
|
|
56
|
+
return this;
|
|
57
|
+
running = false;
|
|
58
|
+
const cancel = cancelFrame ?? globalThis.cancelAnimationFrame;
|
|
59
|
+
if (frameId !== null && typeof cancel === "function")
|
|
60
|
+
cancel(frameId);
|
|
61
|
+
frameId = null;
|
|
62
|
+
previousTime = null;
|
|
63
|
+
return this;
|
|
64
|
+
},
|
|
65
|
+
get running() {
|
|
66
|
+
return running;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return loop;
|
|
70
|
+
}
|
|
71
|
+
// src/sound.ts
|
|
72
|
+
function createSound(buffer, audioContext, { volume = 1, maxGain = 4 } = {}) {
|
|
73
|
+
if (!buffer)
|
|
74
|
+
throw new TypeError("buffer is required");
|
|
75
|
+
if (!audioContext || typeof audioContext.createBufferSource !== "function" || typeof audioContext.createGain !== "function") {
|
|
76
|
+
throw new TypeError("audioContext must provide createBufferSource() and createGain()");
|
|
77
|
+
}
|
|
78
|
+
if (!Number.isFinite(maxGain) || maxGain < 0)
|
|
79
|
+
throw new RangeError("maxGain must be a finite, non-negative number");
|
|
80
|
+
if (!Number.isFinite(volume) || volume < 0)
|
|
81
|
+
throw new RangeError("volume must be a finite, non-negative number");
|
|
82
|
+
return {
|
|
83
|
+
startPlaying({ loop = false, playbackRate = 1 } = {}) {
|
|
84
|
+
const source = audioContext.createBufferSource();
|
|
85
|
+
const gainNode = audioContext.createGain();
|
|
86
|
+
source.buffer = buffer;
|
|
87
|
+
source.loop = Boolean(loop);
|
|
88
|
+
if (source.playbackRate)
|
|
89
|
+
source.playbackRate.value = playbackRate;
|
|
90
|
+
const baseGain = clamp(volume, maxGain);
|
|
91
|
+
gainNode.gain.value = baseGain;
|
|
92
|
+
source.connect(gainNode);
|
|
93
|
+
gainNode.connect(audioContext.destination);
|
|
94
|
+
source.start();
|
|
95
|
+
let stopped = false;
|
|
96
|
+
return {
|
|
97
|
+
source,
|
|
98
|
+
amplify(multiplier) {
|
|
99
|
+
if (stopped)
|
|
100
|
+
return this;
|
|
101
|
+
if (multiplier === "max")
|
|
102
|
+
gainNode.gain.value = maxGain;
|
|
103
|
+
else if (typeof multiplier === "number" && Number.isFinite(multiplier)) {
|
|
104
|
+
gainNode.gain.value = clamp(baseGain * multiplier, maxGain);
|
|
105
|
+
} else
|
|
106
|
+
throw new TypeError("amplify expects a finite multiplier or 'max'");
|
|
107
|
+
return this;
|
|
108
|
+
},
|
|
109
|
+
stop() {
|
|
110
|
+
if (!stopped) {
|
|
111
|
+
stopped = true;
|
|
112
|
+
source.stop();
|
|
113
|
+
}
|
|
114
|
+
return this;
|
|
115
|
+
},
|
|
116
|
+
get stopped() {
|
|
117
|
+
return stopped;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function clamp(value, maximum) {
|
|
124
|
+
return Math.min(maximum, Math.max(0, value));
|
|
125
|
+
}
|
|
126
|
+
// src/store.ts
|
|
127
|
+
function createStore(initialState = {}) {
|
|
128
|
+
let state = initialState;
|
|
129
|
+
const listeners = new Set;
|
|
130
|
+
function setState(nextState) {
|
|
131
|
+
const next = typeof nextState === "function" ? nextState(state) : nextState;
|
|
132
|
+
if (Object.is(next, state))
|
|
133
|
+
return state;
|
|
134
|
+
state = next;
|
|
135
|
+
for (const listener of [...listeners])
|
|
136
|
+
listener(state);
|
|
137
|
+
return state;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
getState: () => state,
|
|
141
|
+
setState,
|
|
142
|
+
update(mutator) {
|
|
143
|
+
if (typeof mutator !== "function")
|
|
144
|
+
throw new TypeError("mutator must be a function");
|
|
145
|
+
return setState(mutator(state));
|
|
146
|
+
},
|
|
147
|
+
subscribe(listener) {
|
|
148
|
+
if (typeof listener !== "function")
|
|
149
|
+
throw new TypeError("listener must be a function");
|
|
150
|
+
listeners.add(listener);
|
|
151
|
+
return () => listeners.delete(listener);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// src/canvas.ts
|
|
156
|
+
function createCanvas({ document: doc = globalThis.document, parent, width = 300, height = 150, context = "2d", contextOptions } = {}) {
|
|
157
|
+
if (!doc || typeof doc.createElement !== "function")
|
|
158
|
+
throw new Error("A browser document is required; pass document explicitly");
|
|
159
|
+
const element = doc.createElement("canvas");
|
|
160
|
+
element.width = width;
|
|
161
|
+
element.height = height;
|
|
162
|
+
const drawingContext = element.getContext(context, contextOptions);
|
|
163
|
+
if (!drawingContext)
|
|
164
|
+
throw new Error(`Unable to create ${context} canvas context`);
|
|
165
|
+
parent?.appendChild(element);
|
|
166
|
+
let removed = false;
|
|
167
|
+
return {
|
|
168
|
+
element,
|
|
169
|
+
context: drawingContext,
|
|
170
|
+
resize(nextWidth, nextHeight) {
|
|
171
|
+
if (removed)
|
|
172
|
+
throw new Error("Cannot resize a removed canvas");
|
|
173
|
+
element.width = nextWidth;
|
|
174
|
+
element.height = nextHeight;
|
|
175
|
+
return this;
|
|
176
|
+
},
|
|
177
|
+
destroy() {
|
|
178
|
+
if (!removed) {
|
|
179
|
+
removed = true;
|
|
180
|
+
element.remove();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
createCanvas,
|
|
187
|
+
createGame,
|
|
188
|
+
createSound,
|
|
189
|
+
createStore
|
|
190
|
+
};
|
package/dist/sound.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/sound.ts
|
|
2
|
+
function createSound(buffer, audioContext, { volume = 1, maxGain = 4 } = {}) {
|
|
3
|
+
if (!buffer)
|
|
4
|
+
throw new TypeError("buffer is required");
|
|
5
|
+
if (!audioContext || typeof audioContext.createBufferSource !== "function" || typeof audioContext.createGain !== "function") {
|
|
6
|
+
throw new TypeError("audioContext must provide createBufferSource() and createGain()");
|
|
7
|
+
}
|
|
8
|
+
if (!Number.isFinite(maxGain) || maxGain < 0)
|
|
9
|
+
throw new RangeError("maxGain must be a finite, non-negative number");
|
|
10
|
+
if (!Number.isFinite(volume) || volume < 0)
|
|
11
|
+
throw new RangeError("volume must be a finite, non-negative number");
|
|
12
|
+
return {
|
|
13
|
+
startPlaying({ loop = false, playbackRate = 1 } = {}) {
|
|
14
|
+
const source = audioContext.createBufferSource();
|
|
15
|
+
const gainNode = audioContext.createGain();
|
|
16
|
+
source.buffer = buffer;
|
|
17
|
+
source.loop = Boolean(loop);
|
|
18
|
+
if (source.playbackRate)
|
|
19
|
+
source.playbackRate.value = playbackRate;
|
|
20
|
+
const baseGain = clamp(volume, maxGain);
|
|
21
|
+
gainNode.gain.value = baseGain;
|
|
22
|
+
source.connect(gainNode);
|
|
23
|
+
gainNode.connect(audioContext.destination);
|
|
24
|
+
source.start();
|
|
25
|
+
let stopped = false;
|
|
26
|
+
return {
|
|
27
|
+
source,
|
|
28
|
+
amplify(multiplier) {
|
|
29
|
+
if (stopped)
|
|
30
|
+
return this;
|
|
31
|
+
if (multiplier === "max")
|
|
32
|
+
gainNode.gain.value = maxGain;
|
|
33
|
+
else if (typeof multiplier === "number" && Number.isFinite(multiplier)) {
|
|
34
|
+
gainNode.gain.value = clamp(baseGain * multiplier, maxGain);
|
|
35
|
+
} else
|
|
36
|
+
throw new TypeError("amplify expects a finite multiplier or 'max'");
|
|
37
|
+
return this;
|
|
38
|
+
},
|
|
39
|
+
stop() {
|
|
40
|
+
if (!stopped) {
|
|
41
|
+
stopped = true;
|
|
42
|
+
source.stop();
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
},
|
|
46
|
+
get stopped() {
|
|
47
|
+
return stopped;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function clamp(value, maximum) {
|
|
54
|
+
return Math.min(maximum, Math.max(0, value));
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
createSound
|
|
58
|
+
};
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/store.ts
|
|
2
|
+
function createStore(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
|
+
export {
|
|
31
|
+
createStore
|
|
32
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface CanvasOptions {
|
|
2
|
+
document?: Document;
|
|
3
|
+
parent?: Element;
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
context?: '2d';
|
|
7
|
+
contextOptions?: CanvasRenderingContext2DSettings;
|
|
8
|
+
}
|
|
9
|
+
export interface CanvasSurface {
|
|
10
|
+
element: HTMLCanvasElement;
|
|
11
|
+
context: CanvasRenderingContext2D;
|
|
12
|
+
resize(width: number, height: number): this;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
/** Create an independent canvas surface. DOM access happens only when called. */
|
|
16
|
+
export declare function createCanvas({ document: doc, parent, width, height, context, contextOptions }?: CanvasOptions): CanvasSurface;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface FrameInfo {
|
|
2
|
+
deltaMs: number;
|
|
3
|
+
timestamp: number;
|
|
4
|
+
frame: number;
|
|
5
|
+
}
|
|
6
|
+
export interface GameOptions<State = unknown> {
|
|
7
|
+
state?: State;
|
|
8
|
+
update?: (deltaSeconds: number, state: State, frame: FrameInfo) => void;
|
|
9
|
+
render?: (state: State, frame: FrameInfo & {
|
|
10
|
+
deltaSeconds: number;
|
|
11
|
+
}) => void;
|
|
12
|
+
requestFrame?: (callback: FrameRequestCallback) => number;
|
|
13
|
+
cancelFrame?: (id: number) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface GameLoop<State = unknown> {
|
|
16
|
+
step(deltaMs: number, timestamp?: number): State;
|
|
17
|
+
getState(): State;
|
|
18
|
+
setState(nextState: State): State;
|
|
19
|
+
start(): this;
|
|
20
|
+
stop(): this;
|
|
21
|
+
readonly running: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** A tiny browser game loop with deterministic, manually-driven `step`. */
|
|
24
|
+
export declare function createGame<State = Record<string, never>>({ state, update, render, requestFrame, cancelFrame, }?: GameOptions<State>): GameLoop<State>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createGame } from './game.js';
|
|
2
|
+
export type { GameOptions, GameLoop, FrameInfo } from './game.js';
|
|
3
|
+
export { createSound } from './sound.js';
|
|
4
|
+
export type { SoundOptions, Sound, Playback, PlaybackOptions } from './sound.js';
|
|
5
|
+
export { createStore } from './store.js';
|
|
6
|
+
export type { Store } from './store.js';
|
|
7
|
+
export { createCanvas } from './canvas.js';
|
|
8
|
+
export type { CanvasOptions, CanvasSurface } from './canvas.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SoundOptions {
|
|
2
|
+
/** Initial linear gain, in the Web Audio gain scale. */
|
|
3
|
+
volume?: number;
|
|
4
|
+
/** Upper bound for gain values produced by amplify(); defaults to 4. */
|
|
5
|
+
maxGain?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PlaybackOptions {
|
|
8
|
+
loop?: boolean;
|
|
9
|
+
playbackRate?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Playback {
|
|
12
|
+
readonly source: AudioBufferSourceNode;
|
|
13
|
+
readonly stopped: boolean;
|
|
14
|
+
amplify(multiplier: number | 'max'): this;
|
|
15
|
+
stop(): this;
|
|
16
|
+
}
|
|
17
|
+
export interface Sound {
|
|
18
|
+
startPlaying(options?: PlaybackOptions): Playback;
|
|
19
|
+
}
|
|
20
|
+
/** Create a reusable sound backed by a Web Audio AudioBuffer. */
|
|
21
|
+
export declare function createSound(buffer: AudioBuffer, audioContext: BaseAudioContext, { volume, maxGain }?: SoundOptions): Sound;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Store<State> {
|
|
2
|
+
getState(): State;
|
|
3
|
+
setState(nextState: State | ((current: State) => State)): State;
|
|
4
|
+
update(mutator: (current: State) => State): State;
|
|
5
|
+
subscribe(listener: (state: State) => void): () => boolean;
|
|
6
|
+
}
|
|
7
|
+
/** A small observable store that can be shared by any number of components. */
|
|
8
|
+
export declare function createStore<State = Record<string, never>>(initialState?: State): Store<State>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
woofjs-engine is a small set of host-independent primitives. It does not own a scene graph, input system, asset loader, or framework lifecycle. The host application owns those concerns and supplies callbacks or browser objects when needed. The public entry point also exports `createStore` for observable shared state and `createCanvas` for independent DOM canvas surfaces. Multiple canvases can share a store without requiring a built-in scene graph.
|
|
4
|
+
|
|
5
|
+
## Game loop
|
|
6
|
+
|
|
7
|
+
`createGame({ state, update, render, requestFrame, cancelFrame })` creates a game controller. `state` is the starting state object. `update(deltaSeconds, state, frame)` advances it; `render(state, frame)` draws or presents it. The first callback argument is elapsed **seconds**. The public `step(deltaMs)` accepts **milliseconds** and converts the duration before invoking `update`.
|
|
8
|
+
|
|
9
|
+
The controller exposes:
|
|
10
|
+
|
|
11
|
+
- `step(deltaMs)` to process one frame explicitly.
|
|
12
|
+
- `start()` to begin scheduling frames through the injected scheduler.
|
|
13
|
+
- `stop()` to cancel the scheduled frame and halt the loop.
|
|
14
|
+
- `getState()` to read the live state object.
|
|
15
|
+
- `setState(nextState)` to replace the state object.
|
|
16
|
+
|
|
17
|
+
This split keeps the simulation usable without `window` or `requestAnimationFrame`. A server process, test, or fixed-step host can call `step()` directly. A browser can inject `requestAnimationFrame` and `cancelAnimationFrame`. The engine does not assume the global browser functions exist.
|
|
18
|
+
|
|
19
|
+
The simulation's update callback receives time in seconds, which makes movement independent of a particular display refresh rate when update logic scales changes by the supplied duration. `step()` makes the duration explicit for reproducible scenarios. The engine does not currently claim to provide a fixed timestep, input buffering, delta clamping, pause semantics, or rollback; applications should make those policies explicit where they matter.
|
|
20
|
+
|
|
21
|
+
The update callback also receives frame metadata as its third argument; the render callback receives state and metadata. Metadata includes `deltaMs`, `timestamp`, and `frame` (and render metadata also includes `deltaSeconds`). `createStore(initialState)` is separate from the game controller: `getState()` reads it, `setState(valueOrUpdater)` replaces it, `update(mutator)` applies a transform, and `subscribe(listener)` returns an unsubscribe function. The game loop and store are not implicitly connected; application code chooses how state flows between them.
|
|
22
|
+
|
|
23
|
+
## Audio
|
|
24
|
+
|
|
25
|
+
`createSound(buffer, audioContext, { volume = 1, maxGain = 4 })` wraps a decoded Web Audio `AudioBuffer` and an `AudioContext`. It returns a sound object with `startPlaying(options?)`. Each playback handle exposes `amplify(number | 'max')`, `stop()`, and its source node as `.source`.
|
|
26
|
+
|
|
27
|
+
Numeric amplification multiplies the initial `volume` and clamps the result between zero and `maxGain`; `'max'` selects the configured maximum. This is only a software gain bound and cannot guarantee protection from clipping, loud speakers, or hearing damage. The sound helper uses browser Web Audio rather than an engine-owned audio backend. The application remains responsible for fetching/decoding assets, managing the context, and complying with browser autoplay restrictions.
|
|
28
|
+
|
|
29
|
+
## Framework integration
|
|
30
|
+
|
|
31
|
+
Frameworks own mount/unmount and view updates. An integration should create the controller at mount time, provide scheduler functions where available, and call `stop()` during teardown. Keep mutable simulation state in the engine and use the framework's rendering mechanism to reflect it. See [the Svelte example](../examples/svelte/Game.svelte) for a minimal pattern.
|
|
32
|
+
|
|
33
|
+
`createCanvas({ document, parent, width, height, context, contextOptions })` creates a canvas element, optionally appends it to `parent`, and returns `{ element, context, resize, destroy }`. The `document` can be injected for alternate DOM environments; otherwise it reads `globalThis.document` when called. Multiple canvas instances are independent surfaces, and a shared store can coordinate the data they render.
|
|
34
|
+
|
|
35
|
+
## Module boundaries
|
|
36
|
+
|
|
37
|
+
The public entry point is `src/index.js`; game-loop behavior lives in `src/game.js`, sound in `src/sound.js`, shared state in `src/store.js`, and canvas surfaces in `src/canvas.js`. Keeping the modules focused leaves input, asset loading, and UI choices to consumers.
|
package/docs/planning.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Planning notes
|
|
2
|
+
|
|
3
|
+
This document records design directions, not a release schedule. The project is inspired by the approachable WoofJS style ([source project](https://github.com/stevekrouse/WoofJS), [website](https://woofjs.com/)), but is an independent implementation and does not promise source or API compatibility. The guiding constraint is to keep the core small and portable while adding features only when they have clear contracts and can be exercised without tying the engine to a particular UI framework.
|
|
4
|
+
|
|
5
|
+
## Current baseline
|
|
6
|
+
|
|
7
|
+
- A host-provided state/update/render game loop.
|
|
8
|
+
- Explicit deterministic stepping via `step(deltaMs)`.
|
|
9
|
+
- Optional host-provided frame scheduling via `start()` and `stop()`.
|
|
10
|
+
- A basic observable store and independent canvas surface helper.
|
|
11
|
+
- Web Audio playback helper with bounded amplification and explicit stop control.
|
|
12
|
+
|
|
13
|
+
## Candidate areas to explore
|
|
14
|
+
|
|
15
|
+
1. **Richer shared views:** the current store and canvas helpers are basic building blocks. Explore coordination for multiple canvases or components that share state and utilities, with clearly defined ownership and update ordering.
|
|
16
|
+
2. **UI component mappings:** explore mapping familiar UI components to game behavior without making a specific framework mandatory.
|
|
17
|
+
3. **Input adapters:** define a small input shape while keeping DOM event registration in optional host adapters.
|
|
18
|
+
4. **Timing policy:** consider opt-in delta clamping or fixed-step accumulation, preserving the current explicit step behavior.
|
|
19
|
+
5. **Optional compilation:** evaluate whether compilation meaningfully helps users author games, and define a build step only if it remains optional and has a stable input/output contract.
|
|
20
|
+
6. **Lifecycle and examples:** document teardown, browser audio activation, and integration with common frameworks.
|
|
21
|
+
7. **Testability and assets:** retain deterministic stepping; consider loading/decoding helpers only after deciding whether they belong in core or adapters.
|
|
22
|
+
|
|
23
|
+
The richer shared-view coordination, component-mapping, and compilation ideas are roadmap questions. The current release provides basic store and canvas helpers but does not implement those higher-level systems.
|
|
24
|
+
|
|
25
|
+
## Decisions to preserve
|
|
26
|
+
|
|
27
|
+
- Core game logic should be callable in Node and browser environments.
|
|
28
|
+
- Browser facilities should be injected or isolated behind optional adapters rather than read at module import time.
|
|
29
|
+
- Time units and audio gain bounds should remain explicit in the public API.
|
|
30
|
+
- Avoid framework-specific abstractions in the core package.
|
|
31
|
+
|
|
32
|
+
These candidates need user and maintainer feedback before becoming commitments.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createSound } from 'woofjs-engine';
|
|
2
|
+
|
|
3
|
+
// Call this from a click/tap handler so the browser can permit audio playback.
|
|
4
|
+
export async function playDecodedSound(arrayBuffer) {
|
|
5
|
+
const audioContext = new AudioContext();
|
|
6
|
+
const buffer = await audioContext.decodeAudioData(arrayBuffer);
|
|
7
|
+
const sound = createSound(buffer, audioContext, { volume: 0.7, maxGain: 4 });
|
|
8
|
+
const playback = sound.startPlaying();
|
|
9
|
+
|
|
10
|
+
// Keep `playback` if the UI needs to adjust or stop this specific playback:
|
|
11
|
+
// playback.amplify(1.25);
|
|
12
|
+
// playback.amplify('max');
|
|
13
|
+
// playback.stop();
|
|
14
|
+
return { audioContext, playback };
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createCanvas, createStore } from 'woofjs-engine';
|
|
2
|
+
|
|
3
|
+
// In a browser, place elements with ids "main" and "minimap" in the page.
|
|
4
|
+
const store = createStore({ x: 20, y: 30 });
|
|
5
|
+
const main = createCanvas({ parent: document.querySelector('#main'), width: 640, height: 360 });
|
|
6
|
+
const minimap = createCanvas({ parent: document.querySelector('#minimap'), width: 160, height: 90 });
|
|
7
|
+
|
|
8
|
+
function draw(context, state, width, height) {
|
|
9
|
+
context.clearRect(0, 0, width, height);
|
|
10
|
+
context.fillRect(state.x, state.y, 12, 12);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const unsubscribe = store.subscribe(state => {
|
|
14
|
+
draw(main.context, state, main.element.width, main.element.height);
|
|
15
|
+
draw(minimap.context, state, minimap.element.width, minimap.element.height);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Example teardown when the owning page/component is removed:
|
|
19
|
+
// unsubscribe();
|
|
20
|
+
// main.destroy();
|
|
21
|
+
// minimap.destroy();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// A host-independent example: manually step the game from Node or a test.
|
|
2
|
+
import { createGame } from 'woofjs-engine';
|
|
3
|
+
|
|
4
|
+
const game = createGame({
|
|
5
|
+
state: { secondsAlive: 0 },
|
|
6
|
+
update(deltaSeconds, state) {
|
|
7
|
+
state.secondsAlive += deltaSeconds;
|
|
8
|
+
},
|
|
9
|
+
render(state) {
|
|
10
|
+
console.log(`Alive for ${state.secondsAlive.toFixed(2)} seconds`);
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
game.step(250); // step takes milliseconds; update receives seconds
|
|
15
|
+
game.step(250);
|
|
16
|
+
console.log('Final state:', game.getState());
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { createGame } from 'woofjs-engine';
|
|
4
|
+
|
|
5
|
+
let x = 20;
|
|
6
|
+
let game;
|
|
7
|
+
|
|
8
|
+
onMount(() => {
|
|
9
|
+
game = createGame({
|
|
10
|
+
state: { x },
|
|
11
|
+
update(deltaSeconds, state) {
|
|
12
|
+
state.x += 80 * deltaSeconds;
|
|
13
|
+
},
|
|
14
|
+
render(state) {
|
|
15
|
+
// Assigning a new value lets Svelte update the view.
|
|
16
|
+
x = state.x;
|
|
17
|
+
},
|
|
18
|
+
requestFrame: callback => requestAnimationFrame(callback),
|
|
19
|
+
cancelFrame: id => cancelAnimationFrame(id),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
game.start();
|
|
23
|
+
return () => game.stop();
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div class="track" aria-label="Game area">
|
|
28
|
+
<div class="player" style:left={`${x}px`}>🐶</div>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.track {
|
|
33
|
+
position: relative;
|
|
34
|
+
height: 4rem;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
border: 1px solid #999;
|
|
37
|
+
}
|
|
38
|
+
.player {
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0.5rem;
|
|
41
|
+
font-size: 2rem;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "woofjs-engine",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A small browser-friendly, deterministic TypeScript game engine core.",
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./game": {
|
|
13
|
+
"types": "./dist/types/game.d.ts",
|
|
14
|
+
"import": "./dist/game.js"
|
|
15
|
+
},
|
|
16
|
+
"./sound": {
|
|
17
|
+
"types": "./dist/types/sound.d.ts",
|
|
18
|
+
"import": "./dist/sound.js"
|
|
19
|
+
},
|
|
20
|
+
"./store": {
|
|
21
|
+
"types": "./dist/types/store.d.ts",
|
|
22
|
+
"import": "./dist/store.js"
|
|
23
|
+
},
|
|
24
|
+
"./canvas": {
|
|
25
|
+
"types": "./dist/types/canvas.d.ts",
|
|
26
|
+
"import": "./dist/canvas.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
31
|
+
"build": "bun build src/index.ts src/game.ts src/sound.ts src/store.ts src/canvas.ts --outdir dist --target browser --format esm && tsc -p tsconfig.json",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.consumer.json",
|
|
33
|
+
"test": "npm run typecheck && node --test"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://gitlab.com/ratradworke/woofjs-engine.git"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://woofjs-engine-c23a47.gitlab.io/",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://gitlab.com/ratradworke/woofjs-engine/-/issues"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"game-engine",
|
|
49
|
+
"education",
|
|
50
|
+
"canvas",
|
|
51
|
+
"svelte"
|
|
52
|
+
],
|
|
53
|
+
"files": [
|
|
54
|
+
"dist/",
|
|
55
|
+
"docs/",
|
|
56
|
+
"examples/",
|
|
57
|
+
"README.md",
|
|
58
|
+
"LICENSE"
|
|
59
|
+
],
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"bun": "^1.4.5",
|
|
62
|
+
"typescript": "^7.0.2"
|
|
63
|
+
}
|
|
64
|
+
}
|