@mingxy/ocosay 1.1.25 → 1.1.26

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.
Files changed (2) hide show
  1. package/dist/plugin.js +22 -48
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -9901,7 +9901,7 @@ import { readFileSync as readFileSync2, existsSync as existsSync7, writeFileSync
9901
9901
  import { fileURLToPath } from "url";
9902
9902
  import { dirname as dirname2, join as join8 } from "path";
9903
9903
  import { homedir as homedir3 } from "os";
9904
- import { execSync as execSync4 } from "child_process";
9904
+ import { exec, execSync as execSync4 } from "child_process";
9905
9905
  import { createRequire as createRequire2 } from "module";
9906
9906
 
9907
9907
  // src/core/dependency-detector.ts
@@ -10254,6 +10254,13 @@ async function verifyInstallation(packages) {
10254
10254
  }
10255
10255
 
10256
10256
  // src/plugin.ts
10257
+ function execAsync(cmd, cwd) {
10258
+ return new Promise((resolve) => {
10259
+ exec(cmd, { cwd, encoding: "utf8" }, (error, stdout, stderr) => {
10260
+ resolve({ stdout: stdout || "", stderr: stderr || "", error: error || void 0 });
10261
+ });
10262
+ });
10263
+ }
10257
10264
  var logger9 = createModuleLogger("Plugin");
10258
10265
  var require3 = createRequire2(import.meta.url);
10259
10266
  var opencodeBinPath = execSync4("which opencode").toString().trim();
@@ -10266,11 +10273,11 @@ function getSkipFilePath() {
10266
10273
  function shouldSkipNaudiodon() {
10267
10274
  return existsSync7(getSkipFilePath());
10268
10275
  }
10269
- function markNaudiodonSkipped() {
10276
+ async function markNaudiodonSkipped() {
10270
10277
  try {
10271
10278
  const dir = join8(homedir3(), ".config", "opencode");
10272
10279
  if (!existsSync7(dir)) {
10273
- execSync4("mkdir -p", { cwd: dir });
10280
+ await execAsync("mkdir -p", dir);
10274
10281
  }
10275
10282
  writeFileSync6(getSkipFilePath(), Date.now().toString(), "utf-8");
10276
10283
  } catch {
@@ -10290,10 +10297,7 @@ async function rebuildNaudiodonDependency(dep) {
10290
10297
  const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10291
10298
  try {
10292
10299
  notificationService.info(`\u6B63\u5728\u7F16\u8BD1 ${dep}...`, "Ocosay \u4F9D\u8D56", 4e3);
10293
- execSync4(`npm rebuild ${dep}`, {
10294
- cwd: naudiodonPath,
10295
- stdio: "inherit"
10296
- });
10300
+ await execAsync(`npm rebuild ${dep}`, naudiodonPath);
10297
10301
  logger9.info(`${dep} rebuilt successfully`);
10298
10302
  return true;
10299
10303
  } catch (err) {
@@ -10320,10 +10324,7 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
10320
10324
  } catch {
10321
10325
  try {
10322
10326
  notificationService.info(`\u6B63\u5728\u5B89\u88C5 ${dep}...`, "Ocosay", 4e3);
10323
- execSync4(`npm install ${dep}`, {
10324
- cwd: naudiodonPath,
10325
- stdio: "inherit"
10326
- });
10327
+ await execAsync(`npm install ${dep}`, naudiodonPath);
10327
10328
  logger9.info(`${dep} installed successfully`);
10328
10329
  anySuccess = true;
10329
10330
  } catch (installErr) {
@@ -10334,10 +10335,7 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
10334
10335
  if (!anySuccess || !await verifyNaudiodonLoad()) {
10335
10336
  try {
10336
10337
  notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 4e3);
10337
- execSync4("npm rebuild naudiodon", {
10338
- cwd: naudiodonPath,
10339
- stdio: "inherit"
10340
- });
10338
+ await execAsync("npm rebuild naudiodon", naudiodonPath);
10341
10339
  logger9.info("naudiodon rebuilt");
10342
10340
  anySuccess = true;
10343
10341
  } catch (err) {
@@ -10369,10 +10367,7 @@ async function ensureNaudiodonCompiled() {
10369
10367
  try {
10370
10368
  const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10371
10369
  logger9.info({ naudiodonPath }, "found naudiodon, rebuilding");
10372
- execSync4("npm rebuild naudiodon", {
10373
- cwd: naudiodonPath,
10374
- stdio: "inherit"
10375
- });
10370
+ await execAsync("npm rebuild naudiodon", naudiodonPath);
10376
10371
  logger9.info("naudiodon compiled, verifying...");
10377
10372
  const loadSuccess = await verifyNaudiodonLoad();
10378
10373
  if (loadSuccess) {
@@ -10394,10 +10389,7 @@ async function ensureNaudiodonCompiled() {
10394
10389
  try {
10395
10390
  const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10396
10391
  notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
10397
- execSync4("npm rebuild naudiodon", {
10398
- cwd: naudiodonPath,
10399
- stdio: "inherit"
10400
- });
10392
+ await execAsync("npm rebuild naudiodon", naudiodonPath);
10401
10393
  logger9.info("naudiodon compiled successfully after PortAudio install");
10402
10394
  const loadSuccess = await verifyNaudiodonLoad();
10403
10395
  if (loadSuccess) {
@@ -10452,18 +10444,12 @@ async function tryCompileSpeaker() {
10452
10444
  }
10453
10445
  if (!isModuleInstalled(dep)) {
10454
10446
  try {
10455
- execSync4("npm install speaker", {
10456
- cwd: opencodeNodeModules,
10457
- stdio: "pipe"
10458
- });
10447
+ await execAsync("npm install speaker", opencodeNodeModules);
10459
10448
  } catch {
10460
10449
  }
10461
10450
  }
10462
10451
  try {
10463
- execSync4("npm rebuild speaker", {
10464
- cwd: opencodeNodeModules,
10465
- stdio: "pipe"
10466
- });
10452
+ await execAsync("npm rebuild speaker", opencodeNodeModules);
10467
10453
  if (await verifyModuleLoad(dep)) {
10468
10454
  result.success = true;
10469
10455
  }
@@ -10518,10 +10504,7 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
10518
10504
  logger9.info("speaker installed but not loadable, rebuilding");
10519
10505
  notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10520
10506
  try {
10521
- execSync4("npm rebuild speaker", {
10522
- cwd: opencodeNodeModules,
10523
- stdio: "inherit"
10524
- });
10507
+ await execAsync("npm rebuild speaker", opencodeNodeModules);
10525
10508
  logger9.info("speaker rebuilt");
10526
10509
  } catch (err) {
10527
10510
  logger9.warn({ err }, "speaker rebuild failed");
@@ -10534,10 +10517,7 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
10534
10517
  logger9.info("speaker not found, installing");
10535
10518
  notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10536
10519
  try {
10537
- execSync4("npm install speaker", {
10538
- cwd: opencodeNodeModules,
10539
- stdio: "inherit"
10540
- });
10520
+ await execAsync("npm install speaker", opencodeNodeModules);
10541
10521
  logger9.info("speaker installed");
10542
10522
  } catch (err) {
10543
10523
  logger9.warn({ err }, "speaker install failed");
@@ -10551,10 +10531,7 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
10551
10531
  logger9.info({ attempt, dep }, "speaker not loadable, trying rebuild");
10552
10532
  notificationService.info(`\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
10553
10533
  try {
10554
- execSync4("npm rebuild speaker", {
10555
- cwd: opencodeNodeModules,
10556
- stdio: "inherit"
10557
- });
10534
+ await execAsync("npm rebuild speaker", opencodeNodeModules);
10558
10535
  logger9.info("speaker rebuilt");
10559
10536
  } catch (err) {
10560
10537
  logger9.warn({ err }, "speaker rebuild failed");
@@ -10581,10 +10558,7 @@ async function ensurePlaySoundInstalled() {
10581
10558
  logger9.info("play-sound not found, installing");
10582
10559
  notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10583
10560
  try {
10584
- execSync4("npm install play-sound", {
10585
- cwd: opencodeNodeModules,
10586
- stdio: "inherit"
10587
- });
10561
+ await execAsync("npm install play-sound", opencodeNodeModules);
10588
10562
  logger9.info("play-sound installed");
10589
10563
  } catch (err) {
10590
10564
  logger9.warn({ err }, "play-sound install failed");
@@ -10662,7 +10636,7 @@ async function installPortAudio() {
10662
10636
  logger9.info(`Running: ${cmd}`);
10663
10637
  notificationService.info(desc, "\u6B63\u5728\u5B89\u88C5...", 5e3);
10664
10638
  try {
10665
- execSync4(cmd, { stdio: "inherit" });
10639
+ await execAsync(cmd);
10666
10640
  return true;
10667
10641
  } catch (err) {
10668
10642
  const msg = err.message || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/ocosay",
3
- "version": "1.1.25",
3
+ "version": "1.1.26",
4
4
  "description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",