@kmamal/sdl 0.11.13 → 1.0.0-3
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 +113 -1
- package/README.md +26 -2685
- package/binding.gyp +82 -65
- package/package.json +17 -11
- package/scripts/build-sdl.mjs +15 -7
- package/scripts/build.mjs +30 -15
- package/scripts/download-release.mjs +9 -6
- package/scripts/download-sdl.mjs +9 -6
- package/scripts/install.mjs +13 -5
- package/scripts/util/common.js +9 -1
- package/src/javascript/audio/audio-playback-stream.js +50 -0
- package/src/javascript/audio/audio-recording-stream.js +32 -0
- package/src/javascript/audio/{audio-instance.js → audio-stream.js} +40 -34
- package/src/javascript/audio/device.js +34 -6
- package/src/javascript/audio/format-helpers.js +29 -34
- package/src/javascript/audio/index.js +37 -26
- package/src/javascript/audio/prevent-exit.js +19 -9
- package/src/javascript/cleanup.js +19 -10
- package/src/javascript/enums.js +5 -0
- package/src/javascript/events/events-via-poll.js +25 -7
- package/src/javascript/events/index.js +280 -174
- package/src/javascript/gamepad/device.js +23 -0
- package/src/javascript/gamepad/gamepad-instance.js +211 -0
- package/src/javascript/gamepad/index.js +51 -0
- package/src/javascript/globals.js +8 -5
- package/src/javascript/helpers.js +41 -7
- package/src/javascript/index.js +5 -3
- package/src/javascript/joystick/device.js +5 -10
- package/src/javascript/joystick/index.js +7 -7
- package/src/javascript/joystick/joystick-instance.js +81 -42
- package/src/javascript/joystick/shared.js +90 -0
- package/src/javascript/keyboard/index.js +6 -4
- package/src/javascript/keyboard/key-mapping.js +70 -28
- package/src/javascript/mouse/index.js +21 -10
- package/src/javascript/sensor/devices.js +17 -0
- package/src/javascript/sensor/index.js +2 -16
- package/src/javascript/sensor/sensor-instance.js +22 -6
- package/src/javascript/touch/devices.js +17 -0
- package/src/javascript/touch/index.js +3 -7
- package/src/javascript/video/format-helpers.js +117 -0
- package/src/javascript/video/index.js +44 -5
- package/src/javascript/video/window.js +289 -133
- package/src/native/audio.cpp +182 -58
- package/src/native/audio.h +10 -5
- package/src/native/clipboard.cpp +22 -5
- package/src/native/cocoa-window.h +1 -0
- package/src/native/cocoa-window.mm +1 -1
- package/src/native/enums.cpp +91 -58
- package/src/native/events.cpp +437 -284
- package/src/native/events.h +18 -12
- package/src/native/gamepad.cpp +185 -0
- package/src/native/gamepad.h +27 -0
- package/src/native/global.cpp +173 -167
- package/src/native/global.h +0 -2
- package/src/native/joystick.cpp +287 -225
- package/src/native/joystick.h +7 -6
- package/src/native/keyboard.cpp +28 -8
- package/src/native/keyboard.h +4 -2
- package/src/native/module.cpp +14 -8
- package/src/native/mouse.cpp +54 -34
- package/src/native/mouse.h +0 -1
- package/src/native/power.cpp +10 -4
- package/src/native/power.h +1 -1
- package/src/native/sensor.cpp +52 -52
- package/src/native/sensor.h +1 -1
- package/src/native/touch.cpp +45 -24
- package/src/native/touch.h +1 -1
- package/src/native/video.cpp +115 -75
- package/src/native/video.h +5 -2
- package/src/native/window.cpp +409 -321
- package/src/native/window.h +3 -1
- package/src/types/helpers.d.ts +45 -19
- package/src/types/index.d.ts +366 -273
- package/scripts/util/fetch.js +0 -85
- package/src/javascript/audio/audio-playback-instance.js +0 -23
- package/src/javascript/audio/audio-recording-instance.js +0 -17
- package/src/javascript/controller/controller-instance.js +0 -160
- package/src/javascript/controller/device.js +0 -26
- package/src/javascript/controller/index.js +0 -33
- package/src/javascript/events/reconcile-audio-devices.js +0 -16
- package/src/javascript/events/reconcile-displays.js +0 -17
- package/src/javascript/events/reconcile-joystick-and-controller-devices.js +0 -40
- package/src/javascript/events/reconcile.js +0 -61
- package/src/javascript/video/display.js +0 -4
- package/src/native/controller.cpp +0 -192
- package/src/native/controller.h +0 -26
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,117 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [v1.0.0] - 2026-10-01
|
|
11
|
+
|
|
12
|
+
The library now builds against SDL3 (3.4.x) instead of SDL2. This release contains breaking changes, see the [migration guide](https://github.com/kmamal/node-sdl/tree/master/docs/migrating-to-sdl3.md) for a walkthrough.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Exceptions thrown in event listeners are re-emitted as an `'error'` event on the window or instance, following the usual `EventEmitter` semantics: with no `'error'` listener they surface as an uncaught exception. They no longer stop event delivery or crash the process.
|
|
17
|
+
- Attaching a listener to a destroyed window or a closed instance or stream now throws, instead of silently never firing.
|
|
18
|
+
- Audio and video formats are reported using the platform-independent enums. The platform-dependent ones are only used as input.
|
|
19
|
+
- Character keys are reported as the unshifted character (`'ü'` instead of `'Ü'`), so `getKey(getScancode('ü'))` round-trips.
|
|
20
|
+
- steamHandle is now reported as a BigInt.
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Windows arm64 build
|
|
25
|
+
- Wayland support
|
|
26
|
+
- Support FreeBSD, OpenBSD, and NetBSD.
|
|
27
|
+
- `NODE_SDL_SYSTEM=1 npm install` builds against the SDL already installed on the system (located through `pkg-config`, or `SDL_INC`/`SDL_LIB`) instead of downloading one.
|
|
28
|
+
- Relative mouse mode for FPS-style camera controls.
|
|
29
|
+
- `mouseMove` and `ballMotion` events report relative movement through `dx` and `dy`.
|
|
30
|
+
- Window event `'fingerCancel'`, fired when the system cancels a touch.
|
|
31
|
+
- Audio device objects report the `format`, `channels`, `frequency`, and `buffered` the device is running with while streams are open on them.
|
|
32
|
+
- Gamepad buttons `misc1` and `touchpad` are now reported instead of arriving with `button: null`.
|
|
33
|
+
- Pixel-format helpers similar to audio format helpers.
|
|
34
|
+
- More stuff in `@kmamal/sdl/helpers`
|
|
35
|
+
- More scancodes and keys
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
Windows:
|
|
40
|
+
|
|
41
|
+
- A new window reports its actual position, size, display, and flags on creation (a fullscreen window no longer reports 640x480), including when it is created from inside an event listener.
|
|
42
|
+
- OpenGL and WebGPU windows have no SDL renderer, so `createWindow()` now throws if you pass `accelerated` or `vsync` together with `opengl` or `webgpu`, instead of ignoring the option.
|
|
43
|
+
- `resize` fires, and `pixelWidth`/`pixelHeight` update, when only the pixel size changes (for example when moving to a display with a different scale).
|
|
44
|
+
- `move` and `resize` events are no longer delivered twice.
|
|
45
|
+
- Closing the last window via its close button no longer fires `beforeClose` twice, which bypassed `prevent()`.
|
|
46
|
+
- Windows created with `visible: false` no longer receive an initial `expose` event until they are shown.
|
|
47
|
+
- `window.fullscreen`, `minimized`, `maximized`, `visible`, and `focused` only change when the windowing system reports the change.
|
|
48
|
+
- `fullscreen` is no longer reset when the window is minimized, maximized, or restored.
|
|
49
|
+
- `window.setSizeInPixels()` no longer rejects almost every size on displays with a fractional scale.
|
|
50
|
+
- `setResizable()` and `setBorderless()` enforce the same mutual exclusivity as `createWindow()`.
|
|
51
|
+
- `window.destroy()` no longer crashes when called from a `beforeClose` listener, or from a `move` or `resize` listener while the window is being dragged.
|
|
52
|
+
- Removing all of a window's listeners no longer breaks event polling, lets the process exit while the window is open, or turns `destroy()` into a no-op.
|
|
53
|
+
- `window.render()` throws instead of silently presenting stale contents when updating the texture fails, and no longer corrupts memory or leaks after a failed render or renderer switch.
|
|
54
|
+
- Windows recover from a lost graphics device instead of failing every `render()` from then on.
|
|
55
|
+
- `window.render()` validates image `stride` and buffer sizes, preventing out-of-bounds reads, including for planar and packed YUV formats with odd dimensions.
|
|
56
|
+
- `window.setIcon()` and `mouse.setCursorImage()` reject YUV pixel formats with a clear error.
|
|
57
|
+
- A `blur` or `leave` event no longer clears `sdl.video.focused`/`sdl.video.hovered` when another window has already gained focus or hover, and both now return current values.
|
|
58
|
+
|
|
59
|
+
Displays:
|
|
60
|
+
|
|
61
|
+
- Connecting or disconnecting a display no longer crashes the process.
|
|
62
|
+
- `window.display` is `null` when its display has been removed.
|
|
63
|
+
- The `displayMove` event is emitted instead of throwing "invalid event", and `displayOrient` and `displayMove` events carry the documented `device` property
|
|
64
|
+
- A display's `frequency` is `null` instead of `0` when the refresh rate is unknown.
|
|
65
|
+
|
|
66
|
+
Mouse and keyboard:
|
|
67
|
+
|
|
68
|
+
- The space key is reported as `' '`, like every other character-producing key, instead of `'space'`.
|
|
69
|
+
- `mouse.getButton()` returns the current button state instead of old values.
|
|
70
|
+
- The right GUI key reports the documented `'gui'` key name instead of `'gUI'`.
|
|
71
|
+
- The GUI keys on Windows and the GUI and Alt keys on macOS report `'windows'`, `'command'`, and `'option'` instead of `null`.
|
|
72
|
+
- Keys outside the Basic Multilingual Plane (such as emoji) are reported as that character instead of `null`.
|
|
73
|
+
- `sdl.keyboard.getScancode()` resolves single-character keys such as `','` and `'0'` to the main keyboard keys instead of the keypad ones.
|
|
74
|
+
- `sdl.keyboard.getKey()` agrees with the `key` of keyboard events on AZERTY and non-Latin layouts, and both functions pick up a layout change right away.
|
|
75
|
+
|
|
76
|
+
Touch:
|
|
77
|
+
|
|
78
|
+
- Touch events no longer crash event handling.
|
|
79
|
+
- `sdl.touch.devices` is refreshed on every read instead of returning the list from startup, and no longer lists the virtual devices SDL creates for events synthesized from the mouse and pen. Those events arrive with a `null` `device`.
|
|
80
|
+
|
|
81
|
+
Joysticks and gamepads:
|
|
82
|
+
|
|
83
|
+
- Unplugging a device no longer makes the remaining joystick, gamepad, display, or audio devices report the wrong identity, and `deviceRemove`/`displayRemove` report the right device.
|
|
84
|
+
- `openDevice()` no longer risks opening the wrong physical device while another device is being unplugged.
|
|
85
|
+
- Closing an instance from an event listener no longer crashes the process.
|
|
86
|
+
- Removed the axis scaling to their initial value.
|
|
87
|
+
- Trackball state and `ballMotion` events report accumulated positions.
|
|
88
|
+
- Rumble takes into account that the motors are owned by the device and may be shared across instances.
|
|
89
|
+
- `hasLed`, `hasRumble`, and `hasRumbleTriggers` report the device's current capabilities, and `setLed()`, `rumble()`, `stopRumble()`, `rumbleTriggers()`, and `stopRumbleTriggers()` consistently throw when the device lacks the hardware.
|
|
90
|
+
- `sdl.gamepad.addMappings()` refreshes the device lists (including `sdl.joystick.devices`) even when a mapping is invalid, and throws the error for the invalid mapping. The `mapping`, `name`, and `type` of a device are up to date when its `remap` event fires.
|
|
91
|
+
- `setPlayer()` and `resetPlayer()` update `player` on all of the device's objects, including the device that previously held the requested index, and throw if SDL refuses the assignment.
|
|
92
|
+
- The `power` and `steamHandle` getters, and sensor `data`, return current values instead of stale ones.
|
|
93
|
+
|
|
94
|
+
Sensors:
|
|
95
|
+
|
|
96
|
+
- `sdl.sensor.devices` no longer crashes when a sensor disappears while the list is read or throws for sensors of unknown type, and reports `side` for left/right sensors (such as Joy-Con pairs).
|
|
97
|
+
- `sdl.sensor.openDevice()` no longer throws a `TypeError`.
|
|
98
|
+
|
|
99
|
+
Audio:
|
|
100
|
+
|
|
101
|
+
- `putData()` and `getData()` accept empty buffers as no-ops, and reject a `bytes` count that isn't a whole number of sample frames with a validation error.
|
|
102
|
+
- `buffered` values larger than `32768` are rejected instead of silently truncated, and the buffer size the driver actually uses is reported on the stream's device.
|
|
103
|
+
- `playbackStream.queued` no longer reports negative values for queues over 2 GiB.
|
|
104
|
+
- `stream.playing` is `false` once the stream is closed.
|
|
105
|
+
- `readSample()` and `writeSample()` reject non-`Buffer` arguments, and `zeroSampleValue` for `u8` is `128`.
|
|
106
|
+
- Unplugging an audio device closes every stream opened from it, and plugging or unplugging one no longer fires spurious events for unrelated devices or crashes the process.
|
|
107
|
+
|
|
108
|
+
Other:
|
|
109
|
+
|
|
110
|
+
- Fixed native memory leaks when opening devices, creating windows, setting cursors, and handling file drops.
|
|
111
|
+
- Listening for `newListener` or `removeListener` no longer keeps the process alive forever.
|
|
112
|
+
- `emit()` now returns whether the event had listeners, as `EventEmitter` specifies.
|
|
113
|
+
- `sdl.clipboard.text` no longer throws when another application empties the clipboard mid-read.
|
|
114
|
+
- Integer arguments that cross into native code are validated to fit in 32 bits instead of silently wrapping.
|
|
115
|
+
- Enum values this build doesn't know are reported as `null` instead of an empty string.
|
|
116
|
+
- SDL errors are detected reliably, and stale SDL errors no longer cause spurious "SDL silent error" throws or lost data.
|
|
117
|
+
- The library no longer fails to load on systems where the audio or video subsystem can't be initialized, such as headless servers.
|
|
118
|
+
|
|
8
119
|
## [v0.11.13] - 2025-08-30
|
|
9
120
|
|
|
10
121
|
### Fixed
|
|
@@ -54,7 +165,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
54
165
|
|
|
55
166
|
- Started keeping this changelog.
|
|
56
167
|
|
|
57
|
-
[unreleased]: https://github.com/kmamal/node-sdl/compare/
|
|
168
|
+
[unreleased]: https://github.com/kmamal/node-sdl/compare/v1.0.0...HEAD
|
|
169
|
+
[v1.0.0]: https://github.com/kmamal/node-sdl/compare/v0.11.13...v1.0.0
|
|
58
170
|
[v0.11.13]: https://github.com/kmamal/node-sdl/compare/v0.11.12...v0.11.13
|
|
59
171
|
[v0.11.12]: https://github.com/kmamal/node-sdl/compare/v0.11.11...v0.11.12
|
|
60
172
|
[v0.11.11]: https://github.com/kmamal/node-sdl/compare/v0.11.10...v0.11.11
|