@mingxy/ocosay 1.1.9 → 1.1.11
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 +1 -1
- package/dist/plugin.js +119 -19
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -9587,6 +9587,83 @@ function markNaudiodonSkipped() {
|
|
|
9587
9587
|
} catch {
|
|
9588
9588
|
}
|
|
9589
9589
|
}
|
|
9590
|
+
async function verifyNaudiodonLoad() {
|
|
9591
|
+
try {
|
|
9592
|
+
require2("naudiodon");
|
|
9593
|
+
logger8.info("naudiodon loaded successfully");
|
|
9594
|
+
return true;
|
|
9595
|
+
} catch (err) {
|
|
9596
|
+
logger8.warn({ err }, "naudiodon load failed after rebuild");
|
|
9597
|
+
return false;
|
|
9598
|
+
}
|
|
9599
|
+
}
|
|
9600
|
+
async function rebuildNaudiodonDependency(dep) {
|
|
9601
|
+
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
9602
|
+
try {
|
|
9603
|
+
notificationService.info(`\u6B63\u5728\u7F16\u8BD1 ${dep}...`, "Ocosay \u4F9D\u8D56", 4e3);
|
|
9604
|
+
execSync(`npm rebuild ${dep}`, {
|
|
9605
|
+
cwd: naudiodonPath,
|
|
9606
|
+
stdio: "inherit"
|
|
9607
|
+
});
|
|
9608
|
+
logger8.info(`${dep} rebuilt successfully`);
|
|
9609
|
+
return true;
|
|
9610
|
+
} catch (err) {
|
|
9611
|
+
logger8.warn({ err }, `${dep} rebuild failed`);
|
|
9612
|
+
return false;
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9615
|
+
async function fixNaudiodonDependencies(maxRetries = 5) {
|
|
9616
|
+
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
9617
|
+
const criticalDeps = ["segfault-handler", "bindings", "node-pre-gyp"];
|
|
9618
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
9619
|
+
if (await verifyNaudiodonLoad()) {
|
|
9620
|
+
return true;
|
|
9621
|
+
}
|
|
9622
|
+
logger8.info({ attempt }, "naudiodon not loadable, trying dependency rebuild");
|
|
9623
|
+
notificationService.info(`\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56 (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
|
|
9624
|
+
let anySuccess = false;
|
|
9625
|
+
for (const dep of criticalDeps) {
|
|
9626
|
+
try {
|
|
9627
|
+
require2.resolve(dep, { paths: [naudiodonPath] });
|
|
9628
|
+
if (await rebuildNaudiodonDependency(dep)) {
|
|
9629
|
+
anySuccess = true;
|
|
9630
|
+
}
|
|
9631
|
+
} catch {
|
|
9632
|
+
try {
|
|
9633
|
+
notificationService.info(`\u6B63\u5728\u5B89\u88C5 ${dep}...`, "Ocosay", 4e3);
|
|
9634
|
+
execSync(`npm install ${dep}`, {
|
|
9635
|
+
cwd: naudiodonPath,
|
|
9636
|
+
stdio: "inherit"
|
|
9637
|
+
});
|
|
9638
|
+
logger8.info(`${dep} installed successfully`);
|
|
9639
|
+
anySuccess = true;
|
|
9640
|
+
} catch (installErr) {
|
|
9641
|
+
logger8.warn({ err: installErr }, `${dep} install failed`);
|
|
9642
|
+
}
|
|
9643
|
+
}
|
|
9644
|
+
}
|
|
9645
|
+
if (!anySuccess || !await verifyNaudiodonLoad()) {
|
|
9646
|
+
try {
|
|
9647
|
+
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 4e3);
|
|
9648
|
+
execSync("npm rebuild naudiodon", {
|
|
9649
|
+
cwd: naudiodonPath,
|
|
9650
|
+
stdio: "inherit"
|
|
9651
|
+
});
|
|
9652
|
+
logger8.info("naudiodon rebuilt");
|
|
9653
|
+
anySuccess = true;
|
|
9654
|
+
} catch (err) {
|
|
9655
|
+
logger8.warn({ err }, "naudiodon rebuild failed");
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
if (await verifyNaudiodonLoad()) {
|
|
9659
|
+
return true;
|
|
9660
|
+
}
|
|
9661
|
+
if (anySuccess) {
|
|
9662
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
9663
|
+
}
|
|
9664
|
+
}
|
|
9665
|
+
return await verifyNaudiodonLoad();
|
|
9666
|
+
}
|
|
9590
9667
|
async function ensureNaudiodonCompiled() {
|
|
9591
9668
|
if (shouldSkipNaudiodon()) {
|
|
9592
9669
|
logger8.info("naudiodon skipped previously");
|
|
@@ -9598,7 +9675,7 @@ async function ensureNaudiodonCompiled() {
|
|
|
9598
9675
|
return;
|
|
9599
9676
|
} catch {
|
|
9600
9677
|
logger8.info("naudiodon not compiled, will attempt to compile");
|
|
9601
|
-
notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF");
|
|
9678
|
+
notificationService.info("\u6B63\u5728\u7F16\u8BD1 naudiodon...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
9602
9679
|
}
|
|
9603
9680
|
try {
|
|
9604
9681
|
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
@@ -9607,30 +9684,52 @@ async function ensureNaudiodonCompiled() {
|
|
|
9607
9684
|
cwd: naudiodonPath,
|
|
9608
9685
|
stdio: "inherit"
|
|
9609
9686
|
});
|
|
9610
|
-
logger8.info("naudiodon compiled
|
|
9611
|
-
|
|
9687
|
+
logger8.info("naudiodon compiled, verifying...");
|
|
9688
|
+
const loadSuccess = await verifyNaudiodonLoad();
|
|
9689
|
+
if (loadSuccess) {
|
|
9690
|
+
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
9691
|
+
} else {
|
|
9692
|
+
notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
|
|
9693
|
+
const fixed = await fixNaudiodonDependencies();
|
|
9694
|
+
if (fixed) {
|
|
9695
|
+
notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
9696
|
+
} else {
|
|
9697
|
+
throw new Error("naudiodon dependencies could not be fixed");
|
|
9698
|
+
}
|
|
9699
|
+
}
|
|
9612
9700
|
} catch (err) {
|
|
9613
9701
|
logger8.warn({ err }, "naudiodon rebuild failed, checking for PortAudio");
|
|
9614
|
-
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...");
|
|
9702
|
+
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
|
|
9615
9703
|
const installed = await installPortAudio();
|
|
9616
9704
|
if (installed.success) {
|
|
9617
9705
|
try {
|
|
9618
9706
|
const naudiodonPath = dirname2(require2.resolve("naudiodon"));
|
|
9619
|
-
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay");
|
|
9707
|
+
notificationService.info("\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 naudiodon...", "Ocosay", 5e3);
|
|
9620
9708
|
execSync("npm rebuild naudiodon", {
|
|
9621
9709
|
cwd: naudiodonPath,
|
|
9622
9710
|
stdio: "inherit"
|
|
9623
9711
|
});
|
|
9624
9712
|
logger8.info("naudiodon compiled successfully after PortAudio install");
|
|
9625
|
-
|
|
9713
|
+
const loadSuccess = await verifyNaudiodonLoad();
|
|
9714
|
+
if (loadSuccess) {
|
|
9715
|
+
notificationService.success("naudiodon \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
9716
|
+
} else {
|
|
9717
|
+
notificationService.warning("naudiodon \u52A0\u8F7D\u5931\u8D25", "\u6B63\u5728\u68C0\u67E5\u4F9D\u8D56...", 5e3);
|
|
9718
|
+
const fixed = await fixNaudiodonDependencies();
|
|
9719
|
+
if (fixed) {
|
|
9720
|
+
notificationService.success("naudiodon \u4F9D\u8D56\u4FEE\u590D\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
9721
|
+
} else {
|
|
9722
|
+
throw new Error("naudiodon dependencies could not be fixed");
|
|
9723
|
+
}
|
|
9724
|
+
}
|
|
9626
9725
|
} catch (retryErr) {
|
|
9627
9726
|
logger8.error({ err: retryErr }, "naudiodon compile failed even after PortAudio install");
|
|
9628
|
-
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5");
|
|
9727
|
+
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|
|
9629
9728
|
markNaudiodonSkipped();
|
|
9630
9729
|
}
|
|
9631
9730
|
} else {
|
|
9632
9731
|
logger8.error("PortAudio install failed");
|
|
9633
|
-
notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5");
|
|
9732
|
+
notificationService.error("PortAudio \u5B89\u88C5\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|
|
9634
9733
|
markNaudiodonSkipped();
|
|
9635
9734
|
}
|
|
9636
9735
|
}
|
|
@@ -9663,7 +9762,7 @@ async function installPortAudio() {
|
|
|
9663
9762
|
logger8.info({ platform, wsl }, "installing PortAudio");
|
|
9664
9763
|
const runInstall = async (cmd, desc) => {
|
|
9665
9764
|
logger8.info(`Running: ${cmd}`);
|
|
9666
|
-
notificationService.info(desc, "\u6B63\u5728\u5B89\u88C5...");
|
|
9765
|
+
notificationService.info(desc, "\u6B63\u5728\u5B89\u88C5...", 5e3);
|
|
9667
9766
|
try {
|
|
9668
9767
|
execSync(cmd, { stdio: "inherit" });
|
|
9669
9768
|
return true;
|
|
@@ -9672,7 +9771,8 @@ async function installPortAudio() {
|
|
|
9672
9771
|
if (msg.includes("sudo") || msg.includes("password") || msg.includes("Password")) {
|
|
9673
9772
|
notificationService.error(
|
|
9674
9773
|
"\u9700\u8981 sudo \u6743\u9650",
|
|
9675
|
-
"\u8BF7\u624B\u52A8\u8FD0\u884C: sudo apt-get update && sudo apt-get install -y alsa-utils"
|
|
9774
|
+
"\u8BF7\u624B\u52A8\u8FD0\u884C: sudo apt-get update && sudo apt-get install -y alsa-utils",
|
|
9775
|
+
8e3
|
|
9676
9776
|
);
|
|
9677
9777
|
logger8.error({ err }, "sudo password required");
|
|
9678
9778
|
return false;
|
|
@@ -9681,41 +9781,41 @@ async function installPortAudio() {
|
|
|
9681
9781
|
logger8.info("already installed");
|
|
9682
9782
|
return true;
|
|
9683
9783
|
}
|
|
9684
|
-
notificationService.error(desc + " \u5931\u8D25", msg.substring(0, 100));
|
|
9784
|
+
notificationService.error(desc + " \u5931\u8D25", msg.substring(0, 100), 8e3);
|
|
9685
9785
|
logger8.error({ err }, `install failed: ${desc}`);
|
|
9686
9786
|
return false;
|
|
9687
9787
|
}
|
|
9688
9788
|
};
|
|
9689
9789
|
if (platform === "linux" || wsl) {
|
|
9690
|
-
notificationService.info("\u68C0\u6D4B\u97F3\u9891\u8BBE\u5907...", "\u97F3\u9891\u540E\u7AEF");
|
|
9790
|
+
notificationService.info("\u68C0\u6D4B\u97F3\u9891\u8BBE\u5907...", "\u97F3\u9891\u540E\u7AEF", 5e3);
|
|
9691
9791
|
if (checkAlsa()) {
|
|
9692
9792
|
logger8.info("alsa-utils already available and working");
|
|
9693
|
-
notificationService.success("alsa-utils \u5C31\u7EEA", "\u97F3\u9891\u540E\u7AEF\u5DF2\u53EF\u7528");
|
|
9793
|
+
notificationService.success("alsa-utils \u5C31\u7EEA", "\u97F3\u9891\u540E\u7AEF\u5DF2\u53EF\u7528", 5e3);
|
|
9694
9794
|
return { success: true, message: "alsa" };
|
|
9695
9795
|
}
|
|
9696
|
-
notificationService.info("\u5B89\u88C5 alsa-utils...", "\u97F3\u9891\u540E\u7AEF");
|
|
9796
|
+
notificationService.info("\u5B89\u88C5 alsa-utils...", "\u97F3\u9891\u540E\u7AEF", 5e3);
|
|
9697
9797
|
const alsaInstalled = await runInstall(
|
|
9698
9798
|
"sudo apt-get update && sudo apt-get install -y alsa-utils",
|
|
9699
9799
|
"\u5B89\u88C5 alsa-utils"
|
|
9700
9800
|
);
|
|
9701
9801
|
if (alsaInstalled) {
|
|
9702
9802
|
if (checkAlsa()) {
|
|
9703
|
-
notificationService.success("alsa-utils \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
|
|
9803
|
+
notificationService.success("alsa-utils \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
9704
9804
|
return { success: true, message: "alsa" };
|
|
9705
9805
|
} else {
|
|
9706
|
-
notificationService.warning("alsa-utils \u5B89\u88C5\u540E\u68C0\u6D4B\u5931\u8D25", "\u7EE7\u7EED\u5C1D\u8BD5\u5176\u4ED6\u65B9\u6848");
|
|
9806
|
+
notificationService.warning("alsa-utils \u5B89\u88C5\u540E\u68C0\u6D4B\u5931\u8D25", "\u7EE7\u7EED\u5C1D\u8BD5\u5176\u4ED6\u65B9\u6848", 5e3);
|
|
9707
9807
|
}
|
|
9708
9808
|
}
|
|
9709
|
-
notificationService.info("\u5B89\u88C5 libportaudio-dev...", "\u97F3\u9891\u540E\u7AEF");
|
|
9809
|
+
notificationService.info("\u5B89\u88C5 libportaudio-dev...", "\u97F3\u9891\u540E\u7AEF", 5e3);
|
|
9710
9810
|
const portaudioInstalled = await runInstall(
|
|
9711
9811
|
"sudo apt-get update && sudo apt-get install -y libportaudio-dev",
|
|
9712
9812
|
"\u5B89\u88C5 libportaudio-dev"
|
|
9713
9813
|
);
|
|
9714
9814
|
if (portaudioInstalled) {
|
|
9715
|
-
notificationService.success("libportaudio-dev \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA");
|
|
9815
|
+
notificationService.success("libportaudio-dev \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
9716
9816
|
return { success: true, message: "portaudio" };
|
|
9717
9817
|
}
|
|
9718
|
-
notificationService.warning("PortAudio \u5B89\u88C5\u5931\u8D25", "\u97F3\u9891\u53EF\u80FD\u65E0\u6CD5\u6B63\u5E38\u5DE5\u4F5C");
|
|
9818
|
+
notificationService.warning("PortAudio \u5B89\u88C5\u5931\u8D25", "\u97F3\u9891\u53EF\u80FD\u65E0\u6CD5\u6B63\u5E38\u5DE5\u4F5C", 5e3);
|
|
9719
9819
|
markNaudiodonSkipped();
|
|
9720
9820
|
return { success: false, message: "linux install failed" };
|
|
9721
9821
|
}
|