@lingxia/types 0.1.2 → 0.4.3

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 (80) hide show
  1. package/dist/app/index.d.ts +7 -0
  2. package/dist/app/index.d.ts.map +1 -1
  3. package/dist/device/actions.d.ts +8 -0
  4. package/dist/device/actions.d.ts.map +1 -0
  5. package/dist/device/actions.js +7 -0
  6. package/dist/device/actions.js.map +1 -0
  7. package/dist/device/index.d.ts +4 -37
  8. package/dist/device/index.d.ts.map +1 -1
  9. package/dist/device/index.js +18 -4
  10. package/dist/device/index.js.map +1 -1
  11. package/dist/device/info.d.ts +17 -0
  12. package/dist/device/info.d.ts.map +1 -0
  13. package/dist/device/info.js +7 -0
  14. package/dist/device/info.js.map +1 -0
  15. package/dist/device/network.d.ts +13 -0
  16. package/dist/device/network.d.ts.map +1 -0
  17. package/dist/device/network.js +7 -0
  18. package/dist/device/network.js.map +1 -0
  19. package/dist/device/wifi.d.ts +21 -0
  20. package/dist/device/wifi.d.ts.map +1 -0
  21. package/dist/device/wifi.js +7 -0
  22. package/dist/device/wifi.js.map +1 -0
  23. package/dist/display/index.d.ts +9 -0
  24. package/dist/display/index.d.ts.map +1 -0
  25. package/dist/display/index.js +7 -0
  26. package/dist/display/index.js.map +1 -0
  27. package/dist/error.d.ts +15 -0
  28. package/dist/error.d.ts.map +1 -0
  29. package/dist/error.js +85 -0
  30. package/dist/error.js.map +1 -0
  31. package/dist/file/index.d.ts +102 -0
  32. package/dist/file/index.d.ts.map +1 -0
  33. package/dist/file/index.js +7 -0
  34. package/dist/file/index.js.map +1 -0
  35. package/dist/generated/error.d.ts +165 -0
  36. package/dist/generated/error.d.ts.map +1 -0
  37. package/dist/generated/error.js +46 -0
  38. package/dist/generated/error.js.map +1 -0
  39. package/dist/generated/i18n.d.ts +3 -0
  40. package/dist/generated/i18n.d.ts.map +1 -0
  41. package/dist/generated/i18n.js +124 -0
  42. package/dist/generated/i18n.js.map +1 -0
  43. package/dist/index.d.ts +44 -8
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +7 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/media/index.d.ts +233 -3
  48. package/dist/media/index.d.ts.map +1 -1
  49. package/dist/navigator/index.d.ts +10 -0
  50. package/dist/navigator/index.d.ts.map +1 -0
  51. package/dist/navigator/index.js +7 -0
  52. package/dist/navigator/index.js.map +1 -0
  53. package/dist/storage/index.d.ts +2 -7
  54. package/dist/storage/index.d.ts.map +1 -1
  55. package/dist/storage/index.js +2 -2
  56. package/dist/system/index.d.ts +3 -12
  57. package/dist/system/index.d.ts.map +1 -1
  58. package/dist/system/index.js +1 -1
  59. package/dist/update/index.d.ts +18 -0
  60. package/dist/update/index.d.ts.map +1 -0
  61. package/dist/update/index.js +7 -0
  62. package/dist/update/index.js.map +1 -0
  63. package/package.json +29 -3
  64. package/src/app/index.ts +9 -0
  65. package/src/device/actions.ts +8 -0
  66. package/src/device/index.ts +4 -46
  67. package/src/device/info.ts +18 -0
  68. package/src/device/network.ts +24 -0
  69. package/src/device/wifi.ts +24 -0
  70. package/src/display/index.ts +10 -0
  71. package/src/error.ts +82 -0
  72. package/src/file/index.ts +121 -0
  73. package/src/generated/error.ts +52 -0
  74. package/src/generated/i18n.ts +123 -0
  75. package/src/index.ts +65 -8
  76. package/src/media/index.ts +250 -3
  77. package/src/navigator/index.ts +10 -0
  78. package/src/storage/index.ts +2 -8
  79. package/src/system/index.ts +3 -14
  80. package/src/update/index.ts +20 -0
@@ -25,6 +25,146 @@ export interface CompressImageResult {
25
25
  tempFilePath: string;
26
26
  }
27
27
 
28
+ export type VideoCompressQuality = 'low' | 'medium' | 'high';
29
+
30
+ export interface CompressVideoOptions {
31
+ /**
32
+ * Source video path or `lx://` URI.
33
+ */
34
+ path: string;
35
+ /**
36
+ * Cross-platform note: video compression parameters are best-effort and may map to
37
+ * native presets instead of exact encoder settings.
38
+ *
39
+ * Compression quality preset.
40
+ * When provided, `bitrate`, `fps`, and `resolution` are ignored.
41
+ */
42
+ quality?: VideoCompressQuality;
43
+ /**
44
+ * Preferred target video bitrate in kbps.
45
+ * May be adjusted or ignored by platform codec/runtime limitations.
46
+ */
47
+ bitrate?: number;
48
+ /**
49
+ * Preferred target frame rate in fps.
50
+ * Some platforms may ignore this option.
51
+ */
52
+ fps?: number;
53
+ /**
54
+ * Target resolution scale ratio relative to source size, in range `(0, 1]`.
55
+ * May be approximated or ignored by platform transcoder capabilities.
56
+ */
57
+ resolution?: number;
58
+ /**
59
+ * Optional output path for compressed file.
60
+ */
61
+ outputPath?: string;
62
+ }
63
+
64
+ export interface CompressVideoResult {
65
+ tempFilePath: string;
66
+ width: number;
67
+ height: number;
68
+ durationMs: number;
69
+ /**
70
+ * Output file size in bytes.
71
+ * Could be close to source size when platform falls back to source content.
72
+ */
73
+ size: number;
74
+ type: string;
75
+ }
76
+
77
+ export interface GetVideoInfoOptions {
78
+ /**
79
+ * Video file path or `lx://` URI.
80
+ */
81
+ path: string;
82
+ }
83
+
84
+ export interface VideoInfo {
85
+ /**
86
+ * Encoded display width in pixels.
87
+ */
88
+ width: number;
89
+ /**
90
+ * Encoded display height in pixels.
91
+ */
92
+ height: number;
93
+ /**
94
+ * Video duration in milliseconds.
95
+ */
96
+ durationMs: number;
97
+ /**
98
+ * Clockwise rotation in degrees (usually `0 | 90 | 180 | 270`).
99
+ */
100
+ rotation?: number;
101
+ /**
102
+ * Average bitrate in bits per second (bps).
103
+ */
104
+ bitrate?: number;
105
+ /**
106
+ * Frame rate in frames per second (fps).
107
+ */
108
+ fps?: number;
109
+ /**
110
+ * MIME type, e.g. `video/mp4`.
111
+ */
112
+ type?: string;
113
+ /**
114
+ * Resolved path used by runtime (typically `lx://...`).
115
+ */
116
+ path: string;
117
+ }
118
+
119
+ export interface ExtractVideoThumbnailOptions {
120
+ /**
121
+ * Source video path or `lx://` URI.
122
+ */
123
+ path: string;
124
+ /**
125
+ * Optional output image path. If omitted, runtime chooses a temporary path.
126
+ */
127
+ outputPath?: string;
128
+ /**
129
+ * Max output width in pixels.
130
+ * Optional; when set with/without `maxHeight`, output keeps aspect ratio (no cropping).
131
+ */
132
+ maxWidth?: number;
133
+ /**
134
+ * Max output height in pixels.
135
+ * Optional; when set with/without `maxWidth`, output keeps aspect ratio (no cropping).
136
+ */
137
+ maxHeight?: number;
138
+ /**
139
+ * Target frame time in milliseconds from video start.
140
+ * `0` means first frame.
141
+ */
142
+ timeMs?: number;
143
+ /**
144
+ * JPEG quality in range `0-100`.
145
+ */
146
+ quality?: number;
147
+ }
148
+
149
+ export interface ExtractVideoThumbnailResult {
150
+ /**
151
+ * Generated thumbnail file path.
152
+ */
153
+ tempFilePath: string;
154
+ /**
155
+ * Output image width in pixels.
156
+ */
157
+ width: number;
158
+ /**
159
+ * Output image height in pixels.
160
+ */
161
+ height: number;
162
+ /**
163
+ * Output MIME type, usually `image/jpeg`.
164
+ */
165
+ type: string;
166
+ }
167
+
28
168
  export interface ChooseMediaOptions {
29
169
  count?: number;
30
170
  mediaType?: ('image' | 'video')[];
@@ -39,14 +179,121 @@ export interface ChosenMediaEntry {
39
179
  isOriginal: boolean;
40
180
  }
41
181
 
42
- export interface PreviewMediaItem {
182
+ export type MediaRotation = 0 | 90 | 180 | 270;
183
+
184
+ export type MediaObjectFit = 'cover' | 'contain' | 'fill' | 'fit';
185
+
186
+ export interface PreviewMediaSource {
187
+ /**
188
+ * Media source path.
189
+ * Recommended: `lx://` path (for example `lx://usercache/...`) or a sandbox-local path
190
+ * that can be resolved by runtime access rules.
191
+ */
43
192
  path: string;
44
193
  type?: 'image' | 'video';
194
+ /**
195
+ * Optional poster image path for video preview.
196
+ * Uses the same path contract as `path`.
197
+ */
45
198
  coverPath?: string;
199
+ /**
200
+ * Optional clockwise rotation in degrees (`0 | 90 | 180 | 270`).
201
+ * Default: when omitted, runtime resolves orientation from media metadata.
202
+ */
203
+ rotate?: MediaRotation;
204
+ /**
205
+ * Optional display fit mode for video preview.
206
+ * Default: `contain`.
207
+ */
208
+ objectFit?: MediaObjectFit;
209
+ /**
210
+ * Image display duration in milliseconds.
211
+ * Effective only for image items and only when preview `advance` is not `manual`.
212
+ */
213
+ durationMs?: number;
214
+ }
215
+
216
+ export type PreviewMediaAdvance = 'manual' | 'next' | 'loop';
217
+
218
+ export interface PreviewMediaSingleOptions extends PreviewMediaSource {
219
+ /**
220
+ * Auto behavior for the preview session.
221
+ *
222
+ * - `manual`: never auto-advance
223
+ * - `next`: advance to the next item; if already on the last item, close the session
224
+ * - `loop`: advance to the next item; if already on the last item, wrap to the first item
225
+ *
226
+ * Default: `manual`
227
+ */
228
+ advance?: PreviewMediaAdvance;
229
+ /**
230
+ * Optional cancellation signal for the preview request.
231
+ *
232
+ * Aborting rejects the returned promise with a cancellation error and requests the active
233
+ * native preview session to close immediately.
234
+ */
235
+ signal?: AbortSignal;
236
+ /**
237
+ * Whether to show the top `current/total` indicator.
238
+ *
239
+ * Default: `true` when previewing multiple items, otherwise `false`.
240
+ */
241
+ showIndexIndicator?: boolean;
46
242
  }
47
243
 
48
- export interface PreviewMediaOptions {
49
- sources: PreviewMediaItem[];
244
+ export interface PreviewMediaSequenceOptions {
245
+ /**
246
+ * Preview list. Supports images, videos, or a mixed queue.
247
+ */
248
+ sources: PreviewMediaSource[];
249
+ /**
250
+ * Initial item index in `sources`.
251
+ * Must be an integer.
252
+ * Out-of-range values are clamped by runtime.
253
+ * Default: `0`.
254
+ */
255
+ startIndex?: number;
256
+ /**
257
+ * Auto behavior for the preview session.
258
+ *
259
+ * - `manual`: never auto-advance
260
+ * - `next`: advance to the next item; if already on the last item, close the session
261
+ * - `loop`: advance to the next item; if already on the last item, wrap to the first item
262
+ *
263
+ * Default: `manual`
264
+ */
265
+ advance?: PreviewMediaAdvance;
266
+ /**
267
+ * Optional cancellation signal for the preview request.
268
+ *
269
+ * Aborting rejects the returned promise with a cancellation error and requests the active
270
+ * native preview session to close immediately.
271
+ */
272
+ signal?: AbortSignal;
273
+ /**
274
+ * Whether to show the top `current/total` indicator.
275
+ *
276
+ * Default: `true` when previewing multiple items, otherwise `false`.
277
+ */
278
+ showIndexIndicator?: boolean;
279
+ }
280
+
281
+ export type PreviewMediaOptions =
282
+ | string
283
+ | PreviewMediaSingleOptions
284
+ | PreviewMediaSequenceOptions;
285
+
286
+ export type PreviewMediaCloseReason = 'manual' | 'completed' | 'interrupted' | 'error';
287
+
288
+ export interface PreviewMediaResult {
289
+ /**
290
+ * Why the preview session finished.
291
+ */
292
+ reason: PreviewMediaCloseReason;
293
+ /**
294
+ * Last active item index before close.
295
+ */
296
+ lastIndex: number;
50
297
  }
51
298
 
52
299
  export interface SaveMediaOptions {
@@ -0,0 +1,10 @@
1
+ /**
2
+ * LxApp navigator APIs
3
+ * Corresponds to: lingxia-logic/src/navigator.rs
4
+ */
5
+
6
+ export interface NavigateToLxAppOptions {
7
+ appId: string;
8
+ path?: string;
9
+ envVersion?: 'develop' | 'trial' | 'release';
10
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Storage & File System APIs
3
- * Corresponds to: lingxia-logic/src/storage.rs, fs.rs, env.rs
2
+ * Storage APIs
3
+ * Corresponds to: lingxia-logic/src/storage.rs, env.rs
4
4
  */
5
5
 
6
6
  export interface LxEnv {
@@ -17,9 +17,3 @@ export interface Storage {
17
17
  has(key: string): boolean;
18
18
  size(): number;
19
19
  }
20
-
21
- export interface OpenDocumentOptions {
22
- filePath: string;
23
- fileType?: string;
24
- showMenu?: boolean;
25
- }
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * System APIs
3
- * Corresponds to: lingxia-logic/src/system.rs, navigator.rs, update.rs
3
+ * Corresponds to: lingxia-logic/src/system.rs
4
4
  */
5
5
 
6
6
  export interface AppBaseInfo {
7
7
  language: string;
8
8
  productName: string;
9
9
  version: string;
10
+ SDKVersion: string;
10
11
  }
11
12
 
12
13
  export interface SystemSettingInfo {
@@ -17,17 +18,5 @@ export interface SystemSettingInfo {
17
18
 
18
19
  export interface OpenURLOptions {
19
20
  url: string;
20
- openIn?: 'external' | 'internal';
21
- }
22
-
23
- export interface NavigateToLxAppOptions {
24
- appId: string;
25
- path?: string;
26
- envVersion?: 'develop' | 'trial' | 'release';
27
- }
28
-
29
- export interface UpdateManager {
30
- applyUpdate(): void;
31
- onUpdateReady(callback: () => void): void;
32
- onUpdateFailed(callback: () => void): void;
21
+ target?: 'self' | 'external';
33
22
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Update APIs
3
+ * Corresponds to: lingxia-logic/src/update.rs
4
+ */
5
+
6
+ export interface UpdateManager {
7
+ applyUpdate(): void;
8
+ onUpdateReady(callback: (info: UpdateReadyInfo) => void): void;
9
+ onUpdateFailed(callback: (info: UpdateFailedInfo) => void): void;
10
+ }
11
+
12
+ export interface UpdateReadyInfo {
13
+ version?: string;
14
+ isForceUpdate?: boolean;
15
+ releaseType?: "release" | "preview" | "developer" | string;
16
+ }
17
+
18
+ export interface UpdateFailedInfo extends UpdateReadyInfo {
19
+ error?: string;
20
+ }