@mingxy/ocosay 1.1.3 → 1.1.5
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 +2 -2
- package/dist/plugin.js +35 -11
- package/package.json +2 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingxy/ocosay",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"zod": "^4.3.6"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"naudiodon": "^
|
|
51
|
+
"naudiodon": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/howler": "^2.2.12",
|
package/dist/plugin.js
CHANGED
|
@@ -4650,7 +4650,7 @@ var require_transport = __commonJS({
|
|
|
4650
4650
|
"node_modules/pino/lib/transport.js"(exports, module) {
|
|
4651
4651
|
"use strict";
|
|
4652
4652
|
var { createRequire: createRequire2 } = __require("module");
|
|
4653
|
-
var { existsSync:
|
|
4653
|
+
var { existsSync: existsSync7 } = __require("node:fs");
|
|
4654
4654
|
var getCallers = require_caller();
|
|
4655
4655
|
var { join: join8, isAbsolute, sep } = __require("node:path");
|
|
4656
4656
|
var { fileURLToPath: fileURLToPath2 } = __require("node:url");
|
|
@@ -4724,7 +4724,7 @@ var require_transport = __commonJS({
|
|
|
4724
4724
|
return false;
|
|
4725
4725
|
}
|
|
4726
4726
|
}
|
|
4727
|
-
return isAbsolute(path2) && !
|
|
4727
|
+
return isAbsolute(path2) && !existsSync7(path2);
|
|
4728
4728
|
}
|
|
4729
4729
|
function stripQuotes(value) {
|
|
4730
4730
|
const first = value[0];
|
|
@@ -9551,25 +9551,46 @@ function loadOrCreateConfig() {
|
|
|
9551
9551
|
}
|
|
9552
9552
|
|
|
9553
9553
|
// src/plugin.ts
|
|
9554
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
9554
|
+
import { readFileSync as readFileSync2, existsSync as existsSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
9555
9555
|
import { fileURLToPath } from "url";
|
|
9556
9556
|
import { dirname as dirname2, join as join7 } from "path";
|
|
9557
|
+
import { homedir as homedir3 } from "os";
|
|
9557
9558
|
import { execSync } from "child_process";
|
|
9558
9559
|
import { createRequire } from "module";
|
|
9559
9560
|
var logger7 = createModuleLogger("Plugin");
|
|
9560
9561
|
var require2 = createRequire(import.meta.url);
|
|
9562
|
+
function getSkipFilePath() {
|
|
9563
|
+
return join7(homedir3(), ".config", "opencode", ".naudiodon_skip");
|
|
9564
|
+
}
|
|
9565
|
+
function shouldSkipNaudiodon() {
|
|
9566
|
+
return existsSync6(getSkipFilePath());
|
|
9567
|
+
}
|
|
9568
|
+
function markNaudiodonSkipped() {
|
|
9569
|
+
try {
|
|
9570
|
+
const dir = join7(homedir3(), ".config", "opencode");
|
|
9571
|
+
if (!existsSync6(dir)) {
|
|
9572
|
+
execSync("mkdir -p", { cwd: dir });
|
|
9573
|
+
}
|
|
9574
|
+
writeFileSync5(getSkipFilePath(), Date.now().toString(), "utf-8");
|
|
9575
|
+
} catch {
|
|
9576
|
+
}
|
|
9577
|
+
}
|
|
9561
9578
|
async function ensureNaudiodonCompiled() {
|
|
9579
|
+
if (shouldSkipNaudiodon()) {
|
|
9580
|
+
logger7.info("naudiodon skipped previously");
|
|
9581
|
+
return;
|
|
9582
|
+
}
|
|
9562
9583
|
try {
|
|
9563
9584
|
require2("naudiodon");
|
|
9564
9585
|
logger7.info("naudiodon already compiled");
|
|
9565
9586
|
return;
|
|
9566
9587
|
} catch {
|
|
9567
|
-
logger7.info("naudiodon not compiled,
|
|
9588
|
+
logger7.info("naudiodon not compiled, will attempt to compile");
|
|
9589
|
+
notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF");
|
|
9568
9590
|
}
|
|
9569
9591
|
try {
|
|
9570
9592
|
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
9571
|
-
logger7.info({ naudiodonPath }, "found naudiodon
|
|
9572
|
-
notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF");
|
|
9593
|
+
logger7.info({ naudiodonPath }, "found naudiodon, rebuilding");
|
|
9573
9594
|
execSync("npm rebuild naudiodon", {
|
|
9574
9595
|
cwd: naudiodonPath,
|
|
9575
9596
|
stdio: "inherit"
|
|
@@ -9577,7 +9598,7 @@ async function ensureNaudiodonCompiled() {
|
|
|
9577
9598
|
logger7.info("naudiodon compiled successfully");
|
|
9578
9599
|
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
|
|
9579
9600
|
} catch (err) {
|
|
9580
|
-
logger7.warn({ err }, "naudiodon rebuild failed, checking for PortAudio
|
|
9601
|
+
logger7.warn({ err }, "naudiodon rebuild failed, checking for PortAudio");
|
|
9581
9602
|
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...");
|
|
9582
9603
|
const installed = installPortAudio();
|
|
9583
9604
|
if (installed) {
|
|
@@ -9591,11 +9612,14 @@ async function ensureNaudiodonCompiled() {
|
|
|
9591
9612
|
logger7.info("naudiodon compiled successfully after PortAudio install");
|
|
9592
9613
|
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
|
|
9593
9614
|
} catch (retryErr) {
|
|
9594
|
-
logger7.error({ err: retryErr }, "
|
|
9595
|
-
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u8BF7\u624B\u52A8\
|
|
9615
|
+
logger7.error({ err: retryErr }, "naudiodon compile failed even after PortAudio install");
|
|
9616
|
+
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5");
|
|
9617
|
+
markNaudiodonSkipped();
|
|
9596
9618
|
}
|
|
9597
9619
|
} else {
|
|
9598
|
-
|
|
9620
|
+
logger7.error("PortAudio install failed");
|
|
9621
|
+
notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5");
|
|
9622
|
+
markNaudiodonSkipped();
|
|
9599
9623
|
}
|
|
9600
9624
|
}
|
|
9601
9625
|
}
|
|
@@ -9748,7 +9772,6 @@ var server = (async (input, _options) => {
|
|
|
9748
9772
|
const opencodeTui = input.client?.tui;
|
|
9749
9773
|
global.__opencode_tui__ = opencodeTui;
|
|
9750
9774
|
notificationService.setTui(opencodeTui);
|
|
9751
|
-
await ensureNaudiodonCompiled();
|
|
9752
9775
|
const config = loadOrCreateConfig();
|
|
9753
9776
|
try {
|
|
9754
9777
|
await initialize({
|
|
@@ -9765,6 +9788,7 @@ var server = (async (input, _options) => {
|
|
|
9765
9788
|
initError = err instanceof Error ? err : new Error(String(err));
|
|
9766
9789
|
logger7.error({ error: initError }, "initialization failed");
|
|
9767
9790
|
}
|
|
9791
|
+
await ensureNaudiodonCompiled();
|
|
9768
9792
|
setTimeout(() => {
|
|
9769
9793
|
if (initError) {
|
|
9770
9794
|
notificationService.error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingxy/ocosay",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "OpenCode TTS 播放插件 - 支持豆包模式边接收边朗读",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/plugin.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"zod": "^4.3.6"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"naudiodon": "^
|
|
51
|
+
"naudiodon": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/howler": "^2.2.12",
|