@kmamal/sdl 0.10.4 → 0.10.6
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 +1 -1
- package/package.json +3 -3
- package/scripts/build-sdl.mjs +1 -1
- package/scripts/download-release.mjs +1 -1
- package/scripts/download-sdl.mjs +14 -8
- package/src/native/video.cpp +8 -9
- package/src/types/index.d.ts +1 -1
package/README.md
CHANGED
|
@@ -515,7 +515,7 @@ Check [`sdl.video.displays`](#sdlvideodisplays) to get the new list of displays.
|
|
|
515
515
|
* `x, y, width, height: <Rect>` The position and size of the display's geometry.
|
|
516
516
|
* `usable: <object>` Similar to `geometry`, but excludes areas taken up by the OS or window manager such as menus, docks, e.t.c.
|
|
517
517
|
* `x, y, width, height: <Rect>` The position and size of the display's usable region.
|
|
518
|
-
* `dpi: <object>` Return pixel density for the display in dots/pixels-per-inch units.
|
|
518
|
+
* `dpi: <object>|<null>` Return pixel density for the display in dots/pixels-per-inch units. Might be `null` on some devices if DPI info can't be retrieved.
|
|
519
519
|
* `horizontal: <number>` The horizontal density.
|
|
520
520
|
* `vertical: <number>` The vertical density.
|
|
521
521
|
* `diagonal: <number>` The diagonal density.
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.10.
|
|
2
|
+
"version": "0.10.6",
|
|
3
3
|
"name": "@kmamal/sdl",
|
|
4
4
|
"description": "SDL bindings for Node.js",
|
|
5
5
|
"keywords": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"clean": "cd scripts && node clean.mjs"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"tar": "^
|
|
63
|
+
"tar": "^7.1.0"
|
|
64
64
|
},
|
|
65
65
|
"sdl": {
|
|
66
66
|
"owner": "kmamal",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@kmamal/evdev": "^0.0.1",
|
|
72
72
|
"@kmamal/testing": "^0.0.30",
|
|
73
|
-
"@types/node": "^20.
|
|
73
|
+
"@types/node": "^20.12.8",
|
|
74
74
|
"node-addon-api": "^8.0.0",
|
|
75
75
|
"node-gyp": "^10.1.0"
|
|
76
76
|
}
|
package/scripts/build-sdl.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import Path from 'node:path'
|
|
|
3
3
|
import { once } from 'node:events'
|
|
4
4
|
import C from './util/common.js'
|
|
5
5
|
import { fetch } from './util/fetch.js'
|
|
6
|
-
import Tar from 'tar'
|
|
6
|
+
import * as Tar from 'tar'
|
|
7
7
|
|
|
8
8
|
const url = `https://github.com/${C.sdl.owner}/${C.sdl.repo}/archive/refs/tags/v${C.sdl.version}.tar.gz`
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@ import Fs from 'node:fs'
|
|
|
2
2
|
import { once } from 'node:events'
|
|
3
3
|
import C from './util/common.js'
|
|
4
4
|
import { fetch } from './util/fetch.js'
|
|
5
|
-
import Tar from 'tar'
|
|
5
|
+
import * as Tar from 'tar'
|
|
6
6
|
|
|
7
7
|
const url = `https://github.com/${C.owner}/${C.repo}/releases/download/v${C.version}/${C.assetName}`
|
|
8
8
|
|
package/scripts/download-sdl.mjs
CHANGED
|
@@ -2,16 +2,22 @@ import Fs from 'node:fs'
|
|
|
2
2
|
import { once } from 'node:events'
|
|
3
3
|
import C from './util/common.js'
|
|
4
4
|
import { fetch } from './util/fetch.js'
|
|
5
|
-
import Tar from 'tar'
|
|
5
|
+
import * as Tar from 'tar'
|
|
6
6
|
|
|
7
7
|
const url = `https://github.com/${C.sdl.owner}/${C.sdl.repo}/releases/download/v${C.sdl.version}/${C.sdl.assetName}`
|
|
8
8
|
|
|
9
9
|
console.log("fetch", url)
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
const response = await fetch(url)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
await Fs.promises.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
|
|
14
|
+
console.log("unpack to", C.dir.sdl)
|
|
15
|
+
await Fs.promises.rm(C.dir.sdl, { recursive: true }).catch(() => {})
|
|
16
|
+
await Fs.promises.mkdir(C.dir.sdl, { recursive: true })
|
|
17
|
+
const tar = Tar.extract({ gzip: true, C: C.dir.sdl })
|
|
18
|
+
response.stream().pipe(tar)
|
|
19
|
+
await once(tar, 'finish')
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.log(error)
|
|
22
|
+
throw error
|
|
23
|
+
}
|
package/src/native/video.cpp
CHANGED
|
@@ -67,19 +67,18 @@ video::getDisplays(const Napi::CallbackInfo &info)
|
|
|
67
67
|
usable.Set("width", Napi::Number::New(env, rect.w));
|
|
68
68
|
usable.Set("height", Napi::Number::New(env, rect.h));
|
|
69
69
|
|
|
70
|
+
Napi::Value dpi;
|
|
70
71
|
float ddpi, hdpi, vdpi;
|
|
71
72
|
if (SDL_GetDisplayDPI(i, &ddpi, &hdpi, &vdpi) < 0) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
dpi = env.Null();
|
|
74
|
+
} else {
|
|
75
|
+
Napi::Object dpi_obj = Napi::Object::New(env);
|
|
76
|
+
dpi_obj.Set("diagonal", Napi::Number::New(env, ddpi));
|
|
77
|
+
dpi_obj.Set("horizontal", Napi::Number::New(env, hdpi));
|
|
78
|
+
dpi_obj.Set("vertical", Napi::Number::New(env, vdpi));
|
|
79
|
+
dpi = dpi_obj;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
Napi::Object dpi = Napi::Object::New(env);
|
|
79
|
-
dpi.Set("diagonal", Napi::Number::New(env, ddpi));
|
|
80
|
-
dpi.Set("horizontal", Napi::Number::New(env, hdpi));
|
|
81
|
-
dpi.Set("vertical", Napi::Number::New(env, vdpi));
|
|
82
|
-
|
|
83
82
|
Napi::Object display = Napi::Object::New(env);
|
|
84
83
|
display.Set("name", Napi::String::New(env, name));
|
|
85
84
|
display.Set("format", video::formats[(SDL_PixelFormatEnum) mode.format]);
|