@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 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.4",
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": "^6.2.1"
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.11.30",
73
+ "@types/node": "^20.12.8",
74
74
  "node-addon-api": "^8.0.0",
75
75
  "node-gyp": "^10.1.0"
76
76
  }
@@ -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
 
@@ -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
- const response = await fetch(url)
10
+ try {
11
+ const response = await fetch(url)
11
12
 
12
- console.log("unpack to", C.dir.sdl)
13
- await Fs.promises.rm(C.dir.sdl, { recursive: true }).catch(() => {})
14
- await Fs.promises.mkdir(C.dir.sdl, { recursive: true })
15
- const tar = Tar.extract({ gzip: true, C: C.dir.sdl })
16
- response.stream().pipe(tar)
17
- await once(tar, 'finish')
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
+ }
@@ -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
- std::ostringstream message;
73
- message << "SDL_GetDisplayDPI(" << i << ") error: " << SDL_GetError();
74
- SDL_ClearError();
75
- throw Napi::Error::New(env, message.str());
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]);
@@ -371,7 +371,7 @@ export namespace Sdl {
371
371
  readonly horizontal: number
372
372
  readonly vertical: number
373
373
  readonly diagonal: number
374
- }
374
+ } | null
375
375
  }
376
376
 
377
377
  export class Window {