miaoda-expo-devkit 0.1.1-beta.98 → 0.1.1-dev.development-build.1

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.
Files changed (42) hide show
  1. package/README.md +154 -110
  2. package/dist/babel/plugin-lucide-react-native.js +184 -184
  3. package/dist/cli/lint.js +317 -309
  4. package/dist/index.d.mts +1 -110
  5. package/dist/index.d.ts +1 -110
  6. package/dist/index.js +0 -159
  7. package/dist/index.mjs +0 -132
  8. package/dist/metro.d.mts +25 -5
  9. package/dist/metro.d.ts +25 -5
  10. package/dist/metro.js +49 -18
  11. package/dist/metro.mjs +50 -20
  12. package/dist/rules/no-expo-audio-compat.js +2041 -0
  13. package/dist/rules/no-expo-video-compat.js +90 -90
  14. package/dist/stubs/entry-inject.js +0 -2
  15. package/dist/stubs/expo-native-wechat-stub.js +116 -0
  16. package/dist/stubs/expo-router-entry-native-stub.js +4 -0
  17. package/dist/stubs/i18n/en.js +16 -1
  18. package/dist/stubs/i18n/zh.js +16 -1
  19. package/dist/stubs/logbox-control.js +9 -0
  20. package/dist/stubs/screenshot-control.js +1 -1
  21. package/dist/stubs/sentry-react-native-stub.js +15 -180
  22. package/oxlint-config.json +11 -4
  23. package/package.json +60 -5
  24. package/pnpm-patches/@expo__cli@55.0.16-55.0.22.patch +627 -0
  25. package/pnpm-patches/@expo__cli@55.0.16.patch +218 -0
  26. package/pnpm-patches/@expo__cli@55.0.17.patch +218 -0
  27. package/pnpm-patches/@expo__cli@55.0.18.patch +218 -0
  28. package/pnpm-patches/@expo__cli@55.0.19.patch +218 -0
  29. package/pnpm-patches/@expo__cli@55.0.20.patch +218 -0
  30. package/pnpm-patches/@expo__cli@55.0.21.patch +218 -0
  31. package/pnpm-patches/@expo__cli@55.0.22.patch +218 -0
  32. package/pnpm-patches/@shopify__react-native-skia@2.4.18.patch +14 -0
  33. package/pnpm-patches/expo-modules-core@55.0.15.patch +21 -0
  34. package/pnpm-patches/expo@55.0.6.patch +235 -0
  35. package/pnpm-patches/metro-file-map@0.83.3.patch +24 -0
  36. package/pnpm-patches/metro-runtime@0.83.3.patch +13 -0
  37. package/pnpm-patches/react-native-css-interop@0.2.6.patch +12 -0
  38. package/pnpm-patches/react-native-reanimated@4.2.1.patch +53 -0
  39. package/pnpm-patches/react-native-worklets@0.7.2.patch +91 -0
  40. package/pnpm-patches/react-native@0.83.2.patch +384 -0
  41. package/pnpmfile.cjs +168 -0
  42. package/dist/stubs/preview-control.js +0 -60
package/dist/index.d.mts CHANGED
@@ -1,111 +1,2 @@
1
- import { ErrorEvent, EventHint, Breadcrumb, BreadcrumbHint } from '@sentry/core';
2
1
 
3
- /**
4
- * Sentry Capture 模块
5
- *
6
- * 提供 Metro 符号化(MetroSymbolicator)和 Sentry 事件捕获(SentryCapture)。
7
- */
8
-
9
- /** Metro /symbolicate 接口的帧格式(请求与响应共用)。 */
10
- interface MetroFrame {
11
- file: string;
12
- lineNumber: number;
13
- column: number;
14
- methodName: string;
15
- }
16
- /** SentryCapture.onError 回调参数 */
17
- interface ErrorCaptureInfo {
18
- message: string;
19
- symbolicatedFrames: MetroFrame[] | null;
20
- componentStack: string | null;
21
- /** Sentry Mechanism.type,如 'onerror' / 'generic' / 'auto.function.react.error_boundary' */
22
- mechanismType: string | null;
23
- }
24
- /** SentryCapture.onNetwork 回调参数 */
25
- interface NetworkCaptureInfo {
26
- method: string | null;
27
- url: string | null;
28
- statusCode: number | null;
29
- }
30
- interface SentryCaptureOptions {
31
- onError?: (info: ErrorCaptureInfo) => void;
32
- onNetwork?: (info: NetworkCaptureInfo) => void;
33
- /** 可注入 mock 实例以在单元测试中隔离网络依赖 */
34
- symbolicator?: MetroSymbolicator;
35
- }
36
- /**
37
- * Metro 符号化器。
38
- * 将 bundle 行列号还原为源码位置(通过 Metro /symbolicate 接口)。
39
- *
40
- * @example
41
- * const sym = new MetroSymbolicator();
42
- *
43
- * @example
44
- * // 单测:注入 baseUrl 并 mock fetch
45
- * const sym = new MetroSymbolicator({ baseUrl: 'http://localhost:8081' });
46
- * global.fetch = jest.fn().mockResolvedValue({ ok: true, json: async () => ({ stack: [...] }) });
47
- */
48
- declare class MetroSymbolicator {
49
- readonly baseUrl: string;
50
- constructor({ baseUrl }?: {
51
- baseUrl?: string;
52
- });
53
- /**
54
- * 从 NativeModules.SourceCode.scriptURL 推断 Metro server base URL。
55
- * web 平台使用相对路径;native 回退到 localhost:8081。
56
- */
57
- private static _getDefaultBaseUrl;
58
- /**
59
- * 解析 Error.stack 字符串为 Metro 所需的帧数组。
60
- *
61
- * 使用 stacktrace-parser 覆盖各 JS 引擎的格式:
62
- * V8/Node.js/Hermes(新):at methodName (url:line:col)
63
- * Gecko/Firefox/Hermes(旧):methodName@url:line:col
64
- * JavaScriptCore(iOS):methodName@url:line:col
65
- *
66
- * 无法符号化的帧(file 或 lineNumber 为 null)会被过滤掉。
67
- */
68
- parseErrorStack(stack: string): MetroFrame[];
69
- /**
70
- * 将帧列表发送到 Metro /symbolicate,返回符号化后的帧数组。
71
- */
72
- symbolicate(stack: MetroFrame[]): Promise<MetroFrame[] | null>;
73
- }
74
- /**
75
- * Sentry 事件捕获器。
76
- * 封装 beforeSend / beforeBreadcrumb 逻辑,通过注入的回调将事件数据交给调用方处理。
77
- *
78
- * @example
79
- * const capture = new SentryCapture({
80
- * onError(info) { console.log(info.message, info.symbolicatedFrames); },
81
- * onNetwork(info) { console.log(info.method, info.url, info.statusCode); },
82
- * });
83
- * Sentry.init({ dsn: '...', beforeSend: capture.beforeSend, beforeBreadcrumb: capture.beforeBreadcrumb });
84
- *
85
- * @example
86
- * // 单测:注入 mock symbolicator
87
- * const mockSym = { parseErrorStack: jest.fn(() => []), symbolicate: jest.fn(async () => null) };
88
- * const onError = jest.fn();
89
- * const capture = new SentryCapture({ onError, symbolicator: mockSym });
90
- * await capture.beforeSend(fakeEvent, { originalException: new Error('oops') });
91
- * expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'oops' }));
92
- */
93
- declare class SentryCapture {
94
- private readonly onError;
95
- private readonly onNetwork;
96
- private readonly symbolicator;
97
- constructor({ onError, onNetwork, symbolicator }?: SentryCaptureOptions);
98
- /**
99
- * Sentry beforeSend hook。
100
- * 优先使用原始 Error.stack 进行符号化;若无法获取则回退到 Sentry 事件帧。
101
- * 符号化完成后触发 onError 回调,原样返回 event。
102
- */
103
- beforeSend(event: ErrorEvent, hint: EventHint): Promise<ErrorEvent>;
104
- /**
105
- * Sentry beforeBreadcrumb hook。
106
- * 识别 HTTP 类型的 breadcrumb,触发 onNetwork 回调,原样返回 breadcrumb。
107
- */
108
- beforeBreadcrumb(breadcrumb: Breadcrumb, _hint?: BreadcrumbHint): Breadcrumb;
109
- }
110
-
111
- export { type ErrorCaptureInfo, type MetroFrame, MetroSymbolicator, type NetworkCaptureInfo, SentryCapture, type SentryCaptureOptions };
2
+ export { }
package/dist/index.d.ts CHANGED
@@ -1,111 +1,2 @@
1
- import { ErrorEvent, EventHint, Breadcrumb, BreadcrumbHint } from '@sentry/core';
2
1
 
3
- /**
4
- * Sentry Capture 模块
5
- *
6
- * 提供 Metro 符号化(MetroSymbolicator)和 Sentry 事件捕获(SentryCapture)。
7
- */
8
-
9
- /** Metro /symbolicate 接口的帧格式(请求与响应共用)。 */
10
- interface MetroFrame {
11
- file: string;
12
- lineNumber: number;
13
- column: number;
14
- methodName: string;
15
- }
16
- /** SentryCapture.onError 回调参数 */
17
- interface ErrorCaptureInfo {
18
- message: string;
19
- symbolicatedFrames: MetroFrame[] | null;
20
- componentStack: string | null;
21
- /** Sentry Mechanism.type,如 'onerror' / 'generic' / 'auto.function.react.error_boundary' */
22
- mechanismType: string | null;
23
- }
24
- /** SentryCapture.onNetwork 回调参数 */
25
- interface NetworkCaptureInfo {
26
- method: string | null;
27
- url: string | null;
28
- statusCode: number | null;
29
- }
30
- interface SentryCaptureOptions {
31
- onError?: (info: ErrorCaptureInfo) => void;
32
- onNetwork?: (info: NetworkCaptureInfo) => void;
33
- /** 可注入 mock 实例以在单元测试中隔离网络依赖 */
34
- symbolicator?: MetroSymbolicator;
35
- }
36
- /**
37
- * Metro 符号化器。
38
- * 将 bundle 行列号还原为源码位置(通过 Metro /symbolicate 接口)。
39
- *
40
- * @example
41
- * const sym = new MetroSymbolicator();
42
- *
43
- * @example
44
- * // 单测:注入 baseUrl 并 mock fetch
45
- * const sym = new MetroSymbolicator({ baseUrl: 'http://localhost:8081' });
46
- * global.fetch = jest.fn().mockResolvedValue({ ok: true, json: async () => ({ stack: [...] }) });
47
- */
48
- declare class MetroSymbolicator {
49
- readonly baseUrl: string;
50
- constructor({ baseUrl }?: {
51
- baseUrl?: string;
52
- });
53
- /**
54
- * 从 NativeModules.SourceCode.scriptURL 推断 Metro server base URL。
55
- * web 平台使用相对路径;native 回退到 localhost:8081。
56
- */
57
- private static _getDefaultBaseUrl;
58
- /**
59
- * 解析 Error.stack 字符串为 Metro 所需的帧数组。
60
- *
61
- * 使用 stacktrace-parser 覆盖各 JS 引擎的格式:
62
- * V8/Node.js/Hermes(新):at methodName (url:line:col)
63
- * Gecko/Firefox/Hermes(旧):methodName@url:line:col
64
- * JavaScriptCore(iOS):methodName@url:line:col
65
- *
66
- * 无法符号化的帧(file 或 lineNumber 为 null)会被过滤掉。
67
- */
68
- parseErrorStack(stack: string): MetroFrame[];
69
- /**
70
- * 将帧列表发送到 Metro /symbolicate,返回符号化后的帧数组。
71
- */
72
- symbolicate(stack: MetroFrame[]): Promise<MetroFrame[] | null>;
73
- }
74
- /**
75
- * Sentry 事件捕获器。
76
- * 封装 beforeSend / beforeBreadcrumb 逻辑,通过注入的回调将事件数据交给调用方处理。
77
- *
78
- * @example
79
- * const capture = new SentryCapture({
80
- * onError(info) { console.log(info.message, info.symbolicatedFrames); },
81
- * onNetwork(info) { console.log(info.method, info.url, info.statusCode); },
82
- * });
83
- * Sentry.init({ dsn: '...', beforeSend: capture.beforeSend, beforeBreadcrumb: capture.beforeBreadcrumb });
84
- *
85
- * @example
86
- * // 单测:注入 mock symbolicator
87
- * const mockSym = { parseErrorStack: jest.fn(() => []), symbolicate: jest.fn(async () => null) };
88
- * const onError = jest.fn();
89
- * const capture = new SentryCapture({ onError, symbolicator: mockSym });
90
- * await capture.beforeSend(fakeEvent, { originalException: new Error('oops') });
91
- * expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'oops' }));
92
- */
93
- declare class SentryCapture {
94
- private readonly onError;
95
- private readonly onNetwork;
96
- private readonly symbolicator;
97
- constructor({ onError, onNetwork, symbolicator }?: SentryCaptureOptions);
98
- /**
99
- * Sentry beforeSend hook。
100
- * 优先使用原始 Error.stack 进行符号化;若无法获取则回退到 Sentry 事件帧。
101
- * 符号化完成后触发 onError 回调,原样返回 event。
102
- */
103
- beforeSend(event: ErrorEvent, hint: EventHint): Promise<ErrorEvent>;
104
- /**
105
- * Sentry beforeBreadcrumb hook。
106
- * 识别 HTTP 类型的 breadcrumb,触发 onNetwork 回调,原样返回 breadcrumb。
107
- */
108
- beforeBreadcrumb(breadcrumb: Breadcrumb, _hint?: BreadcrumbHint): Breadcrumb;
109
- }
110
-
111
- export { type ErrorCaptureInfo, type MetroFrame, MetroSymbolicator, type NetworkCaptureInfo, SentryCapture, type SentryCaptureOptions };
2
+ export { }
package/dist/index.js CHANGED
@@ -1,161 +1,2 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- MetroSymbolicator: () => MetroSymbolicator,
24
- SentryCapture: () => SentryCapture
25
- });
26
- module.exports = __toCommonJS(src_exports);
27
-
28
- // src/capture.ts
29
- var import_stacktrace_parser = require("stacktrace-parser");
30
- var import_react_native = require("react-native");
31
- var MetroSymbolicator = class _MetroSymbolicator {
32
- constructor({ baseUrl } = {}) {
33
- this.baseUrl = baseUrl ?? _MetroSymbolicator._getDefaultBaseUrl();
34
- }
35
- /**
36
- * 从 NativeModules.SourceCode.scriptURL 推断 Metro server base URL。
37
- * web 平台使用相对路径;native 回退到 localhost:8081。
38
- */
39
- static _getDefaultBaseUrl() {
40
- try {
41
- const scriptURL = import_react_native.NativeModules?.SourceCode?.scriptURL;
42
- if (scriptURL) {
43
- const url = new URL(scriptURL);
44
- return `${url.protocol}//${url.host}`;
45
- }
46
- } catch (_) {
47
- }
48
- return import_react_native.Platform.OS === "web" ? "" : "http://localhost:8081";
49
- }
50
- /**
51
- * 解析 Error.stack 字符串为 Metro 所需的帧数组。
52
- *
53
- * 使用 stacktrace-parser 覆盖各 JS 引擎的格式:
54
- * V8/Node.js/Hermes(新):at methodName (url:line:col)
55
- * Gecko/Firefox/Hermes(旧):methodName@url:line:col
56
- * JavaScriptCore(iOS):methodName@url:line:col
57
- *
58
- * 无法符号化的帧(file 或 lineNumber 为 null)会被过滤掉。
59
- */
60
- parseErrorStack(stack) {
61
- return (0, import_stacktrace_parser.parse)(stack).filter(
62
- (f) => f.file != null && f.lineNumber != null
63
- ).map((f) => ({
64
- file: f.file,
65
- lineNumber: f.lineNumber,
66
- column: f.column != null ? f.column - 1 : 0,
67
- methodName: f.methodName === "<unknown>" ? "(anonymous)" : f.methodName
68
- }));
69
- }
70
- /**
71
- * 将帧列表发送到 Metro /symbolicate,返回符号化后的帧数组。
72
- */
73
- async symbolicate(stack) {
74
- if (stack.length === 0) return null;
75
- const endpoint = `${this.baseUrl}/symbolicate`;
76
- try {
77
- const res = await fetch(endpoint, {
78
- method: "POST",
79
- headers: { "Content-Type": "application/json" },
80
- body: JSON.stringify({ stack })
81
- });
82
- if (!res.ok) {
83
- console.warn(`[SentryCapture] /symbolicate returned ${res.status}`);
84
- return null;
85
- }
86
- const data = await res.json();
87
- return data.stack ?? null;
88
- } catch (e) {
89
- console.warn("[SentryCapture] symbolication failed:", e?.message ?? e);
90
- return null;
91
- }
92
- }
93
- };
94
- var SentryCapture = class {
95
- constructor({ onError, onNetwork, symbolicator } = {}) {
96
- this.onError = onError;
97
- this.onNetwork = onNetwork;
98
- this.symbolicator = symbolicator ?? new MetroSymbolicator();
99
- this.beforeSend = this.beforeSend.bind(this);
100
- this.beforeBreadcrumb = this.beforeBreadcrumb.bind(this);
101
- }
102
- /**
103
- * Sentry beforeSend hook。
104
- * 优先使用原始 Error.stack 进行符号化;若无法获取则回退到 Sentry 事件帧。
105
- * 符号化完成后触发 onError 回调,原样返回 event。
106
- */
107
- async beforeSend(event, hint) {
108
- globalThis.__SENTRY_LAST_RAW__ = { event, hint };
109
- const message = event.exception?.values?.[0]?.value ?? event.message ?? "(unknown)";
110
- let symbolicatedFrames = null;
111
- const originalException = hint?.originalException;
112
- const rawStack = originalException instanceof Error && typeof originalException.stack === "string" ? originalException.stack : null;
113
- if (rawStack !== null) {
114
- const frames = this.symbolicator.parseErrorStack(rawStack);
115
- if (frames.length > 0) {
116
- symbolicatedFrames = await this.symbolicator.symbolicate(frames);
117
- }
118
- }
119
- if (symbolicatedFrames === null) {
120
- const sentryFrames = event.exception?.values?.[0]?.stacktrace?.frames ?? [];
121
- const mapped = sentryFrames.filter(
122
- (f) => f.filename != null && f.lineno != null
123
- ).map(
124
- (f) => ({
125
- file: f.filename,
126
- lineNumber: f.lineno,
127
- column: f.colno ?? 0,
128
- methodName: f.function ?? "(anonymous)"
129
- })
130
- );
131
- if (mapped.length > 0) {
132
- symbolicatedFrames = await this.symbolicator.symbolicate(mapped);
133
- }
134
- }
135
- const componentStack = event.contexts?.react?.componentStack ?? null;
136
- const mechanismType = event.exception?.values?.[0]?.mechanism?.type ?? null;
137
- this.onError?.({ message, symbolicatedFrames, componentStack, mechanismType });
138
- return event;
139
- }
140
- /**
141
- * Sentry beforeBreadcrumb hook。
142
- * 识别 HTTP 类型的 breadcrumb,触发 onNetwork 回调,原样返回 breadcrumb。
143
- */
144
- beforeBreadcrumb(breadcrumb, _hint) {
145
- if (breadcrumb.type === "http") {
146
- const data = breadcrumb.data;
147
- this.onNetwork?.({
148
- method: data?.method ?? null,
149
- url: data?.url ?? null,
150
- statusCode: data?.status_code ?? null
151
- });
152
- }
153
- return breadcrumb;
154
- }
155
- };
156
- // Annotate the CommonJS export names for ESM import in node:
157
- 0 && (module.exports = {
158
- MetroSymbolicator,
159
- SentryCapture
160
- });
161
2
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,133 +1 @@
1
- // src/capture.ts
2
- import { parse as parseStackTrace } from "stacktrace-parser";
3
- import { NativeModules, Platform } from "react-native";
4
- var MetroSymbolicator = class _MetroSymbolicator {
5
- constructor({ baseUrl } = {}) {
6
- this.baseUrl = baseUrl ?? _MetroSymbolicator._getDefaultBaseUrl();
7
- }
8
- /**
9
- * 从 NativeModules.SourceCode.scriptURL 推断 Metro server base URL。
10
- * web 平台使用相对路径;native 回退到 localhost:8081。
11
- */
12
- static _getDefaultBaseUrl() {
13
- try {
14
- const scriptURL = NativeModules?.SourceCode?.scriptURL;
15
- if (scriptURL) {
16
- const url = new URL(scriptURL);
17
- return `${url.protocol}//${url.host}`;
18
- }
19
- } catch (_) {
20
- }
21
- return Platform.OS === "web" ? "" : "http://localhost:8081";
22
- }
23
- /**
24
- * 解析 Error.stack 字符串为 Metro 所需的帧数组。
25
- *
26
- * 使用 stacktrace-parser 覆盖各 JS 引擎的格式:
27
- * V8/Node.js/Hermes(新):at methodName (url:line:col)
28
- * Gecko/Firefox/Hermes(旧):methodName@url:line:col
29
- * JavaScriptCore(iOS):methodName@url:line:col
30
- *
31
- * 无法符号化的帧(file 或 lineNumber 为 null)会被过滤掉。
32
- */
33
- parseErrorStack(stack) {
34
- return parseStackTrace(stack).filter(
35
- (f) => f.file != null && f.lineNumber != null
36
- ).map((f) => ({
37
- file: f.file,
38
- lineNumber: f.lineNumber,
39
- column: f.column != null ? f.column - 1 : 0,
40
- methodName: f.methodName === "<unknown>" ? "(anonymous)" : f.methodName
41
- }));
42
- }
43
- /**
44
- * 将帧列表发送到 Metro /symbolicate,返回符号化后的帧数组。
45
- */
46
- async symbolicate(stack) {
47
- if (stack.length === 0) return null;
48
- const endpoint = `${this.baseUrl}/symbolicate`;
49
- try {
50
- const res = await fetch(endpoint, {
51
- method: "POST",
52
- headers: { "Content-Type": "application/json" },
53
- body: JSON.stringify({ stack })
54
- });
55
- if (!res.ok) {
56
- console.warn(`[SentryCapture] /symbolicate returned ${res.status}`);
57
- return null;
58
- }
59
- const data = await res.json();
60
- return data.stack ?? null;
61
- } catch (e) {
62
- console.warn("[SentryCapture] symbolication failed:", e?.message ?? e);
63
- return null;
64
- }
65
- }
66
- };
67
- var SentryCapture = class {
68
- constructor({ onError, onNetwork, symbolicator } = {}) {
69
- this.onError = onError;
70
- this.onNetwork = onNetwork;
71
- this.symbolicator = symbolicator ?? new MetroSymbolicator();
72
- this.beforeSend = this.beforeSend.bind(this);
73
- this.beforeBreadcrumb = this.beforeBreadcrumb.bind(this);
74
- }
75
- /**
76
- * Sentry beforeSend hook。
77
- * 优先使用原始 Error.stack 进行符号化;若无法获取则回退到 Sentry 事件帧。
78
- * 符号化完成后触发 onError 回调,原样返回 event。
79
- */
80
- async beforeSend(event, hint) {
81
- globalThis.__SENTRY_LAST_RAW__ = { event, hint };
82
- const message = event.exception?.values?.[0]?.value ?? event.message ?? "(unknown)";
83
- let symbolicatedFrames = null;
84
- const originalException = hint?.originalException;
85
- const rawStack = originalException instanceof Error && typeof originalException.stack === "string" ? originalException.stack : null;
86
- if (rawStack !== null) {
87
- const frames = this.symbolicator.parseErrorStack(rawStack);
88
- if (frames.length > 0) {
89
- symbolicatedFrames = await this.symbolicator.symbolicate(frames);
90
- }
91
- }
92
- if (symbolicatedFrames === null) {
93
- const sentryFrames = event.exception?.values?.[0]?.stacktrace?.frames ?? [];
94
- const mapped = sentryFrames.filter(
95
- (f) => f.filename != null && f.lineno != null
96
- ).map(
97
- (f) => ({
98
- file: f.filename,
99
- lineNumber: f.lineno,
100
- column: f.colno ?? 0,
101
- methodName: f.function ?? "(anonymous)"
102
- })
103
- );
104
- if (mapped.length > 0) {
105
- symbolicatedFrames = await this.symbolicator.symbolicate(mapped);
106
- }
107
- }
108
- const componentStack = event.contexts?.react?.componentStack ?? null;
109
- const mechanismType = event.exception?.values?.[0]?.mechanism?.type ?? null;
110
- this.onError?.({ message, symbolicatedFrames, componentStack, mechanismType });
111
- return event;
112
- }
113
- /**
114
- * Sentry beforeBreadcrumb hook。
115
- * 识别 HTTP 类型的 breadcrumb,触发 onNetwork 回调,原样返回 breadcrumb。
116
- */
117
- beforeBreadcrumb(breadcrumb, _hint) {
118
- if (breadcrumb.type === "http") {
119
- const data = breadcrumb.data;
120
- this.onNetwork?.({
121
- method: data?.method ?? null,
122
- url: data?.url ?? null,
123
- statusCode: data?.status_code ?? null
124
- });
125
- }
126
- return breadcrumb;
127
- }
128
- };
129
- export {
130
- MetroSymbolicator,
131
- SentryCapture
132
- };
133
1
  //# sourceMappingURL=index.mjs.map
package/dist/metro.d.mts CHANGED
@@ -58,9 +58,10 @@ declare function withNativeWind(config: MetroConfig, options?: any): MetroConfig
58
58
  /**
59
59
  * withEntryInjection — 在 expo-router 启动前注入脚本
60
60
  *
61
- * 拦截 expo-router/entry-classic 的解析,重定向到 expo-router-entry-stub.js。
62
- * stub 先 require entry-inject.js,再 require expo-router/entry-classic,
63
- * 使注入脚本在 expo-router renderRootComponent 之前执行。
61
+ * 拦截 expo-router/entry-classic 的解析,重定向到平台对应的入口 stub。
62
+ * Web 使用 expo-router-entry-stub.js;iOS/Android 使用
63
+ * expo-router-entry-native-stub.js。入口 stub 会在 expo-router 注册应用前
64
+ * 执行 DevKit 的公共运行时初始化。
64
65
  *
65
66
  * 拦截 entry-classic 而非 entry 本身:expo-router/entry 通过 <script src="...entry.bundle">
66
67
  * 直接加载,不经过 resolveRequest;其内部的 import 'expo-router/entry-classic' 才经过 resolveRequest。
@@ -120,9 +121,10 @@ declare function withRouteEndpoint(config: MetroConfig, options: RouteEndpointOp
120
121
  * withExpoNotificationsStub — Android:expo-notifications → stub(Expo Go no-op,Dev Build 透传)
121
122
  * withExpoMediaLibraryStub — Web / Expo Go:expo-media-library → stub(弹 Alert 提示,Dev Build 透传)
122
123
  * withExpoCalendarStub — Web / Expo Go:expo-calendar → stub(弹 Alert 提示,Dev Build 透传)
124
+ * withExpoNativeWechatStub — Web / Expo Go:expo-native-wechat → stub(弹 Dialog/Alert 提示,Dev Build 透传)
123
125
  * withExpoFileSystemStub — Web:expo-file-system/legacy → stub(弹 Dialog 提示,原生透传)
124
126
  * withExpoImagePickerStub — Web 桌面:launchCameraAsync 用 getUserMedia 唤起摄像头
125
- * withEntryInjection — 在 expo-router 启动前注入脚本(仅 __DEV__)
127
+ * withEntryInjection — 在 expo-router 启动前注入公共运行时策略(仅 __DEV__)
126
128
  * withDevStubs — 替换 Sentry DSN / 屏蔽 LogBox(仅 __DEV__)
127
129
  * withRouteEndpoint — 添加 /__routes 端点(仅 __DEV__)
128
130
  * withNativeWind — NativeWind 支持(含缓存路径修复)
@@ -306,6 +308,24 @@ declare function withExpoMediaLibraryStub(config: MetroConfig): MetroConfig;
306
308
  */
307
309
  declare function withExpoCalendarStub(config: MetroConfig): MetroConfig;
308
310
 
311
+ /**
312
+ * withExpoNativeWechatStub — Web 平台将 expo-native-wechat 替换为 stub
313
+ *
314
+ * expo-native-wechat 的 module.ts 在 import 时无条件调用
315
+ * requireNativeModule('ExpoNativeWechat'),Web 环境下没有该 native module 会直接抛错。
316
+ *
317
+ * stub 运行时行为:
318
+ * - Web:no-op,设置/查询类 API 静默返回占位值,业务动作类 API(分享、
319
+ * 支付、授权等)弹出 Dialog 提示当前环境不支持并 reject
320
+ * - Development Build(原生):透传真实 expo-native-wechat,功能完全正常
321
+ */
322
+
323
+ /**
324
+ * @param config Metro config 对象
325
+ * @returns 注入 resolveRequest 后的新 Metro config
326
+ */
327
+ declare function withExpoNativeWechatStub(config: MetroConfig): MetroConfig;
328
+
309
329
  /**
310
330
  * withExpoFileSystemStub — Web 端将 expo-file-system 系列模块替换为 stub
311
331
  *
@@ -500,4 +520,4 @@ interface PersistentCacheOptions {
500
520
  }
501
521
  declare function withPersistentCache(config: MetroConfig, options?: PersistentCacheOptions): MetroConfig;
502
522
 
503
- export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type PersistentCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoCameraRecordStub, withExpoContactsStub, withExpoFileSystemStub, withExpoHapticsStub, withExpoImagePickerStub, withExpoMediaLibraryStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withPersistentCache, withRouteEndpoint, withTransformLogger, withWasmSupport, withWorkspaceNodeModules };
523
+ export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type PersistentCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoCameraRecordStub, withExpoContactsStub, withExpoFileSystemStub, withExpoHapticsStub, withExpoImagePickerStub, withExpoMediaLibraryStub, withExpoNativeWechatStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withPersistentCache, withRouteEndpoint, withTransformLogger, withWasmSupport, withWorkspaceNodeModules };
package/dist/metro.d.ts CHANGED
@@ -58,9 +58,10 @@ declare function withNativeWind(config: MetroConfig, options?: any): MetroConfig
58
58
  /**
59
59
  * withEntryInjection — 在 expo-router 启动前注入脚本
60
60
  *
61
- * 拦截 expo-router/entry-classic 的解析,重定向到 expo-router-entry-stub.js。
62
- * stub 先 require entry-inject.js,再 require expo-router/entry-classic,
63
- * 使注入脚本在 expo-router renderRootComponent 之前执行。
61
+ * 拦截 expo-router/entry-classic 的解析,重定向到平台对应的入口 stub。
62
+ * Web 使用 expo-router-entry-stub.js;iOS/Android 使用
63
+ * expo-router-entry-native-stub.js。入口 stub 会在 expo-router 注册应用前
64
+ * 执行 DevKit 的公共运行时初始化。
64
65
  *
65
66
  * 拦截 entry-classic 而非 entry 本身:expo-router/entry 通过 <script src="...entry.bundle">
66
67
  * 直接加载,不经过 resolveRequest;其内部的 import 'expo-router/entry-classic' 才经过 resolveRequest。
@@ -120,9 +121,10 @@ declare function withRouteEndpoint(config: MetroConfig, options: RouteEndpointOp
120
121
  * withExpoNotificationsStub — Android:expo-notifications → stub(Expo Go no-op,Dev Build 透传)
121
122
  * withExpoMediaLibraryStub — Web / Expo Go:expo-media-library → stub(弹 Alert 提示,Dev Build 透传)
122
123
  * withExpoCalendarStub — Web / Expo Go:expo-calendar → stub(弹 Alert 提示,Dev Build 透传)
124
+ * withExpoNativeWechatStub — Web / Expo Go:expo-native-wechat → stub(弹 Dialog/Alert 提示,Dev Build 透传)
123
125
  * withExpoFileSystemStub — Web:expo-file-system/legacy → stub(弹 Dialog 提示,原生透传)
124
126
  * withExpoImagePickerStub — Web 桌面:launchCameraAsync 用 getUserMedia 唤起摄像头
125
- * withEntryInjection — 在 expo-router 启动前注入脚本(仅 __DEV__)
127
+ * withEntryInjection — 在 expo-router 启动前注入公共运行时策略(仅 __DEV__)
126
128
  * withDevStubs — 替换 Sentry DSN / 屏蔽 LogBox(仅 __DEV__)
127
129
  * withRouteEndpoint — 添加 /__routes 端点(仅 __DEV__)
128
130
  * withNativeWind — NativeWind 支持(含缓存路径修复)
@@ -306,6 +308,24 @@ declare function withExpoMediaLibraryStub(config: MetroConfig): MetroConfig;
306
308
  */
307
309
  declare function withExpoCalendarStub(config: MetroConfig): MetroConfig;
308
310
 
311
+ /**
312
+ * withExpoNativeWechatStub — Web 平台将 expo-native-wechat 替换为 stub
313
+ *
314
+ * expo-native-wechat 的 module.ts 在 import 时无条件调用
315
+ * requireNativeModule('ExpoNativeWechat'),Web 环境下没有该 native module 会直接抛错。
316
+ *
317
+ * stub 运行时行为:
318
+ * - Web:no-op,设置/查询类 API 静默返回占位值,业务动作类 API(分享、
319
+ * 支付、授权等)弹出 Dialog 提示当前环境不支持并 reject
320
+ * - Development Build(原生):透传真实 expo-native-wechat,功能完全正常
321
+ */
322
+
323
+ /**
324
+ * @param config Metro config 对象
325
+ * @returns 注入 resolveRequest 后的新 Metro config
326
+ */
327
+ declare function withExpoNativeWechatStub(config: MetroConfig): MetroConfig;
328
+
309
329
  /**
310
330
  * withExpoFileSystemStub — Web 端将 expo-file-system 系列模块替换为 stub
311
331
  *
@@ -500,4 +520,4 @@ interface PersistentCacheOptions {
500
520
  }
501
521
  declare function withPersistentCache(config: MetroConfig, options?: PersistentCacheOptions): MetroConfig;
502
522
 
503
- export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type PersistentCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoCameraRecordStub, withExpoContactsStub, withExpoFileSystemStub, withExpoHapticsStub, withExpoImagePickerStub, withExpoMediaLibraryStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withPersistentCache, withRouteEndpoint, withTransformLogger, withWasmSupport, withWorkspaceNodeModules };
523
+ export { type DevkitOptions, type InjectOptions, type PatchNativeWindCacheOptions, type PersistentCacheOptions, type RouteEndpointOptions, patchNativeWindCachePath, withCssInterop, withDevStubs, withDevkit, withEntryInjection, withEsbuildMinify, withExpoCalendarStub, withExpoCameraRecordStub, withExpoContactsStub, withExpoFileSystemStub, withExpoHapticsStub, withExpoImagePickerStub, withExpoMediaLibraryStub, withExpoNativeWechatStub, withExpoNotificationsStub, withLucideResolver, withNativeWind, withPersistentCache, withRouteEndpoint, withTransformLogger, withWasmSupport, withWorkspaceNodeModules };