@mingxy/ocosay 1.1.19 → 1.1.20
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 +52 -27
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -10062,6 +10062,14 @@ async function ensureNaudiodonCompiled() {
|
|
|
10062
10062
|
}
|
|
10063
10063
|
}
|
|
10064
10064
|
}
|
|
10065
|
+
function isModuleInstalled(moduleName) {
|
|
10066
|
+
try {
|
|
10067
|
+
require2.resolve(moduleName);
|
|
10068
|
+
return true;
|
|
10069
|
+
} catch {
|
|
10070
|
+
return false;
|
|
10071
|
+
}
|
|
10072
|
+
}
|
|
10065
10073
|
async function verifyModuleLoad(dep) {
|
|
10066
10074
|
try {
|
|
10067
10075
|
require2(dep);
|
|
@@ -10075,29 +10083,29 @@ async function verifyModuleLoad(dep) {
|
|
|
10075
10083
|
async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
10076
10084
|
const dep = "speaker";
|
|
10077
10085
|
const basePath = dirname2(require2.resolve("./package.json"));
|
|
10078
|
-
if (
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
logger8.info("speaker
|
|
10086
|
+
if (isModuleInstalled(dep)) {
|
|
10087
|
+
logger8.info("speaker already installed");
|
|
10088
|
+
if (await verifyModuleLoad(dep)) {
|
|
10089
|
+
return;
|
|
10090
|
+
}
|
|
10091
|
+
logger8.info("speaker installed but not loadable, rebuilding");
|
|
10084
10092
|
notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
10093
|
+
try {
|
|
10094
|
+
execSync2("npm rebuild speaker", {
|
|
10095
|
+
cwd: basePath,
|
|
10096
|
+
stdio: "inherit"
|
|
10097
|
+
});
|
|
10098
|
+
logger8.info("speaker rebuilt");
|
|
10099
|
+
} catch (err) {
|
|
10100
|
+
logger8.warn({ err }, "speaker rebuild failed");
|
|
10101
|
+
}
|
|
10095
10102
|
if (await verifyModuleLoad(dep)) {
|
|
10096
10103
|
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10097
10104
|
return;
|
|
10098
10105
|
}
|
|
10099
|
-
|
|
10100
|
-
|
|
10106
|
+
} else {
|
|
10107
|
+
logger8.info("speaker not found, installing");
|
|
10108
|
+
notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10101
10109
|
try {
|
|
10102
10110
|
execSync2("npm install speaker", {
|
|
10103
10111
|
cwd: basePath,
|
|
@@ -10107,27 +10115,44 @@ async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
|
10107
10115
|
} catch (err) {
|
|
10108
10116
|
logger8.warn({ err }, "speaker install failed");
|
|
10109
10117
|
}
|
|
10118
|
+
}
|
|
10119
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
10120
|
+
if (await verifyModuleLoad(dep)) {
|
|
10121
|
+
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10122
|
+
return;
|
|
10123
|
+
}
|
|
10124
|
+
logger8.info({ attempt, dep }, "speaker not loadable, trying rebuild");
|
|
10125
|
+
notificationService.info(`\u6B63\u5728\u91CD\u65B0\u7F16\u8BD1 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
|
|
10126
|
+
try {
|
|
10127
|
+
execSync2("npm rebuild speaker", {
|
|
10128
|
+
cwd: basePath,
|
|
10129
|
+
stdio: "inherit"
|
|
10130
|
+
});
|
|
10131
|
+
logger8.info("speaker rebuilt");
|
|
10132
|
+
} catch (err) {
|
|
10133
|
+
logger8.warn({ err }, "speaker rebuild failed");
|
|
10134
|
+
}
|
|
10110
10135
|
if (await verifyModuleLoad(dep)) {
|
|
10111
|
-
notificationService.success("speaker \
|
|
10136
|
+
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10112
10137
|
return;
|
|
10113
10138
|
}
|
|
10114
10139
|
if (attempt < maxRetries - 1) {
|
|
10115
10140
|
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
10116
10141
|
}
|
|
10117
10142
|
}
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
} else {
|
|
10121
|
-
logger8.error({ dep }, "speaker could not be compiled");
|
|
10122
|
-
notificationService.error("speaker \u7F16\u8BD1\u5931\u8D25", "\u8BF7\u624B\u52A8\u8FD0\u884C: npm install speaker && npm rebuild speaker", 8e3);
|
|
10123
|
-
}
|
|
10143
|
+
logger8.error({ dep }, "speaker could not be compiled");
|
|
10144
|
+
notificationService.error("speaker \u7F16\u8BD1\u5931\u8D25", "\u8BF7\u624B\u52A8\u8FD0\u884C: npm install speaker && npm rebuild speaker", 8e3);
|
|
10124
10145
|
}
|
|
10125
10146
|
async function ensurePlaySoundInstalled() {
|
|
10126
10147
|
const dep = "play-sound";
|
|
10127
10148
|
const basePath = dirname2(require2.resolve("./package.json"));
|
|
10128
|
-
if (
|
|
10129
|
-
|
|
10149
|
+
if (isModuleInstalled(dep)) {
|
|
10150
|
+
logger8.info("play-sound already installed");
|
|
10151
|
+
if (await verifyModuleLoad(dep)) {
|
|
10152
|
+
return;
|
|
10153
|
+
}
|
|
10130
10154
|
}
|
|
10155
|
+
logger8.info("play-sound not found, installing");
|
|
10131
10156
|
notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10132
10157
|
try {
|
|
10133
10158
|
execSync2("npm install play-sound", {
|