@ojes94/socket 1.0.1 → 1.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/bin/ssc.mjs +65 -0
- package/package.json +3 -3
package/bin/ssc.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { fork } from 'node:child_process'
|
|
4
|
+
import path from 'node:path'
|
|
5
|
+
import os from 'node:os'
|
|
6
|
+
|
|
7
|
+
const dirname = path.dirname(import.meta.url).replace(`file://${os.platform() === 'win32' ? '/' : ''}`, '')
|
|
8
|
+
|
|
9
|
+
let exiting = false
|
|
10
|
+
|
|
11
|
+
export async function load () {
|
|
12
|
+
const platform = os.platform()
|
|
13
|
+
const arch = os.arch()
|
|
14
|
+
const info = await import(`@ojes94/socket-${platform}-${arch}`)
|
|
15
|
+
return info?.default ?? info ?? null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function main () {
|
|
19
|
+
const installation = await load()
|
|
20
|
+
const args = process.argv.slice(2)
|
|
21
|
+
const env = {
|
|
22
|
+
...installation.env,
|
|
23
|
+
SOCKET_HOME_API: path.dirname(dirname),
|
|
24
|
+
...process.env
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof installation.firstTimeExperienceSetup === 'function' && !await installation.firstTimeExperienceSetup()) {
|
|
28
|
+
// FTE not completed satisfactorally, or 'setup' was ran externally
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const child = fork(installation.bin['ssc-platform'], args, {
|
|
33
|
+
env,
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
windowsHide: true
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
child.once('exit', (code) => {
|
|
39
|
+
if (!exiting) {
|
|
40
|
+
exiting = true
|
|
41
|
+
process.exit(code)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
child.once('error', (err) => {
|
|
46
|
+
console.error(err.message)
|
|
47
|
+
if (!exiting) {
|
|
48
|
+
exiting = true
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
process.on('SIGTERM', () => {
|
|
54
|
+
child.kill('SIGTERM')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
process.on('exit', () => {
|
|
58
|
+
child.kill('SIGTERM')
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
main().catch((err) => {
|
|
63
|
+
console.error(err)
|
|
64
|
+
process.exit(1)
|
|
65
|
+
})
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ojes94/socket",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A Cross-Platform, Native Runtime for Desktop and Mobile Apps — Create apps using HTML, CSS, and JavaScript. Written from the ground up to be small and maintainable.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"ssc": "./
|
|
9
|
+
"ssc": "./bin/ssc.mjs"
|
|
10
10
|
},
|
|
11
11
|
"os": [
|
|
12
12
|
"linux",
|
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
"@ojes94/socket-linux-x64": "1.0.0",
|
|
46
46
|
"@ojes94/socket-win32-x64": "1.0.0"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|