@mingxy/ocosay 1.1.10 → 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/plugin.js +102 -3
- package/package.json +1 -1
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");
|
|
@@ -9607,8 +9684,19 @@ 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
9702
|
notificationService.warning("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u6B63\u5728\u5C1D\u8BD5\u5B89\u88C5 PortAudio...", 5e3);
|
|
@@ -9622,7 +9710,18 @@ async function ensureNaudiodonCompiled() {
|
|
|
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
9727
|
notificationService.error("naudiodon \u7F16\u8BD1\u5931\u8D25", "\u81EA\u52A8\u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u5C1D\u8BD5\u624B\u52A8\u5B89\u88C5", 8e3);
|