teamshare-bridge 0.19.6 → 0.19.8
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.
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerScheme = registerScheme;
|
|
4
|
+
exports.schemeRegistered = schemeRegistered;
|
|
5
|
+
/**
|
|
6
|
+
* Standalone protocol registration — zero bridge imports.
|
|
7
|
+
*
|
|
8
|
+
* This file is intentionally self-contained so the npm postinstall hook
|
|
9
|
+
* can run it without loading the entire bridge codebase (which pulls in
|
|
10
|
+
* native modules like @napi-rs/keyring that lock files during cleanup).
|
|
11
|
+
*
|
|
12
|
+
* ONLY import node built-ins here — no ../lib/* or ../bridge/* deps.
|
|
13
|
+
*/
|
|
14
|
+
const node_child_process_1 = require("node:child_process");
|
|
15
|
+
const node_fs_1 = require("node:fs");
|
|
16
|
+
const node_os_1 = require("node:os");
|
|
17
|
+
const node_path_1 = require("node:path");
|
|
18
|
+
function registerScheme() {
|
|
19
|
+
const nodeBin = process.execPath;
|
|
20
|
+
const serveScript = (0, node_path_1.join)(__dirname, 'index.js');
|
|
21
|
+
if (process.platform === 'win32') {
|
|
22
|
+
const vbsPath = (0, node_path_1.join)(__dirname, 'serve.vbs');
|
|
23
|
+
const vbs = [
|
|
24
|
+
'Set sh = CreateObject("WScript.Shell")',
|
|
25
|
+
`sh.Run "${nodeBin.replace(/"/g, '""')} ""${serveScript.replace(/"/g, '""')}"" serve ""%1"" --hidden", 0, False`,
|
|
26
|
+
].join('\r\n');
|
|
27
|
+
(0, node_fs_1.writeFileSync)(vbsPath, vbs, 'utf8');
|
|
28
|
+
const classes = 'HKCU\\Software\\Classes\\teamshare';
|
|
29
|
+
(0, node_child_process_1.execFileSync)('reg.exe', ['add', classes, '/v', 'URL Protocol', '/t', 'REG_SZ', '/d', '', '/f'], { stdio: 'inherit' });
|
|
30
|
+
(0, node_child_process_1.execFileSync)('reg.exe', ['add', `${classes}\\shell\\open\\command`, '/ve', '/t', 'REG_SZ', '/d', `"wscript.exe" "${vbsPath}" "%1"`, '/f'], { stdio: 'inherit' });
|
|
31
|
+
console.log('Registered teamshare:// (HKCU, per-user, hidden launcher).');
|
|
32
|
+
}
|
|
33
|
+
else if (process.platform === 'darwin') {
|
|
34
|
+
const bundle = (0, node_path_1.join)((0, node_os_1.homedir)(), 'Applications', 'TeamShareBridge.app');
|
|
35
|
+
const contents = (0, node_path_1.join)(bundle, 'Contents');
|
|
36
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(contents, 'MacOS'), { recursive: true });
|
|
37
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(contents, 'Info.plist'), `<?xml version="1.0" encoding="UTF-8"?>
|
|
38
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
39
|
+
<plist version="1.0">
|
|
40
|
+
<dict>
|
|
41
|
+
<key>CFBundleIdentifier</key><string>com.teamshare.bridge</string>
|
|
42
|
+
<key>CFBundleName</key><string>TeamShare Bridge</string>
|
|
43
|
+
<key>CFBundleExecutable</key><string>run.sh</string>
|
|
44
|
+
<key>CFBundlePackageType</key><string>APPL</string>
|
|
45
|
+
<key>CFBundleURLTypes</key>
|
|
46
|
+
<array><dict>
|
|
47
|
+
<key>CFBundleURLName</key><string>teamshare</string>
|
|
48
|
+
<key>CFBundleURLSchemes</key><array><string>teamshare</string></array>
|
|
49
|
+
</dict></array>
|
|
50
|
+
</dict>
|
|
51
|
+
</plist>
|
|
52
|
+
`, 'utf8');
|
|
53
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(contents, 'MacOS', 'run.sh'), `#!/bin/bash\nexec "${nodeBin}" "${serveScript}" serve "$1"\n`, 'utf8');
|
|
54
|
+
console.log('Registered teamshare:// bundle at ' + bundle);
|
|
55
|
+
console.log('Run: open "' + bundle + '" once to finish registration.');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const desktop = (0, node_path_1.join)((0, node_os_1.homedir)(), '.local', 'share', 'applications');
|
|
59
|
+
(0, node_fs_1.mkdirSync)(desktop, { recursive: true });
|
|
60
|
+
const file = (0, node_path_1.join)(desktop, 'teamshare-bridge.desktop');
|
|
61
|
+
(0, node_fs_1.writeFileSync)(file, `[Desktop Entry]
|
|
62
|
+
Type=Application
|
|
63
|
+
Name=TeamShare Bridge
|
|
64
|
+
Exec=${nodeBin} ${serveScript} serve %u
|
|
65
|
+
MimeType=x-scheme-handler/teamshare
|
|
66
|
+
NoDisplay=true
|
|
67
|
+
`, 'utf8');
|
|
68
|
+
console.log('Registered teamshare:// via ' + file);
|
|
69
|
+
try {
|
|
70
|
+
(0, node_child_process_1.execFileSync)('update-desktop-database', [desktop], { stdio: 'ignore' });
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
/* best-effort */
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function schemeRegistered() {
|
|
78
|
+
if (process.platform === 'win32') {
|
|
79
|
+
try {
|
|
80
|
+
(0, node_child_process_1.execFileSync)('reg.exe', ['query', 'HKCU\\Software\\Classes\\teamshare'], { stdio: 'ignore' });
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (process.platform === 'darwin') {
|
|
88
|
+
return (0, node_fs_1.existsSync)((0, node_path_1.join)((0, node_os_1.homedir)(), 'Applications', 'TeamShareBridge.app'));
|
|
89
|
+
}
|
|
90
|
+
return (0, node_fs_1.existsSync)((0, node_path_1.join)((0, node_os_1.homedir)(), '.local', 'share', 'applications', 'teamshare-bridge.desktop'));
|
|
91
|
+
}
|
|
92
|
+
// When run directly (postinstall): register if not already registered.
|
|
93
|
+
// When imported: just export the functions.
|
|
94
|
+
const isMain = process.argv[1] && (process.argv[1].endsWith('register-only.js') ||
|
|
95
|
+
process.argv[1].endsWith('register-only.ts'));
|
|
96
|
+
if (isMain) {
|
|
97
|
+
if (schemeRegistered()) {
|
|
98
|
+
console.log('teamshare:// already registered.');
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
registerScheme();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=register-only.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-only.js","sourceRoot":"","sources":["../../src/bridge/register-only.ts"],"names":[],"mappings":";;AAcA,wCAqEC;AAED,4CAaC;AAlGD;;;;;;;;GAQG;AACH,2DAAkD;AAClD,qCAA+D;AAC/D,qCAAkC;AAClC,yCAAiC;AAEjC,SAAgB,cAAc;IAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IACjC,MAAM,WAAW,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEhD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG;YACV,wCAAwC;YACxC,WAAW,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,qCAAqC;SACjH,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACf,IAAA,uBAAa,EAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEpC,MAAM,OAAO,GAAG,oCAAoC,CAAC;QACrD,IAAA,iCAAY,EAAC,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK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AO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAC7C,CAAC;AACF,IAAI,MAAM,EAAE,CAAC;IACX,IAAI,gBAAgB,EAAE,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,cAAc,EAAE,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamshare-bridge",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.8",
|
|
4
4
|
"description": "Local bridge for TeamShare agents - CLI session runner, auto-wake WebSocket daemon, and teamshare:// protocol handler.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc -p tsconfig.json",
|
|
35
35
|
"prepare": "npm run build",
|
|
36
|
-
"postinstall": "node dist/bridge/
|
|
36
|
+
"postinstall": "node -e \"try{require('child_process').execSync('node dist/bridge/register-only.js',{stdio:'inherit'})}catch(e){}\"",
|
|
37
37
|
"dev": "tsc -p tsconfig.json --watch",
|
|
38
38
|
"lint": "eslint src --ext .ts",
|
|
39
39
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|