@open-wxa/wxa-runner-core 0.12.2 → 0.12.3
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/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -8
- package/dist/index.mjs.map +1 -1
- package/dist/runtime/frame.js +28 -2
- package/dist/runtime/frame.js.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -600,8 +600,8 @@ var AppBuilder = class {
|
|
|
600
600
|
this.pending = { covers: this.changes, result: result2 };
|
|
601
601
|
}
|
|
602
602
|
const { covers, result } = this.pending;
|
|
603
|
-
|
|
604
|
-
|
|
603
|
+
if (covers >= wanted) return result;
|
|
604
|
+
await result.catch(() => void 0);
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
/**
|
|
@@ -1994,6 +1994,8 @@ var DevServer = class {
|
|
|
1994
1994
|
this.socketProxy = null;
|
|
1995
1995
|
this.sockets = null;
|
|
1996
1996
|
this.watcher = null;
|
|
1997
|
+
/** 上次编译失败时页面上显示着错误,修好后整页刷新才能清掉 */
|
|
1998
|
+
this.lastBuildFailed = false;
|
|
1997
1999
|
this.address = "";
|
|
1998
2000
|
this.lanAccess = false;
|
|
1999
2001
|
/** 运行时生成的临时文件(canvas 导出、拍照等),随服务器进程存在 */
|
|
@@ -2037,10 +2039,12 @@ var DevServer = class {
|
|
|
2037
2039
|
return Object.values(os3.networkInterfaces()).flat().filter((net2) => net2 && net2.family === "IPv4" && !net2.internal).map((net2) => `http://${net2.address}:${port}`);
|
|
2038
2040
|
}
|
|
2039
2041
|
async start() {
|
|
2042
|
+
if (this.options.watch !== false) await this.startWatching();
|
|
2040
2043
|
try {
|
|
2041
2044
|
const build2 = await this.builder.build();
|
|
2042
2045
|
this.logger.log(`[wxa-runner] \u7F16\u8BD1\u5B8C\u6210\uFF1A${build2.pages.length} \u4E2A\u9875\u9762\uFF0C${build2.components.length} \u4E2A\u7EC4\u4EF6\uFF0C${build2.durationMs}ms`);
|
|
2043
2046
|
} catch (error) {
|
|
2047
|
+
this.lastBuildFailed = true;
|
|
2044
2048
|
this.logger.error(`[wxa-runner] \u7F16\u8BD1\u5931\u8D25\uFF1A
|
|
2045
2049
|
${error.message}`);
|
|
2046
2050
|
}
|
|
@@ -2063,11 +2067,17 @@ ${error.message}`);
|
|
|
2063
2067
|
}
|
|
2064
2068
|
});
|
|
2065
2069
|
const host = this.options.host || "localhost";
|
|
2066
|
-
|
|
2070
|
+
let port;
|
|
2071
|
+
try {
|
|
2072
|
+
port = await listen(server, this.options.port, host, this.logger);
|
|
2073
|
+
} catch (error) {
|
|
2074
|
+
await this.watcher?.close();
|
|
2075
|
+
this.watcher = null;
|
|
2076
|
+
throw error;
|
|
2077
|
+
}
|
|
2067
2078
|
this.server = server;
|
|
2068
2079
|
this.lanAccess = LOCAL_HOST_OF_ANY_ADDRESS.has(host);
|
|
2069
2080
|
this.address = `http://${LOCAL_HOST_OF_ANY_ADDRESS.get(host) ?? host}:${port}`;
|
|
2070
|
-
if (this.options.watch !== false) this.startWatching();
|
|
2071
2081
|
this.ticketSource?.().then(requireUsableTicket).catch((error) => this.logger.warn(`[wxa-runner] \u5F00\u53D1\u8005\u5DE5\u5177\u7684\u767B\u5F55\u6001\u6682\u4E0D\u53EF\u7528\uFF08--devtools-login\uFF09\uFF1A${error.message}`));
|
|
2072
2082
|
return this.address;
|
|
2073
2083
|
}
|
|
@@ -2304,31 +2314,32 @@ ${error.message}`);
|
|
|
2304
2314
|
get hotEnabled() {
|
|
2305
2315
|
return this.options.watch !== false;
|
|
2306
2316
|
}
|
|
2317
|
+
/** 返回初次扫描完成的时刻,此前已存在的文件不会作为改动报告 */
|
|
2307
2318
|
startWatching() {
|
|
2308
|
-
let lastBuildFailed = false;
|
|
2309
2319
|
const watched = [this.project.root];
|
|
2310
2320
|
const outsideRoot = (file) => path6.relative(this.project.root, file).startsWith("..");
|
|
2311
2321
|
if (this.setupFile && outsideRoot(this.setupFile)) watched.push(this.setupFile);
|
|
2312
2322
|
const projectConfig = path6.join(this.project.projectPath, "project.config.json");
|
|
2313
2323
|
if (outsideRoot(projectConfig) && fs6.existsSync(projectConfig)) watched.push(projectConfig);
|
|
2314
2324
|
this.watcher = watchProject(this.project.root, watched, async ({ files, structural }) => {
|
|
2315
|
-
const reloadOnly = structural || lastBuildFailed;
|
|
2325
|
+
const reloadOnly = structural || this.lastBuildFailed;
|
|
2316
2326
|
this.builder.invalidate(files);
|
|
2317
2327
|
const label = files.length > 3 ? `${files.slice(0, 3).join(", ")} \u7B49 ${files.length} \u4E2A\u6587\u4EF6` : files.join(", ");
|
|
2318
2328
|
try {
|
|
2319
2329
|
const build2 = await this.builder.build();
|
|
2320
|
-
lastBuildFailed = false;
|
|
2330
|
+
this.lastBuildFailed = false;
|
|
2321
2331
|
const plan = reloadOnly ? null : planHotUpdate(files, build2);
|
|
2322
2332
|
this.logger.log(`[wxa-runner] ${label} \u5DF2\u66F4\u65B0\uFF0C\u91CD\u65B0\u7F16\u8BD1 ${build2.durationMs}ms${plan ? "\uFF0C\u70ED\u66F4\u65B0" : ""}`);
|
|
2323
2333
|
this.broadcast(plan ? { type: "hot", version: build2.version, ...plan } : { type: "reload" });
|
|
2324
2334
|
} catch (error) {
|
|
2325
|
-
lastBuildFailed = true;
|
|
2335
|
+
this.lastBuildFailed = true;
|
|
2326
2336
|
const message = error.message;
|
|
2327
2337
|
this.logger.error(`[wxa-runner] \u7F16\u8BD1\u5931\u8D25\uFF1A
|
|
2328
2338
|
${message}`);
|
|
2329
2339
|
this.broadcast({ type: "error", message });
|
|
2330
2340
|
}
|
|
2331
2341
|
});
|
|
2342
|
+
return this.watcher.ready;
|
|
2332
2343
|
}
|
|
2333
2344
|
broadcast(message) {
|
|
2334
2345
|
const data = JSON.stringify(message);
|