@trimjs/web-app 0.1.1 → 0.1.2
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/index.d.ts +72 -0
- package/dist/logger.d.ts +38 -0
- package/dist/mobile/index.d.ts +23 -0
- package/dist/mobile/types.d.ts +9 -0
- package/dist/types.d.ts +17 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/web/index.d.ts +14 -0
- package/package.json +4 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { PlatformConfig, TrimAppOptions } from "./types";
|
|
2
|
+
import { type ResponseData } from "@fn/micro-app-postmate/src/child/os-type";
|
|
3
|
+
import { type FilePickerParams, type QueryConfig } from "@fn/micro-app-postmate/src/child/type";
|
|
4
|
+
/**
|
|
5
|
+
* @trim/app - NAS 应用 SDK
|
|
6
|
+
* @description nas 应用 SDK
|
|
7
|
+
*/
|
|
8
|
+
export type { TrimAppOptions } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Trim App 实例类
|
|
11
|
+
*/
|
|
12
|
+
export declare class TrimApp {
|
|
13
|
+
private options;
|
|
14
|
+
private flutterInAppWebView;
|
|
15
|
+
private osConnector;
|
|
16
|
+
private initPromise;
|
|
17
|
+
isWeb: boolean;
|
|
18
|
+
constructor(options?: TrimAppOptions);
|
|
19
|
+
private init;
|
|
20
|
+
callAppMethod<T>(fn: string, params?: string): Promise<T | null>;
|
|
21
|
+
/**
|
|
22
|
+
* 等待初始化完成
|
|
23
|
+
* @returns Promise
|
|
24
|
+
*/
|
|
25
|
+
ready(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 获取配置
|
|
28
|
+
*/
|
|
29
|
+
getOptions(): TrimAppOptions;
|
|
30
|
+
/**
|
|
31
|
+
* 更新配置
|
|
32
|
+
*/
|
|
33
|
+
setOptions(options: Partial<TrimAppOptions>): void;
|
|
34
|
+
/**
|
|
35
|
+
* 获取平台配置
|
|
36
|
+
*/
|
|
37
|
+
getPlatformConfig(): Promise<PlatformConfig>;
|
|
38
|
+
/**
|
|
39
|
+
* setTitle - 设置标题
|
|
40
|
+
* @param title 标题文本
|
|
41
|
+
*/
|
|
42
|
+
setTitle(title: string): Promise<unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* setExitPageTips - 设置退出页面提示
|
|
45
|
+
* @param params 提示参数
|
|
46
|
+
*/
|
|
47
|
+
setExitPageTips(params?: {
|
|
48
|
+
title?: string;
|
|
49
|
+
content?: string;
|
|
50
|
+
}): Promise<unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* 通过应用打开某个文件
|
|
53
|
+
*/
|
|
54
|
+
openFile(path: string): Promise<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* 打开文件管理器
|
|
57
|
+
*/
|
|
58
|
+
openFileManager(path: string): Promise<unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* 关闭应用
|
|
61
|
+
*/
|
|
62
|
+
close(): Promise<unknown>;
|
|
63
|
+
/**
|
|
64
|
+
* 请求接口
|
|
65
|
+
*/
|
|
66
|
+
query<T>(params: any, config?: QueryConfig): Promise<ResponseData<T>>;
|
|
67
|
+
/**
|
|
68
|
+
* 选择文件
|
|
69
|
+
*/
|
|
70
|
+
pickFile(params: FilePickerParams): Promise<unknown>;
|
|
71
|
+
}
|
|
72
|
+
export default TrimApp;
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger 工具类
|
|
3
|
+
* 只有在 debug 模式下才会输出日志
|
|
4
|
+
*/
|
|
5
|
+
declare class Logger {
|
|
6
|
+
private debug;
|
|
7
|
+
/**
|
|
8
|
+
* 设置 debug 模式
|
|
9
|
+
* @param enabled 是否启用 debug
|
|
10
|
+
*/
|
|
11
|
+
setDebug(enabled: boolean): void;
|
|
12
|
+
/**
|
|
13
|
+
* 获取当前 debug 状态
|
|
14
|
+
*/
|
|
15
|
+
isDebug(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 输出日志(只在 debug 模式下)
|
|
18
|
+
* @param args 日志参数
|
|
19
|
+
*/
|
|
20
|
+
log(...args: any[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* 输出警告日志(只在 debug 模式下)
|
|
23
|
+
* @param args 日志参数
|
|
24
|
+
*/
|
|
25
|
+
warn(...args: any[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* 输出错误日志(只在 debug 模式下)
|
|
28
|
+
* @param args 日志参数
|
|
29
|
+
*/
|
|
30
|
+
error(...args: any[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* 输出信息日志(只在 debug 模式下)
|
|
33
|
+
* @param args 日志参数
|
|
34
|
+
*/
|
|
35
|
+
info(...args: any[]): void;
|
|
36
|
+
}
|
|
37
|
+
export declare const logger: Logger;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface FlutterInAppWebView {
|
|
2
|
+
callHandler: (fn: string, params?: string) => Promise<string>;
|
|
3
|
+
_platformReady?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
flutter_inappwebview: FlutterInAppWebView;
|
|
8
|
+
fnAppMessage?: (message: string) => void;
|
|
9
|
+
onAppHeaderGoBack?: () => boolean | number | string;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const initMobile: () => Promise<FlutterInAppWebView>;
|
|
13
|
+
export interface FnAppMessage<T> {
|
|
14
|
+
reqId: string;
|
|
15
|
+
method: string;
|
|
16
|
+
result: T;
|
|
17
|
+
}
|
|
18
|
+
export declare const callHandler: <T>(flutterInAppWebView: FlutterInAppWebView, fn: string, params?: string) => Promise<T | null>;
|
|
19
|
+
export declare function pickFilePromise(flutterInAppWebView: FlutterInAppWebView, params: {
|
|
20
|
+
title: string;
|
|
21
|
+
multiple: boolean;
|
|
22
|
+
directory: boolean;
|
|
23
|
+
}): Promise<string[] | undefined>;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK 配置选项
|
|
3
|
+
*/
|
|
4
|
+
export interface TrimAppOptions {
|
|
5
|
+
/** 是否开启 debug 模式,开启后会输出日志 */
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PlatformConfig {
|
|
9
|
+
theme: "dark" | "light";
|
|
10
|
+
language: string;
|
|
11
|
+
appVersion?: string;
|
|
12
|
+
systemVersion: string;
|
|
13
|
+
format: {
|
|
14
|
+
date?: string;
|
|
15
|
+
time?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OSConfig } from "@fn/micro-app-postmate/src/parent/type";
|
|
2
|
+
import { type OSMethods, type ConnectionResult, type AsyncMethodReturns } from "@fn/micro-app-postmate/src/types";
|
|
3
|
+
import type { PlatformConfig, TrimAppOptions } from "../types";
|
|
4
|
+
export type OSConnection = AsyncMethodReturns<ConnectionResult<OSMethods & {
|
|
5
|
+
setExitPageTips: (params?: {
|
|
6
|
+
title?: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
}) => void;
|
|
9
|
+
openFileManagerApp: (path: string) => void;
|
|
10
|
+
openFile: (path: string) => void;
|
|
11
|
+
getPlatformConfig: () => Promise<PlatformConfig>;
|
|
12
|
+
close: () => void;
|
|
13
|
+
}, OSConfig>>;
|
|
14
|
+
export declare const initWeb: (options?: TrimAppOptions) => Promise<AsyncMethodReturns<ConnectionResult<OSMethods>>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trimjs/web-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "web app sdk for nas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "vite",
|
|
11
|
-
"build": "tsc -b
|
|
11
|
+
"build": "vite build & tsc -b",
|
|
12
12
|
"lint": "eslint .",
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"access": "public"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@fn/micro-app-postmate": "workspace:*",
|
|
24
|
-
"@fn/micro-app-event": "workspace:*",
|
|
25
23
|
"@eslint/js": "^9.13.0",
|
|
24
|
+
"@fn/micro-app-event": "workspace:*",
|
|
25
|
+
"@fn/micro-app-postmate": "workspace:*",
|
|
26
26
|
"eslint": "^9.13.0",
|
|
27
27
|
"globals": "^15.11.0",
|
|
28
28
|
"typescript": "~5.6.2",
|