miaoda-expo-devkit 0.1.1-beta.45 → 0.1.1-beta.46

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/metro.d.mts CHANGED
@@ -339,22 +339,36 @@ declare function withEsbuildMinify(config: MetroConfig): MetroConfig;
339
339
  declare function withWasmSupport(config: MetroConfig): MetroConfig;
340
340
 
341
341
  /**
342
- * withTransformLogger — Metro 单文件 transform 耗时日志
342
+ * withTransformLogger — Metro bundle 整体耗时日志
343
343
  *
344
- * 通过监听 metro-core Logger 'log' 事件,将每个文件的变换耗时写入 JSONL 文件。
344
+ * 通过 unstable_perfLoggerFactory 收集每次 bundle 请求的性能数据,写入 JSONL 文件。
345
+ * 该回调在主进程执行,不受 --max-workers 多进程影响。
345
346
  *
346
347
  * 激活条件(两者同时满足):
347
348
  * 1. 环境变量 METRO_TRANSFORM_LOG 设置为目标文件路径
348
349
  * 2. 当前处于开发模式(__DEV__ === true),expo export 生产构建时不记录
349
350
  *
350
- * 每行格式:
351
- * {"phase":"start","file":"...","duration_ms":null,"t":1234567890}
352
- * {"phase":"end","file":"...","duration_ms":42,"t":1234567890}
351
+ * 每行格式(一次 bundle 请求写一条):
352
+ * {
353
+ * "type": "BUNDLING_REQUEST", // START_UP | BUNDLING_REQUEST | HMR
354
+ * "status": "SUCCESS", // SUCCESS | FAIL | CANCEL
355
+ * "duration_ms": 1234,
356
+ * "bundle_url": "index.bundle",
357
+ * "initial_build": true, // true=首次构建 false=增量更新
358
+ * "graph_node_count": 220, // 模块数量
359
+ * "bundle_length": 512000, // bundle 字节数
360
+ * "points": { // 各阶段耗时(ms,从 start 计算)
361
+ * "resolvingAndTransformingDependencies_start": 5,
362
+ * "resolvingAndTransformingDependencies_end": 980,
363
+ * "serializingBundle_start": 981,
364
+ * "serializingBundle_end": 1200
365
+ * },
366
+ * "t": 1234567890 // bundle 完成时的时间戳
367
+ * }
353
368
  */
354
369
 
355
370
  /**
356
- * 在开发模式下,若 METRO_TRANSFORM_LOG 已设置,则安装 transform 耗时日志监听器。
357
- * 该函数调用时即生效(挂监听器),Metro config 本身无需修改,返回原对象。
371
+ * 在开发模式下,若 METRO_TRANSFORM_LOG 已设置,则注入 unstable_perfLoggerFactory。
358
372
  */
359
373
  declare function withTransformLogger(config: MetroConfig): MetroConfig;
360
374
 
package/dist/metro.d.ts CHANGED
@@ -339,22 +339,36 @@ declare function withEsbuildMinify(config: MetroConfig): MetroConfig;
339
339
  declare function withWasmSupport(config: MetroConfig): MetroConfig;
340
340
 
341
341
  /**
342
- * withTransformLogger — Metro 单文件 transform 耗时日志
342
+ * withTransformLogger — Metro bundle 整体耗时日志
343
343
  *
344
- * 通过监听 metro-core Logger 'log' 事件,将每个文件的变换耗时写入 JSONL 文件。
344
+ * 通过 unstable_perfLoggerFactory 收集每次 bundle 请求的性能数据,写入 JSONL 文件。
345
+ * 该回调在主进程执行,不受 --max-workers 多进程影响。
345
346
  *
346
347
  * 激活条件(两者同时满足):
347
348
  * 1. 环境变量 METRO_TRANSFORM_LOG 设置为目标文件路径
348
349
  * 2. 当前处于开发模式(__DEV__ === true),expo export 生产构建时不记录
349
350
  *
350
- * 每行格式:
351
- * {"phase":"start","file":"...","duration_ms":null,"t":1234567890}
352
- * {"phase":"end","file":"...","duration_ms":42,"t":1234567890}
351
+ * 每行格式(一次 bundle 请求写一条):
352
+ * {
353
+ * "type": "BUNDLING_REQUEST", // START_UP | BUNDLING_REQUEST | HMR
354
+ * "status": "SUCCESS", // SUCCESS | FAIL | CANCEL
355
+ * "duration_ms": 1234,
356
+ * "bundle_url": "index.bundle",
357
+ * "initial_build": true, // true=首次构建 false=增量更新
358
+ * "graph_node_count": 220, // 模块数量
359
+ * "bundle_length": 512000, // bundle 字节数
360
+ * "points": { // 各阶段耗时(ms,从 start 计算)
361
+ * "resolvingAndTransformingDependencies_start": 5,
362
+ * "resolvingAndTransformingDependencies_end": 980,
363
+ * "serializingBundle_start": 981,
364
+ * "serializingBundle_end": 1200
365
+ * },
366
+ * "t": 1234567890 // bundle 完成时的时间戳
367
+ * }
353
368
  */
354
369
 
355
370
  /**
356
- * 在开发模式下,若 METRO_TRANSFORM_LOG 已设置,则安装 transform 耗时日志监听器。
357
- * 该函数调用时即生效(挂监听器),Metro config 本身无需修改,返回原对象。
371
+ * 在开发模式下,若 METRO_TRANSFORM_LOG 已设置,则注入 unstable_perfLoggerFactory。
358
372
  */
359
373
  declare function withTransformLogger(config: MetroConfig): MetroConfig;
360
374
 
package/dist/metro.js CHANGED
@@ -443,31 +443,62 @@ function withWasmSupport(config) {
443
443
  // src/metro/withTransformLogger.ts
444
444
  var import_node_fs = __toESM(require("fs"));
445
445
  var import_node_path = __toESM(require("path"));
446
- function installLogger(logFile) {
447
- const { Logger } = require("metro-core");
446
+ function installPerfLogger(logFile, existingFactory) {
448
447
  const dir = import_node_path.default.dirname(logFile);
449
448
  if (!import_node_fs.default.existsSync(dir)) {
450
449
  import_node_fs.default.mkdirSync(dir, { recursive: true });
451
450
  }
452
451
  import_node_fs.default.writeFileSync(logFile, "");
453
- Logger.on("log", (entry) => {
454
- if (entry["action_name"] !== "Transforming file") return;
455
- const line = JSON.stringify({
456
- phase: entry["action_phase"],
457
- file: entry["file_name"],
458
- duration_ms: entry["duration_ms"] ?? null,
459
- t: Date.now()
460
- });
461
- import_node_fs.default.appendFileSync(logFile, line + "\n");
462
- });
452
+ return (type, opts) => {
453
+ const upstream = existingFactory?.(type, opts) ?? null;
454
+ const startTime = process.hrtime.bigint();
455
+ const points = {};
456
+ const annotations = {};
457
+ const logger = {
458
+ start() {
459
+ upstream?.start?.();
460
+ },
461
+ end(status) {
462
+ const duration_ms = Number(process.hrtime.bigint() - startTime) / 1e6;
463
+ const line = JSON.stringify({
464
+ type,
465
+ status,
466
+ duration_ms: Math.round(duration_ms),
467
+ ...annotations,
468
+ points,
469
+ t: Date.now()
470
+ });
471
+ import_node_fs.default.appendFileSync(logFile, line + "\n");
472
+ upstream?.end?.(status);
473
+ },
474
+ annotate(ann) {
475
+ for (const [, kv] of Object.entries(ann)) {
476
+ if (kv && typeof kv === "object") {
477
+ Object.assign(annotations, kv);
478
+ }
479
+ }
480
+ upstream?.annotate?.(ann);
481
+ },
482
+ point(name) {
483
+ points[name] = Math.round(Number(process.hrtime.bigint() - startTime) / 1e6);
484
+ upstream?.point?.(name);
485
+ },
486
+ subSpan(label) {
487
+ return upstream?.subSpan?.(label) ?? logger;
488
+ }
489
+ };
490
+ return logger;
491
+ };
463
492
  }
464
493
  function withTransformLogger(config) {
465
494
  const logFile = process.env["METRO_TRANSFORM_LOG"];
466
495
  if (!logFile) return config;
467
496
  const isDev = typeof __DEV__ !== "undefined" ? __DEV__ : process.env["NODE_ENV"] !== "production";
468
497
  if (!isDev) return config;
469
- installLogger(logFile);
470
- return config;
498
+ return {
499
+ ...config,
500
+ unstable_perfLoggerFactory: installPerfLogger(logFile, config.unstable_perfLoggerFactory)
501
+ };
471
502
  }
472
503
 
473
504
  // src/metro/withDevkit.ts
package/dist/metro.mjs CHANGED
@@ -399,31 +399,62 @@ function withWasmSupport(config) {
399
399
  // src/metro/withTransformLogger.ts
400
400
  import fs4 from "fs";
401
401
  import path12 from "path";
402
- function installLogger(logFile) {
403
- const { Logger } = __require("metro-core");
402
+ function installPerfLogger(logFile, existingFactory) {
404
403
  const dir = path12.dirname(logFile);
405
404
  if (!fs4.existsSync(dir)) {
406
405
  fs4.mkdirSync(dir, { recursive: true });
407
406
  }
408
407
  fs4.writeFileSync(logFile, "");
409
- Logger.on("log", (entry) => {
410
- if (entry["action_name"] !== "Transforming file") return;
411
- const line = JSON.stringify({
412
- phase: entry["action_phase"],
413
- file: entry["file_name"],
414
- duration_ms: entry["duration_ms"] ?? null,
415
- t: Date.now()
416
- });
417
- fs4.appendFileSync(logFile, line + "\n");
418
- });
408
+ return (type, opts) => {
409
+ const upstream = existingFactory?.(type, opts) ?? null;
410
+ const startTime = process.hrtime.bigint();
411
+ const points = {};
412
+ const annotations = {};
413
+ const logger = {
414
+ start() {
415
+ upstream?.start?.();
416
+ },
417
+ end(status) {
418
+ const duration_ms = Number(process.hrtime.bigint() - startTime) / 1e6;
419
+ const line = JSON.stringify({
420
+ type,
421
+ status,
422
+ duration_ms: Math.round(duration_ms),
423
+ ...annotations,
424
+ points,
425
+ t: Date.now()
426
+ });
427
+ fs4.appendFileSync(logFile, line + "\n");
428
+ upstream?.end?.(status);
429
+ },
430
+ annotate(ann) {
431
+ for (const [, kv] of Object.entries(ann)) {
432
+ if (kv && typeof kv === "object") {
433
+ Object.assign(annotations, kv);
434
+ }
435
+ }
436
+ upstream?.annotate?.(ann);
437
+ },
438
+ point(name) {
439
+ points[name] = Math.round(Number(process.hrtime.bigint() - startTime) / 1e6);
440
+ upstream?.point?.(name);
441
+ },
442
+ subSpan(label) {
443
+ return upstream?.subSpan?.(label) ?? logger;
444
+ }
445
+ };
446
+ return logger;
447
+ };
419
448
  }
420
449
  function withTransformLogger(config) {
421
450
  const logFile = process.env["METRO_TRANSFORM_LOG"];
422
451
  if (!logFile) return config;
423
452
  const isDev = typeof __DEV__ !== "undefined" ? __DEV__ : process.env["NODE_ENV"] !== "production";
424
453
  if (!isDev) return config;
425
- installLogger(logFile);
426
- return config;
454
+ return {
455
+ ...config,
456
+ unstable_perfLoggerFactory: installPerfLogger(logFile, config.unstable_perfLoggerFactory)
457
+ };
427
458
  }
428
459
 
429
460
  // src/metro/withDevkit.ts
@@ -218,9 +218,6 @@ class EditorController {
218
218
  case "editor-delete":
219
219
  this.deleteActiveNode();
220
220
  break;
221
- case "editor-text-update":
222
- this.updateActiveNodeText(e);
223
- break;
224
221
  }
225
222
  };
226
223
  }
@@ -363,16 +360,6 @@ class EditorController {
363
360
  this.activeNode = null;
364
361
  postToParent("iframe-node-clear");
365
362
  }
366
- /**
367
- * 更新选中元素的文本内容
368
- */
369
- updateActiveNodeText(e) {
370
- if (!this.activeNode) return;
371
- const text = e.data.value;
372
- if (typeof text !== "string") return;
373
- const node = this.activeNode;
374
- node.innerHTML = text;
375
- }
376
363
  }
377
364
  let controller = null;
378
365
  function onGlobalMessage(e) {
@@ -48,7 +48,8 @@
48
48
  "metro.config.js",
49
49
  "babel.config.js",
50
50
  ".pnpmfile.cjs",
51
- "output/**"
51
+ "output/**",
52
+ "supabase/**"
52
53
  ],
53
54
 
54
55
  "overrides": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-beta.45",
3
+ "version": "0.1.1-beta.46",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -83,7 +83,6 @@
83
83
  "@sentry/react-native": ">=8.0.0",
84
84
  "metro": ">=0.80.0",
85
85
  "metro-config": ">=0.80.0",
86
- "metro-core": ">=0.80.0",
87
86
  "metro-resolver": ">=0.80.0",
88
87
  "nativewind": ">=4.0.0",
89
88
  "react-native": ">=0.79.0",
@@ -103,9 +102,6 @@
103
102
  "metro-config": {
104
103
  "optional": true
105
104
  },
106
- "metro-core": {
107
- "optional": true
108
- },
109
105
  "metro-resolver": {
110
106
  "optional": true
111
107
  },