@trimjs/web-app 0.3.3 → 0.4.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.
- package/README.md +107 -22
- package/dist/app-auth.d.ts +52 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +141 -382
- package/dist/index.js +1 -1
- package/dist/logger.d.ts +42 -0
- package/dist/mobile/index.d.ts +53 -0
- package/dist/mobile/types.d.ts +10 -0
- package/dist/types.d.ts +42 -0
- package/dist/utils/platform.d.ts +3 -0
- package/dist/web/extension.d.ts +4 -0
- package/dist/web/index.d.ts +23 -0
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,382 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
*
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
* 扩充搜索 文件类型
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* expandFiles: [
|
|
146
|
-
* {
|
|
147
|
-
* title: '我的种子',
|
|
148
|
-
* extension: '.torrent',
|
|
149
|
-
* },
|
|
150
|
-
* ];
|
|
151
|
-
*/
|
|
152
|
-
expandFiles?: {
|
|
153
|
-
/**
|
|
154
|
-
* 侧边栏标题
|
|
155
|
-
*/
|
|
156
|
-
title: string;
|
|
157
|
-
/**
|
|
158
|
-
* 文件扩展名
|
|
159
|
-
*/
|
|
160
|
-
extension: string;
|
|
161
|
-
}[];
|
|
162
|
-
/**
|
|
163
|
-
* 是否允许创建文件夹
|
|
164
|
-
*
|
|
165
|
-
* @default true
|
|
166
|
-
*/
|
|
167
|
-
creatable?: boolean;
|
|
168
|
-
/**
|
|
169
|
-
* 标题
|
|
170
|
-
*
|
|
171
|
-
* @default '选择文件' | '选择文件夹'
|
|
172
|
-
*/
|
|
173
|
-
title?: string;
|
|
174
|
-
/**
|
|
175
|
-
* 确认按钮文本
|
|
176
|
-
*
|
|
177
|
-
* @default '确定'
|
|
178
|
-
*/
|
|
179
|
-
okText?: string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export declare interface HostSnapshot {
|
|
183
|
-
status: string;
|
|
184
|
-
host?: string;
|
|
185
|
-
username?: string;
|
|
186
|
-
currentSessionId?: string;
|
|
187
|
-
sessions: Array<{
|
|
188
|
-
id: string;
|
|
189
|
-
label: string;
|
|
190
|
-
host?: string;
|
|
191
|
-
username?: string;
|
|
192
|
-
}>;
|
|
193
|
-
errorMessage?: string;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
declare interface OpenAppParams {
|
|
197
|
-
custom?: {
|
|
198
|
-
name?: string;
|
|
199
|
-
};
|
|
200
|
-
app?: App;
|
|
201
|
-
params?: {
|
|
202
|
-
[key: string]: any;
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export declare interface PlatformConfig {
|
|
207
|
-
theme: 'dark' | 'light';
|
|
208
|
-
language: string;
|
|
209
|
-
appVersion?: string;
|
|
210
|
-
systemVersion: string;
|
|
211
|
-
format: {
|
|
212
|
-
date?: string;
|
|
213
|
-
time?: string;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export declare interface QueryConfig {
|
|
218
|
-
timer?: boolean;
|
|
219
|
-
observable?: boolean;
|
|
220
|
-
encrypt?: boolean;
|
|
221
|
-
timeout?: number;
|
|
222
|
-
skipPreflight?: boolean;
|
|
223
|
-
autoFailTips?: boolean;
|
|
224
|
-
failTipsPrefix?: string;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export declare type ResponseData<T> = T extends undefined ? ResponseDataBase : ResponseDataBase & T;
|
|
228
|
-
|
|
229
|
-
declare interface ResponseDataBase {
|
|
230
|
-
reqid: string;
|
|
231
|
-
result: ResponseStatus;
|
|
232
|
-
taskId?: string;
|
|
233
|
-
type?: string;
|
|
234
|
-
errmsg?: string;
|
|
235
|
-
errno?: number;
|
|
236
|
-
extra?: string;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
declare enum ResponseStatus {
|
|
240
|
-
SUCCESS = "succ",// 成功
|
|
241
|
-
FAIL = "fail",// 失败
|
|
242
|
-
CANCEL = "cancel",// 用户取消
|
|
243
|
-
DOING = "doing"
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Trim App 实例类
|
|
248
|
-
*/
|
|
249
|
-
declare class TrimApp {
|
|
250
|
-
private options;
|
|
251
|
-
private flutterInAppWebView;
|
|
252
|
-
private osConnector;
|
|
253
|
-
private initPromise;
|
|
254
|
-
private appApiVersion?;
|
|
255
|
-
isWeb: boolean;
|
|
256
|
-
isStandaloneWeb: boolean;
|
|
257
|
-
constructor(options?: TrimAppOptions);
|
|
258
|
-
private init;
|
|
259
|
-
private getWebMethods;
|
|
260
|
-
private loadAppMessage;
|
|
261
|
-
private initMobileAppApi;
|
|
262
|
-
private assertMobileAppApi;
|
|
263
|
-
private isAtLeastVersion;
|
|
264
|
-
private parseVersion;
|
|
265
|
-
callAppMethod<T>(fn: string, ...params: Array<string | undefined>): Promise<T | null>;
|
|
266
|
-
/**
|
|
267
|
-
* 等待初始化完成
|
|
268
|
-
*
|
|
269
|
-
* @returns Promise
|
|
270
|
-
*/
|
|
271
|
-
ready(): Promise<void>;
|
|
272
|
-
/**
|
|
273
|
-
* 获取配置
|
|
274
|
-
*/
|
|
275
|
-
getOptions(): TrimAppOptions;
|
|
276
|
-
/**
|
|
277
|
-
* 更新配置
|
|
278
|
-
*/
|
|
279
|
-
setOptions(options: Partial<TrimAppOptions>): void;
|
|
280
|
-
/**
|
|
281
|
-
* 获取平台配置
|
|
282
|
-
*/
|
|
283
|
-
getPlatformConfig(): Promise<PlatformConfig>;
|
|
284
|
-
getHostSnapshot(): Promise<HostSnapshot>;
|
|
285
|
-
getAppAuthBaseUrl(): Promise<string>;
|
|
286
|
-
buildAppAuthUrl(request: AppAuthRequest): Promise<string>;
|
|
287
|
-
openAppAuth(request: AppAuthRequest, options?: {
|
|
288
|
-
target?: string;
|
|
289
|
-
features?: string;
|
|
290
|
-
}): Promise<string>;
|
|
291
|
-
parseAppAuthCallback(input?: string | URL | URLSearchParams): AppAuthResult;
|
|
292
|
-
/**
|
|
293
|
-
* setTitle - 设置标题
|
|
294
|
-
*
|
|
295
|
-
* @param title 标题文本
|
|
296
|
-
*/
|
|
297
|
-
setTitle(title: string): Promise<void>;
|
|
298
|
-
/**
|
|
299
|
-
* setExitPageTips - 设置退出页面提示
|
|
300
|
-
*
|
|
301
|
-
* @param params 提示参数
|
|
302
|
-
*/
|
|
303
|
-
setExitPageTips(params?: {
|
|
304
|
-
title?: string;
|
|
305
|
-
content?: string;
|
|
306
|
-
}): Promise<unknown>;
|
|
307
|
-
/**
|
|
308
|
-
* 通过应用打开某个文件
|
|
309
|
-
*/
|
|
310
|
-
openFile(path: string): Promise<unknown>;
|
|
311
|
-
/**
|
|
312
|
-
* 打开文件管理器
|
|
313
|
-
*/
|
|
314
|
-
openFileManager(path: string): Promise<unknown>;
|
|
315
|
-
showFileDetails(paths: string[], options?: FileDetailsOptions): Promise<unknown>;
|
|
316
|
-
authorizeUserFile(path: string): Promise<AppBridgeResponse_2<AuthorizeFileResult> | undefined>;
|
|
317
|
-
authorizeSharedFile(path: string): Promise<AppBridgeResponse_2<AuthorizeFileResult> | undefined>;
|
|
318
|
-
/**
|
|
319
|
-
* 打开当前应用在系统中的应用设置页
|
|
320
|
-
*/
|
|
321
|
-
openAppSetting(): Promise<unknown>;
|
|
322
|
-
/**
|
|
323
|
-
* 打开应用
|
|
324
|
-
*
|
|
325
|
-
* @param anchor 锚点
|
|
326
|
-
*/
|
|
327
|
-
openApp(anchor: string): Promise<unknown>;
|
|
328
|
-
/**
|
|
329
|
-
* 打开自定义应用
|
|
330
|
-
*
|
|
331
|
-
* @param appName 自定义应用标识
|
|
332
|
-
* @param options 自定义应用配置和打开参数
|
|
333
|
-
*/
|
|
334
|
-
openCustomApp(appName: string, options: OpenAppParams): Promise<void>;
|
|
335
|
-
/**
|
|
336
|
-
* 打开外部链接 App 端通过系统浏览器打开,Web 端沿用 window.open 行为
|
|
337
|
-
*/
|
|
338
|
-
openURL(url: string, target?: string, features?: string): Promise<unknown>;
|
|
339
|
-
/**
|
|
340
|
-
* 关闭应用
|
|
341
|
-
*/
|
|
342
|
-
close(): Promise<unknown>;
|
|
343
|
-
/**
|
|
344
|
-
* 请求接口
|
|
345
|
-
*/
|
|
346
|
-
query<T>(params: any, config?: QueryConfig): Promise<ResponseData<T>>;
|
|
347
|
-
refreshToken(): Promise<void>;
|
|
348
|
-
/**
|
|
349
|
-
* 监听事件(仅 Web 平台)
|
|
350
|
-
*/
|
|
351
|
-
$on(event: string, cb: (...args: any[]) => void): Promise<void>;
|
|
352
|
-
/**
|
|
353
|
-
* 取消监听事件(仅 Web 平台)
|
|
354
|
-
*/
|
|
355
|
-
$off(event: string, cb: (...args: any[]) => void): Promise<void>;
|
|
356
|
-
/**
|
|
357
|
-
* 监听一次事件(仅 Web 平台)
|
|
358
|
-
*/
|
|
359
|
-
$once(event: string, cb: (...args: any[]) => void): Promise<void>;
|
|
360
|
-
/**
|
|
361
|
-
* 选择文件
|
|
362
|
-
*/
|
|
363
|
-
pickFile(params: FilePickerParams): Promise<string[] | undefined>;
|
|
364
|
-
/**
|
|
365
|
-
* 选择共享文件并授权给当前应用
|
|
366
|
-
*/
|
|
367
|
-
pickSharedFile(params?: Omit<FilePickerParams, 'directory'>): Promise<AppBridgeResponse_2<string[]> | undefined>;
|
|
368
|
-
}
|
|
369
|
-
export { TrimApp }
|
|
370
|
-
export default TrimApp;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* SDK 配置选项
|
|
374
|
-
*/
|
|
375
|
-
export declare interface TrimAppOptions {
|
|
376
|
-
/**
|
|
377
|
-
* 是否开启 debug 模式,开启后会输出日志
|
|
378
|
-
*/
|
|
379
|
-
debug?: boolean;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
export { }
|
|
1
|
+
import { AuthorizeFileResult, FileDetailsOptions, HostSnapshot, PlatformConfig, TrimAppOptions } from './types';
|
|
2
|
+
import { AppAuthMethod, AppAuthParams, AppAuthResult } from './app-auth';
|
|
3
|
+
import { ObservableLike } from './mobile/index';
|
|
4
|
+
import { AppBridgeResponse, OpenAppParams, ResponseData, FilePickerParams, QueryConfig } from '@fn/micro-app-postmate';
|
|
5
|
+
export type { FilePickerParams, QueryConfig, ResponseData } from '@fn/micro-app-postmate';
|
|
6
|
+
/**
|
|
7
|
+
* nas 应用 SDK
|
|
8
|
+
*
|
|
9
|
+
* @trim/app - NAS 应用 SDK
|
|
10
|
+
*/
|
|
11
|
+
export type { PlatformConfig, TrimAppOptions } from './types';
|
|
12
|
+
export type { HostSnapshot } from './types';
|
|
13
|
+
export type { AppBridgeResponse, AuthorizeFileResult, FileDetailsOptions } from './types';
|
|
14
|
+
export type { AppAuthAuthorizeParams, AppAuthBaseParams, AppAuthCallbackError, AppAuthCallbackStatus, AppAuthMethod, AppAuthMethodParamsMap, AppAuthParams, AppAuthPickFileParams, AppAuthPickSharedFileParams, AppAuthResult, } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* Trim App 实例类
|
|
17
|
+
*/
|
|
18
|
+
export declare class TrimApp {
|
|
19
|
+
private options;
|
|
20
|
+
private flutterInAppWebView;
|
|
21
|
+
private osConnector;
|
|
22
|
+
private initPromise;
|
|
23
|
+
private appApiVersion?;
|
|
24
|
+
isWeb: boolean;
|
|
25
|
+
isStandaloneWeb: boolean;
|
|
26
|
+
constructor(options?: TrimAppOptions);
|
|
27
|
+
private init;
|
|
28
|
+
private getWebMethods;
|
|
29
|
+
private loadAppMessage;
|
|
30
|
+
private initMobileAppApi;
|
|
31
|
+
private assertMobileAppApi;
|
|
32
|
+
private isAtLeastVersion;
|
|
33
|
+
private parseVersion;
|
|
34
|
+
callAppMethod<T>(fn: string, ...params: Array<string | undefined>): Promise<T | null>;
|
|
35
|
+
/**
|
|
36
|
+
* 等待初始化完成
|
|
37
|
+
*
|
|
38
|
+
* @returns Promise
|
|
39
|
+
*/
|
|
40
|
+
ready(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* 获取配置
|
|
43
|
+
*/
|
|
44
|
+
getOptions(): TrimAppOptions;
|
|
45
|
+
/**
|
|
46
|
+
* 更新配置
|
|
47
|
+
*/
|
|
48
|
+
setOptions(options: Partial<TrimAppOptions>): void;
|
|
49
|
+
/**
|
|
50
|
+
* 获取平台配置
|
|
51
|
+
*/
|
|
52
|
+
getPlatformConfig(): Promise<PlatformConfig>;
|
|
53
|
+
getHostSnapshot(): Promise<HostSnapshot>;
|
|
54
|
+
getAppAuthBaseUrl(): Promise<string>;
|
|
55
|
+
buildAppAuthUrl<TMethod extends AppAuthMethod>(method: TMethod, params: AppAuthParams<NoInfer<TMethod>>): Promise<string>;
|
|
56
|
+
openAppAuth<TMethod extends AppAuthMethod>(method: TMethod, params: AppAuthParams<NoInfer<TMethod>>, options?: {
|
|
57
|
+
target?: string;
|
|
58
|
+
features?: string;
|
|
59
|
+
}): Promise<string>;
|
|
60
|
+
parseAppAuthCallback(input?: string | URL | URLSearchParams): AppAuthResult;
|
|
61
|
+
/**
|
|
62
|
+
* setTitle - 设置标题
|
|
63
|
+
*
|
|
64
|
+
* @param title 标题文本
|
|
65
|
+
*/
|
|
66
|
+
setTitle(title: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* setExitPageTips - 设置退出页面提示
|
|
69
|
+
*
|
|
70
|
+
* @param params 提示参数
|
|
71
|
+
*/
|
|
72
|
+
setExitPageTips(params?: {
|
|
73
|
+
title?: string;
|
|
74
|
+
content?: string;
|
|
75
|
+
}): Promise<unknown>;
|
|
76
|
+
/**
|
|
77
|
+
* 通过应用打开某个文件
|
|
78
|
+
*/
|
|
79
|
+
openFile(path: string): Promise<unknown>;
|
|
80
|
+
/**
|
|
81
|
+
* 打开文件管理器
|
|
82
|
+
*/
|
|
83
|
+
openFileManager(path: string): Promise<unknown>;
|
|
84
|
+
showFileDetails(paths: string[], options?: FileDetailsOptions): Promise<unknown>;
|
|
85
|
+
authorizeUserFile(path: string): Promise<AppBridgeResponse<AuthorizeFileResult> | undefined>;
|
|
86
|
+
authorizeSharedFile(path: string): Promise<AppBridgeResponse<AuthorizeFileResult> | undefined>;
|
|
87
|
+
/**
|
|
88
|
+
* 打开当前应用在系统中的应用设置页
|
|
89
|
+
*/
|
|
90
|
+
openAppSetting(): Promise<unknown>;
|
|
91
|
+
/**
|
|
92
|
+
* 打开应用
|
|
93
|
+
*
|
|
94
|
+
* @param anchor 锚点
|
|
95
|
+
*/
|
|
96
|
+
openApp(anchor: string): Promise<unknown>;
|
|
97
|
+
/**
|
|
98
|
+
* 打开自定义应用
|
|
99
|
+
*
|
|
100
|
+
* @param appName 自定义应用标识
|
|
101
|
+
* @param options 自定义应用配置和打开参数
|
|
102
|
+
*/
|
|
103
|
+
openCustomApp(appName: string, options: OpenAppParams): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* 打开外部链接 App 端通过系统浏览器打开,Web 端沿用 window.open 行为
|
|
106
|
+
*/
|
|
107
|
+
openURL(url: string, target?: string, features?: string): Promise<unknown>;
|
|
108
|
+
/**
|
|
109
|
+
* 关闭应用
|
|
110
|
+
*/
|
|
111
|
+
close(): Promise<unknown>;
|
|
112
|
+
/**
|
|
113
|
+
* 请求接口
|
|
114
|
+
*/
|
|
115
|
+
query<T>(params: any, config: QueryConfig & {
|
|
116
|
+
observable: true;
|
|
117
|
+
}): Promise<ObservableLike<ResponseData<T>>>;
|
|
118
|
+
query<T>(params: any, config?: QueryConfig): Promise<ResponseData<T>>;
|
|
119
|
+
refreshToken(): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* 监听事件(仅 Web 平台)
|
|
122
|
+
*/
|
|
123
|
+
$on(event: string, cb: (...args: any[]) => void): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* 取消监听事件(仅 Web 平台)
|
|
126
|
+
*/
|
|
127
|
+
$off(event: string, cb: (...args: any[]) => void): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* 监听一次事件(仅 Web 平台)
|
|
130
|
+
*/
|
|
131
|
+
$once(event: string, cb: (...args: any[]) => void): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* 选择文件
|
|
134
|
+
*/
|
|
135
|
+
pickFile(params: FilePickerParams): Promise<string[] | undefined>;
|
|
136
|
+
/**
|
|
137
|
+
* 选择共享文件并授权给当前应用
|
|
138
|
+
*/
|
|
139
|
+
pickSharedFile(params?: Omit<FilePickerParams, 'directory'>): Promise<AppBridgeResponse<string[]> | undefined>;
|
|
140
|
+
}
|
|
141
|
+
export default TrimApp;
|