@bobfrankston/msger 0.1.15 → 0.1.20
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/index.js +19 -1
- package/index.js.map +1 -1
- package/index.ts +23 -1
- package/msger-native/build.ts +1 -1
- package/package.json +2 -1
- package/postinstall.d.ts +3 -0
- package/postinstall.js +25 -0
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import { platform } from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
4
5
|
/**
|
|
5
6
|
* Show a message box dialog using native Rust implementation
|
|
6
7
|
* @param options Message box configuration
|
|
@@ -8,9 +9,26 @@ import path from 'path';
|
|
|
8
9
|
*/
|
|
9
10
|
export async function showMessageBox(options) {
|
|
10
11
|
return new Promise((resolve, reject) => {
|
|
12
|
+
const isWindows = platform() === 'win32';
|
|
11
13
|
// Determine the binary name based on platform
|
|
12
|
-
const binaryName =
|
|
14
|
+
const binaryName = isWindows ? 'msgernative.exe' : 'msgernative';
|
|
13
15
|
const binaryPath = path.join(import.meta.dirname, 'msger-native', 'bin', binaryName);
|
|
16
|
+
// Check if binary exists
|
|
17
|
+
if (!fs.existsSync(binaryPath)) {
|
|
18
|
+
reject(new Error(`Binary not found: ${binaryPath}`));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// On Unix systems, check if binary is executable
|
|
22
|
+
if (!isWindows) {
|
|
23
|
+
try {
|
|
24
|
+
fs.accessSync(binaryPath, fs.constants.X_OK);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
reject(new Error(`Binary is not executable: ${binaryPath}\n` +
|
|
28
|
+
`Please run: sudo chmod +x ${binaryPath}`));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
14
32
|
// Spawn the Rust binary
|
|
15
33
|
const child = spawn(binaryPath, [], {
|
|
16
34
|
stdio: ['pipe', 'pipe', 'pipe']
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAwBpB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAA0B;IAC3D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,SAAS,GAAG,QAAQ,EAAE,KAAK,OAAO,CAAC;QAEzC,8CAA8C;QAC9C,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;QACjE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;QAErF,yBAAyB;QACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC,CAAC;YACrD,OAAO;QACX,CAAC;QAED,iDAAiD;QACjD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,IAAI,CAAC;gBACD,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,SAAS,CAAC,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AAC,OAAO,aAAa,MAAM,EAAE,CAAC,CAAC,CAAC;YACrF,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,wBAAwB;QACxB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACxB,MAAM,CAAC,IAAI,KAAK,CAAC,0BAA0B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,wBAAwB;QACxB,IAAI,CAAC;YACD,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACtB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED,6CAA6C;AAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACnB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IACtD,MAAM,OAAO,EAAE,CAAC;AACpB,CAAC"}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import { platform } from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
4
5
|
|
|
5
6
|
export interface MessageBoxOptions {
|
|
6
7
|
title?: string;
|
|
@@ -31,10 +32,31 @@ export interface MessageBoxResult {
|
|
|
31
32
|
*/
|
|
32
33
|
export async function showMessageBox(options: MessageBoxOptions): Promise<MessageBoxResult> {
|
|
33
34
|
return new Promise((resolve, reject) => {
|
|
35
|
+
const isWindows = platform() === 'win32';
|
|
36
|
+
|
|
34
37
|
// Determine the binary name based on platform
|
|
35
|
-
const binaryName =
|
|
38
|
+
const binaryName = isWindows ? 'msgernative.exe' : 'msgernative';
|
|
36
39
|
const binaryPath = path.join(import.meta.dirname, 'msger-native', 'bin', binaryName);
|
|
37
40
|
|
|
41
|
+
// Check if binary exists
|
|
42
|
+
if (!fs.existsSync(binaryPath)) {
|
|
43
|
+
reject(new Error(`Binary not found: ${binaryPath}`));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// On Unix systems, check if binary is executable
|
|
48
|
+
if (!isWindows) {
|
|
49
|
+
try {
|
|
50
|
+
fs.accessSync(binaryPath, fs.constants.X_OK);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
reject(new Error(
|
|
53
|
+
`Binary is not executable: ${binaryPath}\n` +
|
|
54
|
+
`Please run: sudo chmod +x ${binaryPath}`
|
|
55
|
+
));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
38
60
|
// Spawn the Rust binary
|
|
39
61
|
const child = spawn(binaryPath, [], {
|
|
40
62
|
stdio: ['pipe', 'pipe', 'pipe']
|
package/msger-native/build.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { execSync } from 'child_process';
|
|
4
4
|
import { platform, arch } from 'os';
|
|
5
|
-
import { existsSync, mkdirSync, copyFileSync, readFileSync, statSync } from 'fs';
|
|
5
|
+
import { existsSync, mkdirSync, copyFileSync, readFileSync, statSync, chmodSync } from 'fs';
|
|
6
6
|
|
|
7
7
|
function isWSL() {
|
|
8
8
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/msger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "Fast, lightweight, cross-platform message box - Rust-powered alternative to msgview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"watch": "tsc -w",
|
|
23
23
|
"clean": "rm -rf *.js *.d.ts *.js.map bin && cd msger-native && cargo clean",
|
|
24
24
|
"test": "node test.js",
|
|
25
|
+
"postinstall": "node postinstall.js",
|
|
25
26
|
"prepublishOnly": "npm run build:ts && npm run build:native:all",
|
|
26
27
|
"prerelease:local": "git add -A && (git diff-index --quiet HEAD || git commit -m \"Pre-release commit\")",
|
|
27
28
|
"preversion": "npm run build:ts && npm run build:native:all && git add -A",
|
package/postinstall.d.ts
ADDED
package/postinstall.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const isWindows = process.platform === 'win32';
|
|
10
|
+
|
|
11
|
+
if (!isWindows) {
|
|
12
|
+
const binaryPath = path.join(__dirname, 'msger-native', 'bin', 'msgernative');
|
|
13
|
+
|
|
14
|
+
if (fs.existsSync(binaryPath)) {
|
|
15
|
+
try {
|
|
16
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
17
|
+
console.log('✅ Set execute permissions on msgernative binary');
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.warn(`⚠️ Could not set execute permission on ${binaryPath}: ${error.message}`);
|
|
20
|
+
console.warn(' You may need to run: sudo chmod +x ${binaryPath}');
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
console.warn(`⚠️ Binary not found at ${binaryPath}`);
|
|
24
|
+
}
|
|
25
|
+
}
|