miaoda-expo-devkit 0.1.1-beta.113 → 0.1.1-beta.114
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/README.md
CHANGED
|
@@ -165,8 +165,10 @@ EXPO_AI_ERROR_COLLECTOR=1 npx expo start
|
|
|
165
165
|
可能清理这个目录;需要持久化时请设置 `EXPO_AI_ERROR_FILE` 指向项目外部路径。
|
|
166
166
|
|
|
167
167
|
状态文件只表示“当前编译”:`bundle_build_started` 会立即清除上一次错误,
|
|
168
|
-
`bundling_error`
|
|
169
|
-
|
|
168
|
+
`bundling_error` 写入结构化错误,下一次完整编译成功或失败都会替换旧状态。
|
|
169
|
+
Expo CLI patch 也会为 HMR 增量更新写入 `hmr_update_started`、
|
|
170
|
+
`hmr_update_done` 状态,确保源码修复后通过 Fast Refresh 恢复时旧错误同步清除。
|
|
171
|
+
AI 进程直接读取这个文件即可,不需要额外的 HTTP 服务或 WebSocket 客户端。
|
|
170
172
|
|
|
171
173
|
返回对象包含 `status`(`compiling`、`failed`、`succeeded`)和 `error`。失败时
|
|
172
174
|
`error` 至少包含 `type`、`message`、`filename`、`lineNumber`、`column`、
|
package/package.json
CHANGED
|
@@ -29,7 +29,50 @@ diff --git a/build/src/start/server/metro/instantiateMetro.js b/build/src/start/
|
|
|
29
29
|
// This function ensures that modules in source maps are sorted in the same
|
|
30
30
|
// order as in a plain JS bundle.
|
|
31
31
|
metro._getSortedModules = function(graph) {
|
|
32
|
-
@@ -
|
|
32
|
+
@@ -388,6 +388,11 @@
|
|
33
|
+
// Patch HMR Server to send more info to the `_createModuleId` function for deterministic module IDs and add support for serializing HMR updates the same as all other bundles.
|
|
34
|
+
hmrServer._prepareMessage = async function(group, options, changeEvent) {
|
|
35
|
+
// Fork of https://github.com/facebook/metro/blob/3b3e0aaf725cfa6907bf2c8b5fbc0da352d29efe/packages/metro/src/HmrServer.js#L327-L393
|
|
36
|
+
// with patch for `_createModuleId`.
|
|
37
|
+
const logger = !options.isInitialUpdate ? changeEvent == null ? void 0 : changeEvent.logger : null;
|
|
38
|
+
+ const hmrChangeID = `${changeEvent == null ? 'initial' : changeEvent.changeId}:${group.revisionId}`;
|
|
39
|
+
+ aiErrorCollector == null ? void 0 : aiErrorCollector.handleMetroEvent({
|
|
40
|
+
+ type: 'hmr_update_started',
|
|
41
|
+
+ changeID: hmrChangeID
|
|
42
|
+
+ });
|
|
43
|
+
try {
|
|
44
|
+
@@ -394,7 +399,13 @@
|
|
45
|
+
const revPromise = this._bundler.getRevision(group.revisionId);
|
|
46
|
+
if (!revPromise) {
|
|
47
|
+
+ const revisionError = new (_RevisionNotFoundError()).default(group.revisionId);
|
|
48
|
+
+ aiErrorCollector == null ? void 0 : aiErrorCollector.handleMetroEvent({
|
|
49
|
+
+ type: 'hmr_update_failed',
|
|
50
|
+
+ changeID: hmrChangeID,
|
|
51
|
+
+ error: revisionError
|
|
52
|
+
+ });
|
|
53
|
+
return {
|
|
54
|
+
type: 'error',
|
|
55
|
+
- body: (0, _formatBundlingError().default)(new (_RevisionNotFoundError()).default(group.revisionId))
|
|
56
|
+
+ body: (0, _formatBundlingError().default)(revisionError)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
@@ -428,3 +439,7 @@
|
|
60
|
+
});
|
|
61
|
+
logger == null ? void 0 : logger.point('serialize_end');
|
|
62
|
+
+ aiErrorCollector == null ? void 0 : aiErrorCollector.handleMetroEvent({
|
|
63
|
+
+ type: 'hmr_update_done',
|
|
64
|
+
+ changeID: hmrChangeID
|
|
65
|
+
+ });
|
|
66
|
+
return {
|
|
67
|
+
@@ -438,4 +453,6 @@
|
|
68
|
+
this._config.reporter.update({
|
|
69
|
+
type: 'bundling_error',
|
|
70
|
+
- error
|
|
71
|
+
+ error,
|
|
72
|
+
+ isHmr: true,
|
|
73
|
+
+ changeID: hmrChangeID
|
|
74
|
+
});
|
|
75
|
+
@@ -493,1 +515,1 @@
|
|
33
76
|
-//# sourceMappingURL=instantiateMetro.js.map
|
|
34
77
|
|
|
35
78
|
+//# sourceMappingURL=instantiateMetro.js.map
|
|
@@ -37,7 +80,7 @@ diff --git a/build/src/start/server/metro/aiErrorCollector.js b/build/src/start/
|
|
|
37
80
|
new file mode 100644
|
|
38
81
|
--- /dev/null
|
|
39
82
|
+++ b/build/src/start/server/metro/aiErrorCollector.js
|
|
40
|
-
@@ -0,0 +1,
|
|
83
|
+
@@ -0,0 +1,222 @@
|
|
41
84
|
+"use strict";
|
|
42
85
|
+Object.defineProperty(exports, "__esModule", {
|
|
43
86
|
+ value: true
|
|
@@ -144,6 +187,7 @@ new file mode 100644
|
|
|
144
187
|
+ const outputFile = getOutputPath(projectRoot);
|
|
145
188
|
+ let activeBuildID = null;
|
|
146
189
|
+ let lastFailedBuildID = null;
|
|
190
|
+
+ let activeHmrChangeID = null;
|
|
147
191
|
+ let state = {
|
|
148
192
|
+ schemaVersion: 1,
|
|
149
193
|
+ status: 'compiling',
|
|
@@ -179,8 +223,41 @@ new file mode 100644
|
|
|
179
223
|
+ if (!event || typeof event !== 'object') return;
|
|
180
224
|
+ const type = event.type;
|
|
181
225
|
+ const buildID = event.buildID ?? event.bundleDetails?.buildID ?? null;
|
|
226
|
+
+ if (type === 'hmr_update_started') {
|
|
227
|
+
+ activeHmrChangeID = typeof event.changeID === 'string' ? event.changeID : null;
|
|
228
|
+
+ lastFailedBuildID = null;
|
|
229
|
+
+ publish({
|
|
230
|
+
+ schemaVersion: 1,
|
|
231
|
+
+ status: 'compiling',
|
|
232
|
+
+ buildID: activeBuildID,
|
|
233
|
+
+ error: null
|
|
234
|
+
+ });
|
|
235
|
+
+ return;
|
|
236
|
+
+ }
|
|
237
|
+
+ if (type === 'hmr_update_failed') {
|
|
238
|
+
+ if (activeHmrChangeID == null || event.changeID !== activeHmrChangeID) return;
|
|
239
|
+
+ publish({
|
|
240
|
+
+ schemaVersion: 1,
|
|
241
|
+
+ status: 'failed',
|
|
242
|
+
+ buildID: activeBuildID,
|
|
243
|
+
+ error: normalizeError(event.error, projectRoot, activeBuildID)
|
|
244
|
+
+ });
|
|
245
|
+
+ return;
|
|
246
|
+
+ }
|
|
247
|
+
+ if (type === 'hmr_update_done') {
|
|
248
|
+
+ if (activeHmrChangeID == null || event.changeID !== activeHmrChangeID) return;
|
|
249
|
+
+ activeHmrChangeID = null;
|
|
250
|
+
+ publish({
|
|
251
|
+
+ schemaVersion: 1,
|
|
252
|
+
+ status: 'succeeded',
|
|
253
|
+
+ buildID: activeBuildID,
|
|
254
|
+
+ error: null
|
|
255
|
+
+ });
|
|
256
|
+
+ return;
|
|
257
|
+
+ }
|
|
182
258
|
+ if (type === 'bundle_build_started') {
|
|
183
259
|
+ activeBuildID = buildID;
|
|
260
|
+
+ activeHmrChangeID = null;
|
|
184
261
|
+ lastFailedBuildID = null;
|
|
185
262
|
+ publish({ schemaVersion: 1, status: 'compiling', buildID, error: null });
|
|
186
263
|
+ return;
|
|
@@ -197,8 +274,16 @@ new file mode 100644
|
|
|
197
274
|
+ return;
|
|
198
275
|
+ }
|
|
199
276
|
+ if (type === 'bundling_error') {
|
|
200
|
-
+ const
|
|
277
|
+
+ const isHmrError = event.isHmr === true;
|
|
278
|
+
+ if (isHmrError && activeHmrChangeID != null && event.changeID !== activeHmrChangeID) return;
|
|
279
|
+
+ const errorBuildID = isHmrError ? activeBuildID : buildID ?? lastFailedBuildID ?? activeBuildID;
|
|
201
280
|
+ if (!isCurrentBuild(errorBuildID, true)) return;
|
|
281
|
+
+ if (isHmrError) {
|
|
282
|
+
+ // HMR errors do not carry Metro build IDs; keep the change token for its recovery event.
|
|
283
|
+
+ activeHmrChangeID = event.changeID ?? activeHmrChangeID;
|
|
284
|
+
+ }
|
|
285
|
+
+ lastFailedBuildID = errorBuildID;
|
|
286
|
+
+
|
|
202
287
|
+ publish({
|
|
203
288
|
+ schemaVersion: 1,
|
|
204
289
|
+ status: 'failed',
|
|
@@ -209,6 +294,8 @@ new file mode 100644
|
|
|
209
294
|
+ }
|
|
210
295
|
+ if (type === 'bundle_build_done') {
|
|
211
296
|
+ if (!isCurrentBuild(buildID)) return;
|
|
297
|
+
+ activeHmrChangeID = null;
|
|
298
|
+
+ lastFailedBuildID = null;
|
|
212
299
|
+ publish({ schemaVersion: 1, status: 'succeeded', buildID: buildID ?? activeBuildID, error: null });
|
|
213
300
|
+ }
|
|
214
301
|
+ }
|