@mingxy/ocosay 1.1.2 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/ocosay",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",
@@ -29,9 +29,7 @@
29
29
  "build:plugin": "esbuild src/plugin.ts --bundle --platform=node --format=esm --outdir=dist --sourcemap --external:@opencode-ai/plugin --external:axios --external:ws --external:zod",
30
30
  "watch": "tsc --watch",
31
31
  "test": "jest",
32
- "lint": "eslint src --ext .ts",
33
- "install-deps": "node scripts/install-native-deps.js",
34
- "postinstall": "node scripts/verify-audio.js"
32
+ "lint": "eslint src --ext .ts"
35
33
  },
36
34
  "keywords": [
37
35
  "tts",
@@ -50,7 +48,6 @@
50
48
  "zod": "^4.3.6"
51
49
  },
52
50
  "optionalDependencies": {
53
- "bindings": "^1.5.0",
54
51
  "naudiodon": "^1.0.0"
55
52
  },
56
53
  "devDependencies": {
package/dist/plugin.js CHANGED
@@ -4649,7 +4649,7 @@ var require_thread_stream = __commonJS({
4649
4649
  var require_transport = __commonJS({
4650
4650
  "node_modules/pino/lib/transport.js"(exports, module) {
4651
4651
  "use strict";
4652
- var { createRequire } = __require("module");
4652
+ var { createRequire: createRequire2 } = __require("module");
4653
4653
  var { existsSync: existsSync6 } = __require("node:fs");
4654
4654
  var getCallers = require_caller();
4655
4655
  var { join: join8, isAbsolute, sep } = __require("node:path");
@@ -4852,7 +4852,7 @@ var require_transport = __commonJS({
4852
4852
  for (const filePath of callers) {
4853
4853
  try {
4854
4854
  const context = filePath === "node:repl" ? process.cwd() + sep : filePath;
4855
- fixTarget2 = createRequire(context).resolve(origin);
4855
+ fixTarget2 = createRequire2(context).resolve(origin);
4856
4856
  break;
4857
4857
  } catch (err) {
4858
4858
  continue;
@@ -9554,7 +9554,72 @@ function loadOrCreateConfig() {
9554
9554
  import { readFileSync as readFileSync2 } from "fs";
9555
9555
  import { fileURLToPath } from "url";
9556
9556
  import { dirname as dirname2, join as join7 } from "path";
9557
+ import { execSync } from "child_process";
9558
+ import { createRequire } from "module";
9557
9559
  var logger7 = createModuleLogger("Plugin");
9560
+ var require2 = createRequire(import.meta.url);
9561
+ async function ensureNaudiodonCompiled() {
9562
+ try {
9563
+ require2("naudiodon");
9564
+ logger7.info("naudiodon already compiled");
9565
+ return;
9566
+ } catch {
9567
+ logger7.info("naudiodon not compiled, attempting to compile...");
9568
+ }
9569
+ try {
9570
+ const naudiodonPath = dirname2(require2.resolve("naudiodon"));
9571
+ logger7.info({ naudiodonPath }, "found naudiodon at");
9572
+ notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF");
9573
+ execSync("npm rebuild naudiodon", {
9574
+ cwd: naudiodonPath,
9575
+ stdio: "inherit"
9576
+ });
9577
+ logger7.info("naudiodon compiled successfully");
9578
+ notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
9579
+ } catch (err) {
9580
+ logger7.warn({ err }, "naudiodon rebuild failed, checking for PortAudio...");
9581
+ notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...");
9582
+ const installed = installPortAudio();
9583
+ if (installed) {
9584
+ try {
9585
+ const naudiodonPath = dirname2(require2.resolve("naudiodon"));
9586
+ notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay");
9587
+ execSync("npm rebuild naudiodon", {
9588
+ cwd: naudiodonPath,
9589
+ stdio: "inherit"
9590
+ });
9591
+ logger7.info("naudiodon compiled successfully after PortAudio install");
9592
+ notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
9593
+ } catch (retryErr) {
9594
+ logger7.error({ err: retryErr }, "failed to compile naudiodon even after PortAudio install");
9595
+ notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u8BF7\u624B\u52A8\u8FD0\u884C: npm rebuild naudiodon");
9596
+ }
9597
+ } else {
9598
+ notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u8BF7\u624B\u52A8\u5B89\u88C5\u540E\u91CD\u8BD5");
9599
+ }
9600
+ }
9601
+ }
9602
+ function installPortAudio() {
9603
+ const platform = process.platform;
9604
+ logger7.info({ platform }, "installing PortAudio for platform");
9605
+ notificationService.info("\u6B63\u5728\u5B89\u88C5 PortAudio...", `\u5E73\u53F0: ${platform}`);
9606
+ try {
9607
+ if (platform === "linux") {
9608
+ execSync("sudo apt-get update && sudo apt-get install -y libportaudio-dev portaudio", { stdio: "inherit" });
9609
+ } else if (platform === "darwin") {
9610
+ execSync("brew install portaudio", { stdio: "inherit" });
9611
+ } else if (platform === "win32") {
9612
+ execSync("choco install portaudio -y", { stdio: "inherit" });
9613
+ } else {
9614
+ logger7.warn("unsupported platform for automatic PortAudio install");
9615
+ return false;
9616
+ }
9617
+ return true;
9618
+ } catch (err) {
9619
+ logger7.error({ err }, "failed to install PortAudio automatically");
9620
+ return false;
9621
+ }
9622
+ }
9558
9623
  var __filename = fileURLToPath(import.meta.url);
9559
9624
  var __dirname2 = dirname2(__filename);
9560
9625
  var id = "ocosay";
@@ -9680,6 +9745,10 @@ var ttsStreamStatusTool = tool({
9680
9745
  });
9681
9746
  var initError = null;
9682
9747
  var server = (async (input, _options) => {
9748
+ const opencodeTui = input.client?.tui;
9749
+ global.__opencode_tui__ = opencodeTui;
9750
+ notificationService.setTui(opencodeTui);
9751
+ await ensureNaudiodonCompiled();
9683
9752
  const config = loadOrCreateConfig();
9684
9753
  try {
9685
9754
  await initialize({
@@ -9696,9 +9765,6 @@ var server = (async (input, _options) => {
9696
9765
  initError = err instanceof Error ? err : new Error(String(err));
9697
9766
  logger7.error({ error: initError }, "initialization failed");
9698
9767
  }
9699
- const opencodeTui = input.client?.tui;
9700
- global.__opencode_tui__ = opencodeTui;
9701
- notificationService.setTui(opencodeTui);
9702
9768
  setTimeout(() => {
9703
9769
  if (initError) {
9704
9770
  notificationService.error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingxy/ocosay",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",
@@ -29,9 +29,7 @@
29
29
  "build:plugin": "esbuild src/plugin.ts --bundle --platform=node --format=esm --outdir=dist --sourcemap --external:@opencode-ai/plugin --external:axios --external:ws --external:zod",
30
30
  "watch": "tsc --watch",
31
31
  "test": "jest",
32
- "lint": "eslint src --ext .ts",
33
- "install": "node scripts/install-portaudio.cjs && node scripts/compile-native.cjs",
34
- "install:portaudio": "node scripts/install-portaudio.cjs"
32
+ "lint": "eslint src --ext .ts"
35
33
  },
36
34
  "keywords": [
37
35
  "tts",
@@ -50,7 +48,7 @@
50
48
  "zod": "^4.3.6"
51
49
  },
52
50
  "optionalDependencies": {
53
- "naudiodon": "^2.3.1"
51
+ "naudiodon": "^1.0.0"
54
52
  },
55
53
  "devDependencies": {
56
54
  "@types/howler": "^2.2.12",