Add FileBow Windows app, Store identity and optional Ko-fi link
This commit is contained in:
commit
65cebb31ca
139 files changed
+375057
No files matched your search
@@ -0,0 +1,46 @@
|
||||
const { spawn } = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
class WindowsBridge {
|
||||
constructor(root) {
|
||||
this.next = 1; this.pending = new Map(); this.onDrag = () => {};
|
||||
this.process = spawn(path.join(root, 'vendor/windows/FileBow.Windows.exe'), [], { windowsHide: true, stdio: ['pipe','pipe','pipe'] });
|
||||
let buffer = '';
|
||||
this.ready = new Promise((resolve, reject) => {
|
||||
this.process.on('error', reject);
|
||||
this.process.stdout.setEncoding('utf8');
|
||||
this.process.stdout.on('data', chunk => {
|
||||
buffer += chunk;
|
||||
const lines = buffer.split(/\r?\n/); buffer = lines.pop();
|
||||
for (const line of lines) {
|
||||
let message; try { message = JSON.parse(line); } catch { continue; }
|
||||
if (message.type === 'ready') resolve();
|
||||
else if (message.type === 'drag') this.onDrag(message);
|
||||
else if (this.pending.has(message.id)) {
|
||||
const pending = this.pending.get(message.id); this.pending.delete(message.id); clearTimeout(pending.timer);
|
||||
if (message.error) pending.reject(new Error(message.error)); else pending.resolve(message.result);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.process.stderr.resume();
|
||||
this.process.on('exit', () => {
|
||||
reject(new Error('Windows-Hilfsprozess wurde beendet.'));
|
||||
for (const pending of this.pending.values()) { clearTimeout(pending.timer); pending.reject(new Error('Windows-Hilfsprozess wurde beendet.')); }
|
||||
this.pending.clear();
|
||||
});
|
||||
});
|
||||
}
|
||||
async request(command, extra = {}) {
|
||||
await this.ready;
|
||||
return new Promise((resolve,reject) => {
|
||||
const id = this.next++;
|
||||
const timer = setTimeout(() => { this.pending.delete(id); reject(new Error('Windows antwortet nicht.')); }, 10000);
|
||||
this.pending.set(id, { resolve,reject,timer });
|
||||
this.process.stdin.write(JSON.stringify({ id, command, ...extra }) + '\n');
|
||||
});
|
||||
}
|
||||
getExplorerSelection() { return this.request('selection'); }
|
||||
startFileDragMonitor(callback) { this.onDrag = callback; return this.request('monitor', { enabled: true }); }
|
||||
stopFileDragMonitor() { return this.request('monitor', { enabled: false }); }
|
||||
close() { this.process.stdin.end(); }
|
||||
}
|
||||
module.exports = { WindowsBridge };
|
||||
Reference in new issue
Block a user