@bitefoundry/rtt 0.3.0 → 0.3.1
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/README.md +3 -1
- package/bin/rtt.exe +0 -0
- package/package.json +27 -32
- package/bin/rtt.js +0 -62
- package/scripts/postinstall.mjs +0 -275
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Windows 라이브 캡션의 음성을 터미널에서 실시간으로 받아 적
|
|
|
5
5
|
## 필요한 것
|
|
6
6
|
|
|
7
7
|
- Windows 11 22H2 이상 (라이브 캡션 기능 포함; 라이브 캡션이 없는 환경에서는 녹음과 재생만 사용할 수 있습니다)
|
|
8
|
-
- Node.js 18 이상
|
|
8
|
+
- Node.js 18 이상 (설치와 업데이트에만 쓰이며, `rtt`를 실행할 때는 `rtt.exe`가 바로 실행됩니다)
|
|
9
9
|
- 지원하는 LLM API 키 (선택: 키 없이도 받아 적기와 녹음·재생은 사용할 수 있습니다)
|
|
10
10
|
|
|
11
11
|
## 처음 쓰는 법
|
|
@@ -34,6 +34,8 @@ rtt --version
|
|
|
34
34
|
|
|
35
35
|
## 업데이트
|
|
36
36
|
|
|
37
|
+
실행 중인 `rtt`가 있으면 먼저 닫은 뒤 업데이트하세요(실행 중인 `rtt.exe`는 Windows가 잠급니다).
|
|
38
|
+
|
|
37
39
|
```powershell
|
|
38
40
|
npm update -g @bitefoundry/rtt
|
|
39
41
|
```
|
package/bin/rtt.exe
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bitefoundry/rtt",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Real-time captions, translation and reply suggestions for Windows Live Captions (terminal app)",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"os": [
|
|
7
|
-
"win32"
|
|
8
|
-
],
|
|
9
|
-
"cpu": [
|
|
10
|
-
"x64"
|
|
11
|
-
],
|
|
12
|
-
"bin": {
|
|
13
|
-
"rtt": "bin/rtt.
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"bin/rtt.
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
"optionalDependencies": {
|
|
30
|
-
"@bitefoundry/rtt-win32-x64": "0.3.0"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bitefoundry/rtt",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Real-time captions, translation and reply suggestions for Windows Live Captions (terminal app)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"os": [
|
|
7
|
+
"win32"
|
|
8
|
+
],
|
|
9
|
+
"cpu": [
|
|
10
|
+
"x64"
|
|
11
|
+
],
|
|
12
|
+
"bin": {
|
|
13
|
+
"rtt": "bin/rtt.exe"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin/rtt.exe",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"sync-version": "node scripts/sync-version.mjs",
|
|
25
|
+
"build:npm": "node scripts/build-npm.mjs"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/bin/rtt.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
// Ported from @bitefoundry/notion (bin/notion.js).
|
|
5
|
-
const { spawnSync } = require('node:child_process');
|
|
6
|
-
const fs = require('node:fs');
|
|
7
|
-
const path = require('node:path');
|
|
8
|
-
|
|
9
|
-
const PLATFORM_PACKAGES = {
|
|
10
|
-
'win32-x64': '@bitefoundry/rtt-win32-x64',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function resolveBinary() {
|
|
14
|
-
if (process.env.RTT_BIN_PATH && fs.existsSync(process.env.RTT_BIN_PATH)) {
|
|
15
|
-
return process.env.RTT_BIN_PATH;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const binaryName = process.platform === 'win32' ? 'rtt.exe' : 'rtt';
|
|
19
|
-
const localLinked = path.join(__dirname, binaryName);
|
|
20
|
-
if (fs.existsSync(localLinked)) {
|
|
21
|
-
return localLinked;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const key = `${process.platform}-${process.arch}`;
|
|
25
|
-
const pkgName = PLATFORM_PACKAGES[key];
|
|
26
|
-
if (!pkgName) {
|
|
27
|
-
console.error(
|
|
28
|
-
`[@bitefoundry/rtt] Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORM_PACKAGES).join(', ')}`,
|
|
29
|
-
);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
|
|
35
|
-
const candidate = path.join(path.dirname(pkgJsonPath), 'bin', binaryName);
|
|
36
|
-
if (fs.existsSync(candidate)) {
|
|
37
|
-
return candidate;
|
|
38
|
-
}
|
|
39
|
-
} catch {
|
|
40
|
-
// Fall through to helpful diagnostic error below.
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.error(
|
|
44
|
-
`[@bitefoundry/rtt] Could not locate prebuilt binary from optional dependency "${pkgName}".\n` +
|
|
45
|
-
`Try reinstalling without --omit=optional.`,
|
|
46
|
-
);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const binPath = resolveBinary();
|
|
51
|
-
const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
52
|
-
|
|
53
|
-
if (result.error) {
|
|
54
|
-
console.error(`[@bitefoundry/rtt] Failed to launch ${binPath}: ${result.error.message}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (result.signal) {
|
|
59
|
-
process.kill(process.pid, result.signal);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
process.exit(result.status ?? 0);
|
package/scripts/postinstall.mjs
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Zero-Node-Process npm native binary linker.
|
|
3
|
-
// Ported from @bitefoundry/notion (scripts/postinstall.mjs).
|
|
4
|
-
//
|
|
5
|
-
// On Windows (win32): creates NTFS hardlink (fallback copy) `bin/rtt.exe`
|
|
6
|
-
// and rewrites npm's `rtt.cmd`, `rtt.ps1`, and POSIX `rtt` shims when present
|
|
7
|
-
// to invoke the native executable directly without spawning `node.exe`.
|
|
8
|
-
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { createRequire } from 'node:module';
|
|
12
|
-
import { fileURLToPath } from 'node:url';
|
|
13
|
-
|
|
14
|
-
const BIN_NAMES = ['rtt'];
|
|
15
|
-
const PKG_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
16
|
-
|
|
17
|
-
function linkOrCopyFile(source, destination) {
|
|
18
|
-
const tmp = `${destination}.tmp-${process.pid}`;
|
|
19
|
-
try {
|
|
20
|
-
fs.rmSync(tmp, { force: true });
|
|
21
|
-
} catch {
|
|
22
|
-
// Ignore cleanup errors on nonexistent temp paths.
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
fs.linkSync(source, tmp);
|
|
26
|
-
} catch {
|
|
27
|
-
fs.copyFileSync(source, tmp);
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
fs.renameSync(tmp, destination);
|
|
31
|
-
} catch {
|
|
32
|
-
try {
|
|
33
|
-
fs.rmSync(destination, { force: true });
|
|
34
|
-
} catch {
|
|
35
|
-
// Ignore; renameSync below will surface or fail safely.
|
|
36
|
-
}
|
|
37
|
-
fs.renameSync(tmp, destination);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function replaceJsWithNativeLinkUnix(binaryPath, destinationJs) {
|
|
42
|
-
const tmp = `${destinationJs}.tmp-${process.pid}`;
|
|
43
|
-
try {
|
|
44
|
-
fs.rmSync(tmp, { force: true });
|
|
45
|
-
} catch {
|
|
46
|
-
// Ignore cleanup errors.
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
fs.linkSync(binaryPath, tmp);
|
|
50
|
-
} catch {
|
|
51
|
-
try {
|
|
52
|
-
fs.rmSync(tmp, { force: true });
|
|
53
|
-
} catch {
|
|
54
|
-
// Ignore cleanup errors.
|
|
55
|
-
}
|
|
56
|
-
fs.symlinkSync(binaryPath, tmp);
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
fs.renameSync(tmp, destinationJs);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
try {
|
|
62
|
-
fs.rmSync(tmp, { force: true });
|
|
63
|
-
} catch {
|
|
64
|
-
// Ignore cleanup errors.
|
|
65
|
-
}
|
|
66
|
-
throw err;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function collectWindowsShimDirs(pkgRoot, env = process.env) {
|
|
71
|
-
const dirs = [];
|
|
72
|
-
const parentScope = path.dirname(pkgRoot);
|
|
73
|
-
const nodeModulesDir = path.dirname(parentScope);
|
|
74
|
-
if (
|
|
75
|
-
path.basename(parentScope) === '@bitefoundry' &&
|
|
76
|
-
path.basename(nodeModulesDir) === 'node_modules'
|
|
77
|
-
) {
|
|
78
|
-
dirs.push(path.join(nodeModulesDir, '.bin'));
|
|
79
|
-
// On global Windows npm installs (`<prefix>\node_modules\@bitefoundry\rtt`),
|
|
80
|
-
// shims sit directly in the parent of `node_modules` even when `npm_config_prefix` is unset in npm v9+.
|
|
81
|
-
dirs.push(path.dirname(nodeModulesDir));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (env.npm_config_global === 'true' && env.npm_config_prefix) {
|
|
85
|
-
const prefix = path.resolve(env.npm_config_prefix);
|
|
86
|
-
dirs.push(prefix);
|
|
87
|
-
dirs.push(path.join(prefix, 'bin'));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return [...new Set(dirs)];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function shimReferencesLauncher(content, name) {
|
|
94
|
-
const normalized = content.replace(/\\/g, '/').toLowerCase();
|
|
95
|
-
return (
|
|
96
|
-
normalized.includes('@bitefoundry/rtt') &&
|
|
97
|
-
normalized.includes(`bin/${name}.js`)
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function rewriteWindowsShims(shimDir, pkgRoot) {
|
|
102
|
-
if (!fs.existsSync(shimDir)) return 0;
|
|
103
|
-
let rewritten = 0;
|
|
104
|
-
|
|
105
|
-
for (const name of BIN_NAMES) {
|
|
106
|
-
const exePath = path.join(pkgRoot, 'bin', `${name}.exe`);
|
|
107
|
-
if (!fs.existsSync(exePath)) continue;
|
|
108
|
-
|
|
109
|
-
const relWin = path.relative(shimDir, exePath).replace(/\//g, '\\');
|
|
110
|
-
const relPosix = path.relative(shimDir, exePath).replace(/\\/g, '/');
|
|
111
|
-
|
|
112
|
-
// 1. `<name>.cmd`
|
|
113
|
-
const cmdPath = path.join(shimDir, `${name}.cmd`);
|
|
114
|
-
try {
|
|
115
|
-
if (fs.existsSync(cmdPath)) {
|
|
116
|
-
const content = fs.readFileSync(cmdPath, 'utf8');
|
|
117
|
-
if (shimReferencesLauncher(content, name)) {
|
|
118
|
-
fs.writeFileSync(cmdPath, `@ECHO off\r\n"%~dp0${relWin}" %*\r\n`, 'utf8');
|
|
119
|
-
rewritten += 1;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} catch {
|
|
123
|
-
// Fall back cleanly to bin/<name>.js if shim is read-only or locked.
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// 2. `<name>.ps1`
|
|
127
|
-
const ps1Path = path.join(shimDir, `${name}.ps1`);
|
|
128
|
-
try {
|
|
129
|
-
if (fs.existsSync(ps1Path)) {
|
|
130
|
-
const content = fs.readFileSync(ps1Path, 'utf8');
|
|
131
|
-
if (shimReferencesLauncher(content, name)) {
|
|
132
|
-
const ps1Body = [
|
|
133
|
-
'#!/usr/bin/env pwsh',
|
|
134
|
-
'$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent',
|
|
135
|
-
`$exePath = Join-Path $basedir '${relWin.replace(/'/g, "''")}'`,
|
|
136
|
-
'if ($MyInvocation.ExpectingInput) {',
|
|
137
|
-
' $input | & $exePath @args',
|
|
138
|
-
'} else {',
|
|
139
|
-
' & $exePath @args',
|
|
140
|
-
'}',
|
|
141
|
-
'exit $LASTEXITCODE',
|
|
142
|
-
'',
|
|
143
|
-
].join('\n');
|
|
144
|
-
fs.writeFileSync(ps1Path, ps1Body, 'utf8');
|
|
145
|
-
rewritten += 1;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
} catch {
|
|
149
|
-
// Fall back cleanly.
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// 3. `<name>` (Git Bash / MSYS2 POSIX shell shim)
|
|
153
|
-
const shPath = path.join(shimDir, name);
|
|
154
|
-
try {
|
|
155
|
-
if (fs.existsSync(shPath)) {
|
|
156
|
-
const content = fs.readFileSync(shPath, 'utf8');
|
|
157
|
-
if (shimReferencesLauncher(content, name)) {
|
|
158
|
-
const shBody = [
|
|
159
|
-
'#!/bin/sh',
|
|
160
|
-
'basedir=$(dirname "$(echo "$0" | sed -e \'s,\\\\,/,g\')")',
|
|
161
|
-
`exec "$basedir/${relPosix}" "$@"`,
|
|
162
|
-
'',
|
|
163
|
-
].join('\n');
|
|
164
|
-
fs.writeFileSync(shPath, shBody, 'utf8');
|
|
165
|
-
rewritten += 1;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
} catch {
|
|
169
|
-
// Fall back cleanly.
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return rewritten;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function runPostinstall(options = {}) {
|
|
177
|
-
const pkgRoot = path.resolve(options.pkgRoot || PKG_ROOT);
|
|
178
|
-
const platform = options.platform || process.platform;
|
|
179
|
-
const arch = options.arch || process.arch;
|
|
180
|
-
const env = options.env || process.env;
|
|
181
|
-
|
|
182
|
-
// CRITICAL SAFETY GUARD: Never mutate files inside the git development repository.
|
|
183
|
-
if (
|
|
184
|
-
fs.existsSync(path.join(pkgRoot, 'Cargo.toml')) ||
|
|
185
|
-
fs.existsSync(path.join(pkgRoot, '.git'))
|
|
186
|
-
) {
|
|
187
|
-
return { skipped: true, reason: 'dev_repo' };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const platformKey = `${platform}-${arch}`;
|
|
191
|
-
const packageName = `@bitefoundry/rtt-${platformKey}`;
|
|
192
|
-
const binaryName = platform === 'win32' ? 'rtt.exe' : 'rtt';
|
|
193
|
-
|
|
194
|
-
let packageDir = null;
|
|
195
|
-
try {
|
|
196
|
-
const requireFromPkg = createRequire(path.join(pkgRoot, 'package.json'));
|
|
197
|
-
packageDir = path.dirname(requireFromPkg.resolve(`${packageName}/package.json`));
|
|
198
|
-
} catch {
|
|
199
|
-
packageDir = null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const binaryPath = packageDir ? path.join(packageDir, 'bin', binaryName) : null;
|
|
203
|
-
if (!binaryPath || !fs.existsSync(binaryPath)) {
|
|
204
|
-
return { skipped: true, reason: 'missing_platform_binary' };
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const binDir = path.join(pkgRoot, 'bin');
|
|
208
|
-
if (!fs.existsSync(binDir)) {
|
|
209
|
-
return { skipped: true, reason: 'missing_bin_dir' };
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (platform === 'win32') {
|
|
213
|
-
let linked = 0;
|
|
214
|
-
for (const name of BIN_NAMES) {
|
|
215
|
-
const destExe = path.join(binDir, `${name}.exe`);
|
|
216
|
-
try {
|
|
217
|
-
linkOrCopyFile(binaryPath, destExe);
|
|
218
|
-
linked += 1;
|
|
219
|
-
} catch {
|
|
220
|
-
// Leave fallback JS launcher untouched.
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
let shimsRewritten = 0;
|
|
225
|
-
for (const shimDir of collectWindowsShimDirs(pkgRoot, env)) {
|
|
226
|
-
try {
|
|
227
|
-
shimsRewritten += rewriteWindowsShims(shimDir, pkgRoot);
|
|
228
|
-
} catch {
|
|
229
|
-
// Never fail npm install on read-only or custom shims.
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return { skipped: false, platform, linked, shimsRewritten };
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// Unix fallback (not currently packaged for rtt).
|
|
236
|
-
try {
|
|
237
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
238
|
-
} catch {
|
|
239
|
-
// Ignore on read-only stores.
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
let linked = 0;
|
|
243
|
-
for (const name of BIN_NAMES) {
|
|
244
|
-
const destJs = path.join(binDir, `${name}.js`);
|
|
245
|
-
try {
|
|
246
|
-
replaceJsWithNativeLinkUnix(binaryPath, destJs);
|
|
247
|
-
linked += 1;
|
|
248
|
-
} catch {
|
|
249
|
-
// Leave fallback JS launcher intact.
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return { skipped: false, platform, linked };
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function resolveCanonicalPath(p) {
|
|
257
|
-
try {
|
|
258
|
-
return fs.realpathSync(p);
|
|
259
|
-
} catch {
|
|
260
|
-
return path.resolve(p);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (
|
|
265
|
-
process.argv[1] &&
|
|
266
|
-
resolveCanonicalPath(process.argv[1]) ===
|
|
267
|
-
resolveCanonicalPath(fileURLToPath(import.meta.url))
|
|
268
|
-
) {
|
|
269
|
-
try {
|
|
270
|
-
runPostinstall();
|
|
271
|
-
} catch {
|
|
272
|
-
// Postinstall optimization must never fail npm install.
|
|
273
|
-
}
|
|
274
|
-
process.exit(0);
|
|
275
|
-
}
|