@nebula-rn/client 0.0.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 (98) hide show
  1. package/dist/chooseMedia/index.d.ts +22 -0
  2. package/dist/chooseMedia/index.js +4 -0
  3. package/dist/compressImage/index.d.ts +7 -0
  4. package/dist/compressImage/index.js +4 -0
  5. package/dist/descriptions.d.ts +9 -0
  6. package/dist/descriptions.js +259 -0
  7. package/dist/file.d.ts +51 -0
  8. package/dist/file.js +14 -0
  9. package/dist/getAppBaseInfo/index.d.ts +6 -0
  10. package/dist/getAppBaseInfo/index.js +4 -0
  11. package/dist/getClipboardData/index.d.ts +1 -0
  12. package/dist/getClipboardData/index.js +4 -0
  13. package/dist/getFileInfo/index.d.ts +9 -0
  14. package/dist/getFileInfo/index.js +4 -0
  15. package/dist/getFileSystemManager/index.d.ts +70 -0
  16. package/dist/getFileSystemManager/index.js +43 -0
  17. package/dist/getImageInfo/index.d.ts +16 -0
  18. package/dist/getImageInfo/index.js +20 -0
  19. package/dist/getLocation/index.d.ts +15 -0
  20. package/dist/getLocation/index.js +4 -0
  21. package/dist/getScreenBrightness/index.d.ts +1 -0
  22. package/dist/getScreenBrightness/index.js +4 -0
  23. package/dist/getStorage/index.d.ts +1 -0
  24. package/dist/getStorage/index.js +8 -0
  25. package/dist/getStorageInfo/index.d.ts +6 -0
  26. package/dist/getStorageInfo/index.js +12 -0
  27. package/dist/getSystemInfo/index.d.ts +1 -0
  28. package/dist/getSystemInfo/index.js +4 -0
  29. package/dist/index.d.ts +26 -0
  30. package/dist/index.js +26 -0
  31. package/dist/location.d.ts +10 -0
  32. package/dist/location.js +18 -0
  33. package/dist/makePhoneCall/index.d.ts +1 -0
  34. package/dist/makePhoneCall/index.js +4 -0
  35. package/dist/media.d.ts +5 -0
  36. package/dist/media.js +8 -0
  37. package/dist/miniAppUpdate/index.d.ts +3 -0
  38. package/dist/miniAppUpdate/index.js +7 -0
  39. package/dist/network.d.ts +9 -0
  40. package/dist/network.js +15 -0
  41. package/dist/onUserCaptureScreen/index.d.ts +1 -0
  42. package/dist/onUserCaptureScreen/index.js +11 -0
  43. package/dist/previewImage/index.d.ts +8 -0
  44. package/dist/previewImage/index.js +4 -0
  45. package/dist/runtime/host.d.ts +41 -0
  46. package/dist/runtime/host.js +152 -0
  47. package/dist/scanCode/contract.d.ts +7 -0
  48. package/dist/scanCode/contract.js +8 -0
  49. package/dist/scanCode/icon_close.png +0 -0
  50. package/dist/scanCode/icon_pic.png +0 -0
  51. package/dist/scanCode/index.d.ts +6 -0
  52. package/dist/scanCode/index.js +72 -0
  53. package/dist/scanCode/types.d.ts +25 -0
  54. package/dist/scanCode/types.js +8 -0
  55. package/dist/sensors.d.ts +13 -0
  56. package/dist/sensors.js +15 -0
  57. package/dist/setClipboardData/index.d.ts +1 -0
  58. package/dist/setClipboardData/index.js +2 -0
  59. package/dist/setStorage/index.d.ts +5 -0
  60. package/dist/setStorage/index.js +5 -0
  61. package/dist/storage.d.ts +9 -0
  62. package/dist/storage.js +36 -0
  63. package/dist/uploadFile/index.d.ts +30 -0
  64. package/dist/uploadFile/index.js +6 -0
  65. package/package.json +77 -0
  66. package/src/chooseMedia/index.ts +36 -0
  67. package/src/compressImage/index.ts +14 -0
  68. package/src/descriptions.ts +294 -0
  69. package/src/file.ts +89 -0
  70. package/src/getAppBaseInfo/index.ts +10 -0
  71. package/src/getClipboardData/index.ts +5 -0
  72. package/src/getFileInfo/index.ts +17 -0
  73. package/src/getFileSystemManager/index.ts +141 -0
  74. package/src/getImageInfo/index.ts +40 -0
  75. package/src/getLocation/index.ts +23 -0
  76. package/src/getScreenBrightness/index.ts +5 -0
  77. package/src/getStorage/index.ts +10 -0
  78. package/src/getStorageInfo/index.ts +20 -0
  79. package/src/getSystemInfo/index.ts +5 -0
  80. package/src/index.ts +26 -0
  81. package/src/location.ts +40 -0
  82. package/src/makePhoneCall/index.ts +5 -0
  83. package/src/media.ts +19 -0
  84. package/src/miniAppUpdate/index.ts +20 -0
  85. package/src/network.ts +36 -0
  86. package/src/onUserCaptureScreen/index.ts +17 -0
  87. package/src/previewImage/index.tsx +13 -0
  88. package/src/runtime/host.ts +356 -0
  89. package/src/scanCode/contract.ts +20 -0
  90. package/src/scanCode/icon_close.png +0 -0
  91. package/src/scanCode/icon_pic.png +0 -0
  92. package/src/scanCode/index.tsx +127 -0
  93. package/src/scanCode/types.ts +38 -0
  94. package/src/sensors.ts +48 -0
  95. package/src/setClipboardData/index.ts +4 -0
  96. package/src/setStorage/index.ts +11 -0
  97. package/src/storage.ts +51 -0
  98. package/src/uploadFile/index.ts +57 -0
@@ -0,0 +1,22 @@
1
+ export interface ChooseMediaFile {
2
+ tempFilePath: string;
3
+ size: number;
4
+ duration?: number;
5
+ height?: number;
6
+ width?: number;
7
+ thumbTempFilePath?: string;
8
+ fileType: 'image' | 'video';
9
+ }
10
+ export interface ChooseMediaResult {
11
+ tempFiles: ChooseMediaFile[];
12
+ type: 'image' | 'video' | 'mix';
13
+ }
14
+ export interface ChooseMediaOption {
15
+ count?: number;
16
+ mediaType?: ('image' | 'video' | 'mix')[];
17
+ sourceType?: ('album' | 'camera')[];
18
+ maxDuration?: number;
19
+ sizeType?: ('original' | 'compressed')[];
20
+ camera?: 'back' | 'front';
21
+ }
22
+ export declare const chooseMedia: (options?: ChooseMediaOption) => Promise<ChooseMediaResult>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export const chooseMedia = (options = {}) => {
3
+ return invokeHostApi('chooseMedia', options, '1.0', 120000);
4
+ };
@@ -0,0 +1,7 @@
1
+ export interface CompressImageOption {
2
+ src: string;
3
+ quality?: number;
4
+ compressedWidth?: number;
5
+ compressedHeight?: number;
6
+ }
7
+ export declare const compressImage: (options: CompressImageOption) => Promise<string>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export const compressImage = (options) => {
3
+ return invokeHostApi('compressImage', options);
4
+ };
@@ -0,0 +1,9 @@
1
+ import type { NebulaHostApiDescription, NebulaHostApiDescriptionMap } from '@nebula-rn/sdk';
2
+ export type NebulaPublicApiDescription = NebulaHostApiDescription & {
3
+ kind?: 'api' | 'manager' | 'subscription' | 'task' | 'utility';
4
+ methods?: Record<string, NebulaHostApiDescription>;
5
+ };
6
+ export type NebulaPublicApiDescriptionMap = Record<string, NebulaPublicApiDescription>;
7
+ export declare const nebulaApiDescriptions: NebulaPublicApiDescriptionMap;
8
+ export declare function getNebulaApiDescriptions(): NebulaPublicApiDescriptionMap;
9
+ export declare function getHostApiDescriptions(timeoutMs?: number): Promise<NebulaHostApiDescriptionMap>;
@@ -0,0 +1,259 @@
1
+ import { Miniapp } from '@nebula-rn/sdk';
2
+ export const nebulaApiDescriptions = {
3
+ chooseMedia: {
4
+ summary: 'Open the host media picker and return selected image or video assets.',
5
+ kind: 'api',
6
+ tags: ['media', 'picker'],
7
+ },
8
+ compressImage: {
9
+ summary: 'Resize and compress an image through the host runtime.',
10
+ kind: 'api',
11
+ tags: ['media', 'image'],
12
+ },
13
+ downloadFile: {
14
+ summary: 'Start a host-managed download task with progress and abort support.',
15
+ kind: 'task',
16
+ tags: ['file', 'network'],
17
+ },
18
+ uploadFile: {
19
+ summary: 'Start a host-managed upload task with progress and abort support.',
20
+ kind: 'task',
21
+ tags: ['file', 'network'],
22
+ },
23
+ getAppBaseInfo: {
24
+ summary: 'Return basic host app information for the current miniapp runtime.',
25
+ kind: 'api',
26
+ tags: ['device', 'app'],
27
+ },
28
+ getClipboardData: {
29
+ summary: 'Read plain text from the system clipboard.',
30
+ kind: 'api',
31
+ tags: ['clipboard'],
32
+ },
33
+ getFileInfo: {
34
+ summary: 'Read size and digest information for a file path.',
35
+ kind: 'api',
36
+ tags: ['file'],
37
+ },
38
+ getFileSystemManager: {
39
+ summary: 'Return a file system manager bound to host-backed file APIs.',
40
+ kind: 'manager',
41
+ tags: ['file'],
42
+ methods: {
43
+ access: {
44
+ summary: 'Check whether a path exists and is accessible.',
45
+ tags: ['file'],
46
+ },
47
+ appendFile: {
48
+ summary: 'Append text data to a file path.',
49
+ tags: ['file'],
50
+ },
51
+ saveFile: {
52
+ summary: 'Persist a temp file into the miniapp sandbox.',
53
+ tags: ['file'],
54
+ },
55
+ copyFile: {
56
+ summary: 'Copy a file from one path to another.',
57
+ tags: ['file'],
58
+ },
59
+ mkdir: {
60
+ summary: 'Create a directory path recursively.',
61
+ tags: ['file'],
62
+ },
63
+ readFile: {
64
+ summary: 'Read a file as text with optional encoding.',
65
+ tags: ['file'],
66
+ },
67
+ readdir: {
68
+ summary: 'List child entries in a directory.',
69
+ tags: ['file'],
70
+ },
71
+ rename: {
72
+ summary: 'Rename or move a file or directory.',
73
+ tags: ['file'],
74
+ },
75
+ rmdir: {
76
+ summary: 'Remove a directory path recursively.',
77
+ tags: ['file'],
78
+ },
79
+ unlink: {
80
+ summary: 'Delete a file path.',
81
+ tags: ['file'],
82
+ },
83
+ writeFile: {
84
+ summary: 'Write text data to a file path.',
85
+ tags: ['file'],
86
+ },
87
+ getFileInfo: {
88
+ summary: 'Read file stat information for a sandbox path.',
89
+ tags: ['file'],
90
+ },
91
+ },
92
+ },
93
+ getImageInfo: {
94
+ summary: 'Read width, height, and metadata information for an image source.',
95
+ kind: 'api',
96
+ tags: ['media', 'image'],
97
+ },
98
+ getLocation: {
99
+ summary: 'Get the current device location once.',
100
+ description: 'The host may request runtime location permission before resolving.',
101
+ kind: 'api',
102
+ tags: ['location'],
103
+ },
104
+ getScreenBrightness: {
105
+ summary: 'Read the current screen brightness reported by the device.',
106
+ kind: 'api',
107
+ tags: ['device'],
108
+ },
109
+ getStorage: {
110
+ summary: 'Read a JSON-serializable value from host-backed key-value storage.',
111
+ kind: 'api',
112
+ tags: ['storage'],
113
+ },
114
+ getStorageInfo: {
115
+ summary: 'Read host-backed storage usage and key information.',
116
+ kind: 'api',
117
+ tags: ['storage'],
118
+ },
119
+ getSystemInfo: {
120
+ summary: 'Return device, screen, and safe-area information for layout and diagnostics.',
121
+ kind: 'api',
122
+ tags: ['device', 'layout'],
123
+ },
124
+ onLocationChange: {
125
+ summary: 'Subscribe to host location change events.',
126
+ kind: 'subscription',
127
+ tags: ['location', 'subscription'],
128
+ },
129
+ makePhoneCall: {
130
+ summary: 'Open the system dialer for a phone number.',
131
+ kind: 'api',
132
+ tags: ['device', 'communication'],
133
+ },
134
+ getMiniAppUpdateInfo: {
135
+ summary: 'Read the installed miniapp version, update strategy, and whether a newer remote version exists.',
136
+ kind: 'api',
137
+ tags: ['miniapp', 'update'],
138
+ },
139
+ applyMiniAppUpdate: {
140
+ summary: 'Install the newest available bundle for the current miniapp and return the updated version state.',
141
+ kind: 'api',
142
+ tags: ['miniapp', 'update'],
143
+ },
144
+ saveMedia: {
145
+ summary: 'Save a photo or video into the system media library.',
146
+ kind: 'api',
147
+ tags: ['media'],
148
+ },
149
+ getNetworkType: {
150
+ summary: 'Read the current network connection type and connectivity state.',
151
+ kind: 'api',
152
+ tags: ['network'],
153
+ },
154
+ onNetworkStatusChange: {
155
+ summary: 'Subscribe to host network status change events.',
156
+ kind: 'subscription',
157
+ tags: ['network', 'subscription'],
158
+ },
159
+ onUserCaptureScreen: {
160
+ summary: 'Subscribe to host screenshot capture events.',
161
+ kind: 'subscription',
162
+ tags: ['device', 'subscription'],
163
+ },
164
+ previewImage: {
165
+ summary: 'Open a host-managed fullscreen image preview modal for one or more image URLs.',
166
+ kind: 'api',
167
+ tags: ['media', 'image', 'modal'],
168
+ },
169
+ scanCode: {
170
+ summary: 'Open a host-managed scanner modal and return the first detected barcode or QR code.',
171
+ kind: 'api',
172
+ tags: ['camera', 'scanner', 'modal'],
173
+ },
174
+ scanCodeSafe: {
175
+ summary: 'Open the host scanner modal and always resolve with an ok/error result object.',
176
+ kind: 'api',
177
+ tags: ['camera', 'scanner', 'modal'],
178
+ },
179
+ onAccelerometerChange: {
180
+ summary: 'Subscribe to host accelerometer events.',
181
+ kind: 'subscription',
182
+ tags: ['sensor', 'subscription'],
183
+ },
184
+ onGyroscopeChange: {
185
+ summary: 'Subscribe to host gyroscope events.',
186
+ kind: 'subscription',
187
+ tags: ['sensor', 'subscription'],
188
+ },
189
+ onMagnetometerChange: {
190
+ summary: 'Subscribe to host magnetometer events.',
191
+ kind: 'subscription',
192
+ tags: ['sensor', 'subscription'],
193
+ },
194
+ onBarometerChange: {
195
+ summary: 'Subscribe to host barometer events.',
196
+ kind: 'subscription',
197
+ tags: ['sensor', 'subscription'],
198
+ },
199
+ setClipboardData: {
200
+ summary: 'Write plain text to the system clipboard.',
201
+ kind: 'api',
202
+ tags: ['clipboard'],
203
+ },
204
+ setStorage: {
205
+ summary: 'Persist a JSON-serializable value in host-backed key-value storage.',
206
+ kind: 'api',
207
+ tags: ['storage'],
208
+ },
209
+ storage: {
210
+ summary: 'Low-level storage helpers for host-backed key-value access and serialization.',
211
+ kind: 'utility',
212
+ tags: ['storage'],
213
+ methods: {
214
+ serializeStorageValue: {
215
+ summary: 'Serialize a JSON-serializable value before writing to storage.',
216
+ tags: ['storage'],
217
+ },
218
+ deserializeStorageValue: {
219
+ summary: 'Deserialize a stored JSON string into a typed value.',
220
+ tags: ['storage'],
221
+ },
222
+ setStorageItem: {
223
+ summary: 'Persist a raw storage item by key.',
224
+ tags: ['storage'],
225
+ },
226
+ getStorageItem: {
227
+ summary: 'Read a raw storage item by key.',
228
+ tags: ['storage'],
229
+ },
230
+ removeStorageItem: {
231
+ summary: 'Remove a raw storage item by key.',
232
+ tags: ['storage'],
233
+ },
234
+ clearStorageItems: {
235
+ summary: 'Clear all host-backed storage entries.',
236
+ tags: ['storage'],
237
+ },
238
+ getStorageKeys: {
239
+ summary: 'List all keys in host-backed storage.',
240
+ tags: ['storage'],
241
+ },
242
+ getStorageCurrentSize: {
243
+ summary: 'Return the approximate storage size in KB.',
244
+ tags: ['storage'],
245
+ },
246
+ },
247
+ },
248
+ removeFile: {
249
+ summary: 'Remove a file from the miniapp sandbox.',
250
+ kind: 'api',
251
+ tags: ['file'],
252
+ },
253
+ };
254
+ export function getNebulaApiDescriptions() {
255
+ return nebulaApiDescriptions;
256
+ }
257
+ export function getHostApiDescriptions(timeoutMs = 15000) {
258
+ return Miniapp.getHostApiDescriptions(timeoutMs);
259
+ }
package/dist/file.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ export interface HeadersRes {
2
+ header: Record<string, string>;
3
+ }
4
+ export interface Task<T, P> {
5
+ abort(): Promise<void>;
6
+ onProgressUpdate(listener: (res: P) => void): void;
7
+ offProgressUpdate(listener: (res: P) => void): void;
8
+ onHeadersReceived(listener: (res: HeadersRes) => void): void;
9
+ offHeadersReceived(listener: (res: HeadersRes) => void): void;
10
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
11
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
12
+ }
13
+ export interface DownloadProgressRes {
14
+ progress: number;
15
+ totalBytesWritten: number;
16
+ totalBytesExpectedToWrite: number;
17
+ }
18
+ export interface DownloadFileResult {
19
+ tempFilePath: string;
20
+ statusCode: number;
21
+ }
22
+ export interface DownloadFileOption {
23
+ url: string;
24
+ header?: Record<string, string>;
25
+ timeout?: number;
26
+ filePath?: string;
27
+ }
28
+ export type DownloadTask = Task<DownloadFileResult, DownloadProgressRes>;
29
+ export declare const downloadFile: (options: DownloadFileOption) => DownloadTask;
30
+ export interface UploadProgressRes {
31
+ progress: number;
32
+ totalBytesSent: number;
33
+ totalBytesExpectedToSend: number;
34
+ }
35
+ export interface UploadFileResult {
36
+ data: string;
37
+ statusCode: number;
38
+ }
39
+ export interface UploadFileOption {
40
+ url: string;
41
+ filePath: string;
42
+ name: string;
43
+ header?: Record<string, string>;
44
+ formData?: Record<string, string>;
45
+ }
46
+ export type UploadTask = Task<UploadFileResult, UploadProgressRes>;
47
+ export declare const uploadFile: (options: UploadFileOption) => UploadTask;
48
+ export interface RemoveFileOption {
49
+ filePath: string;
50
+ }
51
+ export declare const removeFile: (options: RemoveFileOption) => Promise<void>;
package/dist/file.js ADDED
@@ -0,0 +1,14 @@
1
+ import { createHostTask, invokeHostApi } from './runtime/host';
2
+ export const downloadFile = (options) => {
3
+ return createHostTask('downloadFile', options, {
4
+ timeoutMs: 60000,
5
+ });
6
+ };
7
+ export const uploadFile = (options) => {
8
+ return createHostTask('uploadFile', options, {
9
+ timeoutMs: 60000,
10
+ });
11
+ };
12
+ export const removeFile = (options) => {
13
+ return invokeHostApi('removeFile', options);
14
+ };
@@ -0,0 +1,6 @@
1
+ export declare function getAppBaseInfo(): Promise<{
2
+ version: string;
3
+ language: string;
4
+ enableDebug: boolean;
5
+ theme: string;
6
+ }>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export function getAppBaseInfo() {
3
+ return invokeHostApi('getAppBaseInfo');
4
+ }
@@ -0,0 +1 @@
1
+ export declare function getClipboardData(): Promise<string>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export function getClipboardData() {
3
+ return invokeHostApi('getClipboardData');
4
+ }
@@ -0,0 +1,9 @@
1
+ export interface GetFileInfoOption {
2
+ filePath: string;
3
+ digestAlgorithm?: 'md5' | 'sha1' | 'sha256';
4
+ }
5
+ export interface GetFileInfoResult {
6
+ size: number;
7
+ digest: string;
8
+ }
9
+ export declare const getFileInfo: (options: GetFileInfoOption) => Promise<GetFileInfoResult>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export const getFileInfo = (options) => {
3
+ return invokeHostApi('getFileInfo', options);
4
+ };
@@ -0,0 +1,70 @@
1
+ import { GetFileInfoOption, GetFileInfoResult } from '../getFileInfo';
2
+ export interface FileAccessOption {
3
+ path: string;
4
+ }
5
+ export interface FileAppendOption {
6
+ filePath: string;
7
+ data: string;
8
+ encoding?: 'ascii' | 'base64' | 'utf8';
9
+ }
10
+ export interface FileSaveOption {
11
+ tempFilePath: string;
12
+ filePath?: string;
13
+ }
14
+ export interface FileSaveResult {
15
+ savedFilePath: string;
16
+ }
17
+ export interface FileCopyOption {
18
+ srcPath: string;
19
+ destPath: string;
20
+ }
21
+ export interface FileMkdirOption {
22
+ dirPath: string;
23
+ recursive?: boolean;
24
+ }
25
+ export interface FileReadOption {
26
+ filePath: string;
27
+ encoding?: 'ascii' | 'base64' | 'utf8';
28
+ position?: number;
29
+ length?: number;
30
+ }
31
+ export interface FileReadResult {
32
+ data: string;
33
+ }
34
+ export interface FileReaddirOption {
35
+ dirPath: string;
36
+ }
37
+ export interface FileReaddirResult {
38
+ files: string[];
39
+ }
40
+ export interface FileRenameOption {
41
+ oldPath: string;
42
+ newPath: string;
43
+ }
44
+ export interface FileRmdirOption {
45
+ dirPath: string;
46
+ recursive?: boolean;
47
+ }
48
+ export interface FileUnlinkOption {
49
+ filePath: string;
50
+ }
51
+ export interface FileWriteOption {
52
+ filePath: string;
53
+ data: string;
54
+ encoding?: 'ascii' | 'base64' | 'utf8';
55
+ }
56
+ export interface FileSystemManager {
57
+ access(options: FileAccessOption): Promise<void>;
58
+ appendFile(options: FileAppendOption): Promise<void>;
59
+ saveFile(options: FileSaveOption): Promise<FileSaveResult>;
60
+ copyFile(options: FileCopyOption): Promise<void>;
61
+ mkdir(options: FileMkdirOption): Promise<void>;
62
+ readFile(options: FileReadOption): Promise<FileReadResult>;
63
+ readdir(options: FileReaddirOption): Promise<FileReaddirResult>;
64
+ rename(options: FileRenameOption): Promise<void>;
65
+ rmdir(options: FileRmdirOption): Promise<void>;
66
+ unlink(options: FileUnlinkOption): Promise<void>;
67
+ writeFile(options: FileWriteOption): Promise<void>;
68
+ getFileInfo(options: GetFileInfoOption): Promise<GetFileInfoResult>;
69
+ }
70
+ export declare const getFileSystemManager: () => FileSystemManager;
@@ -0,0 +1,43 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ class FileSystemManagerImpl {
3
+ access(options) {
4
+ return invokeHostApi('fileSystem.access', options);
5
+ }
6
+ appendFile(options) {
7
+ return invokeHostApi('fileSystem.appendFile', options);
8
+ }
9
+ saveFile(options) {
10
+ return invokeHostApi('fileSystem.saveFile', options);
11
+ }
12
+ copyFile(options) {
13
+ return invokeHostApi('fileSystem.copyFile', options);
14
+ }
15
+ mkdir(options) {
16
+ return invokeHostApi('fileSystem.mkdir', options);
17
+ }
18
+ readFile(options) {
19
+ return invokeHostApi('fileSystem.readFile', options);
20
+ }
21
+ readdir(options) {
22
+ return invokeHostApi('fileSystem.readdir', options);
23
+ }
24
+ rename(options) {
25
+ return invokeHostApi('fileSystem.rename', options);
26
+ }
27
+ rmdir(options) {
28
+ return invokeHostApi('fileSystem.rmdir', options);
29
+ }
30
+ unlink(options) {
31
+ return invokeHostApi('fileSystem.unlink', options);
32
+ }
33
+ writeFile(options) {
34
+ return invokeHostApi('fileSystem.writeFile', options);
35
+ }
36
+ getFileInfo(options) {
37
+ return invokeHostApi('fileSystem.getFileInfo', options);
38
+ }
39
+ }
40
+ const fileSystemManager = new FileSystemManagerImpl();
41
+ export const getFileSystemManager = () => {
42
+ return fileSystemManager;
43
+ };
@@ -0,0 +1,16 @@
1
+ type GetImageInfoOption = {
2
+ src: string;
3
+ success?: (res: Record<string, unknown>) => void;
4
+ fail?: (res: Record<string, unknown>) => void;
5
+ complete?: (res: Record<string, unknown>) => void;
6
+ };
7
+ type GetImageInfoSuccessResult = {
8
+ width: number;
9
+ height: number;
10
+ path: string;
11
+ orientation: string;
12
+ type: string;
13
+ errMsg: string;
14
+ };
15
+ export declare function getImageInfo(option: GetImageInfoOption): Promise<GetImageInfoSuccessResult>;
16
+ export {};
@@ -0,0 +1,20 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export function getImageInfo(option) {
3
+ const { src, success, fail, complete } = option;
4
+ return invokeHostApi('getImageInfo', {
5
+ src,
6
+ })
7
+ .then(res => {
8
+ success?.(res);
9
+ complete?.(res);
10
+ return res;
11
+ })
12
+ .catch(error => {
13
+ const res = {
14
+ errMsg: error instanceof Error ? error.message : 'getImageInfo:fail',
15
+ };
16
+ fail?.(res);
17
+ complete?.(res);
18
+ throw res;
19
+ });
20
+ }
@@ -0,0 +1,15 @@
1
+ export interface GetLocationOption {
2
+ altitude?: boolean;
3
+ isHighAccuracy?: boolean;
4
+ highAccuracyExpireTime?: number;
5
+ }
6
+ export interface GetLocationResult {
7
+ latitude: number;
8
+ longitude: number;
9
+ speed: number;
10
+ accuracy: number;
11
+ altitude: number;
12
+ verticalAccuracy: number;
13
+ horizontalAccuracy: number;
14
+ }
15
+ export declare const getLocation: (options?: GetLocationOption) => Promise<GetLocationResult>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export const getLocation = (options = {}) => {
3
+ return invokeHostApi('getLocation', options);
4
+ };
@@ -0,0 +1 @@
1
+ export declare const getScreenBrightness: () => Promise<number>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export const getScreenBrightness = () => {
3
+ return invokeHostApi('getScreenBrightness');
4
+ };
@@ -0,0 +1 @@
1
+ export declare const getStorage: <T>(key: string) => Promise<T>;
@@ -0,0 +1,8 @@
1
+ import { deserializeStorageValue, getStorageItem } from '../storage';
2
+ export const getStorage = async (key) => {
3
+ const data = await getStorageItem(key);
4
+ if (data !== undefined && data !== null) {
5
+ return deserializeStorageValue(data);
6
+ }
7
+ throw new Error('getStorage:fail data not found');
8
+ };
@@ -0,0 +1,6 @@
1
+ export interface GetStorageInfoResult {
2
+ keys: string[];
3
+ currentSize: number;
4
+ limitSize: number;
5
+ }
6
+ export declare const getStorageInfo: () => Promise<GetStorageInfoResult>;
@@ -0,0 +1,12 @@
1
+ import { getStorageCurrentSize, getStorageKeys } from '../storage';
2
+ export const getStorageInfo = async () => {
3
+ const [keys, currentSize] = await Promise.all([
4
+ getStorageKeys(),
5
+ getStorageCurrentSize(),
6
+ ]);
7
+ return {
8
+ keys,
9
+ currentSize,
10
+ limitSize: 10240,
11
+ };
12
+ };
@@ -0,0 +1 @@
1
+ export declare function getSystemInfo(): Promise<Record<string, unknown>>;
@@ -0,0 +1,4 @@
1
+ import { invokeHostApi } from '../runtime/host';
2
+ export function getSystemInfo() {
3
+ return invokeHostApi('getSystemInfo');
4
+ }