@wailsio/runtime 3.0.0-alpha.9 → 3.0.0-alpha.95
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/android.js +39 -0
- package/{src → dist}/application.js +32 -46
- package/dist/browser.js +20 -0
- package/dist/callable.js +144 -0
- package/dist/calls.js +114 -0
- package/dist/cancellable.js +792 -0
- package/dist/clipboard.js +30 -0
- package/dist/contextmenu.js +83 -0
- package/dist/create.js +99 -0
- package/dist/dialogs.js +69 -0
- package/dist/drag.js +268 -0
- package/dist/environment.js +17 -0
- package/dist/event_types.js +292 -0
- package/dist/events.js +119 -0
- package/dist/flags.js +23 -0
- package/dist/index.js +88 -0
- package/dist/ios.js +28 -0
- package/dist/listener.js +44 -0
- package/dist/nanoid.js +38 -0
- package/dist/plugins/vite.js +64 -0
- package/dist/runtime.js +198 -0
- package/dist/screens.js +58 -0
- package/dist/system.js +158 -0
- package/dist/updater.js +74 -0
- package/dist/utils.js +98 -0
- package/dist/window.js +734 -0
- package/dist/wml.js +179 -0
- package/package.json +71 -26
- package/types/android.d.ts +21 -0
- package/types/application.d.ts +3 -10
- package/types/browser.d.ts +4 -4
- package/types/callable.d.ts +3 -0
- package/types/calls.d.ts +52 -24
- package/types/cancellable.d.ts +433 -0
- package/types/clipboard.d.ts +6 -5
- package/types/contextmenu.d.ts +1 -1
- package/types/create.d.ts +36 -0
- package/types/dialogs.d.ts +132 -20
- package/types/drag.d.ts +1 -4
- package/types/environment.d.ts +8 -0
- package/types/event_types.d.ts +281 -0
- package/types/events.d.ts +70 -33
- package/types/flags.d.ts +3 -3
- package/types/index.d.ts +32 -48
- package/types/ios.d.ts +13 -0
- package/types/listener.d.ts +9 -0
- package/types/nanoid.d.ts +1 -0
- package/types/plugins/vite.d.ts +10 -0
- package/types/runtime.d.ts +61 -22
- package/types/screens.d.ts +64 -7
- package/types/system.d.ts +74 -39
- package/types/updater.d.ts +65 -0
- package/types/utils.d.ts +21 -0
- package/types/window.d.ts +327 -13
- package/types/wml.d.ts +5 -3
- package/src/browser.js +0 -24
- package/src/calls.js +0 -123
- package/src/clipboard.js +0 -35
- package/src/contextmenu.js +0 -98
- package/src/dialogs.js +0 -138
- package/src/drag.js +0 -125
- package/src/events.js +0 -134
- package/src/flags.js +0 -63
- package/src/index.d.ts +0 -136
- package/src/index.js +0 -58
- package/src/runtime.js +0 -122
- package/src/screens.js +0 -45
- package/src/system.js +0 -122
- package/src/window.js +0 -122
- package/src/wml.js +0 -151
- package/tsconfig.json +0 -20
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception class that will be used as rejection reason
|
|
3
|
+
* in case a {@link CancellablePromise} is cancelled successfully.
|
|
4
|
+
*
|
|
5
|
+
* The value of the {@link name} property is the string `"CancelError"`.
|
|
6
|
+
* The value of the {@link cause} property is the cause passed to the cancel method, if any.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CancelError extends Error {
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new `CancelError` instance.
|
|
11
|
+
* @param message - The error message.
|
|
12
|
+
* @param options - Options to be forwarded to the Error constructor.
|
|
13
|
+
*/
|
|
14
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Exception class that will be reported as an unhandled rejection
|
|
18
|
+
* in case a {@link CancellablePromise} rejects after being cancelled,
|
|
19
|
+
* or when the `oncancelled` callback throws or rejects.
|
|
20
|
+
*
|
|
21
|
+
* The value of the {@link name} property is the string `"CancelledRejectionError"`.
|
|
22
|
+
* The value of the {@link cause} property is the reason the promise rejected with.
|
|
23
|
+
*
|
|
24
|
+
* Because the original promise was cancelled,
|
|
25
|
+
* a wrapper promise will be passed to the unhandled rejection listener instead.
|
|
26
|
+
* The {@link promise} property holds a reference to the original promise.
|
|
27
|
+
*/
|
|
28
|
+
export declare class CancelledRejectionError extends Error {
|
|
29
|
+
/**
|
|
30
|
+
* Holds a reference to the promise that was cancelled and then rejected.
|
|
31
|
+
*/
|
|
32
|
+
promise: CancellablePromise<unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Constructs a new `CancelledRejectionError` instance.
|
|
35
|
+
* @param promise - The promise that caused the error originally.
|
|
36
|
+
* @param reason - The rejection reason.
|
|
37
|
+
* @param info - An optional informative message specifying the circumstances in which the error was thrown.
|
|
38
|
+
* Defaults to the string `"Unhandled rejection in cancelled promise."`.
|
|
39
|
+
*/
|
|
40
|
+
constructor(promise: CancellablePromise<unknown>, reason?: any, info?: string);
|
|
41
|
+
}
|
|
42
|
+
type CancellablePromiseResolver<T> = (value: T | PromiseLike<T> | CancellablePromiseLike<T>) => void;
|
|
43
|
+
type CancellablePromiseRejector = (reason?: any) => void;
|
|
44
|
+
type CancellablePromiseCanceller = (cause?: any) => void | PromiseLike<void>;
|
|
45
|
+
type CancellablePromiseExecutor<T> = (resolve: CancellablePromiseResolver<T>, reject: CancellablePromiseRejector) => void;
|
|
46
|
+
export interface CancellablePromiseLike<T> {
|
|
47
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1> | CancellablePromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2> | CancellablePromiseLike<TResult2>) | undefined | null): CancellablePromiseLike<TResult1 | TResult2>;
|
|
48
|
+
cancel(cause?: any): void | PromiseLike<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Wraps a cancellable promise along with its resolution methods.
|
|
52
|
+
* The `oncancelled` field will be null initially but may be set to provide a custom cancellation function.
|
|
53
|
+
*/
|
|
54
|
+
export interface CancellablePromiseWithResolvers<T> {
|
|
55
|
+
promise: CancellablePromise<T>;
|
|
56
|
+
resolve: CancellablePromiseResolver<T>;
|
|
57
|
+
reject: CancellablePromiseRejector;
|
|
58
|
+
oncancelled: CancellablePromiseCanceller | null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A promise with an attached method for cancelling long-running operations (see {@link CancellablePromise#cancel}).
|
|
62
|
+
* Cancellation can optionally be bound to an {@link AbortSignal}
|
|
63
|
+
* for better composability (see {@link CancellablePromise#cancelOn}).
|
|
64
|
+
*
|
|
65
|
+
* Cancelling a pending promise will result in an immediate rejection
|
|
66
|
+
* with an instance of {@link CancelError} as reason,
|
|
67
|
+
* but whoever started the promise will be responsible
|
|
68
|
+
* for actually aborting the underlying operation.
|
|
69
|
+
* To this purpose, the constructor and all chaining methods
|
|
70
|
+
* accept optional cancellation callbacks.
|
|
71
|
+
*
|
|
72
|
+
* If a `CancellablePromise` still resolves after having been cancelled,
|
|
73
|
+
* the result will be discarded. If it rejects, the reason
|
|
74
|
+
* will be reported as an unhandled rejection,
|
|
75
|
+
* wrapped in a {@link CancelledRejectionError} instance.
|
|
76
|
+
* To facilitate the handling of cancellation requests,
|
|
77
|
+
* cancelled `CancellablePromise`s will _not_ report unhandled `CancelError`s
|
|
78
|
+
* whose `cause` field is the same as the one with which the current promise was cancelled.
|
|
79
|
+
*
|
|
80
|
+
* All usual promise methods are defined and return a `CancellablePromise`
|
|
81
|
+
* whose cancel method will cancel the parent operation as well, propagating the cancellation reason
|
|
82
|
+
* upwards through promise chains.
|
|
83
|
+
* Conversely, cancelling a promise will not automatically cancel dependent promises downstream:
|
|
84
|
+
* ```ts
|
|
85
|
+
* let root = new CancellablePromise((resolve, reject) => { ... });
|
|
86
|
+
* let child1 = root.then(() => { ... });
|
|
87
|
+
* let child2 = child1.then(() => { ... });
|
|
88
|
+
* let child3 = root.catch(() => { ... });
|
|
89
|
+
* child1.cancel(); // Cancels child1 and root, but not child2 or child3
|
|
90
|
+
* ```
|
|
91
|
+
* Cancelling a promise that has already settled is safe and has no consequence.
|
|
92
|
+
*
|
|
93
|
+
* The `cancel` method returns a promise that _always fulfills_
|
|
94
|
+
* after the whole chain has processed the cancel request
|
|
95
|
+
* and all attached callbacks up to that moment have run.
|
|
96
|
+
*
|
|
97
|
+
* All ES2024 promise methods (static and instance) are defined on CancellablePromise,
|
|
98
|
+
* but actual availability may vary with OS/webview version.
|
|
99
|
+
*
|
|
100
|
+
* In line with the proposal at https://github.com/tc39/proposal-rm-builtin-subclassing,
|
|
101
|
+
* `CancellablePromise` does not support transparent subclassing.
|
|
102
|
+
* Extenders should take care to provide their own method implementations.
|
|
103
|
+
* This might be reconsidered in case the proposal is retired.
|
|
104
|
+
*
|
|
105
|
+
* CancellablePromise is a wrapper around the DOM Promise object
|
|
106
|
+
* and is compliant with the [Promises/A+ specification](https://promisesaplus.com/)
|
|
107
|
+
* (it passes the [compliance suite](https://github.com/promises-aplus/promises-tests))
|
|
108
|
+
* if so is the underlying implementation.
|
|
109
|
+
*/
|
|
110
|
+
export declare class CancellablePromise<T> extends Promise<T> implements PromiseLike<T>, CancellablePromiseLike<T> {
|
|
111
|
+
/**
|
|
112
|
+
* Creates a new `CancellablePromise`.
|
|
113
|
+
*
|
|
114
|
+
* @param executor - A callback used to initialize the promise. This callback is passed two arguments:
|
|
115
|
+
* a `resolve` callback used to resolve the promise with a value
|
|
116
|
+
* or the result of another promise (possibly cancellable),
|
|
117
|
+
* and a `reject` callback used to reject the promise with a provided reason or error.
|
|
118
|
+
* If the value provided to the `resolve` callback is a thenable _and_ cancellable object
|
|
119
|
+
* (it has a `then` _and_ a `cancel` method),
|
|
120
|
+
* cancellation requests will be forwarded to that object and the oncancelled will not be invoked anymore.
|
|
121
|
+
* If any one of the two callbacks is called _after_ the promise has been cancelled,
|
|
122
|
+
* the provided values will be cancelled and resolved as usual,
|
|
123
|
+
* but their results will be discarded.
|
|
124
|
+
* However, if the resolution process ultimately ends up in a rejection
|
|
125
|
+
* that is not due to cancellation, the rejection reason
|
|
126
|
+
* will be wrapped in a {@link CancelledRejectionError}
|
|
127
|
+
* and bubbled up as an unhandled rejection.
|
|
128
|
+
* @param oncancelled - It is the caller's responsibility to ensure that any operation
|
|
129
|
+
* started by the executor is properly halted upon cancellation.
|
|
130
|
+
* This optional callback can be used to that purpose.
|
|
131
|
+
* It will be called _synchronously_ with a cancellation cause
|
|
132
|
+
* when cancellation is requested, _after_ the promise has already rejected
|
|
133
|
+
* with a {@link CancelError}, but _before_
|
|
134
|
+
* any {@link then}/{@link catch}/{@link finally} callback runs.
|
|
135
|
+
* If the callback returns a thenable, the promise returned from {@link cancel}
|
|
136
|
+
* will only fulfill after the former has settled.
|
|
137
|
+
* Unhandled exceptions or rejections from the callback will be wrapped
|
|
138
|
+
* in a {@link CancelledRejectionError} and bubbled up as unhandled rejections.
|
|
139
|
+
* If the `resolve` callback is called before cancellation with a cancellable promise,
|
|
140
|
+
* cancellation requests on this promise will be diverted to that promise,
|
|
141
|
+
* and the original `oncancelled` callback will be discarded.
|
|
142
|
+
*/
|
|
143
|
+
constructor(executor: CancellablePromiseExecutor<T>, oncancelled?: CancellablePromiseCanceller);
|
|
144
|
+
/**
|
|
145
|
+
* Cancels immediately the execution of the operation associated with this promise.
|
|
146
|
+
* The promise rejects with a {@link CancelError} instance as reason,
|
|
147
|
+
* with the {@link CancelError#cause} property set to the given argument, if any.
|
|
148
|
+
*
|
|
149
|
+
* Has no effect if called after the promise has already settled;
|
|
150
|
+
* repeated calls in particular are safe, but only the first one
|
|
151
|
+
* will set the cancellation cause.
|
|
152
|
+
*
|
|
153
|
+
* The `CancelError` exception _need not_ be handled explicitly _on the promises that are being cancelled:_
|
|
154
|
+
* cancelling a promise with no attached rejection handler does not trigger an unhandled rejection event.
|
|
155
|
+
* Therefore, the following idioms are all equally correct:
|
|
156
|
+
* ```ts
|
|
157
|
+
* new CancellablePromise((resolve, reject) => { ... }).cancel();
|
|
158
|
+
* new CancellablePromise((resolve, reject) => { ... }).then(...).cancel();
|
|
159
|
+
* new CancellablePromise((resolve, reject) => { ... }).then(...).catch(...).cancel();
|
|
160
|
+
* ```
|
|
161
|
+
* Whenever some cancelled promise in a chain rejects with a `CancelError`
|
|
162
|
+
* with the same cancellation cause as itself, the error will be discarded silently.
|
|
163
|
+
* However, the `CancelError` _will still be delivered_ to all attached rejection handlers
|
|
164
|
+
* added by {@link then} and related methods:
|
|
165
|
+
* ```ts
|
|
166
|
+
* let cancellable = new CancellablePromise((resolve, reject) => { ... });
|
|
167
|
+
* cancellable.then(() => { ... }).catch(console.log);
|
|
168
|
+
* cancellable.cancel(); // A CancelError is printed to the console.
|
|
169
|
+
* ```
|
|
170
|
+
* If the `CancelError` is not handled downstream by the time it reaches
|
|
171
|
+
* a _non-cancelled_ promise, it _will_ trigger an unhandled rejection event,
|
|
172
|
+
* just like normal rejections would:
|
|
173
|
+
* ```ts
|
|
174
|
+
* let cancellable = new CancellablePromise((resolve, reject) => { ... });
|
|
175
|
+
* let chained = cancellable.then(() => { ... }).then(() => { ... }); // No catch...
|
|
176
|
+
* cancellable.cancel(); // Unhandled rejection event on chained!
|
|
177
|
+
* ```
|
|
178
|
+
* Therefore, it is important to either cancel whole promise chains from their tail,
|
|
179
|
+
* as shown in the correct idioms above, or take care of handling errors everywhere.
|
|
180
|
+
*
|
|
181
|
+
* @returns A cancellable promise that _fulfills_ after the cancel callback (if any)
|
|
182
|
+
* and all handlers attached up to the call to cancel have run.
|
|
183
|
+
* If the cancel callback returns a thenable, the promise returned by `cancel`
|
|
184
|
+
* will also wait for that thenable to settle.
|
|
185
|
+
* This enables callers to wait for the cancelled operation to terminate
|
|
186
|
+
* without being forced to handle potential errors at the call site.
|
|
187
|
+
* ```ts
|
|
188
|
+
* cancellable.cancel().then(() => {
|
|
189
|
+
* // Cleanup finished, it's safe to do something else.
|
|
190
|
+
* }, (err) => {
|
|
191
|
+
* // Unreachable: the promise returned from cancel will never reject.
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
* Note that the returned promise will _not_ handle implicitly any rejection
|
|
195
|
+
* that might have occurred already in the cancelled chain.
|
|
196
|
+
* It will just track whether registered handlers have been executed or not.
|
|
197
|
+
* Therefore, unhandled rejections will never be silently handled by calling cancel.
|
|
198
|
+
*/
|
|
199
|
+
cancel(cause?: any): CancellablePromise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Binds promise cancellation to the abort event of the given {@link AbortSignal}.
|
|
202
|
+
* If the signal has already aborted, the promise will be cancelled immediately.
|
|
203
|
+
* When either condition is verified, the cancellation cause will be set
|
|
204
|
+
* to the signal's abort reason (see {@link AbortSignal#reason}).
|
|
205
|
+
*
|
|
206
|
+
* Has no effect if called (or if the signal aborts) _after_ the promise has already settled.
|
|
207
|
+
* Only the first signal to abort will set the cancellation cause.
|
|
208
|
+
*
|
|
209
|
+
* For more details about the cancellation process,
|
|
210
|
+
* see {@link cancel} and the `CancellablePromise` constructor.
|
|
211
|
+
*
|
|
212
|
+
* This method enables `await`ing cancellable promises without having
|
|
213
|
+
* to store them for future cancellation, e.g.:
|
|
214
|
+
* ```ts
|
|
215
|
+
* await longRunningOperation().cancelOn(signal);
|
|
216
|
+
* ```
|
|
217
|
+
* instead of:
|
|
218
|
+
* ```ts
|
|
219
|
+
* let promiseToBeCancelled = longRunningOperation();
|
|
220
|
+
* await promiseToBeCancelled;
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @returns This promise, for method chaining.
|
|
224
|
+
*/
|
|
225
|
+
cancelOn(signal: AbortSignal): CancellablePromise<T>;
|
|
226
|
+
/**
|
|
227
|
+
* Attaches callbacks for the resolution and/or rejection of the `CancellablePromise`.
|
|
228
|
+
*
|
|
229
|
+
* The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
|
|
230
|
+
* with the same semantics as the `oncancelled` argument of the constructor.
|
|
231
|
+
* When the parent promise rejects or is cancelled, the `onrejected` callback will run,
|
|
232
|
+
* _even after the returned promise has been cancelled:_
|
|
233
|
+
* in that case, should it reject or throw, the reason will be wrapped
|
|
234
|
+
* in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
|
|
235
|
+
*
|
|
236
|
+
* @param onfulfilled The callback to execute when the Promise is resolved.
|
|
237
|
+
* @param onrejected The callback to execute when the Promise is rejected.
|
|
238
|
+
* @returns A `CancellablePromise` for the completion of whichever callback is executed.
|
|
239
|
+
* The returned promise is hooked up to propagate cancellation requests up the chain, but not down:
|
|
240
|
+
*
|
|
241
|
+
* - if the parent promise is cancelled, the `onrejected` handler will be invoked with a `CancelError`
|
|
242
|
+
* and the returned promise _will resolve regularly_ with its result;
|
|
243
|
+
* - conversely, if the returned promise is cancelled, _the parent promise is cancelled too;_
|
|
244
|
+
* the `onrejected` handler will still be invoked with the parent's `CancelError`,
|
|
245
|
+
* but its result will be discarded
|
|
246
|
+
* and the returned promise will reject with a `CancelError` as well.
|
|
247
|
+
*
|
|
248
|
+
* The promise returned from {@link cancel} will fulfill only after all attached handlers
|
|
249
|
+
* up the entire promise chain have been run.
|
|
250
|
+
*
|
|
251
|
+
* If either callback returns a cancellable promise,
|
|
252
|
+
* cancellation requests will be diverted to it,
|
|
253
|
+
* and the specified `oncancelled` callback will be discarded.
|
|
254
|
+
*/
|
|
255
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1> | CancellablePromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2> | CancellablePromiseLike<TResult2>) | undefined | null, oncancelled?: CancellablePromiseCanceller): CancellablePromise<TResult1 | TResult2>;
|
|
256
|
+
/**
|
|
257
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
258
|
+
*
|
|
259
|
+
* The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
|
|
260
|
+
* with the same semantics as the `oncancelled` argument of the constructor.
|
|
261
|
+
* When the parent promise rejects or is cancelled, the `onrejected` callback will run,
|
|
262
|
+
* _even after the returned promise has been cancelled:_
|
|
263
|
+
* in that case, should it reject or throw, the reason will be wrapped
|
|
264
|
+
* in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
|
|
265
|
+
*
|
|
266
|
+
* It is equivalent to
|
|
267
|
+
* ```ts
|
|
268
|
+
* cancellablePromise.then(undefined, onrejected, oncancelled);
|
|
269
|
+
* ```
|
|
270
|
+
* and the same caveats apply.
|
|
271
|
+
*
|
|
272
|
+
* @returns A Promise for the completion of the callback.
|
|
273
|
+
* Cancellation requests on the returned promise
|
|
274
|
+
* will propagate up the chain to the parent promise,
|
|
275
|
+
* but not in the other direction.
|
|
276
|
+
*
|
|
277
|
+
* The promise returned from {@link cancel} will fulfill only after all attached handlers
|
|
278
|
+
* up the entire promise chain have been run.
|
|
279
|
+
*
|
|
280
|
+
* If `onrejected` returns a cancellable promise,
|
|
281
|
+
* cancellation requests will be diverted to it,
|
|
282
|
+
* and the specified `oncancelled` callback will be discarded.
|
|
283
|
+
* See {@link then} for more details.
|
|
284
|
+
*/
|
|
285
|
+
catch<TResult = never>(onrejected?: ((reason: any) => (PromiseLike<TResult> | TResult)) | undefined | null, oncancelled?: CancellablePromiseCanceller): CancellablePromise<T | TResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Attaches a callback that is invoked when the CancellablePromise is settled (fulfilled or rejected). The
|
|
288
|
+
* resolved value cannot be accessed or modified from the callback.
|
|
289
|
+
* The returned promise will settle in the same state as the original one
|
|
290
|
+
* after the provided callback has completed execution,
|
|
291
|
+
* unless the callback throws or returns a rejecting promise,
|
|
292
|
+
* in which case the returned promise will reject as well.
|
|
293
|
+
*
|
|
294
|
+
* The optional `oncancelled` argument will be invoked when the returned promise is cancelled,
|
|
295
|
+
* with the same semantics as the `oncancelled` argument of the constructor.
|
|
296
|
+
* Once the parent promise settles, the `onfinally` callback will run,
|
|
297
|
+
* _even after the returned promise has been cancelled:_
|
|
298
|
+
* in that case, should it reject or throw, the reason will be wrapped
|
|
299
|
+
* in a {@link CancelledRejectionError} and bubbled up as an unhandled rejection.
|
|
300
|
+
*
|
|
301
|
+
* This method is implemented in terms of {@link then} and the same caveats apply.
|
|
302
|
+
* It is polyfilled, hence available in every OS/webview version.
|
|
303
|
+
*
|
|
304
|
+
* @returns A Promise for the completion of the callback.
|
|
305
|
+
* Cancellation requests on the returned promise
|
|
306
|
+
* will propagate up the chain to the parent promise,
|
|
307
|
+
* but not in the other direction.
|
|
308
|
+
*
|
|
309
|
+
* The promise returned from {@link cancel} will fulfill only after all attached handlers
|
|
310
|
+
* up the entire promise chain have been run.
|
|
311
|
+
*
|
|
312
|
+
* If `onfinally` returns a cancellable promise,
|
|
313
|
+
* cancellation requests will be diverted to it,
|
|
314
|
+
* and the specified `oncancelled` callback will be discarded.
|
|
315
|
+
* See {@link then} for more details.
|
|
316
|
+
*/
|
|
317
|
+
finally(onfinally?: (() => void) | undefined | null, oncancelled?: CancellablePromiseCanceller): CancellablePromise<T>;
|
|
318
|
+
/**
|
|
319
|
+
* Creates a CancellablePromise that is resolved with an array of results
|
|
320
|
+
* when all of the provided Promises resolve, or rejected when any Promise is rejected.
|
|
321
|
+
*
|
|
322
|
+
* Every one of the provided objects that is a thenable _and_ cancellable object
|
|
323
|
+
* will be cancelled when the returned promise is cancelled, with the same cause.
|
|
324
|
+
*
|
|
325
|
+
* @group Static Methods
|
|
326
|
+
*/
|
|
327
|
+
static all<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<Awaited<T>[]>;
|
|
328
|
+
static all<T extends readonly unknown[] | []>(values: T): CancellablePromise<{
|
|
329
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
330
|
+
}>;
|
|
331
|
+
/**
|
|
332
|
+
* Creates a CancellablePromise that is resolved with an array of results
|
|
333
|
+
* when all of the provided Promises resolve or reject.
|
|
334
|
+
*
|
|
335
|
+
* Every one of the provided objects that is a thenable _and_ cancellable object
|
|
336
|
+
* will be cancelled when the returned promise is cancelled, with the same cause.
|
|
337
|
+
*
|
|
338
|
+
* @group Static Methods
|
|
339
|
+
*/
|
|
340
|
+
static allSettled<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<PromiseSettledResult<Awaited<T>>[]>;
|
|
341
|
+
static allSettled<T extends readonly unknown[] | []>(values: T): CancellablePromise<{
|
|
342
|
+
-readonly [P in keyof T]: PromiseSettledResult<Awaited<T[P]>>;
|
|
343
|
+
}>;
|
|
344
|
+
/**
|
|
345
|
+
* The any function returns a promise that is fulfilled by the first given promise to be fulfilled,
|
|
346
|
+
* or rejected with an AggregateError containing an array of rejection reasons
|
|
347
|
+
* if all of the given promises are rejected.
|
|
348
|
+
* It resolves all elements of the passed iterable to promises as it runs this algorithm.
|
|
349
|
+
*
|
|
350
|
+
* Every one of the provided objects that is a thenable _and_ cancellable object
|
|
351
|
+
* will be cancelled when the returned promise is cancelled, with the same cause.
|
|
352
|
+
*
|
|
353
|
+
* @group Static Methods
|
|
354
|
+
*/
|
|
355
|
+
static any<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<Awaited<T>>;
|
|
356
|
+
static any<T extends readonly unknown[] | []>(values: T): CancellablePromise<Awaited<T[number]>>;
|
|
357
|
+
/**
|
|
358
|
+
* Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
|
|
359
|
+
*
|
|
360
|
+
* Every one of the provided objects that is a thenable _and_ cancellable object
|
|
361
|
+
* will be cancelled when the returned promise is cancelled, with the same cause.
|
|
362
|
+
*
|
|
363
|
+
* @group Static Methods
|
|
364
|
+
*/
|
|
365
|
+
static race<T>(values: Iterable<T | PromiseLike<T>>): CancellablePromise<Awaited<T>>;
|
|
366
|
+
static race<T extends readonly unknown[] | []>(values: T): CancellablePromise<Awaited<T[number]>>;
|
|
367
|
+
/**
|
|
368
|
+
* Creates a new cancelled CancellablePromise for the provided cause.
|
|
369
|
+
*
|
|
370
|
+
* @group Static Methods
|
|
371
|
+
*/
|
|
372
|
+
static cancel<T = never>(cause?: any): CancellablePromise<T>;
|
|
373
|
+
/**
|
|
374
|
+
* Creates a new CancellablePromise that cancels
|
|
375
|
+
* after the specified timeout, with the provided cause.
|
|
376
|
+
*
|
|
377
|
+
* If the {@link AbortSignal.timeout} factory method is available,
|
|
378
|
+
* it is used to base the timeout on _active_ time rather than _elapsed_ time.
|
|
379
|
+
* Otherwise, `timeout` falls back to {@link setTimeout}.
|
|
380
|
+
*
|
|
381
|
+
* @group Static Methods
|
|
382
|
+
*/
|
|
383
|
+
static timeout<T = never>(milliseconds: number, cause?: any): CancellablePromise<T>;
|
|
384
|
+
/**
|
|
385
|
+
* Creates a new CancellablePromise that resolves after the specified timeout.
|
|
386
|
+
* The returned promise can be cancelled without consequences.
|
|
387
|
+
*
|
|
388
|
+
* @group Static Methods
|
|
389
|
+
*/
|
|
390
|
+
static sleep(milliseconds: number): CancellablePromise<void>;
|
|
391
|
+
/**
|
|
392
|
+
* Creates a new CancellablePromise that resolves after
|
|
393
|
+
* the specified timeout, with the provided value.
|
|
394
|
+
* The returned promise can be cancelled without consequences.
|
|
395
|
+
*
|
|
396
|
+
* @group Static Methods
|
|
397
|
+
*/
|
|
398
|
+
static sleep<T>(milliseconds: number, value: T): CancellablePromise<T>;
|
|
399
|
+
/**
|
|
400
|
+
* Creates a new rejected CancellablePromise for the provided reason.
|
|
401
|
+
*
|
|
402
|
+
* @group Static Methods
|
|
403
|
+
*/
|
|
404
|
+
static reject<T = never>(reason?: any): CancellablePromise<T>;
|
|
405
|
+
/**
|
|
406
|
+
* Creates a new resolved CancellablePromise.
|
|
407
|
+
*
|
|
408
|
+
* @group Static Methods
|
|
409
|
+
*/
|
|
410
|
+
static resolve(): CancellablePromise<void>;
|
|
411
|
+
/**
|
|
412
|
+
* Creates a new resolved CancellablePromise for the provided value.
|
|
413
|
+
*
|
|
414
|
+
* @group Static Methods
|
|
415
|
+
*/
|
|
416
|
+
static resolve<T>(value: T): CancellablePromise<Awaited<T>>;
|
|
417
|
+
/**
|
|
418
|
+
* Creates a new resolved CancellablePromise for the provided value.
|
|
419
|
+
*
|
|
420
|
+
* @group Static Methods
|
|
421
|
+
*/
|
|
422
|
+
static resolve<T>(value: T | PromiseLike<T>): CancellablePromise<Awaited<T>>;
|
|
423
|
+
/**
|
|
424
|
+
* Creates a new CancellablePromise and returns it in an object, along with its resolve and reject functions
|
|
425
|
+
* and a getter/setter for the cancellation callback.
|
|
426
|
+
*
|
|
427
|
+
* This method is polyfilled, hence available in every OS/webview version.
|
|
428
|
+
*
|
|
429
|
+
* @group Static Methods
|
|
430
|
+
*/
|
|
431
|
+
static withResolvers<T>(): CancellablePromiseWithResolvers<T>;
|
|
432
|
+
}
|
|
433
|
+
export {};
|
package/types/clipboard.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sets the text to the Clipboard.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @return
|
|
4
|
+
* @param text - The text to be set to the Clipboard.
|
|
5
|
+
* @return A Promise that resolves when the operation is successful.
|
|
6
6
|
*/
|
|
7
|
-
export function SetText(text: string): Promise<
|
|
7
|
+
export declare function SetText(text: string): Promise<void>;
|
|
8
8
|
/**
|
|
9
9
|
* Get the Clipboard text
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* @returns A promise that resolves with the text from the Clipboard.
|
|
11
12
|
*/
|
|
12
|
-
export function Text(): Promise<string>;
|
|
13
|
+
export declare function Text(): Promise<string>;
|
package/types/contextmenu.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Any is a dummy creation function for simple or unknown types.
|
|
3
|
+
*/
|
|
4
|
+
export declare function Any<T = any>(source: any): T;
|
|
5
|
+
/**
|
|
6
|
+
* ByteSlice is a creation function that replaces
|
|
7
|
+
* null strings with empty strings.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ByteSlice(source: any): string;
|
|
10
|
+
/**
|
|
11
|
+
* Array takes a creation function for an arbitrary type
|
|
12
|
+
* and returns an in-place creation function for an array
|
|
13
|
+
* whose elements are of that type.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Array<T = any>(element: (source: any) => T): (source: any) => T[];
|
|
16
|
+
/**
|
|
17
|
+
* Map takes creation functions for two arbitrary types
|
|
18
|
+
* and returns an in-place creation function for an object
|
|
19
|
+
* whose keys and values are of those types.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Map<K extends PropertyKey = any, V = any>(key: (source: any) => K, value: (source: any) => V): (source: any) => Record<K, V>;
|
|
22
|
+
/**
|
|
23
|
+
* Nullable takes a creation function for an arbitrary type
|
|
24
|
+
* and returns a creation function for a nullable value of that type.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Nullable<T = any>(element: (source: any) => T): (source: any) => (T | null);
|
|
27
|
+
/**
|
|
28
|
+
* Struct takes an object mapping field names to creation functions
|
|
29
|
+
* and returns an in-place creation function for a struct.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Struct(createField: Record<string, (source: any) => any>): <U extends Record<string, any> = any>(source: any) => U;
|
|
32
|
+
/**
|
|
33
|
+
* Maps known event names to creation functions for their data types.
|
|
34
|
+
* Will be monkey-patched by the binding generator.
|
|
35
|
+
*/
|
|
36
|
+
export declare const Events: Record<string, (source: any) => any>;
|
package/types/dialogs.d.ts
CHANGED
|
@@ -1,28 +1,140 @@
|
|
|
1
|
+
export interface OpenFileDialogOptions {
|
|
2
|
+
/** Indicates if directories can be chosen. */
|
|
3
|
+
CanChooseDirectories?: boolean;
|
|
4
|
+
/** Indicates if files can be chosen. */
|
|
5
|
+
CanChooseFiles?: boolean;
|
|
6
|
+
/** Indicates if directories can be created. */
|
|
7
|
+
CanCreateDirectories?: boolean;
|
|
8
|
+
/** Indicates if hidden files should be shown. */
|
|
9
|
+
ShowHiddenFiles?: boolean;
|
|
10
|
+
/** Indicates if aliases should be resolved. */
|
|
11
|
+
ResolvesAliases?: boolean;
|
|
12
|
+
/** Indicates if multiple selection is allowed. */
|
|
13
|
+
AllowsMultipleSelection?: boolean;
|
|
14
|
+
/** Indicates if the extension should be hidden. */
|
|
15
|
+
HideExtension?: boolean;
|
|
16
|
+
/** Indicates if hidden extensions can be selected. */
|
|
17
|
+
CanSelectHiddenExtension?: boolean;
|
|
18
|
+
/** Indicates if file packages should be treated as directories. */
|
|
19
|
+
TreatsFilePackagesAsDirectories?: boolean;
|
|
20
|
+
/** Indicates if other file types are allowed. */
|
|
21
|
+
AllowsOtherFiletypes?: boolean;
|
|
22
|
+
/** Array of file filters. */
|
|
23
|
+
Filters?: FileFilter[];
|
|
24
|
+
/** Title of the dialog. */
|
|
25
|
+
Title?: string;
|
|
26
|
+
/** Message to show in the dialog. */
|
|
27
|
+
Message?: string;
|
|
28
|
+
/** Text to display on the button. */
|
|
29
|
+
ButtonText?: string;
|
|
30
|
+
/** Directory to open in the dialog. */
|
|
31
|
+
Directory?: string;
|
|
32
|
+
/** Indicates if the dialog should appear detached from the main window. */
|
|
33
|
+
Detached?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface SaveFileDialogOptions {
|
|
36
|
+
/** Default filename to use in the dialog. */
|
|
37
|
+
Filename?: string;
|
|
38
|
+
/** Indicates if directories can be chosen. */
|
|
39
|
+
CanChooseDirectories?: boolean;
|
|
40
|
+
/** Indicates if files can be chosen. */
|
|
41
|
+
CanChooseFiles?: boolean;
|
|
42
|
+
/** Indicates if directories can be created. */
|
|
43
|
+
CanCreateDirectories?: boolean;
|
|
44
|
+
/** Indicates if hidden files should be shown. */
|
|
45
|
+
ShowHiddenFiles?: boolean;
|
|
46
|
+
/** Indicates if aliases should be resolved. */
|
|
47
|
+
ResolvesAliases?: boolean;
|
|
48
|
+
/** Indicates if the extension should be hidden. */
|
|
49
|
+
HideExtension?: boolean;
|
|
50
|
+
/** Indicates if hidden extensions can be selected. */
|
|
51
|
+
CanSelectHiddenExtension?: boolean;
|
|
52
|
+
/** Indicates if file packages should be treated as directories. */
|
|
53
|
+
TreatsFilePackagesAsDirectories?: boolean;
|
|
54
|
+
/** Indicates if other file types are allowed. */
|
|
55
|
+
AllowsOtherFiletypes?: boolean;
|
|
56
|
+
/** Array of file filters. */
|
|
57
|
+
Filters?: FileFilter[];
|
|
58
|
+
/** Title of the dialog. */
|
|
59
|
+
Title?: string;
|
|
60
|
+
/** Message to show in the dialog. */
|
|
61
|
+
Message?: string;
|
|
62
|
+
/** Text to display on the button. */
|
|
63
|
+
ButtonText?: string;
|
|
64
|
+
/** Directory to open in the dialog. */
|
|
65
|
+
Directory?: string;
|
|
66
|
+
/** Indicates if the dialog should appear detached from the main window. */
|
|
67
|
+
Detached?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface MessageDialogOptions {
|
|
70
|
+
/** The title of the dialog window. */
|
|
71
|
+
Title?: string;
|
|
72
|
+
/** The main message to show in the dialog. */
|
|
73
|
+
Message?: string;
|
|
74
|
+
/** Array of button options to show in the dialog. */
|
|
75
|
+
Buttons?: Button[];
|
|
76
|
+
/** True if the dialog should appear detached from the main window (if applicable). */
|
|
77
|
+
Detached?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface Button {
|
|
80
|
+
/** Text that appears within the button. */
|
|
81
|
+
Label?: string;
|
|
82
|
+
/** True if the button should cancel an operation when clicked. */
|
|
83
|
+
IsCancel?: boolean;
|
|
84
|
+
/** True if the button should be the default action when the user presses enter. */
|
|
85
|
+
IsDefault?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface FileFilter {
|
|
88
|
+
/** Display name for the filter, it could be "Text Files", "Images" etc. */
|
|
89
|
+
DisplayName?: string;
|
|
90
|
+
/** Pattern to match for the filter, e.g. "*.txt;*.md" for text markdown files. */
|
|
91
|
+
Pattern?: string;
|
|
92
|
+
}
|
|
1
93
|
/**
|
|
2
|
-
*
|
|
94
|
+
* Presents an info dialog.
|
|
3
95
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @
|
|
6
|
-
|
|
96
|
+
* @param options - Dialog options
|
|
97
|
+
* @returns A promise that resolves with the label of the chosen button.
|
|
98
|
+
*/
|
|
99
|
+
export declare function Info(options: MessageDialogOptions): Promise<string>;
|
|
100
|
+
/**
|
|
101
|
+
* Presents a warning dialog.
|
|
102
|
+
*
|
|
103
|
+
* @param options - Dialog options.
|
|
104
|
+
* @returns A promise that resolves with the label of the chosen button.
|
|
105
|
+
*/
|
|
106
|
+
export declare function Warning(options: MessageDialogOptions): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Presents an error dialog.
|
|
7
109
|
*
|
|
8
|
-
* @
|
|
110
|
+
* @param options - Dialog options.
|
|
111
|
+
* @returns A promise that resolves with the label of the chosen button.
|
|
9
112
|
*/
|
|
10
|
-
export function
|
|
113
|
+
export declare function Error(options: MessageDialogOptions): Promise<string>;
|
|
11
114
|
/**
|
|
12
|
-
*
|
|
115
|
+
* Presents a question dialog.
|
|
13
116
|
*
|
|
14
|
-
* @param
|
|
15
|
-
* @
|
|
117
|
+
* @param options - Dialog options.
|
|
118
|
+
* @returns A promise that resolves with the label of the chosen button.
|
|
119
|
+
*/
|
|
120
|
+
export declare function Question(options: MessageDialogOptions): Promise<string>;
|
|
121
|
+
/**
|
|
122
|
+
* Presents a file selection dialog to pick one or more files to open.
|
|
123
|
+
*
|
|
124
|
+
* @param options - Dialog options.
|
|
125
|
+
* @returns Selected file or list of files, or a blank string/empty list if no file has been selected.
|
|
126
|
+
*/
|
|
127
|
+
export declare function OpenFile(options: OpenFileDialogOptions & {
|
|
128
|
+
AllowsMultipleSelection: true;
|
|
129
|
+
}): Promise<string[]>;
|
|
130
|
+
export declare function OpenFile(options: OpenFileDialogOptions & {
|
|
131
|
+
AllowsMultipleSelection?: false | undefined;
|
|
132
|
+
}): Promise<string>;
|
|
133
|
+
export declare function OpenFile(options: OpenFileDialogOptions): Promise<string | string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Presents a file selection dialog to pick a file to save.
|
|
16
136
|
*
|
|
17
|
-
* @
|
|
137
|
+
* @param options - Dialog options.
|
|
138
|
+
* @returns Selected file, or a blank string if no file has been selected.
|
|
18
139
|
*/
|
|
19
|
-
export function
|
|
20
|
-
export function Info(options: any): Promise<string>;
|
|
21
|
-
export function Warning(options: any): Promise<string>;
|
|
22
|
-
export function Error(options: any): Promise<string>;
|
|
23
|
-
export function Question(options: any): Promise<string>;
|
|
24
|
-
export function OpenFile(options: any): Promise<string[] | string>;
|
|
25
|
-
export function SaveFile(options: any): Promise<string>;
|
|
26
|
-
export type MessageDialogOptions = any;
|
|
27
|
-
export type OpenDialogOptions = any;
|
|
28
|
-
export type SaveDialogOptions = any;
|
|
140
|
+
export declare function SaveFile(options: SaveFileDialogOptions): Promise<string>;
|
package/types/drag.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when running inside a browser/webview with a DOM available.
|
|
3
|
+
* False under server-side rendering (e.g. `next build` prerendering),
|
|
4
|
+
* where application code may import the runtime module even though no
|
|
5
|
+
* Wails APIs can actually be used (#4679). Modules must not touch
|
|
6
|
+
* `window`/`document` at import time except behind this guard.
|
|
7
|
+
*/
|
|
8
|
+
export declare const hasDOM: boolean;
|