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

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
@@ -338,4 +338,24 @@ declare function withEsbuildMinify(config: MetroConfig): MetroConfig;
338
338
 
339
339
  declare function withWasmSupport(config: MetroConfig): MetroConfig;
340
340
 
341
- export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoFileSystemStub, withExpoMediaLibraryStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withRouteEndpoint, withWasmSupport, withWorkspaceNodeModules };
341
+ /**
342
+ * withTransformLogger — Metro 单文件 transform 耗时日志
343
+ *
344
+ * 通过监听 metro-core Logger 的 'log' 事件,将每个文件的变换耗时写入 JSONL 文件。
345
+ *
346
+ * 激活条件(两者同时满足):
347
+ * 1. 环境变量 METRO_TRANSFORM_LOG 设置为目标文件路径
348
+ * 2. 当前处于开发模式(__DEV__ === true),expo export 生产构建时不记录
349
+ *
350
+ * 每行格式:
351
+ * {"phase":"start","file":"...","duration_ms":null,"t":1234567890}
352
+ * {"phase":"end","file":"...","duration_ms":42,"t":1234567890}
353
+ */
354
+
355
+ /**
356
+ * 在开发模式下,若 METRO_TRANSFORM_LOG 已设置,则安装 transform 耗时日志监听器。
357
+ * 该函数调用时即生效(挂监听器),Metro config 本身无需修改,返回原对象。
358
+ */
359
+ declare function withTransformLogger(config: MetroConfig): MetroConfig;
360
+
361
+ export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoFileSystemStub, withExpoMediaLibraryStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withRouteEndpoint, withTransformLogger, withWasmSupport, withWorkspaceNodeModules };
package/dist/metro.d.ts CHANGED
@@ -338,4 +338,24 @@ declare function withEsbuildMinify(config: MetroConfig): MetroConfig;
338
338
 
339
339
  declare function withWasmSupport(config: MetroConfig): MetroConfig;
340
340
 
341
- export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoFileSystemStub, withExpoMediaLibraryStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withRouteEndpoint, withWasmSupport, withWorkspaceNodeModules };
341
+ /**
342
+ * withTransformLogger — Metro 单文件 transform 耗时日志
343
+ *
344
+ * 通过监听 metro-core Logger 的 'log' 事件,将每个文件的变换耗时写入 JSONL 文件。
345
+ *
346
+ * 激活条件(两者同时满足):
347
+ * 1. 环境变量 METRO_TRANSFORM_LOG 设置为目标文件路径
348
+ * 2. 当前处于开发模式(__DEV__ === true),expo export 生产构建时不记录
349
+ *
350
+ * 每行格式:
351
+ * {"phase":"start","file":"...","duration_ms":null,"t":1234567890}
352
+ * {"phase":"end","file":"...","duration_ms":42,"t":1234567890}
353
+ */
354
+
355
+ /**
356
+ * 在开发模式下,若 METRO_TRANSFORM_LOG 已设置,则安装 transform 耗时日志监听器。
357
+ * 该函数调用时即生效(挂监听器),Metro config 本身无需修改,返回原对象。
358
+ */
359
+ declare function withTransformLogger(config: MetroConfig): MetroConfig;
360
+
361
+ export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoFileSystemStub, withExpoMediaLibraryStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withRouteEndpoint, withTransformLogger, withWasmSupport, withWorkspaceNodeModules };
package/dist/metro.js CHANGED
@@ -43,6 +43,7 @@ __export(metro_exports, {
43
43
  withLucideResolver: () => withLucideResolver,
44
44
  withNativeWind: () => withNativeWind,
45
45
  withRouteEndpoint: () => withRouteEndpoint,
46
+ withTransformLogger: () => withTransformLogger,
46
47
  withWasmSupport: () => withWasmSupport,
47
48
  withWorkspaceNodeModules: () => withWorkspaceNodeModules
48
49
  });
@@ -439,10 +440,41 @@ function withWasmSupport(config) {
439
440
  };
440
441
  }
441
442
 
443
+ // src/metro/withTransformLogger.ts
444
+ var import_node_fs = __toESM(require("fs"));
445
+ var import_node_path = __toESM(require("path"));
446
+ function installLogger(logFile) {
447
+ const { Logger } = require("metro-core");
448
+ const dir = import_node_path.default.dirname(logFile);
449
+ if (!import_node_fs.default.existsSync(dir)) {
450
+ import_node_fs.default.mkdirSync(dir, { recursive: true });
451
+ }
452
+ 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
+ });
463
+ }
464
+ function withTransformLogger(config) {
465
+ const logFile = process.env["METRO_TRANSFORM_LOG"];
466
+ if (!logFile) return config;
467
+ const isDev = typeof __DEV__ !== "undefined" ? __DEV__ : process.env["NODE_ENV"] !== "production";
468
+ if (!isDev) return config;
469
+ installLogger(logFile);
470
+ return config;
471
+ }
472
+
442
473
  // src/metro/withDevkit.ts
443
474
  function withDevkit(config, options = {}) {
444
475
  const projectRoot = config.projectRoot ?? process.cwd();
445
476
  const { input = "./src/global.css" } = options;
477
+ config = withTransformLogger(config);
446
478
  config = withWorkspaceNodeModules(config);
447
479
  config = withWasmSupport(config);
448
480
  config = withCssInterop(config);
@@ -482,6 +514,7 @@ try {
482
514
  withLucideResolver,
483
515
  withNativeWind,
484
516
  withRouteEndpoint,
517
+ withTransformLogger,
485
518
  withWasmSupport,
486
519
  withWorkspaceNodeModules
487
520
  });
package/dist/metro.mjs CHANGED
@@ -244,7 +244,7 @@ function withCssInterop(config) {
244
244
  }
245
245
 
246
246
  // src/metro/withDevkit.ts
247
- import path12 from "path";
247
+ import path13 from "path";
248
248
 
249
249
  // src/metro/withEsbuildMinify.ts
250
250
  function withEsbuildMinify(config) {
@@ -396,10 +396,41 @@ function withWasmSupport(config) {
396
396
  };
397
397
  }
398
398
 
399
+ // src/metro/withTransformLogger.ts
400
+ import fs4 from "fs";
401
+ import path12 from "path";
402
+ function installLogger(logFile) {
403
+ const { Logger } = __require("metro-core");
404
+ const dir = path12.dirname(logFile);
405
+ if (!fs4.existsSync(dir)) {
406
+ fs4.mkdirSync(dir, { recursive: true });
407
+ }
408
+ 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
+ });
419
+ }
420
+ function withTransformLogger(config) {
421
+ const logFile = process.env["METRO_TRANSFORM_LOG"];
422
+ if (!logFile) return config;
423
+ const isDev = typeof __DEV__ !== "undefined" ? __DEV__ : process.env["NODE_ENV"] !== "production";
424
+ if (!isDev) return config;
425
+ installLogger(logFile);
426
+ return config;
427
+ }
428
+
399
429
  // src/metro/withDevkit.ts
400
430
  function withDevkit(config, options = {}) {
401
431
  const projectRoot = config.projectRoot ?? process.cwd();
402
432
  const { input = "./src/global.css" } = options;
433
+ config = withTransformLogger(config);
403
434
  config = withWorkspaceNodeModules(config);
404
435
  config = withWasmSupport(config);
405
436
  config = withCssInterop(config);
@@ -412,7 +443,7 @@ function withDevkit(config, options = {}) {
412
443
  if (typeof __DEV__ !== "undefined" && __DEV__) {
413
444
  config = withEntryInjection(config);
414
445
  config = withDevStubs(config);
415
- config = withRouteEndpoint(config, { appDir: path12.join(projectRoot, "src", "app") });
446
+ config = withRouteEndpoint(config, { appDir: path13.join(projectRoot, "src", "app") });
416
447
  }
417
448
  return withNativeWind(config, { input, inlineRem: 16 });
418
449
  }
@@ -438,6 +469,7 @@ export {
438
469
  withLucideResolver,
439
470
  withNativeWind,
440
471
  withRouteEndpoint,
472
+ withTransformLogger,
441
473
  withWasmSupport,
442
474
  withWorkspaceNodeModules
443
475
  };
@@ -218,6 +218,9 @@ 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;
221
224
  }
222
225
  };
223
226
  }
@@ -360,6 +363,16 @@ class EditorController {
360
363
  this.activeNode = null;
361
364
  postToParent("iframe-node-clear");
362
365
  }
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
+ }
363
376
  }
364
377
  let controller = null;
365
378
  function onGlobalMessage(e) {
@@ -1,4 +1,29 @@
1
1
  "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+
25
+ // src/stubs/sentry-react-native-stub.ts
26
+ var RealSentry = __toESM(require("@sentry/react-native"));
2
27
 
3
28
  // src/capture.ts
4
29
  var import_stacktrace_parser = require("stacktrace-parser");
@@ -130,7 +155,6 @@ var SentryCapture = class {
130
155
  };
131
156
 
132
157
  // src/stubs/sentry-react-native-stub.ts
133
- var RealSentry = require("@sentry/react-native");
134
158
  function getParentOrigin() {
135
159
  try {
136
160
  const w = globalThis.window;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-beta.43",
3
+ "version": "0.1.1-beta.45",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -83,6 +83,7 @@
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",
86
87
  "metro-resolver": ">=0.80.0",
87
88
  "nativewind": ">=4.0.0",
88
89
  "react-native": ">=0.79.0",
@@ -102,6 +103,9 @@
102
103
  "metro-config": {
103
104
  "optional": true
104
105
  },
106
+ "metro-core": {
107
+ "optional": true
108
+ },
105
109
  "metro-resolver": {
106
110
  "optional": true
107
111
  },