@fz-firefly/taro 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,163 @@
1
+ import { CaptureContext, FireflyClient, FireflyClient as FireflyClient$1, FireflyOptions, FireflyOptions as FireflyOptions$1, FireflyStorage, FireflyTransport, PlatformContext, ResolvedOptions, Tags } from "@fz-firefly/core";
2
+ import { Platform } from "@fz-firefly/shared";
3
+ /**
4
+ * Taro 的 @tarojs/taro 由宿主项目提供,这里只声明 SDK 真正用到的 API,
5
+ * 避免把整套 Taro 类型带进包依赖。
6
+ */
7
+ interface TaroSystemInfo {
8
+ platform?: string;
9
+ system?: string;
10
+ model?: string;
11
+ brand?: string;
12
+ windowWidth?: number;
13
+ windowHeight?: number;
14
+ pixelRatio?: number;
15
+ language?: string;
16
+ networkType?: string;
17
+ appVersion?: string;
18
+ SDKVersion?: string;
19
+ carrier?: string;
20
+ operator?: string;
21
+ }
22
+ /** Taro.request 的响应。 */
23
+ interface TaroRequestResult {
24
+ statusCode?: number;
25
+ data?: unknown;
26
+ errMsg?: string;
27
+ header?: Record<string, string>;
28
+ }
29
+ /** Taro.request 的入参。 */
30
+ interface TaroRequestOptions {
31
+ url: string;
32
+ method?: string;
33
+ header?: Record<string, string>;
34
+ data?: unknown;
35
+ dataType?: string;
36
+ success?: (result: TaroRequestResult) => void;
37
+ fail?: (error: {
38
+ errMsg?: string;
39
+ }) => void;
40
+ complete?: (...args: unknown[]) => void;
41
+ }
42
+ /** Taro.addInterceptor 提供的请求链。 */
43
+ interface TaroRequestChain {
44
+ requestParams: TaroRequestOptions;
45
+ proceed(requestParams?: TaroRequestOptions): Promise<TaroRequestResult>;
46
+ }
47
+ /** Taro.addInterceptor 的请求拦截器。 */
48
+ type TaroRequestInterceptor = (chain: TaroRequestChain) => unknown;
49
+ /** Taro.getCurrentPages() 返回的页面。 */
50
+ interface TaroPage {
51
+ route?: string;
52
+ options?: Record<string, unknown>;
53
+ $taroPath?: string;
54
+ }
55
+ /** Taro 导航 API 的参数。 */
56
+ interface TaroNavigationOptions {
57
+ url?: string;
58
+ delta?: number;
59
+ success?: (...args: unknown[]) => void;
60
+ fail?: (...args: unknown[]) => void;
61
+ complete?: (...args: unknown[]) => void;
62
+ }
63
+ /** SDK 会包装的导航 API。 */
64
+ type TaroNavigationApi = 'navigateTo' | 'redirectTo' | 'switchTab' | 'reLaunch' | 'navigateBack';
65
+ /**
66
+ * SDK 真正用到的 Taro API 子集。
67
+ *
68
+ * 不直接依赖 @tarojs/taro 的类型,方便在 Node 测试环境里用最小 mock 验证。
69
+ */
70
+ interface TaroRuntime {
71
+ getEnv?(): string;
72
+ getSystemInfoSync?(): TaroSystemInfo;
73
+ getStorageSync?(key: string): unknown;
74
+ setStorageSync?(key: string, value: string): void;
75
+ removeStorageSync?(key: string): void;
76
+ request?(options: TaroRequestOptions): unknown;
77
+ addInterceptor?(interceptor: TaroRequestInterceptor): void;
78
+ onError?(handler: (error: unknown) => void): void;
79
+ offError?(handler: (error: unknown) => void): void;
80
+ onUnhandledRejection?(handler: (event: {
81
+ reason?: unknown;
82
+ }) => void): void;
83
+ offUnhandledRejection?(handler: (event: {
84
+ reason?: unknown;
85
+ }) => void): void;
86
+ onAppShow?(handler: () => void): void;
87
+ offAppShow?(handler: () => void): void;
88
+ onAppHide?(handler: () => void): void;
89
+ offAppHide?(handler: () => void): void;
90
+ onNetworkStatusChange?(handler: (event: {
91
+ isConnected?: boolean;
92
+ networkType?: string;
93
+ }) => void): void;
94
+ offNetworkStatusChange?(handler: (event: {
95
+ isConnected?: boolean;
96
+ networkType?: string;
97
+ }) => void): void;
98
+ navigateTo?(options: TaroNavigationOptions): unknown;
99
+ redirectTo?(options: TaroNavigationOptions): unknown;
100
+ switchTab?(options: TaroNavigationOptions): unknown;
101
+ reLaunch?(options: TaroNavigationOptions): unknown;
102
+ navigateBack?(options?: TaroNavigationOptions): unknown;
103
+ getCurrentPages?(): TaroPage[];
104
+ }
105
+ /** 读取 Taro 运行时;不在 Taro 环境时返回 null。 */
106
+ export declare function getTaro(): TaroRuntime | null;
107
+ /** 安全读取系统信息,失败时返回 null。 */
108
+ export declare function readSystemInfo(runtime?: TaroRuntime | null): TaroSystemInfo | null;
109
+ /** 读取当前页面;非 Taro 环境返回 null。 */
110
+ export declare function readCurrentPage(runtime?: TaroRuntime | null): TaroPage | null;
111
+ /** 平台识别结果。 */
112
+ interface PlatformInfo {
113
+ /** 协议里的运行时平台。 */
114
+ platform: Platform;
115
+ /** 分发标识,例如 h5 / mp-weixin / rn。 */
116
+ dist: string;
117
+ }
118
+ /**
119
+ * 识别当前 Taro 运行平台。
120
+ *
121
+ * 优先使用 Taro.getEnv()(WEAPP / WEB / ALIPAY / RN...),
122
+ * 拿不到时按是否存在 window 粗略判断。协议只接受 web / mp-weixin /
123
+ * mp-alipay / app,其他小程序统一归为 app,并在 dist 里保留真实平台。
124
+ */
125
+ export declare function detectPlatform(runtime?: TaroRuntime | null): PlatformInfo;
126
+ /**
127
+ * Taro 初始化参数。
128
+ *
129
+ * 与 core 的 FireflyOptions 一致,额外提供 H5 / 小程序可用的采集开关。
130
+ */
131
+ interface InitOptions extends FireflyOptions$1 {
132
+ /** 可选:注入应用实际使用的 Taro 运行时。 */
133
+ runtime?: TaroRuntime | null;
134
+ /** 是否记录 H5 点击面包屑,默认 true;小程序无 DOM 时自动跳过。 */
135
+ captureClicks?: boolean;
136
+ /** 是否记录 console.error / console.warn,默认 true。 */
137
+ captureConsole?: boolean;
138
+ /** 是否记录页面可见性/网络状态/小程序前后台,默认 true。 */
139
+ captureLifecycle?: boolean;
140
+ /** 是否记录 H5 资源加载失败,默认 true;小程序自动跳过。 */
141
+ captureResourceErrors?: boolean;
142
+ }
143
+ /** initFirefly 的返回值。 */
144
+ interface FireflyHandle {
145
+ /** 客户端实例,可用于手动 captureException / track / setUser。 */
146
+ client: FireflyClient$1;
147
+ /** 移除 Taro 钩子并停止定时器。 */
148
+ dispose(): void;
149
+ }
150
+ /**
151
+ * Taro 平台入口。
152
+ *
153
+ * 一行接入:
154
+ * ```ts
155
+ * const handle = initFirefly({ dsn, endpoint, environment, release })
156
+ * ```
157
+ *
158
+ * 这个入口只负责 Taro 平台能力;React / Vue 的组件错误处理
159
+ * 分别从 `@fz-firefly/taro/react` 和 `@fz-firefly/taro/vue` 引入。
160
+ */
161
+ export declare function initFirefly(options: InitOptions): FireflyHandle;
162
+ export type { CaptureContext, FireflyClient, FireflyHandle, FireflyOptions, FireflyStorage, FireflyTransport, InitOptions, PlatformContext, PlatformInfo, ResolvedOptions, Tags, TaroNavigationApi, TaroNavigationOptions, TaroPage, TaroRequestChain, TaroRequestInterceptor, TaroRequestOptions, TaroRequestResult, TaroRuntime, TaroSystemInfo };
163
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,163 @@
1
+ import { CaptureContext, FireflyClient, FireflyClient as FireflyClient$1, FireflyOptions, FireflyOptions as FireflyOptions$1, FireflyStorage, FireflyTransport, PlatformContext, ResolvedOptions, Tags } from "@fz-firefly/core";
2
+ import { Platform } from "@fz-firefly/shared";
3
+ /**
4
+ * Taro 的 @tarojs/taro 由宿主项目提供,这里只声明 SDK 真正用到的 API,
5
+ * 避免把整套 Taro 类型带进包依赖。
6
+ */
7
+ interface TaroSystemInfo {
8
+ platform?: string;
9
+ system?: string;
10
+ model?: string;
11
+ brand?: string;
12
+ windowWidth?: number;
13
+ windowHeight?: number;
14
+ pixelRatio?: number;
15
+ language?: string;
16
+ networkType?: string;
17
+ appVersion?: string;
18
+ SDKVersion?: string;
19
+ carrier?: string;
20
+ operator?: string;
21
+ }
22
+ /** Taro.request 的响应。 */
23
+ interface TaroRequestResult {
24
+ statusCode?: number;
25
+ data?: unknown;
26
+ errMsg?: string;
27
+ header?: Record<string, string>;
28
+ }
29
+ /** Taro.request 的入参。 */
30
+ interface TaroRequestOptions {
31
+ url: string;
32
+ method?: string;
33
+ header?: Record<string, string>;
34
+ data?: unknown;
35
+ dataType?: string;
36
+ success?: (result: TaroRequestResult) => void;
37
+ fail?: (error: {
38
+ errMsg?: string;
39
+ }) => void;
40
+ complete?: (...args: unknown[]) => void;
41
+ }
42
+ /** Taro.addInterceptor 提供的请求链。 */
43
+ interface TaroRequestChain {
44
+ requestParams: TaroRequestOptions;
45
+ proceed(requestParams?: TaroRequestOptions): Promise<TaroRequestResult>;
46
+ }
47
+ /** Taro.addInterceptor 的请求拦截器。 */
48
+ type TaroRequestInterceptor = (chain: TaroRequestChain) => unknown;
49
+ /** Taro.getCurrentPages() 返回的页面。 */
50
+ interface TaroPage {
51
+ route?: string;
52
+ options?: Record<string, unknown>;
53
+ $taroPath?: string;
54
+ }
55
+ /** Taro 导航 API 的参数。 */
56
+ interface TaroNavigationOptions {
57
+ url?: string;
58
+ delta?: number;
59
+ success?: (...args: unknown[]) => void;
60
+ fail?: (...args: unknown[]) => void;
61
+ complete?: (...args: unknown[]) => void;
62
+ }
63
+ /** SDK 会包装的导航 API。 */
64
+ type TaroNavigationApi = 'navigateTo' | 'redirectTo' | 'switchTab' | 'reLaunch' | 'navigateBack';
65
+ /**
66
+ * SDK 真正用到的 Taro API 子集。
67
+ *
68
+ * 不直接依赖 @tarojs/taro 的类型,方便在 Node 测试环境里用最小 mock 验证。
69
+ */
70
+ interface TaroRuntime {
71
+ getEnv?(): string;
72
+ getSystemInfoSync?(): TaroSystemInfo;
73
+ getStorageSync?(key: string): unknown;
74
+ setStorageSync?(key: string, value: string): void;
75
+ removeStorageSync?(key: string): void;
76
+ request?(options: TaroRequestOptions): unknown;
77
+ addInterceptor?(interceptor: TaroRequestInterceptor): void;
78
+ onError?(handler: (error: unknown) => void): void;
79
+ offError?(handler: (error: unknown) => void): void;
80
+ onUnhandledRejection?(handler: (event: {
81
+ reason?: unknown;
82
+ }) => void): void;
83
+ offUnhandledRejection?(handler: (event: {
84
+ reason?: unknown;
85
+ }) => void): void;
86
+ onAppShow?(handler: () => void): void;
87
+ offAppShow?(handler: () => void): void;
88
+ onAppHide?(handler: () => void): void;
89
+ offAppHide?(handler: () => void): void;
90
+ onNetworkStatusChange?(handler: (event: {
91
+ isConnected?: boolean;
92
+ networkType?: string;
93
+ }) => void): void;
94
+ offNetworkStatusChange?(handler: (event: {
95
+ isConnected?: boolean;
96
+ networkType?: string;
97
+ }) => void): void;
98
+ navigateTo?(options: TaroNavigationOptions): unknown;
99
+ redirectTo?(options: TaroNavigationOptions): unknown;
100
+ switchTab?(options: TaroNavigationOptions): unknown;
101
+ reLaunch?(options: TaroNavigationOptions): unknown;
102
+ navigateBack?(options?: TaroNavigationOptions): unknown;
103
+ getCurrentPages?(): TaroPage[];
104
+ }
105
+ /** 读取 Taro 运行时;不在 Taro 环境时返回 null。 */
106
+ export declare function getTaro(): TaroRuntime | null;
107
+ /** 安全读取系统信息,失败时返回 null。 */
108
+ export declare function readSystemInfo(runtime?: TaroRuntime | null): TaroSystemInfo | null;
109
+ /** 读取当前页面;非 Taro 环境返回 null。 */
110
+ export declare function readCurrentPage(runtime?: TaroRuntime | null): TaroPage | null;
111
+ /** 平台识别结果。 */
112
+ interface PlatformInfo {
113
+ /** 协议里的运行时平台。 */
114
+ platform: Platform;
115
+ /** 分发标识,例如 h5 / mp-weixin / rn。 */
116
+ dist: string;
117
+ }
118
+ /**
119
+ * 识别当前 Taro 运行平台。
120
+ *
121
+ * 优先使用 Taro.getEnv()(WEAPP / WEB / ALIPAY / RN...),
122
+ * 拿不到时按是否存在 window 粗略判断。协议只接受 web / mp-weixin /
123
+ * mp-alipay / app,其他小程序统一归为 app,并在 dist 里保留真实平台。
124
+ */
125
+ export declare function detectPlatform(runtime?: TaroRuntime | null): PlatformInfo;
126
+ /**
127
+ * Taro 初始化参数。
128
+ *
129
+ * 与 core 的 FireflyOptions 一致,额外提供 H5 / 小程序可用的采集开关。
130
+ */
131
+ interface InitOptions extends FireflyOptions$1 {
132
+ /** 可选:注入应用实际使用的 Taro 运行时。 */
133
+ runtime?: TaroRuntime | null;
134
+ /** 是否记录 H5 点击面包屑,默认 true;小程序无 DOM 时自动跳过。 */
135
+ captureClicks?: boolean;
136
+ /** 是否记录 console.error / console.warn,默认 true。 */
137
+ captureConsole?: boolean;
138
+ /** 是否记录页面可见性/网络状态/小程序前后台,默认 true。 */
139
+ captureLifecycle?: boolean;
140
+ /** 是否记录 H5 资源加载失败,默认 true;小程序自动跳过。 */
141
+ captureResourceErrors?: boolean;
142
+ }
143
+ /** initFirefly 的返回值。 */
144
+ interface FireflyHandle {
145
+ /** 客户端实例,可用于手动 captureException / track / setUser。 */
146
+ client: FireflyClient$1;
147
+ /** 移除 Taro 钩子并停止定时器。 */
148
+ dispose(): void;
149
+ }
150
+ /**
151
+ * Taro 平台入口。
152
+ *
153
+ * 一行接入:
154
+ * ```ts
155
+ * const handle = initFirefly({ dsn, endpoint, environment, release })
156
+ * ```
157
+ *
158
+ * 这个入口只负责 Taro 平台能力;React / Vue 的组件错误处理
159
+ * 分别从 `@fz-firefly/taro/react` 和 `@fz-firefly/taro/vue` 引入。
160
+ */
161
+ export declare function initFirefly(options: InitOptions): FireflyHandle;
162
+ export type { CaptureContext, FireflyClient, FireflyHandle, FireflyOptions, FireflyStorage, FireflyTransport, InitOptions, PlatformContext, PlatformInfo, ResolvedOptions, Tags, TaroNavigationApi, TaroNavigationOptions, TaroPage, TaroRequestChain, TaroRequestInterceptor, TaroRequestOptions, TaroRequestResult, TaroRuntime, TaroSystemInfo };
163
+ //# sourceMappingURL=index.d.ts.map