bit-office 0.1.1 → 0.1.3
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/dist/index.js +75 -19
- package/dist/index.js.map +1 -1
- package/dist/web/out/404.html +2 -2
- package/dist/web/out/_next/static/chunks/app/pair/page-d136726b49f8054d.js +1 -0
- package/dist/web/out/index.html +2 -2
- package/dist/web/out/index.txt +1 -1
- package/dist/web/out/office.html +2 -2
- package/dist/web/out/office.txt +1 -1
- package/dist/web/out/pair.html +2 -2
- package/dist/web/out/pair.txt +2 -2
- package/dist/web/out/sw.js +1 -1
- package/package.json +1 -1
- package/dist/web/out/_next/static/chunks/app/pair/page-389c78f078318d25.js +0 -1
- /package/dist/web/out/_next/static/{WUkru2DsWDrbIAe5_By4_ → cj3y0KrOWGVoa7jq43eZZ}/_buildManifest.js +0 -0
- /package/dist/web/out/_next/static/{WUkru2DsWDrbIAe5_By4_ → cj3y0KrOWGVoa7jq43eZZ}/_ssgManifest.js +0 -0
package/dist/index.js
CHANGED
|
@@ -4227,16 +4227,37 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
|
4227
4227
|
import { homedir } from "os";
|
|
4228
4228
|
import { randomBytes } from "crypto";
|
|
4229
4229
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4230
|
+
var CONFIG_DIR = resolve(homedir(), ".bit-office");
|
|
4231
|
+
var CONFIG_FILE = resolve(CONFIG_DIR, "config.json");
|
|
4232
|
+
function ensureConfigDir() {
|
|
4233
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
4234
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
function loadSavedConfig() {
|
|
4238
|
+
if (!existsSync(CONFIG_FILE)) return {};
|
|
4239
|
+
try {
|
|
4240
|
+
return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
|
|
4241
|
+
} catch {
|
|
4242
|
+
return {};
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
function saveConfig(cfg) {
|
|
4246
|
+
ensureConfigDir();
|
|
4247
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2), "utf-8");
|
|
4248
|
+
}
|
|
4249
|
+
function hasSetupRun() {
|
|
4250
|
+
return existsSync(CONFIG_FILE);
|
|
4251
|
+
}
|
|
4230
4252
|
function getOrCreateMachineId() {
|
|
4231
|
-
|
|
4232
|
-
const
|
|
4233
|
-
if (existsSync(
|
|
4234
|
-
return readFileSync(
|
|
4253
|
+
ensureConfigDir();
|
|
4254
|
+
const idFile = resolve(CONFIG_DIR, "machine-id");
|
|
4255
|
+
if (existsSync(idFile)) {
|
|
4256
|
+
return readFileSync(idFile, "utf-8").trim();
|
|
4235
4257
|
}
|
|
4236
4258
|
const id = `mac-${randomBytes(4).toString("hex")}`;
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
console.log(`[Config] Generated machine ID: ${id} (saved to ${configFile})`);
|
|
4259
|
+
writeFileSync(idFile, id, "utf-8");
|
|
4260
|
+
console.log(`[Config] Generated machine ID: ${id}`);
|
|
4240
4261
|
return id;
|
|
4241
4262
|
}
|
|
4242
4263
|
function resolveWebDir() {
|
|
@@ -4245,19 +4266,22 @@ function resolveWebDir() {
|
|
|
4245
4266
|
if (existsSync(bundled)) return bundled;
|
|
4246
4267
|
return resolve(__dirname, "../../web/out");
|
|
4247
4268
|
}
|
|
4248
|
-
function
|
|
4249
|
-
const
|
|
4250
|
-
|
|
4251
|
-
|
|
4269
|
+
function buildConfig() {
|
|
4270
|
+
const saved = loadSavedConfig();
|
|
4271
|
+
return {
|
|
4272
|
+
machineId: getOrCreateMachineId(),
|
|
4273
|
+
defaultWorkspace: process.cwd(),
|
|
4274
|
+
wsPort: 9090,
|
|
4275
|
+
ablyApiKey: process.env.ABLY_API_KEY || saved.ablyApiKey || void 0,
|
|
4276
|
+
webDir: resolveWebDir(),
|
|
4277
|
+
telegramBotTokens: process.env.TELEGRAM_BOT_TOKENS ? process.env.TELEGRAM_BOT_TOKENS.split(",").map((t) => t.trim() || void 0) : (saved.telegramBotTokens ?? []).map((t) => t || void 0)
|
|
4278
|
+
};
|
|
4279
|
+
}
|
|
4280
|
+
var config = buildConfig();
|
|
4281
|
+
function reloadConfig() {
|
|
4282
|
+
const fresh = buildConfig();
|
|
4283
|
+
Object.assign(config, fresh);
|
|
4252
4284
|
}
|
|
4253
|
-
var config = {
|
|
4254
|
-
machineId: getOrCreateMachineId(),
|
|
4255
|
-
defaultWorkspace: process.cwd(),
|
|
4256
|
-
wsPort: 9090,
|
|
4257
|
-
ablyApiKey: process.env.ABLY_API_KEY || void 0,
|
|
4258
|
-
webDir: resolveWebDir(),
|
|
4259
|
-
telegramBotTokens: parseTelegramTokens()
|
|
4260
|
-
};
|
|
4261
4285
|
|
|
4262
4286
|
// src/ws-server.ts
|
|
4263
4287
|
import { networkInterfaces } from "os";
|
|
@@ -4928,6 +4952,34 @@ var telegramChannel = {
|
|
|
4928
4952
|
}
|
|
4929
4953
|
};
|
|
4930
4954
|
|
|
4955
|
+
// src/setup.ts
|
|
4956
|
+
import { createInterface } from "readline";
|
|
4957
|
+
function ask(rl, question) {
|
|
4958
|
+
return new Promise((resolve2) => {
|
|
4959
|
+
rl.question(question, (answer) => resolve2(answer.trim()));
|
|
4960
|
+
});
|
|
4961
|
+
}
|
|
4962
|
+
async function runSetup() {
|
|
4963
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
4964
|
+
console.log("");
|
|
4965
|
+
console.log("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
|
|
4966
|
+
console.log("\u2551 Bit Office \u2014 First Setup \u2551");
|
|
4967
|
+
console.log("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
|
|
4968
|
+
console.log("");
|
|
4969
|
+
console.log("Press Enter to skip any step.\n");
|
|
4970
|
+
console.log("\u2500\u2500 Remote Access (Ably) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
4971
|
+
console.log("Enables access from outside your LAN.");
|
|
4972
|
+
const ablyApiKey = await ask(rl, "Ably API Key (optional): ");
|
|
4973
|
+
rl.close();
|
|
4974
|
+
saveConfig({
|
|
4975
|
+
ablyApiKey: ablyApiKey || void 0
|
|
4976
|
+
// telegramBotTokens: tokens,
|
|
4977
|
+
});
|
|
4978
|
+
console.log("\n\u2713 Config saved to ~/.bit-office/config.json");
|
|
4979
|
+
if (ablyApiKey) console.log(" \u2022 Ably: enabled");
|
|
4980
|
+
console.log(" \u2022 Run with --setup to reconfigure\n");
|
|
4981
|
+
}
|
|
4982
|
+
|
|
4931
4983
|
// src/index.ts
|
|
4932
4984
|
import { nanoid as nanoid3 } from "nanoid";
|
|
4933
4985
|
import { exec } from "child_process";
|
|
@@ -5043,6 +5095,10 @@ function handleCommand(parsed) {
|
|
|
5043
5095
|
}
|
|
5044
5096
|
}
|
|
5045
5097
|
async function main() {
|
|
5098
|
+
if (!hasSetupRun() || process.argv.includes("--setup")) {
|
|
5099
|
+
await runSetup();
|
|
5100
|
+
reloadConfig();
|
|
5101
|
+
}
|
|
5046
5102
|
console.log(`[Gateway] Starting for machine: ${config.machineId}`);
|
|
5047
5103
|
showPairCode();
|
|
5048
5104
|
await initTransports(handleCommand);
|