@bobfrankston/msger 0.1.158 → 0.1.159
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/cli.js +8 -0
- package/cli.ts +8 -1
- package/package.json +2 -1
- package/bbt.json +0 -10
- package/cli.d.ts +0 -2
- package/cruft/apply-zoom-fix.js +0 -105
- package/cruft/build.js +0 -99
- package/cruft/clean.d.ts +0 -3
- package/cruft/clean.js +0 -71
- package/cruft/msgerdefs/msgerdefs.d.ts +0 -321
- package/cruft/msgerdefs/msgerdefs.js +0 -109
- package/cruft/msgernative-win32-x64.exe +0 -0
- package/cruft/postinstall.js +0 -66
- package/cruft/test-size.d.ts +0 -2
- package/index.d.ts +0 -1
- package/index.js +0 -9
- package/msger-native/bin/msgernative.exe +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Extension Rules/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Extension Scripts/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Extension State/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Local Storage/leveldb/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Service Worker/Database/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Session Storage/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Site Characteristics Database/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/Sync Data/LevelDB/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/favorites_diagnostic.log +0 -100
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Default/shared_proto_db/metadata/000003.log +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Domain Actions/3.0.0.16/domain_actions.dll +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Speech Recognition/1.15.0.1/Microsoft.CognitiveServices.Speech.core.dll +0 -0
- package/msger-native/bin/msgernative.exe.WebView2/EBWebView/Subresource Filter/Unindexed Rules/10.34.0.81/adblock_snippet.js +0 -1
- package/msger-native/builder/postinstall.js +0 -107
- package/msger-native/src/msger-api.js +0 -256
- package/nul +0 -1
- package/shower.d.ts +0 -69
- package/shower.js +0 -264
- package/test-handle.d.mts +0 -2
- package/test.json +0 -11
- package/tests/demo-ansi-colors.js +0 -104
- package/tests/test-ansi-cli.js +0 -38
- package/tests/test-ansi-colors.js +0 -34
- package/tests/test-ansi-escaping.js +0 -15
- package/tests/test-ansi-simple.js +0 -15
- package/tests/test-escape-key.js +0 -20
- package/tests/test-node-dot.js +0 -14
- package/tests/test-plain-and-ansi.js +0 -24
- package/tests/test-size.js +0 -27
package/cli.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
//
|
|
3
|
+
// TODO: Migrate to use @bobfrankston/msgcommon for argument parsing
|
|
4
|
+
// Example:
|
|
5
|
+
// import { parseCommonArgs } from '@bobfrankston/msgcommon';
|
|
6
|
+
// const { options, messageWords, showHelp, showVersion } = parseCommonArgs(args);
|
|
7
|
+
//
|
|
2
8
|
import { showMessageBox } from './shower.js';
|
|
3
9
|
import packageJson from './package.json' with { type: 'json' };
|
|
4
10
|
import fs from 'fs';
|
|
5
11
|
import path from 'path';
|
|
6
12
|
import { execSync } from 'child_process';
|
|
7
13
|
import JSON5 from 'json5';
|
|
14
|
+
// Uncomment when ready to migrate:
|
|
15
|
+
// import { parseCommonArgs } from '@bobfrankston/msgcommon';
|
|
8
16
|
export default async function main() {
|
|
9
17
|
const args = process.argv.slice(2);
|
|
10
18
|
// No arguments - show help
|
package/cli.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
//
|
|
3
|
+
// TODO: Migrate to use @bobfrankston/msgcommon for argument parsing
|
|
4
|
+
// Example:
|
|
5
|
+
// import { parseCommonArgs } from '@bobfrankston/msgcommon';
|
|
6
|
+
// const { options, messageWords, showHelp, showVersion } = parseCommonArgs(args);
|
|
7
|
+
//
|
|
3
8
|
import { showMessageBox, MessageBoxOptions } from './shower.js';
|
|
4
9
|
import packageJson from './package.json' with { type: 'json' };
|
|
5
10
|
import fs from 'fs';
|
|
6
11
|
import path from 'path';
|
|
7
12
|
import { execSync } from 'child_process';
|
|
8
13
|
import JSON5 from 'json5';
|
|
14
|
+
// Uncomment when ready to migrate:
|
|
15
|
+
// import { parseCommonArgs } from '@bobfrankston/msgcommon';
|
|
9
16
|
|
|
10
17
|
export default async function main() {
|
|
11
18
|
const args = process.argv.slice(2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/msger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.159",
|
|
4
4
|
"description": "Fast, lightweight, cross-platform message box - Rust-powered alternative to msgview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@types/node": "^24.9.1"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
+
"@bobfrankston/msgcommon": "^0.1.0",
|
|
54
55
|
"ansi-to-html": "^0.7.2",
|
|
55
56
|
"json5": "^2.2.3"
|
|
56
57
|
}
|
package/bbt.json
DELETED
package/cli.d.ts
DELETED
package/cruft/apply-zoom-fix.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
|
|
6
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const filePath = path.join(__dirname, 'src', 'main.rs');
|
|
8
|
-
let content = fs.readFileSync(filePath, 'utf8');
|
|
9
|
-
|
|
10
|
-
console.log('Applying zoom and right-click fixes to main.rs...');
|
|
11
|
-
|
|
12
|
-
// 1. Add zoom JavaScript
|
|
13
|
-
const oldKeydown = ` document.addEventListener('keydown', function(e) {{
|
|
14
|
-
if (e.key === 'Escape') {{
|
|
15
|
-
const result = {{ button: '{}', dismissed: true }};
|
|
16
|
-
window.ipc.postMessage(JSON.stringify(result));
|
|
17
|
-
}} else if (e.key === 'Enter') {{
|
|
18
|
-
const buttons = document.querySelectorAll('button');
|
|
19
|
-
if (buttons.length > 0) {{
|
|
20
|
-
buttons[buttons.length - 1].click();
|
|
21
|
-
}}
|
|
22
|
-
}}
|
|
23
|
-
}});`;
|
|
24
|
-
|
|
25
|
-
const newKeydownWithZoom = ` // Zoom support with mouse wheel
|
|
26
|
-
let zoomLevel = 1.0;
|
|
27
|
-
document.addEventListener('wheel', function(e) {{
|
|
28
|
-
// Only zoom when Ctrl is held (or Cmd on Mac)
|
|
29
|
-
if (e.ctrlKey || e.metaKey) {{
|
|
30
|
-
e.preventDefault();
|
|
31
|
-
|
|
32
|
-
// Zoom in/out based on wheel direction
|
|
33
|
-
if (e.deltaY < 0) {{
|
|
34
|
-
zoomLevel = Math.min(zoomLevel + 0.1, 3.0); // Max 300%
|
|
35
|
-
}} else {{
|
|
36
|
-
zoomLevel = Math.max(zoomLevel - 0.1, 0.5); // Min 50%
|
|
37
|
-
}}
|
|
38
|
-
|
|
39
|
-
document.body.style.zoom = zoomLevel;
|
|
40
|
-
}}
|
|
41
|
-
}}, {{ passive: false }});
|
|
42
|
-
|
|
43
|
-
document.addEventListener('keydown', function(e) {{
|
|
44
|
-
if (e.key === 'Escape') {{
|
|
45
|
-
const result = {{ button: '{}', dismissed: true }};
|
|
46
|
-
window.ipc.postMessage(JSON.stringify(result));
|
|
47
|
-
}} else if (e.key === 'Enter') {{
|
|
48
|
-
const buttons = document.querySelectorAll('button');
|
|
49
|
-
if (buttons.length > 0) {{
|
|
50
|
-
buttons[buttons.length - 1].click();
|
|
51
|
-
}}
|
|
52
|
-
}} else if ((e.ctrlKey || e.metaKey) && e.key === '0') {{
|
|
53
|
-
// Reset zoom with Ctrl+0
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
zoomLevel = 1.0;
|
|
56
|
-
document.body.style.zoom = zoomLevel;
|
|
57
|
-
}} else if ((e.ctrlKey || e.metaKey) && (e.key === '+' || e.key === '=')) {{
|
|
58
|
-
// Zoom in with Ctrl++
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
zoomLevel = Math.min(zoomLevel + 0.1, 3.0);
|
|
61
|
-
document.body.style.zoom = zoomLevel;
|
|
62
|
-
}} else if ((e.ctrlKey || e.metaKey) && e.key === '-') {{
|
|
63
|
-
// Zoom out with Ctrl+-
|
|
64
|
-
e.preventDefault();
|
|
65
|
-
zoomLevel = Math.max(zoomLevel - 0.1, 0.5);
|
|
66
|
-
document.body.style.zoom = zoomLevel;
|
|
67
|
-
}}
|
|
68
|
-
}});`;
|
|
69
|
-
|
|
70
|
-
if (content.includes('let zoomLevel')) {
|
|
71
|
-
console.log('- Zoom already added');
|
|
72
|
-
} else {
|
|
73
|
-
content = content.replace(oldKeydown, newKeydownWithZoom);
|
|
74
|
-
console.log('✓ Added zoom JavaScript');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 2. Add devtools to URL WebViewBuilder
|
|
78
|
-
content = content.replace(
|
|
79
|
-
/WebViewBuilder::new\(\)\s+\.with_url\(url\)\s+\.with_ipc_handler/,
|
|
80
|
-
`WebViewBuilder::new()
|
|
81
|
-
.with_url(url)
|
|
82
|
-
.with_devtools(true)
|
|
83
|
-
.with_ipc_handler`
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// 3. Add devtools to HTML WebViewBuilder
|
|
87
|
-
content = content.replace(
|
|
88
|
-
/WebViewBuilder::new\(\)\s+\.with_html\(&html\)\s+\.with_ipc_handler/,
|
|
89
|
-
`WebViewBuilder::new()
|
|
90
|
-
.with_html(&html)
|
|
91
|
-
.with_devtools(true)
|
|
92
|
-
.with_ipc_handler`
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
console.log('✓ Added .with_devtools(true) to WebViewBuilders');
|
|
96
|
-
|
|
97
|
-
// Write the file
|
|
98
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
99
|
-
console.log('\n✅ All changes applied to main.rs');
|
|
100
|
-
console.log('\nNext steps:');
|
|
101
|
-
console.log('1. cd msger-native');
|
|
102
|
-
console.log('2. cargo build --release');
|
|
103
|
-
console.log('3. copy target\\release\\msgernative.exe bin\\');
|
|
104
|
-
console.log('4. Test: msger -url http://localhost:9299 -title Test -detach');
|
|
105
|
-
console.log('5. Try: Ctrl+Scroll to zoom, Right-click for menu');
|
package/cruft/build.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { execSync } from 'child_process';
|
|
4
|
-
import { platform, arch } from 'os';
|
|
5
|
-
import { existsSync, mkdirSync, copyFileSync, readFileSync, statSync } from 'fs';
|
|
6
|
-
|
|
7
|
-
function isWSL() {
|
|
8
|
-
try {
|
|
9
|
-
const release = readFileSync('/proc/version', 'utf8');
|
|
10
|
-
return release.toLowerCase().includes('microsoft');
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function isWindows() {
|
|
17
|
-
return platform() === 'win32' && !isWSL();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function runCommand(cmd, description) {
|
|
21
|
-
console.log(`\n📦 ${description}...`);
|
|
22
|
-
try {
|
|
23
|
-
execSync(cmd, { stdio: 'inherit' });
|
|
24
|
-
console.log(`✅ ${description} completed`);
|
|
25
|
-
return true;
|
|
26
|
-
} catch (error) {
|
|
27
|
-
console.error(`❌ ${description} failed:`, error.message);
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function main() {
|
|
33
|
-
console.log('🚀 Building msger (Rust)...');
|
|
34
|
-
|
|
35
|
-
if (isWindows()) {
|
|
36
|
-
console.log('📍 Running on Windows');
|
|
37
|
-
|
|
38
|
-
// Try building with cargo directly first
|
|
39
|
-
// Cargo should find the VS linker if available
|
|
40
|
-
const success = runCommand('cargo build --release', 'Building Windows x64 binary (release)');
|
|
41
|
-
|
|
42
|
-
if (success) {
|
|
43
|
-
// Copy binary to bin directory for easy access
|
|
44
|
-
const binDir = './bin';
|
|
45
|
-
if (!existsSync(binDir)) {
|
|
46
|
-
mkdirSync(binDir, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const exeName = 'msger.exe';
|
|
50
|
-
const srcPath = `./target/release/${exeName}`;
|
|
51
|
-
const destPath = `${binDir}/${exeName}`;
|
|
52
|
-
|
|
53
|
-
if (existsSync(srcPath)) {
|
|
54
|
-
copyFileSync(srcPath, destPath);
|
|
55
|
-
console.log(`\n✅ Binary copied to: ${destPath}`);
|
|
56
|
-
|
|
57
|
-
// Show file size
|
|
58
|
-
const stats = statSync(destPath);
|
|
59
|
-
const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
|
|
60
|
-
console.log(`📊 Binary size: ${sizeMB} MB`);
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
console.log('\n⚠️ Build failed. You may need to:');
|
|
64
|
-
console.log(' 1. Open "x64 Native Tools Command Prompt for VS 2022"');
|
|
65
|
-
console.log(' 2. Run: cd Y:\\dev\\utils\\msger && cargo build --release');
|
|
66
|
-
console.log(' 3. Or install Visual Studio Build Tools with C++ workload');
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
} else if (isWSL()) {
|
|
71
|
-
console.log('📍 Running on WSL');
|
|
72
|
-
console.log('🐧 Building Linux x64 binary...');
|
|
73
|
-
|
|
74
|
-
const success = runCommand('cargo build --release', 'Building Linux x64 binary');
|
|
75
|
-
|
|
76
|
-
if (success) {
|
|
77
|
-
const binDir = './bin';
|
|
78
|
-
if (!existsSync(binDir)) {
|
|
79
|
-
mkdirSync(binDir, { recursive: true });
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const exeName = 'msger';
|
|
83
|
-
const srcPath = `./target/release/${exeName}`;
|
|
84
|
-
const destPath = `${binDir}/${exeName}`;
|
|
85
|
-
|
|
86
|
-
if (existsSync(srcPath)) {
|
|
87
|
-
copyFileSync(srcPath, destPath);
|
|
88
|
-
console.log(`\n✅ Binary copied to: ${destPath}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
console.log('📍 Running on Linux/macOS');
|
|
93
|
-
runCommand('cargo build --release', 'Building native binary');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
console.log('\n🎉 Build process completed!');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
main();
|
package/cruft/clean.d.ts
DELETED
package/cruft/clean.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Cross-platform clean script
|
|
4
|
-
* Removes build artifacts
|
|
5
|
-
*/
|
|
6
|
-
import fs from 'fs';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { execSync } from 'child_process';
|
|
9
|
-
const rootDir = process.cwd();
|
|
10
|
-
console.log('🧹 Cleaning build artifacts...\n');
|
|
11
|
-
// Files to delete in root directory
|
|
12
|
-
const rootPatterns = [
|
|
13
|
-
'*.js',
|
|
14
|
-
'*.d.ts',
|
|
15
|
-
'*.d.ts.map',
|
|
16
|
-
'*.js.map'
|
|
17
|
-
];
|
|
18
|
-
// Directories to exclude
|
|
19
|
-
const excludeDirs = ['node_modules', '.git', 'msger-native'];
|
|
20
|
-
function deleteFile(filePath) {
|
|
21
|
-
try {
|
|
22
|
-
fs.unlinkSync(filePath);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function matchesPattern(filename, pattern) {
|
|
30
|
-
const regex = new RegExp('^' + pattern.replace(/\*/g, '.*').replace(/\./g, '\\.') + '$');
|
|
31
|
-
return regex.test(filename);
|
|
32
|
-
}
|
|
33
|
-
// Clean root directory
|
|
34
|
-
let deletedCount = 0;
|
|
35
|
-
const files = fs.readdirSync(rootDir);
|
|
36
|
-
for (const file of files) {
|
|
37
|
-
const filePath = path.join(rootDir, file);
|
|
38
|
-
const stat = fs.statSync(filePath);
|
|
39
|
-
if (stat.isDirectory())
|
|
40
|
-
continue;
|
|
41
|
-
for (const pattern of rootPatterns) {
|
|
42
|
-
if (matchesPattern(file, pattern)) {
|
|
43
|
-
if (deleteFile(filePath)) {
|
|
44
|
-
console.log(` ✓ Deleted: ${file}`);
|
|
45
|
-
deletedCount++;
|
|
46
|
-
}
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
console.log(`\n📁 Cleaned ${deletedCount} files from root directory`);
|
|
52
|
-
// Clean Rust build artifacts
|
|
53
|
-
console.log('\n🦀 Cleaning Rust build artifacts...');
|
|
54
|
-
const nativeDir = path.join(rootDir, 'msger-native');
|
|
55
|
-
if (fs.existsSync(nativeDir)) {
|
|
56
|
-
try {
|
|
57
|
-
execSync('cargo clean', {
|
|
58
|
-
cwd: nativeDir,
|
|
59
|
-
stdio: 'inherit'
|
|
60
|
-
});
|
|
61
|
-
console.log(' ✓ Rust artifacts cleaned');
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
console.error(' ✗ Failed to run cargo clean');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
console.log(' ⚠️ msger-native directory not found');
|
|
69
|
-
}
|
|
70
|
-
console.log('\n✨ Clean complete!\n');
|
|
71
|
-
//# sourceMappingURL=clean.js.map
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript definitions for the msger JavaScript API
|
|
3
|
-
*
|
|
4
|
-
* This module provides type-safe access to msger's window control,
|
|
5
|
-
* data persistence, and file system features.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import type { MsgerAPI } from '@bobfrankston/msgerdefs';
|
|
10
|
-
*
|
|
11
|
-
* declare global {
|
|
12
|
-
* interface Window {
|
|
13
|
-
* msger?: MsgerAPI;
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* // Check if running in msger
|
|
18
|
-
* if (window.msger) {
|
|
19
|
-
* window.msger.setTitle('My App');
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Result object returned when the window closes
|
|
25
|
-
*/
|
|
26
|
-
export interface MsgerResult {
|
|
27
|
-
/** Button that was clicked */
|
|
28
|
-
button: string;
|
|
29
|
-
/** Optional input field value */
|
|
30
|
-
value?: string;
|
|
31
|
-
/** Optional form data */
|
|
32
|
-
form?: Record<string, any>;
|
|
33
|
-
/** True if window was closed via close button */
|
|
34
|
-
closed?: boolean;
|
|
35
|
-
/** True if window was dismissed via Escape key */
|
|
36
|
-
dismissed?: boolean;
|
|
37
|
-
/** True if window was closed due to timeout */
|
|
38
|
-
timeout?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* File information returned by file system operations
|
|
42
|
-
*/
|
|
43
|
-
export interface FileInfo {
|
|
44
|
-
/** File name */
|
|
45
|
-
name: string;
|
|
46
|
-
/** Full file path */
|
|
47
|
-
path: string;
|
|
48
|
-
/** True if this is a directory */
|
|
49
|
-
isDir: boolean;
|
|
50
|
-
/** File size in bytes (0 for directories) */
|
|
51
|
-
size: number;
|
|
52
|
-
/** Last modified timestamp (ISO 8601 string) */
|
|
53
|
-
modified?: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Options for file selection dialogs
|
|
57
|
-
*/
|
|
58
|
-
export interface FileDialogOptions {
|
|
59
|
-
/** Dialog title */
|
|
60
|
-
title?: string;
|
|
61
|
-
/** Default filename for save dialogs */
|
|
62
|
-
defaultFilename?: string;
|
|
63
|
-
/** File filters (e.g., [{name: "Text", extensions: ["txt", "md"]}]) */
|
|
64
|
-
filters?: Array<{
|
|
65
|
-
name: string;
|
|
66
|
-
extensions: string[];
|
|
67
|
-
}>;
|
|
68
|
-
/** Default directory to open */
|
|
69
|
-
defaultPath?: string;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Selected file with content
|
|
73
|
-
*/
|
|
74
|
-
export interface SelectedFile {
|
|
75
|
-
/** File name */
|
|
76
|
-
name: string;
|
|
77
|
-
/** Full file path */
|
|
78
|
-
path: string;
|
|
79
|
-
/** File content as string */
|
|
80
|
-
content: string;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* msger JavaScript API
|
|
84
|
-
*
|
|
85
|
-
* Available when running inside msger via window.msger
|
|
86
|
-
*/
|
|
87
|
-
export interface MsgerAPI {
|
|
88
|
-
/**
|
|
89
|
-
* Toggle fullscreen mode on/off
|
|
90
|
-
* @example
|
|
91
|
-
* msger.toggleFullscreen();
|
|
92
|
-
*/
|
|
93
|
-
toggleFullscreen(): void;
|
|
94
|
-
/**
|
|
95
|
-
* Set fullscreen mode
|
|
96
|
-
* @param enabled - true to enter fullscreen, false to exit
|
|
97
|
-
* @example
|
|
98
|
-
* msger.setFullscreen(true);
|
|
99
|
-
*/
|
|
100
|
-
setFullscreen(enabled: boolean): void;
|
|
101
|
-
/**
|
|
102
|
-
* Minimize the window
|
|
103
|
-
* @example
|
|
104
|
-
* msger.minimize();
|
|
105
|
-
*/
|
|
106
|
-
minimize(): void;
|
|
107
|
-
/**
|
|
108
|
-
* Toggle maximize/restore window
|
|
109
|
-
* @example
|
|
110
|
-
* msger.maximize();
|
|
111
|
-
*/
|
|
112
|
-
maximize(): void;
|
|
113
|
-
/**
|
|
114
|
-
* Set window size
|
|
115
|
-
* @param width - Window width in pixels
|
|
116
|
-
* @param height - Window height in pixels
|
|
117
|
-
* @example
|
|
118
|
-
* msger.setSize(800, 600);
|
|
119
|
-
*/
|
|
120
|
-
setSize(width: number, height: number): void;
|
|
121
|
-
/**
|
|
122
|
-
* Set window position
|
|
123
|
-
* @param x - X coordinate in pixels
|
|
124
|
-
* @param y - Y coordinate in pixels
|
|
125
|
-
* @example
|
|
126
|
-
* msger.setPosition(100, 100);
|
|
127
|
-
*/
|
|
128
|
-
setPosition(x: number, y: number): void;
|
|
129
|
-
/**
|
|
130
|
-
* Set always-on-top behavior
|
|
131
|
-
* @param enabled - true to keep window on top
|
|
132
|
-
* @example
|
|
133
|
-
* msger.setAlwaysOnTop(true);
|
|
134
|
-
*/
|
|
135
|
-
setAlwaysOnTop(enabled: boolean): void;
|
|
136
|
-
/**
|
|
137
|
-
* Set window title
|
|
138
|
-
* @param title - New window title
|
|
139
|
-
* @example
|
|
140
|
-
* msger.setTitle("My Application");
|
|
141
|
-
*/
|
|
142
|
-
setTitle(title: string): void;
|
|
143
|
-
/**
|
|
144
|
-
* Close the window
|
|
145
|
-
* @param result - Optional result to return to parent process
|
|
146
|
-
* @example
|
|
147
|
-
* // Close with default dismissed result
|
|
148
|
-
* msger.close();
|
|
149
|
-
*
|
|
150
|
-
* // Close with custom result
|
|
151
|
-
* msger.close({button: 'OK', value: 'user data'});
|
|
152
|
-
*/
|
|
153
|
-
close(result?: Partial<MsgerResult>): void;
|
|
154
|
-
/**
|
|
155
|
-
* Send result and close window (legacy compatibility)
|
|
156
|
-
* @param result - Result to return to parent process
|
|
157
|
-
* @example
|
|
158
|
-
* msger.sendResult({button: 'Submit', value: 'form data'});
|
|
159
|
-
*/
|
|
160
|
-
sendResult(result: Partial<MsgerResult>): void;
|
|
161
|
-
/**
|
|
162
|
-
* Save data to persistent storage
|
|
163
|
-
* Data is stored with 'msger_' prefix in localStorage
|
|
164
|
-
* @param key - Storage key
|
|
165
|
-
* @param value - Value to store (will be JSON.stringify'd)
|
|
166
|
-
* @returns true on success, false on failure
|
|
167
|
-
* @example
|
|
168
|
-
* msger.saveData('userPrefs', {theme: 'dark', fontSize: 14});
|
|
169
|
-
*/
|
|
170
|
-
saveData(key: string, value: any): boolean;
|
|
171
|
-
/**
|
|
172
|
-
* Load data from persistent storage
|
|
173
|
-
* @param key - Storage key
|
|
174
|
-
* @param defaultValue - Default value if key not found
|
|
175
|
-
* @returns Stored value or defaultValue
|
|
176
|
-
* @example
|
|
177
|
-
* const prefs = msger.loadData('userPrefs', {theme: 'light'});
|
|
178
|
-
*/
|
|
179
|
-
loadData<T = any>(key: string, defaultValue?: T): T;
|
|
180
|
-
/**
|
|
181
|
-
* Remove data from persistent storage
|
|
182
|
-
* @param key - Storage key to remove
|
|
183
|
-
* @returns true on success, false on failure
|
|
184
|
-
* @example
|
|
185
|
-
* msger.removeData('tempData');
|
|
186
|
-
*/
|
|
187
|
-
removeData(key: string): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Clear all msger data from persistent storage
|
|
190
|
-
* Only removes items with 'msger_' prefix
|
|
191
|
-
* @returns true on success, false on failure
|
|
192
|
-
* @example
|
|
193
|
-
* msger.clearData();
|
|
194
|
-
*/
|
|
195
|
-
clearData(): boolean;
|
|
196
|
-
/**
|
|
197
|
-
* File system operations namespace
|
|
198
|
-
*/
|
|
199
|
-
fs?: {
|
|
200
|
-
/**
|
|
201
|
-
* Select a file using native file picker
|
|
202
|
-
* @param options - File dialog options
|
|
203
|
-
* @returns Selected file with content, or null if cancelled
|
|
204
|
-
* @example
|
|
205
|
-
* const file = await msger.fs.selectFile({
|
|
206
|
-
* title: 'Open File',
|
|
207
|
-
* filters: [{name: 'Text', extensions: ['txt', 'md']}]
|
|
208
|
-
* });
|
|
209
|
-
* if (file) {
|
|
210
|
-
* console.log(file.content);
|
|
211
|
-
* }
|
|
212
|
-
*/
|
|
213
|
-
selectFile(options?: FileDialogOptions): Promise<SelectedFile | null>;
|
|
214
|
-
/**
|
|
215
|
-
* Select multiple files using native file picker
|
|
216
|
-
* @param options - File dialog options
|
|
217
|
-
* @returns Array of selected files with content
|
|
218
|
-
* @example
|
|
219
|
-
* const files = await msger.fs.selectFiles({
|
|
220
|
-
* title: 'Open Files'
|
|
221
|
-
* });
|
|
222
|
-
*/
|
|
223
|
-
selectFiles(options?: FileDialogOptions): Promise<SelectedFile[]>;
|
|
224
|
-
/**
|
|
225
|
-
* Save file using native save dialog
|
|
226
|
-
* @param content - File content to save
|
|
227
|
-
* @param defaultFilename - Default filename
|
|
228
|
-
* @param options - Additional dialog options
|
|
229
|
-
* @returns Path where file was saved, or null if cancelled
|
|
230
|
-
* @example
|
|
231
|
-
* const path = await msger.fs.saveFileAs('Hello World', 'greeting.txt');
|
|
232
|
-
*/
|
|
233
|
-
saveFileAs(content: string, defaultFilename?: string, options?: FileDialogOptions): Promise<string | null>;
|
|
234
|
-
/**
|
|
235
|
-
* Select a directory using native folder picker
|
|
236
|
-
* @param options - Dialog options
|
|
237
|
-
* @returns Selected directory path, or null if cancelled
|
|
238
|
-
* @example
|
|
239
|
-
* const dir = await msger.fs.selectFolder({
|
|
240
|
-
* title: 'Select Output Folder'
|
|
241
|
-
* });
|
|
242
|
-
*/
|
|
243
|
-
selectFolder(options?: FileDialogOptions): Promise<string | null>;
|
|
244
|
-
/**
|
|
245
|
-
* Read file contents
|
|
246
|
-
* Note: Requires allowFs: true flag when launching msger
|
|
247
|
-
* @param path - File path to read
|
|
248
|
-
* @returns File content as string
|
|
249
|
-
* @example
|
|
250
|
-
* const content = await msger.fs.read('/path/to/file.txt');
|
|
251
|
-
*/
|
|
252
|
-
read(path: string): Promise<string>;
|
|
253
|
-
/**
|
|
254
|
-
* Write file contents
|
|
255
|
-
* Note: Requires allowFs: true flag when launching msger
|
|
256
|
-
* @param path - File path to write
|
|
257
|
-
* @param content - Content to write
|
|
258
|
-
* @example
|
|
259
|
-
* await msger.fs.write('/path/to/file.txt', 'Hello World');
|
|
260
|
-
*/
|
|
261
|
-
write(path: string, content: string): Promise<void>;
|
|
262
|
-
/**
|
|
263
|
-
* List directory contents
|
|
264
|
-
* Note: Requires allowFs: true flag when launching msger
|
|
265
|
-
* @param path - Directory path to list
|
|
266
|
-
* @returns Array of file information
|
|
267
|
-
* @example
|
|
268
|
-
* const files = await msger.fs.list('/path/to/dir');
|
|
269
|
-
*/
|
|
270
|
-
list(path: string): Promise<FileInfo[]>;
|
|
271
|
-
/**
|
|
272
|
-
* Check if file or directory exists
|
|
273
|
-
* Note: Requires allowFs: true flag when launching msger
|
|
274
|
-
* @param path - Path to check
|
|
275
|
-
* @returns true if exists
|
|
276
|
-
* @example
|
|
277
|
-
* const exists = await msger.fs.exists('/path/to/file.txt');
|
|
278
|
-
*/
|
|
279
|
-
exists(path: string): Promise<boolean>;
|
|
280
|
-
/**
|
|
281
|
-
* Delete file or directory
|
|
282
|
-
* Note: Requires allowFs: true flag when launching msger
|
|
283
|
-
* @param path - Path to delete
|
|
284
|
-
* @example
|
|
285
|
-
* await msger.fs.delete('/path/to/file.txt');
|
|
286
|
-
*/
|
|
287
|
-
delete(path: string): Promise<void>;
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Helper to check if code is running in msger
|
|
292
|
-
* @returns true if running in msger environment
|
|
293
|
-
* @example
|
|
294
|
-
* if (isMsger()) {
|
|
295
|
-
* msger.setTitle('Running in msger!');
|
|
296
|
-
* } else {
|
|
297
|
-
* console.log('Running in browser');
|
|
298
|
-
* }
|
|
299
|
-
*/
|
|
300
|
-
export declare function isMsger(): boolean;
|
|
301
|
-
/**
|
|
302
|
-
* Get msger API with fallback for browser compatibility
|
|
303
|
-
* @returns msger API if available, or stub implementation for browser
|
|
304
|
-
* @example
|
|
305
|
-
* const api = getMsgerAPI();
|
|
306
|
-
* api.saveData('key', 'value'); // Works in both msger and browser
|
|
307
|
-
*/
|
|
308
|
-
export declare function getMsgerAPI(): MsgerAPI;
|
|
309
|
-
/**
|
|
310
|
-
* Declare global window.msger
|
|
311
|
-
*/
|
|
312
|
-
declare global {
|
|
313
|
-
interface Window {
|
|
314
|
-
msger?: MsgerAPI;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
declare const _default: {
|
|
318
|
-
isMsger: typeof isMsger;
|
|
319
|
-
getMsgerAPI: typeof getMsgerAPI;
|
|
320
|
-
};
|
|
321
|
-
export default _default;
|