@mingxy/ocosay 1.1.26 → 1.1.27

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/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",
package/dist/plugin.js CHANGED
@@ -10295,15 +10295,14 @@ async function verifyNaudiodonLoad() {
10295
10295
  }
10296
10296
  async function rebuildNaudiodonDependency(dep) {
10297
10297
  const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10298
- try {
10299
- notificationService.info(`\u6B63\u5728\u7F16\u8BD1 ${dep}...`, "Ocosay \u4F9D\u8D56", 4e3);
10300
- await execAsync(`npm rebuild ${dep}`, naudiodonPath);
10301
- logger9.info(`${dep} rebuilt successfully`);
10302
- return true;
10303
- } catch (err) {
10304
- logger9.warn({ err }, `${dep} rebuild failed`);
10298
+ notificationService.info(`\u6B63\u5728\u7F16\u8BD1 ${dep}...`, "Ocosay \u4F9D\u8D56", 4e3);
10299
+ const result = await execAsync(`npm rebuild ${dep}`, naudiodonPath);
10300
+ if (result.error) {
10301
+ logger9.warn({ err: result.error }, `${dep} rebuild failed`);
10305
10302
  return false;
10306
10303
  }
10304
+ logger9.info(`${dep} rebuilt successfully`);
10305
+ return true;
10307
10306
  }
10308
10307
  async function fixNaudiodonDependencies(maxRetries = 5) {
10309
10308
  const naudiodonPath = dirname2(require3.resolve("naudiodon"));
@@ -10322,24 +10321,24 @@ async function fixNaudiodonDependencies(maxRetries = 5) {
10322
10321
  anySuccess = true;
10323
10322
  }
10324
10323
  } catch {
10325
- try {
10326
- notificationService.info(`\u6B63\u5728\u5B89\u88C5 ${dep}...`, "Ocosay", 4e3);
10327
- await execAsync(`npm install ${dep}`, naudiodonPath);
10324
+ notificationService.info(`\u6B63\u5728\u5B89\u88C5 ${dep}...`, "Ocosay", 4e3);
10325
+ const installResult = await execAsync(`npm install ${dep}`, naudiodonPath);
10326
+ if (installResult.error) {
10327
+ logger9.warn({ err: installResult.error }, `${dep} install failed`);
10328
+ } else {
10328
10329
  logger9.info(`${dep} installed successfully`);
10329
10330
  anySuccess = true;
10330
- } catch (installErr) {
10331
- logger9.warn({ err: installErr }, `${dep} install failed`);
10332
10331
  }
10333
10332
  }
10334
10333
  }
10335
10334
  if (!anySuccess || !await verifyNaudiodonLoad()) {
10336
- try {
10337
- notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 4e3);
10338
- await execAsync("npm rebuild naudiodon", naudiodonPath);
10335
+ notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 4e3);
10336
+ const rebuildResult = await execAsync("npm rebuild naudiodon", naudiodonPath);
10337
+ if (rebuildResult.error) {
10338
+ logger9.warn({ err: rebuildResult.error }, "naudiodon rebuild failed");
10339
+ } else {
10339
10340
  logger9.info("naudiodon rebuilt");
10340
10341
  anySuccess = true;
10341
- } catch (err) {
10342
- logger9.warn({ err }, "naudiodon rebuild failed");
10343
10342
  }
10344
10343
  }
10345
10344
  if (await verifyNaudiodonLoad()) {
@@ -10367,18 +10366,52 @@ async function ensureNaudiodonCompiled() {
10367
10366
  try {
10368
10367
  const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10369
10368
  logger9.info({ naudiodonPath }, "found naudiodon, rebuilding");
10370
- await execAsync("npm rebuild naudiodon", naudiodonPath);
10371
- logger9.info("naudiodon compiled, verifying...");
10372
- const loadSuccess = await verifyNaudiodonLoad();
10373
- if (loadSuccess) {
10374
- notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10369
+ const rebuildResult = await execAsync("npm rebuild naudiodon", naudiodonPath);
10370
+ if (rebuildResult.error) {
10371
+ logger9.warn({ err: rebuildResult.error }, "naudiodon rebuild failed, checking for PortAudio");
10372
+ notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
10373
+ const installed = await installPortAudio();
10374
+ if (installed.success) {
10375
+ const retryPath = dirname2(require3.resolve("naudiodon"));
10376
+ notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
10377
+ const retryResult = await execAsync("npm rebuild naudiodon", retryPath);
10378
+ if (retryResult.error) {
10379
+ logger9.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
10380
+ notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10381
+ markNaudiodonSkipped();
10382
+ } else {
10383
+ logger9.info("naudiodon compiled successfully after PortAudio install");
10384
+ const loadSuccess = await verifyNaudiodonLoad();
10385
+ if (loadSuccess) {
10386
+ notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10387
+ } else {
10388
+ notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
10389
+ const fixed = await fixNaudiodonDependencies();
10390
+ if (fixed) {
10391
+ notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10392
+ } else {
10393
+ markNaudiodonSkipped();
10394
+ }
10395
+ }
10396
+ }
10397
+ } else {
10398
+ logger9.error("PortAudio install failed");
10399
+ notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10400
+ markNaudiodonSkipped();
10401
+ }
10375
10402
  } else {
10376
- notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
10377
- const fixed = await fixNaudiodonDependencies();
10378
- if (fixed) {
10379
- notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10403
+ logger9.info("naudiodon compiled, verifying...");
10404
+ const loadSuccess = await verifyNaudiodonLoad();
10405
+ if (loadSuccess) {
10406
+ notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10380
10407
  } else {
10381
- throw new Error("naudiodon dependencies could not be fixed");
10408
+ notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
10409
+ const fixed = await fixNaudiodonDependencies();
10410
+ if (fixed) {
10411
+ notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10412
+ } else {
10413
+ markNaudiodonSkipped();
10414
+ }
10382
10415
  }
10383
10416
  }
10384
10417
  } catch (err) {
@@ -10386,10 +10419,14 @@ async function ensureNaudiodonCompiled() {
10386
10419
  notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
10387
10420
  const installed = await installPortAudio();
10388
10421
  if (installed.success) {
10389
- try {
10390
- const naudiodonPath = dirname2(require3.resolve("naudiodon"));
10391
- notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
10392
- await execAsync("npm rebuild naudiodon", naudiodonPath);
10422
+ const retryPath = dirname2(require3.resolve("naudiodon"));
10423
+ notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
10424
+ const retryResult = await execAsync("npm rebuild naudiodon", retryPath);
10425
+ if (retryResult.error) {
10426
+ logger9.error({ err: retryResult.error }, "naudiodon compile failed even after PortAudio install");
10427
+ notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10428
+ markNaudiodonSkipped();
10429
+ } else {
10393
10430
  logger9.info("naudiodon compiled successfully after PortAudio install");
10394
10431
  const loadSuccess = await verifyNaudiodonLoad();
10395
10432
  if (loadSuccess) {
@@ -10400,13 +10437,9 @@ async function ensureNaudiodonCompiled() {
10400
10437
  if (fixed) {
10401
10438
  notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10402
10439
  } else {
10403
- throw new Error("naudiodon dependencies could not be fixed");
10440
+ markNaudiodonSkipped();
10404
10441
  }
10405
10442
  }
10406
- } catch (retryErr) {
10407
- logger9.error({ err: retryErr }, "naudiodon compile failed even after PortAudio install");
10408
- notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
10409
- markNaudiodonSkipped();
10410
10443
  }
10411
10444
  } else {
10412
10445
  logger9.error("PortAudio install failed");
@@ -10443,18 +10476,17 @@ async function tryCompileSpeaker() {
10443
10476
  }
10444
10477
  }
10445
10478
  if (!isModuleInstalled(dep)) {
10446
- try {
10447
- await execAsync("npm install speaker", opencodeNodeModules);
10448
- } catch {
10479
+ const installResult = await execAsync("npm install speaker", opencodeNodeModules);
10480
+ if (installResult.error) {
10481
+ logger9.warn({ err: installResult.error }, "speaker install failed");
10449
10482
  }
10450
10483
  }
10451
- try {
10452
- await execAsync("npm rebuild speaker", opencodeNodeModules);
10453
- if (await verifyModuleLoad(dep)) {
10454
- result.success = true;
10455
- }
10456
- } catch (err) {
10457
- result.stderr = err.stderr?.toString() || err.message || "";
10484
+ const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
10485
+ if (rebuildResult.error) {
10486
+ result.stderr = rebuildResult.stderr || rebuildResult.error.message || "";
10487
+ }
10488
+ if (await verifyModuleLoad(dep)) {
10489
+ result.success = true;
10458
10490
  }
10459
10491
  return result;
10460
10492
  }
@@ -10503,11 +10535,11 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
10503
10535
  }
10504
10536
  logger9.info("speaker installed but not loadable, rebuilding");
10505
10537
  notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10506
- try {
10507
- await execAsync("npm rebuild speaker", opencodeNodeModules);
10538
+ const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
10539
+ if (rebuildResult.error) {
10540
+ logger9.warn({ err: rebuildResult.error }, "speaker rebuild failed");
10541
+ } else {
10508
10542
  logger9.info("speaker rebuilt");
10509
- } catch (err) {
10510
- logger9.warn({ err }, "speaker rebuild failed");
10511
10543
  }
10512
10544
  if (await verifyModuleLoad(dep)) {
10513
10545
  notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
@@ -10516,11 +10548,11 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
10516
10548
  } else {
10517
10549
  logger9.info("speaker not found, installing");
10518
10550
  notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10519
- try {
10520
- await execAsync("npm install speaker", opencodeNodeModules);
10551
+ const installResult = await execAsync("npm install speaker", opencodeNodeModules);
10552
+ if (installResult.error) {
10553
+ logger9.warn({ err: installResult.error }, "speaker install failed");
10554
+ } else {
10521
10555
  logger9.info("speaker installed");
10522
- } catch (err) {
10523
- logger9.warn({ err }, "speaker install failed");
10524
10556
  }
10525
10557
  }
10526
10558
  for (let attempt = 0; attempt < maxRetries; attempt++) {
@@ -10530,11 +10562,11 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
10530
10562
  }
10531
10563
  logger9.info({ attempt, dep }, "speaker not loadable, trying rebuild");
10532
10564
  notificationService.info(`\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
10533
- try {
10534
- await execAsync("npm rebuild speaker", opencodeNodeModules);
10565
+ const rebuildResult = await execAsync("npm rebuild speaker", opencodeNodeModules);
10566
+ if (rebuildResult.error) {
10567
+ logger9.warn({ err: rebuildResult.error }, "speaker rebuild failed");
10568
+ } else {
10535
10569
  logger9.info("speaker rebuilt");
10536
- } catch (err) {
10537
- logger9.warn({ err }, "speaker rebuild failed");
10538
10570
  }
10539
10571
  if (await verifyModuleLoad(dep)) {
10540
10572
  notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
@@ -10557,11 +10589,9 @@ async function ensurePlaySoundInstalled() {
10557
10589
  }
10558
10590
  logger9.info("play-sound not found, installing");
10559
10591
  notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
10560
- try {
10561
- await execAsync("npm install play-sound", opencodeNodeModules);
10562
- logger9.info("play-sound installed");
10563
- } catch (err) {
10564
- logger9.warn({ err }, "play-sound install failed");
10592
+ const installResult = await execAsync("npm install play-sound", opencodeNodeModules);
10593
+ if (installResult.error) {
10594
+ logger9.warn({ err: installResult.error }, "play-sound install failed");
10565
10595
  notificationService.warning(
10566
10596
  "play-sound \u5B89\u88C5\u5931\u8D25",
10567
10597
  "\u8BF7\u624B\u52A8\u8FD0\u884C: npm install play-sound",
@@ -10569,6 +10599,7 @@ async function ensurePlaySoundInstalled() {
10569
10599
  );
10570
10600
  return;
10571
10601
  }
10602
+ logger9.info("play-sound installed");
10572
10603
  if (await verifyModuleLoad(dep)) {
10573
10604
  notificationService.success("play-sound \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
10574
10605
  } else {
@@ -10635,18 +10666,16 @@ async function installPortAudio() {
10635
10666
  const runInstall = async (cmd, desc) => {
10636
10667
  logger9.info(`Running: ${cmd}`);
10637
10668
  notificationService.info(desc, "\u6B63\u5728\u5B89\u88C5...", 5e3);
10638
- try {
10639
- await execAsync(cmd);
10640
- return true;
10641
- } catch (err) {
10642
- const msg = err.message || "";
10669
+ const result = await execAsync(cmd);
10670
+ if (result.error) {
10671
+ const msg = result.error.message || "";
10643
10672
  if (msg.includes("sudo") || msg.includes("password") || msg.includes("Password")) {
10644
10673
  notificationService.error(
10645
10674
  "\u9700\u8981 sudo \u6743\u9650",
10646
10675
  "# \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21\nsudo visudo\n# \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL",
10647
10676
  1e4
10648
10677
  );
10649
- logger9.error({ err }, "\u9700\u8981 sudo \u6743\u9650 \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21sudo visudo # \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL");
10678
+ logger9.error({ err: result.error }, "\u9700\u8981 sudo \u6743\u9650 \u8BF7\u5728WSL\u7EC8\u7AEF\u6267\u884C\u4E00\u6B21sudo visudo # \u6DFB\u52A0\u884C\uFF1Ayour user name ALL=(ALL) NOPASSWD: ALL");
10650
10679
  return false;
10651
10680
  }
10652
10681
  if (msg.includes("already") || msg.includes("is already")) {
@@ -10654,9 +10683,10 @@ async function installPortAudio() {
10654
10683
  return true;
10655
10684
  }
10656
10685
  notificationService.error(desc + " \u5931\u8D25", msg.substring(0, 100), 8e3);
10657
- logger9.error({ err }, `install failed: ${desc}`);
10686
+ logger9.error({ err: result.error }, `install failed: ${desc}`);
10658
10687
  return false;
10659
10688
  }
10689
+ return true;
10660
10690
  };
10661
10691
  if (platform === "linux" || wsl) {
10662
10692
  notificationService.info("\u68C0\u6D4B ffmpeg...", "\u97F3\u9891\u540E\u7AEF", 5e3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/ocosay",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",