@monimesl/dot-dash 0.1.0-alpha.3 → 0.1.0-alpha.31

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 CHANGED
@@ -1,4 +1,112 @@
1
- import { HostCallOptions, HostError, HostErrorCode, HostRequest } from "@monimesl/dot-core";
1
+ import { HostCallOptions, HostError, HostError as DashError, HostErrorCode, HostErrorCode as DashErrorCode, HostRequest } from "@monimesl/dot-core";
2
+ //#region src/contacts/pick-phone.d.ts
3
+ interface PickedContact {
4
+ name: string;
5
+ phone: string;
6
+ }
7
+ interface PickPhoneMethods {
8
+ 'dash.contacts.pickPhone': {
9
+ params: Record<string, never>;
10
+ result: PickedContact;
11
+ };
12
+ }
13
+ /**
14
+ * Shows the phone's contacts so the person chooses one phone number, such as who to send money to.
15
+ * Needs the `contacts` permission. The dot sees only the chosen contact. Rejects with `cancelled` if
16
+ * the person closes it.
17
+ * @since 1.0
18
+ */
19
+ declare function pickPhone(callOptions?: CallOptions): DashRequest<PickedContact>;
20
+ declare namespace index_d_exports$9 {
21
+ export { ContactsMethods, PickedContact, pickPhone };
22
+ }
23
+ type ContactsMethods = PickPhoneMethods;
24
+ declare namespace index_d_exports$8 {
25
+ export { CryptoInput, CryptoMethods, CryptoOutputOptions, HmacAlgorithm, HmacOptions, hmac, randomBytes, randomUUID, sha256, sha512 };
26
+ }
27
+ type CryptoInput = string | {
28
+ base64: string;
29
+ };
30
+ interface CryptoOutputOptions {
31
+ as?: 'hex' | 'base64';
32
+ }
33
+ type HmacAlgorithm = 'sha256' | 'sha512';
34
+ interface HmacOptions extends CryptoOutputOptions {
35
+ algorithm: HmacAlgorithm;
36
+ key: CryptoInput;
37
+ data: CryptoInput;
38
+ }
39
+ type InputEncoding = 'text' | 'base64';
40
+ type OutputEncoding = 'hex' | 'base64';
41
+ interface WireInput {
42
+ data: string;
43
+ dataEncoding: InputEncoding;
44
+ as: OutputEncoding;
45
+ }
46
+ interface CryptoMethods {
47
+ 'dash.crypto.sha256': {
48
+ params: WireInput;
49
+ result: string;
50
+ };
51
+ 'dash.crypto.sha512': {
52
+ params: WireInput;
53
+ result: string;
54
+ };
55
+ 'dash.crypto.hmac': {
56
+ params: WireInput & {
57
+ algorithm: HmacAlgorithm;
58
+ key: string;
59
+ keyEncoding: InputEncoding;
60
+ };
61
+ result: string;
62
+ };
63
+ 'dash.crypto.randomBytes': {
64
+ params: {
65
+ count: number;
66
+ as: OutputEncoding;
67
+ };
68
+ result: string;
69
+ };
70
+ 'dash.crypto.randomUUID': {
71
+ params: Record<string, never>;
72
+ result: string;
73
+ };
74
+ }
75
+ /** @since 1.0 */
76
+ declare function sha256(data: CryptoInput, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>;
77
+ /** @since 1.0 */
78
+ declare function sha512(data: CryptoInput, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>;
79
+ /**
80
+ * Signs `data` with `key`, as HMAC-SHA256 or HMAC-SHA512, such as
81
+ * `hmac({ algorithm: 'sha256', key, data })`.
82
+ * @since 1.0
83
+ */
84
+ declare function hmac(options: HmacOptions, callOptions?: CallOptions): DashRequest<string>;
85
+ /**
86
+ * `count` secure random bytes, from 1 to 1024, such as for a nonce.
87
+ * @since 1.0
88
+ */
89
+ declare function randomBytes(count: number, options?: CryptoOutputOptions, callOptions?: CallOptions): DashRequest<string>;
90
+ /**
91
+ * A random version 4 UUID, such as "3f0e5c3a-6d1b-4c8e-9a2f-1b7d4e6a9c05".
92
+ * @since 1.0
93
+ */
94
+ declare function randomUUID(callOptions?: CallOptions): DashRequest<string>;
95
+ declare namespace index_d_exports$7 {
96
+ export { DotMethods, close };
97
+ }
98
+ interface DotMethods {
99
+ 'dash.dot.close': {
100
+ params: Record<string, never>;
101
+ result: void;
102
+ };
103
+ }
104
+ /**
105
+ * Closes the dot, as going back from its first page does. Calls still running are cancelled.
106
+ * @since 1.0
107
+ */
108
+ declare function close(callOptions?: CallOptions): DashRequest<void>;
109
+ //#endregion
2
110
  //#region src/files.d.ts
3
111
  interface DotFile {
4
112
  id: string;
@@ -7,6 +115,71 @@ interface DotFile {
7
115
  contentType: string;
8
116
  url: string;
9
117
  }
118
+ //#endregion
119
+ //#region src/media/pick-file.d.ts
120
+ interface PickFileOptions {
121
+ types?: string[];
122
+ }
123
+ interface PickFileMethods {
124
+ 'dash.media.pickFile': {
125
+ params: {
126
+ types?: string[];
127
+ };
128
+ result: DotFile;
129
+ };
130
+ }
131
+ /**
132
+ * Lets the person choose a file from their phone, of at most 25 MB. Needs the `files` permission.
133
+ * Rejects with `cancelled` if they close the picker, and with `invalid` for a larger file. Like a
134
+ * download, it lasts until the dot closes, so `dash.storage.file.save` it to keep it.
135
+ * @since 1.0
136
+ */
137
+ declare function pickFile(options?: PickFileOptions, callOptions?: CallOptions): DashRequest<DotFile>;
138
+ //#endregion
139
+ //#region src/media/pick-photo.d.ts
140
+ type PhotoSource = 'library' | 'camera';
141
+ interface PickPhotoOptions {
142
+ source: PhotoSource;
143
+ }
144
+ interface PickPhotoMethods {
145
+ 'dash.media.pickPhoto': {
146
+ params: {
147
+ source: PhotoSource;
148
+ };
149
+ result: DotFile;
150
+ };
151
+ }
152
+ /**
153
+ * Lets the person choose a photo or take one. Resolves with it as a JPEG of at most 2048 pixels on its
154
+ * longest side, without its location or other details. Rejects with `cancelled` if they close the
155
+ * picker, and with `unsupported` on a device without a camera. Save it with `dash.storage.file.save`
156
+ * to keep it after the dot closes.
157
+ * @since 1.0
158
+ */
159
+ declare function pickPhoto(options: PickPhotoOptions, callOptions?: CallOptions): DashRequest<DotFile>;
160
+ //#endregion
161
+ //#region src/media/scan-code.d.ts
162
+ type CodeFormat = 'qr';
163
+ interface ScannedCode {
164
+ text: string;
165
+ format: CodeFormat;
166
+ }
167
+ interface ScanCodeMethods {
168
+ 'dash.media.scanCode': {
169
+ params: Record<string, never>;
170
+ result: ScannedCode;
171
+ };
172
+ }
173
+ /**
174
+ * Opens Dash's scanner until it reads a QR code. Needs the `camera` permission. Rejects with
175
+ * `cancelled` if the person closes it, and with `unsupported` where Dash has no scanner.
176
+ * @since 1.0
177
+ */
178
+ declare function scanCode(callOptions?: CallOptions): DashRequest<ScannedCode>;
179
+ declare namespace index_d_exports$6 {
180
+ export { CodeFormat, MediaMethods, PhotoSource, PickFileOptions, PickPhotoOptions, ScannedCode, pickFile, pickPhoto, scanCode };
181
+ }
182
+ type MediaMethods = PickFileMethods & PickPhotoMethods & ScanCodeMethods;
10
183
  declare namespace http_d_exports {
11
184
  export { HttpDownloadRequest, HttpDownloadResponse, HttpMethod, HttpMethods, HttpReadOptions, HttpRequest, HttpRequestBody, HttpResponse, HttpUploadFile, HttpUploadRequest, download, request, upload };
12
185
  }
@@ -41,7 +214,7 @@ type HttpDownloadResponse = (Omit<HttpResponse, 'ok' | 'body'> & {
41
214
  });
42
215
  interface HttpUploadFile {
43
216
  field: string;
44
- file: DotFile | string;
217
+ file: DotFile;
45
218
  name?: string;
46
219
  }
47
220
  interface HttpUploadRequest {
@@ -75,120 +248,108 @@ interface HttpMethods {
75
248
  result: HttpResponse;
76
249
  };
77
250
  }
251
+ /**
252
+ * Like fetch, resolves with any response, even a 404. An object body is sent as JSON.
253
+ * @since 1.0
254
+ */
78
255
  declare function request<ResponseBody = string, RequestBody extends HttpRequestBody = HttpRequestBody>(options: HttpRequest<RequestBody> & HttpReadOptions<ResponseBody>, callOptions?: CallOptions): DashRequest<HttpResponse<ResponseBody>>;
256
+ /**
257
+ * Saves a 2xx response's body, up to 256 MB, to a temporary file.
258
+ * @since 1.0
259
+ */
79
260
  declare function download(options: HttpDownloadRequest, callOptions?: CallOptions): DashRequest<HttpDownloadResponse>;
261
+ /**
262
+ * Sends the dot's files as a multipart form.
263
+ * @since 1.0
264
+ */
80
265
  declare function upload<ResponseBody = string>(options: HttpUploadRequest & HttpReadOptions<ResponseBody>, callOptions?: CallOptions): DashRequest<HttpResponse<ResponseBody>>;
81
- declare namespace index_d_exports$3 {
82
- export { HttpDownloadRequest, HttpDownloadResponse, HttpMethod, HttpReadOptions, HttpRequest, HttpRequestBody, HttpResponse, HttpUploadFile, HttpUploadRequest, NetworkMethods, http_d_exports as http };
83
- }
84
- type NetworkMethods = HttpMethods;
85
266
  //#endregion
86
- //#region src/system/clipboard.d.ts
87
- interface ClipboardMethods {
88
- 'dash.system.copyText': {
89
- params: {
90
- text: string;
91
- };
92
- result: void;
267
+ //#region src/network/status.d.ts
268
+ type ConnectionType = 'wifi' | 'cellular' | 'other' | 'none';
269
+ interface NetworkStatus {
270
+ online: boolean;
271
+ type: ConnectionType;
272
+ }
273
+ interface StatusMethods {
274
+ 'dash.network.status': {
275
+ params: Record<string, never>;
276
+ result: NetworkStatus;
93
277
  };
94
278
  }
95
- declare function copyText(text: string, callOptions?: CallOptions): DashRequest<void>;
96
- //#endregion
97
- //#region src/system/delay.d.ts
98
- interface DelayMethods {
99
- 'dash.system.delay': {
279
+ /**
280
+ * Whether the phone is online now, and how. It can still be online without reaching a server.
281
+ * @since 1.0
282
+ */
283
+ declare function status(callOptions?: CallOptions): DashRequest<NetworkStatus>;
284
+ declare namespace index_d_exports$5 {
285
+ export { ConnectionType, HttpDownloadRequest, HttpDownloadResponse, HttpMethod, HttpReadOptions, HttpRequest, HttpRequestBody, HttpResponse, HttpUploadFile, HttpUploadRequest, NetworkMethods, NetworkStatus, http_d_exports as http, status };
286
+ }
287
+ type NetworkMethods = HttpMethods & StatusMethods;
288
+ declare namespace cache_d_exports {
289
+ export { CacheMethods, CacheSetOptions, CacheValue, clear$1 as clear, exists, get$1 as get, keys, remove$2 as remove, set$1 as set };
290
+ }
291
+ type CacheValue = string | number | boolean | CacheValue[] | {
292
+ [key: string]: CacheValue;
293
+ };
294
+ interface CacheMethods {
295
+ 'dash.storage.cache.get': {
100
296
  params: {
101
- milliseconds: number;
297
+ key: string;
102
298
  };
103
- result: void;
299
+ result: CacheValue | null;
104
300
  };
105
- }
106
- declare function delay(milliseconds: number, callOptions?: CallOptions): DashRequest<void>;
107
- //#endregion
108
- //#region src/system/haptics.d.ts
109
- type VibrationStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error';
110
- interface VibrateOptions {
111
- style?: VibrationStyle | undefined;
112
- }
113
- interface HapticsMethods {
114
- 'dash.system.vibrate': {
115
- params: VibrateOptions;
301
+ 'dash.storage.cache.set': {
302
+ params: {
303
+ key: string;
304
+ value: CacheValue;
305
+ ttl?: number | undefined;
306
+ };
116
307
  result: void;
117
308
  };
118
- }
119
- declare function vibrate(options?: VibrateOptions, callOptions?: CallOptions): DashRequest<void>;
120
- //#endregion
121
- //#region src/system/share.d.ts
122
- interface ShareOptions {
123
- title?: string;
124
- text?: string;
125
- url?: string;
126
- file?: DotFile | string;
127
- }
128
- interface ShareMethods {
129
- 'dash.system.share': {
309
+ 'dash.storage.cache.remove': {
130
310
  params: {
131
- title?: string;
132
- text?: string;
133
- url?: string;
134
- file?: string;
311
+ key: string;
135
312
  };
136
313
  result: void;
137
314
  };
138
- }
139
- declare function share(options: ShareOptions, callOptions?: CallOptions): DashRequest<void>;
140
- //#endregion
141
- //#region src/system/torch.d.ts
142
- type TorchState = 'on' | 'off';
143
- interface TorchMethods {
144
- 'dash.system.torch': {
315
+ 'dash.storage.cache.exists': {
145
316
  params: {
146
- state: TorchState;
317
+ key: string;
147
318
  };
148
- result: void;
319
+ result: boolean;
149
320
  };
150
- }
151
- declare function torch(state: TorchState, callOptions?: CallOptions): DashRequest<void>;
152
- declare namespace index_d_exports$2 {
153
- export { ShareOptions, SystemMethods, TorchState, VibrateOptions, VibrationStyle, copyText, delay, share, torch, vibrate };
154
- }
155
- type SystemMethods = ClipboardMethods & DelayMethods & HapticsMethods & ShareMethods & TorchMethods;
156
- //#endregion
157
- //#region src/ui/dialogs.d.ts
158
- interface AlertAction {
159
- id: string;
160
- label: string;
161
- role?: 'default' | 'cancel' | 'destructive' | undefined;
162
- }
163
- interface AlertOptions {
164
- title: string;
165
- message?: string | undefined;
166
- actions?: AlertAction[] | undefined;
167
- }
168
- interface AlertResult {
169
- action: string;
170
- }
171
- interface DialogMethods {
172
- 'dash.ui.alert': {
173
- params: AlertOptions;
174
- result: AlertResult;
321
+ 'dash.storage.cache.keys': {
322
+ params: Record<string, never>;
323
+ result: string[];
324
+ };
325
+ 'dash.storage.cache.clear': {
326
+ params: Record<string, never>;
327
+ result: void;
175
328
  };
176
329
  }
177
- declare function alert(options: AlertOptions, callOptions?: CallOptions): DashRequest<AlertResult>;
178
- declare namespace index_d_exports$1 {
179
- export { AlertAction, AlertOptions, AlertResult, UIMethods, alert };
330
+ interface CacheSetOptions {
331
+ ttl?: number | undefined;
180
332
  }
181
- type UIMethods = DialogMethods;
182
- //#endregion
183
- //#region src/methods.d.ts
184
- type DashMethods = UIMethods & SystemMethods & NetworkMethods & FileMethods;
185
- type DashMethod = keyof DashMethods;
186
- //#endregion
187
- //#region src/call.d.ts
188
- type CallOptions = HostCallOptions;
189
- type DashRequest<Result> = HostRequest<Result>;
190
- declare namespace index_d_exports {
191
- export { FileEncoding, FileEntry, FileMethods, ReadOptions, ReplaceOptions, StorageUsage, WriteOptions, copy, createFolder, list, move, open, read, remove, save, stat, usage, write };
333
+ /**
334
+ * Resolves with null for a missing or expired key.
335
+ * @since 1.0
336
+ */
337
+ declare function get$1<Value extends CacheValue = CacheValue>(key: string, callOptions?: CallOptions): DashRequest<Value | null>;
338
+ /** @since 1.0 */
339
+ declare function set$1(key: string, value: CacheValue, options?: CacheSetOptions, callOptions?: CallOptions): DashRequest<void>;
340
+ /** @since 1.0 */
341
+ declare function remove$2(key: string, callOptions?: CallOptions): DashRequest<void>;
342
+ /** @since 1.0 */
343
+ declare function exists(key: string, callOptions?: CallOptions): DashRequest<boolean>;
344
+ /**
345
+ * The keys, sorted.
346
+ * @since 1.0
347
+ */
348
+ declare function keys(callOptions?: CallOptions): DashRequest<string[]>;
349
+ /** @since 1.0 */
350
+ declare function clear$1(callOptions?: CallOptions): DashRequest<void>;
351
+ declare namespace file_d_exports {
352
+ export { FileEncoding, FileEntry, FileMethods, ReadOptions, ReplaceOptions, StorageUsage, WriteOptions, copy, createFolder, list, move, open, read, remove$1 as remove, save, stat, usage, write };
192
353
  }
193
354
  interface FileEntry {
194
355
  name: string;
@@ -204,14 +365,14 @@ interface StorageUsage {
204
365
  quota: number;
205
366
  }
206
367
  interface FileMethods {
207
- 'dash.file.read': {
368
+ 'dash.storage.file.read': {
208
369
  params: {
209
370
  path: string;
210
371
  as?: FileEncoding;
211
372
  };
212
373
  result: string;
213
374
  };
214
- 'dash.file.write': {
375
+ 'dash.storage.file.write': {
215
376
  params: {
216
377
  path: string;
217
378
  data: string;
@@ -220,26 +381,26 @@ interface FileMethods {
220
381
  };
221
382
  result: FileEntry;
222
383
  };
223
- 'dash.file.stat': {
384
+ 'dash.storage.file.stat': {
224
385
  params: {
225
386
  path: string;
226
387
  };
227
388
  result: FileEntry | null;
228
389
  };
229
- 'dash.file.list': {
390
+ 'dash.storage.file.list': {
230
391
  params: {
231
392
  path: string;
232
393
  recursive?: boolean;
233
394
  };
234
395
  result: FileEntry[];
235
396
  };
236
- 'dash.file.createFolder': {
397
+ 'dash.storage.file.createFolder': {
237
398
  params: {
238
399
  path: string;
239
400
  };
240
401
  result: FileEntry;
241
402
  };
242
- 'dash.file.move': {
403
+ 'dash.storage.file.move': {
243
404
  params: {
244
405
  from: string;
245
406
  to: string;
@@ -247,7 +408,7 @@ interface FileMethods {
247
408
  };
248
409
  result: FileEntry;
249
410
  };
250
- 'dash.file.copy': {
411
+ 'dash.storage.file.copy': {
251
412
  params: {
252
413
  from: string;
253
414
  to: string;
@@ -255,14 +416,14 @@ interface FileMethods {
255
416
  };
256
417
  result: FileEntry;
257
418
  };
258
- 'dash.file.remove': {
419
+ 'dash.storage.file.remove': {
259
420
  params: {
260
421
  path: string;
261
422
  recursive?: boolean;
262
423
  };
263
424
  result: void;
264
425
  };
265
- 'dash.file.save': {
426
+ 'dash.storage.file.save': {
266
427
  params: {
267
428
  file: string;
268
429
  path: string;
@@ -270,13 +431,13 @@ interface FileMethods {
270
431
  };
271
432
  result: FileEntry;
272
433
  };
273
- 'dash.file.open': {
434
+ 'dash.storage.file.open': {
274
435
  params: {
275
436
  path: string;
276
437
  };
277
438
  result: DotFile;
278
439
  };
279
- 'dash.file.usage': {
440
+ 'dash.storage.file.usage': {
280
441
  params: Record<string, never>;
281
442
  result: StorageUsage;
282
443
  };
@@ -291,33 +452,495 @@ interface WriteOptions {
291
452
  interface ReplaceOptions {
292
453
  overwrite?: boolean;
293
454
  }
455
+ /**
456
+ * Reads a file of up to 5 MB.
457
+ * @since 1.0
458
+ */
294
459
  declare function read(path: string, options?: ReadOptions, callOptions?: CallOptions): DashRequest<string>;
460
+ /**
461
+ * Creates any missing folders above the file.
462
+ * @since 1.0
463
+ */
295
464
  declare function write(path: string, data: string, options?: WriteOptions, callOptions?: CallOptions): DashRequest<FileEntry>;
465
+ /** @since 1.0 */
296
466
  declare function stat(path: string, callOptions?: CallOptions): DashRequest<FileEntry | null>;
467
+ /**
468
+ * Sorted by path.
469
+ * @since 1.0
470
+ */
297
471
  declare function list(path?: string, options?: {
298
472
  recursive?: boolean;
299
473
  }, callOptions?: CallOptions): DashRequest<FileEntry[]>;
474
+ /** @since 1.0 */
300
475
  declare function createFolder(path: string, callOptions?: CallOptions): DashRequest<FileEntry>;
476
+ /** @since 1.0 */
301
477
  declare function move(from: string, to: string, options?: ReplaceOptions, callOptions?: CallOptions): DashRequest<FileEntry>;
478
+ /** @since 1.0 */
302
479
  declare function copy(from: string, to: string, options?: ReplaceOptions, callOptions?: CallOptions): DashRequest<FileEntry>;
303
- declare function remove(path: string, options?: {
480
+ /**
481
+ * Removing a folder that isn't empty needs `recursive`.
482
+ * @since 1.0
483
+ */
484
+ declare function remove$1(path: string, options?: {
304
485
  recursive?: boolean;
305
486
  }, callOptions?: CallOptions): DashRequest<void>;
306
- declare function save(file: DotFile | string, path: string, options?: ReplaceOptions, callOptions?: CallOptions): DashRequest<FileEntry>;
487
+ /**
488
+ * Keeps a temporary file, such as a download, at `path`.
489
+ * @since 1.0
490
+ */
491
+ declare function save(file: DotFile, path: string, options?: ReplaceOptions, callOptions?: CallOptions): DashRequest<FileEntry>;
492
+ /**
493
+ * A stored file as a DotFile, to show with its `url` or send with `http.upload`.
494
+ * @since 1.0
495
+ */
307
496
  declare function open(path: string, callOptions?: CallOptions): DashRequest<DotFile>;
497
+ /** @since 1.0 */
308
498
  declare function usage(callOptions?: CallOptions): DashRequest<StorageUsage>;
499
+ declare namespace secret_d_exports {
500
+ export { SecretMethods, clear, get, remove, set };
501
+ }
502
+ interface SecretMethods {
503
+ 'dash.storage.secret.get': {
504
+ params: {
505
+ key: string;
506
+ };
507
+ result: string | null;
508
+ };
509
+ 'dash.storage.secret.set': {
510
+ params: {
511
+ key: string;
512
+ value: string;
513
+ };
514
+ result: void;
515
+ };
516
+ 'dash.storage.secret.remove': {
517
+ params: {
518
+ key: string;
519
+ };
520
+ result: void;
521
+ };
522
+ 'dash.storage.secret.clear': {
523
+ params: Record<string, never>;
524
+ result: void;
525
+ };
526
+ }
527
+ /** @since 1.0 */
528
+ declare function get(key: string, callOptions?: CallOptions): DashRequest<string | null>;
529
+ /** @since 1.0 */
530
+ declare function set(key: string, value: string, callOptions?: CallOptions): DashRequest<void>;
531
+ /** @since 1.0 */
532
+ declare function remove(key: string, callOptions?: CallOptions): DashRequest<void>;
533
+ /** @since 1.0 */
534
+ declare function clear(callOptions?: CallOptions): DashRequest<void>;
535
+ declare namespace index_d_exports$4 {
536
+ export { CacheSetOptions, CacheValue, FileEncoding, FileEntry, ReadOptions, ReplaceOptions, StorageMethods, StorageUsage, WriteOptions, cache_d_exports as cache, file_d_exports as file, secret_d_exports as secret };
537
+ }
538
+ type StorageMethods = FileMethods & CacheMethods & SecretMethods;
539
+ //#endregion
540
+ //#region src/system/clipboard.d.ts
541
+ interface ClipboardMethods {
542
+ 'dash.system.copyText': {
543
+ params: {
544
+ text: string;
545
+ };
546
+ result: void;
547
+ };
548
+ }
549
+ /** @since 1.0 */
550
+ declare function copyText(text: string, callOptions?: CallOptions): DashRequest<void>;
551
+ //#endregion
552
+ //#region src/system/delay.d.ts
553
+ interface DelayMethods {
554
+ 'dash.system.delay': {
555
+ params: {
556
+ milliseconds: number;
557
+ };
558
+ result: void;
559
+ };
560
+ }
561
+ /**
562
+ * Resolves after `milliseconds`. The host keeps the time, since a dot's logic has no timers.
563
+ * @since 1.0
564
+ */
565
+ declare function delay(milliseconds: number, callOptions?: CallOptions): DashRequest<void>;
566
+ //#endregion
567
+ //#region src/system/dial.d.ts
568
+ interface DialMethods {
569
+ 'dash.system.dial': {
570
+ params: {
571
+ number: string;
572
+ };
573
+ result: void;
574
+ };
575
+ }
576
+ /**
577
+ * Opens the phone's dialer with `number` ready, such as "+232 76 123456" or a USSD code such as
578
+ * "*715#". The person taps Call. Spaces and dashes are fine; anything else but digits, +, * and #
579
+ * rejects with `invalid`.
580
+ * @since 1.0
581
+ */
582
+ declare function dial(number: string, callOptions?: CallOptions): DashRequest<void>;
583
+ //#endregion
584
+ //#region src/system/haptics.d.ts
585
+ type VibrationStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error';
586
+ interface VibrateOptions {
587
+ style?: VibrationStyle | undefined;
588
+ }
589
+ interface HapticsMethods {
590
+ 'dash.system.vibrate': {
591
+ params: VibrateOptions;
592
+ result: void;
593
+ };
594
+ }
595
+ /**
596
+ * Plays a short vibration. Resolves once it's done.
597
+ * @since 1.0
598
+ */
599
+ declare function vibrate(options?: VibrateOptions, callOptions?: CallOptions): DashRequest<void>;
600
+ //#endregion
601
+ //#region src/system/info.d.ts
602
+ type Platform = 'ios' | 'android' | 'simulator';
603
+ interface SystemInfo {
604
+ platform: Platform;
605
+ osVersion: string;
606
+ language: string;
607
+ region: string | null;
608
+ timeZone: string;
609
+ dashVersion: string;
610
+ apiVersions: string[];
611
+ }
612
+ interface InfoMethods {
613
+ 'dash.system.info': {
614
+ params: Record<string, never>;
615
+ result: SystemInfo;
616
+ };
617
+ }
618
+ /**
619
+ * The phone and the Dash the dot runs in. It has nothing that identifies the person or the phone.
620
+ * @since 1.0
621
+ */
622
+ declare function info(callOptions?: CallOptions): DashRequest<SystemInfo>;
623
+ //#endregion
624
+ //#region src/system/open-url.d.ts
625
+ interface OpenUrlMethods {
626
+ 'dash.system.openUrl': {
627
+ params: {
628
+ url: string;
629
+ };
630
+ result: void;
631
+ };
632
+ }
633
+ /**
634
+ * Opens an https address in the device's browser. Any other address rejects with `invalid`.
635
+ * @since 1.0
636
+ */
637
+ declare function openUrl(url: string, callOptions?: CallOptions): DashRequest<void>;
638
+ //#endregion
639
+ //#region src/system/screen.d.ts
640
+ type BrightnessLevel = 'max' | 'normal';
641
+ interface ScreenMethods {
642
+ 'dash.system.keepAwake': {
643
+ params: {
644
+ on: boolean;
645
+ };
646
+ result: void;
647
+ };
648
+ 'dash.system.brightness': {
649
+ params: {
650
+ level: BrightnessLevel;
651
+ };
652
+ result: void;
653
+ };
654
+ }
655
+ /**
656
+ * Keeps the screen from dimming and locking while the dot shows, such as while a ticket's QR code is
657
+ * up. Dash undoes it when the dot closes.
658
+ * @since 1.0
659
+ */
660
+ declare function keepAwake(on: boolean, callOptions?: CallOptions): DashRequest<void>;
661
+ /**
662
+ * `max` makes the screen as bright as it goes, so a scanner can read a QR code on it, and `normal`
663
+ * puts it back. Dash puts it back too when the dot closes or the person leaves the app.
664
+ * @since 1.0
665
+ */
666
+ declare function brightness(level: BrightnessLevel, callOptions?: CallOptions): DashRequest<void>;
667
+ //#endregion
668
+ //#region src/system/share.d.ts
669
+ interface ShareOptions {
670
+ title?: string;
671
+ text?: string;
672
+ url?: string;
673
+ file?: DotFile;
674
+ }
675
+ interface ShareMethods {
676
+ 'dash.system.share': {
677
+ params: {
678
+ title?: string;
679
+ text?: string;
680
+ url?: string;
681
+ file?: string;
682
+ };
683
+ result: void;
684
+ };
685
+ }
686
+ /**
687
+ * Opens the device's share sheet. Resolves once it shows.
688
+ * @since 1.0
689
+ */
690
+ declare function share(options: ShareOptions, callOptions?: CallOptions): DashRequest<void>;
691
+ //#endregion
692
+ //#region src/system/torch.d.ts
693
+ interface TorchMethods {
694
+ 'dash.system.torch': {
695
+ params: {
696
+ on: boolean;
697
+ };
698
+ result: void;
699
+ };
700
+ }
701
+ /**
702
+ * Turns the torch on or off. Rejects with `unsupported` on a device without one.
703
+ * @since 1.0
704
+ */
705
+ declare function torch(on: boolean, callOptions?: CallOptions): DashRequest<void>;
706
+ declare namespace index_d_exports$3 {
707
+ export { BrightnessLevel, Platform, ShareOptions, SystemInfo, SystemMethods, VibrateOptions, VibrationStyle, brightness, copyText, delay, dial, info, keepAwake, openUrl, share, torch, vibrate };
708
+ }
709
+ type SystemMethods = ClipboardMethods & DelayMethods & DialMethods & HapticsMethods & InfoMethods & OpenUrlMethods & ScreenMethods & ShareMethods & TorchMethods;
710
+ //#endregion
711
+ //#region src/ui/dialogs.d.ts
712
+ interface AlertAction {
713
+ id: string;
714
+ label: string;
715
+ role?: 'default' | 'cancel' | 'destructive' | undefined;
716
+ }
717
+ interface AlertOptions {
718
+ title: string;
719
+ message?: string | undefined;
720
+ actions?: AlertAction[] | undefined;
721
+ }
722
+ interface AlertResult {
723
+ action: string;
724
+ }
725
+ interface DialogMethods {
726
+ 'dash.ui.alert': {
727
+ params: AlertOptions;
728
+ result: AlertResult;
729
+ };
730
+ }
731
+ /**
732
+ * Shows a native alert. Resolves with the action the person chose.
733
+ * @since 1.0
734
+ */
735
+ declare function alert(options: AlertOptions, callOptions?: CallOptions): DashRequest<AlertResult>;
736
+ //#endregion
737
+ //#region src/ui/pickers.d.ts
738
+ interface PickDateOptions {
739
+ title?: string | undefined;
740
+ value?: string | undefined;
741
+ min?: string | undefined;
742
+ max?: string | undefined;
743
+ }
744
+ interface PickTimeOptions {
745
+ title?: string | undefined;
746
+ value?: string | undefined;
747
+ }
748
+ interface PickerMethods {
749
+ 'dash.ui.pickDate': {
750
+ params: PickDateOptions;
751
+ result: string;
752
+ };
753
+ 'dash.ui.pickTime': {
754
+ params: PickTimeOptions;
755
+ result: string;
756
+ };
757
+ }
758
+ /**
759
+ * Opens the phone's own calendar. Resolves with the chosen date, such as "2026-10-24", or rejects
760
+ * with `cancelled` if the person closes it.
761
+ * @since 1.0
762
+ */
763
+ declare function pickDate(options?: PickDateOptions, callOptions?: CallOptions): DashRequest<string>;
764
+ /**
765
+ * Opens the phone's own clock. Resolves with the chosen time in 24 hours, such as "19:30", or
766
+ * rejects with `cancelled` if the person closes it.
767
+ * @since 1.0
768
+ */
769
+ declare function pickTime(options?: PickTimeOptions, callOptions?: CallOptions): DashRequest<string>;
770
+ declare namespace index_d_exports$2 {
771
+ export { AlertAction, AlertOptions, AlertResult, PickDateOptions, PickTimeOptions, UIMethods, alert, pickDate, pickTime };
772
+ }
773
+ type UIMethods = DialogMethods & PickerMethods;
774
+ //#endregion
775
+ //#region src/methods.d.ts
776
+ type DashMethods = UIMethods & SystemMethods & NetworkMethods & StorageMethods & MediaMethods & ContactsMethods & DotMethods & AccountMethods & CryptoMethods;
777
+ type DashMethod = keyof DashMethods;
778
+ //#endregion
779
+ //#region src/call.d.ts
780
+ type CallOptions = HostCallOptions;
781
+ type DashRequest<Result> = HostRequest<Result>;
782
+ declare namespace index_d_exports$1 {
783
+ export { AccountMethods, OidcProfile, OidcScope, OidcSignIn, OidcSignInOptions, SignInMode, SimpleSignIn, SimpleSignInOptions, signIn };
784
+ }
785
+ type SignInMode = 'simple' | 'oidc';
786
+ interface SimpleSignInOptions {
787
+ mode: 'simple';
788
+ nonce?: string | undefined;
789
+ }
790
+ interface SimpleSignIn {
791
+ fullName: string;
792
+ alias: string;
793
+ accountIdToken: string;
794
+ }
795
+ type OidcScope = 'profile' | 'phone' | 'email';
796
+ interface OidcSignInOptions {
797
+ mode: 'oidc';
798
+ scopes?: OidcScope[] | undefined;
799
+ nonce?: string | undefined;
800
+ }
801
+ interface OidcProfile {
802
+ name?: string | undefined;
803
+ givenName?: string | undefined;
804
+ familyName?: string | undefined;
805
+ phone?: string | undefined;
806
+ email?: string | undefined;
807
+ }
808
+ interface OidcSignIn {
809
+ id: string;
810
+ idToken: string;
811
+ expiresAt: string;
812
+ profile: OidcProfile;
813
+ }
814
+ interface AccountMethods {
815
+ 'dash.account.signIn': {
816
+ params: {
817
+ mode: SignInMode;
818
+ nonce: string;
819
+ scopes?: OidcScope[];
820
+ };
821
+ result: SimpleSignIn | OidcSignIn;
822
+ };
823
+ }
824
+ /**
825
+ * Signs the person in to the dot with their Dash account. Needs the `account` permission.
826
+ *
827
+ * With `mode: 'simple'`, resolves with their full name, their phone number or email address, and a
828
+ * token that names them in this dot. With `mode: 'oidc'`, OpenID Connect, it will resolve with an ID
829
+ * token for the dot's server; until Dash has it, it rejects with `unsupported`.
830
+ *
831
+ * Rejects with `invalid` for a nonce longer than 128 characters, with `unsupported` for a mode this
832
+ * Dash doesn't have, and with `failed` when no one is signed in or Dash can't reach Monime.
833
+ * @since 1.0
834
+ */
835
+ declare function signIn(options: SimpleSignInOptions, callOptions?: CallOptions): DashRequest<SimpleSignIn>;
836
+ declare function signIn(options: OidcSignInOptions, callOptions?: CallOptions): DashRequest<OidcSignIn>;
837
+ //#endregion
838
+ //#region src/api-versions.d.ts
839
+ export declare const DASH_API_VERSION = "1.0";
840
+ export declare const DASH_API_SINCE: {
841
+ readonly 'account.signIn': "1.0";
842
+ readonly 'contacts.pickPhone': "1.0";
843
+ readonly 'crypto.hmac': "1.0";
844
+ readonly 'crypto.randomBytes': "1.0";
845
+ readonly 'crypto.randomUUID': "1.0";
846
+ readonly 'crypto.sha256': "1.0";
847
+ readonly 'crypto.sha512': "1.0";
848
+ readonly 'dot.close': "1.0";
849
+ readonly 'media.pickFile': "1.0";
850
+ readonly 'media.pickPhoto': "1.0";
851
+ readonly 'media.scanCode': "1.0";
852
+ readonly 'network.http.download': "1.0";
853
+ readonly 'network.http.request': "1.0";
854
+ readonly 'network.http.upload': "1.0";
855
+ readonly 'network.status': "1.0";
856
+ readonly 'storage.cache.clear': "1.0";
857
+ readonly 'storage.cache.exists': "1.0";
858
+ readonly 'storage.cache.get': "1.0";
859
+ readonly 'storage.cache.keys': "1.0";
860
+ readonly 'storage.cache.remove': "1.0";
861
+ readonly 'storage.cache.set': "1.0";
862
+ readonly 'storage.file.copy': "1.0";
863
+ readonly 'storage.file.createFolder': "1.0";
864
+ readonly 'storage.file.list': "1.0";
865
+ readonly 'storage.file.move': "1.0";
866
+ readonly 'storage.file.open': "1.0";
867
+ readonly 'storage.file.read': "1.0";
868
+ readonly 'storage.file.remove': "1.0";
869
+ readonly 'storage.file.save': "1.0";
870
+ readonly 'storage.file.stat': "1.0";
871
+ readonly 'storage.file.usage': "1.0";
872
+ readonly 'storage.file.write': "1.0";
873
+ readonly 'storage.secret.clear': "1.0";
874
+ readonly 'storage.secret.get': "1.0";
875
+ readonly 'storage.secret.remove': "1.0";
876
+ readonly 'storage.secret.set': "1.0";
877
+ readonly 'system.brightness': "1.0";
878
+ readonly 'system.copyText': "1.0";
879
+ readonly 'system.delay': "1.0";
880
+ readonly 'system.dial': "1.0";
881
+ readonly 'system.info': "1.0";
882
+ readonly 'system.keepAwake': "1.0";
883
+ readonly 'system.openUrl': "1.0";
884
+ readonly 'system.share': "1.0";
885
+ readonly 'system.torch': "1.0";
886
+ readonly 'system.vibrate': "1.0";
887
+ readonly 'ui.alert': "1.0";
888
+ readonly 'ui.pickDate': "1.0";
889
+ readonly 'ui.pickTime': "1.0";
890
+ };
891
+ type DashFeature = keyof typeof DASH_API_SINCE;
892
+ export declare function useHostDashApiVersions(versions: readonly string[]): void;
893
+ export declare function warnAboveDashApiVersion(minApiVersion: string | undefined): void;
894
+ /**
895
+ * Whether the Dash the dot runs in has `feature`: a call, such as "contacts.pickPhone", or a field
896
+ * added to a call later. Check it before using one that's newer than the dot's minApiVersion.
897
+ * @since 1.0
898
+ */
899
+ declare function supports(feature: DashFeature): boolean;
900
+ //#endregion
901
+ //#region src/utils/encoding.d.ts
902
+ declare const base64: {
903
+ encode(text: string): string;
904
+ decode(encoded: string): string;
905
+ };
906
+ declare const hex: {
907
+ encode(text: string): string;
908
+ decode(encoded: string): string;
909
+ };
910
+ declare namespace index_d_exports {
911
+ export { base64, hex };
912
+ }
309
913
  //#endregion
310
914
  //#region src/tracked.d.ts
311
915
  export declare function tracked<Group extends object>(group: Group, track: (request: DashRequest<unknown>) => void): Group;
312
916
  //#endregion
917
+ //#region src/errors.d.ts
918
+ type DashErrorWith<Code extends HostErrorCode> = HostError & {
919
+ readonly code: Code;
920
+ };
921
+ export declare function isDashError<Code extends HostErrorCode>(error: unknown, ...codes: Code[]): error is DashErrorWith<Code>;
922
+ export declare function errorMessage(error: unknown): string;
923
+ export declare function unlessCancelled<Result>(call: PromiseLike<Result>): Promise<Result | undefined>;
924
+ //#endregion
925
+ //#region src/latest.d.ts
926
+ export declare function latest(): <Result>(call: DashRequest<Result>) => DashRequest<Result>;
927
+ export declare function debounce(milliseconds: number): (dash: Dash) => Promise<boolean>;
928
+ //#endregion
313
929
  //#region src/index.d.ts
314
930
  export declare const dash: {
315
- ui: typeof index_d_exports$1;
316
- system: typeof index_d_exports$2;
317
- network: typeof index_d_exports$3;
318
- file: typeof index_d_exports;
931
+ ui: typeof index_d_exports$2;
932
+ system: typeof index_d_exports$3;
933
+ network: typeof index_d_exports$5;
934
+ storage: typeof index_d_exports$4;
935
+ media: typeof index_d_exports$6;
936
+ contacts: typeof index_d_exports$9;
937
+ dot: typeof index_d_exports$7;
938
+ account: typeof index_d_exports$1;
939
+ crypto: typeof index_d_exports$8;
940
+ utils: typeof index_d_exports;
941
+ supports: typeof supports;
319
942
  };
320
943
  export type Dash = typeof dash;
321
944
  //#endregion
322
- export { type AlertAction, type AlertOptions, type AlertResult, type CallOptions, type DashMethod, type DashMethods, type DashRequest, type DotFile, type FileEncoding, type FileEntry, type FileMethods, HostError, type HostErrorCode, type HttpDownloadRequest, type HttpDownloadResponse, type HttpMethod, type HttpReadOptions, type HttpRequest, type HttpRequestBody, type HttpResponse, type HttpUploadFile, type HttpUploadRequest, type NetworkMethods, type ReadOptions, type ReplaceOptions, type ShareOptions, type StorageUsage, type SystemMethods, type TorchState, type UIMethods, type VibrateOptions, type VibrationStyle, type WriteOptions };
945
+ export { type AlertAction, type AlertOptions, type AlertResult, type BrightnessLevel, type CacheSetOptions, type CacheValue, type CallOptions, type CodeFormat, type ConnectionType, type ContactsMethods, type CryptoInput, type CryptoOutputOptions, DashError, type DashErrorCode, type DashFeature, type DashMethod, type DashMethods, type DashRequest, type DotFile, type FileEncoding, type FileEntry, type HmacAlgorithm, type HmacOptions, type HttpDownloadRequest, type HttpDownloadResponse, type HttpMethod, type HttpReadOptions, type HttpRequest, type HttpRequestBody, type HttpResponse, type HttpUploadFile, type HttpUploadRequest, type MediaMethods, type NetworkMethods, type NetworkStatus, type OidcProfile, type OidcScope, type OidcSignIn, type OidcSignInOptions, type PhotoSource, type PickDateOptions, type PickFileOptions, type PickPhotoOptions, type PickTimeOptions, type PickedContact, type Platform, type ReadOptions, type ReplaceOptions, type ScannedCode, type ShareOptions, type SignInMode, type SimpleSignIn, type SimpleSignInOptions, type StorageMethods, type StorageUsage, type SystemInfo, type SystemMethods, type UIMethods, type VibrateOptions, type VibrationStyle, type WriteOptions };
323
946
  //# sourceMappingURL=index.d.ts.map