miaoda-expo-devkit 0.1.1-beta.42 → 0.1.1-beta.44
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 +21 -1
- package/dist/metro.d.ts +21 -1
- package/dist/metro.js +33 -0
- package/dist/metro.mjs +34 -2
- package/dist/stubs/lgui-control.js +13 -5
- package/package.json +6 -2
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
|
-
|
|
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
|
-
|
|
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
|
|
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:
|
|
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
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var lgui_control_exports = {};
|
|
20
30
|
__export(lgui_control_exports, {
|
|
@@ -22,7 +32,7 @@ __export(lgui_control_exports, {
|
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(lgui_control_exports);
|
|
24
34
|
var import_css_control = require("./css-control");
|
|
25
|
-
var
|
|
35
|
+
var import_lodash = __toESM(require("lodash.throttle"));
|
|
26
36
|
const MD_CONFIG = {
|
|
27
37
|
HOVERED_ATTR: "data-editor-hover",
|
|
28
38
|
ACTIVE_ATTR: "data-editor-active",
|
|
@@ -30,9 +40,7 @@ const MD_CONFIG = {
|
|
|
30
40
|
FULL_WIDTH_ATTR: "data-editor-full-width"
|
|
31
41
|
};
|
|
32
42
|
const THROTTLE_INTERVAL = 8;
|
|
33
|
-
const THROTTLE_OPTIONS = {
|
|
34
|
-
edges: ["leading", "trailing"]
|
|
35
|
-
};
|
|
43
|
+
const THROTTLE_OPTIONS = { leading: true, trailing: true };
|
|
36
44
|
function isInsideSvgButNotSvgElement(el) {
|
|
37
45
|
const tag = el.tagName.toLowerCase();
|
|
38
46
|
return tag !== "svg" && el.closest("svg") !== null;
|
|
@@ -181,7 +189,7 @@ class EditorController {
|
|
|
181
189
|
* 滚动事件处理(节流)
|
|
182
190
|
* 当页面滚动时,向父窗口发送选中元素的新位置信息
|
|
183
191
|
*/
|
|
184
|
-
this.onScroll = (0,
|
|
192
|
+
this.onScroll = (0, import_lodash.default)(
|
|
185
193
|
() => {
|
|
186
194
|
const target = this.activeNode;
|
|
187
195
|
if (!target) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miaoda-expo-devkit",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
3
|
+
"version": "0.1.1-beta.44",
|
|
4
4
|
"description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
],
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"connect": "^3.7.0",
|
|
75
|
-
"
|
|
75
|
+
"lodash.throttle": "^4.1.1",
|
|
76
76
|
"metro-minify-esbuild": "^0.2.0",
|
|
77
77
|
"oxc-resolver": "^11.19.1",
|
|
78
78
|
"package-up": "^5.0.0",
|
|
@@ -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
|
},
|