@kmamal/sdl 0.7.3 → 0.7.4
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/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Fs from 'node:fs'
|
|
2
|
+
import Path from 'node:path'
|
|
3
|
+
import { once } from 'node:events'
|
|
4
|
+
import C from './util/common.js'
|
|
5
|
+
import { fetch } from './util/fetch.js'
|
|
6
|
+
import Tar from 'tar'
|
|
7
|
+
|
|
8
|
+
const url = `https://github.com/${C.sdl.owner}/${C.sdl.repo}/archive/refs/tags/v${C.sdl.version}.tar.gz`
|
|
9
|
+
|
|
10
|
+
console.log("fetch", url)
|
|
11
|
+
const response = await fetch(url)
|
|
12
|
+
|
|
13
|
+
console.log("unpack to", C.dir.sdl)
|
|
14
|
+
await Fs.promises.rm(C.dir.sdl, { recursive: true }).catch(() => {})
|
|
15
|
+
await Fs.promises.mkdir(C.dir.sdl, { recursive: true })
|
|
16
|
+
const tar = Tar.extract({ gzip: true, C: C.dir.sdl })
|
|
17
|
+
response.stream().pipe(tar)
|
|
18
|
+
await once(tar, 'finish')
|
|
19
|
+
|
|
20
|
+
const sdlRoot = Path.join(C.dir.sdl, `${C.sdl.repo}-${C.sdl.version}`)
|
|
21
|
+
await import(Path.join(sdlRoot, '/scripts/build.mjs'))
|
|
22
|
+
const sdlDist = Path.join(sdlRoot, 'dist')
|
|
23
|
+
await Promise.all([
|
|
24
|
+
Fs.promises.cp(
|
|
25
|
+
Path.join(sdlDist, 'include'),
|
|
26
|
+
Path.join(C.dir.sdl, 'include'),
|
|
27
|
+
{ recursive: true },
|
|
28
|
+
),
|
|
29
|
+
Fs.promises.cp(
|
|
30
|
+
Path.join(sdlDist, 'lib'),
|
|
31
|
+
Path.join(C.dir.sdl, 'lib'),
|
|
32
|
+
{ recursive: true },
|
|
33
|
+
),
|
|
34
|
+
])
|
package/scripts/install.mjs
CHANGED
|
@@ -10,5 +10,11 @@ if (!process.env.NODE_SDL_FROM_SOURCE) {
|
|
|
10
10
|
console.log("skip download and build from source")
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
try {
|
|
14
|
+
await import('./download-sdl.mjs')
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.log("failed to download sdl")
|
|
17
|
+
await import('./build-sdl.mjs')
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
await import('./build.mjs')
|
|
@@ -27,9 +27,9 @@ const mouse = {
|
|
|
27
27
|
},
|
|
28
28
|
|
|
29
29
|
setCursor (cursor) {
|
|
30
|
-
const _cursor = Enums.cursor[cursor]
|
|
30
|
+
const _cursor = Enums.cursor[cursor] ?? null
|
|
31
31
|
if (typeof cursor !== 'string') { throw Object.assign(new Error("cursor must be a string"), { cursor }) }
|
|
32
|
-
if (
|
|
32
|
+
if (_cursor === null) { throw Object.assign(new Error("invalid cursor"), { cursor }) }
|
|
33
33
|
|
|
34
34
|
Bindings.mouse_setCursor(_cursor)
|
|
35
35
|
},
|