@mingxy/ocosay 1.1.18 → 1.1.19
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 +55 -53
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -10072,90 +10072,92 @@ async function verifyModuleLoad(dep) {
|
|
|
10072
10072
|
return false;
|
|
10073
10073
|
}
|
|
10074
10074
|
}
|
|
10075
|
-
async function
|
|
10075
|
+
async function ensureSpeakerCompiled(maxRetries = 5) {
|
|
10076
|
+
const dep = "speaker";
|
|
10077
|
+
const basePath = dirname2(require2.resolve("./package.json"));
|
|
10078
|
+
if (await verifyModuleLoad(dep)) {
|
|
10079
|
+
return;
|
|
10080
|
+
}
|
|
10081
|
+
try {
|
|
10082
|
+
require2.resolve(dep);
|
|
10083
|
+
logger8.info("speaker found, rebuilding");
|
|
10084
|
+
notificationService.info("\u6B63\u5728\u7F16\u8BD1 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10085
|
+
execSync2("npm rebuild speaker", {
|
|
10086
|
+
cwd: basePath,
|
|
10087
|
+
stdio: "inherit"
|
|
10088
|
+
});
|
|
10089
|
+
logger8.info("speaker rebuilt, verifying...");
|
|
10090
|
+
} catch {
|
|
10091
|
+
logger8.info("speaker not found or rebuild failed, installing");
|
|
10092
|
+
notificationService.info("\u6B63\u5728\u5B89\u88C5 speaker...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10093
|
+
}
|
|
10076
10094
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
10077
10095
|
if (await verifyModuleLoad(dep)) {
|
|
10078
|
-
|
|
10096
|
+
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10097
|
+
return;
|
|
10079
10098
|
}
|
|
10080
|
-
logger8.info({ attempt, dep }, "
|
|
10081
|
-
notificationService.info(`\u6B63\u5728\
|
|
10099
|
+
logger8.info({ attempt, dep }, "speaker not loadable, trying reinstall");
|
|
10100
|
+
notificationService.info(`\u6B63\u5728\u91CD\u65B0\u5B89\u88C5 speaker (${attempt + 1}/${maxRetries})...`, "Ocosay", 3e3);
|
|
10082
10101
|
try {
|
|
10083
|
-
execSync2("npm
|
|
10084
|
-
cwd:
|
|
10102
|
+
execSync2("npm install speaker", {
|
|
10103
|
+
cwd: basePath,
|
|
10085
10104
|
stdio: "inherit"
|
|
10086
10105
|
});
|
|
10087
|
-
logger8.info(
|
|
10106
|
+
logger8.info("speaker installed");
|
|
10088
10107
|
} catch (err) {
|
|
10089
|
-
logger8.warn({ err },
|
|
10108
|
+
logger8.warn({ err }, "speaker install failed");
|
|
10090
10109
|
}
|
|
10091
10110
|
if (await verifyModuleLoad(dep)) {
|
|
10092
|
-
|
|
10111
|
+
notificationService.success("speaker \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10112
|
+
return;
|
|
10113
|
+
}
|
|
10114
|
+
if (attempt < maxRetries - 1) {
|
|
10115
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
10093
10116
|
}
|
|
10094
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
10095
10117
|
}
|
|
10096
|
-
|
|
10118
|
+
if (await verifyModuleLoad(dep)) {
|
|
10119
|
+
notificationService.success("speaker \u7F16\u8BD1\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
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
|
+
}
|
|
10097
10124
|
}
|
|
10098
|
-
async function
|
|
10099
|
-
const
|
|
10100
|
-
const missingDeps = [];
|
|
10125
|
+
async function ensurePlaySoundInstalled() {
|
|
10126
|
+
const dep = "play-sound";
|
|
10101
10127
|
const basePath = dirname2(require2.resolve("./package.json"));
|
|
10102
|
-
|
|
10103
|
-
if (await verifyModuleLoad(dep)) {
|
|
10104
|
-
continue;
|
|
10105
|
-
}
|
|
10106
|
-
missingDeps.push(dep);
|
|
10107
|
-
}
|
|
10108
|
-
if (missingDeps.length === 0) {
|
|
10128
|
+
if (await verifyModuleLoad(dep)) {
|
|
10109
10129
|
return;
|
|
10110
10130
|
}
|
|
10111
|
-
notificationService.info(
|
|
10112
|
-
`\u6B63\u5728\u5B89\u88C5\u53EF\u9009\u4F9D\u8D56: ${missingDeps.join(", ")}...`,
|
|
10113
|
-
"Ocosay \u97F3\u9891\u540E\u7AEF",
|
|
10114
|
-
5e3
|
|
10115
|
-
);
|
|
10131
|
+
notificationService.info("\u6B63\u5728\u5B89\u88C5 play-sound...", "Ocosay \u97F3\u9891\u540E\u7AEF", 5e3);
|
|
10116
10132
|
try {
|
|
10117
|
-
|
|
10118
|
-
logger8.info({ deps: depsStr }, "installing optional dependencies");
|
|
10119
|
-
execSync2(`npm install ${depsStr}`, {
|
|
10133
|
+
execSync2("npm install play-sound", {
|
|
10120
10134
|
cwd: basePath,
|
|
10121
10135
|
stdio: "inherit"
|
|
10122
10136
|
});
|
|
10123
|
-
logger8.info("
|
|
10137
|
+
logger8.info("play-sound installed");
|
|
10124
10138
|
} catch (err) {
|
|
10125
|
-
logger8.warn({ err }, "
|
|
10139
|
+
logger8.warn({ err }, "play-sound install failed");
|
|
10126
10140
|
notificationService.warning(
|
|
10127
|
-
"\
|
|
10128
|
-
|
|
10141
|
+
"play-sound \u5B89\u88C5\u5931\u8D25",
|
|
10142
|
+
"\u8BF7\u624B\u52A8\u8FD0\u884C: npm install play-sound",
|
|
10129
10143
|
8e3
|
|
10130
10144
|
);
|
|
10131
10145
|
return;
|
|
10132
10146
|
}
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
const depPath = dirname2(require2.resolve(dep, { paths: [basePath] }));
|
|
10136
|
-
if (await verifyModuleLoad(dep)) {
|
|
10137
|
-
continue;
|
|
10138
|
-
}
|
|
10139
|
-
notificationService.warning(`${dep} \u52A0\u8F7D\u5931\u8D25\uFF0C\u6B63\u5728\u5C1D\u8BD5\u7F16\u8BD1...`, "Ocosay", 5e3);
|
|
10140
|
-
const fixed = await fixOptionalDep(dep, depPath);
|
|
10141
|
-
if (!fixed) {
|
|
10142
|
-
allLoaded = false;
|
|
10143
|
-
}
|
|
10144
|
-
}
|
|
10145
|
-
if (allLoaded) {
|
|
10146
|
-
notificationService.success(
|
|
10147
|
-
"\u53EF\u9009\u4F9D\u8D56\u5B89\u88C5\u6210\u529F",
|
|
10148
|
-
"play-sound & speaker \u5DF2\u5C31\u7EEA",
|
|
10149
|
-
5e3
|
|
10150
|
-
);
|
|
10147
|
+
if (await verifyModuleLoad(dep)) {
|
|
10148
|
+
notificationService.success("play-sound \u5B89\u88C5\u6210\u529F", "\u97F3\u9891\u540E\u7AEF\u5DF2\u5C31\u7EEA", 5e3);
|
|
10151
10149
|
} else {
|
|
10152
10150
|
notificationService.warning(
|
|
10153
|
-
"\
|
|
10154
|
-
|
|
10151
|
+
"play-sound \u5B89\u88C5\u5931\u8D25",
|
|
10152
|
+
"\u8BF7\u624B\u52A8\u8FD0\u884C: npm install play-sound",
|
|
10155
10153
|
8e3
|
|
10156
10154
|
);
|
|
10157
10155
|
}
|
|
10158
10156
|
}
|
|
10157
|
+
async function ensureOptionalDepsInstalled() {
|
|
10158
|
+
await ensureSpeakerCompiled();
|
|
10159
|
+
await ensurePlaySoundInstalled();
|
|
10160
|
+
}
|
|
10159
10161
|
function execCmd2(cmd) {
|
|
10160
10162
|
try {
|
|
10161
10163
|
const output = execSync2(cmd, { stdio: "pipe", encoding: "utf8" });
|